jsbindings/jsbindings.cpp
/**
 *   @brief  Loads AAMP JS object into JS execution context
 *
 *   @param[in]  context - JS execution context
 *   @param[in]  playerInstanceAAMP - Instance of PlayerInstanceAAMP, if to be re-used
 *
 *   @return void
 */
@brief  Loads AAMP JS object into JS execution context
@param[in]  context - JS execution context
@param[in]  playerInstanceAAMP - Instance of PlayerInstanceAAMP, if to be re-used

@return void
@brief Loads AAMP JS object into JS execution context @param [ in ] context - JS execution context @param [ in ] playerInstanceAAMP - Instance of PlayerInstanceAAMP if to be re - used @return void
void aamp_LoadJS(void* context, void* playerInstanceAAMP)
{
	INFO("[AAMP_JS] %s() context=%p, aamp=%p", __FUNCTION__, context, playerInstanceAAMP);
	JSGlobalContextRef jsContext = (JSGlobalContextRef)context;
	AAMP_JS* pAAMP = new AAMP_JS();
	pAAMP->_ctx = jsContext;
	if (NULL != playerInstanceAAMP)
	{
		pAAMP->_aamp = (PlayerInstanceAAMP*)playerInstanceAAMP;
	}
	else
	{
		pthread_mutex_lock(&mutex);
		if (NULL == _allocated_aamp )
		{
			_allocated_aamp = new PlayerInstanceAAMP();
			LOG("[AAMP_JS] %s:%d create aamp %p\n", __FUNCTION__, __LINE__, _allocated_aamp);
		}
		else
		{
			LOG("[AAMP_JS] %s:%d reuse aamp %p\n", __FUNCTION__, __LINE__, _allocated_aamp);
		}
		pAAMP->_aamp = _allocated_aamp;
		pthread_mutex_unlock(&mutex);
	}
	pAAMP->_listeners = NULL;
	pAAMP->_eventType = AAMP_JS_AddEventTypeClass(jsContext);
	JSValueProtect(jsContext, pAAMP->_eventType);
	pAAMP->_subscribedTags = NULL;
	JSObjectRef classObj = JSObjectMake(jsContext, AAMP_class_ref(), pAAMP);
	JSObjectRef globalObj = JSContextGetGlobalObject(jsContext);
	JSStringRef str = JSStringCreateWithUTF8CString("AAMP");
	JSObjectSetProperty(jsContext, globalObj, str, classObj, kJSPropertyAttributeReadOnly, NULL);
	JSStringRelease(str);
}
void aamp_LoadJS ( void * context , void * playerInstanceAAMP ) { INFO ( " " , __FUNCTION__ , context , playerInstanceAAMP ) ; JSGlobalContextRef jsContext = ( JSGlobalContextRef ) context ; AAMP_JS * pAAMP = new AAMP_JS ( ) ; pAAMP -> _ctx = jsContext ; if ( NULL != playerInstanceAAMP ) { pAAMP -> _aamp = ( PlayerInstanceAAMP * ) playerInstanceAAMP ; } else { pthread_mutex_lock ( & mutex ) ; if ( NULL == _allocated_aamp ) { _allocated_aamp = new PlayerInstanceAAMP ( ) ; LOG ( " \n " , __FUNCTION__ , __LINE__ , _allocated_aamp ) ; } else { LOG ( " \n " , __FUNCTION__ , __LINE__ , _allocated_aamp ) ; } pAAMP -> _aamp = _allocated_aamp ; pthread_mutex_unlock ( & mutex ) ; } pAAMP -> _listeners = NULL ; pAAMP -> _eventType = AAMP_JS_AddEventTypeClass ( jsContext ) ; JSValueProtect ( jsContext , pAAMP -> _eventType ) ; pAAMP -> _subscribedTags = NULL ; JSObjectRef classObj = JSObjectMake ( jsContext , AAMP_class_ref ( ) , pAAMP ) ; JSObjectRef globalObj = JSContextGetGlobalObject ( jsContext ) ; JSStringRef str = JSStringCreateWithUTF8CString ( " " ) ; JSObjectSetProperty ( jsContext , globalObj , str , classObj , kJSPropertyAttributeReadOnly , NULL ) ; JSStringRelease ( str ) ; }
@brief  Loads AAMP JS object into JS execution context
   @param[in]  context - JS execution context
   @param[in]  playerInstanceAAMP - Instance of PlayerInstanceAAMP, if to be re-used
@brief Loads AAMP JS object into JS execution context @param [ in ] context - JS execution context @param [ in ] playerInstanceAAMP - Instance of PlayerInstanceAAMP if to be re - used