jsbindings/jsbindings.cpp
/**
 * @brief Callback invoked from JS to start playback for requested URL
 *
 * @param[in]  context       JS execution context
 * @param[in]  function      JSObject that is the function being called
 * @param[in]  thisObject    JSObject that is the 'this' variable in the function's scope
 * @param[in]  argumentCount Number of args
 * @param[in]  arguments[]   JSValue array of args
 * @param[out] exception     Pointer to a JSValueRef in which to return an exception, if any
 *
 * @retval JSValue that is the function's return value
 */


@retval JSValue that is the function's return value
@retval JSValue that is the function ' s return value
static JSValueRef AAMP_tune(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
{
	LOG("[AAMP_JS] %s()", __FUNCTION__);
	AAMP_JS* pAAMP = (AAMP_JS*)JSObjectGetPrivate(thisObject); 
	if(!pAAMP)
	{
		ERROR("[AAMP_JS] %s() Error: JSObjectGetPrivate returned NULL!", __FUNCTION__);
		*exception = aamp_GetException(context, AAMPJS_MISSING_OBJECT, "Can only call AAMP.tune on instances of AAMP");
		return JSValueMakeUndefined(context);
	}
	char* contentType = NULL;
	bool bFinalAttempt = false;
	bool bFirstAttempt = true;
	switch(argumentCount)
	{
		case 4:
			{
				bFinalAttempt = JSValueToBoolean(context, arguments[3]);
			}
		case 3:
			{
				bFirstAttempt = JSValueToBoolean(context, arguments[2]);
			}
		case 2:
			{
				contentType = aamp_JSValueToCString(context, arguments[1], exception);
			}
		case 1:
			{
				char* url = aamp_JSValueToCString(context, arguments[0], exception);
				pAAMP->_aamp->Tune(url, contentType, bFirstAttempt, bFinalAttempt);
				delete [] url;
			}
			if(NULL != contentType)
			{
				delete [] contentType;
			}
			break;
		default:
			ERROR("[AAMP_JS] %s() InvalidArgument: argumentCount=%d, expected: 1 to 4", __FUNCTION__, argumentCount);
			*exception = aamp_GetException(context, AAMPJS_INVALID_ARGUMENT, "Failed to execute 'AAMP.tune' - 1 argument required");
			break;
	}
	return JSValueMakeUndefined(context);
}
static JSValueRef AAMP_tune ( JSContextRef context , JSObjectRef function , JSObjectRef thisObject , size_t argumentCount , const JSValueRef arguments [ ] , JSValueRef * exception ) { LOG ( " " , __FUNCTION__ ) ; AAMP_JS * pAAMP = ( AAMP_JS * ) JSObjectGetPrivate ( thisObject ) ; if ( ! pAAMP ) { ERROR ( " " , __FUNCTION__ ) ; * exception = aamp_GetException ( context , AAMPJS_MISSING_OBJECT , " " ) ; return JSValueMakeUndefined ( context ) ; } char * contentType = NULL ; bool bFinalAttempt = false ; bool bFirstAttempt = true ; switch ( argumentCount ) { case 4 : { bFinalAttempt = JSValueToBoolean ( context , arguments [ 3 ] ) ; } case 3 : { bFirstAttempt = JSValueToBoolean ( context , arguments [ 2 ] ) ; } case 2 : { contentType = aamp_JSValueToCString ( context , arguments [ 1 ] , exception ) ; } case 1 : { char * url = aamp_JSValueToCString ( context , arguments [ 0 ] , exception ) ; pAAMP -> _aamp -> Tune ( url , contentType , bFirstAttempt , bFinalAttempt ) ; delete [ ] url ; } if ( NULL != contentType ) { delete [ ] contentType ; } break ; default : ERROR ( " " , __FUNCTION__ , argumentCount ) ; * exception = aamp_GetException ( context , AAMPJS_INVALID_ARGUMENT , " " ) ; break ; } return JSValueMakeUndefined ( context ) ; }
@brief Callback invoked from JS to start playback for requested URL
 @param[in]  context       JS execution context
 @param[in]  function      JSObject that is the function being called
 @param[in]  thisObject    JSObject that is the 'this' variable in the function's scope
 @param[in]  argumentCount Number of args
 @param[in]  arguments[]   JSValue array of args
 @param[out] exception     Pointer to a JSValueRef in which to return an exception, if any
@brief Callback invoked from JS to start playback for requested URL @param [ in ] context JS execution context @param [ in ] function JSObject that is the function being called @param [ in ] thisObject JSObject that is the ' this ' variable in the function ' s scope @param [ in ] argumentCount Number of args @param [ in ] arguments [] JSValue array of args @param [ out ] exception Pointer to a JSValueRef in which to return an exception if any