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// A simplified version of "MPEG1or2VideoStreamFramer" that takes only
19// complete, discrete frames (rather than an arbitrary byte stream) as input.
20// This avoids the parsing and data copying overhead of the full
21// "MPEG1or2VideoStreamFramer".
22// C++ header
23
24#ifndef _MPEG1or2_VIDEO_STREAM_DISCRETE_FRAMER_HH
25#define _MPEG1or2_VIDEO_STREAM_DISCRETE_FRAMER_HH
26
27#ifndef _MPEG1or2_VIDEO_STREAM_FRAMER_HH
28#include "MPEG1or2VideoStreamFramer.hh"
29#endif
30
31#define VSH_MAX_SIZE 1000
32
33class MPEG1or2VideoStreamDiscreteFramer: public MPEG1or2VideoStreamFramer {
34public:
35 static MPEG1or2VideoStreamDiscreteFramer*
36 createNew(UsageEnvironment& env, FramedSource* inputSource,
37 Boolean iFramesOnly = False, // see MPEG1or2VideoStreamFramer.hh
38 double vshPeriod = 5.0, // see MPEG1or2VideoStreamFramer.hh
39 Boolean leavePresentationTimesUnmodified = False);
40
41protected:
42 MPEG1or2VideoStreamDiscreteFramer(UsageEnvironment& env,
43 FramedSource* inputSource,
44 Boolean iFramesOnly, double vshPeriod, Boolean leavePresentationTimesUnmodified);
45 // called only by createNew()
46 virtual ~MPEG1or2VideoStreamDiscreteFramer();
47
48protected:
49 // redefined virtual functions:
50 virtual void doGetNextFrame();
51
52protected:
53 static void afterGettingFrame(void* clientData, unsigned frameSize,
54 unsigned numTruncatedBytes,
55 struct timeval presentationTime,
56 unsigned durationInMicroseconds);
57 void afterGettingFrame1(unsigned frameSize,
58 unsigned numTruncatedBytes,
59 struct timeval presentationTime,
60 unsigned durationInMicroseconds);
61
62protected:
63 Boolean fLeavePresentationTimesUnmodified;
64 struct timeval fLastNonBFramePresentationTime;
65 unsigned fLastNonBFrameTemporal_reference;
66
67 // A saved copy of the most recently seen 'video_sequence_header',
68 // in case we need to insert it into the stream periodically:
69 unsigned char fSavedVSHBuffer[VSH_MAX_SIZE];
70 unsigned fSavedVSHSize;
71 double fSavedVSHTimestamp;
72 Boolean fIFramesOnly;
73 double fVSHPeriod;
74};
75
76#endif
77