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
19
20#include "JPEG2000VideoRTPSource.hh"
21
22JPEG2000VideoRTPSource*
23JPEG2000VideoRTPSource::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
31JPEG2000VideoRTPSource
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
39JPEG2000VideoRTPSource::~JPEG2000VideoRTPSource() {
40 delete[] fSampling;
41}
42
43#define JPEG2000_PAYLOAD_HEADER_SIZE 8
44
45Boolean JPEG2000VideoRTPSource
46::processSpecialHeader(BufferedPacket* packet,
47 unsigned& resultSpecialHeaderSize) {
48 unsigned char* headerStart = 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
62char const* JPEG2000VideoRTPSource::MIMEtype() const {
63 return "video/JPEG2000";
64}
65