1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 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
26SimpleRTPSource*
27SimpleRTPSource::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
38SimpleRTPSource
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
50SimpleRTPSource::~SimpleRTPSource() {
51 delete[] (char*)fMIMEtypeString;
52}
53
54Boolean SimpleRTPSource
55::processSpecialHeader(BufferedPacket* packet,
56 unsigned& resultSpecialHeaderSize) {
57 fCurrentPacketCompletesFrame
58 = !fUseMBitForFrameEnd || packet->rtpMarkerBit();
59
60 resultSpecialHeaderSize = fOffset;
61 return True;
62}
63
64char const* SimpleRTPSource::MIMEtype() const {
65 if (fMIMEtypeString == NULL) return MultiFramedRTPSource::MIMEtype();
66
67 return fMIMEtypeString;
68}
69