RDK Documentation (Open Sourced RDK Components)
isobmffprocessor.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2019 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21 * @file isobmffprocessor.h
22 * @brief Header file for ISO Base Media File Format Fragment Processor
23 */
24 
25 #ifndef __ISOBMFFPROCESSOR_H__
26 #define __ISOBMFFPROCESSOR_H__
27 
28 #include "isobmffbuffer.h"
29 #include "mediaprocessor.h"
30 #include "priv_aamp.h"
31 #include <pthread.h>
32 
33 /**
34  * @enum IsoBmffProcessorType
35  * @brief ISOBMFF Processor types
36  */
38 {
39  eBMFFPROCESSOR_TYPE_VIDEO = 0,
40  eBMFFPROCESSOR_TYPE_AUDIO = 1
41 };
42 
43 /**
44  * @class IsoBmffProcessor
45  * @brief Class for ISO BMFF Fragment Processor
46  */
48 {
49 
50 public:
51  /**
52  * @fn IsoBmffProcessor
53  *
54  * @param[in] aamp - PrivateInstanceAAMP pointer
55  * @param[in] trackType - track type (A/V)
56  * @param[in] peerBmffProcessor - peer instance of IsoBmffProcessor
57  */
58  IsoBmffProcessor(class PrivateInstanceAAMP *aamp, AampLogManager *logObj=NULL, IsoBmffProcessorType trackType = eBMFFPROCESSOR_TYPE_VIDEO, IsoBmffProcessor* peerBmffProcessor = NULL);
59 
60  /**
61  * @fn ~IsoBmffProcessor
62  */
64 
65  IsoBmffProcessor(const IsoBmffProcessor&) = delete;
66  IsoBmffProcessor& operator=(const IsoBmffProcessor&) = delete;
67 
68  /**
69  * @brief Enable or disable throttle
70  *
71  * @param[in] enable - throttle enable/disable
72  * @return void
73  */
74  void setThrottleEnable(bool enable) override { };
75 
76  /**
77  * @brief Set frame rate for trickmode
78  *
79  * @param[in] frameRate - rate per second
80  * @return void
81  */
82  void setFrameRateForTM (int frameRate) override { };
83 
84  /**
85  * @fn sendSegment
86  *
87  * @param[in] segment - fragment buffer pointer
88  * @param[in] size - fragment buffer size
89  * @param[in] position - position of fragment
90  * @param[in] duration - duration of fragment
91  * @param[in] discontinuous - true if discontinuous fragment
92  * @param[out] ptsError - flag indicates if any PTS error occurred
93  * @return true if fragment was sent, false otherwise
94  */
95  bool sendSegment(char *segment, size_t& size, double position, double duration, bool discontinuous, bool &ptsError) override;
96 
97  /**
98  * @fn abort
99  *
100  * @return void
101  */
102  void abort() override;
103 
104  /**
105  * @fn reset
106  *
107  * @return void
108  */
109  void reset() override;
110 
111  /**
112  * @fn setRate
113  *
114  * @param[in] rate - playback rate
115  * @param[in] mode - playback mode
116  * @return void
117  */
118  void setRate(double rate, PlayMode mode) override;
119 
120 private:
121 
122  /**
123  * @brief Set peer instance of IsoBmffProcessor
124  *
125  * @param[in] processor - peer instance
126  * @return void
127  */
128  void setPeerProcessor(IsoBmffProcessor *processor) { peerProcessor = processor; }
129 
130  /**
131  * @fn setBasePTS
132  *
133  * @param[in] pts - base PTS value
134  * @param[in] tScale - TimeScale value
135  * @return void
136  */
137  void setBasePTS(uint64_t pts, uint32_t tScale);
138 
139  /**
140  * @fn cacheInitSegment
141  *
142  * @param[in] segment - buffer pointer
143  * @param[in] size - buffer size
144  * @return void
145  */
146  void cacheInitSegment(char *segment, size_t size);
147 
148  /**
149  * @fn pushInitSegment
150  *
151  * @param[in] position - position value
152  * @return void
153  */
154  void pushInitSegment(double position);
155 
156  /**
157  * @fn clearInitSegment
158  *
159  * @return void
160  */
161  void clearInitSegment();
162 
163  PrivateInstanceAAMP *p_aamp;
164  uint32_t timeScale;
165  uint64_t basePTS;
166  IsoBmffProcessor *peerProcessor;
168  bool processPTSComplete;
169  bool initSegmentProcessComplete;
170  double playRate;
171 
172  std::vector<GrowableBuffer *> initSegment;
173 
174  bool abortAll;
175 
176  pthread_mutex_t m_mutex;
177  pthread_cond_t m_cond;
178  AampLogManager *mLogObj;
179 };
180 
181 #endif /* __ISOBMFFPROCESSOR_H__ */
182 
IsoBmffProcessor::clearInitSegment
void clearInitSegment()
Clear init fragment cached earlier.
Definition: isobmffprocessor.cpp:324
mediaprocessor.h
Header file for base class of media container processor.
IsoBmffProcessor::reset
void reset() override
Reset all variables.
Definition: isobmffprocessor.cpp:252
IsoBmffProcessor::~IsoBmffProcessor
~IsoBmffProcessor()
IsoBmffProcessor destructor.
Definition: isobmffprocessor.cpp:59
IsoBmffProcessor::pushInitSegment
void pushInitSegment(double position)
Push init fragment cached earlier.
Definition: isobmffprocessor.cpp:304
IsoBmffProcessor::setRate
void setRate(double rate, PlayMode mode) override
Set playback rate.
Definition: isobmffprocessor.cpp:268
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
IsoBmffProcessor::setBasePTS
void setBasePTS(uint64_t pts, uint32_t tScale)
Set base PTS and TimeScale value.
Definition: isobmffprocessor.cpp:276
IsoBmffProcessor::sendSegment
bool sendSegment(char *segment, size_t &size, double position, double duration, bool discontinuous, bool &ptsError) override
Process and send ISOBMFF fragment.
Definition: isobmffprocessor.cpp:69
IsoBmffProcessorType
IsoBmffProcessorType
ISOBMFF Processor types.
Definition: isobmffprocessor.h:37
IsoBmffProcessor
Class for ISO BMFF Fragment Processor.
Definition: isobmffprocessor.h:47
IsoBmffProcessor::abort
void abort() override
Abort all operations.
Definition: isobmffprocessor.cpp:241
IsoBmffProcessor::setThrottleEnable
void setThrottleEnable(bool enable) override
Enable or disable throttle.
Definition: isobmffprocessor.h:74
priv_aamp.h
Private functions and types used internally by AAMP.
isobmffbuffer.h
Header file for ISO Base Media File Format Buffer.
PrivateInstanceAAMP
Class representing the AAMP player's private instance, which is not exposed to outside world.
Definition: priv_aamp.h:640
IsoBmffProcessor::setFrameRateForTM
void setFrameRateForTM(int frameRate) override
Set frame rate for trickmode.
Definition: isobmffprocessor.h:82
IsoBmffProcessor::cacheInitSegment
void cacheInitSegment(char *segment, size_t size)
Cache init fragment internally.
Definition: isobmffprocessor.cpp:290
MediaProcessor
Base Class for Media Container Processor.
Definition: mediaprocessor.h:47
IsoBmffProcessor::IsoBmffProcessor
IsoBmffProcessor(class PrivateInstanceAAMP *aamp, AampLogManager *logObj=NULL, IsoBmffProcessorType trackType=eBMFFPROCESSOR_TYPE_VIDEO, IsoBmffProcessor *peerBmffProcessor=NULL)
IsoBmffProcessor constructor.
Definition: isobmffprocessor.cpp:37
IsoBmffProcessor::setPeerProcessor
void setPeerProcessor(IsoBmffProcessor *processor)
Set peer instance of IsoBmffProcessor.
Definition: isobmffprocessor.h:128