Bayonne2 / Common C++ 2 Framework
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rtp.h
Go to the documentation of this file.
1 // Copyright (C) 1999-2005 Open Source Telecom Corporation.
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 
49 #ifndef CCXX_RTP_RTP_H_
50 #define CCXX_RTP_RTP_H_
51 
52 #include <ccrtp/cqueue.h>
53 #include <ccrtp/channel.h>
54 
55 #ifdef CCXX_NAMESPACES
56 namespace ost {
57 #endif
58 
85  template <class RTPDataChannel = DualRTPUDPIPv4Channel,
86  class RTCPChannel = DualRTPUDPIPv4Channel,
87  class ServiceQueue = AVPQueue>
89  {
90  public:
101  tpport_t controlPort, uint32 membersSize,
102  RTPApplication& app) :
103  ServiceQueue(membersSize,app)
104  { build(ia,dataPort,controlPort); }
105 
117  TRTPSessionBase(uint32 ssrc,
118  const InetHostAddress& ia,
119  tpport_t dataPort, tpport_t controlPort,
120  uint32 membersSize, RTPApplication& app):
121  ServiceQueue(ssrc,membersSize,app)
122  { build(ia,dataPort,controlPort); }
123 
137  tpport_t controlPort, uint32 membersSize,
138  RTPApplication& app, uint32 iface) :
139  ServiceQueue(membersSize,app)
140  { build(ia,dataPort,controlPort,iface); }
141 
156  TRTPSessionBase(uint32 ssrc,
157  const InetMcastAddress& ia, tpport_t dataPort,
158  tpport_t controlPort, uint32 membersSize,
159  RTPApplication& app, uint32 iface) :
160  ServiceQueue(ssrc,membersSize,app)
161  { build(ia,dataPort,controlPort,iface); }
162 
163  virtual size_t dispatchBYE(const std::string &str)
164  {
165  return QueueRTCPManager::dispatchBYE(str);
166  }
167 
174  inline Socket::Error
175  setMcastTTL(uint8 ttl)
176  {
177  Socket::Error error = dso->setMulticast(true);
178  if ( error ) return error;
179  error = dso->setTimeToLive(ttl);
180  if ( error ) return error;
181  error = cso->setMulticast(true);
182  if ( error ) return error;
183  return cso->setTimeToLive(ttl);
184  }
185 
186  inline virtual
188  {
189  endSocket();
190  }
191 
192  inline RTPDataChannel *getDSO(void)
193  {return dso;}
194 
195  protected:
199  inline bool
201  { return dso->isPendingRecv(timeout); }
202 
204  getDataSender(tpport_t *port = NULL) const
205  { return dso->getSender(port); }
206 
207  inline size_t
209  { return dso->getNextPacketSize(); }
210 
220  inline size_t
221  recvData(unsigned char* buffer, size_t len,
222  InetHostAddress& na, tpport_t& tp)
223  { na = dso->getSender(tp); return dso->recv(buffer, len); }
224 
225  inline void
226  setDataPeer(const InetAddress &host, tpport_t port)
227  { dso->setPeer(host,port); }
228 
229 
234  inline size_t
235  sendData(const unsigned char* const buffer, size_t len)
236  { return dso->send(buffer, len); }
237 
238  inline SOCKET getDataRecvSocket() const
239  { return dso->getRecvSocket(); }
240 
245  inline bool
247  { return cso->isPendingRecv(timeout); }
248 
250  getControlSender(tpport_t *port = NULL) const
251  { return cso->getSender(port); }
252 
262  inline size_t
263  recvControl(unsigned char *buffer, size_t len,
264  InetHostAddress& na, tpport_t& tp)
265  { na = cso->getSender(tp); return cso->recv(buffer,len); }
266 
267  inline void
269  { cso->setPeer(host,port); }
270 
276  inline size_t
277  sendControl(const unsigned char* const buffer, size_t len)
278  { return cso->send(buffer,len); }
279 
281  { return cso->getRecvSocket(); }
282 
289  inline Socket::Error
290  joinGroup(const InetMcastAddress& ia, uint32 iface)
291  {
292  Socket::Error error = dso->setMulticast(true);
293  if ( error ) return error;
294  error = dso->join(ia,iface);
295  if ( error ) return error;
296  error = cso->setMulticast(true);
297  if ( error ) {
298  dso->drop(ia);
299  return error;
300  }
301  error = cso->join(ia,iface);
302  if ( error ) {
303  dso->drop(ia);
304  return error;
305  }
306  return Socket::errSuccess;
307  }
308 
315  inline Socket::Error
317  {
318  Socket::Error error = dso->setMulticast(false);
319  if ( error ) return error;
320  error = dso->leaveGroup(ia);
321  if ( error ) return error;
322  error = cso->setMulticast(false);
323  if ( error ) return error;
324  return cso->leaveGroup(ia);
325  }
326 
327  inline void
329  {
330  if (dso) {
331  dso->endSocket();
332  delete dso;
333  }
334  dso = NULL;
335  if (cso) {
336  cso->endSocket();
337  delete cso;
338  }
339  cso = NULL;
340  }
341 
342  private:
343  void
344  build(const InetHostAddress& ia, tpport_t dataPort,
345  tpport_t controlPort)
346  {
347  if ( 0 == controlPort ) {
348  dataBasePort = even_port(dataPort);
349  controlBasePort = dataBasePort + 1;
350  } else {
351  dataBasePort = dataPort;
352  controlBasePort = controlPort;
353  }
354  dso = new RTPDataChannel(ia,dataBasePort);
355  cso = new RTCPChannel(ia,controlBasePort);
356  }
357 
358  void
359  build(const InetMcastAddress& ia, tpport_t dataPort,
360  tpport_t controlPort, uint32 iface)
361  {
362  if ( 0 == controlPort ) {
363  dataBasePort = even_port(dataPort);
364  controlBasePort = dataBasePort + 1;
365  } else {
366  dataBasePort = dataPort;
367  controlBasePort = controlPort;
368  }
369  dso = new RTPDataChannel(InetHostAddress("0.0.0.0"),dataBasePort);
370  cso = new RTCPChannel(InetHostAddress("0.0.0.0"),controlBasePort);
371  joinGroup(ia,iface);
372  }
373 
381  inline tpport_t
383  { return (port & 0x01)? (port) : (port - 1); }
384 
392  inline tpport_t
394  { return (port & 0x01)? (port - 1) : (port); }
395 
398 
399  protected:
400  RTPDataChannel* dso;
401  RTCPChannel* cso;
402  friend class RTPSessionBaseHandler;
403  };
404 
415  template
416  <class RTPDataChannel = DualRTPUDPIPv4Channel,
417  class RTCPChannel = DualRTPUDPIPv4Channel,
418  class ServiceQueue = AVPQueue>
420  protected Thread,
421  public TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>
422  {
423  public:
425  tpport_t dataPort = DefaultRTPDataPort,
426  tpport_t controlPort = 0,
427  int pri = 0,
428  uint32 memberssize =
431 #if defined(_MSC_VER) && _MSC_VER >= 1300
432  );
433 #else
434  ):
435  Thread(pri),
437  (ia,dataPort,controlPort,memberssize,app)
438  { }
439 #endif
440 
441  SingleThreadRTPSession(uint32 ssrc, const InetHostAddress& ia,
442  tpport_t dataPort = DefaultRTPDataPort,
443  tpport_t controlPort = 0,
444  int pri = 0,
445  uint32 memberssize =
448 #if defined(_MSC_VER) && _MSC_VER >= 1300
449  );
450 #else
451  ):
452  Thread(pri),
454  (ssrc, ia,dataPort,controlPort,memberssize,app)
455 { }
456 #endif
457 
459  tpport_t dataPort = DefaultRTPDataPort,
460  tpport_t controlPort = 0,
461  int pri = 0,
462  uint32 memberssize =
465  uint32 iface = 0
466 #if defined(_MSC_VER) && _MSC_VER >= 1300
467  );
468 #else
469  ):
470  Thread(pri),
472  (ia,dataPort,controlPort,memberssize,app,iface)
473  { }
474 #endif
475 
477  tpport_t dataPort = DefaultRTPDataPort,
478  tpport_t controlPort = 0,
479  int pri = 0,
480  uint32 memberssize =
483  uint32 iface = 0
484 #if defined(_MSC_VER) && _MSC_VER >= 1300
485  );
486 #else
487  ):
488  Thread(pri),
490  (ssrc,ia,dataPort,controlPort,memberssize,app,iface)
491 { }
492 #endif
493 
494 
496 {
497  if (isRunning()) {
498  disableStack(); Thread::join();
499  }
500 }
501 
502 #if defined(_MSC_VER) && _MSC_VER >= 1300
503 virtual void startRunning();
504 #else
505 
508 void
510 { enableStack(); Thread::start(); }
511 #endif
512 
513 
514 protected:
515 inline void disableStack(void)
517 
518 inline void enableStack(void)
520 
523 
524 inline void controlReceptionService(void)
526 
527 inline void controlTransmissionService(void)
529 
530 inline timeval getRTCPCheckInterval(void)
532 
533 inline size_t dispatchDataPacket(void)
535 
536 #if defined(_MSC_VER) && _MSC_VER >= 1300
537 virtual void run(void);
538 
539 virtual void timerTick(void);
540 
541 virtual bool isPendingData(microtimeout_t timeout);
542 #else
543 
544 virtual void timerTick(void)
545 {return;}
546 
547 virtual bool isPendingData(microtimeout_t timeout)
549 
554 virtual void run(void)
555 {
556  microtimeout_t timeout = 0;
557  while ( ServiceQueue::isActive() ) {
558  if ( timeout < 1000 ){ // !(timeout/1000)
559  timeout = getSchedulingTimeout();
560  }
561  setCancel(cancelDeferred);
562  controlReceptionService();
563  controlTransmissionService();
564  setCancel(cancelImmediate);
565  microtimeout_t maxWait =
566  timeval2microtimeout(getRTCPCheckInterval());
567  // make sure the scheduling timeout is
568  // <= the check interval for RTCP
569  // packets
570  timeout = (timeout > maxWait)? maxWait : timeout;
571  if ( timeout < 1000 ) { // !(timeout/1000)
572  setCancel(cancelDeferred);
573  dispatchDataPacket();
574  setCancel(cancelImmediate);
575  timerTick();
576  } else {
577  if ( isPendingData(timeout/1000) ) {
578  setCancel(cancelDeferred);
579  if (ServiceQueue::isActive()) { // take in only if active
580  takeInDataPacket();
581  }
582  setCancel(cancelImmediate);
583  }
584  timeout = 0;
585  }
586  }
587  dispatchBYE("GNU ccRTP stack finishing.");
588 // Thread::exit();
589 }
590 
591 #endif
592 
593 inline size_t takeInDataPacket(void)
595 
596 inline size_t dispatchBYE(const std::string &str)
598 };
599 
609 
616 
627 
628 #ifdef CCXX_IPV6
629 
651 template <class RTPDataChannel = DualRTPUDPIPv6Channel,
652  class RTCPChannel = DualRTPUDPIPv6Channel,
653  class ServiceQueue = AVPQueue>
654 class __EXPORT TRTPSessionBaseIPV6 : public ServiceQueue
655 {
656 public:
666 TRTPSessionBaseIPV6(const IPV6Host& ia, tpport_t dataPort,
667  tpport_t controlPort, uint32 membersSize,
668  RTPApplication& app) :
669  ServiceQueue(membersSize,app)
670 { build(ia,dataPort,controlPort); }
671 
683  TRTPSessionBaseIPV6(uint32 ssrc,
684  const IPV6Host& ia,
685  tpport_t dataPort, tpport_t controlPort,
686  uint32 membersSize, RTPApplication& app):
687  ServiceQueue(ssrc,membersSize,app)
688  { build(ia,dataPort,controlPort); }
689 
702  TRTPSessionBaseIPV6(const IPV6Multicast& ia, tpport_t dataPort,
703  tpport_t controlPort, uint32 membersSize,
704  RTPApplication& app, uint32 iface) :
705  ServiceQueue(membersSize,app)
706  { build(ia,dataPort,controlPort,iface); }
707 
722  TRTPSessionBaseIPV6(uint32 ssrc,
723  const IPV6Multicast& ia, tpport_t dataPort,
724  tpport_t controlPort, uint32 membersSize,
725  RTPApplication& app, uint32 iface) :
726  ServiceQueue(ssrc,membersSize,app)
727  { build(ia,dataPort,controlPort,iface); }
728 
729  virtual size_t dispatchBYE(const std::string &str)
730  {
731  return QueueRTCPManager::dispatchBYE(str);
732  }
733 
734  inline virtual
735  ~TRTPSessionBaseIPV6()
736  {
737  endSocket();
738  }
739 
740  inline RTPDataChannel *getDSO(void)
741  {return dso;}
742 
743 protected:
747  inline bool
748  isPendingData(microtimeout_t timeout)
749  { return dso->isPendingRecv(timeout); }
750 
751  inline IPV6Host
752  getDataSender(tpport_t *port = NULL) const
753  { return dso->getSender(port); }
754 
755  inline size_t
756  getNextDataPacketSize() const
757  { return dso->getNextPacketSize(); }
758 
768  inline size_t
769  recvData(unsigned char* buffer, size_t len,
770  IPV6Host& na, tpport_t& tp)
771  { na = dso->getSender(tp); return dso->recv(buffer, len); }
772 
773  inline void
774  setDataPeerIPV6(const IPV6Host &host, tpport_t port)
775  { dso->setPeer(host,port); }
776 
781  inline size_t
782  sendDataIPV6(const unsigned char* const buffer, size_t len)
783  { return dso->send(buffer, len); }
784 
785  inline SOCKET getDataRecvSocket() const
786  { return dso->getRecvSocket(); }
787 
792  inline bool
793  isPendingControl(microtimeout_t timeout)
794  { return cso->isPendingRecv(timeout); }
795 
796  inline IPV6Host
797  getControlSender(tpport_t *port = NULL) const
798  { return cso->getSender(port); }
799 
809  inline size_t
810  recvControl(unsigned char *buffer, size_t len,
811  IPV6Host& na, tpport_t& tp)
812  { na = cso->getSender(tp); return cso->recv(buffer,len); }
813 
814  inline void
815  setControlPeerIPV6(const IPV6Host &host, tpport_t port)
816  { cso->setPeer(host,port); }
817 
823  inline size_t
824  sendControl(const unsigned char* const buffer, size_t len)
825  { return cso->send(buffer,len); }
826 
827  inline SOCKET getControlRecvSocket() const
828  { return cso->getRecvSocket(); }
829 
830  inline void
831  endSocket()
832  {
833  dso->endSocket();
834  cso->endSocket();
835  if (dso) delete dso;
836  dso = NULL;
837  if (cso) delete cso;
838  cso = NULL;
839  }
840 
841 private:
842  void
843  build(const IPV6Host& ia, tpport_t dataPort,
844  tpport_t controlPort)
845  {
846  if ( 0 == controlPort ) {
847  dataBasePort = even_port(dataPort);
848  controlBasePort = dataBasePort + 1;
849  } else {
850  dataBasePort = dataPort;
851  controlBasePort = controlPort;
852  }
853  dso = new RTPDataChannel(ia,dataBasePort);
854  cso = new RTCPChannel(ia,controlBasePort);
855  }
856 
857  void
858  build(const IPV6Multicast& ia, tpport_t dataPort,
859  tpport_t controlPort, uint32 iface)
860  {
861  if ( 0 == controlPort ) {
862  dataBasePort = even_port(dataPort);
863  controlBasePort = dataBasePort + 1;
864  } else {
865  dataBasePort = dataPort;
866  controlBasePort = controlPort;
867  }
868  dso = new RTPDataChannel(IPV6Host("0.0.0.0"),dataBasePort);
869  cso = new RTCPChannel(IPV6Host("0.0.0.0"),controlBasePort);
870  joinGroup(ia,iface);
871  }
872 
879  inline Socket::Error
880  joinGroup(const IPV6Multicast& ia, uint32 iface)
881  {
882  Socket::Error error = dso->setMulticast(true);
883  if ( error ) return error;
884  error = dso->join(ia,iface);
885  if ( error ) return error;
886  error = cso->setMulticast(true);
887  if ( error ) {
888  dso->drop(ia);
889  return error;
890  }
891  error = cso->join(ia,iface);
892  if ( error ) {
893  dso->drop(ia);
894  return error;
895  }
896  return Socket::errSuccess;
897  }
898 
905  inline Socket::Error
906  leaveGroup(const IPV6Multicast& ia)
907  {
908  Socket::Error error = dso->setMulticast(false);
909  if ( error ) return error;
910  error = dso->leaveGroup(ia);
911  if ( error ) return error;
912  error = cso->setMulticast(false);
913  if ( error ) return error;
914  return cso->leaveGroup(ia);
915  }
916 
923  inline Socket::Error
924  setMcastTTL(uint8 ttl)
925  {
926  Socket::Error error = dso->setMulticast(true);
927  if ( error ) return error;
928  error = dso->setTimeToLive(ttl);
929  if ( error ) return error;
930  error = cso->setMulticast(true);
931  if ( error ) return error;
932  return cso->setTimeToLive(ttl);
933  }
934 
942  inline tpport_t
943  odd_port(tpport_t port)
944  { return (port & 0x01)? (port) : (port - 1); }
945 
953  inline tpport_t
954  even_port(tpport_t port)
955  { return (port & 0x01)? (port - 1) : (port); }
956 
957  tpport_t dataBasePort;
958  tpport_t controlBasePort;
959 
960 protected:
961  RTPDataChannel* dso;
962  RTCPChannel* cso;
963  friend class RTPSessionBaseHandler;
964 };
965 
976 template
977 <class RTPDataChannel = DualRTPUDPIPv6Channel,
978  class RTCPChannel = DualRTPUDPIPv6Channel,
979  class ServiceQueue = AVPQueue>
980 class __EXPORT SingleThreadRTPSessionIPV6 :
981  protected Thread,
982  public TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>
983 {
984 public:
985  SingleThreadRTPSessionIPV6(const IPV6Host& ia,
986  tpport_t dataPort = DefaultRTPDataPort,
987  tpport_t controlPort = 0,
988  int pri = 0,
989  uint32 memberssize =
992 #if defined(_MSC_VER) && _MSC_VER >= 1300
993  );
994 #else
995  ):
996  Thread(pri),
997  TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>
998  (ia,dataPort,controlPort,memberssize,app)
999 { }
1000 #endif
1001 
1002 SingleThreadRTPSessionIPV6(const IPV6Multicast& ia,
1003  tpport_t dataPort = DefaultRTPDataPort,
1004  tpport_t controlPort = 0,
1005  int pri = 0,
1006  uint32 memberssize =
1009  uint32 iface = 0
1010 #if defined(_MSC_VER) && _MSC_VER >= 1300
1011  );
1012 #else
1013  ):
1014  Thread(pri),
1015  TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>
1016  (ia,dataPort,controlPort,memberssize,app,iface)
1017 { }
1018 #endif
1019 
1020 ~SingleThreadRTPSessionIPV6()
1021 {
1022  if (isRunning()) {
1023  disableStack(); Thread::join();
1024  }
1025 }
1026 
1027 #if defined(_MSC_VER) && _MSC_VER >= 1300
1028 virtual void startRunning();
1029 #else
1030 
1033 void
1034 startRunning()
1035 { enableStack(); Thread::start(); }
1036 #endif
1037 
1038 
1039 protected:
1040 inline void enableStack(void)
1042 
1043 inline void disableStack(void)
1045 
1046 inline microtimeout_t getSchedulingTimeout(void)
1048 
1049 inline void controlReceptionService(void)
1051 
1052 inline void controlTransmissionService(void)
1054 
1055 inline timeval getRTCPCheckInterval(void)
1057 
1058 inline size_t dispatchDataPacket(void)
1060 
1061 #if defined(_MSC_VER) && _MSC_VER >= 1300
1062 virtual void run(void);
1063 
1064 virtual void timerTick(void);
1065 
1066 virtual bool isPendingData(microtimeout_t timeout);
1067 #else
1068 
1069 virtual void timerTick(void)
1070 {return;}
1071 
1072 virtual bool isPendingData(microtimeout_t timeout)
1074 
1079 virtual void run(void)
1080 {
1081  microtimeout_t timeout = 0;
1082  while ( ServiceQueue::isActive() ) {
1083  if ( timeout < 1000 ){ // !(timeout/1000)
1084  timeout = getSchedulingTimeout();
1085  }
1086  setCancel(cancelDeferred);
1087  controlReceptionService();
1088  controlTransmissionService();
1089  setCancel(cancelImmediate);
1090  microtimeout_t maxWait =
1091  timeval2microtimeout(getRTCPCheckInterval());
1092  // make sure the scheduling timeout is
1093  // <= the check interval for RTCP
1094  // packets
1095  timeout = (timeout > maxWait)? maxWait : timeout;
1096  if ( timeout < 1000 ) { // !(timeout/1000)
1097  setCancel(cancelDeferred);
1098  dispatchDataPacket();
1099  setCancel(cancelImmediate);
1100  timerTick();
1101  } else {
1102  if ( isPendingData(timeout/1000) ) {
1103  setCancel(cancelDeferred);
1104  takeInDataPacket();
1105  setCancel(cancelImmediate);
1106  }
1107  timeout = 0;
1108  }
1109  }
1110  dispatchBYE("GNU ccRTP stack finishing.");
1111  Thread::exit();
1112 }
1113 
1114 #endif
1115 
1116 inline size_t takeInDataPacket(void)
1118 
1119 inline size_t dispatchBYE(const std::string &str)
1121 };
1122 
1131 typedef SingleThreadRTPSessionIPV6<> RTPSessionIPV6;
1132 
1138 typedef RTPSessionIPV6 RTPSocketIPV6;
1139 
1148  typedef SingleThreadRTPSessionIPV6<SymmetricRTPChannelIPV6,
1149  SymmetricRTPChannelIPV6> SymmetricRTPSessionIPV6;
1150 
1151 
1152 #endif
1153  // sessions
1155 
1156 #ifdef CCXX_NAMESPACES
1157 }
1158 #endif
1159 
1160 #endif //CCXX_RTP_RTP_H_
1161 
void setControlPeer(const InetAddress &host, tpport_t port)
Definition: rtp.h:268
RTCPChannel * cso
Definition: rtp.h:401
An RTP application, holding identifying RTCP SDES item values.
Definition: sources.h:367
void build(const InetHostAddress &ia, tpport_t dataPort, tpport_t controlPort)
Definition: rtp.h:344
RTPSession RTPSocket
Alias for RTPSession.
Definition: rtp.h:615
class __EXPORT Thread
Definition: thread.h:112
SingleThreadRTPSession(const InetMcastAddress &ia, tpport_t dataPort=DefaultRTPDataPort, tpport_t controlPort=0, int pri=0, uint32 memberssize=MembershipBookkeeping::defaultMembersHashSize, RTPApplication &app=defaultApplication(), uint32 iface=0)
Definition: rtp.h:458
InetHostAddress getControlSender(tpport_t *port=NULL) const
Definition: rtp.h:250
DualRTPChannel< RTPBaseUDPIPv4Socket > DualRTPUDPIPv4Channel
Definition: channel.h:446
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Definition: applog.h:541
virtual void timerTick(void)
Definition: rtp.h:544
uint32 microtimeout_t
Time interval expressed in microseconds.
Definition: base.h:69
void controlReceptionService(void)
Definition: rtp.h:524
Error
Definition: socket.h:131
TRTPSessionBase(uint32 ssrc, const InetMcastAddress &ia, tpport_t dataPort, tpport_t controlPort, uint32 membersSize, RTPApplication &app, uint32 iface)
Builds a session waiting for packets in a multicast address, with the specified ssrc identifier for t...
Definition: rtp.h:156
unsigned short tpport_t
Transport Protocol Ports.
Definition: address.h:86
Socket::Error setMcastTTL(uint8 ttl)
Set the value of the TTL field in the sent packets.
Definition: rtp.h:175
void disableStack(void)
Definition: rtp.h:515
microtimeout_t timeval2microtimeout(const timeval &t)
Convert a time interval, expressed as a timeval value into a microseconds counter.
Definition: base.h:92
size_t dispatchBYE(const std::string &str)
Definition: rtp.h:596
int start(Semaphore *start=0)
When a new thread is created, it does not begin immediate execution.
size_t sendData(const unsigned char *const buffer, size_t len)
Definition: rtp.h:235
void setDataPeer(const InetAddress &host, tpport_t port)
Definition: rtp.h:226
void endSocket()
Definition: rtp.h:328
tpport_t even_port(tpport_t port)
Ensure a port number is even.
Definition: rtp.h:393
SingleRTPChannel SymmetricRTPChannel
Actually, RTP with a single channel can be called 'Symmetric RTP'.
Definition: channel.h:457
void build(const InetMcastAddress &ia, tpport_t dataPort, tpport_t controlPort, uint32 iface)
Definition: rtp.h:359
SOCKET getDataRecvSocket() const
Definition: rtp.h:238
size_t dispatchDataPacket(void)
Definition: rtp.h:533
InetHostAddress getDataSender(tpport_t *port=NULL) const
Definition: rtp.h:204
virtual bool isPendingData(microtimeout_t timeout)
Definition: rtp.h:547
tpport_t controlBasePort
Definition: rtp.h:397
RTPDataChannel * dso
Definition: rtp.h:400
bool isPendingControl(microtimeout_t timeout)
Definition: rtp.h:246
void join(void)
Blocking call which unlocks when thread terminates.
Socket::Error joinGroup(const InetMcastAddress &ia, uint32 iface)
Join a multicast group.
Definition: rtp.h:290
Definition of socket classes for different underlying transport and/or network protocols that can be ...
SOCKET getControlRecvSocket() const
Definition: rtp.h:280
tpport_t odd_port(tpport_t port)
Ensure a port number is odd.
Definition: rtp.h:382
#define InetHostAddress
Definition: address.h:76
size_t takeInDataPacket(void)
Definition: rtp.h:593
A UDP/IPv4 socket class targetted at RTP stacks.
Definition: channel.h:96
SingleThreadRTPSession(const InetHostAddress &ia, tpport_t dataPort=DefaultRTPDataPort, tpport_t controlPort=0, int pri=0, uint32 memberssize=MembershipBookkeeping::defaultMembersHashSize, RTPApplication &app=defaultApplication())
Definition: rtp.h:424
virtual size_t dispatchBYE(const std::string &str)
Definition: rtp.h:163
size_t recvControl(unsigned char *buffer, size_t len, InetHostAddress &na, tpport_t &tp)
Receive data from the control channel/socket.
Definition: rtp.h:263
void startRunning()
Activate stack and start service thread.
Definition: rtp.h:509
SingleThreadRTPSession RTPSession
Uses two pairs of sockets for RTP data and RTCP transmission/reception.
Definition: rtp.h:608
bool isPendingData(microtimeout_t timeout)
Definition: rtp.h:200
static const size_t defaultMembersHashSize
Definition: iqueue.h:854
virtual void run(void)
Single runnable method for this RTP stacks, schedules outgoing and incoming RTP data and RTCP packets...
Definition: rtp.h:554
size_t recvData(unsigned char *buffer, size_t len, InetHostAddress &na, tpport_t &tp)
Receive data from the data channel/socket.
Definition: rtp.h:221
Generic RTCP control queues.
TRTPSessionBase(uint32 ssrc, const InetHostAddress &ia, tpport_t dataPort, tpport_t controlPort, uint32 membersSize, RTPApplication &app)
Builds a session with the specified ssrc identifier for the local source.
Definition: rtp.h:117
TRTPSessionBase(const InetMcastAddress &ia, tpport_t dataPort, tpport_t controlPort, uint32 membersSize, RTPApplication &app, uint32 iface)
Builds a session waiting for packets in a multicast address.
Definition: rtp.h:136
const tpport_t DefaultRTPDataPort
registered default RTP data transport port
Definition: base.h:111
SingleThreadRTPSession(uint32 ssrc, const InetHostAddress &ia, tpport_t dataPort=DefaultRTPDataPort, tpport_t controlPort=0, int pri=0, uint32 memberssize=MembershipBookkeeping::defaultMembersHashSize, RTPApplication &app=defaultApplication())
Definition: rtp.h:441
#define InetAddress
Definition: address.h:75
Socket::Error leaveGroup(const InetMcastAddress &ia)
Leave a multicast group.
Definition: rtp.h:316
size_t sendControl(const unsigned char *const buffer, size_t len)
Definition: rtp.h:277
This template class adds the threading aspect to the RTPSessionBase template in one of the many possi...
Definition: rtp.h:419
#define __EXPORT
Definition: audio2.h:51
#define InetMcastAddress
Definition: address.h:78
void exit(void)
Used to properly exit from a Thread derived run() or initial() method.
Every thread of execution in an application is created by instantiating an object of a class derived ...
Definition: thread.h:1093
timeval getRTCPCheckInterval(void)
Definition: rtp.h:530
size_t getNextDataPacketSize() const
Definition: rtp.h:208
void enableStack(void)
Definition: rtp.h:518
int SOCKET
Definition: socket.h:60
SingleThreadRTPSession< SymmetricRTPChannel, SymmetricRTPChannel > SymmetricRTPSession
Uses one pair of sockets, (1) for RTP data and (2) for RTCP transmission/reception.
Definition: rtp.h:626
SingleThreadRTPSession(uint32 ssrc, const InetMcastAddress &ia, tpport_t dataPort=DefaultRTPDataPort, tpport_t controlPort=0, int pri=0, uint32 memberssize=MembershipBookkeeping::defaultMembersHashSize, RTPApplication &app=defaultApplication(), uint32 iface=0)
Definition: rtp.h:476
virtual ~TRTPSessionBase()
Definition: rtp.h:187
TRTPSessionBase(const InetHostAddress &ia, tpport_t dataPort, tpport_t controlPort, uint32 membersSize, RTPApplication &app)
Builds a session waiting for packets in a host address.
Definition: rtp.h:100
__EXPORT RTPApplication & defaultApplication()
Get the RTPApplication object for the "default" application (the only one used by common applications...
microtimeout_t getSchedulingTimeout(void)
Definition: rtp.h:521
RTPDataChannel * getDSO(void)
Definition: rtp.h:192
size_t dispatchBYE(const std::string &reason)
This method is used to send an RTCP BYE packet.
tpport_t dataBasePort
Definition: rtp.h:396
void controlTransmissionService(void)
Definition: rtp.h:527
This class, an RTP/RTCP queue, adds audio/video profile (AVP) specific methods to the generic RTCP se...
Definition: cqueue.h:629