RDK Documentation (Open Sourced RDK Components)
ota_shim.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 2018 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 ota_shim.h
22  * @brief shim for dispatching UVE OTA ATSC playback
23  */
24 
25 #ifndef OTA_SHIM_H_
26 #define OTA_SHIM_H_
27 
28 #include "StreamAbstractionAAMP.h"
29 #include <string>
30 #include <stdint.h>
31 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
32 #include "Module.h"
33 #include <core/core.h>
34 #include "ThunderAccess.h"
35 #endif
36 using namespace std;
37 
38 /**
39  * @struct ATSCSettings
40  * @brief Structure to save the ATSC settings
41  */
42 typedef struct ATSCSettings
43 {
44  std::string preferredLanguages;
45  std::string preferredRendition;
47 
48 /**
49  * @class StreamAbstractionAAMP_OTA
50  * @brief Fragment collector for OTA
51  */
53 {
54 public:
55  /**
56  * @fn StreamAbstractionAAMP_OTA
57  * @param aamp pointer to PrivateInstanceAAMP object associated with player
58  * @param seek_pos Seek position
59  * @param rate playback rate
60  */
61  StreamAbstractionAAMP_OTA(AampLogManager *logObj, class PrivateInstanceAAMP *aamp,double seekpos, float rate);
62  /**
63  * @fn ~StreamAbstractionAAMP_OTA
64  */
66  /**
67  * @brief Copy constructor disabled
68  *
69  */
71  /**
72  * @brief assignment operator disabled
73  *
74  */
75  StreamAbstractionAAMP_OTA& operator=(const StreamAbstractionAAMP_OTA&) = delete;
76 
77 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
78  /*Event Handler*/
79  void onPlayerStatusHandler(const JsonObject& parameters);
80 #endif
81  /**
82  * @fn DumpProfiles
83  */
84  void DumpProfiles(void) override;
85  /**
86  * @fn Start
87  */
88  void Start() override;
89  /**
90  * @fn Stop
91  */
92  void Stop(bool clearChannelData) override;
93  /**
94  * @fn Init
95  * @note To be implemented by sub classes
96  * @param tuneType to set type of object.
97  * @retval true on success
98  * @retval false on failure
99  */
100  AAMPStatusType Init(TuneType tuneType) override;
101  /**
102  * @fn GetStreamFormat
103  * @param[out] primaryOutputFormat - format of primary track
104  * @param[out] audioOutputFormat - format of audio track
105  * @param[out] auxOutputFormat - format of aux audio track
106  * @param[out] subtitleOutputFormat - format of sutbtile track
107  */
108  void GetStreamFormat(StreamOutputFormat &primaryOutputFormat, StreamOutputFormat &audioOutputFormat, StreamOutputFormat &auxOutputFormat, StreamOutputFormat &subtitleOutputFormat) override;
109  /**
110  * @fn GetStreamPosition
111  *
112  * @retval current position of stream.
113  */
114  double GetStreamPosition() override;
115  /**
116  * @fn GetMediaTrack
117  *
118  * @param[in] type - track type
119  * @retval MediaTrack pointer.
120  */
121  MediaTrack* GetMediaTrack(TrackType type) override;
122  /**
123  * @fn GetFirstPTS
124  *
125  * @retval PTS of first sample
126  */
127  double GetFirstPTS() override;
128  /**
129  * @fn GetStartTimeOfFirstPTS
130  *
131  * @retval start time of first sample
132  */
133  double GetStartTimeOfFirstPTS() override;
134  /**
135  * @fn GetBufferedDuration
136  *
137  */
138  double GetBufferedDuration() override;
139  /**
140  * @fn IsInitialCachingSupported
141  */
142  bool IsInitialCachingSupported() override;
143  /**
144  * @fn GetBWIndex
145  * @param[in] bitrate Bitrate to lookup profile
146  * @retval profile index
147  */
148  int GetBWIndex(long bitrate) override;
149  /**
150  * @fn GetVideoBitrates
151  * @return available video bitrates
152  */
153  std::vector<long> GetVideoBitrates(void) override;
154  /**
155  * @fn GetAudioBitrates
156  * @return available audio bitrates
157  */
158  std::vector<long> GetAudioBitrates(void) override;
159  /**
160  * @fn GetMaxBitrate
161  * @return long MAX video bitrates
162  */
163  long GetMaxBitrate(void) override;
164  /**
165  * @fn StopInjection
166  */
167  void StopInjection(void) override;
168  /**
169  * @fn StartInjection
170  */
171  void StartInjection(void) override;
172  /**
173  * @brief update the Seek position
174  */
175  void SeekPosUpdate(double) { };
176  /**
177  * @fn SetVideoRectangle
178  *
179  * @param[in] x,y - position coordinates of video rectangle
180  * @param[in] wxh - width & height of video rectangle
181  */
182  void SetVideoRectangle(int x, int y, int w, int h) override;
183  /**
184  * @fn SetAudioTrack
185  *
186  * @param[in] Index of the audio track.
187  */
188  void SetAudioTrack(int index) override;
189  /**
190  * @fn SetAudioTrackByLanguage
191  *
192  * @param[in] lang : Audio Language to be set
193  */
194  void SetAudioTrackByLanguage(const char* lang) override;
195  /**
196  * @fn GetAvailableAudioTracks
197  *
198  * @return std::vector<AudioTrackInfo> List of available audio tracks
199  */
200  std::vector<AudioTrackInfo> &GetAvailableAudioTracks(bool allTrack=false) override;
201  /**
202  * @fn GetAudioTrack
203  *
204  * @return int - index of current audio track
205  */
206  int GetAudioTrack() override;
207  /**
208  * @fn GetCurrentAudioTrack
209  * @return int - index of current audio track
210  */
211  bool GetCurrentAudioTrack(AudioTrackInfo &audioTrack) override;
212  /**
213  * @fn GetAvailableTextTracks
214  * @return std::vector<TextTrackInfo> List of available text tracks
215  */
216  std::vector<TextTrackInfo> &GetAvailableTextTracks(bool all=false) override;
217  /**
218  * @fn SetPreferredAudioLanguages
219  *
220  */
221  void SetPreferredAudioLanguages() override;
222  /**
223  * @fn DisableContentRestrictions
224  *
225  * @param[in] grace - seconds from current time, grace period, grace = -1 will allow an unlimited grace period
226  * @param[in] time - seconds from current time,time till which the channel need to be kept unlocked
227  * @param[in] eventChange - disable restriction handling till next program event boundary
228  */
229  void DisableContentRestrictions(long grace, long time, bool eventChange) override;
230  /**
231  * @fn EnableContentRestrictions
232  *
233  */
234  void EnableContentRestrictions() override;
235  /**
236  * @fn GetAvailableVideoTracks
237  * @return available video tracks
238  */
239  std::vector<StreamInfo*> GetAvailableVideoTracks(void) override;
240  /**
241  * @fn GetAvailableThumbnailTracks
242  * @return available thumbnail tracks
243  */
244  std::vector<StreamInfo*> GetAvailableThumbnailTracks(void) override;
245  /**
246  * @fn SetThumbnailTrack
247  *
248  * @param thumbnail index value indicating the track to select
249  * @return bool true on success.
250  */
251  bool SetThumbnailTrack(int) override;
252  /**
253  * @fn GetThumbnailRangeData
254  * @return available thumbnail tracks
255  */
256  std::vector<ThumbnailData> GetThumbnailRangeData(double,double, std::string*, int*, int*, int*, int*) override;
257  /**
258  * @fn Is4KStream
259  * @brief check if current stream have 4K content
260  * @param height - resolution of 4K stream if found
261  * @param bandwidth - bandwidth of 4K stream if foudd
262  * @return true on success
263  */
264  virtual bool Is4KStream(int &height, long &bandwidth) override {return false; };
265 
266 private:
267 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
268  ThunderAccessAAMP thunderAccessObj;
269  ThunderAccessAAMP mediaSettingsObj;
270  std::string prevState;
271  std::string prevBlockedReason;
272  bool tuned;
273  bool mEventSubscribed;
274 
275  ThunderAccessAAMP thunderRDKShellObj;
276  bool GetScreenResolution(int & screenWidth, int & screenHeight);
277 
278  /* Additional data from ATSC playback */
279  std::string mPCRating; /**< Parental control rating json string object */
280  int mSsi; /**< Signal strength indicator 0-100 where 100 is a perfect signal. -1 indicates data not available */
281  /* Video info */
282  long mVideoBitrate;
283  float mFrameRate; /**< FrameRate */
284  VideoScanType mVideoScanType; /**< Video Scan Type progressive/interlaced */
285  int mAspectRatioWidth; /**< Aspect Ratio Width*/
286  int mAspectRatioHeight; /**< Aspect Ratio Height*/
287  std::string mVideoCodec; /**< VideoCodec - E.g MPEG2.*/
288  std::string mHdrType; /**< type of HDR being played, in example "DOLBY_VISION" */
289  int miVideoWidth; /**< Video Width */
290  int miVideoHeight; /**< Video Height */
291 
292  int miPrevmiVideoWidth;
293  int miPrevmiVideoHeight;
294 
295  /* Audio Info */
296  long mAudioBitrate; /**< int - Rate of the Audio stream in bps. Calculated based on transport stream rate. So will have some fluctuation. */
297  std::string mAudioCodec; /**< AudioCodec E.g AC3.*/
298  std::string mAudioMixType; /**< AudioMixType(- E.g STEREO. */
299  bool mIsAtmos; /**< Is Atmos : 1 - True if audio playing is Dolby Atmos, 0 false , -1 indicates data not available */
300 
301  /**
302  * @fn PopulateMetaData
303  */
304  bool PopulateMetaData(const JsonObject& parameters); /**< reads metadata properties from player status object and return true if any of data is changed */
305  void SendMediaMetadataEvent();
306 #endif
307  /**
308  * @fn GetAudioTracks
309  * @return void
310  */
311  void GetAudioTracks();
312  /**
313  * @fn GetAudioTrackInternal
314  *
315  */
316  int GetAudioTrackInternal();
317  /**
318  * @fn NotifyAudioTrackChange
319  *
320  * @param[in] tracks - updated audio track info
321  */
322  void NotifyAudioTrackChange(const std::vector<AudioTrackInfo> &tracks);
323  /**
324  * @fn GetTextTracks
325  * @return voi @return void
326  */
327  void GetTextTracks();
328 protected:
329  /**
330  * @fn GetStreamInfo
331  *
332  * @param[in] idx - profile index.
333  * @retval stream information corresponding to index.
334  */
335  StreamInfo* GetStreamInfo(int idx) override;
336 };
337 
338 #endif //OTA_SHIM_H_
339 /**
340  * @}
341  */
342 
343 
344 
ThunderAccess.h
shim for dispatching UVE HDMI input playback
StreamOutputFormat
StreamOutputFormat
Media output format.
Definition: main_aamp.h:106
StreamInfo
Structure holding the information of a stream.
Definition: StreamAbstractionAAMP.h:69
AudioTrackInfo
Structure for audio track information Holds information about an audio track in playlist.
Definition: main_aamp.h:178
TuneType
TuneType
Tune Typea.
Definition: priv_aamp.h:190
StreamAbstractionAAMP.h
Base classes of HLS/MPD collectors. Implements common caching/injection logic.
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
ATSCSettings
Structure to save the ATSC settings.
Definition: ota_shim.h:42
VideoScanType
VideoScanType
VideoScanType - Progressive/Interlaced.
Definition: AampEvent.h:190
MediaTrack
Base Class for Media Track.
Definition: StreamAbstractionAAMP.h:159
StreamAbstractionAAMP
StreamAbstraction class of AAMP.
Definition: StreamAbstractionAAMP.h:577
StreamAbstractionAAMP_OTA
Fragment collector for OTA.
Definition: ota_shim.h:52
TrackType
TrackType
Media Track Types.
Definition: StreamAbstractionAAMP.h:48
StreamAbstractionAAMP_OTA::SeekPosUpdate
void SeekPosUpdate(double)
update the Seek position
Definition: ota_shim.h:175
PrivateInstanceAAMP
Class representing the AAMP player's private instance, which is not exposed to outside world.
Definition: priv_aamp.h:640
AAMPStatusType
AAMPStatusType
AAMP Function return values.
Definition: priv_aamp.h:205
StreamAbstractionAAMP_OTA::Is4KStream
virtual bool Is4KStream(int &height, long &bandwidth) override
check if current stream have 4K content
Definition: ota_shim.h:264
ThunderAccessAAMP
Support Thunder Plugin Access from AAMP.
Definition: ThunderAccess.h:41
Module.h
Declaration of module name aamp.