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// AC3 Audio RTP Sources
19// Implementation
20
21#include "AC3AudioRTPSource.hh"
22
23AC3AudioRTPSource*
24AC3AudioRTPSource::createNew(UsageEnvironment& env,
25 Groupsock* RTPgs,
26 unsigned char rtpPayloadFormat,
27 unsigned rtpTimestampFrequency) {
28 return new AC3AudioRTPSource(env, RTPgs, rtpPayloadFormat,
29 rtpTimestampFrequency);
30}
31
32AC3AudioRTPSource::AC3AudioRTPSource(UsageEnvironment& env,
33 Groupsock* rtpGS,
34 unsigned char rtpPayloadFormat,
35 unsigned rtpTimestampFrequency)
36 : MultiFramedRTPSource(env, rtpGS,
37 rtpPayloadFormat, rtpTimestampFrequency) {
38}
39
40AC3AudioRTPSource::~AC3AudioRTPSource() {
41}
42
43Boolean AC3AudioRTPSource
44::processSpecialHeader(BufferedPacket* packet,
45 unsigned& resultSpecialHeaderSize) {
46 unsigned char* headerStart = packet->data();
47 unsigned packetSize = packet->dataSize();
48
49 // There's a 2-byte payload header at the beginning:
50 if (packetSize < 2) return False;
51 resultSpecialHeaderSize = 2;
52
53 unsigned char FT = headerStart[0]&0x03;
54 fCurrentPacketBeginsFrame = FT != 3;
55
56 // The RTP "M" (marker) bit indicates the last fragment of a frame.
57 // In case the sender did not set the "M" bit correctly, we also test for FT == 0:
58 fCurrentPacketCompletesFrame = packet->rtpMarkerBit() || FT == 0;
59
60 return True;
61}
62
63char const* AC3AudioRTPSource::MIMEtype() const {
64 return "audio/AC3";
65}
66
67