RDK Documentation (Open Sourced RDK Components)
jscontroller-jsbindings.cpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2018 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21  * @file jscontroller-jsbindings.cpp
22  * @brief JavaScript bindings for AAMP_JSController
23  */
24 
25 
26 #include <JavaScriptCore/JavaScript.h>
27 
28 #include "jsbindings.h"
29 #include "jseventlistener.h"
30 #include "jsutils.h"
31 #include "priv_aamp.h"
32 
33 #include <stdio.h>
34 #include <string.h>
35 
36 extern "C"
37 {
38 
39  void aamp_LoadJSController(JSGlobalContextRef context);
40 
41  void aamp_UnloadJSController(JSGlobalContextRef context);
42 
44 
46 
47  void aamp_SetPageHttpHeaders(const char* headers);
48 
50 }
51 //global variable to hold the custom http headers
52 static std::map<std::string, std::string> g_PageHttpHeaders;
53 
54 /**
55  * @struct AAMP_JSController
56  * @brief Data structure of AAMP_JSController JS object
57  */
59 {
60  AAMP_JSController() : _aampSessionID(0), _licenseServerUrl()
61  {}
62  int _aampSessionID;
63  std::string _licenseServerUrl;
64 };
65 
66 /**
67  * @brief Global AAMP_JSController object
68  */
70 
71 
72 /**
73  * @brief Set the instance of PlayerInstanceAAMP and session id
74  * @param[in] aamp instance of PlayerInstanceAAMP
75  * @param[in] sessionID session id
76  */
77 void setAAMPPlayerInstance(PlayerInstanceAAMP *aamp, int sessionID)
78 {
79  LOG_TRACE("setAAMPPlayerInstance (%p, id=%d)", aamp, sessionID);
80  if (_globalController == NULL)
81  {
82  return;
83  }
84 
85  _globalController->_aamp = aamp;
86  _globalController->_aampSessionID = sessionID;
87 
88  if (_globalController->_listeners.size() > 0)
89  {
90  std::multimap<AAMPEventType, void*>::iterator listenerIter;
91 
92  for (listenerIter = _globalController->_listeners.begin(); listenerIter != _globalController->_listeners.end(); listenerIter++)
93  {
94  AAMP_JSEventListener *listener = (AAMP_JSEventListener *)listenerIter->second;
95  _globalController->_aamp->AddEventListener(listenerIter->first, listener);
96  }
97  }
98  if (!_globalController->_licenseServerUrl.empty())
99  {
100  _globalController->_aamp->SetLicenseServerURL(_globalController->_licenseServerUrl.c_str());
101  }
102 }
103 
104 
105 /**
106  * @brief Remove the PlayerInstanceAAMP stored earlier
107  * @param[in] aamp instance of PlayerInstanceAAMP to be removed
108  */
110 {
111  if (_globalController == NULL || _globalController->_aamp != aamp)
112  {
113  return;
114  }
115 
116  if (_globalController->_listeners.size() > 0)
117  {
118  std::multimap<AAMPEventType, void*>::iterator listenerIter;
119 
120  for (listenerIter = _globalController->_listeners.begin(); listenerIter != _globalController->_listeners.end(); listenerIter++)
121  {
122  AAMP_JSEventListener *listener = (AAMP_JSEventListener *)listenerIter->second;
123  if (_globalController->_aamp)
124  {
125  _globalController->_aamp->RemoveEventListener(listenerIter->first, listener);
126  }
127  }
128  }
129  _globalController->_aamp = NULL;
130 }
131 
132 
133 
134 /**
135  * @brief Callback invoked from JS to get the CC enabled property
136  * @param[in] context JS execution context
137  * @param[in] thisObject JSObject to search for the property
138  * @param[in] propertyName JSString containing the name of the property to get
139  * @param[out] exception pointer to a JSValueRef in which to return an exception, if any
140  * @retval property's value if object has the property, otherwise NULL
141  */
142 static JSValueRef AAMPJSC_getProperty_closedCaptionEnabled(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
143 {
144 
145  LOG_TRACE("Enter");
146  AAMP_JSController* obj = (AAMP_JSController*) JSObjectGetPrivate(thisObject);
147 
148  if (obj == NULL)
149  {
150  *exception = aamp_GetException(context, AAMPJS_MISSING_OBJECT, "Can only call AAMP_JSController.closedCaptionEnabled on instances of AAMP_JSController");
151  return JSValueMakeUndefined(context);
152  }
153 
154  LOG_ERROR_EX("AAMP_JSController.closedCaptionEnabled has been deprecated!!");
155  return JSValueMakeBoolean(context, false);
156 }
157 
158 
159 /**
160  * @brief Callback invoked from JS to set the CC enabled property
161  * @param[in] context JS exception context
162  * @param[in] thisObject JSObject on which to set the property's value
163  * @param[in] propertyName JSString containing the name of the property to set
164  * @param[in] value JSValue to use as the property's value
165  * @param[out] exception pointer to a JSValueRef in which to return an exception, if any
166  * @retval true if the property was set, otherwise false
167  */
168 static bool AAMPJSC_setProperty_closedCaptionEnabled(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
169 {
170 
171  LOG_TRACE("Enter");
172  AAMP_JSController* obj = (AAMP_JSController*) JSObjectGetPrivate(thisObject);
173 
174  if (obj == NULL)
175  {
176  *exception = aamp_GetException(context, AAMPJS_MISSING_OBJECT, "Can only call AAMP_JSController.closedCaptionEnabled on instances of AAMP_JSController");
177  }
178  else if (!JSValueIsBoolean(context, value))
179  {
180  *exception = aamp_GetException(context, AAMPJS_INVALID_ARGUMENT, "Failed to execute 'AAMP_JSController.closedCaptionEnabled' - value passed is not boolean");
181 
182  }
183 
184  LOG_ERROR_EX("AAMP_JSController.closedCaptionEnabled has been deprecated!!");
185  return false;
186 }
187 
188 
189 /**
190  * @brief Callback invoked from JS to get the session id property
191  * @param[in] context JS execution context
192  * @param[in] thisObject JSObject to search for the property
193  * @param[in] propertyName JSString containing the name of the property to get
194  * @param[out] exception pointer to a JSValueRef in which to return an exception, if any
195  * @retval property's value if object has the property, otherwise NULL
196  */
197 static JSValueRef AAMPJSC_getProperty_aampSessionID(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
198 {
199 
200  LOG_TRACE("Enter");
201 
202 
203  AAMP_JSController *aampObj = (AAMP_JSController *) JSObjectGetPrivate(thisObject);
204 
205  if (aampObj == NULL)
206  {
207  return JSValueMakeUndefined(context);
208  }
209 
210  if (aampObj->_aampSessionID == 0)
211  {
212  return JSValueMakeUndefined(context);
213  }
214 
215  return JSValueMakeNumber(context, aampObj->_aampSessionID);
216 }
217 
218 
219 /**
220  * @brief Array containing the AAMP_JSController's statically declared value properties
221  */
222 static const JSStaticValue AAMP_JSController_static_values[] =
223 {
224  {"closedCaptionEnabled", AAMPJSC_getProperty_closedCaptionEnabled, AAMPJSC_setProperty_closedCaptionEnabled, kJSPropertyAttributeDontDelete },
225  {"aampSessionID", AAMPJSC_getProperty_aampSessionID, NULL, kJSPropertyAttributeDontDelete },
226  {NULL, NULL, NULL, 0}
227 };
228 
229 
230 /**
231  * @brief Callback invoked from JS to add an event listener
232  * @param[in] context JS execution context
233  * @param[in] function JSObject that is the function being called
234  * @param[in] thisObject JSObject that is the 'this' variable in the function's scope
235  * @param[in] argumentCount number of args
236  * @param[in] arguments[] JSValue array of args
237  * @param[out] exception pointer to a JSValueRef in which to return an exception, if any
238  * @retval JSValue that is the function's return value
239  */
240 static JSValueRef AAMPJSC_addEventListener(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
241 {
242  LOG_TRACE("Enter");
243  AAMP_JSController *aampObj = (AAMP_JSController *)JSObjectGetPrivate(thisObject);
244 
245  if (aampObj == NULL)
246  {
247  *exception = aamp_GetException(context, AAMPJS_MISSING_OBJECT, "Can only call AAMP_JSController.addEventListener on instances of AAMP_JSController");
248  return JSValueMakeUndefined(context);
249  }
250 
251  if (argumentCount >= 2)
252  {
253  char* type = aamp_JSValueToCString(context, arguments[0], NULL);
254  JSObjectRef callbackFunc = JSValueToObject(context, arguments[1], NULL);
255 
256  if ((callbackFunc != NULL) && JSObjectIsFunction(context, callbackFunc))
257  {
259  LOG_WARN_EX("eventType='%s', %d", type, eventType);
260  if ((eventType >= 0) && (eventType < AAMP_MAX_NUM_EVENTS))
261  {
262  AAMP_JSEventListener::AddEventListener(aampObj, eventType, callbackFunc);
263  }
264  }
265  else
266  {
267  LOG_ERROR_EX("callbackFunc = %p, JSObjectIsFunction(context, callbackFunc) is NULL", callbackFunc);
268  char errMsg[512];
269  memset(errMsg, '\0', 512);
270  snprintf(errMsg, 511, "Failed to execute addEventListener() for event %s - parameter 2 is not a function", type);
271  *exception = aamp_GetException(context, AAMPJS_INVALID_ARGUMENT, (const char*)errMsg);
272  }
273  SAFE_DELETE_ARRAY(type);
274  }
275  else
276  {
277  *exception = aamp_GetException(context, AAMPJS_INVALID_ARGUMENT, "Failed to execute 'AAMP_JSController.addEventListener' - 2 arguments required");
278  }
279 
280  return JSValueMakeUndefined(context);
281 }
282 
283 
284 /**
285  * @brief Callback from JS to remove an event listener
286  * @param[in] context JS execution context
287  * @param[in] function JSObject that is the function being called
288  * @param[in] thisObject JSObject that is the 'this' variable in the function's scope
289  * @param[in] argumentCount number of args
290  * @param[in] arguments[] JSValue array of args
291  * @param[out] exception pointer to a JSValueRef in which to return an exception, if any
292  * @retval JSValue that is the function's return value
293  */
294 static JSValueRef AAMPJSC_removeEventListener(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
295 {
296  LOG_TRACE("Enter");
297  AAMP_JSController *aampObj = (AAMP_JSController *)JSObjectGetPrivate(thisObject);
298  JSObjectRef callbackFunc;
299 
300  if (aampObj == NULL)
301  {
302  *exception = aamp_GetException(context, AAMPJS_MISSING_OBJECT, "Can only call AAMP_JSController.removeEventListener on instances of AAMP_JSController");
303  return JSValueMakeUndefined(context);
304  }
305 
306  if (argumentCount >= 2)
307  {
308  char* type = aamp_JSValueToCString(context, arguments[0], NULL);
309  JSObjectRef callbackFunc = JSValueToObject(context, arguments[1], NULL);
310 
311  if ((callbackFunc != NULL) && JSObjectIsFunction(context, callbackFunc))
312  {
314  LOG_TRACE("eventType='%s', %d",type, eventType);
315 
316  if ((eventType >= 0) && (eventType < AAMP_MAX_NUM_EVENTS))
317  {
318  AAMP_JSEventListener::RemoveEventListener(aampObj, eventType, callbackFunc);
319  }
320  }
321  else
322  {
323  LOG_ERROR_EX("callbackFunc = %p, JSObjectIsFunction(context, callbackFunc) is NULL", callbackFunc);
324  char errMsg[512];
325  memset(errMsg, '\0', 512);
326  snprintf(errMsg, 511, "Failed to execute removeEventListener() for event %s - parameter 2 is not a function", type);
327  *exception = aamp_GetException(context, AAMPJS_INVALID_ARGUMENT, (const char*)errMsg);
328  }
329  SAFE_DELETE_ARRAY(type);
330  }
331  else
332  {
333  *exception = aamp_GetException(context, AAMPJS_INVALID_ARGUMENT, "Failed to execute 'AAMP_JSController.removeEventListener' - 2 arguments required");
334  }
335 
336  return JSValueMakeUndefined(context);
337 }
338 
339 
340 /**
341  * @brief Callback from JS to set a license server URL
342  * @param[in] context JS execution context
343  * @param[in] function JSObject that is the function being called
344  * @param[in] thisObject JSObject that is the 'this' variable in the function's scope
345  * @param[in] argumentCount number of args
346  * @param[in] arguments[] JSValue array of args
347  * @param[out] exception pointer to a JSValueRef in which to return an exception, if any
348  * @retval JSValue that is the function's return value
349  */
350 static JSValueRef AAMPJSC_setLicenseServerUrl(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
351 {
352  LOG_TRACE("Enter");
353  AAMP_JSController *aampObj = (AAMP_JSController *)JSObjectGetPrivate(thisObject);
354 
355  if (aampObj == NULL)
356  {
357  *exception = aamp_GetException(context, AAMPJS_MISSING_OBJECT, "Can only call AAMP_JSController.setLicenseServerUrl on instances of AAMP_JSController");
358  return JSValueMakeUndefined(context);
359  }
360 
361  if (argumentCount == 1)
362  {
363  char *url = aamp_JSValueToCString(context, arguments[0], exception);
364  if (strlen(url) > 0)
365  {
366  aampObj->_licenseServerUrl = std::string(url);
367  if (aampObj->_aamp != NULL)
368  {
369  aampObj->_aamp->SetLicenseServerURL(aampObj->_licenseServerUrl.c_str());
370  }
371  }
372  SAFE_DELETE_ARRAY(url);
373  }
374  else
375  {
376  *exception = aamp_GetException(context, AAMPJS_INVALID_ARGUMENT, "Failed to execute 'AAMP_JSController.setLicenseServerURL' - 1 argument required");
377  }
378 
379  return JSValueMakeUndefined(context);
380 }
381 
382 
383 /**
384  * @brief Array containing the AAMP_JSController's statically declared functions
385  */
386 static const JSStaticFunction AAMP_JSController_static_methods[] =
387 {
388  {"addEventListener", AAMPJSC_addEventListener, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly},
389  {"removeEventListener", AAMPJSC_removeEventListener, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
390  {"setLicenseServerUrl", AAMPJSC_setLicenseServerUrl, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
391  {NULL, NULL, 0}
392 };
393 
394 
395 /**
396  * @brief Callback invoked when an object of AAMP_JSController is finalized
397  * @param[in] thisObj JSObject being finalized
398  */
399 void AAMP_JSController_finalize(JSObjectRef thisObj)
400 {
401 
402  LOG_WARN_EX("AAMP_finalize: object=%p", thisObj);
403  AAMP_JSController *aampObj = (AAMP_JSController*) JSObjectGetPrivate(thisObj);
404 
405  if (aampObj == NULL)
406  return;
407 
408  if (aampObj->_ctx != NULL)
409  {
410  if (aampObj->_listeners.size() > 0)
411  {
413  }
414  }
415 
416  JSObjectSetPrivate(thisObj, NULL);
417 
418  SAFE_DELETE(aampObj);
419 }
420 
421 
422 /**
423  * @brief callback invoked when an AAMP_JSController is used along with 'new'
424  * @param[in] context JS execution context
425  * @param[in] constructor JSObject that is the constructor being called
426  * @param[in] argumentCount number of args
427  * @param[in] arguments[] JSValue array of args
428  * @param[out] exception pointer to a JSValueRef in which to return an exception, if any
429  * @retval JSObject that is the constructor's return value
430  */
431 static JSObjectRef AAMP_JSController_class_constructor(JSContextRef context, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
432 {
433  *exception = aamp_GetException(context, AAMPJS_GENERIC_ERROR, "Cannot create an object of AAMP_JSController");
434  return NULL;
435 }
436 
437 /**
438  * @brief Structure contains properties and callbacks of AAMP_JSController object
439  */
440 static const JSClassDefinition AAMP_JSController_class_def =
441 {
442  0,
443  kJSClassAttributeNone,
444  "__AAMPJSController__class",
445  NULL,
448  NULL,
449  NULL, // _globalController is reused, so don't clean when one object goes out of scope
450  NULL,
451  NULL,
452  NULL,
453  NULL,
454  NULL,
455  NULL,
457  NULL,
458  NULL
459 };
460 
461 /**
462  * @brief Sets the custom http headers from received json string
463  * @param[in] headerJson http headers json in string format
464  */
465 void aamp_SetPageHttpHeaders(const char* headerJson)
466 {
467  //headerJson is expected to be in the format "[{\"name\":\"X-PRIVACY-SETTINGS\",\"value\":\"lmt=1,us_privacy=1-Y-\"}, {\"name\":\"abc\",\"value\":\"xyz\"}]"
468  g_PageHttpHeaders.clear();
469  if(nullptr != headerJson && '\0' != headerJson[0])
470  {
471  LOG_WARN_EX("aamp_SetPageHttpHeaders headerJson=%s", headerJson);
472  cJSON *parentJsonObj = cJSON_Parse(headerJson);
473  cJSON *jsonObj = nullptr;
474  if(nullptr != parentJsonObj)
475  {
476  jsonObj = parentJsonObj->child;
477  }
478 
479  while(nullptr != jsonObj)
480  {
481  cJSON *child = jsonObj->child;
482  std::string key = "";
483  std::string val = "";
484  while( nullptr != child )
485  {
486  if(strcmp (child->string,"name") == 0)
487  {
488  key = std::string(child->valuestring);
489  }
490  else if(strcmp (child->string,"value") == 0)
491  {
492  val = std::string(child->valuestring);
493  }
494  child = child->next;
495  }
496  if(!key.empty() && key == "X-PRIVACY-SETTINGS")/* RDK-35182: Condition is added to filter out header "X-PRIVACY-SETTINGS" since other headres like X-Forwarded-For/User-Agent/Accept-Language/ are appearing in case of x1 **/
497  {
498  //insert key value pairs one by one
499  g_PageHttpHeaders.insert(std::make_pair(key, val));
500  }
501  jsonObj = jsonObj->next;
502  }
503  if(parentJsonObj)
504  cJSON_Delete(parentJsonObj);
505  }
506 }
507 /**
508  * @brief applies the parsed custom http headers into the aamp
509  * @param[in] aampObject main aamp object
510  */
512 {
513  LOG_WARN_EX("aamp_ApplyPageHttpHeaders aampObject=%p", aampObject);
514  if(NULL != aampObject)
515  {
516  aampObject->AddPageHeaders(g_PageHttpHeaders);
517  }
518 }
519 
520 /**
521  * @brief Loads AAMP_JSController JS object into JS execution context
522  * @param[in] context JS execution context
523  */
524 void aamp_LoadJSController(JSGlobalContextRef context)
525 {
526 
527  LOG_WARN_EX("aamp_LoadJSController context=%p", context);
528  AAMP_JSController* aampObj = new AAMP_JSController();
529  aampObj->_ctx = context;
530  aampObj->_aampSessionID = 0;
531  aampObj->_listeners.clear();
532  aampObj->_licenseServerUrl = std::string();
533 
534  _globalController = aampObj;
535 
536  // DELIA-47534: For this ticket we have repurposed AAMP.version to return the UVE bindings version
537  // When at some point in future we deprecate legacy bindings or aamp_LoadJS() please don't forget
538  // to retain this support to avoid backward compatibility issues.
539  aamp_LoadJS(context, NULL);
540  AAMPPlayer_LoadJS(context);
541 
542  JSClassRef classDef = JSClassCreate(&AAMP_JSController_class_def);
543  JSObjectRef classObj = JSObjectMake(context, classDef, aampObj);
544  JSObjectRef globalObj = JSContextGetGlobalObject(context);
545  JSStringRef str = JSStringCreateWithUTF8CString("AAMP_JSController");
546  JSObjectSetProperty(context, globalObj, str, classObj, kJSPropertyAttributeReadOnly, NULL);
547  JSClassRelease(classDef);
548  JSStringRelease(str);
549 }
550 
551 
552 /**
553  * @brief Removes the AAMP_JSController instance from JS context
554  * @param[in] context JS execution context
555  */
556 void aamp_UnloadJSController(JSGlobalContextRef context)
557 {
558 
559  LOG_WARN_EX("aamp_UnloadJSController context=%p", context);
560 
561  aamp_UnloadJS(context);
562  AAMPPlayer_UnloadJS(context);
563 
564  JSObjectRef globalObj = JSContextGetGlobalObject(context);
565  JSStringRef str = JSStringCreateWithUTF8CString("AAMP_JSController");
566  JSValueRef aamp = JSObjectGetProperty(context, globalObj, str, NULL);
567 
568  if (aamp == NULL)
569  {
570  JSStringRelease(str);
571  return;
572  }
573 
574  JSObjectRef aampObj = JSValueToObject(context, aamp, NULL);
575  if (aampObj == NULL || JSObjectGetPrivate(aampObj) == NULL)
576  {
577  JSStringRelease(str);
578  return;
579  }
580 
582  _globalController = NULL;
583 
584  // Per comments in DELIA-48964, use JSObjectDeleteProperty instead of JSObjectSetProperty when trying to invalidate a read-only property
585  JSObjectDeleteProperty(context, globalObj, str, NULL);
586  JSStringRelease(str);
587 
588  LOG_TRACE("JSGarbageCollect(%p)", context);
589 
590 
591  JSGarbageCollect(context);
592 }
aamp_SetPageHttpHeaders
void aamp_SetPageHttpHeaders(const char *headers)
Sets the custom http headers from received json string.
Definition: jscontroller-jsbindings.cpp:465
aamp_GetException
JSValueRef aamp_GetException(JSContextRef context, ErrorCode error, const char *additionalInfo)
Generate a JSValue object with the exception details.
Definition: jsutils.cpp:278
aampPlayer_getEventTypeFromName
AAMPEventType aampPlayer_getEventTypeFromName(const char *szName)
Convert JS event name to AAMP event type (AAMPMediaPlayer)
Definition: jsutils.cpp:356
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_class_def
static const JSClassDefinition AAMP_JSController_class_def
Structure contains properties and callbacks of AAMP_JSController object.
Definition: jscontroller-jsbindings.cpp:440
aamp_UnloadJS
void aamp_UnloadJS(void *context)
Unload aamp JS bindings.
Definition: jsbindings.cpp:4709
PrivAAMPStruct_JS
Private data structure for JS binding object.
Definition: jsbindings.h:35
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
PlayerInstanceAAMP::RemoveEventListener
void RemoveEventListener(AAMPEventType eventType, EventListener *eventListener)
Remove event listener for eventType.
Definition: main_aamp.cpp:1493
AAMPPlayer_UnloadJS
void AAMPPlayer_UnloadJS(void *context)
Removes the AAMPMediaPlayer constructor from JS context.
Definition: jsmediaplayer.cpp:3906
jsutils.h
JavaScript util functions for AAMP.
PlayerInstanceAAMP::AddEventListener
void AddEventListener(AAMPEventType eventType, EventListener *eventListener)
Support multiple listeners for multiple event type.
Definition: main_aamp.cpp:1483
aamp_LoadJS
void aamp_LoadJS(void *context, void *playerInstanceAAMP)
Load aamp JS bindings.
Definition: jsbindings.cpp:4651
AAMP_JSEventListener
Event listener impl for AAMPMediaPlayer_JS object.
Definition: jseventlistener.h:37
AAMP_JSEventListener::RemoveEventListener
static void RemoveEventListener(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
Removes a JS listener for a particular event.
Definition: jseventlistener.cpp:1688
PlayerInstanceAAMP
Player interface class for the JS pluggin.
Definition: main_aamp.h:692
aamp_UnloadJSController
void aamp_UnloadJSController(JSGlobalContextRef context)
Removes the AAMP_JSController instance from JS context.
Definition: jscontroller-jsbindings.cpp:556
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
aamp_LoadJSController
void aamp_LoadJSController(JSGlobalContextRef context)
Loads AAMP_JSController JS object into JS execution context.
Definition: jscontroller-jsbindings.cpp:524
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
LOG_WARN_EX
#define LOG_WARN_EX(FORMAT,...)
Definition: jsutils.h:44
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
jseventlistener.h
Event Listner impl for AAMPMediaPlayer_JS object.
_globalController
AAMP_JSController * _globalController
Global AAMP_JSController object.
Definition: jscontroller-jsbindings.cpp:69
AAMP_JSEventListener::RemoveAllEventListener
static void RemoveAllEventListener(PrivAAMPStruct_JS *obj)
Remove all JS listeners registered.
Definition: jseventlistener.cpp:1721
aamp_JSValueToCString
char * aamp_JSValueToCString(JSContextRef context, JSValueRef value, JSValueRef *exception)
Convert JSString to C string.
Definition: jsutils.cpp:164
priv_aamp.h
Private functions and types used internally by AAMP.
unsetAAMPPlayerInstance
void unsetAAMPPlayerInstance(PlayerInstanceAAMP *)
Remove the PlayerInstanceAAMP stored earlier.
Definition: jscontroller-jsbindings.cpp:109
aamp_ApplyPageHttpHeaders
void aamp_ApplyPageHttpHeaders(PlayerInstanceAAMP *)
applies the parsed custom http headers into the aamp
Definition: jscontroller-jsbindings.cpp:511
AAMP_JSController
Data structure of AAMP_JSController JS object.
Definition: jscontroller-jsbindings.cpp:58
AAMPPlayer_LoadJS
void AAMPPlayer_LoadJS(void *context)
Loads AAMPMediaPlayer JS constructor into JS context.
Definition: jsmediaplayer.cpp:3877
AAMPEventType
AAMPEventType
Type of the events sending to the JSPP player.
Definition: AampEvent.h:44
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
AAMP_JSEventListener::AddEventListener
static void AddEventListener(PrivAAMPStruct_JS *obj, AAMPEventType type, JSObjectRef jsCallback)
Adds a JS function as listener for a particular event.
Definition: jseventlistener.cpp:1571
PlayerInstanceAAMP::SetLicenseServerURL
void SetLicenseServerURL(const char *url, DRMSystems type=eDRM_MAX_DRMSystems)
Set License Server URL.
Definition: main_aamp.cpp:1590
AAMP_JSController_finalize
void AAMP_JSController_finalize(JSObjectRef thisObj)
Callback invoked when an object of AAMP_JSController is finalized.
Definition: jscontroller-jsbindings.cpp:399
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
PlayerInstanceAAMP::AddPageHeaders
void AddPageHeaders(std::map< std::string, std::string > customHttpHeaders)
Applies the custom http headers for page (Injector bundle) received from the js layer.
Definition: main_aamp.cpp:1563
setAAMPPlayerInstance
void setAAMPPlayerInstance(PlayerInstanceAAMP *, int)
Set the instance of PlayerInstanceAAMP and session id.
Definition: jscontroller-jsbindings.cpp:77
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
LOG_TRACE
#define LOG_TRACE
Definition: rdk_debug_priv.c:83