Bayonne2 / Common C++ 2 Framework: sources.h Source File

Bayonne2 / Common C++ 2 Framework
sources.h
Go to the documentation of this file.
1 // Copyright (C) 2001,2002,2003,2004 Federico Montesino Pouzols <fedemp@altern.org>.
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 //
17 // As a special exception, you may use this file as part of a free software
18 // library without restriction. Specifically, if other files instantiate
19 // templates or use macros or inline functions from this file, or you compile
20 // this file and link it with other files to produce an executable, this
21 // file does not by itself cause the resulting executable to be covered by
22 // the GNU General Public License. This exception does not however
23 // invalidate any other reasons why the executable file might be covered by
24 // the GNU General Public License.
25 //
26 // This exception applies only to the code released under the name GNU
27 // ccRTP. If you copy code from other releases into a copy of GNU
28 // ccRTP, as the General Public License permits, the exception does
29 // not apply to the code that you add in this way. To avoid misleading
30 // anyone as to the status of such modified files, you must delete
31 // this exception notice from them.
32 //
33 // If you write modifications of your own for GNU ccRTP, it is your choice
34 // whether to permit this exception to apply to your modifications.
35 // If you do not wish that, delete this exception notice.
36 //
37 
44 #ifndef CCXX_RTP_SOURCES_H_
45 #define CCXX_RTP_SOURCES_H_
46 
47 #include <string>
48 #include <ccrtp/rtcppkt.h>
49 
50 #ifdef CCXX_NAMESPACES
51 namespace ost {
52 #endif
53 
67  class __EXPORT SDESItemsHolder
68 {
69 public:
70  const std::string&
71  getItem(SDESItemType type) const;
72 
73  inline const std::string&
74   getPRIVPrefix() const
75 { return sdesItems[SDESItemTypeEND]; }
76 
77  void
78  setItem(SDESItemType item, const std::string& val);
79 
80  inline void
81   setPRIVPrefix(const std::string& val)
82  { sdesItems[SDESItemTypeEND] = val; }
83 
84 protected:
85   SDESItemsHolder()
86  { }
87 
88   inline virtual ~SDESItemsHolder()
89  { }
90 
91 private:
92  // SDES items for a participant.
93  // sdesItems[0] (== sdesItems[SDESItemTypeEND]) holds the prefix
94  // value for the PRIV item. The rest of entries hold the
95  // correponding SDES item value.
96   std::string sdesItems[SDESItemTypeLast + 1];
97 };
98 
127  class __EXPORT Participant : private SDESItemsHolder
128 {
129 public:
142  const std::string&
143   getSDESItem(SDESItemType type) const
144 { return SDESItemsHolder::getItem(type); }
145 
153  inline const std::string&
154   getPRIVPrefix() const
155 { return SDESItemsHolder::getPRIVPrefix(); }
156 
162  Participant(const std::string& cname);
163 
164  ~Participant();
165 
166 private:
167   friend class ParticipantHandler;
168 
172  inline void
173   setSDESItem(SDESItemType item, const std::string& val)
174  { SDESItemsHolder::setItem(item,val); }
175 
179  inline void
180   setPRIVPrefix(const std::string val)
181  { SDESItemsHolder::setPRIVPrefix(val); }
182 };
183 
195  class __EXPORT SyncSource
196 {
197 public:
228   typedef enum {
229   stateUnknown,
230   statePrevalid,
231  stateActive,
234  stateInactive,
236  stateLeaving
239  } State;
241 
246  SyncSource(uint32 ssrc);
247 
248  ~SyncSource();
249 
250  State
251   getState() const
252 { return state; }
253 
257   bool isSender() const
258 { return activeSender; }
259 
260   uint32 getID() const
261 { return SSRC; }
262 
270  inline Participant*
271   getParticipant() const
272 { return participant; }
273 
274   tpport_t getDataTransportPort() const
275 { return dataTransportPort; }
276 
277   tpport_t getControlTransportPort() const
278 { return controlTransportPort; }
279 
280   const InetAddress& getNetworkAddress() const
281 { return networkAddress; }
282 
283 protected:
287  SyncSource(const SyncSource& source);
288 
289  SyncSource&
290  operator=(const SyncSource& source);
291 
292 private:
293   friend class SyncSourceHandler;
294 
295  inline void
296   setState(State st)
297  { state = st; }
298 
302  inline void
303   setSender(bool active)
304  { activeSender = active; }
305 
306  inline void
307   setParticipant(Participant& p)
308  { participant = &p; }
309 
310   void setDataTransportPort(tpport_t p)
311  { dataTransportPort = p; }
312 
313   void setControlTransportPort(tpport_t p)
314  { controlTransportPort = p; }
315 
316   void setNetworkAddress(InetAddress addr)
317  { networkAddress = addr; }
318 
319  inline void
320   setLink(void *l)
321  { link = l; }
322 
323   void *getLink() const
324 { return link; }
325 
326  // validity state of this source
327   State state;
328  // 32-bit SSRC identifier.
329   uint32 SSRC;
330  // A valid source not always is active
331   bool activeSender;
332  // The corresponding participant.
333   Participant* participant;
334 
335  // Network protocol address for data and control connection
336  // (both are assumed to be the same).
337   InetAddress networkAddress;
338   tpport_t dataTransportPort;
339   tpport_t controlTransportPort;
340 
341  // Pointer to the SyncSourceLink or similar object in the
342  // service queue. Saves a lot of searches in the membership
343  // table.
344   void* link;
345 };
346 
367  class __EXPORT RTPApplication : private SDESItemsHolder
368 {
369 private:
370  struct ParticipantLink;
371 
372 public:
380  RTPApplication(const std::string& cname);
381 
382  ~RTPApplication();
383 
384  inline void
385   setSDESItem(SDESItemType item, const std::string& val)
386  { SDESItemsHolder::setItem(item,val); }
387 
388  inline void
389   setPRIVPrefix(const std::string& val)
390  { SDESItemsHolder::setPRIVPrefix(val); }
391 
392  const std::string&
393   getSDESItem(SDESItemType item) const
394 { return SDESItemsHolder::getItem(item); }
395 
396  inline const std::string&
397   getPRIVPrefix() const
398 { return SDESItemsHolder::getPRIVPrefix(); }
399 
404   class ParticipantsIterator
405  {
406  public:
407   typedef std::forward_iterator_tag iterator_category;
408   typedef Participant value_type;
409   typedef ptrdiff_t difference_type;
410   typedef const Participant* pointer;
411   typedef const Participant& reference;
412 
413   ParticipantsIterator(ParticipantLink* p = NULL) :
414  link(p)
415  { }
416 
417   ParticipantsIterator(const ParticipantsIterator& pi) :
418  link(pi.link)
419  { }
420 
421   reference operator*() const
422 { return *(link->getParticipant()); }
423 
424   pointer operator->() const
425 { return link->getParticipant(); }
426 
427   ParticipantsIterator& operator++() {
428  link = link->getNext();
429  return *this;
430  }
431 
432   ParticipantsIterator operator++(int) {
433  ParticipantsIterator result(*this);
434  ++(*this);
435  return result;
436  }
437   friend bool operator==(const ParticipantsIterator& l,
438  const ParticipantsIterator& r)
439  { return l.link == r.link; }
440 
441   friend bool operator!=(const ParticipantsIterator& l,
442  const ParticipantsIterator& r)
443  { return l.link != r.link; }
444  private:
445   ParticipantLink *link;
446  };
447 
448   ParticipantsIterator begin()
449  { return ParticipantsIterator(firstPart); }
450 
451   ParticipantsIterator end()
452  { return ParticipantsIterator(NULL); }
453 
454  const Participant*
455  getParticipant(const std::string& cname) const;
456 
457 private:
458   friend class ApplicationHandler;
459 
460   struct ParticipantLink {
461   ParticipantLink(Participant& p,
462  ParticipantLink* l) :
463  participant(&p), next(l)
464  { }
465   inline ~ParticipantLink() { delete participant; }
466   inline Participant* getParticipant() { return participant; }
467   inline ParticipantLink* getPrev() { return prev; }
468   inline ParticipantLink* getNext() { return next; }
469   inline void setPrev(ParticipantLink* l) { prev = l; }
470   inline void setNext(ParticipantLink* l) { next = l; }
471   Participant* participant;
472   ParticipantLink* next, *prev;
473  };
474 
475  void
476  addParticipant(Participant& part);
477 
478  void
479  removeParticipant(ParticipantLink* part);
480 
485  void
486  findCNAME();
487 
489   static const size_t defaultParticipantsNum;
490   Participant** participants;
492   ParticipantLink* firstPart, * lastPart;
493 };
494 
504 __EXPORT RTPApplication& defaultApplication();
505  // sources
507 
508 #ifdef CCXX_NAMESPACES
509 }
510 #endif
511 
512 #endif //CCXX_RTP_SOURCES_H_
513 
RTPApplication::ParticipantsIterator::pointer
const Participant * pointer
Definition: sources.h:410
RTPApplication::ParticipantsIterator::operator!=
friend bool operator!=(const ParticipantsIterator &l, const ParticipantsIterator &r)
Definition: sources.h:441
SyncSource::SSRC
uint32 SSRC
Definition: sources.h:329
RTPApplication::setPRIVPrefix
void setPRIVPrefix(const std::string &val)
Definition: sources.h:389
RTPApplication::lastPart
ParticipantLink * lastPart
Definition: sources.h:492
RTPApplication::getPRIVPrefix
const std::string & getPRIVPrefix() const
Definition: sources.h:397
SyncSource::getDataTransportPort
tpport_t getDataTransportPort() const
Definition: sources.h:274
SDESItemTypeLast
Last defined code.
Definition: rtcppkt.h:79
RTPApplication
An RTP application, holding identifying RTCP SDES item values.
Definition: sources.h:367
SyncSource
Synchronization source in an RTP session.
Definition: sources.h:195
SyncSource::setParticipant
void setParticipant(Participant &p)
Definition: sources.h:307
RTPApplication::ParticipantsIterator::operator++
ParticipantsIterator operator++(int)
Definition: sources.h:432
SyncSource::participant
Participant * participant
Definition: sources.h:333
SyncSource::setControlTransportPort
void setControlTransportPort(tpport_t p)
Definition: sources.h:313
SyncSource::stateUnknown
No valid packet has been received.
Definition: sources.h:229
SyncSource::link
void * link
Definition: sources.h:344
RTPApplication::begin
ParticipantsIterator begin()
Definition: sources.h:448
tpport_t
unsigned short tpport_t
Transport Protocol Ports.
Definition: address.h:86
SyncSource::networkAddress
InetAddress networkAddress
Definition: sources.h:337
SDESItemsHolder::SDESItemsHolder
SDESItemsHolder()
Definition: sources.h:85
RTPApplication::ParticipantsIterator::ParticipantsIterator
ParticipantsIterator(ParticipantLink *p=NULL)
Definition: sources.h:413
RTPApplication::ParticipantsIterator::reference
const Participant & reference
Definition: sources.h:411
ParticipantHandler
Participant objects modification methods.
Definition: iqueue.h:182
SyncSource::setState
void setState(State st)
Definition: sources.h:296
RTPApplication::ParticipantsIterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: sources.h:407
rtcppkt.h
RTCP packets handling.
SDESItemsHolder::getItem
const std::string & getItem(SDESItemType type) const
SyncSource::State
State
Synchronization source states during an RTP session.
Definition: sources.h:228
ApplicationHandler
Application objects modification methods.
Definition: iqueue.h:208
Participant
A class of objects representing remote participants (RTP applications) in a multimedia session...
Definition: sources.h:127
SDESItemsHolder::setItem
void setItem(SDESItemType item, const std::string &val)
RTPApplication::end
ParticipantsIterator end()
Definition: sources.h:451
SyncSource::getState
State getState() const
Definition: sources.h:251
SyncSource::controlTransportPort
tpport_t controlTransportPort
Definition: sources.h:339
RTPApplication::ParticipantsIterator::ParticipantsIterator
ParticipantsIterator(const ParticipantsIterator &pi)
Definition: sources.h:417
SDESItemsHolder::~SDESItemsHolder
virtual ~SDESItemsHolder()
Definition: sources.h:88
SyncSource::getParticipant
Participant * getParticipant() const
Get the participant this synchronization source is asociated to.
Definition: sources.h:271
RTPApplication::setSDESItem
void setSDESItem(SDESItemType item, const std::string &val)
Definition: sources.h:385
SDESItemTypeEND
END of SDES item list.
Definition: rtcppkt.h:69
SyncSource::setLink
void setLink(void *l)
Definition: sources.h:320
RTPApplication::ParticipantsIterator::operator*
reference operator*() const
Definition: sources.h:421
SyncSource::getNetworkAddress
const InetAddress & getNetworkAddress() const
Definition: sources.h:280
InetAddress
#define InetAddress
Definition: address.h:75
RTPApplication::ParticipantsIterator
Iterator through the list of participants in this session.
Definition: sources.h:404
SyncSource::setSender
void setSender(bool active)
Mark this source as an active sender.
Definition: sources.h:303
SyncSource::getControlTransportPort
tpport_t getControlTransportPort() const
Definition: sources.h:277
SyncSource::isSender
bool isSender() const
Whether this source sends RTP data packets.
Definition: sources.h:257
__EXPORT
#define __EXPORT
Definition: audio2.h:51
SDESItemsHolder
Holds the SDES items and related information from a participant in an RTP application.
Definition: sources.h:67
SDESItemsHolder::getPRIVPrefix
const std::string & getPRIVPrefix() const
Definition: sources.h:74
RTPApplication::ParticipantsIterator::operator==
friend bool operator==(const ParticipantsIterator &l, const ParticipantsIterator &r)
Definition: sources.h:437
SyncSource::getLink
void * getLink() const
Definition: sources.h:323
SyncSource::dataTransportPort
tpport_t dataTransportPort
Definition: sources.h:338
SDESItemsHolder::setPRIVPrefix
void setPRIVPrefix(const std::string &val)
Definition: sources.h:81
RTPApplication::defaultParticipantsNum
static const size_t defaultParticipantsNum
Hash table with sources of RTP and RTCP packets.
Definition: sources.h:489
SyncSource::state
State state
Definition: sources.h:327
RTPApplication::participants
Participant ** participants
Definition: sources.h:490
SyncSource::getID
uint32 getID() const
Definition: sources.h:260
SyncSource::setDataTransportPort
void setDataTransportPort(tpport_t p)
Definition: sources.h:310
RTPApplication::getSDESItem
const std::string & getSDESItem(SDESItemType item) const
Definition: sources.h:393
SyncSourceHandler
SyncSource objects modification methods.
Definition: iqueue.h:127
RTPApplication::ParticipantsIterator::operator->
pointer operator->() const
Definition: sources.h:424
defaultApplication
__EXPORT RTPApplication & defaultApplication()
Get the RTPApplication object for the "default" application (the only one used by common applications...
SyncSource::activeSender
bool activeSender
Definition: sources.h:331
Participant::setPRIVPrefix
void setPRIVPrefix(const std::string val)
Set prefix value for the PRIV SDES item.
Definition: sources.h:180
Participant::getPRIVPrefix
const std::string & getPRIVPrefix() const
Get the prefix value for the PRIV SDES item.
Definition: sources.h:154
SDESItemType
SDESItemType
SDES items that may be carried in a Source DEScription RTCP packet.
Definition: rtcppkt.h:67
Participant::getSDESItem
const std::string & getSDESItem(SDESItemType type) const
Get the value of an SDES item.
Definition: sources.h:143
Participant::setSDESItem
void setSDESItem(SDESItemType item, const std::string &val)
Set the value of a SDES item.
Definition: sources.h:173
SyncSource::setNetworkAddress
void setNetworkAddress(InetAddress addr)
Definition: sources.h:316
RTPApplication::ParticipantsIterator::operator++
ParticipantsIterator & operator++()
Definition: sources.h:427

Generated on Dec 21, 2017 for commoncpp2-1.8.1, ccrtp-1.7.2, libzrtpcpp-2.3.4, ccscript3-1.1.7, ccaudio2-1.0.0 and bayonne2-2.3.2 (after installation in /usr/local/) by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /