RDK Documentation (Open Sourced RDK Components)
FakePrivateInstanceAAMP.cpp
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 2022 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 #include "priv_aamp.h"
21 #include "MockPrivateInstanceAAMP.h"
22 
23 //Enable the define below to get AAMP logging out when running tests
24 //#define ENABLE_LOGGING
25 #define TEST_LOG_LEVEL eLOGLEVEL_TRACE
26 
27 MockPrivateInstanceAAMP *g_mockPrivateInstanceAAMP = nullptr;
28 
29 PrivateInstanceAAMP::PrivateInstanceAAMP(AampConfig *config) : mConfig (config)
30 {
31 }
32 
34 {
35 }
36 
37 size_t PrivateInstanceAAMP::HandleSSLWriteCallback ( char *ptr, size_t size, size_t nmemb, void* userdata )
38 {
39  return 0;
40 }
41 
42 size_t PrivateInstanceAAMP::HandleSSLHeaderCallback ( const char *ptr, size_t size, size_t nmemb, void* user_data )
43 {
44  return 0;
45 }
46 
47 int PrivateInstanceAAMP::HandleSSLProgressCallback ( void *clientp, double dltotal, double dlnow, double ultotal, double ulnow )
48 {
49  return 0;
50 }
51 
53 {
54 }
55 
57 {
58  if (g_mockPrivateInstanceAAMP != nullptr)
59  {
60  g_mockPrivateInstanceAAMP->GetState(state);
61  }
62 }
63 
65 {
66  if (g_mockPrivateInstanceAAMP != nullptr)
67  {
68  g_mockPrivateInstanceAAMP->SetState(state);
69  }
70 }
71 
73 {
74 }
75 
77 {
78  return true;
79 }
80 
81 void PrivateInstanceAAMP::StartPausePositionMonitoring(long long pausePositionMilliseconds)
82 {
83  if (g_mockPrivateInstanceAAMP != nullptr)
84  {
85  g_mockPrivateInstanceAAMP->StartPausePositionMonitoring(pausePositionMilliseconds);
86  }
87 }
88 
90 {
91  if (g_mockPrivateInstanceAAMP != nullptr)
92  {
93  g_mockPrivateInstanceAAMP->StopPausePositionMonitoring(reason);
94  }
95 }
96 
98 {
99  return nullptr;
100 }
101 
102 void PrivateInstanceAAMP::Tune(const char *mainManifestUrl, bool autoPlay, const char *contentType, bool bFirstAttempt, bool bFinalAttempt,const char *pTraceID,bool audioDecoderStreamSync)
103 {
104 }
105 
107 {
108 }
109 
110 void PrivateInstanceAAMP::NotifySpeedChanged(float rate, bool changeState)
111 {
112 }
113 
115 {
116 }
117 
119 {
120  return false;
121 }
122 
124 {
125 }
126 
128 {
129  return false;
130 }
131 
133 {
134  return 0;
135 }
136 
138 {
139  return false;
140 }
141 
143 {
144 }
145 
147 {
148 }
149 
151 {
152 }
153 
155 {
156 }
157 
159 {
160 }
161 
162 void PrivateInstanceAAMP::TuneHelper(TuneType tuneType, bool seekWhilePaused)
163 {
164 }
165 
167 {
168 }
169 
171 {
172  return false;
173 }
174 
175 void PrivateInstanceAAMP::TeardownStream(bool newTune)
176 {
177 }
178 
179 void PrivateInstanceAAMP::SetVideoRectangle(int x, int y, int w, int h)
180 {
181 }
182 
184 {
185 }
186 
188 {
189  return false;
190 }
191 
192 void PrivateInstanceAAMP::SetVideoMute(bool muted)
193 {
194 }
195 
197 {
198 }
199 
201 {
202 }
203 
205 {
206 }
207 
209 {
210 }
211 
212 std::shared_ptr<AampDrmHelper> PrivateInstanceAAMP::GetCurrentDRM(void)
213 {
214  return nullptr;
215 }
216 
217 void PrivateInstanceAAMP::AddCustomHTTPHeader(std::string headerName, std::vector<std::string> headerValue, bool isLicenseHeader)
218 {
219 }
220 
221 void PrivateInstanceAAMP::SetLiveOffsetAppRequest(bool LiveOffsetAppRequest)
222 {
223 }
224 
226 {
227  return 0;
228 }
229 
231 {
232  return ContentType_UNKNOWN;
233 }
234 
235 void PrivateInstanceAAMP::SetAlternateContents(const std::string &adBreakId, const std::string &adId, const std::string &url)
236 {
237 }
238 
239 void SetPreferredLanguages(const char *languageList, const char *preferredRendition, const char *preferredType, const char *codecList, const char *labelList )
240 {
241 }
242 
244 {
245  return nullptr;
246 }
247 
249 {
250  return nullptr;
251 }
252 
253 void PrivateInstanceAAMP::SetPreferredTextLanguages(const char *param )
254 {
255 }
256 
258 {
259  return eDRM_NONE;
260 }
261 
263 {
264  return nullptr;
265 }
266 
267 void PrivateInstanceAAMP::SetVideoTracks(std::vector<long> bitrateList)
268 {
269 }
270 
272 {
273  return nullptr;
274 }
275 
277 {
278  return nullptr;
279 }
280 
282 {
283  return 0;
284 }
285 
286 std::string PrivateInstanceAAMP::GetAvailableTextTracks(bool allTrack)
287 {
288  return nullptr;
289 }
290 
291 std::string PrivateInstanceAAMP::GetAvailableAudioTracks(bool allTrack)
292 {
293  return nullptr;
294 }
295 
296 std::string PrivateInstanceAAMP::GetVideoRectangle()
297 {
298  return nullptr;
299 }
300 
301 void PrivateInstanceAAMP::SetAppName(std::string name)
302 {
303 }
304 
306 {
307  return 0;
308 }
309 
310 void PrivateInstanceAAMP::SetCCStatus(bool enabled)
311 {
312 }
313 
315 {
316  return false;
317 }
318 
319 void PrivateInstanceAAMP::SetTextStyle(const std::string &options)
320 {
321 }
322 
324 {
325  return nullptr;
326 }
327 
329 {
330  return nullptr;
331 }
332 
333 std::string PrivateInstanceAAMP::GetThumbnails(double tStart, double tEnd)
334 {
335  return nullptr;
336 }
337 
338 void PrivateInstanceAAMP::DisableContentRestrictions(long grace, long time, bool eventChange)
339 {
340 }
341 
343 {
344 }
345 
347 {
348  return eMEDIAFORMAT_UNKNOWN;
349 }
350 
352 {
353 }
354 
356 {
357  return false;
358 }
359 
360 void PrivateInstanceAAMP::TuneFail(bool fail)
361 {
362 }
363 
365 {
366  return nullptr;
367 }
368 
369 void PrivateInstanceAAMP::individualization(const std::string& payload)
370 {
371 }
372 
373 void PrivateInstanceAAMP::SetTextTrack(int trackId, char *data)
374 {
375 }
376 
378 {
379  return false;
380 }
381 
383 {
384 }
385 
386 void PrivateInstanceAAMP::SetPreferredLanguages(char const*, char const*, char const*, char const*, char const*)
387 {
388 }
PrivateInstanceAAMP::SetLiveOffsetAppRequest
void SetLiveOffsetAppRequest(bool LiveOffsetAppRequest)
set LiveOffset Request flag Status
Definition: priv_aamp.cpp:11648
PrivateInstanceAAMP::GetAudioTrack
int GetAudioTrack()
Get current audio track index.
Definition: priv_aamp.cpp:9976
MockPrivateInstanceAAMP
Definition: MockPrivateInstanceAAMP.h:26
PrivateInstanceAAMP::NotifyFirstBufferProcessed
void NotifyFirstBufferProcessed()
Notify if first buffer processed by gstreamer.
Definition: priv_aamp.cpp:8471
PrivateInstanceAAMP::TuneHelper
void TuneHelper(TuneType tuneType, bool seekWhilePaused=false)
The helper function which perform tuning Common tune operations used on Tune, Seek,...
Definition: priv_aamp.cpp:4874
PrivateInstanceAAMP::SetPreferredLanguages
void SetPreferredLanguages(const char *languageList, const char *preferredRendition, const char *preferredType, const char *codecList, const char *labelList)
set preferred Audio Language properties like language, rendition, type and codec
Definition: priv_aamp.cpp:10744
TuneType
TuneType
Tune Typea.
Definition: priv_aamp.h:190
PrivateInstanceAAMP::GetPlaybackStats
std::string GetPlaybackStats()
Get playback stats for the session so far.
Definition: priv_aamp.cpp:11744
EventListener
Class for sed event to Listener.
Definition: AampEventListener.h:35
ContentType_UNKNOWN
@ ContentType_UNKNOWN
Definition: AampProfiler.h:101
PrivateInstanceAAMP::GetThumbnails
std::string GetThumbnails(double start, double end)
Get the Thumbnail Tile data.
Definition: priv_aamp.cpp:6505
PrivateInstanceAAMP::IsTuneCompleted
bool IsTuneCompleted()
Check if tune completed or not.
Definition: priv_aamp.cpp:8835
PrivateInstanceAAMP::HandleSSLWriteCallback
size_t HandleSSLWriteCallback(char *ptr, size_t size, size_t nmemb, void *userdata)
HandleSSLWriteCallback - Handle write callback from CURL.
Definition: priv_aamp.cpp:770
PrivateInstanceAAMP::SetAudioVolume
void SetAudioVolume(int volume)
Set audio volume.
Definition: priv_aamp.cpp:6732
PrivateInstanceAAMP::SetVideoMute
void SetVideoMute(bool muted)
Enable/ Disable Video.
Definition: priv_aamp.cpp:6712
PrivateInstanceAAMP::Tune
void Tune(const char *url, bool autoPlay, const char *contentType=NULL, bool bFirstAttempt=true, bool bFinalAttempt=false, const char *sessionUUID=NULL, bool audioDecoderStreamSync=true)
Tune API.
Definition: priv_aamp.cpp:5349
PrivateInstanceAAMP::SetState
void SetState(PrivAAMPState state)
Set player state.
Definition: priv_aamp.cpp:7731
PrivateInstanceAAMP::LogPlayerPreBuffered
void LogPlayerPreBuffered(void)
Profile Player changed from background to foreground i.e prebuffred.
Definition: priv_aamp.cpp:3115
PrivateInstanceAAMP::getAampCacheHandler
AampCacheHandler * getAampCacheHandler()
Get AampCacheHandler instance.
Definition: priv_aamp.cpp:6277
PrivateInstanceAAMP::SetTextStyle
void SetTextStyle(const std::string &options)
Set style options for text track rendering.
Definition: priv_aamp.cpp:10441
PrivateInstanceAAMP::AcquireStreamLock
void AcquireStreamLock()
acquire streamsink lock
Definition: priv_aamp.cpp:10671
PrivateInstanceAAMP::RemoveEventListener
void RemoveEventListener(AAMPEventType eventType, EventListener *eventListener)
Deregister event lister, Remove listener to aamp events.
Definition: priv_aamp.cpp:2253
PrivateInstanceAAMP::SetPreferredTextLanguages
void SetPreferredTextLanguages(const char *param)
Set Preferred Text Language.
Definition: priv_aamp.cpp:11142
PrivateInstanceAAMP::GetDurationMs
long long GetDurationMs(void)
Get asset duration in milliseconds.
Definition: priv_aamp.cpp:6798
PrivateInstanceAAMP::IsFragmentCachingRequired
bool IsFragmentCachingRequired()
Check if fragment caching is required.
Definition: priv_aamp.cpp:8189
PrivateInstanceAAMP::SetTextTrack
void SetTextTrack(int trackId, char *data=NULL)
Set text track.
Definition: priv_aamp.cpp:10240
PrivateInstanceAAMP::HandleSSLHeaderCallback
size_t HandleSSLHeaderCallback(const char *ptr, size_t size, size_t nmemb, void *userdata)
HandleSSLHeaderCallback - Hanlde header callback from SSL.
Definition: priv_aamp.cpp:863
PrivateInstanceAAMP::GetAvailableVideoTracks
std::string GetAvailableVideoTracks()
Get available video tracks.
Definition: priv_aamp.cpp:9482
PrivateInstanceAAMP::PrivateInstanceAAMP
PrivateInstanceAAMP(AampConfig *config=NULL)
PrivateInstanceAAMP Constructor.
Definition: priv_aamp.cpp:1278
PrivateInstanceAAMP::StopDownloads
void StopDownloads()
Stop downloads of all tracks. Used by aamp internally to manage states.
Definition: priv_aamp.cpp:3148
PrivateInstanceAAMP::SetSubtitleMute
void SetSubtitleMute(bool muted)
Set subtitle mute state.
Definition: priv_aamp.cpp:6722
AampConfig
AAMP Config Class defn.
Definition: AampConfig.h:457
VideoZoomMode
VideoZoomMode
Video zoom mode.
Definition: main_aamp.h:129
PrivateInstanceAAMP::LockGetPositionMilliseconds
bool LockGetPositionMilliseconds()
Lock GetPositionMilliseconds() returns true if successfull.
Definition: priv_aamp.cpp:6861
PrivateInstanceAAMP::GetState
void GetState(PrivAAMPState &state)
Get player state.
Definition: priv_aamp.cpp:7769
PrivateInstanceAAMP::individualization
void individualization(const std::string &payload)
DRM individualization callback.
Definition: priv_aamp.cpp:9807
PrivateInstanceAAMP::GetThumbnailTracks
std::string GetThumbnailTracks()
Get available thumbnail tracks.
Definition: priv_aamp.cpp:6461
PrivateInstanceAAMP::TuneFail
void TuneFail(bool fail)
Profiler for failure tune.
Definition: priv_aamp.cpp:3018
PrivateInstanceAAMP::GetPositionMilliseconds
long long GetPositionMilliseconds(void)
Get current stream playback position in milliseconds.
Definition: priv_aamp.cpp:6888
PrivateInstanceAAMP::ReleaseStreamLock
void ReleaseStreamLock()
release streamsink lock
Definition: priv_aamp.cpp:10689
PrivateInstanceAAMP::GetAvailableAudioTracks
std::string GetAvailableAudioTracks(bool allTrack=false)
Get available audio tracks.
Definition: priv_aamp.cpp:9572
PrivateInstanceAAMP::DisableContentRestrictions
void DisableContentRestrictions(long grace=0, long time=-1, bool eventChange=false)
Disable Content Restrictions - unlock.
Definition: priv_aamp.cpp:10599
PrivateInstanceAAMP::GetPreferredDRM
DRMSystems GetPreferredDRM()
Get Preferred DRM.
Definition: priv_aamp.cpp:8843
PrivateInstanceAAMP::GetTextStyle
std::string GetTextStyle()
Get style options for text track rendering.
Definition: priv_aamp.cpp:10464
PrivateInstanceAAMP::SetStreamSink
void SetStreamSink(StreamSink *streamSink)
Setting the stream sink.
Definition: priv_aamp.cpp:7034
PrivateInstanceAAMP::StopPausePositionMonitoring
void StopPausePositionMonitoring(std::string reason)
stop the PausePositionMonitoring thread used for PauseAt functionality
Definition: priv_aamp.cpp:1839
PrivateInstanceAAMP::Stop
void Stop(void)
Stop playback and release resources.
Definition: priv_aamp.cpp:7068
PrivateInstanceAAMP::GetTextTrackInfo
std::string GetTextTrackInfo()
Get current audio track index.
Definition: priv_aamp.cpp:10095
PrivateInstanceAAMP::TeardownStream
void TeardownStream(bool newTune)
Terminate the stream.
Definition: priv_aamp.cpp:4641
PrivateInstanceAAMP::GetContentType
ContentType GetContentType() const
Get Content Type.
Definition: priv_aamp.cpp:6193
PrivateInstanceAAMP::IsLive
bool IsLive(void)
Checking if the stream is live or not.
Definition: priv_aamp.cpp:7042
PrivateInstanceAAMP::GetPreferredAudioProperties
std::string GetPreferredAudioProperties()
get the current audio preference set by user
Definition: priv_aamp.cpp:9431
PrivateInstanceAAMP::TryStreamLock
bool TryStreamLock()
try to acquire streamsink lock
Definition: priv_aamp.cpp:10680
priv_aamp.h
Private functions and types used internally by AAMP.
PrivateInstanceAAMP::NotifySpeedChanged
void NotifySpeedChanged(float rate, bool changeState=true)
Notify speed change event to listeners.
Definition: priv_aamp.cpp:2582
PrivateInstanceAAMP::SetVideoTracks
void SetVideoTracks(std::vector< long > bitrateList)
set birate for video tracks selection
Definition: priv_aamp.cpp:9546
StreamSink
GStreamer Abstraction class for the implementation of AAMPGstPlayer and gstaamp plugin.
Definition: main_aamp.h:385
PrivateInstanceAAMP::IsActiveInstancePresent
static bool IsActiveInstancePresent()
Check if any active PrivateInstanceAAMP available.
Definition: priv_aamp.cpp:10472
PrivAAMPState
PrivAAMPState
Mapping all required status codes based on JS player requirement. These requirements may be forced by...
Definition: AampEvent.h:156
AampCacheHandler
Handles Aamp Cahe operations.
Definition: AampCacheHandler.h:110
PrivateInstanceAAMP::UnlockGetPositionMilliseconds
void UnlockGetPositionMilliseconds()
Unlock GetPositionMilliseconds()
Definition: priv_aamp.cpp:6873
PrivateInstanceAAMP::AddCustomHTTPHeader
void AddCustomHTTPHeader(std::string headerName, std::vector< std::string > headerValue, bool isLicenseHeader)
Add/Remove a custom HTTP header and value.
Definition: priv_aamp.cpp:8384
PrivateInstanceAAMP::GetCCStatus
bool GetCCStatus(void)
Get CC visibility on/off.
Definition: priv_aamp.cpp:10416
PrivateInstanceAAMP::GetMediaFormatType
MediaFormat GetMediaFormatType(const char *url)
Assign the correct mediaFormat by parsing the url.
Definition: priv_aamp.cpp:5806
PrivateInstanceAAMP::SetVideoZoom
void SetVideoZoom(VideoZoomMode zoom)
Set video zoom.
Definition: priv_aamp.cpp:6704
PrivateInstanceAAMP::StartPausePositionMonitoring
void StartPausePositionMonitoring(long long pausePositionMilliseconds)
start the PausePositionMonitoring thread used for PauseAt functionality
Definition: priv_aamp.cpp:1811
AAMPEventType
AAMPEventType
Type of the events sending to the JSPP player.
Definition: AampEvent.h:44
PrivateInstanceAAMP::SetVideoRectangle
void SetVideoRectangle(int x, int y, int w, int h)
Set video rectangle.
Definition: priv_aamp.cpp:6667
eDRM_NONE
@ eDRM_NONE
Definition: AampDrmSystems.h:35
ContentType
ContentType
Asset's content types.
Definition: AampProfiler.h:99
PrivateInstanceAAMP::SetEventPriorityAsyncTune
void SetEventPriorityAsyncTune(bool bValue)
Set async tune configuration for EventPriority.
Definition: priv_aamp.cpp:6631
PrivateInstanceAAMP::HandleSSLProgressCallback
int HandleSSLProgressCallback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
HandleSSLProgressCallback - Process progress callback from CURL.
Definition: priv_aamp.cpp:1116
PrivateInstanceAAMP::~PrivateInstanceAAMP
~PrivateInstanceAAMP()
PrivateInstanceAAMP Destructor.
Definition: priv_aamp.cpp:1534
PrivateInstanceAAMP::GetCurrentDRM
std::shared_ptr< AampDrmHelper > GetCurrentDRM()
Get current drm.
Definition: priv_aamp.cpp:6453
DRMSystems
DRMSystems
DRM system types.
Definition: AampDrmSystems.h:33
PrivateInstanceAAMP::GetPauseOnFirstVideoFrameDisp
bool GetPauseOnFirstVideoFrameDisp(void)
GetPauseOnFirstVideoFrameDisplay.
Definition: priv_aamp.cpp:11571
PrivateInstanceAAMP::SetCCStatus
void SetCCStatus(bool enabled)
Set CC visibility on/off.
Definition: priv_aamp.cpp:10394
PrivateInstanceAAMP::EnableContentRestrictions
void EnableContentRestrictions()
Enable Content Restrictions - lock.
Definition: priv_aamp.cpp:10618
PrivateInstanceAAMP::SetAlternateContents
void SetAlternateContents(const std::string &adBreakId, const std::string &adId, const std::string &url)
Setting the alternate contents' (Ads/blackouts) URL.
Definition: priv_aamp.cpp:8868
PrivateInstanceAAMP::GetAvailableTextTracks
std::string GetAvailableTextTracks(bool alltrack=false)
Get available text tracks.
Definition: priv_aamp.cpp:9676
PrivateInstanceAAMP::GetTextTrack
int GetTextTrack()
Get current text track index.
Definition: priv_aamp.cpp:10362
PrivateInstanceAAMP::EnableDownloads
void EnableDownloads(void)
Enable downloads after aamp_DisableDownloads. Called after stopping fragment collector thread.
Definition: priv_aamp.cpp:6761
PrivateInstanceAAMP::GetPreferredTextProperties
std::string GetPreferredTextProperties()
get the current text preference set by user
Definition: priv_aamp.cpp:9384
PrivateInstanceAAMP::NotifyOnEnteringLive
void NotifyOnEnteringLive()
Notify when entering live point to listeners.
Definition: priv_aamp.cpp:2910
MediaFormat
MediaFormat
Media format types.
Definition: AampDrmMediaFormat.h:32
PrivateInstanceAAMP::GetAudioTrackInfo
std::string GetAudioTrackInfo()
Get current audio track index.
Definition: priv_aamp.cpp:9991
PrivateInstanceAAMP::SetAppName
void SetAppName(std::string name)
Set the application name which has created PlayerInstanceAAMP, for logging purposes.
Definition: priv_aamp.cpp:9791
eMEDIAFORMAT_UNKNOWN
@ eMEDIAFORMAT_UNKNOWN
Definition: AampDrmMediaFormat.h:43
PrivateInstanceAAMP::SetStateBufferingIfRequired
bool SetStateBufferingIfRequired()
Set eSTATE_BUFFERING if required.
Definition: priv_aamp.cpp:9889
PrivateInstanceAAMP::ResumeDownloads
void ResumeDownloads()
Resume downloads of all tracks. Used by aamp internally to manage states.
Definition: priv_aamp.cpp:3163
PrivateInstanceAAMP::detach
void detach()
Soft stop the player instance.
Definition: priv_aamp.cpp:6248
PrivateInstanceAAMP::AddEventListener
void AddEventListener(AAMPEventType eventType, EventListener *eventListener)
Add listener to aamp events.
Definition: priv_aamp.cpp:2244