live
H264or5VideoStreamFramer.hh
Go to the documentation of this file.
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-2024 Live Networks, Inc. All rights reserved.
18// A filter that breaks up a H.264 or H.265 Video Elementary Stream into NAL units.
19// C++ header
20
21#ifndef _H264_OR_5_VIDEO_STREAM_FRAMER_HH
22#define _H264_OR_5_VIDEO_STREAM_FRAMER_HH
23
24#ifndef _MPEG_VIDEO_STREAM_FRAMER_HH
26#endif
27
29public:
30 void getVPSandSPSandPPS(u_int8_t*& vps, unsigned& vpsSize,
31 u_int8_t*& sps, unsigned& spsSize,
32 u_int8_t*& pps, unsigned& ppsSize) const {
33 // Returns pointers to copies of the most recently seen VPS (video parameter set)
34 // SPS (sequence parameter set) and PPS (picture parameter set) NAL units.
35 // (NULL pointers are returned if the NAL units have not yet been seen.)
36 vps = fLastSeenVPS; vpsSize = fLastSeenVPSSize;
37 sps = fLastSeenSPS; spsSize = fLastSeenSPSSize;
38 pps = fLastSeenPPS; ppsSize = fLastSeenPPSSize;
39 }
40
41 void setVPSandSPSandPPS(u_int8_t* vps, unsigned vpsSize,
42 u_int8_t* sps, unsigned spsSize,
43 u_int8_t* pps, unsigned ppsSize) {
44 // Assigns copies of the VPS, SPS and PPS NAL units. If this function is not called,
45 // then these NAL units are assigned only if/when they appear in the input stream.
46 saveCopyOfVPS(vps, vpsSize);
47 saveCopyOfSPS(sps, spsSize);
48 saveCopyOfPPS(pps, ppsSize);
49 }
50
51protected:
52 H264or5VideoStreamFramer(int hNumber, // 264 or 265
54 Boolean createParser,
55 Boolean includeStartCodeInOutput, Boolean insertAccessUnitDelimiters);
56 // We're an abstract base class.
58
59 void saveCopyOfVPS(u_int8_t* from, unsigned size);
60 void saveCopyOfSPS(u_int8_t* from, unsigned size);
61 void saveCopyOfPPS(u_int8_t* from, unsigned size);
62
64
65 Boolean isVPS(u_int8_t nal_unit_type);
66 Boolean isSPS(u_int8_t nal_unit_type);
67 Boolean isPPS(u_int8_t nal_unit_type);
68 Boolean isVCL(u_int8_t nal_unit_type);
69
70protected: // redefined virtual functions
71 virtual void doGetNextFrame();
72
73protected:
76 u_int8_t* fLastSeenVPS;
78 u_int8_t* fLastSeenSPS;
80 u_int8_t* fLastSeenPPS;
82 struct timeval fNextPresentationTime; // the presentation time to be used for the next NAL unit to be parsed/delivered after this
83 friend class H264or5VideoStreamParser; // hack
84};
85
86// A general routine for making a copy of a (H.264 or H.265) NAL unit,
87// removing 'emulation' bytes from the copy:
88unsigned removeH264or5EmulationBytes(u_int8_t* to, unsigned toMaxSize,
89 u_int8_t const* from, unsigned fromSize);
90 // returns the size of the copy; it will be <= min(toMaxSize,fromSize)
91
92#endif
unsigned char Boolean
Definition: Boolean.hh:25
unsigned removeH264or5EmulationBytes(u_int8_t *to, unsigned toMaxSize, u_int8_t const *from, unsigned fromSize)
FramedSource * inputSource() const
Definition: FramedFilter.hh:30
Boolean isVPS(u_int8_t nal_unit_type)
Boolean isPPS(u_int8_t nal_unit_type)
void saveCopyOfSPS(u_int8_t *from, unsigned size)
void getVPSandSPSandPPS(u_int8_t *&vps, unsigned &vpsSize, u_int8_t *&sps, unsigned &spsSize, u_int8_t *&pps, unsigned &ppsSize) const
Boolean isSPS(u_int8_t nal_unit_type)
virtual void doGetNextFrame()
Boolean isVCL(u_int8_t nal_unit_type)
void saveCopyOfPPS(u_int8_t *from, unsigned size)
void setVPSandSPSandPPS(u_int8_t *vps, unsigned vpsSize, u_int8_t *sps, unsigned spsSize, u_int8_t *pps, unsigned ppsSize)
void saveCopyOfVPS(u_int8_t *from, unsigned size)
virtual ~H264or5VideoStreamFramer()
H264or5VideoStreamFramer(int hNumber, UsageEnvironment &env, FramedSource *inputSource, Boolean createParser, Boolean includeStartCodeInOutput, Boolean insertAccessUnitDelimiters)