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 filter that breaks up an MPEG video elementary stream into
19// headers and frames
20// C++ header
21
22#ifndef _MPEG_VIDEO_STREAM_FRAMER_HH
23#define _MPEG_VIDEO_STREAM_FRAMER_HH
24
25#ifndef _FRAMED_FILTER_HH
26#include "FramedFilter.hh"
27#endif
28
29class TimeCode {
30public:
31 TimeCode();
32 virtual ~TimeCode();
33
34 int operator==(TimeCode const& arg2);
35 unsigned days, hours, minutes, seconds, pictures;
36};
37
38class MPEGVideoStreamFramer: public FramedFilter {
39public:
40 Boolean& pictureEndMarker() { return fPictureEndMarker; }
41 // a hack for implementing the RTP 'M' bit
42
43 void flushInput(); // called if there is a discontinuity (seeking) in the input
44
45protected:
46 MPEGVideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource);
47 // we're an abstract base class
48 virtual ~MPEGVideoStreamFramer();
49
50 void computePresentationTime(unsigned numAdditionalPictures);
51 // sets "fPresentationTime"
52 void setTimeCode(unsigned hours, unsigned minutes, unsigned seconds,
53 unsigned pictures, unsigned picturesSinceLastGOP);
54
55protected: // redefined virtual functions
56 virtual void doGetNextFrame();
57 virtual void doStopGettingFrames();
58
59private:
60 void reset();
61
62 static void continueReadProcessing(void* clientData,
63 unsigned char* ptr, unsigned size,
64 struct timeval presentationTime);
65 void continueReadProcessing();
66
67protected:
68 double fFrameRate; // Note: For MPEG-4, this is really a 'tick rate'
69 unsigned fPictureCount; // hack used to implement doGetNextFrame()
70 Boolean fPictureEndMarker;
71 struct timeval fPresentationTimeBase;
72
73 // parsing state
74 class MPEGVideoStreamParser* fParser;
75 friend class MPEGVideoStreamParser; // hack
76
77private:
78 TimeCode fCurGOPTimeCode, fPrevGOPTimeCode;
79 unsigned fPicturesAdjustment;
80 double fPictureTimeBase;
81 unsigned fTcSecsBase;
82 Boolean fHaveSeenFirstTimeCode;
83};
84
85#endif
86