RDK Documentation (Open Sourced RDK Components)
jscontroller-jsbindings.cpp File Reference

JavaScript bindings for AAMP_JSController. More...

#include <JavaScriptCore/JavaScript.h>
#include "jsbindings.h"
#include "jseventlistener.h"
#include "jsutils.h"
#include "priv_aamp.h"
#include <stdio.h>
#include <string.h>
Include dependency graph for jscontroller-jsbindings.cpp:

Go to the source code of this file.

Data Structures

struct  AAMP_JSController
 Data structure of AAMP_JSController JS object. More...
 

Functions

void aamp_LoadJSController (JSGlobalContextRef context)
 Loads AAMP_JSController JS object into JS execution context. More...
 
void aamp_UnloadJSController (JSGlobalContextRef context)
 Removes the AAMP_JSController instance from JS context. More...
 
void setAAMPPlayerInstance (PlayerInstanceAAMP *aamp, int sessionID)
 Set the instance of PlayerInstanceAAMP and session id. More...
 
void unsetAAMPPlayerInstance (PlayerInstanceAAMP *aamp)
 Remove the PlayerInstanceAAMP stored earlier. More...
 
void aamp_SetPageHttpHeaders (const char *headerJson)
 Sets the custom http headers from received json string. More...
 
void aamp_ApplyPageHttpHeaders (PlayerInstanceAAMP *aampObject)
 applies the parsed custom http headers into the aamp More...
 
static JSValueRef AAMPJSC_getProperty_closedCaptionEnabled (JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef *exception)
 Callback invoked from JS to get the CC enabled property. More...
 
static bool AAMPJSC_setProperty_closedCaptionEnabled (JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef *exception)
 Callback invoked from JS to set the CC enabled property. More...
 
static JSValueRef AAMPJSC_getProperty_aampSessionID (JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef *exception)
 Callback invoked from JS to get the session id property. More...
 
static JSValueRef AAMPJSC_addEventListener (JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
 Callback invoked from JS to add an event listener. More...
 
static JSValueRef AAMPJSC_removeEventListener (JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
 Callback from JS to remove an event listener. More...
 
static JSValueRef AAMPJSC_setLicenseServerUrl (JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
 Callback from JS to set a license server URL. More...
 
void AAMP_JSController_finalize (JSObjectRef thisObj)
 Callback invoked when an object of AAMP_JSController is finalized. More...
 
static JSObjectRef AAMP_JSController_class_constructor (JSContextRef context, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
 callback invoked when an AAMP_JSController is used along with 'new' More...
 

Variables

static std::map< std::string, std::string > g_PageHttpHeaders
 
AAMP_JSController_globalController = NULL
 Global AAMP_JSController object.
 
static const JSStaticValue AAMP_JSController_static_values []
 Array containing the AAMP_JSController's statically declared value properties. More...
 
static const JSStaticFunction AAMP_JSController_static_methods []
 Array containing the AAMP_JSController's statically declared functions. More...
 
static const JSClassDefinition AAMP_JSController_class_def
 Structure contains properties and callbacks of AAMP_JSController object. More...
 

yes

JavaScript bindings for AAMP_JSController.

Definition in file jscontroller-jsbindings.cpp.

Function Documentation

◆ aamp_LoadJSController()

void aamp_LoadJSController ( JSGlobalContextRef  context)

Loads AAMP_JSController JS object into JS execution context.

Parameters
[in]contextJS execution context

Definition at line 524 of file jscontroller-jsbindings.cpp.

◆ aamp_UnloadJSController()

void aamp_UnloadJSController ( JSGlobalContextRef  context)

Removes the AAMP_JSController instance from JS context.

Parameters
[in]contextJS execution context

Definition at line 556 of file jscontroller-jsbindings.cpp.

◆ setAAMPPlayerInstance()

void setAAMPPlayerInstance ( PlayerInstanceAAMP aamp,
int  sessionID 
)

Set the instance of PlayerInstanceAAMP and session id.

Parameters
[in]aampinstance of PlayerInstanceAAMP
[in]sessionIDsession id

Definition at line 77 of file jscontroller-jsbindings.cpp.

◆ unsetAAMPPlayerInstance()

void unsetAAMPPlayerInstance ( PlayerInstanceAAMP aamp)

Remove the PlayerInstanceAAMP stored earlier.

Parameters
[in]aampinstance of PlayerInstanceAAMP to be removed

Definition at line 109 of file jscontroller-jsbindings.cpp.

◆ aamp_SetPageHttpHeaders()

void aamp_SetPageHttpHeaders ( const char *  headerJson)

Sets the custom http headers from received json string.

Parameters
[in]headerJsonhttp headers json in string format

Definition at line 465 of file jscontroller-jsbindings.cpp.

◆ aamp_ApplyPageHttpHeaders()

void aamp_ApplyPageHttpHeaders ( PlayerInstanceAAMP aampObject)

applies the parsed custom http headers into the aamp

Parameters
[in]aampObjectmain aamp object

Definition at line 511 of file jscontroller-jsbindings.cpp.

◆ AAMPJSC_getProperty_closedCaptionEnabled()

static JSValueRef AAMPJSC_getProperty_closedCaptionEnabled ( JSContextRef  context,
JSObjectRef  thisObject,
JSStringRef  propertyName,
JSValueRef *  exception 
)
static

Callback invoked from JS to get the CC enabled property.

Parameters
[in]contextJS execution context
[in]thisObjectJSObject to search for the property
[in]propertyNameJSString containing the name of the property to get
[out]exceptionpointer to a JSValueRef in which to return an exception, if any
Return values
property'svalue if object has the property, otherwise NULL

Definition at line 142 of file jscontroller-jsbindings.cpp.

◆ AAMPJSC_setProperty_closedCaptionEnabled()

static bool AAMPJSC_setProperty_closedCaptionEnabled ( JSContextRef  context,
JSObjectRef  thisObject,
JSStringRef  propertyName,
JSValueRef  value,
JSValueRef *  exception 
)
static

Callback invoked from JS to set the CC enabled property.

Parameters
[in]contextJS exception context
[in]thisObjectJSObject on which to set the property's value
[in]propertyNameJSString containing the name of the property to set
[in]valueJSValue to use as the property's value
[out]exceptionpointer to a JSValueRef in which to return an exception, if any
Return values
trueif the property was set, otherwise false

Definition at line 168 of file jscontroller-jsbindings.cpp.

◆ AAMPJSC_getProperty_aampSessionID()

static JSValueRef AAMPJSC_getProperty_aampSessionID ( JSContextRef  context,
JSObjectRef  thisObject,
JSStringRef  propertyName,
JSValueRef *  exception 
)
static

Callback invoked from JS to get the session id property.

Parameters
[in]contextJS execution context
[in]thisObjectJSObject to search for the property
[in]propertyNameJSString containing the name of the property to get
[out]exceptionpointer to a JSValueRef in which to return an exception, if any
Return values
property'svalue if object has the property, otherwise NULL

Definition at line 197 of file jscontroller-jsbindings.cpp.

◆ AAMPJSC_addEventListener()

static JSValueRef AAMPJSC_addEventListener ( JSContextRef  context,
JSObjectRef  function,
JSObjectRef  thisObject,
size_t  argumentCount,
const JSValueRef  arguments[],
JSValueRef *  exception 
)
static

Callback invoked from JS to add an event listener.

Parameters
[in]contextJS execution context
[in]functionJSObject that is the function being called
[in]thisObjectJSObject that is the 'this' variable in the function's scope
[in]argumentCountnumber of args
[in]arguments[]JSValue array of args
[out]exceptionpointer to a JSValueRef in which to return an exception, if any
Return values
JSValuethat is the function's return value

Definition at line 240 of file jscontroller-jsbindings.cpp.

◆ AAMPJSC_removeEventListener()

static JSValueRef AAMPJSC_removeEventListener ( JSContextRef  context,
JSObjectRef  function,
JSObjectRef  thisObject,
size_t  argumentCount,
const JSValueRef  arguments[],
JSValueRef *  exception 
)
static

Callback from JS to remove an event listener.

Parameters
[in]contextJS execution context
[in]functionJSObject that is the function being called
[in]thisObjectJSObject that is the 'this' variable in the function's scope
[in]argumentCountnumber of args
[in]arguments[]JSValue array of args
[out]exceptionpointer to a JSValueRef in which to return an exception, if any
Return values
JSValuethat is the function's return value

Definition at line 294 of file jscontroller-jsbindings.cpp.

◆ AAMPJSC_setLicenseServerUrl()

static JSValueRef AAMPJSC_setLicenseServerUrl ( JSContextRef  context,
JSObjectRef  function,
JSObjectRef  thisObject,
size_t  argumentCount,
const JSValueRef  arguments[],
JSValueRef *  exception 
)
static

Callback from JS to set a license server URL.

Parameters
[in]contextJS execution context
[in]functionJSObject that is the function being called
[in]thisObjectJSObject that is the 'this' variable in the function's scope
[in]argumentCountnumber of args
[in]arguments[]JSValue array of args
[out]exceptionpointer to a JSValueRef in which to return an exception, if any
Return values
JSValuethat is the function's return value

Definition at line 350 of file jscontroller-jsbindings.cpp.

◆ AAMP_JSController_finalize()

void AAMP_JSController_finalize ( JSObjectRef  thisObj)

Callback invoked when an object of AAMP_JSController is finalized.

Parameters
[in]thisObjJSObject being finalized

Definition at line 399 of file jscontroller-jsbindings.cpp.

◆ AAMP_JSController_class_constructor()

static JSObjectRef AAMP_JSController_class_constructor ( JSContextRef  context,
JSObjectRef  constructor,
size_t  argumentCount,
const JSValueRef  arguments[],
JSValueRef *  exception 
)
static

callback invoked when an AAMP_JSController is used along with 'new'

Parameters
[in]contextJS execution context
[in]constructorJSObject that is the constructor being called
[in]argumentCountnumber of args
[in]arguments[]JSValue array of args
[out]exceptionpointer to a JSValueRef in which to return an exception, if any
Return values
JSObjectthat is the constructor's return value

Definition at line 431 of file jscontroller-jsbindings.cpp.

Variable Documentation

◆ AAMP_JSController_static_values

const JSStaticValue AAMP_JSController_static_values[]
static
Initial value:
=
{
{"closedCaptionEnabled", AAMPJSC_getProperty_closedCaptionEnabled, AAMPJSC_setProperty_closedCaptionEnabled, kJSPropertyAttributeDontDelete },
{"aampSessionID", AAMPJSC_getProperty_aampSessionID, NULL, kJSPropertyAttributeDontDelete },
{NULL, NULL, NULL, 0}
}

Array containing the AAMP_JSController's statically declared value properties.

Definition at line 222 of file jscontroller-jsbindings.cpp.

◆ AAMP_JSController_static_methods

const JSStaticFunction AAMP_JSController_static_methods[]
static
Initial value:
=
{
{"addEventListener", AAMPJSC_addEventListener, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly},
{"removeEventListener", AAMPJSC_removeEventListener, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
{"setLicenseServerUrl", AAMPJSC_setLicenseServerUrl, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
{NULL, NULL, 0}
}

Array containing the AAMP_JSController's statically declared functions.

Definition at line 386 of file jscontroller-jsbindings.cpp.

◆ AAMP_JSController_class_def

const JSClassDefinition AAMP_JSController_class_def
static
Initial value:
=
{
0,
kJSClassAttributeNone,
"__AAMPJSController__class",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
}

Structure contains properties and callbacks of AAMP_JSController object.

Definition at line 440 of file jscontroller-jsbindings.cpp.

AAMPJSC_getProperty_closedCaptionEnabled
static JSValueRef AAMPJSC_getProperty_closedCaptionEnabled(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef *exception)
Callback invoked from JS to get the CC enabled property.
Definition: jscontroller-jsbindings.cpp:142
AAMP_JSController_static_values
static const JSStaticValue AAMP_JSController_static_values[]
Array containing the AAMP_JSController's statically declared value properties.
Definition: jscontroller-jsbindings.cpp:222
AAMP_JSController_static_methods
static const JSStaticFunction AAMP_JSController_static_methods[]
Array containing the AAMP_JSController's statically declared functions.
Definition: jscontroller-jsbindings.cpp:386
AAMP_JSController_class_constructor
static JSObjectRef AAMP_JSController_class_constructor(JSContextRef context, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
callback invoked when an AAMP_JSController is used along with 'new'
Definition: jscontroller-jsbindings.cpp:431
AAMPJSC_addEventListener
static JSValueRef AAMPJSC_addEventListener(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
Callback invoked from JS to add an event listener.
Definition: jscontroller-jsbindings.cpp:240
AAMPJSC_getProperty_aampSessionID
static JSValueRef AAMPJSC_getProperty_aampSessionID(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef *exception)
Callback invoked from JS to get the session id property.
Definition: jscontroller-jsbindings.cpp:197
AAMPJSC_setLicenseServerUrl
static JSValueRef AAMPJSC_setLicenseServerUrl(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
Callback from JS to set a license server URL.
Definition: jscontroller-jsbindings.cpp:350
AAMPJSC_removeEventListener
static JSValueRef AAMPJSC_removeEventListener(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
Callback from JS to remove an event listener.
Definition: jscontroller-jsbindings.cpp:294
AAMPJSC_setProperty_closedCaptionEnabled
static bool AAMPJSC_setProperty_closedCaptionEnabled(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef *exception)
Callback invoked from JS to set the CC enabled property.
Definition: jscontroller-jsbindings.cpp:168