ccRTP
rtp.h
Go to the documentation of this file.
1 // Copyright (C) 1999-2005 Open Source Telecom Corporation.
2 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
3 // Copyright (C) 2015 Cherokees of Idaho.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with GNU ccRTP. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free software
19 // library without restriction. Specifically, if other files instantiate
20 // templates or use macros or inline functions from this file, or you compile
21 // this file and link it with other files to produce an executable, this
22 // file does not by itself cause the resulting executable to be covered by
23 // the GNU General Public License. This exception does not however
24 // invalidate any other reasons why the executable file might be covered by
25 // the GNU General Public License.
26 //
27 // This exception applies only to the code released under the name GNU
28 // ccRTP. If you copy code from other releases into a copy of GNU
29 // ccRTP, as the General Public License permits, the exception does
30 // not apply to the code that you add in this way. To avoid misleading
31 // anyone as to the status of such modified files, you must delete
32 // this exception notice from them.
33 //
34 // If you write modifications of your own for GNU ccRTP, it is your choice
35 // whether to permit this exception to apply to your modifications.
36 // If you do not wish that, delete this exception notice.
37 //
38 
50 #ifndef CCXX_RTP_RTP_H_
51 #define CCXX_RTP_RTP_H_
52 
53 #include <ccrtp/cqueue.h>
54 #include <ccrtp/channel.h>
55 
56 NAMESPACE_COMMONCPP
57 
84  template <class RTPDataChannel = DualRTPUDPIPv4Channel,
85  class RTCPChannel = DualRTPUDPIPv4Channel,
86  class ServiceQueue = AVPQueue>
87  class __EXPORT TRTPSessionBase : public ServiceQueue
88  {
89  public:
99  TRTPSessionBase(const InetHostAddress& ia, tpport_t dataPort,
100  tpport_t controlPort, uint32 membersSize,
101  RTPApplication& app) :
102  ServiceQueue(membersSize,app)
103  { build(ia,dataPort,controlPort); }
104 
116  TRTPSessionBase(uint32 ssrc,
117  const InetHostAddress& ia,
118  tpport_t dataPort, tpport_t controlPort,
119  uint32 membersSize, RTPApplication& app):
120  ServiceQueue(ssrc,membersSize,app)
121  { build(ia,dataPort,controlPort); }
122 
135  TRTPSessionBase(const InetMcastAddress& ia, tpport_t dataPort,
136  tpport_t controlPort, uint32 membersSize,
137  RTPApplication& app, uint32 iface) :
138  ServiceQueue(membersSize,app)
139  { build(ia,dataPort,controlPort,iface); }
140 
155  TRTPSessionBase(uint32 ssrc,
156  const InetMcastAddress& ia, tpport_t dataPort,
157  tpport_t controlPort, uint32 membersSize,
158  RTPApplication& app, uint32 iface) :
159  ServiceQueue(ssrc,membersSize,app)
160  { build(ia,dataPort,controlPort,iface); }
161 
162  virtual size_t dispatchBYE(const std::string &str)
163  {
164  return QueueRTCPManager::dispatchBYE(str);
165  }
166 
173  inline Socket::Error
174  setMcastTTL(uint8 ttl)
175  {
176  Socket::Error error = dso->setMulticast(true);
177  if ( error ) return error;
178  error = dso->setTimeToLive(ttl);
179  if ( error ) return error;
180  error = cso->setMulticast(true);
181  if ( error ) return error;
182  return cso->setTimeToLive(ttl);
183  }
184 
185  inline virtual
187  {
188  endSocket();
189  }
190 
191  inline RTPDataChannel *getDSO(void)
192  {return dso;}
193 
194  protected:
198  inline bool
200  { return dso->isPendingRecv(timeout); }
201 
202  InetHostAddress
203  getDataSender(tpport_t *port = NULL) const
204  { return dso->getSender(port); }
205 
206  inline size_t
208  { return dso->getNextPacketSize(); }
209 
219  inline size_t
220  recvData(unsigned char* buffer, size_t len,
221  InetHostAddress& na, tpport_t& tp)
222  { na = dso->getSender(tp); return dso->recv(buffer, len); }
223 
224  inline void
225  setDataPeer(const InetAddress &host, tpport_t port)
226  { dso->setPeer(host,port); }
227 
228 
233  inline size_t
234  sendData(const unsigned char* const buffer, size_t len)
235  { return dso->send(buffer, len); }
236 
237  inline SOCKET getDataRecvSocket() const
238  { return dso->getRecvSocket(); }
239 
244  inline bool
246  { return cso->isPendingRecv(timeout); }
247 
248  InetHostAddress
249  getControlSender(tpport_t *port = NULL) const
250  { return cso->getSender(port); }
251 
261  inline size_t
262  recvControl(unsigned char *buffer, size_t len,
263  InetHostAddress& na, tpport_t& tp)
264  { na = cso->getSender(tp); return cso->recv(buffer,len); }
265 
266  inline void
267  setControlPeer(const InetAddress &host, tpport_t port)
268  { cso->setPeer(host,port); }
269 
275  inline size_t
276  sendControl(const unsigned char* const buffer, size_t len)
277  { return cso->send(buffer,len); }
278 
279  inline SOCKET getControlRecvSocket() const
280  { return cso->getRecvSocket(); }
281 
288  inline Socket::Error
289  joinGroup(const InetMcastAddress& ia, uint32 iface)
290  {
291  Socket::Error error = dso->setMulticast(true);
292  if ( error ) return error;
293  error = dso->join(ia,iface);
294  if ( error ) return error;
295  error = cso->setMulticast(true);
296  if ( error ) {
297  dso->drop(ia);
298  return error;
299  }
300  error = cso->join(ia,iface);
301  if ( error ) {
302  dso->drop(ia);
303  return error;
304  }
305  return Socket::errSuccess;
306  }
307 
314  inline Socket::Error
315  leaveGroup(const InetMcastAddress& ia)
316  {
317  Socket::Error error = dso->setMulticast(false);
318  if ( error ) return error;
319  error = dso->leaveGroup(ia);
320  if ( error ) return error;
321  error = cso->setMulticast(false);
322  if ( error ) return error;
323  return cso->leaveGroup(ia);
324  }
325 
326  inline void
328  {
329  if (dso) {
330  dso->endSocket();
331  delete dso;
332  }
333  dso = NULL;
334  if (cso) {
335  cso->endSocket();
336  delete cso;
337  }
338  cso = NULL;
339  }
340 
341  private:
342  void
343  build(const InetHostAddress& ia, tpport_t dataPort,
344  tpport_t controlPort)
345  {
346  if ( 0 == controlPort ) {
347  dataBasePort = even_port(dataPort);
348  controlBasePort = dataBasePort + 1;
349  } else {
350  dataBasePort = dataPort;
351  controlBasePort = controlPort;
352  }
353  dso = new RTPDataChannel(ia,dataBasePort);
354  cso = new RTCPChannel(ia,controlBasePort);
355  }
356 
357  void
358  build(const InetMcastAddress& ia, tpport_t dataPort,
359  tpport_t controlPort, uint32 iface)
360  {
361  if ( 0 == controlPort ) {
362  dataBasePort = even_port(dataPort);
363  controlBasePort = dataBasePort + 1;
364  } else {
365  dataBasePort = dataPort;
366  controlBasePort = controlPort;
367  }
368  dso = new RTPDataChannel(InetHostAddress("0.0.0.0"),dataBasePort);
369  cso = new RTCPChannel(InetHostAddress("0.0.0.0"),controlBasePort);
370  joinGroup(ia,iface);
371  }
372 
380  inline tpport_t
381  odd_port(tpport_t port)
382  { return (port & 0x01)? (port) : (port - 1); }
383 
391  inline tpport_t
392  even_port(tpport_t port)
393  { return (port & 0x01)? (port - 1) : (port); }
394 
395  tpport_t dataBasePort;
396  tpport_t controlBasePort;
397 
398  protected:
399  RTPDataChannel* dso;
400  RTCPChannel* cso;
401  friend class RTPSessionBaseHandler;
402  };
403 
414  template
415  <class RTPDataChannel = DualRTPUDPIPv4Channel,
416  class RTCPChannel = DualRTPUDPIPv4Channel,
417  class ServiceQueue = AVPQueue>
418  class __EXPORT SingleThreadRTPSession :
419  protected Thread,
420  public TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>
421  {
422  public:
423  SingleThreadRTPSession(const InetHostAddress& ia,
424  tpport_t dataPort = DefaultRTPDataPort,
425  tpport_t controlPort = 0,
426  int pri = 0,
427  uint32 memberssize =
430 #if defined(_MSC_VER) && _MSC_VER >= 1300
431  );
432 #else
433  ):
434  Thread(pri),
436  (ia,dataPort,controlPort,memberssize,app)
437  { }
438 #endif
439 
440  SingleThreadRTPSession(uint32 ssrc, const InetHostAddress& ia,
441  tpport_t dataPort = DefaultRTPDataPort,
442  tpport_t controlPort = 0,
443  int pri = 0,
444  uint32 memberssize =
447 #if defined(_MSC_VER) && _MSC_VER >= 1300
448  );
449 #else
450  ):
451  Thread(pri),
453  (ssrc, ia,dataPort,controlPort,memberssize,app)
454 { }
455 #endif
456 
457 SingleThreadRTPSession(const InetMcastAddress& ia,
458  tpport_t dataPort = DefaultRTPDataPort,
459  tpport_t controlPort = 0,
460  int pri = 0,
461  uint32 memberssize =
464  uint32 iface = 0
465 #if defined(_MSC_VER) && _MSC_VER >= 1300
466  );
467 #else
468  ):
469  Thread(pri),
471  (ia,dataPort,controlPort,memberssize,app,iface)
472  { }
473 #endif
474 
475 SingleThreadRTPSession(uint32 ssrc, const InetMcastAddress& ia,
476  tpport_t dataPort = DefaultRTPDataPort,
477  tpport_t controlPort = 0,
478  int pri = 0,
479  uint32 memberssize =
482  uint32 iface = 0
483 #if defined(_MSC_VER) && _MSC_VER >= 1300
484  );
485 #else
486  ):
487  Thread(pri),
489  (ssrc,ia,dataPort,controlPort,memberssize,app,iface)
490 { }
491 #endif
492 
493 
495 {
496  if (isRunning()) {
497  disableStack(); Thread::join();
498  }
499 }
500 
501 #if defined(_MSC_VER) && _MSC_VER >= 1300
502 virtual void startRunning();
503 #else
507 void
509 { enableStack(); Thread::start(); }
510 #endif
511 
512 
513 protected:
514 inline void disableStack(void)
516 
517 inline void enableStack(void)
519 
522 
523 inline void controlReceptionService(void)
525 
526 inline void controlTransmissionService(void)
528 
529 inline timeval getRTCPCheckInterval(void)
531 
532 inline size_t dispatchDataPacket(void)
534 
535 #if defined(_MSC_VER) && _MSC_VER >= 1300
536 virtual void run(void);
537 
538 virtual void timerTick(void);
539 
540 virtual bool isPendingData(microtimeout_t timeout);
541 #else
542 
543 virtual void timerTick(void)
544 {return;}
545 
546 virtual bool isPendingData(microtimeout_t timeout)
548 
553 virtual void run(void)
554 {
555  microtimeout_t timeout = 0;
556  while ( ServiceQueue::isActive() ) {
557  if ( timeout < 1000 ){ // !(timeout/1000)
558  timeout = getSchedulingTimeout();
559  }
560  controlReceptionService();
561  controlTransmissionService();
562  microtimeout_t maxWait =
563  timeval2microtimeout(getRTCPCheckInterval());
564  // make sure the scheduling timeout is
565  // <= the check interval for RTCP
566  // packets
567  timeout = (timeout > maxWait)? maxWait : timeout;
568  if ( timeout < 1000 ) { // !(timeout/1000)
569  dispatchDataPacket();
570  timerTick();
571  } else {
572  if ( isPendingData(timeout/1000) ) {
573  if (ServiceQueue::isActive()) { // take in only if active
574  takeInDataPacket();
575  }
576  }
577  timeout = 0;
578  }
579  }
580  dispatchBYE("GNU ccRTP stack finishing.");
581 // Thread::exit();
582 }
583 
584 #endif
585 
586 inline size_t takeInDataPacket(void)
588 
589 inline size_t dispatchBYE(const std::string &str)
591 };
592 
602 
609 
620 
621 #ifdef CCXX_IPV6
622 
644 template <class RTPDataChannel = DualRTPUDPIPv6Channel,
645  class RTCPChannel = DualRTPUDPIPv6Channel,
646  class ServiceQueue = AVPQueue>
647 class __EXPORT TRTPSessionBaseIPV6 : public ServiceQueue
648 {
649 public:
659 TRTPSessionBaseIPV6(const IPV6Host& ia, tpport_t dataPort,
660  tpport_t controlPort, uint32 membersSize,
661  RTPApplication& app) :
662  ServiceQueue(membersSize,app)
663 { build(ia,dataPort,controlPort); }
664 
676  TRTPSessionBaseIPV6(uint32 ssrc,
677  const IPV6Host& ia,
678  tpport_t dataPort, tpport_t controlPort,
679  uint32 membersSize, RTPApplication& app):
680  ServiceQueue(ssrc,membersSize,app)
681  { build(ia,dataPort,controlPort); }
682 
695  TRTPSessionBaseIPV6(const IPV6Multicast& ia, tpport_t dataPort,
696  tpport_t controlPort, uint32 membersSize,
697  RTPApplication& app, uint32 iface) :
698  ServiceQueue(membersSize,app)
699  { build(ia,dataPort,controlPort,iface); }
700 
715  TRTPSessionBaseIPV6(uint32 ssrc,
716  const IPV6Multicast& ia, tpport_t dataPort,
717  tpport_t controlPort, uint32 membersSize,
718  RTPApplication& app, uint32 iface) :
719  ServiceQueue(ssrc,membersSize,app)
720  { build(ia,dataPort,controlPort,iface); }
721 
722  virtual size_t dispatchBYE(const std::string &str)
723  {
724  return QueueRTCPManager::dispatchBYE(str);
725  }
726 
727  inline virtual
728  ~TRTPSessionBaseIPV6()
729  {
730  endSocket();
731  }
732 
733  inline RTPDataChannel *getDSO(void)
734  {return dso;}
735 
736 protected:
740  inline bool
741  isPendingData(microtimeout_t timeout)
742  { return dso->isPendingRecv(timeout); }
743 
744  inline IPV6Host
745  getDataSender(tpport_t *port = NULL) const
746  { return dso->getSender(port); }
747 
748  inline size_t
749  getNextDataPacketSize() const
750  { return dso->getNextPacketSize(); }
751 
761  inline size_t
762  recvData(unsigned char* buffer, size_t len,
763  IPV6Host& na, tpport_t& tp)
764  { na = dso->getSender(tp); return dso->recv(buffer, len); }
765 
766  inline void
767  setDataPeerIPV6(const IPV6Host &host, tpport_t port)
768  { dso->setPeer(host,port); }
769 
774  inline size_t
775  sendDataIPV6(const unsigned char* const buffer, size_t len)
776  { return dso->send(buffer, len); }
777 
778  inline SOCKET getDataRecvSocket() const
779  { return dso->getRecvSocket(); }
780 
785  inline bool
786  isPendingControl(microtimeout_t timeout)
787  { return cso->isPendingRecv(timeout); }
788 
789  inline IPV6Host
790  getControlSender(tpport_t *port = NULL) const
791  { return cso->getSender(port); }
792 
802  inline size_t
803  recvControl(unsigned char *buffer, size_t len,
804  IPV6Host& na, tpport_t& tp)
805  { na = cso->getSender(tp); return cso->recv(buffer,len); }
806 
807  inline void
808  setControlPeerIPV6(const IPV6Host &host, tpport_t port)
809  { cso->setPeer(host,port); }
810 
816  inline size_t
817  sendControl(const unsigned char* const buffer, size_t len)
818  { return cso->send(buffer,len); }
819 
820  inline SOCKET getControlRecvSocket() const
821  { return cso->getRecvSocket(); }
822 
823  inline void
824  endSocket()
825  {
826  dso->endSocket();
827  cso->endSocket();
828  if (dso) delete dso;
829  dso = NULL;
830  if (cso) delete cso;
831  cso = NULL;
832  }
833 
834 private:
835  void
836  build(const IPV6Host& ia, tpport_t dataPort,
837  tpport_t controlPort)
838  {
839  if ( 0 == controlPort ) {
840  dataBasePort = even_port(dataPort);
841  controlBasePort = dataBasePort + 1;
842  } else {
843  dataBasePort = dataPort;
844  controlBasePort = controlPort;
845  }
846  dso = new RTPDataChannel(ia,dataBasePort);
847  cso = new RTCPChannel(ia,controlBasePort);
848  }
849 
850  void
851  build(const IPV6Multicast& ia, tpport_t dataPort,
852  tpport_t controlPort, uint32 iface)
853  {
854  if ( 0 == controlPort ) {
855  dataBasePort = even_port(dataPort);
856  controlBasePort = dataBasePort + 1;
857  } else {
858  dataBasePort = dataPort;
859  controlBasePort = controlPort;
860  }
861  dso = new RTPDataChannel(IPV6Host("0.0.0.0"),dataBasePort);
862  cso = new RTCPChannel(IPV6Host("0.0.0.0"),controlBasePort);
863  joinGroup(ia,iface);
864  }
865 
872  inline Socket::Error
873  joinGroup(const IPV6Multicast& ia, uint32 iface)
874  {
875  Socket::Error error = dso->setMulticast(true);
876  if ( error ) return error;
877  error = dso->join(ia,iface);
878  if ( error ) return error;
879  error = cso->setMulticast(true);
880  if ( error ) {
881  dso->drop(ia);
882  return error;
883  }
884  error = cso->join(ia,iface);
885  if ( error ) {
886  dso->drop(ia);
887  return error;
888  }
889  return Socket::errSuccess;
890  }
891 
898  inline Socket::Error
899  leaveGroup(const IPV6Multicast& ia)
900  {
901  Socket::Error error = dso->setMulticast(false);
902  if ( error ) return error;
903  error = dso->leaveGroup(ia);
904  if ( error ) return error;
905  error = cso->setMulticast(false);
906  if ( error ) return error;
907  return cso->leaveGroup(ia);
908  }
909 
916  inline Socket::Error
917  setMcastTTL(uint8 ttl)
918  {
919  Socket::Error error = dso->setMulticast(true);
920  if ( error ) return error;
921  error = dso->setTimeToLive(ttl);
922  if ( error ) return error;
923  error = cso->setMulticast(true);
924  if ( error ) return error;
925  return cso->setTimeToLive(ttl);
926  }
927 
935  inline tpport_t
936  odd_port(tpport_t port)
937  { return (port & 0x01)? (port) : (port - 1); }
938 
946  inline tpport_t
947  even_port(tpport_t port)
948  { return (port & 0x01)? (port - 1) : (port); }
949 
950  tpport_t dataBasePort;
951  tpport_t controlBasePort;
952 
953 protected:
954  RTPDataChannel* dso;
955  RTCPChannel* cso;
956  friend class RTPSessionBaseHandler;
957 };
958 
969 template
970 <class RTPDataChannel = DualRTPUDPIPv6Channel,
971  class RTCPChannel = DualRTPUDPIPv6Channel,
972  class ServiceQueue = AVPQueue>
973 class __EXPORT SingleThreadRTPSessionIPV6 :
974  protected Thread,
975  public TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>
976 {
977 public:
978  SingleThreadRTPSessionIPV6(const IPV6Host& ia,
979  tpport_t dataPort = DefaultRTPDataPort,
980  tpport_t controlPort = 0,
981  int pri = 0,
982  uint32 memberssize =
985 #if defined(_MSC_VER) && _MSC_VER >= 1300
986  );
987 #else
988  ):
989  Thread(pri),
990  TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>
991  (ia,dataPort,controlPort,memberssize,app)
992 { }
993 #endif
994 
995 SingleThreadRTPSessionIPV6(const IPV6Multicast& ia,
996  tpport_t dataPort = DefaultRTPDataPort,
997  tpport_t controlPort = 0,
998  int pri = 0,
999  uint32 memberssize =
1002  uint32 iface = 0
1003 #if defined(_MSC_VER) && _MSC_VER >= 1300
1004  );
1005 #else
1006  ):
1007  Thread(pri),
1008  TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>
1009  (ia,dataPort,controlPort,memberssize,app,iface)
1010 { }
1011 #endif
1012 
1013 ~SingleThreadRTPSessionIPV6()
1014 {
1015  if (isRunning()) {
1016  disableStack(); Thread::join();
1017  }
1018 }
1019 
1020 #if defined(_MSC_VER) && _MSC_VER >= 1300
1021 virtual void startRunning();
1022 #else
1026 void
1027 startRunning()
1028 { enableStack(); Thread::start(); }
1029 #endif
1030 
1031 
1032 protected:
1033 inline void enableStack(void)
1034 {TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::enableStack();}
1035 
1036 inline void disableStack(void)
1037 {TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::disableStack();}
1038 
1039 inline microtimeout_t getSchedulingTimeout(void)
1040 {return TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::getSchedulingTimeout();}
1041 
1042 inline void controlReceptionService(void)
1043 {TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::controlReceptionService();}
1044 
1045 inline void controlTransmissionService(void)
1046 {TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::controlTransmissionService();}
1047 
1048 inline timeval getRTCPCheckInterval(void)
1049 {return TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::getRTCPCheckInterval();}
1050 
1051 inline size_t dispatchDataPacket(void)
1052 {return TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::dispatchDataPacket();}
1053 
1054 #if defined(_MSC_VER) && _MSC_VER >= 1300
1055 virtual void run(void);
1056 
1057 virtual void timerTick(void);
1058 
1059 virtual bool isPendingData(microtimeout_t timeout);
1060 #else
1061 
1062 virtual void timerTick(void)
1063 {return;}
1064 
1065 virtual bool isPendingData(microtimeout_t timeout)
1066 {return TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::isPendingData(timeout);}
1067 
1072 virtual void run(void)
1073 {
1074  microtimeout_t timeout = 0;
1075  while ( ServiceQueue::isActive() ) {
1076  if ( timeout < 1000 ){ // !(timeout/1000)
1077  timeout = getSchedulingTimeout();
1078  }
1079  controlReceptionService();
1080  controlTransmissionService();
1081  microtimeout_t maxWait =
1082  timeval2microtimeout(getRTCPCheckInterval());
1083  // make sure the scheduling timeout is
1084  // <= the check interval for RTCP
1085  // packets
1086  timeout = (timeout > maxWait)? maxWait : timeout;
1087  if ( timeout < 1000 ) { // !(timeout/1000)
1088  dispatchDataPacket();
1089  timerTick();
1090  } else {
1091  if ( isPendingData(timeout/1000) ) {
1092  takeInDataPacket();
1093  }
1094  timeout = 0;
1095  }
1096  }
1097  dispatchBYE("GNU ccRTP stack finishing.");
1098  Thread::exit();
1099 }
1100 
1101 #endif
1102 
1103 inline size_t takeInDataPacket(void)
1104 {return TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::takeInDataPacket();}
1105 
1106 inline size_t dispatchBYE(const std::string &str)
1107 {return TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::dispatchBYE(str);}
1108 };
1109 
1118 typedef SingleThreadRTPSessionIPV6<> RTPSessionIPV6;
1119 
1125 typedef RTPSessionIPV6 RTPSocketIPV6;
1126 
1135  typedef SingleThreadRTPSessionIPV6<SymmetricRTPChannelIPV6,
1136  SymmetricRTPChannelIPV6> SymmetricRTPSessionIPV6;
1137 
1138 
1139 #endif
1140  // sessions
1142 
1143 END_NAMESPACE
1144 
1145 #endif //CCXX_RTP_RTP_H_
1146 
microtimeout_t timeval2microtimeout(const timeval &t)
Convert a time interval, expressed as a timeval value into a microseconds counter.
Definition: base.h:90
uint32 microtimeout_t
Time interval expressed in microseconds.
Definition: base.h:67
const tpport_t DefaultRTPDataPort
registered default RTP data transport port
Definition: base.h:109
Definition of socket classes for different underlying transport and/or network protocols that can be ...
This class, an RTP/RTCP queue, adds audio/video profile (AVP) specific methods to the generic RTCP se...
Definition: cqueue.h:709
virtual size_t takeInDataPacket()
This function is used by the service thread to process the next incoming packet and place it in the r...
static const size_t defaultMembersHashSize
Definition: iqueue.h:854
microtimeout_t getSchedulingTimeout()
This computes the timeout period for scheduling transmission of the next packet at the "head" of the ...
size_t dispatchDataPacket()
This function is used by the service thread to process the next outgoing packet pending in the sendin...
void controlReceptionService()
Process incoming RTCP packets pending in the control reception socket.
void controlTransmissionService()
Build and send RTCP packets following timing rules (including the "timer reconsideration" algorithm).
timeval getRTCPCheckInterval()
Definition: cqueue.h:362
size_t dispatchBYE(const std::string &reason)
This method is used to send an RTCP BYE packet.
An RTP application, holding identifying RTCP SDES item values.
Definition: sources.h:365
A UDP/IPv4 socket class targetted at RTP stacks.
Definition: channel.h:95
void disableStack()
Disable packet queue processing in the stack.
Definition: ioqueue.h:129
void enableStack()
Enable packet queue processing in the stack.
Definition: ioqueue.h:123
Definition: pool.h:54
This template class adds the threading aspect to the RTPSessionBase template in one of the many possi...
Definition: rtp.h:421
void controlTransmissionService(void)
Definition: rtp.h:526
size_t dispatchDataPacket(void)
Definition: rtp.h:532
virtual void timerTick(void)
Definition: rtp.h:543
microtimeout_t getSchedulingTimeout(void)
Definition: rtp.h:520
void enableStack(void)
Definition: rtp.h:517
virtual bool isPendingData(microtimeout_t timeout)
Definition: rtp.h:546
virtual void run(void)
Single runnable method for this RTP stacks, schedules outgoing and incoming RTP data and RTCP packets...
Definition: rtp.h:553
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:475
size_t takeInDataPacket(void)
Definition: rtp.h:586
void controlReceptionService(void)
Definition: rtp.h:523
timeval getRTCPCheckInterval(void)
Definition: rtp.h:529
~SingleThreadRTPSession()
Definition: rtp.h:494
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:440
void disableStack(void)
Definition: rtp.h:514
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:423
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:457
size_t dispatchBYE(const std::string &str)
Definition: rtp.h:589
void startRunning()
Activate stack and start service thread.
Definition: rtp.h:508
Definition: rtp.h:88
void setControlPeer(const InetAddress &host, tpport_t port)
Definition: rtp.h:267
virtual size_t dispatchBYE(const std::string &str)
Definition: rtp.h:162
Socket::Error setMcastTTL(uint8 ttl)
Set the value of the TTL field in the sent packets.
Definition: rtp.h:174
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:155
InetHostAddress getDataSender(tpport_t *port=NULL) const
Definition: rtp.h:203
void endSocket()
Definition: rtp.h:327
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:135
RTPDataChannel * dso
Definition: rtp.h:399
size_t sendControl(const unsigned char *const buffer, size_t len)
Definition: rtp.h:276
RTPDataChannel * getDSO(void)
Definition: rtp.h:191
bool isPendingData(microtimeout_t timeout)
Definition: rtp.h:199
bool isPendingControl(microtimeout_t timeout)
Definition: rtp.h:245
Socket::Error joinGroup(const InetMcastAddress &ia, uint32 iface)
Join a multicast group.
Definition: rtp.h:289
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:116
size_t recvData(unsigned char *buffer, size_t len, InetHostAddress &na, tpport_t &tp)
Receive data from the data channel/socket.
Definition: rtp.h:220
size_t sendData(const unsigned char *const buffer, size_t len)
Definition: rtp.h:234
SOCKET getDataRecvSocket() const
Definition: rtp.h:237
virtual ~TRTPSessionBase()
Definition: rtp.h:186
size_t getNextDataPacketSize() const
Definition: rtp.h:207
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:99
Socket::Error leaveGroup(const InetMcastAddress &ia)
Leave a multicast group.
Definition: rtp.h:315
size_t recvControl(unsigned char *buffer, size_t len, InetHostAddress &na, tpport_t &tp)
Receive data from the control channel/socket.
Definition: rtp.h:262
SOCKET getControlRecvSocket() const
Definition: rtp.h:279
void setDataPeer(const InetAddress &host, tpport_t port)
Definition: rtp.h:225
RTCPChannel * cso
Definition: rtp.h:400
InetHostAddress getControlSender(tpport_t *port=NULL) const
Definition: rtp.h:249
Generic RTCP control queues.
SingleThreadRTPSession RTPSession
Uses two pairs of sockets for RTP data and RTCP transmission/reception.
Definition: rtp.h:601
SingleThreadRTPSession< SymmetricRTPChannel, SymmetricRTPChannel > SymmetricRTPSession
Uses one pair of sockets, (1) for RTP data and (2) for RTCP transmission/reception.
Definition: rtp.h:619
RTPSession RTPSocket
Alias for RTPSession.
Definition: rtp.h:608
SingleRTPChannel SymmetricRTPChannel
Actually, RTP with a single channel can be called 'Symmetric RTP'.
Definition: channel.h:455
DualRTPChannel< RTPBaseUDPIPv4Socket > DualRTPUDPIPv4Channel
Definition: channel.h:444
__EXPORT RTPApplication & defaultApplication()
Get the RTPApplication object for the "default" application (the only one used by common applications...