sipxmedialib  Version 3.3
RTCPSource.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006-2013 SIPez LLC. All rights reserved.
3 //
4 // Copyright (C) 2004-2006 SIPfoundry Inc.
5 // Licensed by SIPfoundry under the LGPL license.
6 //
7 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
8 // Licensed to SIPfoundry under a Contributor Agreement.
9 //
10 // $$
12 
13 
14 // Border Guard
15 #ifndef _RTCPSource_h
16 #define _RTCPSource_h
17 
18 #include "rtcp/RtcpConfig.h"
19 
20 // Includes
21 #include "TLinkedList.h"
22 #include "RTCPHeader.h"
23 #include "ByeReport.h"
24 #include "SenderReport.h"
25 #include "ReceiverReport.h"
26 #include "SourceDescription.h"
27 #include "IRTCPStatistics.h"
28 #include "INetDispatch.h"
29 #include "IRTCPNotify.h"
30 
31 #ifdef __pingtel_on_posix__
32 #include <netinet/in.h>
33 #endif
34 
54  public CBaseClass, // Inherits CBaseClass implementation
55  public INetDispatch, // RTCP Report Input Interface
56  public IRTCPStatistics // RTCP Statistics Retrieval Interface
57  {
58 
59 // Public Methods
60 public:
61 
87  CRTCPSource(ssrc_t ulSSRC, IRTCPNotify *piRTCPNotify,
88  ISetReceiverStatistics *piSetStatistics);
89 
90 
119  virtual ~CRTCPSource(void);
120 
155  void ProcessPacket(unsigned char *puchDataBuffer,
156  unsigned long ulBufferLength, int verbose=0);
157 
177 
178 private: // Private Methods
179 
180 
205  void SendRTCPEvent(unsigned long ulEventType,
206  void *pvInterface,
207  unsigned long ulChangeMask=0);
208 
240  unsigned long ProcessSenderReport(unsigned char *puchRTCPReport);
241 
242 
273  unsigned long ProcessReceiverReport(unsigned char *puchRTCPReport,
274  unsigned long ulReportCount = 0);
275 
276 
307  unsigned long ProcessSDESReport(unsigned char *puchRTCPReport);
308 
330  unsigned long ProcessByeReport(unsigned char *puchRTCPReport);
331 
332 
354  unsigned long ProcessAppReport(unsigned char *puchRTCPReport);
355 
356 
386  void GetStatistics(IGetSrcDescription **piGetSrcDescription,
387  IGetSenderStatistics **piSenderStatistics,
388  IGetReceiverStatistics **piReceiverStatistics,
389  IGetByeInfo **piGetByeInfo);
390 
408  RTCP_REPORTS_ET GetPayloadType(unsigned char *puchRTCPBuffer);
409 
410 
429  ssrc_t GetSenderSSRC(bool bHeader, unsigned char *puchRTCPBuffer);
430 
431 
450  ssrc_t GetReceiverSSRC(bool bRTCPHeader,
451  unsigned char *puchRTCPBuffer);
452 
470  unsigned long GetReportCount(unsigned char *puchRTCPBuffer);
471 
472 
490  unsigned long GetReportLength(unsigned char *puchRTCPBuffer);
491 
492 
493 private: // Private Data Members
494 
506 
507 
518  IRTCPNotify * m_piRTCPNotify;
519 
520 
532  ISetReceiverStatistics *m_piSetReceiverStatistics;
533 
546 
547 
561 
574 
587 
588 };
589 
590 
608 inline RTCP_REPORTS_ET
609  CRTCPSource::GetPayloadType(unsigned char *puchRTCPBuffer)
610 {
611 
612 // Snoop into the packet header and return the payload type
613  return((RTCP_REPORTS_ET)*(puchRTCPBuffer + PAYLOAD_OFFSET));
614 
615 }
616 
617 
635 inline ssrc_t CRTCPSource::GetSenderSSRC(bool bRTCPHeader, unsigned char *puchRTCPBuffer)
636 {
637 
638 // Advance over RTCP Header if one exists
639  if(bRTCPHeader)
640  puchRTCPBuffer += SSRC_OFFSET;
641 
642 // Return Sender SSRC
643  return(ntohl(*((ssrc_t *)puchRTCPBuffer)));
644 
645 }
646 
647 
666 inline ssrc_t CRTCPSource::GetReceiverSSRC(bool bRTCPHeader,
667  unsigned char *puchRTCPBuffer)
668 {
669 
670 // Advance over RTCP Header if one exists
671  if(bRTCPHeader)
672  puchRTCPBuffer += HEADER_LENGTH;
673 
674 // Return Receiver SSRC
675  return(ntohl(*((ssrc_t *)puchRTCPBuffer)));
676 
677 }
678 
696 inline unsigned long CRTCPSource::GetReportCount(unsigned char *puchRTCPBuffer)
697 {
698 
699 // Extract Report Count
700  return(*puchRTCPBuffer & COUNT_MASK);
701 
702 }
703 
721 inline unsigned long CRTCPSource::GetReportLength(unsigned char *puchRTCPBuffer)
722 {
723 
724 // Extract Report Length
725  unsigned long ulReportLength =
726  ntohs(*((unsigned short *)(puchRTCPBuffer + LENGTH_OFFSET))) + 1;
727 
728  return(ulReportLength * sizeof(uint32_t));
729 
730 }
731 #endif
unsigned long ProcessReceiverReport(unsigned char *puchRTCPReport, unsigned long ulReportCount=0)
Definition: RTCPSource.h:53
void ProcessPacket(unsigned char *puchDataBuffer, unsigned long ulBufferLength, int verbose=0)
#define HEADER_LENGTH
Definition: RTCPHeader.h:27
ssrc_t GetReceiverSSRC(bool bRTCPHeader, unsigned char *puchRTCPBuffer)
Definition: RTCPSource.h:666
unsigned long GetReportLength(unsigned char *puchRTCPBuffer)
Definition: RTCPSource.h:721
CByeReport * m_poByeReport
Definition: RTCPSource.h:586
ssrc_t GetSenderSSRC(bool bHeader, unsigned char *puchRTCPBuffer)
Definition: RTCPSource.h:635
unsigned long ProcessSDESReport(unsigned char *puchRTCPReport)
RTCP_REPORTS_ET
Definition: IRTCPHeader.h:23
interface IGetSenderStatistics IGetReceiverStatistics ** piReceiverStatistics
Definition: IRTCPStatistics.h:74
interface IGetSenderStatistics ** piSenderStatistics
Definition: IRTCPStatistics.h:74
#define SSRC_OFFSET
Definition: RTCPHeader.h:31
ISetReceiverStatistics * m_piSetReceiverStatistics
Definition: RTCPSource.h:532
#define COUNT_MASK
Definition: RTCPHeader.h:32
RTCP_REPORTS_ET GetPayloadType(unsigned char *puchRTCPBuffer)
Definition: RTCPSource.h:609
CSenderReport * m_poSenderReport
Definition: RTCPSource.h:573
unsigned long GetReportCount(unsigned char *puchRTCPBuffer)
Definition: RTCPSource.h:696
virtual ~CRTCPSource(void)
IRTCPNotify * m_piRTCPNotify
Definition: RTCPSource.h:518
CTLinkedList< CSourceDescription * > m_tSrcDescriptorList
Definition: RTCPSource.h:545
#define DECLARE_IBASE_M
Definition: BaseClass.h:368
uint32_t ssrc_t
Definition: RtcpConfig.h:62
ssrc_t m_ulSSRC
Definition: RTCPSource.h:505
#define PAYLOAD_OFFSET
Definition: RTCPHeader.h:29
unsigned long ProcessByeReport(unsigned char *puchRTCPReport)
Definition: ByeReport.h:44
Definition: BaseClass.h:118
Definition: SenderReport.h:49
void GetStatistics(IGetSrcDescription **piGetSrcDescription, IGetSenderStatistics **piSenderStatistics, IGetReceiverStatistics **piReceiverStatistics, IGetByeInfo **piGetByeInfo)
void SendRTCPEvent(unsigned long ulEventType, void *pvInterface, unsigned long ulChangeMask=0)
unsigned long ProcessAppReport(unsigned char *puchRTCPReport)
unsigned long ProcessSenderReport(unsigned char *puchRTCPReport)
CRTCPSource(ssrc_t ulSSRC, IRTCPNotify *piRTCPNotify, ISetReceiverStatistics *piSetStatistics)
CTLinkedList< CReceiverReport * > m_tReceiverReportList
Definition: RTCPSource.h:560
interface IGetSenderStatistics IGetReceiverStatistics IGetByeInfo ** piGetByeInfo
Definition: IRTCPStatistics.h:74
interface unsigned long ulBufferLength
Definition: INetDispatch.h:63
#define LENGTH_OFFSET
Definition: RTCPHeader.h:30