jsbindings/jsbindings.cpp
/**
 * @brief Callback invoked from JS to get the timedMetadata property value
 *
 * @param[in] context        JS execution context
 * @param[in] thisObject     JSObject to search for the property
 * @param[in] propertyName   JSString containing the name of the property to get
 * @param[out] exception     Pointer to a JSValueRef in which to return an exception, if any
 *
 * @retval Property's value if object has the property, otherwise NULL
 */


@retval Property's value if object has the property, otherwise NULL
@retval Property ' s value if object has the property otherwise NULL
static JSValueRef AAMP_getProperty_timedMetadata(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
{
	LOG("[AAMP_JS] %s()", __FUNCTION__);
	AAMP_JS* pAAMP = (AAMP_JS*)JSObjectGetPrivate(thisObject);
	if (pAAMP == NULL)
	{
		ERROR("[AAMP_JS] %s() Error: JSObjectGetPrivate returned NULL!", __FUNCTION__);
		*exception = aamp_GetException(context, AAMPJS_MISSING_OBJECT, "Can only call AAMP.timedMetadata on instances of AAMP");
		return JSValueMakeUndefined(context);
	}
	PrivateInstanceAAMP* privAAMP = (pAAMP->_aamp != NULL) ? pAAMP->_aamp->aamp : NULL;
	if (privAAMP == NULL)
	{
		ERROR("[AAMP_JS] %s() privAAMP not initialized", __FUNCTION__);
		*exception = aamp_GetException(context, AAMPJS_INVALID_ARGUMENT, "AAMP.timedMetadata - initialization error");
		return JSValueMakeUndefined(context);
	}
	int32_t length = privAAMP->timedMetadata.size();
	JSValueRef* array = new JSValueRef[length];
	for (int32_t i = 0; i < length; i++)
	{
		TimedMetadata item = privAAMP->timedMetadata.at(i);
		JSObjectRef ref = AAMP_JS_CreateTimedMetadata(context, item._timeMS, item._name.c_str(), item._content.c_str());
		array[i] = ref;
	}
	JSValueRef prop = JSObjectMakeArray(context, length, array, NULL);
	delete [] array;
	return prop;
}
static JSValueRef AAMP_getProperty_timedMetadata ( JSContextRef context , JSObjectRef thisObject , JSStringRef propertyName , JSValueRef * exception ) { LOG ( " " , __FUNCTION__ ) ; AAMP_JS * pAAMP = ( AAMP_JS * ) JSObjectGetPrivate ( thisObject ) ; if ( pAAMP == NULL ) { ERROR ( " " , __FUNCTION__ ) ; * exception = aamp_GetException ( context , AAMPJS_MISSING_OBJECT , " " ) ; return JSValueMakeUndefined ( context ) ; } PrivateInstanceAAMP * privAAMP = ( pAAMP -> _aamp != NULL ) ? pAAMP -> _aamp -> aamp : NULL ; if ( privAAMP == NULL ) { ERROR ( " " , __FUNCTION__ ) ; * exception = aamp_GetException ( context , AAMPJS_INVALID_ARGUMENT , " " ) ; return JSValueMakeUndefined ( context ) ; } int32_t length = privAAMP -> timedMetadata . size ( ) ; JSValueRef * array = new JSValueRef [ length ] ; for ( int32_t i = 0 ; i < length ; i ++ ) { TimedMetadata item = privAAMP -> timedMetadata . at ( i ) ; JSObjectRef ref = AAMP_JS_CreateTimedMetadata ( context , item . _timeMS , item . _name . c_str ( ) , item . _content . c_str ( ) ) ; array [ i ] = ref ; } JSValueRef prop = JSObjectMakeArray ( context , length , array , NULL ) ; delete [ ] array ; return prop ; }
@brief Callback invoked from JS to get the timedMetadata property value
 @param[in] context        JS execution context
 @param[in] thisObject     JSObject to search for the property
 @param[in] propertyName   JSString containing the name of the property to get
 @param[out] exception     Pointer to a JSValueRef in which to return an exception, if any
@brief Callback invoked from JS to get the timedMetadata property value @param [ in ] context JS execution context @param [ in ] thisObject JSObject to search for the property @param [ in ] propertyName JSString containing the name of the property to get @param [ out ] exception Pointer to a JSValueRef in which to return an exception if any