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 | // 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 | |
33 | class MPEG1or2VideoStreamDiscreteFramer: public MPEG1or2VideoStreamFramer { |
34 | public: |
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 | |
41 | protected: |
42 | MPEG1or2VideoStreamDiscreteFramer(UsageEnvironment& env, |
43 | FramedSource* inputSource, |
44 | Boolean iFramesOnly, double vshPeriod, Boolean leavePresentationTimesUnmodified); |
45 | // called only by createNew() |
46 | virtual ~MPEG1or2VideoStreamDiscreteFramer(); |
47 | |
48 | protected: |
49 | // redefined virtual functions: |
50 | virtual void doGetNextFrame(); |
51 | |
52 | protected: |
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 | |
62 | protected: |
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 | |