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 | // RTP sink for Raw video |
19 | // C++ header |
20 | |
21 | #ifndef _RAW_VIDEO_RTP_SINK_HH |
22 | #define _RAW_VIDEO_RTP_SINK_HH |
23 | |
24 | #ifndef _VIDEO_RTP_SINK_HH |
25 | #include "VideoRTPSink.hh" |
26 | #endif |
27 | |
28 | ////////// FrameParameters ////////// |
29 | |
30 | struct FrameParameters { |
31 | u_int16_t pGroupSize; |
32 | u_int16_t nbOfPixelInPGroup; |
33 | u_int32_t scanLineSize ; |
34 | u_int32_t frameSize; |
35 | u_int16_t scanLineIterationStep; |
36 | }; |
37 | |
38 | |
39 | class RawVideoRTPSink: public VideoRTPSink { |
40 | public: |
41 | static RawVideoRTPSink* |
42 | createNew(UsageEnvironment& env, Groupsock* RTPgs, u_int8_t rtpPayloadFormat, |
43 | // The following headers provide the 'configuration' information, for the SDP description: |
44 | unsigned height, unsigned width, unsigned depth, |
45 | char const* sampling, char const* colorimetry = "BT709-2" ); |
46 | |
47 | protected: |
48 | RawVideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs, |
49 | u_int8_t rtpPayloadFormat, |
50 | unsigned height, unsigned width, unsigned depth, |
51 | char const* sampling, char const* colorimetry = "BT709-2" ); |
52 | // called only by createNew() |
53 | |
54 | virtual ~RawVideoRTPSink(); |
55 | |
56 | private: // redefined virtual functions: |
57 | virtual char const* auxSDPLine(); // for the "a=fmtp:" SDP line |
58 | |
59 | virtual void doSpecialFrameHandling(unsigned fragmentationOffset, |
60 | unsigned char* frameStart, |
61 | unsigned numBytesInFrame, |
62 | struct timeval framePresentationTime, |
63 | unsigned numRemainingBytes); |
64 | virtual Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart, |
65 | unsigned numBytesInFrame) const; |
66 | virtual unsigned () const; |
67 | virtual unsigned computeOverflowForNewFrame(unsigned newFrameSize) const; |
68 | |
69 | private: |
70 | char* fFmtpSDPLine; |
71 | char* fSampling; |
72 | unsigned fWidth; |
73 | unsigned fHeight; |
74 | unsigned fDepth; |
75 | char* fColorimetry; |
76 | unsigned fLineindex; |
77 | FrameParameters fFrameParameters; |
78 | |
79 | unsigned getNbLineInPacket(unsigned fragOffset, unsigned*& lengths, unsigned*& offsets) const; |
80 | // return the number of lines, their lengths and offsets from the fragmentation offset of the whole frame. |
81 | // call delete[] on lengths and offsets after use of the function |
82 | void setFrameParameters(); |
83 | }; |
84 | |
85 | #endif |
86 | |