| 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 | |
| 19 | |
| 20 | #include "JPEG2000VideoRTPSource.hh" |
| 21 | |
| 22 | JPEG2000VideoRTPSource* |
| 23 | JPEG2000VideoRTPSource::createNew(UsageEnvironment& env, |
| 24 | Groupsock* RTPgs, |
| 25 | unsigned char rtpPayloadFormat, |
| 26 | unsigned rtpTimestampFrequency, |
| 27 | char const* sampling) { |
| 28 | return new JPEG2000VideoRTPSource(env, RTPgs, rtpPayloadFormat, rtpTimestampFrequency, sampling); |
| 29 | } |
| 30 | |
| 31 | JPEG2000VideoRTPSource |
| 32 | ::JPEG2000VideoRTPSource(UsageEnvironment& env, Groupsock* RTPgs, |
| 33 | unsigned char rtpPayloadFormat, unsigned rtpTimestampFrequency, |
| 34 | char const* sampling) |
| 35 | : MultiFramedRTPSource(env, RTPgs, rtpPayloadFormat, rtpTimestampFrequency) { |
| 36 | fSampling = strDup(sampling); |
| 37 | } |
| 38 | |
| 39 | JPEG2000VideoRTPSource::~JPEG2000VideoRTPSource() { |
| 40 | delete[] fSampling; |
| 41 | } |
| 42 | |
| 43 | #define 8 |
| 44 | |
| 45 | Boolean JPEG2000VideoRTPSource |
| 46 | ::(BufferedPacket* packet, |
| 47 | unsigned& ) { |
| 48 | unsigned char* = packet->data(); |
| 49 | unsigned packetSize = packet->dataSize(); |
| 50 | |
| 51 | // There should be enough space for a payload header: |
| 52 | if (packetSize < JPEG2000_PAYLOAD_HEADER_SIZE) return False; |
| 53 | |
| 54 | u_int32_t fragmentOffset = (headerStart[5]<<16)|(headerStart[6]<<8)|(headerStart[7]); |
| 55 | fCurrentPacketBeginsFrame = fragmentOffset == 0; |
| 56 | fCurrentPacketCompletesFrame = packet->rtpMarkerBit(); |
| 57 | |
| 58 | resultSpecialHeaderSize = JPEG2000_PAYLOAD_HEADER_SIZE; |
| 59 | return True; |
| 60 | } |
| 61 | |
| 62 | char const* JPEG2000VideoRTPSource::MIMEtype() const { |
| 63 | return "video/JPEG2000" ; |
| 64 | } |
| 65 | |