📄 member.h
字号:
/* * Copyright (c) 1996 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement * is hereby granted, provided that the above copyright notice and the * following two paragraphs appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE * UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * * * $Id: member.h,v 1.13 1997/01/15 22:41:30 aswan Exp $ */#ifndef member_h#define member_h#include "config.h"#include "rtp.h"#define LOSS_HISTORY 4class SenderInfo { public: SenderInfo(); virtual ~SenderInfo() {} void loss(u_int32_t loss, u_int32_t expected); u_char loss(void); inline void filtloss(u_char v) { if (count_ == 1) filtloss_ = v; else filtloss_ += (int)(v - filtloss_) >> 2; } inline u_char filtloss(void) const { return u_char((int)filtloss_ * 100 / 256); } inline void jitter(u_int32_t v) { jitter_ = v; } inline u_int32_t jitter() const { return jitter_; } protected: u_int32_t lost_[LOSS_HISTORY]; u_int32_t expected_[LOSS_HISTORY]; int count_; u_char filtloss_; u_int32_t jitter_; int ptr_;};class Member : public TclObject { public: Member(u_int32_t srcid, u_int32_t addr); virtual ~Member(); virtual int command(int argc, const char*const* argv); inline u_int32_t srcid() const { return (srcid_); } inline void srcid(u_int32_t s) { srcid_ = s; } inline u_int32_t addr() const { return (addr_); } inline void addr(u_int32_t s) { addr_ = s; } inline bool locked() const { return (locked_); } inline void locked(bool v) { locked_ = v; } inline bool sender() const { return (sender_); } inline void sender(bool v) { bool isnew = (!sender_ && v); sender_ = v; if (isnew) { Tcl& tcl = Tcl::instance(); tcl.evalf("if [catch {new-sender %s} msg] { puts stderr \"new-sender error: $msg\" }", name() ); } } inline bool ignore() const { return (ignore_); } inline void ignore(bool v) { ignore_ = v; } inline bool active() const { return (active_); } inline void active(bool v) { active_ = v; } inline int pos() const { return (pos_); } inline void pos(int v) { pos_ = v; } inline const char* sdes(int n) { return (sdes_[n]); } inline void sdes(int n, const char* v) { if (sdes_[n] == 0 || strcmp(v, sdes_[n])) { if (sdes_[n]) delete[] sdes_[n]; sdes_[n] = new char[strlen(v) + 1]; strcpy(sdes_[n], v); } } inline u_int32_t val() const { return (val_); } inline void val(u_int32_t v) { val_ = v; } inline u_int32_t badsdes() const { return (badsdes_); } inline void badsdes(int v) { badsdes_ += v; } inline u_int32_t badlen() const { return (badlen_); } inline void badlen(int v) { badlen_ += v; } inline u_int32_t badver() const { return (badver_); } inline void badver(int v) { badver_ += v; } inline u_int32_t badopt() const { return (badopt_); } inline void badopt(int v) { badopt_ += v; } inline time_t ts() const { return (ts_); } inline void ts(time_t v) { ts_ = v; } inline void loss(int n, u_int32_t l, u_int32_t e) { senders_[n].loss(l, e); } inline u_char loss(int n) const { return senders_[n].loss(); } inline void filtloss(int n, u_char v) { senders_[n].filtloss(v); } inline u_char filtloss(int n) { return senders_[n].filtloss(); } inline void jitter(int n, u_int32_t v) { senders_[n].jitter(v); } inline u_int32_t jitter(int n) const { return senders_[n].jitter(); } inline u_int32_t getstat(int s, int n) { switch (s) { case 0: return loss(n); case 1: return filtloss(n); case 2: return jitter(n); } } protected: u_int32_t srcid_; /* rtp global src id (CSRC), net order */ u_int32_t addr_; bool locked_; bool sender_; bool ignore_; bool active_; int pos_; char *sdes_[RTCP_SDES_MAX + 1]; u_int32_t val_; u_int32_t badsdes_; u_int32_t badlen_; u_int32_t badver_; u_int32_t badopt_; time_t ts_; int size_; SenderInfo* senders_; public: Member *next_; /* for sorted list of listeners */ Member *snext_; /* for list of senders */ Member *hlink_; /* for hash table */ Member *mnext_; /* used while finding median */};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -