| 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 | // DV Video RTP Sources |
| 19 | // Implementation |
| 20 | |
| 21 | #include "DVVideoRTPSource.hh" |
| 22 | |
| 23 | DVVideoRTPSource* |
| 24 | DVVideoRTPSource::createNew(UsageEnvironment& env, |
| 25 | Groupsock* RTPgs, |
| 26 | unsigned char rtpPayloadFormat, |
| 27 | unsigned rtpTimestampFrequency) { |
| 28 | return new DVVideoRTPSource(env, RTPgs, rtpPayloadFormat, rtpTimestampFrequency); |
| 29 | } |
| 30 | |
| 31 | DVVideoRTPSource::DVVideoRTPSource(UsageEnvironment& env, |
| 32 | Groupsock* rtpGS, |
| 33 | unsigned char rtpPayloadFormat, |
| 34 | unsigned rtpTimestampFrequency) |
| 35 | : MultiFramedRTPSource(env, rtpGS, |
| 36 | rtpPayloadFormat, rtpTimestampFrequency) { |
| 37 | } |
| 38 | |
| 39 | DVVideoRTPSource::~DVVideoRTPSource() { |
| 40 | } |
| 41 | |
| 42 | #define DV_DIF_BLOCK_SIZE 80 |
| 43 | #define 0x1F |
| 44 | |
| 45 | Boolean DVVideoRTPSource |
| 46 | ::(BufferedPacket* packet, |
| 47 | unsigned& ) { |
| 48 | unsigned const packetSize = packet->dataSize(); |
| 49 | if (packetSize < DV_DIF_BLOCK_SIZE) return False; // TARFU! |
| 50 | |
| 51 | u_int8_t const* data = packet->data(); |
| 52 | fCurrentPacketBeginsFrame = data[0] == DV_SECTION_HEADER && (data[1]&0xf8) == 0 && data[2] == 0; // thanks to Ben Hutchings |
| 53 | |
| 54 | // The RTP "M" (marker) bit indicates the last fragment of a frame: |
| 55 | fCurrentPacketCompletesFrame = packet->rtpMarkerBit(); |
| 56 | |
| 57 | // There is no special header |
| 58 | resultSpecialHeaderSize = 0; |
| 59 | return True; |
| 60 | } |
| 61 | |
| 62 | char const* DVVideoRTPSource::MIMEtype() const { |
| 63 | return "video/DV" ; |
| 64 | } |
| 65 | |
| 66 | |