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 | // AC3 Audio RTP Sources |
19 | // Implementation |
20 | |
21 | #include "AC3AudioRTPSource.hh" |
22 | |
23 | AC3AudioRTPSource* |
24 | AC3AudioRTPSource::createNew(UsageEnvironment& env, |
25 | Groupsock* RTPgs, |
26 | unsigned char rtpPayloadFormat, |
27 | unsigned rtpTimestampFrequency) { |
28 | return new AC3AudioRTPSource(env, RTPgs, rtpPayloadFormat, |
29 | rtpTimestampFrequency); |
30 | } |
31 | |
32 | AC3AudioRTPSource::AC3AudioRTPSource(UsageEnvironment& env, |
33 | Groupsock* rtpGS, |
34 | unsigned char rtpPayloadFormat, |
35 | unsigned rtpTimestampFrequency) |
36 | : MultiFramedRTPSource(env, rtpGS, |
37 | rtpPayloadFormat, rtpTimestampFrequency) { |
38 | } |
39 | |
40 | AC3AudioRTPSource::~AC3AudioRTPSource() { |
41 | } |
42 | |
43 | Boolean AC3AudioRTPSource |
44 | ::(BufferedPacket* packet, |
45 | unsigned& ) { |
46 | unsigned char* = 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 | |
63 | char const* AC3AudioRTPSource::MIMEtype() const { |
64 | return "audio/AC3" ; |
65 | } |
66 | |
67 | |