RDK Documentation (Open Sourced RDK Components)
jsutils.h File Reference

JavaScript util functions for AAMP. More...

#include "main_aamp.h"
#include "AampUtils.h"
#include <JavaScriptCore/JavaScript.h>
#include <stdio.h>
#include <string.h>
#include <vector>
Include dependency graph for jsutils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PLAYER_ID_NA   -5
 
#define LOG_INFO(AAMP_JS_OBJECT, FORMAT, ...)   if(AAMP_JS_OBJECT && AAMP_JS_OBJECT->bInfoEnabled) { jsBindingLogprintf(( (NULL != AAMP_JS_OBJECT)? AAMP_JS_OBJECT->iPlayerId : PLAYER_ID_NA ),"INFO",__FUNCTION__,__LINE__,FORMAT, ##__VA_ARGS__); }
 
#define LOG_ERROR(AAMP_JS_OBJECT, FORMAT, ...)   jsBindingLogprintf(( (NULL != AAMP_JS_OBJECT)?AAMP_JS_OBJECT->iPlayerId : PLAYER_ID_NA ),"ERR",__FUNCTION__,__LINE__,FORMAT, ##__VA_ARGS__)
 
#define LOG_WARN(AAMP_JS_OBJECT, FORMAT, ...)   jsBindingLogprintf(((NULL != AAMP_JS_OBJECT)?AAMP_JS_OBJECT->iPlayerId : PLAYER_ID_NA ),"WARN",__FUNCTION__,__LINE__,FORMAT, ##__VA_ARGS__)
 
#define LOG_WARN_EX(FORMAT, ...)   jsBindingLogprintf(PLAYER_ID_NA,"WARN",__FUNCTION__,__LINE__,FORMAT, ##__VA_ARGS__)
 
#define LOG_ERROR_EX(FORMAT, ...)   jsBindingLogprintf(PLAYER_ID_NA,"ERR",__FUNCTION__,__LINE__,FORMAT, ##__VA_ARGS__)
 
#define LOG_TRACE(FORMAT, ...)
 
#define EXCEPTION_ERR_MSG_MAX_LEN   1024
 
#define MUTE_SUBTITLES_TRACKID   (-1) /* match priv_aamp.h */
 

Enumerations

enum  ErrorCode
 JavaScript error codes.
 

Functions

JSValueRef aamp_CStringToJSValue (JSContextRef context, const char *sz)
 Convert C string to JSString.
 
char * aamp_JSValueToCString (JSContextRef context, JSValueRef value, JSValueRef *exception)
 Convert JSString to C string.
 
char * aamp_JSValueToJSONCString (JSContextRef context, JSValueRef value, JSValueRef *exception)
 Convert JSString to JSON C string.
 
bool aamp_JSValueIsArray (JSContextRef context, JSValueRef value)
 Check if a JSValue object is array or not.
 
std::vector< std::string > aamp_StringArrayToCStringArray (JSContextRef context, JSValueRef arrayRef)
 Convert an array of JSString to an array of C strings.
 
JSValueRef aamp_GetException (JSContextRef context, ErrorCode error, const char *additionalInfo)
 Generate a JSValue object with the exception details.
 
AAMPEventType aamp_getEventTypeFromName (const char *szName)
 Convert JS event name to AAMP event type.
 
void aamp_dispatchEventToJS (JSContextRef context, JSObjectRef callback, JSObjectRef event)
 To dispatch a JS event.
 
AAMPEventType aampPlayer_getEventTypeFromName (const char *szName)
 Convert JS event name to AAMP event type (AAMPMediaPlayer)
 
const char * aampPlayer_getNameFromEventType (AAMPEventType type)
 Convert AAMP event type to JS event string (AAMPMediaPlayer)
 
JSObjectRef aamp_CreateTimedMetadataJSObject (JSContextRef context, long long timeMS, const char *szName, const char *szContent, const char *id, double durationMS)
 Create a TimedMetadata JS object with args passed. Sample input "#EXT-X-CUE:ID=eae90713-db8e,DURATION=30.063" Sample output {"time":62062,"duration":0,"name":"#EXT-X-CUE","content":"-X-CUE:ID=eae90713-db8e,DURATION=30.063","type":0,"metadata":{"ID":"eae90713-db8e","DURATION":"30.063"},"id":"eae90713-db8e"}.
 
void jsBindingLogprintf (int playerId, const char *levelstr, const char *functionName, int line, const char *format,...)
 Print logs to console / log file.
 

yes

JavaScript util functions for AAMP.

Definition in file jsutils.h.

Macro Definition Documentation

◆ LOG_INFO

#define LOG_INFO (   AAMP_JS_OBJECT,
  FORMAT,
  ... 
)    if(AAMP_JS_OBJECT && AAMP_JS_OBJECT->bInfoEnabled) { jsBindingLogprintf(( (NULL != AAMP_JS_OBJECT)? AAMP_JS_OBJECT->iPlayerId : PLAYER_ID_NA ),"INFO",__FUNCTION__,__LINE__,FORMAT, ##__VA_ARGS__); }

Defining LOG macros for logging with Playerid in consideration

Definition at line 39 of file jsutils.h.

◆ LOG_WARN_EX

#define LOG_WARN_EX (   FORMAT,
  ... 
)    jsBindingLogprintf(PLAYER_ID_NA,"WARN",__FUNCTION__,__LINE__,FORMAT, ##__VA_ARGS__)

Defining LOG macros where AAMP-JS object is not relevant

Definition at line 44 of file jsutils.h.