This repository was 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
/
Copy pathmain_aamp.h
executable file
·2151 lines (1883 loc) · 55.4 KB
/
main_aamp.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 main_aamp.h
* @brief Types and APIs exposed by the AAMP player.
*/
/**
@mainpage Advanced Adaptive Micro Player (AAMP)
<b>AAMP</b> is a native video engine build on top of gstreamer, optimized for
performance, memory use, and code size.
<br><b>AAMP</b> downloads and parses HLS/DASH manifests. <b>AAMP</b> has been
integrated with Adobe Access, PlayReady, CONSEC agnostic, and Widevine DRM
<b>AAMP</b> is fronted by JS PP (JavaScript Player Platform), which provides an
additional layer of functionality including player analytics, configuration
management, and ad insertion.
*/
#ifndef MAINAAMP_H
#define MAINAAMP_H
#include <memory>
#include <functional>
#include <vector>
#include <string>
#include <string.h>
#include <mutex>
#include <stddef.h>
#include <functional>
#include "AampEvent.h"
#include "AampEventListener.h"
#include "AampDrmSystems.h"
#include "AampMediaType.h"
#include "AampScheduler.h"
#include "AampConfig.h"
/*! \mainpage
*
* \section intro_sec Introduction
*
* See PlayerInstanceAAMP for libaamp public C++ API's
*
*/
/**
* @enum AAMPAnomalyMessageType
* @brief AAMP anomaly message types
*/
typedef enum
{
ANOMALY_ERROR, /**< Error Message */
ANOMALY_WARNING, /**< Warning Message */
ANOMALY_TRACE /**< Trace Message */
} AAMPAnomalyMessageType;
/**
* @struct TuneFailureMap
* @brief Structure holding aamp tune failure code and corresponding application error code and description
*/
struct TuneFailureMap
{
AAMPTuneFailure tuneFailure; /**< Failure ID */
int code; /**< Error code */
const char* description; /**< Textual description */
};
/**
* @enum MediaTypeTelemetry
* @brief Media types for telemetry
*/
enum MediaTypeTelemetry
{
eMEDIATYPE_TELEMETRY_AVS, /**< Type audio, video or subtitle */
eMEDIATYPE_TELEMETRY_DRM, /**< Type DRM license */
eMEDIATYPE_TELEMETRY_INIT, /**< Type audio or video init fragment */
eMEDIATYPE_TELEMETRY_MANIFEST, /**< Type main or sub manifest file */
eMEDIATYPE_TELEMETRY_UNKNOWN, /**< Type unknown*/
};
/**
* @enum StreamOutputFormat
* @brief Media output format
*/
enum StreamOutputFormat
{
FORMAT_INVALID, /**< Invalid format */
FORMAT_MPEGTS, /**< MPEG Transport Stream */
FORMAT_ISO_BMFF, /**< ISO Base Media File format */
FORMAT_AUDIO_ES_AAC, /**< AAC Audio Elementary Stream */
FORMAT_AUDIO_ES_AC3, /**< AC3 Audio Elementary Stream */
FORMAT_AUDIO_ES_EC3, /**< Dolby Digital Plus Elementary Stream */
FORMAT_AUDIO_ES_ATMOS, /**< ATMOS Audio stream */
FORMAT_AUDIO_ES_AC4, /**< AC4 Dolby Audio stream */
FORMAT_VIDEO_ES_H264, /**< MPEG-4 Video Elementary Stream */
FORMAT_VIDEO_ES_HEVC, /**< HEVC video elementary stream */
FORMAT_VIDEO_ES_MPEG2, /**< MPEG-2 Video Elementary Stream */
FORMAT_SUBTITLE_WEBVTT, /**< WebVTT subtitle Stream */
FORMAT_SUBTITLE_TTML, /**< WebVTT subtitle Stream */
FORMAT_SUBTITLE_MP4, /**< Generic MP4 stream */
FORMAT_UNKNOWN /**< Unknown Format */
};
/**
* @enum VideoZoomMode
* @brief Video zoom mode
*/
enum VideoZoomMode
{
VIDEO_ZOOM_FULL, /**< Video Zoom Enabled */
VIDEO_ZOOM_NONE /**< Video Zoom Disabled */
};
using AdObject = std::pair<std::string, std::string>;
/**
* @enum AuthTokenErrors
* @brief Auth Token Failure codes
*/
enum AuthTokenErrors {
eAUTHTOKEN_TOKEN_PARSE_ERROR = -1, /**< Auth token parse Error */
eAUTHTOKEN_INVALID_STATUS_CODE = -2 /**< Auth token Invalid status */
};
/**
* @struct PreCacheUrlData
* @brief Pre cache the data information
*/
typedef struct PreCacheUrlData
{
std::string url;
MediaType type;
PreCacheUrlData():url(""),type(eMEDIATYPE_VIDEO)
{
}
} PreCacheUrlStruct;
typedef std::vector < PreCacheUrlStruct> PreCacheUrlList;
/**
* @brief Language Code Preference types
*/
typedef enum
{
ISO639_NO_LANGCODE_PREFERENCE,
ISO639_PREFER_3_CHAR_BIBLIOGRAPHIC_LANGCODE,
ISO639_PREFER_3_CHAR_TERMINOLOGY_LANGCODE,
ISO639_PREFER_2_CHAR_LANGCODE
} LangCodePreference;
/**
* @class Accessibility
* @brief Data type to stro Accessibility Node data
*/
class Accessibility
{
std::string strSchemeId;
int intValue;
std::string strValue;
std::string valueType;
bool isNumber(const std::string& str)
{
std::string::const_iterator it = str.begin();
while (it != str.end() && std::isdigit(*it)) ++it;
return !str.empty() && it == str.end();
};
public:
Accessibility(std::string schemId, std::string val): strSchemeId(schemId), intValue(-1), strValue(""), valueType("")
{
if (isNumber(val))
{
valueType = "int_value";
intValue = std::stoi(val);
strValue = "";
}
else
{
valueType = "string_value";
intValue = -1;
strValue = val;
}
};
Accessibility():strSchemeId(""), intValue(-1), strValue(""), valueType("") {};
void setAccessibilityData(std::string schemId, std::string val)
{
strSchemeId = schemId;
if (isNumber(val))
{
valueType = "int_value";
intValue = std::stoi(val);
strValue = "";
}
else
{
valueType = "string_value";
intValue = -1;
strValue = val;
}
};
void setAccessibilityData(std::string schemId, int val)
{
strSchemeId = schemId;
valueType = "int_value";
intValue = val;
strValue = "";
};
std::string& getTypeName() {return valueType;};
std::string& getSchemeId() {return strSchemeId;};
int getIntValue() {return intValue;};
std::string& getStrValue() {return strValue;};
void clear()
{
strSchemeId = "";
intValue = -1;
strValue = "";
valueType = "";
};
bool operator == (const Accessibility& track) const
{
return ((strSchemeId == track.strSchemeId) &&
(valueType == "int_value"?(intValue == track.intValue):(strValue == track.strValue)));
};
bool operator != (const Accessibility& track) const
{
return ((strSchemeId != track.strSchemeId) ||
(valueType == "int_value"?(intValue != track.intValue):(strValue != track.strValue)));
};
Accessibility& operator = (const Accessibility& track)
{
strSchemeId = track.strSchemeId;
intValue = track.intValue;
strValue = track.strValue;
valueType = track.valueType;
return *this;
};
std::string print()
{
char strData [228];
std::string retVal = "";
if (!strSchemeId.empty())
{
std::snprintf(strData, sizeof(strData), "{ scheme:%s, %s:", strSchemeId.c_str(), valueType.c_str());
retVal += strData;
if (valueType == "int_value")
{
std::snprintf(strData, sizeof(strData), "%d }", intValue);
}else
{
std::snprintf(strData, sizeof(strData), "%s }", strValue.c_str());
}
retVal += strData;
}
else
{
retVal = "NULL";
}
return retVal;
};
};
/**
* @struct AudioTrackInfo
* @brief Structure for audio track information
* Holds information about an audio track in playlist
*/
struct AudioTrackInfo
{
std::string index; /**< Index of track */
std::string language; /**< Language of track */
std::string rendition; /**< role for DASH, group-id for HLS */
std::string name; /**< Name of track info */
std::string codec; /**< Codec of Audio track */
std::string characteristics; /**< Charesterics field of audio track */
std::string label; /**< label of audio track info */
int channels; /**< number channels of track */
long bandwidth; /**< Bandwidth value of track **/
int primaryKey; /**< used for ATSC to store key , this should not be exposed to app */
std::string contentType; /**< used for ATSC to propogate content type */
std::string mixType; /**< used for ATSC to propogate mix type */
std::string accessibilityType; /**< value of Accessibility */
bool isMuxed; /**< Flag to indicated muxed audio track ; this is used by AC4 tracks */
Accessibility accessibilityItem; /**< Field to store Accessibility Node */
std::string mType; /**< Type field of track, to be populated by player */
bool isAvailable;
AudioTrackInfo() : index(), language(), rendition(), name(), codec(), characteristics(), channels(0),
bandwidth(0),primaryKey(0), contentType(), mixType(), accessibilityType(), isMuxed(false), label(), mType(), accessibilityItem(), isAvailable(true)
{
}
AudioTrackInfo(std::string idx, std::string lang, std::string rend, std::string trackName, std::string codecStr, std::string cha, int ch):
index(idx), language(lang), rendition(rend), name(trackName),
codec(codecStr), characteristics(cha), channels(ch), bandwidth(-1), primaryKey(0) , contentType(), mixType(), accessibilityType(), isMuxed(false), label(), mType(), accessibilityItem(),
isAvailable(true)
{
}
AudioTrackInfo(std::string idx, std::string lang, std::string rend, std::string trackName, std::string codecStr, int pk, std::string conType, std::string mixType):
index(idx), language(lang), rendition(rend), name(trackName),
codec(codecStr), characteristics(), channels(0), bandwidth(-1), primaryKey(pk),
contentType(conType), mixType(mixType), accessibilityType(), isMuxed(false), label(), mType(), accessibilityItem(),
isAvailable(true)
{
}
AudioTrackInfo(std::string idx, std::string lang, std::string rend, std::string trackName, std::string codecStr, long bw, std::string typ, bool available):
index(idx), language(lang), rendition(rend), name(trackName),
codec(codecStr), characteristics(), channels(0), bandwidth(bw),primaryKey(0), contentType(), mixType(), accessibilityType(typ), isMuxed(false), label(), mType(), accessibilityItem(),
isAvailable(true)
{
}
AudioTrackInfo(std::string idx, std::string lang, std::string rend, std::string trackName, std::string codecStr, long bw, int channel):
index(idx), language(lang), rendition(rend), name(trackName),
codec(codecStr), characteristics(), channels(channel), bandwidth(bw),primaryKey(0), contentType(), mixType(), accessibilityType(), isMuxed(false), label(), mType(), accessibilityItem(),
isAvailable(true)
{
}
AudioTrackInfo(std::string idx, std::string lang, std::string rend, std::string trackName, std::string codecStr, long bw, int channel, bool muxed, bool available):
index(idx), language(lang), rendition(rend), name(trackName),
codec(codecStr), characteristics(), channels(channel), bandwidth(bw),primaryKey(0), contentType(), mixType(), accessibilityType(), isMuxed(muxed), label(), mType(), accessibilityItem(),
isAvailable(available)
{
}
AudioTrackInfo(std::string idx, std::string lang, std::string rend, std::string trackName, std::string codecStr, long bw, std::string typ, bool muxed, std::string lab, std::string type, bool available):
index(idx), language(lang), rendition(rend), name(trackName),
codec(codecStr), characteristics(), channels(0), bandwidth(bw),primaryKey(0), contentType(), mixType(), accessibilityType(typ), isMuxed(muxed), label(lab), mType(type), accessibilityItem(),
isAvailable(available)
{
}
AudioTrackInfo(std::string idx, std::string lang, std::string rend, std::string trackName, std::string codecStr, long bw, std::string typ, bool muxed, std::string lab, std::string type, Accessibility accessbility, bool available):
index(idx), language(lang), rendition(rend), name(trackName),
codec(codecStr), characteristics(), channels(0), bandwidth(bw),primaryKey(0), contentType(), mixType(), accessibilityType(typ), isMuxed(muxed), label(lab), mType(type), accessibilityItem(accessbility),
isAvailable(available)
{
}
bool operator == (const AudioTrackInfo& track) const
{
return ((language == track.language) &&
(rendition == track.rendition) &&
(contentType == track.contentType) &&
(codec == track.codec) &&
(channels == track.channels) &&
(bandwidth == track.bandwidth) &&
(isMuxed == track.isMuxed) &&
(label == track.label) &&
(mType == track.mType) &&
(accessibilityItem == track.accessibilityItem));
}
bool operator < (const AudioTrackInfo& track) const
{
return (bandwidth < track.bandwidth);
}
bool operator > (const AudioTrackInfo& track) const
{
return (bandwidth > track.bandwidth);
}
};
/**
* @brief Structure for text track information
* Holds information about a text track in playlist
*/
struct TextTrackInfo
{
std::string index;
std::string language;
bool isCC;
std::string rendition; //role for DASH, group-id for HLS
std::string name;
std::string instreamId;
std::string characteristics;
std::string codec;
std::string label; //Field for label
int primaryKey; // used for ATSC to store key , this should not be exposed to app.
std::string accessibilityType; //value of Accessibility
Accessibility accessibilityItem; /**< Field to store Accessibility Node */
std::string mType;
bool isAvailable;
TextTrackInfo() : index(), language(), isCC(false), rendition(), name(), instreamId(), characteristics(), codec(), primaryKey(0), accessibilityType(), label(), mType(), accessibilityItem(),
isAvailable(true)
{
}
TextTrackInfo(std::string idx, std::string lang, bool cc, std::string rend, std::string trackName, std::string id, std::string cha):
index(idx), language(lang), isCC(cc), rendition(rend),
name(trackName), instreamId(id), characteristics(cha),
codec(), primaryKey(0), accessibilityType(), label(), mType(), accessibilityItem(), isAvailable(true)
{
}
TextTrackInfo(std::string idx, std::string lang, bool cc, std::string rend, std::string trackName, std::string id, std::string cha, int pk):
index(idx), language(lang), isCC(cc), rendition(rend),
name(trackName), instreamId(id), characteristics(cha),
codec(), primaryKey(pk), accessibilityType(), label(), mType(), accessibilityItem(), isAvailable(true)
{
}
TextTrackInfo(std::string idx, std::string lang, bool cc, std::string rend, std::string trackName, std::string codecStr, std::string cha, std::string typ):
index(idx), language(lang), isCC(cc), rendition(rend),
name(trackName), instreamId(), characteristics(cha),
codec(codecStr), primaryKey(0), accessibilityType(typ), label(), mType(), accessibilityItem(), isAvailable(true)
{
}
TextTrackInfo(std::string idx, std::string lang, bool cc, std::string rend, std::string trackName, std::string codecStr, std::string cha, std::string typ, std::string lab, std::string type):
index(idx), language(lang), isCC(cc), rendition(rend),
name(trackName), instreamId(), characteristics(cha),
codec(codecStr), primaryKey(0), accessibilityType(typ), label(lab), mType(type), accessibilityItem(), isAvailable(true)
{
}
TextTrackInfo(std::string idx, std::string lang, bool cc, std::string rend, std::string trackName, std::string codecStr, std::string cha, std::string typ, std::string lab, std::string type, Accessibility acc, bool available):
index(idx), language(lang), isCC(cc), rendition(rend),
name(trackName), instreamId(), characteristics(cha),
codec(codecStr), primaryKey(0), accessibilityType(typ), label(lab), mType(type), accessibilityItem(acc), isAvailable(available)
{
}
void set (std::string idx, std::string lang, bool cc, std::string rend, std::string trackName, std::string codecStr, std::string cha,
std::string acctyp, std::string lab, std::string type, Accessibility acc)
{
index = idx;
language = lang;
isCC = cc;
rendition = rend;
name = trackName;
characteristics = cha;
codec = codecStr;
accessibilityType = acctyp;
label = lab;
accessibilityItem = acc;
mType = type;
}
bool operator == (const TextTrackInfo& track) const
{
return ((language == track.language) &&
(isCC == track.isCC) &&
(rendition == track.rendition) &&
(name == track.name) &&
(characteristics == track.characteristics) &&
(codec == track.codec) &&
(accessibilityType == track.accessibilityType) &&
(label == track.label) &&
(accessibilityItem == track.accessibilityItem) &&
(mType == track.mType));
}
bool operator < (const TextTrackInfo& track) const
{
return (index < track.index);
}
bool operator > (const TextTrackInfo& track) const
{
return (index > track.index);
}
};
/**
* @class StreamSink
* @brief GStreamer Abstraction class for the implementation of AAMPGstPlayer and gstaamp plugin
*/
class StreamSink
{
public:
/**
* @brief Configure output formats
*
* @param[in] format - Video output format.
* @param[in] audioFormat - Audio output format.
* @param[in] auxFormat - Aux audio output format.
* @param[in] bESChangeStatus - Flag to keep force configure the pipeline value
* @param[in] forwardAudioToAux - Flag denotes if audio buffers have to be forwarded to aux pipeline
* @param[in] setReadyAfterPipelineCreation - Flag denotes if pipeline has to be reset to ready or not
* @return void
*/
virtual void Configure(StreamOutputFormat format, StreamOutputFormat audioFormat, StreamOutputFormat auxFormat, StreamOutputFormat subFormat, bool bESChangeStatus, bool forwardAudioToAux, bool setReadyAfterPipelineCreation=false){}
/**
* @brief API to send audio/video buffer into the sink.
*
* @param[in] mediaType - Type of the media.
* @param[in] ptr - Pointer to the buffer; caller responsible of freeing memory
* @param[in] len - Buffer length.
* @param[in] fpts - Presentation Time Stamp.
* @param[in] fdts - Decode Time Stamp
* @param[in] duration - Buffer duration.
* @return void
*/
virtual void SendCopy( MediaType mediaType, const void *ptr, size_t len, double fpts, double fdts, double duration)= 0;
/**
* @brief API to send audio/video buffer into the sink.
*
* @param[in] mediaType - Type of the media.
* @param[in] buffer - Pointer to the GrowableBuffer; ownership is taken by the sink
* @param[in] fpts - Presentation Time Stamp.
* @param[in] fdts - Decode Time Stamp
* @param[in] duration - Buffer duration.
* @param[in] initFragment - flag for buffer type (init, data)
* @return void
*/
virtual void SendTransfer( MediaType mediaType, struct GrowableBuffer* buffer, double fpts, double fdts, double duration, bool initFragment = false)= 0;
/**
* @brief Notifies EOS to sink
*
* @param[in] mediaType - Media Type
* @return void
*/
virtual void EndOfStreamReached(MediaType mediaType){}
/**
* @brief Start the stream
*
* @return void
*/
virtual void Stream(void){}
/**
* @fn Stop
*
* @param[in] keepLastFrame - Keep the last frame on screen (true/false)
* @return void
*/
virtual void Stop(bool keepLastFrame){}
/**
* @brief Dump the sink status for debugging purpose
*
* @return void
*/
virtual void DumpStatus(void){}
/**
* @brief Flush the pipeline
*
* @param[in] position - playback position
* @param[in] rate - Speed
* @param[in] shouldTearDown - if pipeline is not in a valid state, tear down pipeline
* @return void
*/
virtual void Flush(double position = 0, int rate = AAMP_NORMAL_PLAY_RATE, bool shouldTearDown = true){}
/**
* @brief Set player rate to audio/video sink
*
* @param[in] rate - Speed
* @return true if player rate is set successfully
*/
virtual bool SetPlayBackRate ( double rate ){return true;}
/**
* @brief Adjust the pipeline
*
* @param[in] position - playback position
* @param[in] rate - Speed
* @return void
*/
virtual bool AdjustPlayBackRate(double position, double rate){ return true; }
/**
* @brief Enabled or disable playback pause
*
* @param[in] pause Enable/Disable
* @param[in] forceStopGstreamerPreBuffering - true for disabling bufferinprogress
* @return true if content successfully paused
*/
virtual bool Pause(bool pause, bool forceStopGstreamerPreBuffering){ return true; }
/**
* @brief Get playback duration in milliseconds
*
* @return duration in ms.
*/
virtual long GetDurationMilliseconds(void){ return 0; };
/**
* @brief Get playback position in milliseconds
*
* @return Position in ms.
*/
virtual long GetPositionMilliseconds(void){ return 0; };
/**
* @brief Get Video 90 KHz Video PTS
*
* @return video PTS
*/
virtual long long GetVideoPTS(void){ return 2; };
/**
* @brief Get closed caption handle
*
* @return Closed caption handle
*/
virtual unsigned long getCCDecoderHandle(void) { return 0; };
/**
* @brief Set video display rectangle co-ordinates
*
* @param[in] x - x position
* @param[in] y - y position
* @param[in] w - Width
* @param[in] h - Height
* @return void
*/
virtual void SetVideoRectangle(int x, int y, int w, int h){};
/**
* @brief Set video zoom state
*
* @param[in] zoom - Zoom mode
* @return void
*/
virtual void SetVideoZoom(VideoZoomMode zoom){};
/**
* @brief Set video mute state
*
* @param[in] muted - true: video muted, false: video unmuted
* @return void
*/
virtual void SetVideoMute(bool muted){};
/**
* @brief Set subtitle mute state
*
* @param[in] muted - true: subtitle muted, false: subtitle unmuted
* @return void
*/
virtual void SetSubtitleMute(bool muted){};
/**
* @brief Set subtitle pts offset in sink
*
* @param[in] pts_offset - pts offset for subs display
* @return void
*/
virtual void SetSubtitlePtsOffset(std::uint64_t pts_offset){};
/**
* @brief Set volume level
*
* @param[in] volume - Minimum 0, maximum 100.
* @return void
*/
virtual void SetAudioVolume(int volume){};
/**
* @brief StreamSink Dtor
*/
virtual ~StreamSink(){};
/**
* @brief Process PTS discontinuity for a stream type
*
* @param[in] mediaType - Media Type
* @return TRUE if discontinuity processed
*/
virtual bool Discontinuity( MediaType mediaType) = 0;
/**
* @brief Check if PTS is changing
*
* @param[in] timeout - max time period within which PTS hasn't changed
* @retval true if PTS is changing, false if PTS hasn't changed for timeout msecs
*/
virtual bool CheckForPTSChangeWithTimeout(long timeout) { return true; }
/**
* @brief Check whether cach is empty
*
* @param[in] mediaType - Media Type
* @return true: empty, false: not empty
*/
virtual bool IsCacheEmpty(MediaType mediaType){ return true; };
/**
* @brief Reset EOS SignalledFlag
*/
virtual void ResetEOSSignalledFlag(){};
/**
* @brief API to notify that fragment caching done
*
* @return void
*/
virtual void NotifyFragmentCachingComplete(){};
/**
* @brief API to notify that fragment caching is ongoing
*
* @return void
*/
virtual void NotifyFragmentCachingOngoing(){};
/**
* @brief Get the video dimensions
*
* @param[out] w - Width
* @param[out] h - Height
* @return void
*/
virtual void GetVideoSize(int &w, int &h){};
/**
* @brief Queue-up the protection event.
*
* @param[in] protSystemId - DRM system ID.
* @param[in] ptr - Pointer to the protection data.
* @param[in] len - Length of the protection data.
* @return void
*/
virtual void QueueProtectionEvent(const char *protSystemId, const void *ptr, size_t len, MediaType type) {};
/**
* @brief Clear the protection event.
*
* @return void
*/
virtual void ClearProtectionEvent() {};
/**
* @brief Signal discontinuity on trickmode if restamping is done by stream sink.
*
* @return void
*/
virtual void SignalTrickModeDiscontinuity() {};
/**
* @brief Seek stream sink to desired position and playback rate with a flushing seek
*
* @param[in] position - desired playback position.
* @param[in] rate - desired playback rate.
* @return void
*/
virtual void SeekStreamSink(double position, double rate) {};
/**
* @brief Get the video window co-ordinates
*
* @return current video co-ordinates in x,y,w,h format
*/
virtual std::string GetVideoRectangle() { return std::string(); };
/**
* @brief Stop buffering in sink
*
* @param[in] forceStop - true if buffering to be stopped without any checks
* @return void
*/
virtual void StopBuffering(bool forceStop) { };
/**
* @brief API to set track Id to audio sync property in case of AC4 audio
*
* @param[in] trackId - AC4 track Id parsed by aamp based of preference
* @return bol sttaus of API
*/
};
/**
* @class PlayerInstanceAAMP
* @brief Player interface class for the JS pluggin.
*/
class PlayerInstanceAAMP
{
public:
/**
* @fn PlayerInstanceAAMP
*
* @param streamSink - custom stream sink, NULL for default.
* @param exportFrames - Callback function to export video frames of signature 'void fn(uint8_t *yuvBuffer, int size, int pixel_w, int pixel_h)'
*/
PlayerInstanceAAMP(StreamSink* streamSink = NULL
, std::function< void(uint8_t *, int, int, int) > exportFrames = nullptr
);
/**
* @fn ~PlayerInstanceAAMP
*/
~PlayerInstanceAAMP();
/**
* @brief copy constructor
*
* @param other object to copy
*/
PlayerInstanceAAMP(const PlayerInstanceAAMP& other) = delete;
/**
* @brief To overload = operator for copying
*
* @param other object to copy
*/
PlayerInstanceAAMP& operator=(const PlayerInstanceAAMP& other) = delete;
/**
* @fn Tune
*
* @param[in] mainManifestUrl - HTTP/HTTPS url to be played.
* @param[in] contentType - Content type of the asset
* @param[in] audioDecoderStreamSync - Enable or disable audio decoder stream sync,
* set to 'false' if audio fragments come with additional padding at the end (BCOM-4203)
* @return void
*/
void Tune(const char *mainManifestUrl, const char *contentType, bool bFirstAttempt, bool bFinalAttempt,const char *traceUUID,bool audioDecoderStreamSync);
/**
* @fn Tune
*
* @param[in] mainManifestUrl - HTTP/HTTPS url to be played.
* @param[in] autoPlay - Start playback immediately or not
* @param[in] contentType - Content type of the asset
* @param[in] audioDecoderStreamSync - Enable or disable audio decoder stream sync,
* set to 'false' if audio fragments come with additional padding at the end (BCOM-4203)
* @return void
*/
void Tune(const char *mainManifestUrl, bool autoPlay = true, const char *contentType = NULL, bool bFirstAttempt = true, bool bFinalAttempt = false,const char *traceUUID = NULL,bool audioDecoderStreamSync = true);
/**
* @brief Stop playback and release resources.
* @param[in] sendStateChangeEvent - true if state change events need to be sent for Stop operation
* @return void
*/
void Stop(bool sendStateChangeEvent = true);
/**
* @fn ResetConfiguration
* @return void
*/
void ResetConfiguration();
/**
* @fn SetRate
*
* @param[in] rate - Rate of playback.
* @param[in] overshootcorrection - overshoot correction in milliseconds.
* @return void
*/
void SetRate(float rate, int overshootcorrection=0);
/**
* @fn PauseAt
*
* Any subsequent call to this method will override the previous call.
*
* @param[in] position - Absolute position within the asset for VOD or
* relative position from first tune command for linear content;
* a negative value would cancel any previous PauseAt call.
* @return void
*/
void PauseAt(double position);
/**
* @fn Seek
*
* @param[in] secondsRelativeToTuneTime - Seek position for VOD,
* relative position from first tune command.
* @param[in] keepPaused - set true if want to keep paused state after seek
*/
void Seek(double secondsRelativeToTuneTime, bool keepPaused = false);
/**
* @fn SeekToLive
*
* @param[in] keepPaused - set true if want to keep paused state after seek
* @return void
*/
void SeekToLive(bool keepPaused = false);
/**
* @fn SetRateAndSeek
*
* @param[in] rate - Rate of playback.
* @param[in] secondsRelativeToTuneTime - Seek position for VOD,
* relative position from first tune command.
* @return void
*/
void SetRateAndSeek(int rate, double secondsRelativeToTuneTime);
/**
* @brief Set slow motion player speed.
*
* @param[in] rate - Rate of playback.
*/
void SetSlowMotionPlayRate (float rate );
/**
* @fn detach
* @return void
*/
void detach();
/**
* @fn RegisterEvents
*
* @param[in] eventListener - pointer to implementation of EventListener to receive events.
* @return void
*/
void RegisterEvents(EventListener* eventListener);
/**
* @fn UnRegisterEvents
*
* @param[in] eventListener - pointer to implementation of EventListener to receive events.
* @return void
*/
void UnRegisterEvents(EventListener* eventListener);
/**
* @fn SetVideoRectangle
*
* @param[in] x - horizontal start position.
* @param[in] y - vertical start position.
* @param[in] w - width.
* @param[in] h - height.
* @return void
*/
void SetVideoRectangle(int x, int y, int w, int h);
/**
* @fn SetVideoZoom
*
* @param[in] zoom - zoom mode.
* @return void
*/
void SetVideoZoom(VideoZoomMode zoom);
/**
* @fn SetVideoMute
*
* @param[in] muted - true to disable video, false to enable video.
* @return void
*/
void SetVideoMute(bool muted);
/**
* @brief Enable/ Disable Subtitle.
*
* @param[in] muted - true to disable subtitle, false to enable subtitle.
* @return void
*/
void SetSubtitleMute(bool muted);
/**
* @brief Set Audio Volume.
*
* @param[in] volume - Minimum 0, maximum 100.
* @return void
*/
void SetAudioVolume(int volume);