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
/
aampgstplayer.cpp
executable file
·4916 lines (4517 loc) · 172 KB
/
aampgstplayer.cpp
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 aampgstplayer.cpp
* @brief Gstreamer based player impl for AAMP
*/
#include "aampgstplayer.h"
#include "AampFnLogger.h"
#include "isobmffbuffer.h"
#include "AampUtils.h"
#include "AampGstUtils.h"
#include <gst/gst.h>
#include <gst/app/gstappsrc.h>
#include <gst/app/gstappsink.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h> // for sprintf
#include "priv_aamp.h"
#include <pthread.h>
#include <atomic>
#ifdef __APPLE__
#include "gst/video/videooverlay.h"
guintptr (*gCbgetWindowContentView)() = NULL;
#endif
#ifdef AAMP_MPD_DRM
#include "aampoutputprotection.h"
#endif
/**
* @enum GstPlayFlags
* @brief Enum of configuration flags used by playbin
*/
typedef enum {
GST_PLAY_FLAG_VIDEO = (1 << 0), /**< value is 0x001 */
GST_PLAY_FLAG_AUDIO = (1 << 1), /**< value is 0x002 */
GST_PLAY_FLAG_TEXT = (1 << 2), /**< value is 0x004 */
GST_PLAY_FLAG_VIS = (1 << 3), /**< value is 0x008 */
GST_PLAY_FLAG_SOFT_VOLUME = (1 << 4), /**< value is 0x010 */
GST_PLAY_FLAG_NATIVE_AUDIO = (1 << 5), /**< value is 0x020 */
GST_PLAY_FLAG_NATIVE_VIDEO = (1 << 6), /**< value is 0x040 */
GST_PLAY_FLAG_DOWNLOAD = (1 << 7), /**< value is 0x080 */
GST_PLAY_FLAG_BUFFERING = (1 << 8), /**< value is 0x100 */
GST_PLAY_FLAG_DEINTERLACE = (1 << 9), /**< value is 0x200 */
GST_PLAY_FLAG_SOFT_COLORBALANCE = (1 << 10) /**< value is 0x400 */
} GstPlayFlags;
//#define SUPPORT_MULTI_AUDIO
#define GST_ELEMENT_GET_STATE_RETRY_CNT_MAX 5
/*Playersinkbin events*/
#define GSTPLAYERSINKBIN_EVENT_HAVE_VIDEO 0x01
#define GSTPLAYERSINKBIN_EVENT_HAVE_AUDIO 0x02
#define GSTPLAYERSINKBIN_EVENT_FIRST_VIDEO_FRAME 0x03
#define GSTPLAYERSINKBIN_EVENT_FIRST_AUDIO_FRAME 0x04
#define GSTPLAYERSINKBIN_EVENT_ERROR_VIDEO_UNDERFLOW 0x06
#define GSTPLAYERSINKBIN_EVENT_ERROR_AUDIO_UNDERFLOW 0x07
#define GSTPLAYERSINKBIN_EVENT_ERROR_VIDEO_PTS 0x08
#define GSTPLAYERSINKBIN_EVENT_ERROR_AUDIO_PTS 0x09
#ifdef INTELCE
#define INPUT_GAIN_DB_MUTE (gdouble)-145
#define INPUT_GAIN_DB_UNMUTE (gdouble)0
#endif
#define DEFAULT_BUFFERING_TO_MS 10 /**< TimeOut interval to check buffer fullness */
#if defined(REALTEKCE)
#define DEFAULT_BUFFERING_QUEUED_FRAMES_MIN (3) /**< if the video decoder has this many queued frames start.. */
#define DEFAULT_AVSYNC_FREERUN_THRESHOLD_SECS 12 /**< Currently MAX FRAG DURATION + 2 per Realtek */
#else
#define DEFAULT_BUFFERING_QUEUED_FRAMES_MIN (5) /**< if the video decoder has this many queued frames start.. even at 60fps, close to 100ms... */
#endif
#define DEFAULT_BUFFERING_MAX_MS (1000) /**< max buffering time */
#define DEFAULT_BUFFERING_MAX_CNT (DEFAULT_BUFFERING_MAX_MS/DEFAULT_BUFFERING_TO_MS) /**< max buffering timeout count */
#define AAMP_MIN_PTS_UPDATE_INTERVAL 4000 /**< Time duration in milliseconds if exceeded and pts has not changed; it is concluded pts is not changing */
#define AAMP_DELAY_BETWEEN_PTS_CHECK_FOR_EOS_ON_UNDERFLOW 500 /**< A timeout interval in milliseconds to check pts in case of underflow */
#define BUFFERING_TIMEOUT_PRIORITY -70 /**< 0 is DEFAULT priority whereas -100 is the HIGH_PRIORITY */
#define AAMP_MIN_DECODE_ERROR_INTERVAL 10000 /**< Minimum time interval in milliseconds between two decoder error CB to send anomaly error */
#define VIDEO_COORDINATES_SIZE 32
/**
* @name gmapDecoderLoookUptable
*
* @brief Decoder map list lookup table
* convert from codec to string map list of gstreamer
* component.
*/
static std::map <std::string, std::vector<std::string>> gmapDecoderLoookUptable =
{
{"ac-3", {"omxac3dec", "avdec_ac3", "avdec_ac3_fixed"}},
{"ac-4", {"omxac4dec"}}
};
/**
* @struct media_stream
* @brief Holds stream(Audio, Video, Subtitle and Aux-Audio) specific variables.
*/
struct media_stream
{
GstElement *sinkbin; /**< Sink element to consume data */
GstElement *source; /**< to provide data to the pipleline */
StreamOutputFormat format; /**< Stream output format for this stream */
gboolean using_playersinkbin; /**< Set to TRUE if stream type is MPEG transport stream. Playersink consists of demux, decoder and sink elements */
bool flush; /**< used to flush the pipleline */
bool resetPosition; /**< To indicate that the position of the stream is reset */
bool bufferUnderrun;
bool eosReached; /**< To indicate the status of End of Stream reached */
bool sourceConfigured; /**< To indicate that the current source is initialised and configured */
pthread_mutex_t sourceLock;
uint32_t timeScale;
int32_t trackId; /**< Current Audio Track Id,so far it is implimented for AC4 track selection only */
media_stream() : sinkbin(NULL), source(NULL), format(FORMAT_INVALID),
using_playersinkbin(FALSE), flush(false), resetPosition(false),
bufferUnderrun(false), eosReached(false), sourceConfigured(false), sourceLock(PTHREAD_MUTEX_INITIALIZER)
, timeScale(1), trackId(-1)
{
}
};
/**
* @struct AAMPGstPlayerPriv
* @brief Holds private variables of AAMPGstPlayer
*/
struct AAMPGstPlayerPriv
{
AAMPGstPlayerPriv(const AAMPGstPlayerPriv&) = delete;
AAMPGstPlayerPriv& operator=(const AAMPGstPlayerPriv&) = delete;
media_stream stream[AAMP_TRACK_COUNT];
GstElement *pipeline; /**< GstPipeline used for playback. */
GstBus *bus; /**< Bus for receiving GstEvents from pipeline. */
int current_rate;
guint64 total_bytes;
gint n_audio; /**< Number of audio tracks. */
gint current_audio; /**< Offset of current audio track. */
std::mutex TaskControlMutex; /**< For scheduling/de-scheduling or resetting async tasks/variables and timers */
TaskControlData firstProgressCallbackIdleTask;
guint periodicProgressCallbackIdleTaskId; /**< ID of timed handler created for notifying progress events. */
guint bufferingTimeoutTimerId; /**< ID of timer handler created for buffering timeout. */
GstElement *video_dec; /**< Video decoder used by pipeline. */
GstElement *audio_dec; /**< Audio decoder used by pipeline. */
GstElement *video_sink; /**< Video sink used by pipeline. */
GstElement *audio_sink; /**< Audio sink used by pipeline. */
GstElement *subtitle_sink; /**< Subtitle sink used by pipeline. */
#ifdef INTELCE_USE_VIDRENDSINK
GstElement *video_pproc; /**< Video element used by pipeline.(only for Intel). */
#endif
int rate; /**< Current playback rate. */
double playbackrate; /**< playback rate in fractions */
VideoZoomMode zoom; /**< Video-zoom setting. */
bool videoMuted; /**< Video mute status. */
bool audioMuted; /**< Audio mute status. */
std::mutex volumeMuteMutex; /**< Mutex to ensure setVolumeOrMuteUnMute is thread-safe. */
bool subtitleMuted; /**< Subtitle mute status. */
double audioVolume; /**< Audio volume. */
guint eosCallbackIdleTaskId; /**< ID of idle handler created for notifying EOS event. */
std::atomic<bool> eosCallbackIdleTaskPending; /**< Set if any eos callback is pending. */
bool firstFrameReceived; /**< Flag that denotes if first frame was notified. */
char videoRectangle[VIDEO_COORDINATES_SIZE]; /**< Video-rectangle co-ordinates in format x,y,w,h. */
bool pendingPlayState; /**< Flag that denotes if set pipeline to PLAYING state is pending. */
bool decoderHandleNotified; /**< Flag that denotes if decoder handle was notified. */
guint firstFrameCallbackIdleTaskId; /**< ID of idle handler created for notifying first frame event. */
GstEvent *protectionEvent[AAMP_TRACK_COUNT]; /**< GstEvent holding the pssi data to be sent downstream. */
std::atomic<bool> firstFrameCallbackIdleTaskPending; /**< Set if any first frame callback is pending. */
bool using_westerossink; /**< true if westros sink is used as video sink */
guint busWatchId; /**< Id of the event source assigned to the message bus */
std::atomic<bool> eosSignalled; /**< Indicates if EOS has signaled */
gboolean buffering_enabled; /**< enable buffering based on multiqueue */
gboolean buffering_in_progress; /**< buffering is in progress */
guint buffering_timeout_cnt; /**< make sure buffering_timeout doesn't get stuck */
GstState buffering_target_state; /**< the target state after buffering */
#ifdef INTELCE
bool keepLastFrame; /**< Keep last frame over next pipeline delete/ create cycle */
#endif
gint64 lastKnownPTS; /**< To store the PTS of last displayed video */
long long ptsUpdatedTimeMS; /**< Timestamp when PTS was last updated */
guint ptsCheckForEosOnUnderflowIdleTaskId; /**< ID of task to ensure video PTS is not moving before notifying EOS on underflow. */
int numberOfVideoBuffersSent; /**< Number of video buffers sent to pipeline */
gint64 segmentStart; /**< segment start value; required when qtdemux is enabled and restamping is disabled */
GstQuery *positionQuery; /**< pointer that holds a position query object */
GstQuery *durationQuery; /**< pointer that holds a duration query object */
bool paused; /**< if pipeline is deliberately put in PAUSED state due to user interaction */
GstState pipelineState; /**< current state of pipeline */
guint firstVideoFrameDisplayedCallbackIdleTaskId; /**< ID of idle handler created for notifying state changed to Playing */
std::atomic<bool> firstVideoFrameDisplayedCallbackIdleTaskPending; /**< Set if any state changed to Playing callback is pending. */
#if defined(REALTEKCE)
bool firstTuneWithWesterosSinkOff; /**< DELIA-33640: track if first tune was done for Realtekce build */
#endif
long long decodeErrorMsgTimeMS; /**< Timestamp when decode error message last posted */
int decodeErrorCBCount; /**< Total decode error cb received within thresold time */
bool progressiveBufferingEnabled;
bool progressiveBufferingStatus;
bool forwardAudioBuffers; /**< flag denotes if audio buffers to be forwarded to aux pipeline */
bool enableSEITimeCode; /**< Enables SEI Time Code handling */
bool firstVideoFrameReceived; /**< flag that denotes if first video frame was notified. */
bool firstAudioFrameReceived; /**< flag that denotes if first audio frame was notified */
int NumberOfTracks; /**< Indicates the number of tracks */
AAMPGstPlayerPriv() : pipeline(NULL), bus(NULL), current_rate(0),
total_bytes(0), n_audio(0), current_audio(0),
periodicProgressCallbackIdleTaskId(AAMP_TASK_ID_INVALID),
bufferingTimeoutTimerId(AAMP_TASK_ID_INVALID), video_dec(NULL), audio_dec(NULL),TaskControlMutex(),firstProgressCallbackIdleTask("FirstProgressCallback"),
video_sink(NULL), audio_sink(NULL), subtitle_sink(NULL),
#ifdef INTELCE_USE_VIDRENDSINK
video_pproc(NULL),
#endif
rate(AAMP_NORMAL_PLAY_RATE), zoom(VIDEO_ZOOM_FULL), videoMuted(false), audioMuted(false), volumeMuteMutex(), subtitleMuted(false),
audioVolume(1.0), eosCallbackIdleTaskId(AAMP_TASK_ID_INVALID), eosCallbackIdleTaskPending(false),
firstFrameReceived(false), pendingPlayState(false), decoderHandleNotified(false),
firstFrameCallbackIdleTaskId(AAMP_TASK_ID_INVALID), firstFrameCallbackIdleTaskPending(false),
using_westerossink(false), busWatchId(0), eosSignalled(false),
buffering_enabled(FALSE), buffering_in_progress(FALSE), buffering_timeout_cnt(0),
buffering_target_state(GST_STATE_NULL),
playbackrate(AAMP_NORMAL_PLAY_RATE),
#ifdef INTELCE
keepLastFrame(false),
#endif
lastKnownPTS(0), ptsUpdatedTimeMS(0), ptsCheckForEosOnUnderflowIdleTaskId(AAMP_TASK_ID_INVALID),
numberOfVideoBuffersSent(0), segmentStart(0), positionQuery(NULL), durationQuery(NULL),
paused(false), pipelineState(GST_STATE_NULL), firstVideoFrameDisplayedCallbackIdleTaskId(AAMP_TASK_ID_INVALID),
firstVideoFrameDisplayedCallbackIdleTaskPending(false),
#if defined(REALTEKCE)
firstTuneWithWesterosSinkOff(false),
#endif
decodeErrorMsgTimeMS(0), decodeErrorCBCount(0),
progressiveBufferingEnabled(false), progressiveBufferingStatus(false)
, forwardAudioBuffers (false), enableSEITimeCode(true),firstVideoFrameReceived(false),firstAudioFrameReceived(false),NumberOfTracks(0)
{
memset(videoRectangle, '\0', VIDEO_COORDINATES_SIZE);
#ifdef INTELCE
strcpy(videoRectangle, "0,0,0,0");
#else
/* DELIA-45366-default video scaling should take into account actual graphics
* resolution instead of assuming 1280x720.
* By default we where setting the resolution has 0,0,1280,720.
* For Full HD this default resolution will not scale to full size.
* So, we no need to set any default rectangle size here,
* since the video will display full screen, if a gstreamer pipeline is started
* using the westerossink connected using westeros compositor.
*/
strcpy(videoRectangle, "");
#endif
for(int i = 0; i < AAMP_TRACK_COUNT; i++)
{
protectionEvent[i] = NULL;
}
}
};
static const char* GstPluginNamePR = "aampplayreadydecryptor";
static const char* GstPluginNameWV = "aampwidevinedecryptor";
static const char* GstPluginNameCK = "aampclearkeydecryptor";
static const char* GstPluginNameVMX = "aampverimatrixdecryptor";
/**
* @brief Called from the mainloop when a message is available on the bus
* @param[in] bus the GstBus that sent the message
* @param[in] msg the GstMessage
* @param[in] _this pointer to AAMPGstPlayer instance
* @retval FALSE if the event source should be removed.
*/
static gboolean bus_message(GstBus * bus, GstMessage * msg, AAMPGstPlayer * _this);
/**
* @fn bus_sync_handler
* @brief Invoked synchronously when a message is available on the bus
* @param[in] bus the GstBus that sent the message
* @param[in] msg the GstMessage
* @param[in] _this pointer to AAMPGstPlayer instance
* @retval GST_BUS_PASS to pass the message to the async queue
*/
static GstBusSyncReply bus_sync_handler(GstBus * bus, GstMessage * msg, AAMPGstPlayer * _this);
/**
* @brief g_timeout callback to wait for buffering to change
* pipeline from paused->playing
*/
static gboolean buffering_timeout (gpointer data);
/**
* @brief check if elemement is instance (BCOM-3563)
*/
static void type_check_instance( const char * str, GstElement * elem);
/**
* @fn SetStateWithWarnings
* @brief wraps gst_element_set_state and adds log messages where applicable
* @param[in] element the GstElement whose state is to be changed
* @param[in] targetState the GstState to apply to element
* @param[in] _this pointer to AAMPGstPlayer instance
* @retval Result of the state change (from inner gst_element_set_state())
*/
static GstStateChangeReturn SetStateWithWarnings(GstElement *element, GstState targetState);
#define PLUGINS_TO_LOWER_RANK_MAX 2
const char *plugins_to_lower_rank[PLUGINS_TO_LOWER_RANK_MAX] = {
"aacparse",
"ac3parse",
};
/**
* @brief AAMPGstPlayer Constructor
*/
AAMPGstPlayer::AAMPGstPlayer(AampLogManager *logObj, PrivateInstanceAAMP *aamp
#ifdef RENDER_FRAMES_IN_APP_CONTEXT
, std::function< void(uint8_t *, int, int, int) > exportFrames
#endif
) : mLogObj(logObj), aamp(NULL) , privateContext(NULL), mBufferingLock(), mProtectionLock(), PipelineSetToReady(false), trickTeardown(false)
#ifdef RENDER_FRAMES_IN_APP_CONTEXT
, cbExportYUVFrame(NULL)
#endif
{
FN_TRACE( __FUNCTION__ );
privateContext = new AAMPGstPlayerPriv();
if(privateContext)
{
this->aamp = aamp;
pthread_mutex_init(&mBufferingLock, NULL);
pthread_mutex_init(&mProtectionLock, NULL);
for (int i = 0; i < AAMP_TRACK_COUNT; i++)
pthread_mutex_init(&privateContext->stream[i].sourceLock, NULL);
#ifdef RENDER_FRAMES_IN_APP_CONTEXT
this->cbExportYUVFrame = exportFrames;
#endif
CreatePipeline();
}
else
{
AAMPLOG_WARN("privateContext is null"); //CID:85372 - Null Returns
}
}
/**
* @brief AAMPGstPlayer Destructor
*/
AAMPGstPlayer::~AAMPGstPlayer()
{
FN_TRACE( __FUNCTION__ );
DestroyPipeline();
for (int i = 0; i < AAMP_TRACK_COUNT; i++)
pthread_mutex_destroy(&privateContext->stream[i].sourceLock);
SAFE_DELETE(privateContext);
pthread_mutex_destroy(&mBufferingLock);
pthread_mutex_destroy(&mProtectionLock);
}
/**
* @brief IdleTaskAdd - add an async/idle task in a thread safe manner, assuming it is not queued
*/
bool AAMPGstPlayer::IdleTaskAdd(TaskControlData& taskDetails, BackgroundTask funcPtr)
{
FN_TRACE( __FUNCTION__ );
bool ret = false;
std::lock_guard<std::mutex> lock(privateContext->TaskControlMutex);
if (0 == taskDetails.taskID)
{
taskDetails.taskIsPending = false;
taskDetails.taskID = aamp->ScheduleAsyncTask(funcPtr, (void *)this);
// Wait for scheduler response , if failed to create task for wrong state , not to make pending flag as true
if(0 != taskDetails.taskID)
{
taskDetails.taskIsPending = true;
ret = true;
AAMPLOG_INFO("Task '%.50s' was added with ID = %d.", taskDetails.taskName.c_str(), taskDetails.taskID);
}
else
{
AAMPLOG_INFO("Task '%.50s' was not added or already ran.", taskDetails.taskName.c_str());
}
}
else
{
AAMPLOG_WARN("Task '%.50s' was already pending.", taskDetails.taskName.c_str());
}
return ret;
}
/**
* @brief IdleTaskRemove - remove an async task in a thread safe manner, if it is queued
*/
bool AAMPGstPlayer::IdleTaskRemove(TaskControlData& taskDetails)
{
FN_TRACE( __FUNCTION__ );
bool ret = false;
std::lock_guard<std::mutex> lock(privateContext->TaskControlMutex);
if (0 != taskDetails.taskID)
{
AAMPLOG_INFO("AAMPGstPlayer: Remove task <%.50s> with ID %d", taskDetails.taskName.c_str(), taskDetails.taskID);
aamp->RemoveAsyncTask(taskDetails.taskID);
taskDetails.taskID = 0;
ret = true;
}
else
{
AAMPLOG_TRACE("AAMPGstPlayer: Task already removed <%.50s>, with ID %d", taskDetails.taskName.c_str(), taskDetails.taskID);
}
taskDetails.taskIsPending = false;
return ret;
}
/**
* @brief IdleTaskClearFlags - clear async task id and pending flag in a thread safe manner
* e.g. called when the task executes
*/
void AAMPGstPlayer::IdleTaskClearFlags(TaskControlData& taskDetails)
{
FN_TRACE( __FUNCTION__ );
std::lock_guard<std::mutex> lock(privateContext->TaskControlMutex);
if ( 0 != taskDetails.taskID )
{
AAMPLOG_INFO("AAMPGstPlayer: Clear task control flags <%.50s> with ID %d", taskDetails.taskName.c_str(), taskDetails.taskID);
}
else
{
AAMPLOG_TRACE("AAMPGstPlayer: Task control flags were already cleared <%.50s> with ID %d", taskDetails.taskName.c_str(), taskDetails.taskID);
}
taskDetails.taskIsPending = false;
taskDetails.taskID = 0;
}
/**
* @brief TimerAdd - add a new glib timer in thread safe manner
*/
void AAMPGstPlayer::TimerAdd(GSourceFunc funcPtr, int repeatTimeout, guint& taskId, gpointer user_data, const char* timerName)
{
FN_TRACE( __FUNCTION__ );
std::lock_guard<std::mutex> lock(privateContext->TaskControlMutex);
if (funcPtr && user_data)
{
if (0 == taskId)
{
/* Sets the function pointed by functPtr to be called at regular intervals of repeatTimeout, supplying user_data to the function */
taskId = g_timeout_add(repeatTimeout, funcPtr, user_data);
AAMPLOG_INFO("AAMPGstPlayer: Added timer '%.50s', %d", (nullptr!=timerName) ? timerName : "unknown" , taskId);
}
else
{
AAMPLOG_INFO("AAMPGstPlayer: Timer '%.50s' already added, taskId=%d", (nullptr!=timerName) ? timerName : "unknown", taskId);
}
}
else
{
AAMPLOG_ERR("Bad pointer. funcPtr = %p, user_data=%p");
}
}
/**
* @brief TimerRemove - remove a glib timer in thread safe manner, if it exists
*/
void AAMPGstPlayer::TimerRemove(guint& taskId, const char* timerName)
{
FN_TRACE( __FUNCTION__ );
std::lock_guard<std::mutex> lock(privateContext->TaskControlMutex);
if ( 0 != taskId )
{
AAMPLOG_INFO("AAMPGstPlayer: Remove timer '%.50s', %d", (nullptr!=timerName) ? timerName : "unknown", taskId);
g_source_remove(taskId); /* Removes the source as per the taskId */
taskId = 0;
}
else
{
AAMPLOG_TRACE("Timer '%.50s' with taskId = %d already removed.", (nullptr!=timerName) ? timerName : "unknown", taskId);
}
}
/**
* @brief TimerIsRunning - Check whether timer is currently running
*/
bool AAMPGstPlayer::TimerIsRunning(guint& taskId)
{
FN_TRACE( __FUNCTION__ );
std::lock_guard<std::mutex> lock(privateContext->TaskControlMutex);
return (AAMP_TASK_ID_INVALID != taskId);
}
/**
* @brief Analyze stream info from the GstPipeline
* @param[in] _this pointer to AAMPGstPlayer instance
*/
static void analyze_streams(AAMPGstPlayer *_this)
{
FN_TRACE( __FUNCTION__ );
#ifdef SUPPORT_MULTI_AUDIO
GstElement *sinkbin = _this->privateContext->stream[eMEDIATYPE_VIDEO].sinkbin;
g_object_get(sinkbin, "n-audio", &_this->privateContext->n_audio, NULL);
g_print("audio:\n");
for (gint i = 0; i < _this->privateContext->n_audio; i++)
{
GstTagList *tags = NULL;
g_signal_emit_by_name(sinkbin, "get-audio-tags", i, &tags);
if (tags)
{
gchar *str;
guint rate;
g_print("audio stream %d:\n", i);
if (gst_tag_list_get_string(tags, GST_TAG_AUDIO_CODEC, &str)) {
g_print(" codec: %s\n", str);
g_free(str);
}
if (gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &str)) {
g_print(" language: %s\n", str);
g_free(str);
}
if (gst_tag_list_get_uint(tags, GST_TAG_BITRATE, &rate)) {
g_print(" bitrate: %d\n", rate);
}
gst_tag_list_free(tags);
}
}
g_object_get(sinkbin, "current-audio", &_this->privateContext->current_audio, NULL);
#endif
}
/**
* @brief Callback for appsrc "need-data" signal
* @param[in] source pointer to appsrc instance triggering "need-data" signal
* @param[in] size size of data required
* @param[in] _this pointer to AAMPGstPlayer instance associated with the playback
*/
static void need_data(GstElement *source, guint size, AAMPGstPlayer * _this)
{
if (source == _this->privateContext->stream[eMEDIATYPE_SUBTITLE].source)
{
_this->aamp->ResumeTrackDownloads(eMEDIATYPE_SUBTITLE); // signal fragment downloader thread
}
else if (source == _this->privateContext->stream[eMEDIATYPE_AUDIO].source)
{
_this->aamp->ResumeTrackDownloads(eMEDIATYPE_AUDIO); // signal fragment downloader thread
}
else if (source == _this->privateContext->stream[eMEDIATYPE_AUX_AUDIO].source)
{
_this->aamp->ResumeTrackDownloads(eMEDIATYPE_AUX_AUDIO); // signal fragment downloader thread
}
else
{
_this->aamp->ResumeTrackDownloads(eMEDIATYPE_VIDEO); // signal fragment downloader thread
}
}
/**
* @brief Callback for appsrc "enough-data" signal
* @param[in] source pointer to appsrc instance triggering "enough-data" signal
* @param[in] _this pointer to AAMPGstPlayer instance associated with the playback
*/
static void enough_data(GstElement *source, AAMPGstPlayer * _this)
{
if (_this->aamp->DownloadsAreEnabled()) // avoid processing enough data if the downloads are already disabled.
{
if (source == _this->privateContext->stream[eMEDIATYPE_SUBTITLE].source)
{
_this->aamp->StopTrackDownloads(eMEDIATYPE_SUBTITLE); // signal fragment downloader thread
}
else if (source == _this->privateContext->stream[eMEDIATYPE_AUDIO].source)
{
_this->aamp->StopTrackDownloads(eMEDIATYPE_AUDIO); // signal fragment downloader thread
}
else if (source == _this->privateContext->stream[eMEDIATYPE_AUX_AUDIO].source)
{
_this->aamp->StopTrackDownloads(eMEDIATYPE_AUX_AUDIO); // signal fragment downloader thread
}
else
{
_this->aamp->StopTrackDownloads(eMEDIATYPE_VIDEO); // signal fragment downloader thread
}
}
}
/**
* @brief Callback for appsrc "seek-data" signal
* @param[in] src pointer to appsrc instance triggering "seek-data" signal
* @param[in] offset seek position offset
* @param[in] _this pointer to AAMPGstPlayer instance associated with the playback
*/
static gboolean appsrc_seek(GstAppSrc *src, guint64 offset, AAMPGstPlayer * _this)
{
#ifdef TRACE
AAMPLOG_WARN("appsrc %p seek-signal - offset %" G_GUINT64_FORMAT, src, offset);
#endif
return TRUE;
}
/**
* @brief Initialize properties/callback of appsrc
* @param[in] _this pointer to AAMPGstPlayer instance associated with the playback
* @param[in] source pointer to appsrc instance to be initialized
* @param[in] mediaType stream type
*/
static void InitializeSource(AAMPGstPlayer *_this, GObject *source, MediaType mediaType = eMEDIATYPE_VIDEO)
{
media_stream *stream = &_this->privateContext->stream[mediaType];
GstCaps * caps = NULL;
g_signal_connect(source, "need-data", G_CALLBACK(need_data), _this); /* Sets up the call back function for need data event */
g_signal_connect(source, "enough-data", G_CALLBACK(enough_data), _this); /* Sets up the call back function for enough data event */
g_signal_connect(source, "seek-data", G_CALLBACK(appsrc_seek), _this); /* Sets up the call back function for seek data event */
gst_app_src_set_stream_type(GST_APP_SRC(source), GST_APP_STREAM_TYPE_SEEKABLE);
if (eMEDIATYPE_VIDEO == mediaType )
{
int MaxGstVideoBufBytes = 0;
_this->aamp->mConfig->GetConfigValue(eAAMPConfig_GstVideoBufBytes,MaxGstVideoBufBytes);
AAMPLOG_INFO("Setting gst Video buffer max bytes to %d", MaxGstVideoBufBytes);
g_object_set(source, "max-bytes", (guint64)MaxGstVideoBufBytes, NULL); /* Sets the maximum video buffer bytes as per configuration*/
}
else if (eMEDIATYPE_AUDIO == mediaType || eMEDIATYPE_AUX_AUDIO == mediaType)
{
int MaxGstAudioBufBytes = 0;
_this->aamp->mConfig->GetConfigValue(eAAMPConfig_GstAudioBufBytes,MaxGstAudioBufBytes);
AAMPLOG_INFO("Setting gst Audio buffer max bytes to %d", MaxGstAudioBufBytes);
g_object_set(source, "max-bytes", (guint64)MaxGstAudioBufBytes, NULL); /* Sets the maximum audio buffer bytes as per configuration*/
}
g_object_set(source, "min-percent", 50, NULL); /* Trigger the need data event when the queued bytes fall below 50% */
g_object_set(source, "format", GST_FORMAT_TIME, NULL); /* "format" can be used to perform seek or query/conversion operation*/
/* gstreamer.freedesktop.org recommends to use GST_FORMAT_TIME
'if you don't have a good reason to query for samples/frames' */
caps = GetGstCaps(stream->format);
if (caps != NULL)
{
gst_app_src_set_caps(GST_APP_SRC(source), caps);
gst_caps_unref(caps);
}
else
{
g_object_set(source, "typefind", TRUE, NULL); /* If capabilites can not be established, set typefind TRUE.
typefind determines the media-type of a stream and once type has been
detected it sets its src pad caps to the found media type*/
}
stream->sourceConfigured = true;
}
/**
* @brief Callback when source is added by playbin
* @param[in] object a GstObject
* @param[in] orig the object that originated the signal
* @param[in] pspec the property that changed
* @param[in] _this pointer to AAMPGstPlayer instance associated with the playback
*/
static void found_source(GObject * object, GObject * orig, GParamSpec * pspec, AAMPGstPlayer * _this )
{
MediaType mediaType = eMEDIATYPE_DEFAULT;
if (object == G_OBJECT(_this->privateContext->stream[eMEDIATYPE_VIDEO].sinkbin))
{
AAMPLOG_WARN("Found source for video");
mediaType = eMEDIATYPE_VIDEO;
}
else if (object == G_OBJECT(_this->privateContext->stream[eMEDIATYPE_AUDIO].sinkbin))
{
AAMPLOG_WARN("Found source for audio");
mediaType = eMEDIATYPE_AUDIO;
}
else if (object == G_OBJECT(_this->privateContext->stream[eMEDIATYPE_AUX_AUDIO].sinkbin))
{
AAMPLOG_WARN("Found source for auxiliary audio");
mediaType = eMEDIATYPE_AUX_AUDIO;
}
else if (object == G_OBJECT(_this->privateContext->stream[eMEDIATYPE_SUBTITLE].sinkbin))
{
AAMPLOG_WARN("Found source for subtitle");
mediaType = eMEDIATYPE_SUBTITLE;
}
else
{
AAMPLOG_WARN("found_source didn't find a valid source");
}
if( mediaType != eMEDIATYPE_DEFAULT)
{
media_stream *stream;
stream = &_this->privateContext->stream[mediaType];
g_object_get(orig, pspec->name, &stream->source, NULL);
InitializeSource(_this, G_OBJECT(stream->source), mediaType);
}
}
/**
* @brief callback when the source has been created
* @param[in] element is the pipeline
* @param[in] source the creation of source triggered this callback
* @param[in] data pointer to data associated with the playback
*/
static void httpsoup_source_setup (GstElement * element, GstElement * source, gpointer data)
{
AAMPGstPlayer * _this = (AAMPGstPlayer *)data;
if (!strcmp(GST_ELEMENT_NAME(source), "source"))
{
std::string networkProxyValue = _this->aamp->GetNetworkProxy(); /* Get the proxy network setting from configuration*/
if(!networkProxyValue.empty())
{
g_object_set(source, "proxy", networkProxyValue.c_str(), NULL);
AAMPLOG_WARN("httpsoup -> Set network proxy '%s'", networkProxyValue.c_str());
}
}
}
/**
* @brief Idle callback to notify first frame rendered event
* @param[in] user_data pointer to AAMPGstPlayer instance
* @retval G_SOURCE_REMOVE, if the source should be removed
*/
static gboolean IdleCallbackOnFirstFrame(gpointer user_data)
{
AAMPGstPlayer *_this = (AAMPGstPlayer *)user_data;
if (_this)
{
_this->aamp->NotifyFirstFrameReceived();
_this->privateContext->firstFrameCallbackIdleTaskId = AAMP_TASK_ID_INVALID;
_this->privateContext->firstFrameCallbackIdleTaskPending = false;
}
return G_SOURCE_REMOVE;
}
/**
* @brief Idle callback to notify end-of-stream event
* @param[in] user_data pointer to AAMPGstPlayer instance
* @retval G_SOURCE_REMOVE, if the source should be removed
*/
static gboolean IdleCallbackOnEOS(gpointer user_data)
{
AAMPGstPlayer *_this = (AAMPGstPlayer *)user_data;
if (_this)
{
AAMPLOG_WARN("eosCallbackIdleTaskId %d", _this->privateContext->eosCallbackIdleTaskId);
_this->aamp->NotifyEOSReached();
_this->privateContext->eosCallbackIdleTaskId = AAMP_TASK_ID_INVALID;
_this->privateContext->eosCallbackIdleTaskPending = false;
}
return G_SOURCE_REMOVE;
}
/**
* @brief Timer's callback to notify playback progress event
* @param[in] user_data pointer to AAMPGstPlayer instance
* @retval G_SOURCE_CONTINUE, this function to be called periodically
*/
static gboolean ProgressCallbackOnTimeout(gpointer user_data)
{
AAMPGstPlayer *_this = (AAMPGstPlayer *)user_data;
if (_this)
{
_this->aamp->ReportProgress();
AAMPLOG_TRACE("current %d, stored %d ", g_source_get_id(g_main_current_source()), _this->privateContext->periodicProgressCallbackIdleTaskId);
}
return G_SOURCE_CONTINUE;
}
/**
* @brief Idle callback to start progress notifier timer
* @param[in] user_data pointer to AAMPGstPlayer instance
* @retval G_SOURCE_REMOVE, if the source should be removed
*/
static gboolean IdleCallback(gpointer user_data)
{
AAMPGstPlayer *_this = (AAMPGstPlayer *)user_data;
if (_this)
{
// mAsyncTuneEnabled passed, because this could be called from Scheduler or main loop
_this->aamp->ReportProgress();
_this->IdleTaskClearFlags(_this->privateContext->firstProgressCallbackIdleTask);
if ( !(_this->TimerIsRunning(_this->privateContext->periodicProgressCallbackIdleTaskId)) )
{
double reportProgressInterval;
_this->aamp->mConfig->GetConfigValue(eAAMPConfig_ReportProgressInterval,reportProgressInterval);
reportProgressInterval *= 1000; //convert s to ms
GSourceFunc timerFunc = ProgressCallbackOnTimeout;
_this->TimerAdd(timerFunc, (int)reportProgressInterval, _this->privateContext->periodicProgressCallbackIdleTaskId, user_data, "periodicProgressCallbackIdleTask");
AAMPLOG_WARN("current %d, periodicProgressCallbackIdleTaskId %d", g_source_get_id(g_main_current_source()), _this->privateContext->periodicProgressCallbackIdleTaskId);
}
else
{
AAMPLOG_INFO("Progress callback already available: periodicProgressCallbackIdleTaskId %d", _this->privateContext->periodicProgressCallbackIdleTaskId);
}
}
return G_SOURCE_REMOVE;
}
/**
* @brief Idle callback to notify first video frame was displayed
* @param[in] user_data pointer to AAMPGstPlayer instance
* @retval G_SOURCE_REMOVE, if the source should be removed
*/
static gboolean IdleCallbackFirstVideoFrameDisplayed(gpointer user_data)
{
AAMPGstPlayer *_this = (AAMPGstPlayer *)user_data;
if (_this)
{
_this->aamp->NotifyFirstVideoFrameDisplayed();
_this->privateContext->firstVideoFrameDisplayedCallbackIdleTaskPending = false;
_this->privateContext->firstVideoFrameDisplayedCallbackIdleTaskId = AAMP_TASK_ID_INVALID;
}
return G_SOURCE_REMOVE;
}
/**
* @brief Notify first Audio and Video frame through an idle function to make the playersinkbin halding same as normal(playbin) playback.
*/
void AAMPGstPlayer::NotifyFirstFrame(MediaType type)
{
FN_TRACE( __FUNCTION__ );
// RDK-34481 :LogTuneComplete will be noticed after getting video first frame.
// incase of audio or video only playback NumberofTracks =1, so in that case also LogTuneCompleted needs to captured when either audio/video frame received.
if (!privateContext->firstFrameReceived && (privateContext->firstVideoFrameReceived
|| (1 == privateContext->NumberOfTracks && (privateContext->firstAudioFrameReceived || privateContext->firstVideoFrameReceived))))
{
privateContext->firstFrameReceived = true;
aamp->LogFirstFrame();
aamp->LogTuneComplete();
aamp->NotifyFirstBufferProcessed();
}
if (eMEDIATYPE_VIDEO == type)
{
AAMPLOG_WARN("AAMPGstPlayer_OnFirstVideoFrameCallback. got First Video Frame");
// DELIA-42262: No additional checks added here, since the NotifyFirstFrame will be invoked only once
// in westerossink disabled case until BCOM fixes it. Also aware of NotifyFirstBufferProcessed called
// twice in this function, since it updates timestamp for calculating time elapsed, its trivial
aamp->NotifyFirstBufferProcessed();
if (!privateContext->decoderHandleNotified)
{
privateContext->decoderHandleNotified = true;
privateContext->firstFrameCallbackIdleTaskPending = false;
privateContext->firstFrameCallbackIdleTaskId = aamp->ScheduleAsyncTask(IdleCallbackOnFirstFrame, (void *)this, "FirstFrameCallback");
// Wait for scheduler response , if failed to create task for wrong state , not to make pending flag as true
if(privateContext->firstFrameCallbackIdleTaskId != AAMP_TASK_ID_INVALID)
{
privateContext->firstFrameCallbackIdleTaskPending = true;
}
}
else if (PipelineSetToReady)
{
//If pipeline is set to ready forcefully due to change in track_id, then re-initialize CC
aamp->InitializeCC();
}
IdleTaskAdd(privateContext->firstProgressCallbackIdleTask, IdleCallback);
if ( (!privateContext->firstVideoFrameDisplayedCallbackIdleTaskPending)
&& (aamp->IsFirstVideoFrameDisplayedRequired()) )
{
privateContext->firstVideoFrameDisplayedCallbackIdleTaskPending = false;
privateContext->firstVideoFrameDisplayedCallbackIdleTaskId =
aamp->ScheduleAsyncTask(IdleCallbackFirstVideoFrameDisplayed, (void *)this, "FirstVideoFrameDisplayedCallback");
if(privateContext->firstVideoFrameDisplayedCallbackIdleTaskId != AAMP_TASK_ID_INVALID)
{
privateContext->firstVideoFrameDisplayedCallbackIdleTaskPending = true;
}
}
PipelineSetToReady = false;
}
else if (eMEDIATYPE_AUDIO == type)
{
AAMPLOG_WARN("AAMPGstPlayer_OnAudioFirstFrameAudDecoder. got First Audio Frame");
if (aamp->mAudioOnlyPb)
{
if (!privateContext->decoderHandleNotified)
{
privateContext->decoderHandleNotified = true;
privateContext->firstFrameCallbackIdleTaskPending = false;
privateContext->firstFrameCallbackIdleTaskId = aamp->ScheduleAsyncTask(IdleCallbackOnFirstFrame, (void *)this, "FirstFrameCallback");
// Wait for scheduler response , if failed to create task for wrong state , not to make pending flag as true
if(privateContext->firstFrameCallbackIdleTaskId != AAMP_TASK_ID_INVALID)
{
privateContext->firstFrameCallbackIdleTaskPending = true;
}
}
IdleTaskAdd(privateContext->firstProgressCallbackIdleTask, IdleCallback);
}
}
}
/**
* @brief Callback invoked after first video frame decoded
* @param[in] object pointer to element raising the callback
* @param[in] arg0 number of arguments
* @param[in] arg1 array of arguments
* @param[in] _this pointer to AAMPGstPlayer instance
*/
static void AAMPGstPlayer_OnFirstVideoFrameCallback(GstElement* object, guint arg0, gpointer arg1,
AAMPGstPlayer * _this)
{
_this->privateContext->firstVideoFrameReceived = true;
_this->NotifyFirstFrame(eMEDIATYPE_VIDEO);
}
/**
* @brief Callback invoked after receiving the SEI Time Code information
* @param[in] object pointer to element raising the callback
* @param[in] hours Hour value of the SEI Timecode
* @param[in] minutes Minute value of the SEI Timecode
* @param[in] seconds Second value of the SEI Timecode
* @param[in] user_data pointer to AAMPGstPlayer instance
*/
static void AAMPGstPlayer_redButtonCallback(GstElement* object, guint hours, guint minutes, guint seconds, gpointer user_data)
{
AAMPGstPlayer *_this = (AAMPGstPlayer *)user_data;
if (_this)
{
char buffer[16];
snprintf(buffer,16,"%d:%d:%d",hours,minutes,seconds);
_this->aamp->seiTimecode.assign(buffer);
}
}
/**
* @brief Callback invoked after first audio buffer decoded
* @param[in] object pointer to element raising the callback
* @param[in] arg0 number of arguments
* @param[in] arg1 array of arguments
* @param[in] _this pointer to AAMPGstPlayer instance
*/
static void AAMPGstPlayer_OnAudioFirstFrameAudDecoder(GstElement* object, guint arg0, gpointer arg1,
AAMPGstPlayer * _this)
{
_this->privateContext->firstAudioFrameReceived = true;
_this->NotifyFirstFrame(eMEDIATYPE_AUDIO);
}
/**
* @brief Check if gstreamer element is video decoder
* @param[in] name Name of the element
* @param[in] _this pointer to AAMPGstPlayer instance
* @retval TRUE if element name is that of the decoder
*/
bool AAMPGstPlayer_isVideoDecoder(const char* name, AAMPGstPlayer * _this)
{
#if defined (REALTEKCE)
return (aamp_StartsWith(name, "omxwmvdec") || aamp_StartsWith(name, "omxh26")
|| aamp_StartsWith(name, "omxav1dec") || aamp_StartsWith(name, "omxvp") || aamp_StartsWith(name, "omxmpeg"));
#else
return (_this->privateContext->using_westerossink ? aamp_StartsWith(name, "westerossink"): aamp_StartsWith(name, "brcmvideodecoder"));
#endif
}
/**
* @brief Check if gstreamer element is video sink
* @param[in] name Name of the element
* @param[in] _this pointer to AAMPGstPlayer instance
* @retval TRUE if element name is that of video sink
*/
bool AAMPGstPlayer_isVideoSink(const char* name, AAMPGstPlayer * _this)
{
#if defined (REALTEKCE)
return (aamp_StartsWith(name, "westerossink") || aamp_StartsWith(name, "rtkv1sink"));
#else
return (!_this->privateContext->using_westerossink && aamp_StartsWith(name, "brcmvideosink") == true) || // brcmvideosink0, brcmvideosink1, ...
( _this->privateContext->using_westerossink && aamp_StartsWith(name, "westerossink") == true);
#endif
}
/**
* @brief Check if gstreamer element is audio sink or audio decoder
* @param[in] name Name of the element
* @param[in] _this pointer to AAMPGstPlayer instance
* @retval TRUE if element name is that of audio sink or audio decoder
*/