This repository has been archived by the owner on Jan 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
StreamAbstractionAAMP.h
1462 lines (1271 loc) · 40.3 KB
/
StreamAbstractionAAMP.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* If not stated otherwise in this file or this component's license file the
* following copyright and licenses apply:
*
* Copyright 2018 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file StreamAbstractionAAMP.h
* @brief Base classes of HLS/MPD collectors. Implements common caching/injection logic.
*/
#ifndef STREAMABSTRACTIONAAMP_H
#define STREAMABSTRACTIONAAMP_H
#include "AampMemoryUtils.h"
#include "priv_aamp.h"
#include "AampJsonObject.h"
#include <map>
#include <iterator>
#include <vector>
#include <glib.h>
#include "subtitleParser.h"
#include <CMCDHeaders.h>
#include <AudioCMCDHeaders.h>
#include <VideoCMCDHeaders.h>
#include <ManifestCMCDHeaders.h>
#include <SubtitleCMCDHeaders.h>
/**
* @brief Media Track Types
*/
typedef enum
{
eTRACK_VIDEO, /**< Video track */
eTRACK_AUDIO, /**< Audio track */
eTRACK_SUBTITLE, /**< Subtitle track */
eTRACK_AUX_AUDIO /**< Auxiliary audio track */
} TrackType;
/**
* @brief Structure holding the resolution of stream
*/
struct StreamResolution
{
int width; /**< Width in pixels*/
int height; /**< Height in pixels*/
double framerate; /**< Frame Rate */
};
/**
* @brief Structure holding the information of a stream.
*/
struct StreamInfo
{
bool enabled; /**< indicates if the streamInfo profile is enabled */
bool isIframeTrack; /**< indicates if the stream is iframe stream*/
bool validity; /**< indicates profile validity against user configured profile range */
const char *codecs; /**< Codec String */
long bandwidthBitsPerSecond; /**< Bandwidth of the stream bps*/
StreamResolution resolution; /**< Resolution of the stream*/
BitrateChangeReason reason; /**< Reason for bitrate change*/
};
/**
* \struct TileInfo
* \brief TileInfo structure for Thumbnail data
*/
struct TileInfo
{
int numRows; /**< Number of Rows from Tile Inf */
int numCols; /**< Number of Cols from Tile Inf */
double posterDuration; /**< Duration of each Tile in Spritesheet */
double tileSetDuration; /**<Duration of whole Tile set */
double startTime;
const char *url;
};
/**
* @brief Structure of cached fragment data
* Holds information about a cached fragment
*/
struct CachedFragment
{
GrowableBuffer fragment; /**< Buffer to keep fragment content */
double position; /**< Position in the playlist */
double duration; /**< Fragment duration */
bool initFragment; /**< Is init frgment */
bool discontinuity; /**< PTS discontinuity status */
int profileIndex; /**< Profile index; Updated internally */
#ifdef AAMP_DEBUG_INJECT
std::string uri; /**< Fragment url */
#endif
StreamInfo cacheFragStreamInfo; /**< Bitrate info of the fragment */
MediaType type; /**< MediaType info of the fragment */
};
/**
* @brief Structure of cached fragment data
* Holds information about a cached fragment
*/
struct CachedFragmentChunk
{
GrowableBuffer fragmentChunk; /**< Buffer to keep fragment content */
MediaType type; /**< MediaType info of the fragment */
long long downloadStartTime; /**< The start time of file download */
};
/**
* @brief Playlist Types
*/
typedef enum
{
ePLAYLISTTYPE_UNDEFINED, /**< Playlist type undefined */
ePLAYLISTTYPE_EVENT, /**< Playlist may grow via appended lines, but otherwise won't change */
ePLAYLISTTYPE_VOD, /**< Playlist will never change */
} PlaylistType;
/**
* @brief Buffer health status
*/
enum BufferHealthStatus
{
BUFFER_STATUS_GREEN, /**< Healthy state, where buffering is close to being maxed out */
BUFFER_STATUS_YELLOW, /**< Danger state, where buffering is close to being exhausted */
BUFFER_STATUS_RED /**< Failed state, where buffers have run dry, and player experiences underrun/stalled video */
};
/**
* @brief Media Disconutinuity state
*/
typedef enum
{
eDISCONTIUITY_FREE = 0, /**< No Discontinuity */
eDISCONTINUIY_IN_VIDEO = 1, /**< Discontinuity in Video */
eDISCONTINUIY_IN_AUDIO = 2, /**< Discontinuity in audio */
eDISCONTINUIY_IN_BOTH = 3 /**< Discontinuity in Both Audio and Video */
} MediaTrackDiscontinuityState;
/**
* @brief Base Class for Media Track
*/
class MediaTrack
{
public:
/**
* @fn MediaTrack
*
* @param[in] type - Media track type
* @param[in] aamp - Pointer to PrivateInstanceAAMP
* @param[in] name - Media track name
*/
MediaTrack(AampLogManager *logObj, TrackType type, PrivateInstanceAAMP* aamp, const char* name);
/**
* @fn ~MediaTrack
*/
virtual ~MediaTrack();
/**
* @brief MediaTrack Copy Constructor
*/
MediaTrack(const MediaTrack&) = delete;
/**
* @brief MediaTrack assignment operator overloading
*/
MediaTrack& operator=(const MediaTrack&) = delete;
/**
* @fn StartInjectLoop
*
* @return void
*/
void StartInjectLoop();
/**
* @fn StartInjectChunkLoop
*
* @return void
*/
void StartInjectChunkLoop();
/**
* @fn StopInjectLoop
*
* @return void
*/
void StopInjectLoop();
/**
* @fn StopInjectChunkLoop
*
* @return void
*/
void StopInjectChunkLoop();
/**
* @fn Enabled
* @retval true if enabled, false if disabled
*/
bool Enabled();
/**
* @fn InjectFragment
*
* @return Success/Failure
*/
bool InjectFragment();
/**
* @fn ProcessFragmentChunk
*/
bool ProcessFragmentChunk();
/**
* @fn InjectFragmentChunk
*
* @return Success/Failure
*/
bool InjectFragmentChunk();
/**
* @brief Get total fragment injected duration
*
* @return Total duration in seconds
*/
double GetTotalInjectedDuration() { return totalInjectedDuration; };
/**
* @brief Get total fragment chunk injected duration
*
* @return Total duration in seconds
*/
double GetTotalInjectedChunkDuration() { return totalInjectedChunksDuration; };
/**
* @fn RunInjectLoop
*
* @return void
*/
void RunInjectLoop();
/**
* @fn RunInjectChunkLoop
*
* @return void
*/
void RunInjectChunkLoop();
/**
* @fn UpdateTSAfterFetch
*
* @return void
*/
void UpdateTSAfterFetch();
/**
* @fn UpdateTSAfterChunkFetch
*
* @return void
*/
void UpdateTSAfterChunkFetch();
/**
* @fn WaitForFreeFragmentAvailable
* @param timeoutMs - timeout in milliseconds. -1 for infinite wait
* @retval true if fragment available, false on abort.
*/
bool WaitForFreeFragmentAvailable( int timeoutMs = -1);
/**
* @fn AbortWaitForCachedAndFreeFragment
*
* @param[in] immediate - Forced or lazy abort as in a seek/ stop
* @return void
*/
void AbortWaitForCachedAndFreeFragment(bool immediate);
/**
* @brief Notifies profile changes to subclasses
*
* @return void
*/
virtual void ABRProfileChanged(void) = 0;
virtual double GetBufferedDuration (void) = 0;
/**
* @brief Get number of fragments dpownloaded
*
* @return Number of downloaded fragments
*/
int GetTotalFragmentsFetched(){ return totalFragmentsDownloaded; }
/**
* @fn GetFetchBuffer
*
* @param[in] initialize - Buffer to to initialized or not
* @return Fragment cache buffer
*/
CachedFragment* GetFetchBuffer(bool initialize);
/**
* @fn GetFetchChunkBuffer
* @param[in] initialize true to initialize the fragment chunk
* @retval Pointer to fragment chunk buffer.
*/
CachedFragmentChunk* GetFetchChunkBuffer(bool initialize);
/**
* @fn SetCurrentBandWidth
*
* @param[in] bandwidthBps - Bandwidth in bps
* @return void
*/
void SetCurrentBandWidth(int bandwidthBps);
/**
* @fn GetProfileIndexForBW
* @param mTsbBandwidth - bandwidth to identify profile index from list
* @retval profile index of the current bandwidth
*/
int GetProfileIndexForBW(long mTsbBandwidth);
/**
* @fn GetCurrentBandWidth
*
* @return Bandwidth in bps
*/
int GetCurrentBandWidth();
/**
* @brief Get total duration of fetched fragments
*
* @return Total duration in seconds
*/
double GetTotalFetchedDuration() { return totalFetchedDuration; };
/**
* @brief Get total duration of fetched fragments
*
* @return Total duration in seconds
*/
double GetTotalInjectedChunksDuration() { return totalInjectedChunksDuration; };
/**
* @brief Check if discontinuity is being processed
*
* @return true if discontinuity is being processed
*/
bool IsDiscontinuityProcessed() { return discontinuityProcessed; }
bool isFragmentInjectorThreadStarted( ) { return fragmentInjectorThreadStarted;}
void MonitorBufferHealth();
void ScheduleBufferHealthMonitor();
/**
* @fn GetBufferStatus
*
* @return BufferHealthStatus
*/
BufferHealthStatus GetBufferStatus();
/**
* @brief Get buffer health status
*
* @return current buffer health status
*/
BufferHealthStatus GetBufferHealthStatus() { return bufferStatus; };
/**
* @fn AbortWaitForCachedFragment
*
* @return void
*/
void AbortWaitForCachedFragment();
/**
* @brief Check whether track data injection is aborted
*
* @return true if injection is aborted, false otherwise
*/
bool IsInjectionAborted() { return (abort || abortInject); }
/**
* @brief Returns if the end of track reached.
*/
virtual bool IsAtEndOfTrack() { return eosReached;}
/**
* @fn CheckForFutureDiscontinuity
*
* @param[out] cacheDuration - cached fragment duration in seconds
* @return bool - true if discontinuity present, false otherwise
*/
bool CheckForFutureDiscontinuity(double &cacheDuration);
/**
* @fn OnSinkBufferFull
*
* @return void
*/
void OnSinkBufferFull();
/**
* @fn FlushFragments
* @return void
*/
void FlushFragments();
/**
* @fn FlushFragmentChunks
*
* @return void
*/
void FlushFragmentChunks();
protected:
/**
* @fn UpdateTSAfterInject
*
* @return void
*/
void UpdateTSAfterInject();
/**
* @brief Update segment cache and inject buffer to gstreamer
*
* @return void
*/
void UpdateTSAfterChunkInject();
/**
* @fn WaitForCachedFragmentAvailable
*
* @return TRUE if fragment available, FALSE if aborted/fragment not available.
*/
bool WaitForCachedFragmentAvailable();
/**
* @fn WaitForCachedFragmentChunkInjected
* @retval true if fragment chunk injected , false on abort.
*/
bool WaitForCachedFragmentChunkInjected(int timeoutMs = -1);
/**
* @fn WaitForCachedFragmentChunkAvailable
*
* @return TRUE if fragment chunk available, FALSE if aborted/fragment chunk not available.
*/
bool WaitForCachedFragmentChunkAvailable();
/**
* @brief Get the context of media track. To be implemented by subclasses
*
* @return Pointer to StreamAbstractionAAMP object
*/
virtual class StreamAbstractionAAMP* GetContext() = 0;
/**
* @brief To be implemented by derived classes to receive cached fragment.
*
* @param[in] cachedFragment - contains fragment to be processed and injected
* @param[out] fragmentDiscarded - true if fragment is discarded.
* @return void
*/
virtual void InjectFragmentInternal(CachedFragment* cachedFragment, bool &fragmentDiscarded) = 0;
/**
* @fn InjectFragmentChunkInternal
* @param[in] cachedFragmentChunk - contains fragment to be processed and injected
* @param[out] fragmentChunkDiscarded - true if fragment is discarded.
* @return void
*/
void InjectFragmentChunkInternal(MediaType mediaType, GrowableBuffer* buffer, double fpts, double fdts, double fDuration);
static int GetDeferTimeMs(long maxTimeSeconds);
/**
* @brief To be implemented by derived classes if discontinuity on trick-play is to be notified.
*
*/
virtual void SignalTrickModeDiscontinuity(){};
private:
/**
* @fn GetBufferHealthStatusString
*
* @return string representation of buffer status
*/
static const char* GetBufferHealthStatusString(BufferHealthStatus status);
public:
bool eosReached; /**< set to true when a vod asset has been played to completion */
bool enabled; /**< set to true if track is enabled */
int numberOfFragmentsCached; /**< Number of fragments cached in this track*/
int numberOfFragmentChunksCached; /**< Number of fragments cached in this track*/
const char* name; /**< Track name used for debugging*/
double fragmentDurationSeconds; /**< duration in seconds for current fragment-of-interest */
int segDLFailCount; /**< Segment download fail count*/
int segDrmDecryptFailCount; /**< Segment decryption failure count*/
int mSegInjectFailCount; /**< Segment Inject/Decode fail count */
TrackType type; /**< Media type of the track*/
std::unique_ptr<SubtitleParser> mSubtitleParser; /**< Parser for subtitle data*/
bool refreshSubtitles; /**< Switch subtitle track in the FetchLoop */
int maxCachedFragmentsPerTrack;
int maxCachedFragmentChunksPerTrack;
pthread_cond_t fragmentChunkFetched;/**< Signaled after a fragment Chunk is fetched*/
uint32_t totalMdatCount; /**< Total MDAT Chunk Found*/
int noMDATCount; /**< MDAT Chunk Not Found count continuously while chunk buffer processoing*/
protected:
AampLogManager *mLogObj;
PrivateInstanceAAMP* aamp; /**< Pointer to the PrivateInstanceAAMP*/
CachedFragment *cachedFragment; /**< storage for currently-downloaded fragment */
CachedFragmentChunk cachedFragmentChunks[DEFAULT_CACHED_FRAGMENT_CHUNKS_PER_TRACK];
GrowableBuffer unparsedBufferChunk; /**< Buffer to keep fragment content */
GrowableBuffer parsedBufferChunk; /**< Buffer to keep fragment content */
bool abort; /**< Abort all operations if flag is set*/
pthread_mutex_t mutex; /**< protection of track variables accessed from multiple threads */
bool ptsError; /**< flag to indicate if last injected fragment has ptsError */
bool abortInject; /**< Abort inject operations if flag is set*/
bool abortInjectChunk; /**< Abort inject operations if flag is set*/
private:
pthread_cond_t fragmentFetched; /**< Signaled after a fragment is fetched*/
pthread_cond_t fragmentInjected; /**< Signaled after a fragment is injected*/
pthread_t fragmentInjectorThreadID; /**< Fragment injector thread id*/
pthread_cond_t fragmentChunkInjected; /**< Signaled after a fragment is injected*/
pthread_t fragmentChunkInjectorThreadID;/**< Fragment injector thread id*/
pthread_t bufferMonitorThreadID; /**< Buffer Monitor thread id */
int totalFragmentsDownloaded; /**< Total fragments downloaded since start by track*/
int totalFragmentChunksDownloaded; /**< Total fragments downloaded since start by track*/
bool fragmentInjectorThreadStarted; /**< Fragment injector's thread started or not*/
bool fragmentChunkInjectorThreadStarted;/**< Fragment Chunk injector's thread started or not*/
bool bufferMonitorThreadStarted; /**< Buffer Monitor thread started or not */
double totalInjectedDuration; /**< Total fragment injected duration*/
double totalInjectedChunksDuration; /**< Total fragment injected chunk duration*/
int currentInitialCacheDurationSeconds; /**< Current cached fragments duration before playing*/
bool sinkBufferIsFull; /**< True if sink buffer is full and do not want new fragments*/
bool cachingCompleted; /**< Fragment caching completed or not*/
int fragmentIdxToInject; /**< Write position */
int fragmentChunkIdxToInject; /**< Write position */
int fragmentIdxToFetch; /**< Read position */
int fragmentChunkIdxToFetch; /**< Read position */
int bandwidthBitsPerSecond; /**< Bandwidth of last selected profile*/
double totalFetchedDuration; /**< Total fragment fetched duration*/
bool discontinuityProcessed;
BufferHealthStatus bufferStatus; /**< Buffer status of the track*/
BufferHealthStatus prevBufferStatus; /**< Previous buffer status of the track*/
long long prevDownloadStartTime; /**< Previous file download Start time*/
};
/**
* @brief StreamAbstraction class of AAMP
*/
class StreamAbstractionAAMP
{
public:
/**
* @fn StreamAbstractionAAMP
* @param[in] aamp pointer to PrivateInstanceAAMP object associated with stream
*/
StreamAbstractionAAMP(AampLogManager *logObj, PrivateInstanceAAMP* aamp);
/**
* @fn ~StreamAbstractionAAMP
*/
virtual ~StreamAbstractionAAMP();
/**
* @brief StreamAbstractionAAMP Copy Constructor
*/
StreamAbstractionAAMP(const StreamAbstractionAAMP&) = delete;
/**
* @brief StreamAbstractionAAMP assignment operator overloading
*/
StreamAbstractionAAMP& operator=(const StreamAbstractionAAMP&) = delete;
/**
* @brief Dump profiles for debugging.
* To be implemented by sub classes
*
* @return void
*/
virtual void DumpProfiles(void) = 0;
/**
* @brief Initialize a newly created object.
* To be implemented by sub classes
*
* @param[in] tuneType - to set type of playback.
* @return true on success, false failure
*/
virtual AAMPStatusType Init(TuneType tuneType) = 0;
/**
* @brief Start streaming.
*
* @return void
*/
virtual void Start() = 0;
/**
* @brief Stops streaming.
*
* @param[in] clearChannelData - clear channel /drm data on stop.
* @return void
*/
virtual void Stop(bool clearChannelData) = 0;
/**
* @brief Get output format of stream.
*
* @param[out] primaryOutputFormat - format of primary track
* @param[out] audioOutputFormat - format of audio track
* @param[out] auxAudioOutputFormat - format of aux audio track
* @return void
*/
virtual void GetStreamFormat(StreamOutputFormat &primaryOutputFormat, StreamOutputFormat &audioOutputFormat, StreamOutputFormat &auxAudioOutputFormat, StreamOutputFormat &subtitleOutputFormat) = 0;
/**
* @brief Get current stream position.
*
* @return current position of stream.
*/
virtual double GetStreamPosition() = 0;
/**
* @brief Get PTS of first sample.
*
* @return PTS of first sample
*/
virtual double GetFirstPTS() = 0;
/**
* @brief Get Start time PTS of first sample.
*
* @retval start time of first sample
*/
virtual double GetStartTimeOfFirstPTS() = 0;
/**
* @brief Return MediaTrack of requested type
*
* @param[in] type - track type
* @return MediaTrack pointer.
*/
virtual MediaTrack* GetMediaTrack(TrackType type) = 0;
/**
* @brief Waits audio track injection until caught up with video track.
* Used internally by injection logic
*
* @param None
* @return void
*/
void WaitForVideoTrackCatchup();
/**
* @fn ReassessAndResumeAudioTrack
*
* @return void
*/
void ReassessAndResumeAudioTrack(bool abort);
/**
* @brief When TSB is involved, use this to set bandwidth to be reported.
*
* @param[in] tsbBandwidth - Bandwidth of the track.
* @return void
*/
void SetTsbBandwidth(long tsbBandwidth){ mTsbBandwidth = tsbBandwidth;}
/**
* @brief When TSB is involved, use this to get bandwidth to be reported.
*
* @return Bandwidth of the track.
*/
long GetTsbBandwidth() { return mTsbBandwidth ;}
/**
* @brief Set elementary stream type change status for reconfigure the pipeline.
*
* @return void
*/
void SetESChangeStatus(void){mAudiostateChangeCount++; mESChangeStatus = true;}
/**
* @brief Reset elementary stream type change status once the pipeline reconfigured.
*
* @return void
*/
void ResetESChangeStatus(void){
if( (mAudiostateChangeCount > 0) && !(--mAudiostateChangeCount) )
{
mESChangeStatus = false;
}
}
/**
* @brief Get elementary stream type change status for reconfigure the pipeline..
*
* @retval mESChangeStatus flag value ( true or false )
*/
bool GetESChangeStatus(void){ return mESChangeStatus;}
PrivateInstanceAAMP* aamp; /**< Pointer to PrivateInstanceAAMP object associated with stream*/
AampLogManager *mLogObj;
/**
* @fn RampDownProfile
*
* @param[in] http_error - Http error code
* @return True, if ramp down successful. Else false
*/
bool RampDownProfile(long http_error);
/**
* @fn GetDesiredProfileOnBuffer
*
* @param [in] currProfileIndex
* @param [in] newProfileIndex
* @return None.
*/
void GetDesiredProfileOnBuffer(int currProfileIndex, int &newProfileIndex);
/**
* @fn GetDesiredProfileOnSteadyState
*
* @param [in] currProfileIndex
* @param [in] newProfileIndex
* @param [in] nwBandwidth
* @return None.
*/
void GetDesiredProfileOnSteadyState(int currProfileIndex, int &newProfileIndex, long nwBandwidth);
/**
* @fn ConfigureTimeoutOnBuffer
*
* @return None.
*/
void ConfigureTimeoutOnBuffer();
/**
* @brief Function to get the buffer duration of stream
*
* @return buffer value
*/
virtual double GetBufferedDuration (void) = 0;
/**
* @fn IsLowestProfile
*
* @param currentProfileIndex - current profile index to be checked.
* @return true if the given profile index is lowest.
*/
bool IsLowestProfile(int currentProfileIndex);
/**
* @fn getOriginalCurlError
*
* @param[in] http_error - Error code
* @return error code
*/
long getOriginalCurlError(long http_error);
/**
* @fn CheckForRampDownProfile
*
* @param http_error - Http error code
* @return true if rampdown needed in the case of fragment not available in higher profile.
*/
bool CheckForRampDownProfile(long http_error);
/**
* @fn CheckForProfileChange
*
* @return void
*/
void CheckForProfileChange(void);
/**
* @fn GetIframeTrack
*
* @return iframe track index.
*/
int GetIframeTrack();
/**
* @fn UpdateIframeTracks
*
* @return void
*/
void UpdateIframeTracks();
/**
* @fn LastVideoFragParsedTimeMS
*
* @return Last video fragment parsed time.
*/
double LastVideoFragParsedTimeMS(void);
/**
* @fn GetDesiredProfile
*
* @param getMidProfile - Get the middle profile(True/False)
* @return profile index to be used for the track.
*/
int GetDesiredProfile(bool getMidProfile);
/**
* @fn UpdateRampdownProfileReason
*
* @return void
*/
void UpdateRampdownProfileReason(void);
/**
* @fn NotifyBitRateUpdate
* Used internally by injection logic
*
* @param[in] profileIndex - profile index of last injected fragment.
* @param[in] cacheFragStreamInfo - stream info for the last injected fragment.
* @return void
*/
void NotifyBitRateUpdate(int profileIndex, const StreamInfo &cacheFragStreamInfo, double position);
/**
* @fn IsInitialCachingSupported
*
* @return true if is supported
*/
virtual bool IsInitialCachingSupported();
/**
* @brief Whether we are playing at live point or not.
*
* @return true if we are at live point.
*/
bool IsStreamerAtLivePoint() { return mIsAtLivePoint; }
/**
* @fn Is4KStream
* @brief check if current stream have 4K content
* @param height - resolution of 4K stream if found
* @param bandwidth - bandwidth of 4K stream if foudd
* @return true on success
*/
virtual bool Is4KStream(int &height, long &bandwidth) = 0;
/**
* @fn GetPreferredLiveOffsetFromConfig
* @brief Set the offset value Live object
* @return none
*/
virtual bool GetPreferredLiveOffsetFromConfig();
/**
* @fn NotifyPlaybackPaused
*
* @param[in] paused - true, if playback was paused
* @return void
*/
virtual void NotifyPlaybackPaused(bool paused);
/**
* @fn CheckIfPlayerRunningDry
*
* @return true if player caches are dry, false otherwise.
*/
bool CheckIfPlayerRunningDry(void);
/**
* @fn CheckForPlaybackStall
*
* @param[in] fragmentParsed - true if next fragment was parsed, otherwise false
*/
void CheckForPlaybackStall(bool fragmentParsed);
/**
* @fn NotifyFirstFragmentInjected
* @return void
*/
void NotifyFirstFragmentInjected(void);
/**
* @fn GetElapsedTime
*
* @return elapsed time.
*/
double GetElapsedTime();
virtual double GetFirstPeriodStartTime() { return 0; }
virtual double GetFirstPeriodDynamicStartTime() { return 0; }
virtual uint32_t GetCurrPeriodTimeScale() { return 0; }
/**
* @fn CheckForRampDownLimitReached
* @return true if limit reached, false otherwise
*/
bool CheckForRampDownLimitReached();
bool trickplayMode; /**< trick play flag to be updated by subclasses*/
int currentProfileIndex; /**< current Video profile index of the track*/
int currentAudioProfileIndex; /**< current Audio profile index of the track*/
int currentTextTrackProfileIndex; /**< current SubTitle profile index of the track*/
int profileIdxForBandwidthNotification; /**< internal - profile index for bandwidth change notification*/
bool hasDrm; /**< denotes if the current asset is DRM protected*/
bool mIsAtLivePoint; /**< flag that denotes if playback is at live point*/
bool mIsPlaybackStalled; /**< flag that denotes if playback was stalled or not*/
bool mNetworkDownDetected; /**< Network down status indicator */
bool mCheckForRampdown; /**< flag to indicate if rampdown is attempted or not */
TuneType mTuneType; /**< Tune type of current playback, initialize by derived classes on Init()*/
int mRampDownCount; /**< Total number of rampdowns */
double mProgramStartTime; /**< Indicate program start time or availability start time */
int mTsbMaxBitrateProfileIndex; /**< Indicates the index of highest profile in the saved stream info */
/**
* @brief Get profile index of highest bandwidth
*
* @return Profile index
*/
int GetMaxBWProfile();
/**
* @brief Get profile index of given bandwidth.
*
* @param[in] bandwidth - Bandwidth
* @return Profile index
*/
virtual int GetBWIndex(long bandwidth) = 0;
/**
* @brief Get the ABRManager reference.
*
* @return The ABRManager reference.
*/
ABRManager& GetABRManager() {
return aamp->mhAbrManager;
}
/**
* @brief Get number of profiles/ representations from subclass.
*
* @return number of profiles.
*/
virtual int GetProfileCount() {
return aamp->mhAbrManager.getProfileCount();
}
/**
* @brief Get profile index for TsbBandwidth
* @param mTsbBandwidth - bandwidth to identify profile index from list
* @retval profile index of the current bandwidth
*/
virtual int GetProfileIndexForBandwidth(long mTsbBandwidth) {
return aamp->mhAbrManager.getBestMatchedProfileIndexByBandWidth(mTsbBandwidth);
}
long GetCurProfIdxBW(){
return aamp->mhAbrManager.getBandwidthOfProfile(this->currentProfileIndex);
}
/**
* @brief Gets Max bitrate supported
*
* @return max bandwidth
*/
virtual long GetMaxBitrate(){
return aamp->mhAbrManager.getBandwidthOfProfile(aamp->mhAbrManager.getMaxBandwidthProfile());
}
/**
* @fn GetVideoBitrate
*
* @return bitrate of current video profile.
*/
long GetVideoBitrate(void);
/**
* @fn GetAudioBitrate
*