sipxmedialib  Version 3.3
MprToNet.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006-2018 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 #ifndef _MprToNet_h_
15 #define _MprToNet_h_
16 
17 #include "rtcp/RtcpConfig.h"
18 
19 // Defining this option includes debug code for introducing sudden changes
20 // to several fields of the outgoing RTP headers (SSRC, seq#, timestamp).
21 #define ENABLE_PACKET_HACKING
22 #undef ENABLE_PACKET_HACKING
23 
24 // SYSTEM INCLUDES
25 
26 // APPLICATION INCLUDES
27 #include "os/OsSocket.h"
28 #include "mp/NetInTask.h"
29 #include "mp/MpResourceMsg.h"
30 #ifdef INCLUDE_RTCP /* [ */
32 #endif /* INCLUDE_RTCP ] */
33 
34 // DEFINES
35 // MACROS
36 // EXTERNAL FUNCTIONS
37 // EXTERNAL VARIABLES
38 // CONSTANTS
39 // STRUCTS
40 // TYPEDEFS
41 // FORWARD DECLARATIONS
42 class MprFromNet;
43 class MpFlowGraphBase;
44 
48 class MprToNet
49 {
50 /* //////////////////////////// PUBLIC //////////////////////////////////// */
51 public:
52 
57  };
58 
59  enum {
61  };
62 
63 #ifdef ENABLE_PACKET_HACKING /* [ */
64  static int sDebug1;
65  static int sDebug2;
66  static int sDebug3;
67  static int sDebug4;
68  static int sDebug5;
69 #endif /* ENABLE_PACKET_HACKING ] */
70 
71 /* ============================ CREATORS ================================== */
73 
74 
76  MprToNet();
77 
79  virtual
80  ~MprToNet();
81 
83 
84 /* ============================ MANIPULATORS ============================== */
86 
87 
89  OsStatus setSockets(OsSocket& rRtpSocket, OsSocket& rRtcpSocket);
94  OsStatus resetSockets();
100  OsStatus setRtpPal(MprFromNet* pal);
102 
103  virtual int writeRtp(int payloadType, UtlBoolean markerState,
104  const unsigned char* payloadData, int payloadOctets, unsigned int timestamp,
105  void* csrcList);
106 
107  // set the # of microseconds of skew to add to the RTCP SR timestamps
108  void setSRAdjustUSecs(int iUSecs);
109  // send a message via flowgraph to set the # of microseconds of skew
110  // the namedResource will be one of the Connections (e.g. MpRtpOutputConnection).
111  static OsStatus setSRAdjustUSecs(const UtlString& namedResource, OsMsgQ& fgQ, int adjustUSecs);
112 
114 
115 /* ============================ ACCESSORS ================================= */
117 
118 
120  OsStatus setFlowGraph(MpFlowGraphBase* flowgraph);
121 
122  void setSSRC(ssrc_t iSSRC);
123  inline RtpSRC getSSRC() const;
124 #ifdef INCLUDE_RTCP /* [ */
125  void setRTPAccumulator(ISetSenderStatistics *piRTPAccumulator);
126 #endif /* INCLUDE_RTCP ] */
127 
128 
129 /* ============================ INQUIRY =================================== */
131 
132 
134 
135 /* //////////////////////////// PROTECTED ///////////////////////////////// */
136 protected:
137 
138 /* //////////////////////////// PRIVATE /////////////////////////////////// */
139 private:
140 
146 #ifdef DEBUG /* [ */
147  unsigned int mRtpSampleCounter;
148 #endif /* DEBUG ] */
149 
150  // RTP State
151  unsigned int mTimestampDelta;
152  unsigned int mSeqNum;
153  unsigned int mSSRC;
154  OsSocket* mpRtpSocket;
155  OsSocket* mpRtcpSocket;
158 
159 #ifdef ENABLE_PACKET_HACKING /* [ */
160  void adjustRtpPacket(struct RtpHeader* p);
161 #endif /* ENABLE_PACKET_HACKING ] */
162 
163 #ifdef INCLUDE_RTCP /* [ */
164  ISetSenderStatistics *mpiRTPAccumulator;
166 #endif /* INCLUDE_RTCP ] */
167 
169 
171  MprToNet(const MprToNet& rMprToNet);
172 
174  MprToNet& operator=(const MprToNet& rhs);
175 
176 };
177 
178 /* ============================ INLINE METHODS ============================ */
179 
181 {
182  return mSSRC;
183 }
184 
185 #endif // _MprToNet_h_
OsStatus resetSockets()
Clear the outbound RTP and RTCP sockets.
Definition: MprToNet.cpp:128
Definition: MpResourceMsg.h:56
int mNumRtcpWriteErrors
Definition: MprToNet.h:157
MprToNet & operator=(const MprToNet &rhs)
Assignment operator (not implemented for this class)
int mNumRtpWriteErrors
Definition: MprToNet.h:156
Flow graph for coordinating the execution of media processing resources.
Definition: MpFlowGraphBase.h:91
void setSRAdjustUSecs(int iUSecs)
Definition: MprToNet.cpp:380
MprToNet()
Constructor.
Definition: MprToNet.cpp:70
unsigned int mSeqNum
Definition: MprToNet.h:152
OsSocket * mpRtpSocket
Definition: MprToNet.h:154
int mRtcpFrameCount
Definition: MprToNet.h:144
unsigned int mSSRC
Definition: MprToNet.h:153
MprFromNet * mpFromNetPal
Definition: MprToNet.h:141
OsSocket * mpRtcpSocket
Definition: MprToNet.h:155
int mRtcpFrameLimit
Definition: MprToNet.h:145
void setSSRC(ssrc_t iSSRC)
Definition: MprToNet.cpp:136
RTP header as described in RFC 3550.
Definition: RtpHeader.h:43
OsStatus setSockets(OsSocket &rRtpSocket, OsSocket &rRtcpSocket)
Set the outbound RTP and RTCP sockets.
Definition: MprToNet.cpp:119
uint32_t ssrc_t
Definition: RtcpConfig.h:62
OsStatus setRtpPal(MprFromNet *pal)
Connect us to our corresponding FromNet, for RTCP stats.
Definition: MprToNet.cpp:408
The "From Network" media processing resource.
Definition: MprFromNet.h:55
The RTP writer.
Definition: MprToNet.h:48
RtpSRC getSSRC() const
Definition: MprToNet.h:180
OsStatus setFlowGraph(MpFlowGraphBase *flowgraph)
Set flowgraph in which this is used for debug purposes.
Definition: MprToNet.cpp:401
int mRtcpPackets
Definition: MprToNet.h:143
uint32_t RtpSRC
RTP SSRC or CSRC identifier.
Definition: MpTypes.h:61
virtual ~MprToNet()
Destructor.
Definition: MprToNet.cpp:94
virtual int writeRtp(int payloadType, UtlBoolean markerState, const unsigned char *payloadData, int payloadOctets, unsigned int timestamp, void *csrcList)
Definition: MprToNet.cpp:184
int mSRAdjustUSecs
Definition: MprToNet.h:168
unsigned int mTimestampDelta
Definition: MprToNet.h:151
Definition: MprToNet.h:60
MpFlowGraphBase * mpFlowGraph
for debug purposes
Definition: MprToNet.h:142