57 StateChangedEventPtr evt = std::dynamic_pointer_cast<StateChangedEvent>(ev);
61 prop = JSStringCreateWithUTF8CString(
"state");
62 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getState()), kJSPropertyAttributeReadOnly, NULL);
63 JSStringRelease(prop);
94 ProgressEventPtr evt = std::dynamic_pointer_cast<ProgressEvent>(ev);
98 prop = JSStringCreateWithUTF8CString(
"durationMiliseconds");
99 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getDuration()), kJSPropertyAttributeReadOnly, NULL);
100 JSStringRelease(prop);
102 prop = JSStringCreateWithUTF8CString(
"positionMiliseconds");
103 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
104 JSStringRelease(prop);
106 prop = JSStringCreateWithUTF8CString(
"playbackSpeed");
107 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getSpeed()), kJSPropertyAttributeReadOnly, NULL);
108 JSStringRelease(prop);
110 prop = JSStringCreateWithUTF8CString(
"startMiliseconds");
111 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getStart()), kJSPropertyAttributeReadOnly, NULL);
112 JSStringRelease(prop);
114 prop = JSStringCreateWithUTF8CString(
"endMiliseconds");
115 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getEnd()), kJSPropertyAttributeReadOnly, NULL);
116 JSStringRelease(prop);
118 prop = JSStringCreateWithUTF8CString(
"currentPTS");
119 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getPTS()), kJSPropertyAttributeReadOnly, NULL);
120 JSStringRelease(prop);
122 prop = JSStringCreateWithUTF8CString(
"videoBufferedMiliseconds");
123 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getBufferedDuration()), kJSPropertyAttributeReadOnly, NULL);
124 JSStringRelease(prop);
126 prop = JSStringCreateWithUTF8CString(
"timecode");
128 JSStringRelease(prop);
158 SpeedChangedEventPtr evt = std::dynamic_pointer_cast<SpeedChangedEvent>(ev);
162 prop = JSStringCreateWithUTF8CString(
"speed");
163 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getRate()), kJSPropertyAttributeReadOnly, NULL);
164 JSStringRelease(prop);
166 prop = JSStringCreateWithUTF8CString(
"reason");
168 JSStringRelease(prop);
198 BufferingChangedEventPtr evt = std::dynamic_pointer_cast<BufferingChangedEvent>(ev);
202 prop = JSStringCreateWithUTF8CString(
"buffering");
203 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(
p_obj->_ctx, evt->buffering()), kJSPropertyAttributeReadOnly, NULL);
204 JSStringRelease(prop);
234 MediaErrorEventPtr evt = std::dynamic_pointer_cast<MediaErrorEvent>(ev);
238 prop = JSStringCreateWithUTF8CString(
"code");
239 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getCode()), kJSPropertyAttributeReadOnly, NULL);
240 JSStringRelease(prop);
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);
246 prop = JSStringCreateWithUTF8CString(
"shouldRetry");
247 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(
p_obj->_ctx, evt->shouldRetry()), kJSPropertyAttributeReadOnly, NULL);
248 JSStringRelease(prop);
250 if(-1 != evt->getClass())
252 prop = JSStringCreateWithUTF8CString(
"class");
253 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getClass()), kJSPropertyAttributeReadOnly, NULL);
254 JSStringRelease(prop);
256 prop = JSStringCreateWithUTF8CString(
"reason");
257 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getReason()), kJSPropertyAttributeReadOnly, NULL);
258 JSStringRelease(prop);
260 prop = JSStringCreateWithUTF8CString(
"businessStatus");
261 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getBusinessStatus()), kJSPropertyAttributeReadOnly, NULL);
262 JSStringRelease(prop);
293 MediaMetadataEventPtr evt = std::dynamic_pointer_cast<MediaMetadataEvent>(ev);
296 prop = JSStringCreateWithUTF8CString(
"durationMiliseconds");
297 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getDuration()), kJSPropertyAttributeReadOnly, NULL);
298 JSStringRelease(prop);
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++)
308 JSValueRef propValue = JSObjectMakeArray(
p_obj->_ctx, count, array, NULL);
309 SAFE_DELETE_ARRAY(array);
311 prop = JSStringCreateWithUTF8CString(
"languages");
312 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, propValue, kJSPropertyAttributeReadOnly, NULL);
313 JSStringRelease(prop);
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++)
320 array[i] = JSValueMakeNumber(
p_obj->_ctx, bitrateVect[i]);
322 propValue = JSObjectMakeArray(
p_obj->_ctx, count, array, NULL);
323 SAFE_DELETE_ARRAY(array);
325 prop = JSStringCreateWithUTF8CString(
"bitrates");
326 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, propValue, kJSPropertyAttributeReadOnly, NULL);
327 JSStringRelease(prop);
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++)
334 array[i] = JSValueMakeNumber(
p_obj->_ctx, speedVect[i]);
336 propValue = JSObjectMakeArray(
p_obj->_ctx, count, array, NULL);
337 SAFE_DELETE_ARRAY(array);
339 prop = JSStringCreateWithUTF8CString(
"playbackSpeeds");
340 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, propValue, kJSPropertyAttributeReadOnly, NULL);
341 JSStringRelease(prop);
343 prop = JSStringCreateWithUTF8CString(
"programStartTime");
344 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getProgramStartTime()), kJSPropertyAttributeReadOnly, NULL);
345 JSStringRelease(prop);
347 prop = JSStringCreateWithUTF8CString(
"width");
348 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getWidth()), kJSPropertyAttributeReadOnly, NULL);
349 JSStringRelease(prop);
351 prop = JSStringCreateWithUTF8CString(
"height");
352 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getHeight()), kJSPropertyAttributeReadOnly, NULL);
353 JSStringRelease(prop);
355 prop = JSStringCreateWithUTF8CString(
"hasDrm");
356 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(
p_obj->_ctx, evt->hasDrm()), kJSPropertyAttributeReadOnly, NULL);
357 JSStringRelease(prop);
359 prop = JSStringCreateWithUTF8CString(
"isLive");
360 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(
p_obj->_ctx, evt->isLive()), kJSPropertyAttributeReadOnly, NULL);
361 JSStringRelease(prop);
363 prop = JSStringCreateWithUTF8CString(
"DRM");
365 JSStringRelease(prop);
368 if(!evt->getRatings().empty())
370 prop = JSStringCreateWithUTF8CString(
"ratings");
372 JSStringRelease(prop);
376 if(evt->getSsi() >= 0 )
378 prop = JSStringCreateWithUTF8CString(
"ssi");
379 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getSsi()), kJSPropertyAttributeReadOnly, NULL);
380 JSStringRelease(prop);
384 if(evt->getFrameRate() > 0 )
386 prop = JSStringCreateWithUTF8CString(
"framerate");
387 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getFrameRate()), kJSPropertyAttributeReadOnly, NULL);
388 JSStringRelease(prop);
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);
398 if((0 != evt->getAspectRatioWidth()) && (0 != evt->getAspectRatioHeight()))
400 prop = JSStringCreateWithUTF8CString(
"aspectRatioWidth");
401 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getAspectRatioWidth()), kJSPropertyAttributeReadOnly, NULL);
402 JSStringRelease(prop);
404 prop = JSStringCreateWithUTF8CString(
"aspectRatioHeight");
405 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getAspectRatioHeight()), kJSPropertyAttributeReadOnly, NULL);
406 JSStringRelease(prop);
410 if(!evt->getVideoCodec().empty())
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);
418 if(!evt->getHdrType().empty())
420 prop = JSStringCreateWithUTF8CString(
"hdrType");
422 JSStringRelease(prop);
426 const std::vector<long> &audioBitrateVect = evt->getAudioBitrates();
427 count = audioBitrateVect.size();
430 array =
new JSValueRef[count];
431 for (int32_t i = 0; i < count; i++)
433 array[i] = JSValueMakeNumber(
p_obj->_ctx, audioBitrateVect[i]);
435 propValue = JSObjectMakeArray(
p_obj->_ctx, count, array, NULL);
438 prop = JSStringCreateWithUTF8CString(
"audioBitrates");
439 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, propValue, kJSPropertyAttributeReadOnly, NULL);
440 JSStringRelease(prop);
445 if(!evt->getAudioCodec().empty())
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);
453 if(!evt->getAudioMixType().empty())
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);
461 prop = JSStringCreateWithUTF8CString(
"isAtmos");
462 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(
p_obj->_ctx,evt->getAtmosInfo()), kJSPropertyAttributeReadOnly, NULL);
463 JSStringRelease(prop);
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);
499 SupportedSpeedsChangedEventPtr evt = std::dynamic_pointer_cast<SupportedSpeedsChangedEvent>(ev);
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++)
506 array[i] = JSValueMakeNumber(
p_obj->_ctx, speedVect[i]);
508 JSValueRef propValue = JSObjectMakeArray(
p_obj->_ctx, count, array, NULL);
509 SAFE_DELETE_ARRAY(array);
511 JSStringRef prop = JSStringCreateWithUTF8CString(
"playbackSpeeds");
512 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, propValue, kJSPropertyAttributeReadOnly, NULL);
513 JSStringRelease(prop);
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);
575 TuneProfilingEventPtr evt = std::dynamic_pointer_cast<TuneProfilingEvent>(ev);
577 const char* microData = evt->getProfilingData().c_str();
579 LOG_TRACE(
"AAMP_Listener_TuneProfiling microData %s", microData);
580 prop = JSStringCreateWithUTF8CString(
"microData");
582 JSStringRelease(prop);
612 CCHandleEventPtr evt = std::dynamic_pointer_cast<CCHandleEvent>(ev);
616 prop = JSStringCreateWithUTF8CString(
"decoderHandle");
617 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getCCHandle()), kJSPropertyAttributeReadOnly, NULL);
618 JSStringRelease(prop);
649 DrmMetaDataEventPtr evt = std::dynamic_pointer_cast<DrmMetaDataEvent>(ev);
652 int code = evt->getAccessStatusValue();
653 const char* description = evt->getAccessStatus().c_str();
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);
660 prop = JSStringCreateWithUTF8CString(
"description");
662 JSStringRelease(prop);
693 AnomalyReportEventPtr evt = std::dynamic_pointer_cast<AnomalyReportEvent>(ev);
696 int severity = evt->getSeverity();
697 const char* description = evt->getMessage().c_str();
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);
704 prop = JSStringCreateWithUTF8CString(
"description");
706 JSStringRelease(prop);
737 WebVttCueEventPtr evt = std::dynamic_pointer_cast<WebVttCueEvent>(ev);
740 VTTCue *cue = evt->getCueData();
742 prop = JSStringCreateWithUTF8CString(
"start");
743 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, cue->mStart), kJSPropertyAttributeReadOnly, NULL);
744 JSStringRelease(prop);
746 prop = JSStringCreateWithUTF8CString(
"duration");
747 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, cue->mDuration), kJSPropertyAttributeReadOnly, NULL);
748 JSStringRelease(prop);
750 prop = JSStringCreateWithUTF8CString(
"text");
752 JSStringRelease(prop);
783 TimedMetadataEventPtr evt = std::dynamic_pointer_cast<TimedMetadataEvent>(ev);
785 JSObjectRef timedMetadata =
aamp_CreateTimedMetadataJSObject(
p_obj->_ctx, evt->getTime(), evt->getName().c_str(), evt->getContent().c_str(), evt->getId().c_str(), evt->getDuration());
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);
821 BulkTimedMetadataEventPtr evt = std::dynamic_pointer_cast<BulkTimedMetadataEvent>(ev);
822 JSStringRef name = JSStringCreateWithUTF8CString(
"timedMetadatas");
824 JSStringRelease(name);
855 AdResolvedEventPtr evt = std::dynamic_pointer_cast<AdResolvedEvent>(ev);
858 prop = JSStringCreateWithUTF8CString(
"resolvedStatus");
859 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeBoolean(
p_obj->_ctx, evt->getResolveStatus()), kJSPropertyAttributeReadOnly, NULL);
860 JSStringRelease(prop);
862 prop = JSStringCreateWithUTF8CString(
"placementId");
864 JSStringRelease(prop);
866 prop = JSStringCreateWithUTF8CString(
"placementStartTime");
867 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getStart()), kJSPropertyAttributeReadOnly, NULL);
868 JSStringRelease(prop);
870 prop = JSStringCreateWithUTF8CString(
"placementDuration");
871 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getDuration()), kJSPropertyAttributeReadOnly, NULL);
872 JSStringRelease(prop);
903 AdReservationEventPtr evt = std::dynamic_pointer_cast<AdReservationEvent>(ev);
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);
910 prop = JSStringCreateWithUTF8CString(
"time");
911 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
912 JSStringRelease(prop);
943 AdReservationEventPtr evt = std::dynamic_pointer_cast<AdReservationEvent>(ev);
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);
950 prop = JSStringCreateWithUTF8CString(
"time");
951 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
952 JSStringRelease(prop);
983 AdPlacementEventPtr evt = std::dynamic_pointer_cast<AdPlacementEvent>(ev);
986 prop = JSStringCreateWithUTF8CString(
"adId");
988 JSStringRelease(prop);
990 prop = JSStringCreateWithUTF8CString(
"time");
991 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
992 JSStringRelease(prop);
1023 AdPlacementEventPtr evt = std::dynamic_pointer_cast<AdPlacementEvent>(ev);
1026 prop = JSStringCreateWithUTF8CString(
"adId");
1028 JSStringRelease(prop);
1030 prop = JSStringCreateWithUTF8CString(
"time");
1031 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
1032 JSStringRelease(prop);
1063 AdPlacementEventPtr evt = std::dynamic_pointer_cast<AdPlacementEvent>(ev);
1066 prop = JSStringCreateWithUTF8CString(
"adId");
1068 JSStringRelease(prop);
1070 prop = JSStringCreateWithUTF8CString(
"time");
1071 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
1072 JSStringRelease(prop);
1103 AdPlacementEventPtr evt = std::dynamic_pointer_cast<AdPlacementEvent>(ev);
1106 prop = JSStringCreateWithUTF8CString(
"adId");
1108 JSStringRelease(prop);
1110 prop = JSStringCreateWithUTF8CString(
"time");
1111 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
1112 JSStringRelease(prop);
1114 prop = JSStringCreateWithUTF8CString(
"error");
1115 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getErrorCode()), kJSPropertyAttributeReadOnly, NULL);
1116 JSStringRelease(prop);
1146 BitrateChangeEventPtr evt = std::dynamic_pointer_cast<BitrateChangeEvent>(ev);
1148 name = JSStringCreateWithUTF8CString(
"time");
1149 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(
p_obj->_ctx, evt->getTime()), kJSPropertyAttributeReadOnly, NULL);
1150 JSStringRelease(name);
1152 name = JSStringCreateWithUTF8CString(
"bitRate");
1153 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(
p_obj->_ctx, evt->getBitrate()), kJSPropertyAttributeReadOnly, NULL);
1154 JSStringRelease(name);
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);
1160 name = JSStringCreateWithUTF8CString(
"width");
1161 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(
p_obj->_ctx, evt->getWidth()), kJSPropertyAttributeReadOnly, NULL);
1162 JSStringRelease(name);
1164 name = JSStringCreateWithUTF8CString(
"height");
1165 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(
p_obj->_ctx, evt->getHeight()), kJSPropertyAttributeReadOnly, NULL);
1166 JSStringRelease(name);
1168 name = JSStringCreateWithUTF8CString(
"framerate");
1169 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(
p_obj->_ctx, evt->getFrameRate()), kJSPropertyAttributeReadOnly, NULL);
1170 JSStringRelease(name);
1172 name = JSStringCreateWithUTF8CString(
"position");
1173 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(
p_obj->_ctx, evt->getPosition()), kJSPropertyAttributeReadOnly, NULL);
1174 JSStringRelease(name);
1176 name = JSStringCreateWithUTF8CString(
"cappedProfile");
1177 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(
p_obj->_ctx, evt->getCappedProfileStatus()), kJSPropertyAttributeReadOnly, NULL);
1178 JSStringRelease(name);
1180 name = JSStringCreateWithUTF8CString(
"displayWidth");
1181 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(
p_obj->_ctx, evt->getDisplayWidth()), kJSPropertyAttributeReadOnly, NULL);
1182 JSStringRelease(name);
1184 name = JSStringCreateWithUTF8CString(
"displayHeight");
1185 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(
p_obj->_ctx, evt->getDisplayHeight()), kJSPropertyAttributeReadOnly, NULL);
1186 JSStringRelease(name);
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);
1195 if((0 != evt->getAspectRatioWidth()) && (0 != evt->getAspectRatioHeight()))
1197 name = JSStringCreateWithUTF8CString(
"aspectRatioWidth");
1198 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(
p_obj->_ctx, evt->getAspectRatioWidth()), kJSPropertyAttributeReadOnly, NULL);
1199 JSStringRelease(name);
1201 name = JSStringCreateWithUTF8CString(
"aspectRatioHeight");
1202 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, name, JSValueMakeNumber(
p_obj->_ctx, evt->getAspectRatioHeight()), kJSPropertyAttributeReadOnly, NULL);
1203 JSStringRelease(name);
1234 ID3MetadataEventPtr evt = std::dynamic_pointer_cast<ID3MetadataEvent>(ev);
1235 std::vector<uint8_t> data = evt->getMetadata();
1236 int len = evt->getMetadataSize();
1239 JSValueRef* array =
new JSValueRef[len];
1240 for (int32_t i = 0; i < len; i++)
1242 array[i] = JSValueMakeNumber(
p_obj->_ctx, data[i]);
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);
1248 prop = JSStringCreateWithUTF8CString(
"value");
1250 JSStringRelease(prop);
1252 prop = JSStringCreateWithUTF8CString(
"timeScale");
1253 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getTimeScale()), kJSPropertyAttributeReadOnly, NULL);
1254 JSStringRelease(prop);
1256 prop = JSStringCreateWithUTF8CString(
"presentationTime");
1257 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getPresentationTime()), kJSPropertyAttributeReadOnly, NULL);
1258 JSStringRelease(prop);
1260 prop = JSStringCreateWithUTF8CString(
"eventDuration");
1261 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getEventDuration()), kJSPropertyAttributeReadOnly, NULL);
1262 JSStringRelease(prop);
1264 prop = JSStringCreateWithUTF8CString(
"id");
1265 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getId()), kJSPropertyAttributeReadOnly, NULL);
1266 JSStringRelease(prop);
1268 prop = JSStringCreateWithUTF8CString(
"timestampOffset");
1269 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getTimestampOffset()), kJSPropertyAttributeReadOnly, NULL);
1270 JSStringRelease(prop);
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);
1277 prop = JSStringCreateWithUTF8CString(
"length");
1278 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, len), kJSPropertyAttributeReadOnly, NULL);
1279 JSStringRelease(prop);
1308 BlockedEventPtr evt = std::dynamic_pointer_cast<BlockedEvent>(ev);
1311 prop = JSStringCreateWithUTF8CString(
"reason");
1313 JSStringRelease(prop);
1342 ContentGapEventPtr evt = std::dynamic_pointer_cast<ContentGapEvent>(ev);
1345 double time = evt->getTime();
1346 double durationMs = evt->getDuration();
1348 prop = JSStringCreateWithUTF8CString(
"time");
1349 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, std::round(time)), kJSPropertyAttributeReadOnly, NULL);
1350 JSStringRelease(prop);
1352 if (durationMs >= 0)
1354 prop = JSStringCreateWithUTF8CString(
"duration");
1355 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, (
int)durationMs), kJSPropertyAttributeReadOnly, NULL);
1356 JSStringRelease(prop);
1387 HTTPResponseHeaderEventPtr evt = std::dynamic_pointer_cast<HTTPResponseHeaderEvent>(ev);
1391 prop = JSStringCreateWithUTF8CString(
"header");
1393 JSStringRelease(prop);
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);
1426 WatermarkSessionUpdateEventPtr evt = std::dynamic_pointer_cast<WatermarkSessionUpdateEvent>(ev);
1429 prop = JSStringCreateWithUTF8CString(
"sessionHandle");
1430 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getSessionHandle()), kJSPropertyAttributeReadOnly, NULL);
1431 JSStringRelease(prop);
1433 prop = JSStringCreateWithUTF8CString(
"status");
1434 JSObjectSetProperty(
p_obj->_ctx, jsEventObj, prop, JSValueMakeNumber(
p_obj->_ctx, evt->getStatus()), kJSPropertyAttributeReadOnly, NULL);
1435 JSStringRelease(prop);
1437 prop = JSStringCreateWithUTF8CString(
"system");
1439 JSStringRelease(prop);
1469 ContentProtectionDataEventPtr evt = std::dynamic_pointer_cast<ContentProtectionDataEvent>(ev);
1470 std::vector<uint8_t> keyId = evt->getKeyID();
1471 int len = keyId.size();
1473 JSValueRef* array =
new JSValueRef[len];
1474 for (int32_t i = 0; i < len; i++)
1476 array[i] = JSValueMakeNumber(
p_obj->_ctx, keyId[i]);
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);
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);
1498 , p_jsCallback(jsCallback)
1525 if (evtType < 0 || evtType >= AAMP_MAX_NUM_EVENTS)
1533 JSGlobalContextRef ctx =
p_obj->_ctx;
1534 JSValueProtect(ctx, event);
1535 SetEventProperties(e, event);
1539 AdResolvedEventPtr evt = std::dynamic_pointer_cast<AdResolvedEvent>(e);
1540 std::string adId = evt->getAdId();
1541 JSObjectRef cbObj =
p_obj->getCallbackForAdId(adId);
1545 p_obj->removeCallbackForAdId(adId);
1550 LOG_ERROR_EX(
"No promise callback registered ctx=%p, jsCallback=%p", ctx, cbObj);
1563 JSValueUnprotect(ctx, event);
1573 LOG_TRACE(
"(%p, %d, %p)", obj, type, jsCallback);
1676 if (obj->_aamp != NULL)
1681 obj->_listeners.insert({type, (
void *)pListener});
1690 LOG_TRACE(
"(%p, %d, %p)", obj, type, jsCallback);
1692 if (obj->_listeners.count(type) > 0)
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; )
1702 if (obj->_aamp != NULL)
1706 iter = obj->_listeners.erase(iter);
1707 SAFE_DELETE(listener);
1724 LOG_TRACE(
"obj(%p) listeners remaining(%d)", obj, obj->_listeners.size());
1726 for (
auto listenerIter = obj->_listeners.begin(); listenerIter != obj->_listeners.end();)
1729 if (obj->_aamp != NULL)
1733 listenerIter = obj->_listeners.erase(listenerIter);
1734 SAFE_DELETE(listener);
1737 obj->_listeners.clear();