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 RTP source for a simple RTP payload format that |
19 | // - doesn't have any special headers following the RTP header |
20 | // - doesn't have any special framing apart from the packet data itself |
21 | // Implementation |
22 | |
23 | #include "SimpleRTPSource.hh" |
24 | #include <string.h> |
25 | |
26 | SimpleRTPSource* |
27 | SimpleRTPSource::createNew(UsageEnvironment& env, |
28 | Groupsock* RTPgs, |
29 | unsigned char rtpPayloadFormat, |
30 | unsigned rtpTimestampFrequency, |
31 | char const* mimeTypeString, |
32 | unsigned offset, Boolean doNormalMBitRule) { |
33 | return new SimpleRTPSource(env, RTPgs, rtpPayloadFormat, |
34 | rtpTimestampFrequency, |
35 | mimeTypeString, offset, doNormalMBitRule); |
36 | } |
37 | |
38 | SimpleRTPSource |
39 | ::SimpleRTPSource(UsageEnvironment& env, Groupsock* RTPgs, |
40 | unsigned char rtpPayloadFormat, |
41 | unsigned rtpTimestampFrequency, |
42 | char const* mimeTypeString, |
43 | unsigned offset, Boolean doNormalMBitRule) |
44 | : MultiFramedRTPSource(env, RTPgs, |
45 | rtpPayloadFormat, rtpTimestampFrequency), |
46 | fMIMEtypeString(strDup(mimeTypeString)), fOffset(offset) { |
47 | fUseMBitForFrameEnd = doNormalMBitRule && strncmp(mimeTypeString, "audio/" , 6) != 0; |
48 | } |
49 | |
50 | SimpleRTPSource::~SimpleRTPSource() { |
51 | delete[] (char*)fMIMEtypeString; |
52 | } |
53 | |
54 | Boolean SimpleRTPSource |
55 | ::(BufferedPacket* packet, |
56 | unsigned& ) { |
57 | fCurrentPacketCompletesFrame |
58 | = !fUseMBitForFrameEnd || packet->rtpMarkerBit(); |
59 | |
60 | resultSpecialHeaderSize = fOffset; |
61 | return True; |
62 | } |
63 | |
64 | char const* SimpleRTPSource::MIMEtype() const { |
65 | if (fMIMEtypeString == NULL) return MultiFramedRTPSource::MIMEtype(); |
66 | |
67 | return fMIMEtypeString; |
68 | } |
69 | |