RDK Documentation (Open Sourced RDK Components)
jseventlistener.cpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2018 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21  * @file jseventlistener.cpp
22  * @brief Event Listner impl for PrivAAMPStruct_JS object
23  */
24 
25 
26 #include "jseventlistener.h"
27 #include "jsevent.h"
28 #include "jsutils.h"
29 #include "vttCue.h"
30 
31 
32 /**
33  * @class AAMP_Listener_PlaybackStateChanged
34  * @brief Event listener impl for AAMP_EVENT_STATE_CHANGED event.
35  */
37 {
38 public:
39  /**
40  * @brief AAMP_Listener_PlaybackStateChanged Constructor
41  * @param[in] obj aamp instance of PrivAAMPStruct_JS
42  * @param[in] type event type
43  * @param[in] jsCallback callback to be registered as listener
44  */
46  : AAMP_JSEventListener(obj, type, jsCallback)
47  {
48  }
49 
50  /**
51  * @brief Set properties to JS event object
52  * @param[in] ev AAMP event object
53  * @param[out] jsEventObj JS event object
54  */
55  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
56  {
57  StateChangedEventPtr evt = std::dynamic_pointer_cast<StateChangedEvent>(ev);
58 
59  JSStringRef prop;
60 
61  prop = JSStringCreateWithUTF8CString("state");
62  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getState()), kJSPropertyAttributeReadOnly, NULL);
63  JSStringRelease(prop);
64  }
65 
66 };
67 
68 
69 /**
70  * @class AAMP_Listener_ProgressUpdate
71  * @brief Event listener impl for AAMP_EVENT_PROGRESS event.
72  */
74 {
75 public:
76  /**
77  * @brief AAMP_Listener_ProgressUpdate Constructor
78  * @param[in] obj aamp instance of PrivAAMPStruct_JS
79  * @param[in] type event type
80  * @param[in] jsCallback callback to be registered as listener
81  */
82  AAMP_Listener_ProgressUpdate(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
83  : AAMP_JSEventListener(obj, type, jsCallback)
84  {
85  }
86 
87  /**
88  * @brief Set properties to JS event object
89  * @param[in] ev AAMP event object
90  * @param[out] jsEventObj JS event object
91  */
92  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
93  {
94  ProgressEventPtr evt = std::dynamic_pointer_cast<ProgressEvent>(ev);
95 
96  JSStringRef prop;
97 
98  prop = JSStringCreateWithUTF8CString("durationMiliseconds");
99  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getDuration()), kJSPropertyAttributeReadOnly, NULL);
100  JSStringRelease(prop);
101 
102  prop = JSStringCreateWithUTF8CString("positionMiliseconds");
103  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
104  JSStringRelease(prop);
105 
106  prop = JSStringCreateWithUTF8CString("playbackSpeed");
107  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getSpeed()), kJSPropertyAttributeReadOnly, NULL);
108  JSStringRelease(prop);
109 
110  prop = JSStringCreateWithUTF8CString("startMiliseconds");
111  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getStart()), kJSPropertyAttributeReadOnly, NULL);
112  JSStringRelease(prop);
113 
114  prop = JSStringCreateWithUTF8CString("endMiliseconds");
115  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getEnd()), kJSPropertyAttributeReadOnly, NULL);
116  JSStringRelease(prop);
117 
118  prop = JSStringCreateWithUTF8CString("currentPTS");
119  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getPTS()), kJSPropertyAttributeReadOnly, NULL);
120  JSStringRelease(prop);
121 
122  prop = JSStringCreateWithUTF8CString("videoBufferedMiliseconds");
123  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getBufferedDuration()), kJSPropertyAttributeReadOnly, NULL);
124  JSStringRelease(prop);
125 
126  prop = JSStringCreateWithUTF8CString("timecode");
127  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getSEITimeCode()), kJSPropertyAttributeReadOnly, NULL);
128  JSStringRelease(prop);
129  }
130 };
131 
132 
133 /**
134  * @class AAMP_Listener_SpeedChanged
135  * @brief Event listener impl for AAMP_EVENT_SPEED_CHANGED event.
136  */
138 {
139 public:
140  /**
141  * @brief AAMP_Listener_SpeedChanged Constructor
142  * @param[in] obj aamp instance of PrivAAMPStruct_JS
143  * @param[in] type event type
144  * @param[in] jsCallback callback to be registered as listener
145  */
146  AAMP_Listener_SpeedChanged(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
147  : AAMP_JSEventListener(obj, type, jsCallback)
148  {
149  }
150 
151  /**
152  * @brief Set properties to JS event object
153  * @param[in] ev AAMP event object
154  * @param[out] jsEventObj JS event object
155  */
156  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
157  {
158  SpeedChangedEventPtr evt = std::dynamic_pointer_cast<SpeedChangedEvent>(ev);
159 
160  JSStringRef prop;
161 
162  prop = JSStringCreateWithUTF8CString("speed");
163  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getRate()), kJSPropertyAttributeReadOnly, NULL);
164  JSStringRelease(prop);
165 
166  prop = JSStringCreateWithUTF8CString("reason");
167  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, "unknown"), kJSPropertyAttributeReadOnly, NULL);
168  JSStringRelease(prop);
169  }
170 };
171 
172 
173 /**
174  * @class AAMP_Listener_BufferingChanged
175  * @brief Event listener impl for AAMP_EVENT_BUFFERING_CHANGED event.
176  */
178 {
179 public:
180  /**
181  * @brief AAMP_Listener_BufferingChanged Constructor
182  * @param[in] obj aamp instance of PrivAAMPStruct_JS
183  * @param[in] type event type
184  * @param[in] jsCallback callback to be registered as listener
185  */
187  : AAMP_JSEventListener(obj, type, jsCallback)
188  {
189  }
190 
191  /**
192  * @brief Set properties to JS event object
193  * @param[in] ev AAMP event object
194  * @param[out] jsEventObj JS event object
195  */
196  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
197  {
198  BufferingChangedEventPtr evt = std::dynamic_pointer_cast<BufferingChangedEvent>(ev);
199 
200  JSStringRef prop;
201 
202  prop = JSStringCreateWithUTF8CString("buffering");
203  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(p_obj->_ctx, evt->buffering()), kJSPropertyAttributeReadOnly, NULL);
204  JSStringRelease(prop);
205  }
206 };
207 
208 
209 /**
210  * @class AAMP_Listener_PlaybackFailed
211  * @brief Event listener impl for AAMP_EVENT_TUNE_FAILED event.
212  */
214 {
215 public:
216  /**
217  * @brief AAMP_Listener_PlaybackFailed Constructor
218  * @param[in] obj aamp instance of PrivAAMPStruct_JS
219  * @param[in] type event type
220  * @param[in] jsCallback callback to be registered as listener
221  */
223  : AAMP_JSEventListener(obj, type, jsCallback)
224  {
225  }
226 
227  /**
228  * @brief Set properties to JS event object
229  * @param[in] ev AAMP event object
230  * @param[out] jsEventObj JS event object
231  */
232  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
233  {
234  MediaErrorEventPtr evt = std::dynamic_pointer_cast<MediaErrorEvent>(ev);
235 
236  JSStringRef prop;
237 
238  prop = JSStringCreateWithUTF8CString("code");
239  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getCode()), kJSPropertyAttributeReadOnly, NULL);
240  JSStringRelease(prop);
241 
242  prop = JSStringCreateWithUTF8CString("description");
243  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getDescription().c_str()), kJSPropertyAttributeReadOnly, NULL);
244  JSStringRelease(prop);
245 
246  prop = JSStringCreateWithUTF8CString("shouldRetry");
247  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(p_obj->_ctx, evt->shouldRetry()), kJSPropertyAttributeReadOnly, NULL);
248  JSStringRelease(prop);
249 
250  if(-1 != evt->getClass()) //Only send verbose error for secclient/secmanager DRM failures
251  {
252  prop = JSStringCreateWithUTF8CString("class");
253  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getClass()), kJSPropertyAttributeReadOnly, NULL);
254  JSStringRelease(prop);
255 
256  prop = JSStringCreateWithUTF8CString("reason");
257  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getReason()), kJSPropertyAttributeReadOnly, NULL);
258  JSStringRelease(prop);
259 
260  prop = JSStringCreateWithUTF8CString("businessStatus");
261  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getBusinessStatus()), kJSPropertyAttributeReadOnly, NULL);
262  JSStringRelease(prop);
263  }
264  }
265 };
266 
267 
268 /**
269  * @class AAMP_Listener_MediaMetadata
270  * @brief Event listener impl for AAMP_EVENT_MEDIA_METADATA event.
271  */
273 {
274 public:
275  /**
276  * @brief AAMP_Listener_MediaMetadata Constructor
277  * @param[in] obj aamp instance of PrivAAMPStruct_JS
278  * @param[in] type event type
279  * @param[in] jsCallback callback to be registered as listener
280  */
281  AAMP_Listener_MediaMetadata(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
282  : AAMP_JSEventListener(obj, type, jsCallback)
283  {
284  }
285 
286  /**
287  * @brief Set properties to JS event object
288  * @param[in] ev AAMP event object
289  * @param[out] jsEventObj JS event object
290  */
291  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
292  {
293  MediaMetadataEventPtr evt = std::dynamic_pointer_cast<MediaMetadataEvent>(ev);
294 
295  JSStringRef prop;
296  prop = JSStringCreateWithUTF8CString("durationMiliseconds");
297  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getDuration()), kJSPropertyAttributeReadOnly, NULL);
298  JSStringRelease(prop);
299 
300  int count = evt->getLanguagesCount();
301  const std::vector<std::string> &langVect = evt->getLanguages();
302  JSValueRef* array = new JSValueRef[count];
303  for (int32_t i = 0; i < count; i++)
304  {
305  JSValueRef lang = aamp_CStringToJSValue(p_obj->_ctx, langVect[i].c_str());
306  array[i] = lang;
307  }
308  JSValueRef propValue = JSObjectMakeArray(p_obj->_ctx, count, array, NULL);
309  SAFE_DELETE_ARRAY(array);
310 
311  prop = JSStringCreateWithUTF8CString("languages");
312  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, propValue, kJSPropertyAttributeReadOnly, NULL);
313  JSStringRelease(prop);
314 
315  count = evt->getBitratesCount();
316  const std::vector<long> &bitrateVect = evt->getBitrates();
317  array = new JSValueRef[count];
318  for (int32_t i = 0; i < count; i++)
319  {
320  array[i] = JSValueMakeNumber(p_obj->_ctx, bitrateVect[i]);
321  }
322  propValue = JSObjectMakeArray(p_obj->_ctx, count, array, NULL);
323  SAFE_DELETE_ARRAY(array);
324 
325  prop = JSStringCreateWithUTF8CString("bitrates");
326  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, propValue, kJSPropertyAttributeReadOnly, NULL);
327  JSStringRelease(prop);
328 
329  count = evt->getSupportedSpeedCount();
330  const std::vector<float> &speedVect = evt->getSupportedSpeeds();
331  array = new JSValueRef[count];
332  for (int32_t i = 0; i < count; i++)
333  {
334  array[i] = JSValueMakeNumber(p_obj->_ctx, speedVect[i]);
335  }
336  propValue = JSObjectMakeArray(p_obj->_ctx, count, array, NULL);
337  SAFE_DELETE_ARRAY(array);
338 
339  prop = JSStringCreateWithUTF8CString("playbackSpeeds");
340  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, propValue, kJSPropertyAttributeReadOnly, NULL);
341  JSStringRelease(prop);
342 
343  prop = JSStringCreateWithUTF8CString("programStartTime");
344  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getProgramStartTime()), kJSPropertyAttributeReadOnly, NULL);
345  JSStringRelease(prop);
346 
347  prop = JSStringCreateWithUTF8CString("width");
348  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getWidth()), kJSPropertyAttributeReadOnly, NULL);
349  JSStringRelease(prop);
350 
351  prop = JSStringCreateWithUTF8CString("height");
352  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getHeight()), kJSPropertyAttributeReadOnly, NULL);
353  JSStringRelease(prop);
354 
355  prop = JSStringCreateWithUTF8CString("hasDrm");
356  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(p_obj->_ctx, evt->hasDrm()), kJSPropertyAttributeReadOnly, NULL);
357  JSStringRelease(prop);
358 
359  prop = JSStringCreateWithUTF8CString("isLive");
360  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(p_obj->_ctx, evt->isLive()), kJSPropertyAttributeReadOnly, NULL);
361  JSStringRelease(prop);
362 
363  prop = JSStringCreateWithUTF8CString("DRM");
364  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getDrmType().c_str()), kJSPropertyAttributeReadOnly, NULL);
365  JSStringRelease(prop);
366 
367  //ratings
368  if(!evt->getRatings().empty())
369  {
370  prop = JSStringCreateWithUTF8CString("ratings");
371  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getRatings().c_str()), kJSPropertyAttributeReadOnly, NULL);
372  JSStringRelease(prop);
373  }
374 
375  //ssi
376  if(evt->getSsi() >= 0 )
377  {
378  prop = JSStringCreateWithUTF8CString("ssi");
379  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getSsi()), kJSPropertyAttributeReadOnly, NULL);
380  JSStringRelease(prop);
381  }
382 
383  //framerate
384  if(evt->getFrameRate() > 0 )
385  {
386  prop = JSStringCreateWithUTF8CString("framerate");
387  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getFrameRate()), kJSPropertyAttributeReadOnly, NULL);
388  JSStringRelease(prop);
389  }
390 
391  if(eVIDEOSCAN_UNKNOWN != evt->getVideoScanType())
392  {
393  prop = JSStringCreateWithUTF8CString("progressive");
394  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(p_obj->_ctx, ((eVIDEOSCAN_PROGRESSIVE == evt->getVideoScanType())?true:false)), kJSPropertyAttributeReadOnly, NULL);
395  JSStringRelease(prop);
396  }
397  //aspect ratio
398  if((0 != evt->getAspectRatioWidth()) && (0 != evt->getAspectRatioHeight()))
399  {
400  prop = JSStringCreateWithUTF8CString("aspectRatioWidth");
401  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getAspectRatioWidth()), kJSPropertyAttributeReadOnly, NULL);
402  JSStringRelease(prop);
403 
404  prop = JSStringCreateWithUTF8CString("aspectRatioHeight");
405  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getAspectRatioHeight()), kJSPropertyAttributeReadOnly, NULL);
406  JSStringRelease(prop);
407  }
408 
409  //VideoCodec
410  if(!evt->getVideoCodec().empty())
411  {
412  prop = JSStringCreateWithUTF8CString("videoCodec");
413  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getVideoCodec().c_str()), kJSPropertyAttributeReadOnly, NULL);
414  JSStringRelease(prop);
415  }
416 
417  //HdrType
418  if(!evt->getHdrType().empty())
419  {
420  prop = JSStringCreateWithUTF8CString("hdrType");
421  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getHdrType().c_str()), kJSPropertyAttributeReadOnly, NULL);
422  JSStringRelease(prop);
423  }
424 
425  //AudioBitrate
426  const std::vector<long> &audioBitrateVect = evt->getAudioBitrates();
427  count = audioBitrateVect.size();
428  if(count > 0 )
429  {
430  array = new JSValueRef[count];
431  for (int32_t i = 0; i < count; i++)
432  {
433  array[i] = JSValueMakeNumber(p_obj->_ctx, audioBitrateVect[i]);
434  }
435  propValue = JSObjectMakeArray(p_obj->_ctx, count, array, NULL);
436  delete [] array;
437 
438  prop = JSStringCreateWithUTF8CString("audioBitrates");
439  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, propValue, kJSPropertyAttributeReadOnly, NULL);
440  JSStringRelease(prop);
441  }
442 
443 
444  //AudioCodec
445  if(!evt->getAudioCodec().empty())
446  {
447  prop = JSStringCreateWithUTF8CString("audioCodec");
448  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getAudioCodec().c_str()), kJSPropertyAttributeReadOnly, NULL);
449  JSStringRelease(prop);
450  }
451 
452  //AudioMixType
453  if(!evt->getAudioMixType().empty())
454  {
455  prop = JSStringCreateWithUTF8CString("audioMixType");
456  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getAudioMixType().c_str()), kJSPropertyAttributeReadOnly, NULL);
457  JSStringRelease(prop);
458  }
459 
460  //AtmosInfo
461  prop = JSStringCreateWithUTF8CString("isAtmos");
462  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(p_obj->_ctx,evt->getAtmosInfo()), kJSPropertyAttributeReadOnly, NULL);
463  JSStringRelease(prop);
464 
465  //MediaFormat type
466  prop = JSStringCreateWithUTF8CString("mediaFormat");
467  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getMediaFormat().c_str()), kJSPropertyAttributeReadOnly, NULL);
468  JSStringRelease(prop);
469 
470  }
471 };
472 
473 
474 /**
475  * @class AAMP_Listener_SpeedsChanged
476  * @brief Event listener impl for AAMP_EVENT_SPEEDS_CHANGED event.
477  */
479 {
480 public:
481  /**
482  * @brief AAMP_Listener_SpeedsChanged Constructor
483  * @param[in] obj aamp instance of PrivAAMPStruct_JS
484  * @param[in] type event type
485  * @param[in] jsCallback callback to be registered as listener
486  */
487  AAMP_Listener_SpeedsChanged(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
488  : AAMP_JSEventListener(obj, type, jsCallback)
489  {
490  }
491 
492  /**
493  * @brief Set properties to JS event object
494  * @param[in] ev AAMP event object
495  * @param[out] jsEventObj JS event object
496  */
497  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
498  {
499  SupportedSpeedsChangedEventPtr evt = std::dynamic_pointer_cast<SupportedSpeedsChangedEvent>(ev);
500 
501  int count = evt->getSupportedSpeedCount();
502  const std::vector<float> &speedVect = evt->getSupportedSpeeds();
503  JSValueRef* array = new JSValueRef[count];
504  for (int32_t i = 0; i < count; i++)
505  {
506  array[i] = JSValueMakeNumber(p_obj->_ctx, speedVect[i]);
507  }
508  JSValueRef propValue = JSObjectMakeArray(p_obj->_ctx, count, array, NULL);
509  SAFE_DELETE_ARRAY(array);
510 
511  JSStringRef prop = JSStringCreateWithUTF8CString("playbackSpeeds");
512  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, propValue, kJSPropertyAttributeReadOnly, NULL);
513  JSStringRelease(prop);
514  }
515 };
516 
517 /**
518  * @class AAMP_Listener_Seeked
519  * @brief Event listener impl for AAMP_EVENT_SEEKED event.
520  */
522 {
523 public:
524  /**
525  * @brief AAMP_Listener_Seeked Constructor
526  * @param[in] obj aamp instance of PrivAAMPStruct_JS
527  * @param[in] type event type
528  * @param[in] jsCallback callback to be registered as listener
529  */
530  AAMP_Listener_Seeked(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
531  : AAMP_JSEventListener(obj, type, jsCallback)
532  {
533  }
534 
535  /**
536  * @brief Set properties to JS event object
537  * @param[in] ev AAMP event object
538  * @param[out] jsEventObj JS event object
539  */
540  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
541  {
542  SeekedEventPtr evt = std::dynamic_pointer_cast<SeekedEvent>(ev);
543  JSStringRef prop = JSStringCreateWithUTF8CString("position");
544  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
545  JSStringRelease(prop);
546  }
547 };
548 
549 
550 /**
551  * @class AAMP_Listener_TuneProfiling
552  * @brief Event listener impl for AAMP_EVENT_TUNE_PROFILING event.
553  */
555 {
556 public:
557  /**
558  * @brief AAMP_Listener_TuneProfiling Constructor
559  * @param[in] obj aamp instance of PrivAAMPStruct_JS
560  * @param[in] type event type
561  * @param[in] jsCallback callback to be registered as listener
562  */
563  AAMP_Listener_TuneProfiling(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
564  : AAMP_JSEventListener(obj, type, jsCallback)
565  {
566  }
567 
568  /**
569  * @brief Set properties to JS event object
570  * @param[in] ev AAMP event object
571  * @param[out] jsEventObj JS event object
572  */
573  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
574  {
575  TuneProfilingEventPtr evt = std::dynamic_pointer_cast<TuneProfilingEvent>(ev);
576  JSStringRef prop;
577  const char* microData = evt->getProfilingData().c_str();
578 
579  LOG_TRACE("AAMP_Listener_TuneProfiling microData %s", microData);
580  prop = JSStringCreateWithUTF8CString("microData");
581  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, microData), kJSPropertyAttributeReadOnly, NULL);
582  JSStringRelease(prop);
583  }
584 
585 };
586 
587 /**
588  * @class AAMP_Listener_CCHandleAvailable
589  * @brief Event listener impl for AAMP_EVENT_CC_HANDLE_RECEIVED, event.
590  */
592 {
593 public:
594  /**
595  * @brief AAMP_Listener_CCHandleAvailable Constructor
596  * @param[in] obj aamp instance of PrivAAMPStruct_JS
597  * @param[in] type event type
598  * @param[in] jsCallback callback to be registered as listener
599  */
601  : AAMP_JSEventListener(obj, type, jsCallback)
602  {
603  }
604 
605  /**
606  * @brief Set properties to JS event object
607  * @param[in] ev AAMP event object
608  * @param[out] jsEventObj JS event object
609  */
610  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
611  {
612  CCHandleEventPtr evt = std::dynamic_pointer_cast<CCHandleEvent>(ev);
613 
614  JSStringRef prop;
615 
616  prop = JSStringCreateWithUTF8CString("decoderHandle");
617  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getCCHandle()), kJSPropertyAttributeReadOnly, NULL);
618  JSStringRelease(prop);
619  }
620 
621 };
622 
623 
624 /**
625  * @class AAMP_Listener_DRMMetadata
626  * @brief Event listener impl for AAMP_EVENT_DRM_METADATA event.
627  */
629 {
630 public:
631  /**
632  * @brief AAMP_Listener_DRMMetadata Constructor
633  * @param[in] obj aamp instance of PrivAAMPStruct_JS
634  * @param[in] type event type
635  * @param[in] jsCallback callback to be registered as listener
636  */
637  AAMP_Listener_DRMMetadata(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
638  : AAMP_JSEventListener(obj, type, jsCallback)
639  {
640  }
641 
642  /**
643  * @brief Set properties to JS event object
644  * @param[in] ev AAMP event object
645  * @param[out] jsEventObj JS event object
646  */
647  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
648  {
649  DrmMetaDataEventPtr evt = std::dynamic_pointer_cast<DrmMetaDataEvent>(ev);
650  JSStringRef prop;
651 
652  int code = evt->getAccessStatusValue();
653  const char* description = evt->getAccessStatus().c_str();
654 
655  LOG_WARN_EX("AAMP_Listener_DRMMetadata code %d Description %s", code, description);
656  prop = JSStringCreateWithUTF8CString("code");
657  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, code), kJSPropertyAttributeReadOnly, NULL);
658  JSStringRelease(prop);
659 
660  prop = JSStringCreateWithUTF8CString("description");
661  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, description), kJSPropertyAttributeReadOnly, NULL);
662  JSStringRelease(prop);
663  }
664 
665 };
666 
667 
668 /**
669  * @class AAMP_Listener_AnomalyReport
670  * @brief Event listener impl for AAMP_EVENT_REPORT_ANOMALY event.
671  */
673 {
674 public:
675  /**
676  * @brief AAMP_Listener_AnomalyReport Constructor
677  * @param[in] obj aamp instance of PrivAAMPStruct_JS
678  * @param[in] type event type
679  * @param[in] jsCallback callback to be registered as listener
680  */
681  AAMP_Listener_AnomalyReport(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
682  : AAMP_JSEventListener(obj, type, jsCallback)
683  {
684  }
685 
686  /**
687  * @brief Set properties to JS event object
688  * @param[in] ev AAMP event object
689  * @param[out] jsEventObj JS event object
690  */
691  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
692  {
693  AnomalyReportEventPtr evt = std::dynamic_pointer_cast<AnomalyReportEvent>(ev);
694  JSStringRef prop;
695 
696  int severity = evt->getSeverity();
697  const char* description = evt->getMessage().c_str();
698 
699  LOG_WARN_EX("AAMP_Listener_AnomalyReport severity %d Description %s", severity, description);
700  prop = JSStringCreateWithUTF8CString("severity");
701  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, severity), kJSPropertyAttributeReadOnly, NULL);
702  JSStringRelease(prop);
703 
704  prop = JSStringCreateWithUTF8CString("description");
705  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, description), kJSPropertyAttributeReadOnly, NULL);
706  JSStringRelease(prop);
707  }
708 
709 };
710 
711 
712 /**
713  * @class AAMP_Listener_VTTCueData
714  * @brief Event listener impl for AAMP_EVENT_WEBVTT_CUE_DATA event.
715  */
717 {
718 public:
719  /**
720  * @brief AAMP_Listener_VTTCueData Constructor
721  * @param[in] obj aamp instance of PrivAAMPStruct_JS
722  * @param[in] type event type
723  * @param[in] jsCallback callback to be registered as listener
724  */
725  AAMP_Listener_VTTCueData(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
726  : AAMP_JSEventListener(obj, type, jsCallback)
727  {
728  }
729 
730  /**
731  * @brief Set properties to JS event object
732  * @param[in] ev AAMP event object
733  * @param[out] jsEventObj JS event object
734  */
735  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
736  {
737  WebVttCueEventPtr evt = std::dynamic_pointer_cast<WebVttCueEvent>(ev);
738 
739  JSStringRef prop;
740  VTTCue *cue = evt->getCueData();
741 
742  prop = JSStringCreateWithUTF8CString("start");
743  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, cue->mStart), kJSPropertyAttributeReadOnly, NULL);
744  JSStringRelease(prop);
745 
746  prop = JSStringCreateWithUTF8CString("duration");
747  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, cue->mDuration), kJSPropertyAttributeReadOnly, NULL);
748  JSStringRelease(prop);
749 
750  prop = JSStringCreateWithUTF8CString("text");
751  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, cue->mText.c_str()), kJSPropertyAttributeReadOnly, NULL);
752  JSStringRelease(prop);
753  }
754 
755 };
756 
757 
758 /**
759  * @class AAMP_Listener_TimedMetadata
760  * @brief Event listener impl for AAMP_EVENT_TIMED_METADATA event.
761  */
763 {
764 public:
765  /**
766  * @brief AAMP_Listener_TimedMetadata Constructor
767  * @param[in] obj aamp instance of PrivAAMPStruct_JS
768  * @param[in] type event type
769  * @param[in] jsCallback callback to be registered as listener
770  */
771  AAMP_Listener_TimedMetadata(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
772  : AAMP_JSEventListener(obj, type, jsCallback)
773  {
774  }
775 
776  /**
777  * @brief Set properties to JS event object
778  * @param[in] ev AAMP event object
779  * @param[out] jsEventObj JS event object
780  */
781  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
782  {
783  TimedMetadataEventPtr evt = std::dynamic_pointer_cast<TimedMetadataEvent>(ev);
784 
785  JSObjectRef timedMetadata = aamp_CreateTimedMetadataJSObject(p_obj->_ctx, evt->getTime(), evt->getName().c_str(), evt->getContent().c_str(), evt->getId().c_str(), evt->getDuration());
786  if (timedMetadata)
787  {
788  JSValueProtect(p_obj->_ctx, timedMetadata);
789  JSStringRef prop = JSStringCreateWithUTF8CString("timedMetadata");
790  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, timedMetadata, kJSPropertyAttributeReadOnly, NULL);
791  JSStringRelease(prop);
792  JSValueUnprotect(p_obj->_ctx, timedMetadata);
793  }
794  }
795 };
796 
797 /**
798  * @class AAMP_Listener_BulkTimedMetadata
799  * @brief Event listener impl for BULK_TIMED_METADATA AAMP event
800  */
802 {
803 public:
804  /**
805  * @brief AAMP_Listener_BulkTimedMetadata Constructor
806  * @param[in] obj aamp instance of PrivAAMPStruct_JS
807  * @param[in] type event type
808  * @param[in] jsCallback callback to be registered as listener
809  */
811  : AAMP_JSEventListener(obj, type, jsCallback)
812  {
813  }
814 
815 
816  /**
817  * @brief Set JS event properties
818  */
819  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef eventObj)
820  {
821  BulkTimedMetadataEventPtr evt = std::dynamic_pointer_cast<BulkTimedMetadataEvent>(ev);
822  JSStringRef name = JSStringCreateWithUTF8CString("timedMetadatas");
823  JSObjectSetProperty(p_obj->_ctx, eventObj, name, aamp_CStringToJSValue(p_obj->_ctx, evt->getContent().c_str()), kJSPropertyAttributeReadOnly, NULL);
824  JSStringRelease(name);
825  }
826 };
827 
828 
829 /**
830  * @class AAMP_Listener_AdResolved
831  *
832  * @brief Event listener impl for AAMP_EVENT_AD_RESOLVED event
833  */
835 {
836 public:
837  /**
838  * @brief AAMP_Listener_AdResolved Constructor
839  * @param[in] obj aamp instance of PrivAAMPStruct_JS
840  * @param[in] type event type
841  * @param[in] jsCallback callback to be registered as listener
842  */
843  AAMP_Listener_AdResolved(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
844  : AAMP_JSEventListener(obj, type, jsCallback)
845  {
846  }
847 
848  /**
849  * @brief Set properties to JS event object
850  * @param[in] ev AAMP event object
851  * @param[out] jsEventObj JS event object
852  */
853  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
854  {
855  AdResolvedEventPtr evt = std::dynamic_pointer_cast<AdResolvedEvent>(ev);
856  JSStringRef prop;
857 
858  prop = JSStringCreateWithUTF8CString("resolvedStatus");
859  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(p_obj->_ctx, evt->getResolveStatus()), kJSPropertyAttributeReadOnly, NULL);
860  JSStringRelease(prop);
861 
862  prop = JSStringCreateWithUTF8CString("placementId");
863  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getAdId().c_str()), kJSPropertyAttributeReadOnly, NULL);
864  JSStringRelease(prop);
865 
866  prop = JSStringCreateWithUTF8CString("placementStartTime");
867  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getStart()), kJSPropertyAttributeReadOnly, NULL);
868  JSStringRelease(prop);
869 
870  prop = JSStringCreateWithUTF8CString("placementDuration");
871  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getDuration()), kJSPropertyAttributeReadOnly, NULL);
872  JSStringRelease(prop);
873  }
874 };
875 
876 
877 /**
878  * @class AAMP_Listener_AdReservationStart
879  *
880  * @brief Event listener impl for AAMP_EVENT_AD_RESERVATION_START event
881  */
883 {
884 public:
885  /**
886  * @brief AAMP_Listener_AdReservationStart Constructor
887  * @param[in] obj aamp instance of PrivAAMPStruct_JS
888  * @param[in] type event type
889  * @param[in] jsCallback callback to be registered as listener
890  */
892  : AAMP_JSEventListener(obj, type, jsCallback)
893  {
894  }
895 
896  /**
897  * @brief Set properties to JS event object
898  * @param[in] ev AAMP event object
899  * @param[out] jsEventObj JS event object
900  */
901  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
902  {
903  AdReservationEventPtr evt = std::dynamic_pointer_cast<AdReservationEvent>(ev);
904  JSStringRef prop;
905 
906  prop = JSStringCreateWithUTF8CString("adbreakId");
907  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getAdBreakId().c_str()), kJSPropertyAttributeReadOnly, NULL);
908  JSStringRelease(prop);
909 
910  prop = JSStringCreateWithUTF8CString("time");
911  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
912  JSStringRelease(prop);
913  }
914 };
915 
916 
917 /**
918  * @class AAMP_Listener_AdReservationEnd
919  *
920  * @brief Event listener impl for AAMP_EVENT_AD_RESERVATION_END event
921  */
923 {
924 public:
925  /**
926  * @brief AAMP_Listener_AdReservationEnd Constructor
927  * @param[in] obj aamp instance of PrivAAMPStruct_JS
928  * @param[in] type event type
929  * @param[in] jsCallback callback to be registered as listener
930  */
932  : AAMP_JSEventListener(obj, type, jsCallback)
933  {
934  }
935 
936  /**
937  * @brief Set properties to JS event object
938  * @param[in] ev AAMP event object
939  * @param[out] jsEventObj JS event object
940  */
941  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
942  {
943  AdReservationEventPtr evt = std::dynamic_pointer_cast<AdReservationEvent>(ev);
944  JSStringRef prop;
945 
946  prop = JSStringCreateWithUTF8CString("adbreakId");
947  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getAdBreakId().c_str()), kJSPropertyAttributeReadOnly, NULL);
948  JSStringRelease(prop);
949 
950  prop = JSStringCreateWithUTF8CString("time");
951  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
952  JSStringRelease(prop);
953  }
954 };
955 
956 
957 /**
958  * @class AAMP_Listener_AdPlacementStart
959  *
960  * @brief Event listener impl for AAMP_EVENT_AD_PLACEMENT_START event
961  */
963 {
964 public:
965  /**
966  * @brief AAMP_Listener_AdPlacementStart Constructor
967  * @param[in] obj aamp instance of PrivAAMPStruct_JS
968  * @param[in] type event type
969  * @param[in] jsCallback callback to be registered as listener
970  */
972  : AAMP_JSEventListener(obj, type, jsCallback)
973  {
974  }
975 
976  /**
977  * @brief Set properties to JS event object
978  * @param[in] ev AAMP event object
979  * @param[out] jsEventObj JS event object
980  */
981  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
982  {
983  AdPlacementEventPtr evt = std::dynamic_pointer_cast<AdPlacementEvent>(ev);
984  JSStringRef prop;
985 
986  prop = JSStringCreateWithUTF8CString("adId");
987  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getAdId().c_str()), kJSPropertyAttributeReadOnly, NULL);
988  JSStringRelease(prop);
989 
990  prop = JSStringCreateWithUTF8CString("time");
991  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
992  JSStringRelease(prop);
993  }
994 };
995 
996 
997 /**
998  * @class AAMP_Listener_AdPlacementEnd
999  *
1000  * @brief Event listener impl for AAMP_EVENT_AD_PLACEMENT_END event
1001  */
1003 {
1004 public:
1005  /**
1006  * @brief AAMP_Listener_AdPlacementEnd Constructor
1007  * @param[in] obj aamp instance of PrivAAMPStruct_JS
1008  * @param[in] type event type
1009  * @param[in] jsCallback callback to be registered as listener
1010  */
1012  : AAMP_JSEventListener(obj, type, jsCallback)
1013  {
1014  }
1015 
1016  /**
1017  * @brief Set properties to JS event object
1018  * @param[in] ev AAMP event object
1019  * @param[out] jsEventObj JS event object
1020  */
1021  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
1022  {
1023  AdPlacementEventPtr evt = std::dynamic_pointer_cast<AdPlacementEvent>(ev);
1024  JSStringRef prop;
1025 
1026  prop = JSStringCreateWithUTF8CString("adId");
1027  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getAdId().c_str()), kJSPropertyAttributeReadOnly, NULL);
1028  JSStringRelease(prop);
1029 
1030  prop = JSStringCreateWithUTF8CString("time");
1031  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
1032  JSStringRelease(prop);
1033  }
1034 };
1035 
1036 
1037 /**
1038  * @class AAMP_Listener_AdProgress
1039  *
1040  * @brief Event listener impl for AAMP_EVENT_AD_PLACEMENT_PROGRESS event
1041  */
1043 {
1044 public:
1045  /**
1046  * @brief AAMP_Listener_AdProgress Constructor
1047  * @param[in] obj aamp instance of PrivAAMPStruct_JS
1048  * @param[in] type event type
1049  * @param[in] jsCallback callback to be registered as listener
1050  */
1051  AAMP_Listener_AdProgress(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
1052  : AAMP_JSEventListener(obj, type, jsCallback)
1053  {
1054  }
1055 
1056  /**
1057  * @brief Set properties to JS event object
1058  * @param[in] ev AAMP event object
1059  * @param[out] jsEventObj JS event object
1060  */
1061  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
1062  {
1063  AdPlacementEventPtr evt = std::dynamic_pointer_cast<AdPlacementEvent>(ev);
1064  JSStringRef prop;
1065 
1066  prop = JSStringCreateWithUTF8CString("adId");
1067  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getAdId().c_str()), kJSPropertyAttributeReadOnly, NULL);
1068  JSStringRelease(prop);
1069 
1070  prop = JSStringCreateWithUTF8CString("time");
1071  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
1072  JSStringRelease(prop);
1073  }
1074 };
1075 
1076 
1077 /**
1078  * @class AAMP_Listener_AdPlacementError
1079  *
1080  * @brief Event listener impl for AAMP_EVENT_AD_PLACEMENT_ERROR event
1081  */
1083 {
1084 public:
1085  /**
1086  * @brief AAMP_Listener_AdPlacementError Constructor
1087  * @param[in] obj aamp instance of PrivAAMPStruct_JS
1088  * @param[in] type event type
1089  * @param[in] jsCallback callback to be registered as listener
1090  */
1092  : AAMP_JSEventListener(obj, type, jsCallback)
1093  {
1094  }
1095 
1096  /**
1097  * @brief Set properties to JS event object
1098  * @param[in] ev AAMP event object
1099  * @param[out] jsEventObj JS event object
1100  */
1101  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
1102  {
1103  AdPlacementEventPtr evt = std::dynamic_pointer_cast<AdPlacementEvent>(ev);
1104  JSStringRef prop;
1105 
1106  prop = JSStringCreateWithUTF8CString("adId");
1107  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getAdId().c_str()), kJSPropertyAttributeReadOnly, NULL);
1108  JSStringRelease(prop);
1109 
1110  prop = JSStringCreateWithUTF8CString("time");
1111  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
1112  JSStringRelease(prop);
1113 
1114  prop = JSStringCreateWithUTF8CString("error");
1115  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getErrorCode()), kJSPropertyAttributeReadOnly, NULL);
1116  JSStringRelease(prop);
1117  }
1118 };
1119 
1120 
1121 /**
1122  * @class AAMP_Listener_BitrateChanged
1123  * @brief Event listener impl for AAMP_EVENT_BITRATE_CHANGED event.
1124  */
1126 {
1127 public:
1128  /**
1129  * @brief AAMP_Listener_BitrateChanged Constructor
1130  * @param[in] obj aamp instance of PrivAAMPStruct_JS
1131  * @param[in] type event type
1132  * @param[in] jsCallback callback to be registered as listener
1133  */
1135  : AAMP_JSEventListener(obj, type, jsCallback)
1136  {
1137  }
1138 
1139  /**
1140  * @brief Set properties to JS event object
1141  * @param[in] ev AAMP event object
1142  * @param[out] jsEventObj JS event object
1143  */
1144  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
1145  {
1146  BitrateChangeEventPtr evt = std::dynamic_pointer_cast<BitrateChangeEvent>(ev);
1147  JSStringRef name;
1148  name = JSStringCreateWithUTF8CString("time");
1149  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(p_obj->_ctx, evt->getTime()), kJSPropertyAttributeReadOnly, NULL);
1150  JSStringRelease(name);
1151 
1152  name = JSStringCreateWithUTF8CString("bitRate");
1153  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(p_obj->_ctx, evt->getBitrate()), kJSPropertyAttributeReadOnly, NULL);
1154  JSStringRelease(name);
1155 
1156  name = JSStringCreateWithUTF8CString("description");
1157  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, aamp_CStringToJSValue(p_obj->_ctx, evt->getDescription().c_str()), kJSPropertyAttributeReadOnly, NULL);
1158  JSStringRelease(name);
1159 
1160  name = JSStringCreateWithUTF8CString("width");
1161  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(p_obj->_ctx, evt->getWidth()), kJSPropertyAttributeReadOnly, NULL);
1162  JSStringRelease(name);
1163 
1164  name = JSStringCreateWithUTF8CString("height");
1165  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(p_obj->_ctx, evt->getHeight()), kJSPropertyAttributeReadOnly, NULL);
1166  JSStringRelease(name);
1167 
1168  name = JSStringCreateWithUTF8CString("framerate");
1169  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(p_obj->_ctx, evt->getFrameRate()), kJSPropertyAttributeReadOnly, NULL);
1170  JSStringRelease(name);
1171 
1172  name = JSStringCreateWithUTF8CString("position");
1173  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
1174  JSStringRelease(name);
1175 
1176  name = JSStringCreateWithUTF8CString("cappedProfile");
1177  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(p_obj->_ctx, evt->getCappedProfileStatus()), kJSPropertyAttributeReadOnly, NULL);
1178  JSStringRelease(name);
1179 
1180  name = JSStringCreateWithUTF8CString("displayWidth");
1181  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(p_obj->_ctx, evt->getDisplayWidth()), kJSPropertyAttributeReadOnly, NULL);
1182  JSStringRelease(name);
1183 
1184  name = JSStringCreateWithUTF8CString("displayHeight");
1185  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(p_obj->_ctx, evt->getDisplayHeight()), kJSPropertyAttributeReadOnly, NULL);
1186  JSStringRelease(name);
1187 
1188  if(eVIDEOSCAN_UNKNOWN != evt->getScanType())
1189  {
1190  name = JSStringCreateWithUTF8CString("progressive");
1191  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, JSValueMakeBoolean(p_obj->_ctx, ((eVIDEOSCAN_PROGRESSIVE == evt->getScanType())?true:false)), kJSPropertyAttributeReadOnly, NULL);
1192  JSStringRelease(name);
1193  }
1194 
1195  if((0 != evt->getAspectRatioWidth()) && (0 != evt->getAspectRatioHeight()))
1196  {
1197  name = JSStringCreateWithUTF8CString("aspectRatioWidth");
1198  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(p_obj->_ctx, evt->getAspectRatioWidth()), kJSPropertyAttributeReadOnly, NULL);
1199  JSStringRelease(name);
1200 
1201  name = JSStringCreateWithUTF8CString("aspectRatioHeight");
1202  JSObjectSetProperty(p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(p_obj->_ctx, evt->getAspectRatioHeight()), kJSPropertyAttributeReadOnly, NULL);
1203  JSStringRelease(name);
1204  }
1205 
1206  }
1207 };
1208 
1209 /**
1210  * @class AAMP_Listener_Id3Metadata
1211  * @brief Event listener impl for AAMP_EVENT_ID3_METADATA event.
1212  */
1214 {
1215 public:
1216  /**
1217  * @brief AAMP_Listener_Id3Metadata Constructor
1218  * @param[in] obj aamp instance of PrivAAMPStruct_JS
1219  * @param[in] type event type
1220  * @param[in] jsCallback callback to be registered as listener
1221  */
1222  AAMP_Listener_Id3Metadata(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
1223  : AAMP_JSEventListener(obj, type, jsCallback)
1224  {
1225  }
1226 
1227  /**
1228  * @brief Set JS event properties
1229  * @param[in] ev AAMP event object
1230  * @param[out] jsEventObj JS event object
1231  */
1232  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
1233  {
1234  ID3MetadataEventPtr evt = std::dynamic_pointer_cast<ID3MetadataEvent>(ev);
1235  std::vector<uint8_t> data = evt->getMetadata();
1236  int len = evt->getMetadataSize();
1237  JSStringRef prop;
1238 
1239  JSValueRef* array = new JSValueRef[len];
1240  for (int32_t i = 0; i < len; i++)
1241  {
1242  array[i] = JSValueMakeNumber(p_obj->_ctx, data[i]);
1243  }
1244  prop = JSStringCreateWithUTF8CString("schemeIdUri");
1245  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getSchemeIdUri().c_str()), kJSPropertyAttributeReadOnly, NULL);
1246  JSStringRelease(prop);
1247 
1248  prop = JSStringCreateWithUTF8CString("value");
1249  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getValue().c_str()), kJSPropertyAttributeReadOnly, NULL);
1250  JSStringRelease(prop);
1251 
1252  prop = JSStringCreateWithUTF8CString("timeScale");
1253  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getTimeScale()), kJSPropertyAttributeReadOnly, NULL);
1254  JSStringRelease(prop);
1255 
1256  prop = JSStringCreateWithUTF8CString("presentationTime");
1257  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getPresentationTime()), kJSPropertyAttributeReadOnly, NULL);
1258  JSStringRelease(prop);
1259 
1260  prop = JSStringCreateWithUTF8CString("eventDuration");
1261  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getEventDuration()), kJSPropertyAttributeReadOnly, NULL);
1262  JSStringRelease(prop);
1263 
1264  prop = JSStringCreateWithUTF8CString("id");
1265  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getId()), kJSPropertyAttributeReadOnly, NULL);
1266  JSStringRelease(prop);
1267 
1268  prop = JSStringCreateWithUTF8CString("timestampOffset");
1269  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getTimestampOffset()), kJSPropertyAttributeReadOnly, NULL);
1270  JSStringRelease(prop);
1271 
1272  prop = JSStringCreateWithUTF8CString("data");
1273  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSObjectMakeArray(p_obj->_ctx, len, array, NULL), kJSPropertyAttributeReadOnly, NULL);
1274  JSStringRelease(prop);
1275  SAFE_DELETE_ARRAY(array);
1276 
1277  prop = JSStringCreateWithUTF8CString("length");
1278  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, len), kJSPropertyAttributeReadOnly, NULL);
1279  JSStringRelease(prop);
1280  }
1281 };
1282 
1283 /**
1284  * @class AAMP_Listener_Blocked
1285  * @brief Event listener impl for AAMP_EVENT_BLOCKED event.
1286  */
1288 {
1289 public:
1290  /**
1291  * @brief AAMP_Listener_Blocked Constructor
1292  * @param[in] obj aamp instance of PrivAAMPStruct_JS
1293  * @param[in] type event type
1294  * @param[in] jsCallback callback to be registered as listener
1295  */
1296  AAMP_Listener_Blocked(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
1297  : AAMP_JSEventListener(obj, type, jsCallback)
1298  {
1299  }
1300 
1301  /**
1302  * @brief Set JS event properties
1303  * @param[in] ev AAMP event object
1304  * @param[out] jsEventObj JS event object
1305  */
1306  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
1307  {
1308  BlockedEventPtr evt = std::dynamic_pointer_cast<BlockedEvent>(ev);
1309  JSStringRef prop;
1310 
1311  prop = JSStringCreateWithUTF8CString("reason");
1312  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getReason().c_str()), kJSPropertyAttributeReadOnly, NULL);
1313  JSStringRelease(prop);
1314  }
1315 };
1316 
1317 /**
1318  * @class AAMP_Listener_ContentGap
1319  * @brief Event listener impl for AAMP_EVENT_CONTENT_GAP event.
1320  */
1322 {
1323 public:
1324  /**
1325  * @brief AAMP_Listener_ContentGap Constructor
1326  * @param[in] obj aamp instance of PrivAAMPStruct_JS
1327  * @param[in] type event type
1328  * @param[in] jsCallback callback to be registered as listener
1329  */
1330  AAMP_Listener_ContentGap(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
1331  : AAMP_JSEventListener(obj, type, jsCallback)
1332  {
1333  }
1334 
1335  /**
1336  * @brief Set properties to JS event object
1337  * @param[in] ev AAMP event object
1338  * @param[out] jsEventObj JS event object
1339  */
1340  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
1341  {
1342  ContentGapEventPtr evt = std::dynamic_pointer_cast<ContentGapEvent>(ev);
1343  JSStringRef prop;
1344 
1345  double time = evt->getTime();
1346  double durationMs = evt->getDuration();
1347 
1348  prop = JSStringCreateWithUTF8CString("time");
1349  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, std::round(time)), kJSPropertyAttributeReadOnly, NULL);
1350  JSStringRelease(prop);
1351 
1352  if (durationMs >= 0)
1353  {
1354  prop = JSStringCreateWithUTF8CString("duration");
1355  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, (int)durationMs), kJSPropertyAttributeReadOnly, NULL);
1356  JSStringRelease(prop);
1357  }
1358  }
1359 };
1360 
1361 
1362 /**
1363  * @class AAMP_Listener_HTTPResponseHeader
1364  * @brief Event listener impl for AAMP_EVENT_HTTP_RESPONSE_HEADER event.
1365  */
1367 {
1368 public:
1369  /**
1370  * @brief AAMP_Listener_HTTPResponseHeader Constructor
1371  * @param[in] obj aamp instance of PrivAAMPStruct_JS
1372  * @param[in] type event type
1373  * @param[in] jsCallback callback to be registered as listener
1374  */
1376  : AAMP_JSEventListener(obj, type, jsCallback)
1377  {
1378  }
1379 
1380  /**
1381  * @brief Set properties to JS event object
1382  * @param[in] ev AAMP event object
1383  * @param[out] jsEventObj JS event object
1384  */
1385  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
1386  {
1387  HTTPResponseHeaderEventPtr evt = std::dynamic_pointer_cast<HTTPResponseHeaderEvent>(ev);
1388 
1389  JSStringRef prop;
1390 
1391  prop = JSStringCreateWithUTF8CString("header");
1392  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getHeader().c_str()), kJSPropertyAttributeReadOnly, NULL);
1393  JSStringRelease(prop);
1394 
1395  prop = JSStringCreateWithUTF8CString("response");
1396  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getResponse().c_str()), kJSPropertyAttributeReadOnly, NULL);
1397  JSStringRelease(prop);
1398  }
1399 };
1400 
1401 /**
1402  * @class AAMP_Listener_WatermarkSessionUpdate
1403  * @brief Event listener impl for AAMP_EVENT_WATERMARK_SESSION_UPDATE event.
1404  */
1406 {
1407 public:
1408  /**
1409  * @brief AAMP_Listener_WatermarkSessionUpdate Constructor
1410  * @param[in] obj aamp instance of PrivAAMPStruct_JS
1411  * @param[in] type event type
1412  * @param[in] jsCallback callback to be registered as listener
1413  */
1415  : AAMP_JSEventListener(obj, type, jsCallback)
1416  {
1417  }
1418 
1419  /**
1420  * @brief Set JS event properties
1421  * @param[in] ev AAMP event object
1422  * @param[out] jsEventObj JS event object
1423  */
1424  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
1425  {
1426  WatermarkSessionUpdateEventPtr evt = std::dynamic_pointer_cast<WatermarkSessionUpdateEvent>(ev);
1427  JSStringRef prop;
1428 
1429  prop = JSStringCreateWithUTF8CString("sessionHandle");
1430  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getSessionHandle()), kJSPropertyAttributeReadOnly, NULL);
1431  JSStringRelease(prop);
1432 
1433  prop = JSStringCreateWithUTF8CString("status");
1434  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(p_obj->_ctx, evt->getStatus()), kJSPropertyAttributeReadOnly, NULL);
1435  JSStringRelease(prop);
1436 
1437  prop = JSStringCreateWithUTF8CString("system");
1438  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getSystem().c_str()), kJSPropertyAttributeReadOnly, NULL);
1439  JSStringRelease(prop);
1440  }
1441 };
1442 
1443 /**
1444  * @class AAMP_JSListener_ContentProtectionData
1445  * @brief Event listener impl for (AAMP_EVENT_CONTENT_PROTECTION_DATA_UPDATE) AAMP event
1446  */
1447 
1449 {
1450 public:
1451  /**
1452  * @brief AAMP_Listener_ContentProtectionData Constructor
1453  * @param[in] aamp instance of PrivAAMPStruct_JS
1454  * @param[in] type event type
1455  * @param[in] jsCallback callback to be registered as listener
1456  */
1458  : AAMP_JSEventListener(obj, type, jsCallback)
1459  {
1460  }
1461 
1462  /**
1463  * @brief Set properties to JS event object
1464  * @param[in] ev AAMP event object
1465  * @param[out] jsEventObj JS event object
1466  */
1467  void SetEventProperties(const AAMPEventPtr& ev, JSObjectRef jsEventObj)
1468  {
1469  ContentProtectionDataEventPtr evt = std::dynamic_pointer_cast<ContentProtectionDataEvent>(ev);
1470  std::vector<uint8_t> keyId = evt->getKeyID();
1471  int len = keyId.size();
1472  JSStringRef prop;
1473  JSValueRef* array = new JSValueRef[len];
1474  for (int32_t i = 0; i < len; i++)
1475  {
1476  array[i] = JSValueMakeNumber(p_obj->_ctx, keyId[i]);
1477  }
1478 
1479  prop = JSStringCreateWithUTF8CString("keyID");
1480  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, JSObjectMakeArray(p_obj->_ctx, len, array, NULL), kJSPropertyAttributeReadOnly, NULL);
1481  JSStringRelease(prop);
1482  SAFE_DELETE_ARRAY(array);
1483 
1484  prop = JSStringCreateWithUTF8CString("streamType");
1485  JSObjectSetProperty(p_obj->_ctx, jsEventObj, prop, aamp_CStringToJSValue(p_obj->_ctx, evt->getStreamType().c_str()), kJSPropertyAttributeReadOnly, NULL);
1486  JSStringRelease(prop);
1487  }
1488 
1489 };
1490 
1491 
1492 /**
1493  * @brief AAMP_JSEventListener Constructor
1494  */
1496  : p_obj(obj)
1497  , p_type(type)
1498  , p_jsCallback(jsCallback)
1499 {
1500  if (p_jsCallback != NULL)
1501  {
1502  JSValueProtect(p_obj->_ctx, p_jsCallback);
1503  }
1504 }
1505 
1506 /**
1507  * @brief AAMP_JSEventListener Destructor
1508  */
1510 {
1511  if (p_jsCallback != NULL)
1512  {
1513  JSValueUnprotect(p_obj->_ctx, p_jsCallback);
1514  }
1515 }
1516 
1517 /**
1518  * @brief Callback invoked for dispatching event
1519  */
1520 void AAMP_JSEventListener::Event(const AAMPEventPtr& e)
1521 {
1522  AAMPEventType evtType = e->getType();
1523  LOG_TRACE("type=%d, jsCallback=%p", evtType, p_jsCallback);
1524 
1525  if (evtType < 0 || evtType >= AAMP_MAX_NUM_EVENTS)
1526  {
1527  return;
1528  }
1529 
1530  JSObjectRef event = createNewAAMPJSEvent(p_obj->_ctx, aampPlayer_getNameFromEventType(evtType), false, false);
1531  if (event)
1532  {
1533  JSGlobalContextRef ctx = p_obj->_ctx;
1534  JSValueProtect(ctx, event);
1535  SetEventProperties(e, event);
1536  //send this event through promise callback if an event listener is not registered
1537  if (p_type == AAMP_EVENT_AD_RESOLVED && p_jsCallback == NULL)
1538  {
1539  AdResolvedEventPtr evt = std::dynamic_pointer_cast<AdResolvedEvent>(e);
1540  std::string adId = evt->getAdId();
1541  JSObjectRef cbObj = p_obj->getCallbackForAdId(adId);
1542  if (cbObj != NULL)
1543  {
1544  aamp_dispatchEventToJS(ctx, cbObj, event);
1545  p_obj->removeCallbackForAdId(adId); //promise callbacks are intended for a single-time use for an ad id
1546  }
1547  else
1548  {
1549 
1550  LOG_ERROR_EX("No promise callback registered ctx=%p, jsCallback=%p", ctx, cbObj);
1551  }
1552  }
1553  else if (p_jsCallback != NULL)
1554  {
1555  aamp_dispatchEventToJS(ctx, p_jsCallback, event);
1556  }
1557  else
1558  {
1559 
1560  LOG_WARN_EX("Callback registered is (%p) for event=%d", p_jsCallback, p_type);
1561 
1562  }
1563  JSValueUnprotect(ctx, event);
1564  }
1565 }
1566 
1567 
1568 /**
1569  * @brief Adds a JS function as listener for a particular event
1570  */
1572 {
1573  LOG_TRACE("(%p, %d, %p)", obj, type, jsCallback);
1574 
1575  AAMP_JSEventListener* pListener = NULL;
1576 
1577  switch(type)
1578  {
1580  pListener = new AAMP_Listener_PlaybackStateChanged(obj, type, jsCallback);
1581  break;
1582  case AAMP_EVENT_PROGRESS:
1583  pListener = new AAMP_Listener_ProgressUpdate(obj, type, jsCallback);
1584  break;
1586  pListener = new AAMP_Listener_SpeedChanged(obj, type, jsCallback);
1587  break;
1589  pListener = new AAMP_Listener_BufferingChanged(obj, type, jsCallback);
1590  break;
1592  pListener = new AAMP_Listener_PlaybackFailed(obj, type, jsCallback);
1593  break;
1595  pListener = new AAMP_Listener_MediaMetadata(obj, type, jsCallback);
1596  break;
1598  pListener = new AAMP_Listener_SpeedsChanged(obj, type, jsCallback);
1599  break;
1600  case AAMP_EVENT_SEEKED:
1601  pListener = new AAMP_Listener_Seeked(obj, type, jsCallback);
1602  break;
1604  pListener = new AAMP_Listener_TuneProfiling(obj, type, jsCallback);
1605  break;
1607  pListener = new AAMP_Listener_CCHandleAvailable(obj, type, jsCallback);
1608  break;
1610  pListener = new AAMP_Listener_DRMMetadata(obj, type, jsCallback);
1611  break;
1613  pListener = new AAMP_Listener_AnomalyReport(obj, type, jsCallback);
1614  break;
1616  pListener = new AAMP_Listener_VTTCueData(obj, type, jsCallback);
1617  break;
1619  pListener = new AAMP_Listener_BulkTimedMetadata(obj, type, jsCallback);
1620  break;
1622  pListener = new AAMP_Listener_TimedMetadata(obj, type, jsCallback);
1623  break;
1625  pListener = new AAMP_Listener_HTTPResponseHeader(obj, type, jsCallback);
1626  break;
1628  pListener = new AAMP_Listener_BitrateChanged(obj, type, jsCallback);
1629  break;
1630  // Following events are not having payload and hence falls under default case
1631  // AAMP_EVENT_EOS, AAMP_EVENT_TUNED, AAMP_EVENT_ENTERING_LIVE
1633  pListener = new AAMP_Listener_AdResolved(obj, type, jsCallback);
1634  break;
1636  pListener = new AAMP_Listener_AdReservationStart(obj, type, jsCallback);
1637  break;
1639  pListener = new AAMP_Listener_AdReservationEnd(obj, type, jsCallback);
1640  break;
1642  pListener = new AAMP_Listener_AdPlacementStart(obj, type, jsCallback);
1643  break;
1645  pListener = new AAMP_Listener_AdPlacementEnd(obj, type, jsCallback);
1646  break;
1648  pListener = new AAMP_Listener_AdProgress(obj, type, jsCallback);
1649  break;
1651  pListener = new AAMP_Listener_AdPlacementError(obj, type, jsCallback);
1652  break;
1654  pListener = new AAMP_Listener_Id3Metadata(obj, type, jsCallback);
1655  break;
1656  case AAMP_EVENT_BLOCKED:
1657  pListener = new AAMP_Listener_Blocked(obj, type, jsCallback);
1658  break;
1660  pListener = new AAMP_Listener_ContentGap(obj, type, jsCallback);
1661  break;
1663  pListener = new AAMP_Listener_WatermarkSessionUpdate(obj, type, jsCallback);
1664  break;
1666  pListener = new AAMP_Listener_ContentProtectionData(obj, type, jsCallback);
1667  break;
1668  // Following events are not having payload and hence falls under default case
1669  // AAMP_EVENT_EOS, AAMP_EVENT_TUNED, AAMP_EVENT_ENTERING_LIVE,
1670  // AAMP_EVENT_AUDIO_TRACKS_CHANGED, AAMP_EVENT_TEXT_TRACKS_CHANGED
1671  default:
1672  pListener = new AAMP_JSEventListener(obj, type, jsCallback);
1673  break;
1674  }
1675 
1676  if (obj->_aamp != NULL)
1677  {
1678  obj->_aamp->AddEventListener(type, pListener);
1679  }
1680 
1681  obj->_listeners.insert({type, (void *)pListener});
1682 }
1683 
1684 
1685 /**
1686  * @brief Removes a JS listener for a particular event
1687  */
1689 {
1690  LOG_TRACE("(%p, %d, %p)", obj, type, jsCallback);
1691 
1692  if (obj->_listeners.count(type) > 0)
1693  {
1694 
1695  typedef std::multimap<AAMPEventType, void*>::iterator listenerIter_t;
1696  std::pair<listenerIter_t, listenerIter_t> range = obj->_listeners.equal_range(type);
1697  for(listenerIter_t iter = range.first; iter != range.second; )
1698  {
1699  AAMP_JSEventListener *listener = (AAMP_JSEventListener *)iter->second;
1700  if (listener->p_jsCallback == jsCallback)
1701  {
1702  if (obj->_aamp != NULL)
1703  {
1704  obj->_aamp->RemoveEventListener(iter->first, listener);
1705  }
1706  iter = obj->_listeners.erase(iter);
1707  SAFE_DELETE(listener);
1708  }
1709  else
1710  {
1711  iter++;
1712  }
1713  }
1714  }
1715 }
1716 
1717 
1718 /**
1719  * @brief Remove all JS listeners registered
1720  */
1722 {
1723 
1724  LOG_TRACE("obj(%p) listeners remaining(%d)", obj, obj->_listeners.size());
1725 
1726  for (auto listenerIter = obj->_listeners.begin(); listenerIter != obj->_listeners.end();)
1727  {
1728  AAMP_JSEventListener *listener = (AAMP_JSEventListener *)listenerIter->second;
1729  if (obj->_aamp != NULL)
1730  {
1731  obj->_aamp->RemoveEventListener(listenerIter->first, listener);
1732  }
1733  listenerIter = obj->_listeners.erase(listenerIter);
1734  SAFE_DELETE(listener);
1735  }
1736 
1737  obj->_listeners.clear();
1738 
1739 }
AAMP_Listener_PlaybackStateChanged::AAMP_Listener_PlaybackStateChanged
AAMP_Listener_PlaybackStateChanged(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_PlaybackStateChanged Constructor.
Definition: jseventlistener.cpp:45
AAMP_Listener_BulkTimedMetadata
Event listener impl for BULK_TIMED_METADATA AAMP event.
Definition: jseventlistener.cpp:801
AAMP_EVENT_DRM_METADATA
@ AAMP_EVENT_DRM_METADATA
Definition: AampEvent.h:71
AAMP_EVENT_BULK_TIMED_METADATA
@ AAMP_EVENT_BULK_TIMED_METADATA
Definition: AampEvent.h:59
AAMP_Listener_WatermarkSessionUpdate::AAMP_Listener_WatermarkSessionUpdate
AAMP_Listener_WatermarkSessionUpdate(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_WatermarkSessionUpdate Constructor.
Definition: jseventlistener.cpp:1414
eVIDEOSCAN_UNKNOWN
@ eVIDEOSCAN_UNKNOWN
Definition: AampEvent.h:194
AAMP_Listener_AdPlacementError::AAMP_Listener_AdPlacementError
AAMP_Listener_AdPlacementError(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_AdPlacementError Constructor.
Definition: jseventlistener.cpp:1091
aamp_dispatchEventToJS
void aamp_dispatchEventToJS(JSContextRef context, JSObjectRef callback, JSObjectRef event)
To dispatch a JS event.
Definition: jsutils.cpp:344
AAMP_Listener_BitrateChanged::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:1144
eVIDEOSCAN_PROGRESSIVE
@ eVIDEOSCAN_PROGRESSIVE
Definition: AampEvent.h:192
AAMP_EVENT_CONTENT_GAP
@ AAMP_EVENT_CONTENT_GAP
Definition: AampEvent.h:85
AAMP_Listener_Id3Metadata
Event listener impl for AAMP_EVENT_ID3_METADATA event.
Definition: jseventlistener.cpp:1213
AAMP_EVENT_AD_PLACEMENT_END
@ AAMP_EVENT_AD_PLACEMENT_END
Definition: AampEvent.h:78
AAMP_Listener_CCHandleAvailable::AAMP_Listener_CCHandleAvailable
AAMP_Listener_CCHandleAvailable(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_CCHandleAvailable Constructor.
Definition: jseventlistener.cpp:600
AAMP_Listener_BitrateChanged::AAMP_Listener_BitrateChanged
AAMP_Listener_BitrateChanged(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_BitrateChanged Constructor.
Definition: jseventlistener.cpp:1134
AAMP_EVENT_BUFFERING_CHANGED
@ AAMP_EVENT_BUFFERING_CHANGED
Definition: AampEvent.h:64
AAMP_Listener_ContentGap::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:1340
AAMP_Listener_AdPlacementStart::AAMP_Listener_AdPlacementStart
AAMP_Listener_AdPlacementStart(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_AdPlacementStart Constructor.
Definition: jseventlistener.cpp:971
AAMP_Listener_VTTCueData
Event listener impl for AAMP_EVENT_WEBVTT_CUE_DATA event.
Definition: jseventlistener.cpp:716
AAMP_Listener_AdReservationEnd::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:941
AAMP_EVENT_REPORT_ANOMALY
@ AAMP_EVENT_REPORT_ANOMALY
Definition: AampEvent.h:72
AAMP_Listener_BulkTimedMetadata::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef eventObj)
Set JS event properties.
Definition: jseventlistener.cpp:819
AAMP_EVENT_TUNE_FAILED
@ AAMP_EVENT_TUNE_FAILED
Definition: AampEvent.h:48
AAMP_Listener_AdReservationEnd
Event listener impl for AAMP_EVENT_AD_RESERVATION_END event.
Definition: jseventlistener.cpp:922
AAMP_Listener_AnomalyReport::AAMP_Listener_AnomalyReport
AAMP_Listener_AnomalyReport(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_AnomalyReport Constructor.
Definition: jseventlistener.cpp:681
AAMP_EVENT_AD_RESERVATION_END
@ AAMP_EVENT_AD_RESERVATION_END
Definition: AampEvent.h:76
vttCue.h
Provides data structure to hold a WebVTT cue data.
AAMP_Listener_ContentGap
Event listener impl for AAMP_EVENT_CONTENT_GAP event.
Definition: jseventlistener.cpp:1321
PrivAAMPStruct_JS
Private data structure for JS binding object.
Definition: jsbindings.h:35
PlayerInstanceAAMP::RemoveEventListener
void RemoveEventListener(AAMPEventType eventType, EventListener *eventListener)
Remove event listener for eventType.
Definition: main_aamp.cpp:1493
AAMP_Listener_CCHandleAvailable
Event listener impl for AAMP_EVENT_CC_HANDLE_RECEIVED, event.
Definition: jseventlistener.cpp:591
AAMP_Listener_AdPlacementEnd::AAMP_Listener_AdPlacementEnd
AAMP_Listener_AdPlacementEnd(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_AdPlacementEnd Constructor.
Definition: jseventlistener.cpp:1011
AAMP_Listener_DRMMetadata::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:647
AAMP_Listener_ContentProtectionData
Definition: jseventlistener.cpp:1448
AAMP_Listener_VTTCueData::AAMP_Listener_VTTCueData
AAMP_Listener_VTTCueData(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_VTTCueData Constructor.
Definition: jseventlistener.cpp:725
jsutils.h
JavaScript util functions for AAMP.
AAMP_Listener_AdReservationStart::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:901
AAMP_Listener_SpeedChanged
Event listener impl for AAMP_EVENT_SPEED_CHANGED event.
Definition: jseventlistener.cpp:137
PlayerInstanceAAMP::AddEventListener
void AddEventListener(AAMPEventType eventType, EventListener *eventListener)
Support multiple listeners for multiple event type.
Definition: main_aamp.cpp:1483
AAMP_Listener_SpeedsChanged::AAMP_Listener_SpeedsChanged
AAMP_Listener_SpeedsChanged(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_SpeedsChanged Constructor.
Definition: jseventlistener.cpp:487
AAMP_Listener_VTTCueData::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:735
AAMP_Listener_PlaybackFailed::AAMP_Listener_PlaybackFailed
AAMP_Listener_PlaybackFailed(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_PlaybackFailed Constructor.
Definition: jseventlistener.cpp:222
AAMP_EVENT_WATERMARK_SESSION_UPDATE
@ AAMP_EVENT_WATERMARK_SESSION_UPDATE
Definition: AampEvent.h:87
AAMP_Listener_AdResolved::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:853
AAMP_Listener_HTTPResponseHeader
Event listener impl for AAMP_EVENT_HTTP_RESPONSE_HEADER event.
Definition: jseventlistener.cpp:1366
AAMP_Listener_ProgressUpdate
Event listener impl for AAMP_EVENT_PROGRESS event.
Definition: jseventlistener.cpp:73
AAMP_Listener_TimedMetadata::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:781
AAMP_JSEventListener::~AAMP_JSEventListener
~AAMP_JSEventListener()
AAMP_JSEventListener Destructor.
Definition: jseventlistener.cpp:1509
AAMP_Listener_Id3Metadata::AAMP_Listener_Id3Metadata
AAMP_Listener_Id3Metadata(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_Id3Metadata Constructor.
Definition: jseventlistener.cpp:1222
AAMP_Listener_AdPlacementError::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:1101
AAMP_JSEventListener
Event listener impl for AAMPMediaPlayer_JS object.
Definition: jseventlistener.h:37
AAMP_Listener_Blocked
Event listener impl for AAMP_EVENT_BLOCKED event.
Definition: jseventlistener.cpp:1287
AAMP_EVENT_STATE_CHANGED
@ AAMP_EVENT_STATE_CHANGED
Definition: AampEvent.h:60
AAMP_JSEventListener::RemoveEventListener
static void RemoveEventListener(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
Removes a JS listener for a particular event.
Definition: jseventlistener.cpp:1688
aampPlayer_getNameFromEventType
const char * aampPlayer_getNameFromEventType(AAMPEventType type)
Convert AAMP event type to JS event string (AAMPMediaPlayer)
Definition: jsutils.cpp:377
AAMP_Listener_Seeked::AAMP_Listener_Seeked
AAMP_Listener_Seeked(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_Seeked Constructor.
Definition: jseventlistener.cpp:530
AAMP_Listener_BufferingChanged
Event listener impl for AAMP_EVENT_BUFFERING_CHANGED event.
Definition: jseventlistener.cpp:177
AAMP_Listener_AdPlacementStart
Event listener impl for AAMP_EVENT_AD_PLACEMENT_START event.
Definition: jseventlistener.cpp:962
AAMP_Listener_AdPlacementEnd
Event listener impl for AAMP_EVENT_AD_PLACEMENT_END event.
Definition: jseventlistener.cpp:1002
AAMP_EVENT_SPEEDS_CHANGED
@ AAMP_EVENT_SPEEDS_CHANGED
Definition: AampEvent.h:61
AAMP_EVENT_BLOCKED
@ AAMP_EVENT_BLOCKED
Definition: AampEvent.h:84
AAMP_Listener_DRMMetadata
Event listener impl for AAMP_EVENT_DRM_METADATA event.
Definition: jseventlistener.cpp:628
AAMP_Listener_AdPlacementEnd::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:1021
AAMP_EVENT_AD_PLACEMENT_PROGRESS
@ AAMP_EVENT_AD_PLACEMENT_PROGRESS
Definition: AampEvent.h:80
AAMP_Listener_Blocked::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set JS event properties.
Definition: jseventlistener.cpp:1306
AAMP_EVENT_SPEED_CHANGED
@ AAMP_EVENT_SPEED_CHANGED
Definition: AampEvent.h:49
AAMP_Listener_Seeked::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:540
aamp_CreateTimedMetadataJSObject
JSObjectRef aamp_CreateTimedMetadataJSObject(JSContextRef context, long long timeMS, const char *szName, const char *szContent, const char *id, double durationMS)
Create a TimedMetadata JS object with args passed. Sample input "#EXT-X-CUE:ID=eae90713-db8e,...
Definition: jsutils.cpp:396
AAMP_JSEventListener::AAMP_JSEventListener
AAMP_JSEventListener(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_JSEventListener Constructor.
Definition: jseventlistener.cpp:1495
AAMP_JSEventListener::p_type
AAMPEventType p_type
Definition: jseventlistener.h:92
AAMP_JSEventListener::Event
void Event(const AAMPEventPtr &e)
Callback invoked for dispatching event.
Definition: jseventlistener.cpp:1520
AAMP_EVENT_AD_RESOLVED
@ AAMP_EVENT_AD_RESOLVED
Definition: AampEvent.h:74
AAMP_Listener_ProgressUpdate::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:92
AAMP_EVENT_CONTENT_PROTECTION_DATA_UPDATE
@ AAMP_EVENT_CONTENT_PROTECTION_DATA_UPDATE
Definition: AampEvent.h:88
AAMP_Listener_ContentGap::AAMP_Listener_ContentGap
AAMP_Listener_ContentGap(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_ContentGap Constructor.
Definition: jseventlistener.cpp:1330
AAMP_Listener_TimedMetadata
Event listener impl for AAMP_EVENT_TIMED_METADATA event.
Definition: jseventlistener.cpp:762
AAMP_Listener_AdReservationEnd::AAMP_Listener_AdReservationEnd
AAMP_Listener_AdReservationEnd(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_AdReservationEnd Constructor.
Definition: jseventlistener.cpp:931
LOG_WARN_EX
#define LOG_WARN_EX(FORMAT,...)
Definition: jsutils.h:44
AAMP_Listener_DRMMetadata::AAMP_Listener_DRMMetadata
AAMP_Listener_DRMMetadata(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_DRMMetadata Constructor.
Definition: jseventlistener.cpp:637
jseventlistener.h
Event Listner impl for AAMPMediaPlayer_JS object.
AAMP_Listener_PlaybackFailed
Event listener impl for AAMP_EVENT_TUNE_FAILED event.
Definition: jseventlistener.cpp:213
AAMP_Listener_ProgressUpdate::AAMP_Listener_ProgressUpdate
AAMP_Listener_ProgressUpdate(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_ProgressUpdate Constructor.
Definition: jseventlistener.cpp:82
AAMP_EVENT_TUNE_PROFILING
@ AAMP_EVENT_TUNE_PROFILING
Definition: AampEvent.h:63
AAMP_JSEventListener::p_obj
PrivAAMPStruct_JS * p_obj
Definition: jseventlistener.h:91
AAMP_Listener_AdResolved::AAMP_Listener_AdResolved
AAMP_Listener_AdResolved(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_AdResolved Constructor.
Definition: jseventlistener.cpp:843
AAMP_Listener_HTTPResponseHeader::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:1385
VTTCue
Data structure to hold a VTT cue.
Definition: vttCue.h:39
AAMP_JSEventListener::RemoveAllEventListener
static void RemoveAllEventListener(PrivAAMPStruct_JS *obj)
Remove all JS listeners registered.
Definition: jseventlistener.cpp:1721
AAMP_Listener_Seeked
Event listener impl for AAMP_EVENT_SEEKED event.
Definition: jseventlistener.cpp:521
AAMP_Listener_HTTPResponseHeader::AAMP_Listener_HTTPResponseHeader
AAMP_Listener_HTTPResponseHeader(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_HTTPResponseHeader Constructor.
Definition: jseventlistener.cpp:1375
AAMP_Listener_AnomalyReport
Event listener impl for AAMP_EVENT_REPORT_ANOMALY event.
Definition: jseventlistener.cpp:672
jsevent.h
JavaScript Event Impl for AAMP_JSController and AAMPMediaPlayer_JS.
AAMP_EVENT_ID3_METADATA
@ AAMP_EVENT_ID3_METADATA
Definition: AampEvent.h:82
AAMP_JSEventListener::p_jsCallback
JSObjectRef p_jsCallback
Definition: jseventlistener.h:93
AAMP_Listener_BitrateChanged
Event listener impl for AAMP_EVENT_BITRATE_CHANGED event.
Definition: jseventlistener.cpp:1125
AAMP_Listener_TuneProfiling
Event listener impl for AAMP_EVENT_TUNE_PROFILING event.
Definition: jseventlistener.cpp:554
AAMP_EVENT_AD_RESERVATION_START
@ AAMP_EVENT_AD_RESERVATION_START
Definition: AampEvent.h:75
AAMP_Listener_AdPlacementStart::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:981
AAMP_EVENT_CC_HANDLE_RECEIVED
@ AAMP_EVENT_CC_HANDLE_RECEIVED
Definition: AampEvent.h:53
AAMP_Listener_PlaybackFailed::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:232
AAMP_Listener_AdReservationStart
Event listener impl for AAMP_EVENT_AD_RESERVATION_START event.
Definition: jseventlistener.cpp:882
AAMP_Listener_PlaybackStateChanged::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:55
AAMP_Listener_AdProgress::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:1061
AAMP_EVENT_WEBVTT_CUE_DATA
@ AAMP_EVENT_WEBVTT_CUE_DATA
Definition: AampEvent.h:73
AAMP_Listener_BulkTimedMetadata::AAMP_Listener_BulkTimedMetadata
AAMP_Listener_BulkTimedMetadata(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_BulkTimedMetadata Constructor.
Definition: jseventlistener.cpp:810
AAMP_EVENT_MEDIA_METADATA
@ AAMP_EVENT_MEDIA_METADATA
Definition: AampEvent.h:55
createNewAAMPJSEvent
JSObjectRef createNewAAMPJSEvent(JSGlobalContextRef ctx, const char *type, bool bubbles, bool cancelable)
To create a new JS event instance.
Definition: jsevent.cpp:519
AAMP_Listener_SpeedChanged::AAMP_Listener_SpeedChanged
AAMP_Listener_SpeedChanged(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_SpeedChanged Constructor.
Definition: jseventlistener.cpp:146
AAMP_Listener_AdPlacementError
Event listener impl for AAMP_EVENT_AD_PLACEMENT_ERROR event.
Definition: jseventlistener.cpp:1082
AAMPEventType
AAMPEventType
Type of the events sending to the JSPP player.
Definition: AampEvent.h:44
AAMP_Listener_WatermarkSessionUpdate
Event listener impl for AAMP_EVENT_WATERMARK_SESSION_UPDATE event.
Definition: jseventlistener.cpp:1405
AAMP_Listener_CCHandleAvailable::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:610
aamp_CStringToJSValue
JSValueRef aamp_CStringToJSValue(JSContextRef context, const char *sz)
Convert C string to JSString.
Definition: jsutils.cpp:152
AAMP_JSEventListener::AddEventListener
static void AddEventListener(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
Adds a JS function as listener for a particular event.
Definition: jseventlistener.cpp:1571
AAMP_Listener_TuneProfiling::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:573
AAMP_EVENT_AD_PLACEMENT_START
@ AAMP_EVENT_AD_PLACEMENT_START
Definition: AampEvent.h:77
AAMP_Listener_ContentProtectionData::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:1467
AAMP_EVENT_TIMED_METADATA
@ AAMP_EVENT_TIMED_METADATA
Definition: AampEvent.h:58
AAMP_Listener_BufferingChanged::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:196
AAMP_Listener_Id3Metadata::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set JS event properties.
Definition: jseventlistener.cpp:1232
AAMP_Listener_AdReservationStart::AAMP_Listener_AdReservationStart
AAMP_Listener_AdReservationStart(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_AdReservationStart Constructor.
Definition: jseventlistener.cpp:891
AAMP_EVENT_SEEKED
@ AAMP_EVENT_SEEKED
Definition: AampEvent.h:62
AAMP_EVENT_PROGRESS
@ AAMP_EVENT_PROGRESS
Definition: AampEvent.h:52
AAMP_Listener_PlaybackStateChanged
Event listener impl for AAMP_EVENT_STATE_CHANGED event.
Definition: jseventlistener.cpp:36
AAMP_Listener_AdProgress::AAMP_Listener_AdProgress
AAMP_Listener_AdProgress(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_AdProgress Constructor.
Definition: jseventlistener.cpp:1051
AAMP_Listener_AdProgress
Event listener impl for AAMP_EVENT_AD_PLACEMENT_PROGRESS event.
Definition: jseventlistener.cpp:1042
AAMP_Listener_MediaMetadata::AAMP_Listener_MediaMetadata
AAMP_Listener_MediaMetadata(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_MediaMetadata Constructor.
Definition: jseventlistener.cpp:281
AAMP_Listener_TuneProfiling::AAMP_Listener_TuneProfiling
AAMP_Listener_TuneProfiling(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_TuneProfiling Constructor.
Definition: jseventlistener.cpp:563
AAMP_Listener_TimedMetadata::AAMP_Listener_TimedMetadata
AAMP_Listener_TimedMetadata(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_TimedMetadata Constructor.
Definition: jseventlistener.cpp:771
AAMP_Listener_SpeedsChanged
Event listener impl for AAMP_EVENT_SPEEDS_CHANGED event.
Definition: jseventlistener.cpp:478
AAMP_Listener_ContentProtectionData::AAMP_Listener_ContentProtectionData
AAMP_Listener_ContentProtectionData(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_ContentProtectionData Constructor.
Definition: jseventlistener.cpp:1457
AAMP_Listener_AdResolved
Event listener impl for AAMP_EVENT_AD_RESOLVED event.
Definition: jseventlistener.cpp:834
AAMP_EVENT_HTTP_RESPONSE_HEADER
@ AAMP_EVENT_HTTP_RESPONSE_HEADER
Definition: AampEvent.h:86
AAMP_Listener_BufferingChanged::AAMP_Listener_BufferingChanged
AAMP_Listener_BufferingChanged(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_BufferingChanged Constructor.
Definition: jseventlistener.cpp:186
AAMP_Listener_Blocked::AAMP_Listener_Blocked
AAMP_Listener_Blocked(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
AAMP_Listener_Blocked Constructor.
Definition: jseventlistener.cpp:1296
AAMP_Listener_MediaMetadata::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:291
AAMP_EVENT_BITRATE_CHANGED
@ AAMP_EVENT_BITRATE_CHANGED
Definition: AampEvent.h:57
AAMP_Listener_SpeedChanged::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:156
AAMP_EVENT_AD_PLACEMENT_ERROR
@ AAMP_EVENT_AD_PLACEMENT_ERROR
Definition: AampEvent.h:79
AAMP_Listener_SpeedsChanged::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:497
LOG_TRACE
#define LOG_TRACE
Definition: rdk_debug_priv.c:83
AAMP_Listener_MediaMetadata
Event listener impl for AAMP_EVENT_MEDIA_METADATA event.
Definition: jseventlistener.cpp:272
AAMP_Listener_AnomalyReport::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set properties to JS event object.
Definition: jseventlistener.cpp:691
AAMP_Listener_WatermarkSessionUpdate::SetEventProperties
void SetEventProperties(const AAMPEventPtr &ev, JSObjectRef jsEventObj)
Set JS event properties.
Definition: jseventlistener.cpp:1424