CSL  5.2
RtpSender.h
Go to the documentation of this file.
1 //
2 // RemoteIO.h -- CSL I/O Port for sending sample buffers out over UDP or TCP-IP sockets
3 // (in response to request packets sent from a RtpReceiver client)
4 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
5 //
6 // This is an output driver that receives call-backs from a remote client over a network socket
7 // and calls on its DSP graph to generate a buffer of samples.
8 // See the comment in RtpReceiver.h for a description of the packet format
9 //
10 // Note to self: The RTP sender is triggered from the nextBuffer call
11 //
12 
13 #ifndef CSL_RTPSENDER_H
14 #define CSL_RTPSENDER_H
15 
16 #include "CSL_Core.h"
17 //#include "CslRtpIncludes.h"
18 #include "CslRtpSession.h"
19 #include "ThreadUtilities.h"
20 
21 namespace csl {
22 
23 // the RemoteIO class
24 
25 // TODO: This should be a variable that can be adjusted or set on the constructor
26 #define RTP_BUFFER_SIZE (4410)
27 
28 // So this really isn't an "effect", but you connect it serially in the existing signal
29 // chain, thus it conforms to the Effect interface
30 
31 class RtpSender : public Effect, public CslRtpSession {
32 
33 public: // These data members are public so that they can be used from the thread call
34  RtpSender(unsigned chans = 1);
35  ~RtpSender();
36 
37  // The work method...
38  void nextBuffer(Buffer &outputBuffer, unsigned outBufNum) throw (Exception);
39 
40  bool createRtpSession();
41 
42  bool addRtpDestination(char * remoteIP, unsigned short remotePort);
43  bool removeRtpDestination();
44  void printError(int rtperr);
45 
46 protected:
47  unsigned mNumChans; // The default # of channels sent over RTP
49 
50  unsigned mBufferFrames;
51 
52  unsigned mRemotePort; ///< The network port I send to
53  unsigned mLocalPort; ///< The network port I listen on
54  unsigned mRemoteIP; ///< The IP address of the client in host byte order
55  unsigned mLocalIP; ///< My IP address in host byte order
56  string mCName; ///< The CName of my computer
57  string mEmail; ///< My email I want registered with RTP
58  int mLastPacketNumber; ///< The RTP ID of the last packet sent (or -1 if none)
59  int mPayloadType; ///< The RTP payload type we are sending
60 
61  RTPUDPv4TransmissionParams * mTransparams; // We are using UDP over IPv4
62  RTPSessionParams * mSessparams;
63  RTPIPv4Address * mAddress;
64 
65 #ifdef DO_TIMING // This is for the performance timing code
66  struct timeval mThen, mNow; // Used for getting the real time
67  long mTimeVals, mThisSec; // Used for CPU usage statistics
68  long mTimeSum;
69 #endif
70 
71 
72 };
73 
74 }
75 
76 #endif
77