1 /**********
2 This library is free software; you can redistribute it and/or modify it under
3 the terms of the GNU Lesser General Public License as published by the
4 Free Software Foundation; either version 3 of the License, or (at your
5 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6 
7 This library is distributed in the hope that it will be useful, but WITHOUT
8 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
10 more details.
11 
12 You should have received a copy of the GNU Lesser General Public License
13 along with this library; if not, write to the Free Software Foundation, Inc.,
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
15 **********/
16 // "liveMedia"
17 // Copyright (c) 1996-2020 Live Networks, Inc.  All rights reserved.
18 // A simple RTP sink that packs frames into each outgoing
19 //     packet, without any fragmentation or special headers.
20 // C++ header
21 
22 #ifndef _SIMPLE_RTP_SINK_HH
23 #define _SIMPLE_RTP_SINK_HH
24 
25 #ifndef _MULTI_FRAMED_RTP_SINK_HH
26 #include "MultiFramedRTPSink.hh"
27 #endif
28 
29 class SimpleRTPSink: public MultiFramedRTPSink {
30 public:
31   static SimpleRTPSink*
32   createNew(UsageEnvironment& env, Groupsock* RTPgs,
33 	    unsigned char rtpPayloadFormat,
34 	    unsigned rtpTimestampFrequency,
35 	    char const* sdpMediaTypeString,
36 	    char const* rtpPayloadFormatName,
37 	    unsigned numChannels = 1,
38 	    Boolean allowMultipleFramesPerPacket = True,
39 	    Boolean doNormalMBitRule = True);
40   // "doNormalMBitRule" means: If the medium (i.e., "sdpMediaTypeString") is other than "audio", set the RTP "M" bit
41   // on each outgoing packet iff it contains the last (or only) fragment of a frame.
42   // Otherwise (i.e., if "doNormalMBitRule" is False, or the medium is "audio"), leave the "M" bit unset.
43 
setMBitOnNextPacket()44   void setMBitOnNextPacket() { fSetMBitOnNextPacket = True; } // hack for optionally setting the RTP 'M' bit from outside the class
45 
46 protected:
47   SimpleRTPSink(UsageEnvironment& env, Groupsock* RTPgs,
48 		unsigned char rtpPayloadFormat,
49 		unsigned rtpTimestampFrequency,
50 		char const* sdpMediaTypeString,
51 		char const* rtpPayloadFormatName,
52 		unsigned numChannels,
53 		Boolean allowMultipleFramesPerPacket,
54 		Boolean doNormalMBitRule);
55 	// called only by createNew()
56 
57   virtual ~SimpleRTPSink();
58 
59 protected: // redefined virtual functions
60   virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
61                                       unsigned char* frameStart,
62                                       unsigned numBytesInFrame,
63                                       struct timeval framePresentationTime,
64                                       unsigned numRemainingBytes);
65   virtual
66   Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,
67 					 unsigned numBytesInFrame) const;
68   virtual char const* sdpMediaType() const;
69 
70 private:
71   char const* fSDPMediaTypeString;
72   Boolean fAllowMultipleFramesPerPacket;
73   Boolean fSetMBitOnLastFrames, fSetMBitOnNextPacket;
74 };
75 
76 #endif
77