| 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 | // MPEG-1 or MPEG-2 Audio RTP Sources |
| 19 | // Implementation |
| 20 | |
| 21 | #include "MPEG1or2AudioRTPSource.hh" |
| 22 | |
| 23 | MPEG1or2AudioRTPSource* |
| 24 | MPEG1or2AudioRTPSource::createNew(UsageEnvironment& env, |
| 25 | Groupsock* RTPgs, |
| 26 | unsigned char rtpPayloadFormat, |
| 27 | unsigned rtpTimestampFrequency) { |
| 28 | return new MPEG1or2AudioRTPSource(env, RTPgs, rtpPayloadFormat, |
| 29 | rtpTimestampFrequency); |
| 30 | } |
| 31 | |
| 32 | MPEG1or2AudioRTPSource::MPEG1or2AudioRTPSource(UsageEnvironment& env, |
| 33 | Groupsock* rtpGS, |
| 34 | unsigned char rtpPayloadFormat, |
| 35 | unsigned rtpTimestampFrequency) |
| 36 | : MultiFramedRTPSource(env, rtpGS, |
| 37 | rtpPayloadFormat, rtpTimestampFrequency) { |
| 38 | } |
| 39 | |
| 40 | MPEG1or2AudioRTPSource::~MPEG1or2AudioRTPSource() { |
| 41 | } |
| 42 | |
| 43 | Boolean MPEG1or2AudioRTPSource |
| 44 | ::(BufferedPacket* packet, |
| 45 | unsigned& ) { |
| 46 | // There's a 4-byte header indicating fragmentation. |
| 47 | if (packet->dataSize() < 4) return False; |
| 48 | |
| 49 | // Note: This fragmentation header is actually useless to us, because |
| 50 | // it doesn't tell us whether or not this RTP packet *ends* a |
| 51 | // fragmented frame. Thus, we can't use it to properly set |
| 52 | // "fCurrentPacketCompletesFrame". Instead, we assume that even |
| 53 | // a partial audio frame will be usable to clients. |
| 54 | |
| 55 | resultSpecialHeaderSize = 4; |
| 56 | return True; |
| 57 | } |
| 58 | |
| 59 | char const* MPEG1or2AudioRTPSource::MIMEtype() const { |
| 60 | return "audio/MPEG" ; |
| 61 | } |
| 62 | |
| 63 | |