|
1 | 1 | # RdkNativeScript |
2 | 2 |
|
3 | | -rdkNativeScript is a JavaScript runtime component in the RDK middleware that enables native execution of JavaScript applications directly on RDK-V devices, outside of a full browser environment. It provides a lightweight, embeddable runtime that exposes device capabilities — such as media playback, networking, and display — to JavaScript applications through a set of controlled API bindings. The component is deployed as a Thunder plugin with the callsign `org.rdk.jsruntime` and can be cloned to create multiple independent runtime instances. |
| 3 | +rdkNativeScript is a JavaScript runtime component in the RDK middleware that enables native execution of JavaScript applications directly on RDKE/RDKV devices, outside of a full browser environment. It provides a lightweight, embeddable runtime that exposes device capabilities — such as media playback, networking, and display — to JavaScript applications through a set of controlled API bindings. The component is deployed as a Thunder plugin with the callsign `org.rdk.jsruntime` and can be cloned to create multiple independent runtime instances. |
4 | 4 |
|
5 | 5 | At the device level, rdkNativeScript allows non-browser JavaScript applications such as lightweight widgets and streaming clients to run with native-level access to media pipelines, WebSocket communication, and the Wayland display stack. It bridges the gap between JavaScript application logic and low-level device capabilities without requiring a full web engine. |
6 | 6 |
|
@@ -127,11 +127,11 @@ graph TD |
127 | 127 | - **Synchronization**: `NativeJSRenderer` protects the context map with `mUserMutex`. The console state uses `isProcessing_cv` (condition variable + mutex) for producer/consumer coordination of queued scripts. `JSRuntimeServer` protects the connection set with `mDataMutex`. `JSRuntimeClient` uses `mResponseMutex` and `mResponseCondition` with a 5-second wait-for-response timeout. |
128 | 128 | - **Async / Event Dispatch**: Key events from Essos are dispatched synchronously into the registered `JavaScriptKeyListener` (the active context). Timer callbacks and deferred JS execution are scheduled through the GLib main loop rather than blocking caller threads. |
129 | 129 |
|
130 | | -### RDK-V Platform and Integration Requirements |
| 130 | +### RDKE/RDKV Platform and Integration Requirements |
131 | 131 |
|
132 | 132 | - **Build Dependencies**: westeros, essos, rapidjson, rtcore, libuv, gstreamer1.0, uwebsockets, JavaScriptCore, websocketpp, cjson, boost, virtual/egl. When container widget support is enabled, dobby is additionally required. |
133 | 133 | - **Plugin Dependencies**: The AAMP media player library (`libaampjsbindings.so`) must be present at the target library path when dynamic AAMP bindings are enabled. |
134 | | -- **Device Services / HAL**: Essos HAL for Wayland compositor abstraction and keyboard input; GStreamer 1.0 for media pipeline initialization. |
| 134 | +- **HAL**: Essos HAL for Wayland compositor abstraction and keyboard input; GStreamer 1.0 for media pipeline initialization. |
135 | 135 | - **Systemd Services**: A running Wayland compositor (Westeros) must be available when Essos integration is enabled and a display is requested. |
136 | 136 |
|
137 | 137 | ### Module Settings |
@@ -281,18 +281,18 @@ sequenceDiagram |
281 | 281 |
|
282 | 282 | ### Interaction Matrix |
283 | 283 |
|
284 | | -| Target Component / Layer | Interaction Purpose | Key APIs / Topics | |
285 | | -| ------------------------- | ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | |
286 | | -| **Plugins** | | | |
287 | | -| `Thunder` | Plugin activation, JSON-RPC method dispatch, plugin cloning | `Controller.1.clone`, `Controller.1.activate`, `launchApplication` | |
288 | | -| **Device Services / HAL** | | | |
289 | | -| Essos | Wayland display initialization and keyboard input routing | `EssContextCreate`, `EssContextSetKeyListener`, `EssContextStart` | |
290 | | -| GStreamer | Media pipeline subsystem initialization required for AAMP playback | `gst_init()` | |
291 | | -| AAMP JS Bindings | Media playback control exposed as `AAMPMediaPlayer` in JavaScript | `AAMPPlayer_LoadJS()`, `AAMPPlayer_UnloadJS()` (dynamic: `libaampjsbindings.so`) | |
292 | | -| libcurl | Remote script file download by URL before evaluation | `curl_easy_perform`, write callbacks | |
293 | | -| **External Systems** | | | |
294 | | -| WebSocket Server (self) | External tools and container clients send application control commands | WebSocket JSON messages: `launchApplication`, `createApplication`, `terminateApplication` | |
295 | | -| Remote Inspector | JavaScript debugger connection over network | `JSRemoteInspectorStart()`, env `NATIVEJS_INSPECTOR_SERVER` | |
| 284 | +| Target Component / Layer | Interaction Purpose | Key APIs / Topics | |
| 285 | +| ------------------------ | ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | |
| 286 | +| **Plugins** | | | |
| 287 | +| `Thunder` | Plugin activation, JSON-RPC method dispatch, plugin cloning | `Controller.1.clone`, `Controller.1.activate`, `launchApplication` | |
| 288 | +| **HAL** | | | |
| 289 | +| Essos | Wayland display initialization and keyboard input routing | `EssCtxCreate`, `EssCtxSetKeyboardListener`, `EssCtxStart` | |
| 290 | +| GStreamer | Media pipeline subsystem initialization required for AAMP playback | `gst_init()` | |
| 291 | +| AAMP JS Bindings | Media playback control exposed as `AAMPMediaPlayer` in JavaScript | `AAMPPlayer_LoadJS()`, `AAMPPlayer_UnloadJS()` (dynamic: `libaampjsbindings.so`) | |
| 292 | +| libcurl | Remote script file download by URL before evaluation | `curl_easy_perform`, write callbacks | |
| 293 | +| **External Systems** | | | |
| 294 | +| WebSocket Server (self) | External tools and container clients send application control commands | WebSocket JSON messages: `launchApplication`, `createApplication`, `terminateApplication` | |
| 295 | +| Remote Inspector | JavaScript debugger connection over network | `JSRemoteInspectorStart()`, env `NATIVEJS_INSPECTOR_SERVER` | |
296 | 296 |
|
297 | 297 | ### Events Published |
298 | 298 |
|
@@ -324,14 +324,14 @@ sequenceDiagram |
324 | 324 |
|
325 | 325 | ## Implementation Details |
326 | 326 |
|
327 | | -### Major HAL APIs Integration |
| 327 | +### Key External API Integrations |
328 | 328 |
|
329 | | -| HAL / DS API | Purpose | Implementation File | |
| 329 | +| API | Purpose | Implementation File | |
330 | 330 | | ------------------------------------------- | ---------------------------------------------------------------------- | ------------------------------- | |
331 | | -| `EssContextCreate()` | Creates an Essos compositor context | `src/EssosInstance.cpp` | |
332 | | -| `EssContextSetTerminateListener()` | Registers a termination callback with the compositor | `src/EssosInstance.cpp` | |
333 | | -| `EssContextSetKeyListener()` | Registers a keyboard input callback for key press and release events | `src/EssosInstance.cpp` | |
334 | | -| `EssContextStart()` | Starts the Essos event loop, connecting to the Wayland display | `src/EssosInstance.cpp` | |
| 331 | +| `EssCtxCreate()` | Creates an Essos compositor context | `src/EssosInstance.cpp` | |
| 332 | +| `EssCtxSetTerminateListener()` | Registers a termination callback with the compositor | `src/EssosInstance.cpp` | |
| 333 | +| `EssCtxSetKeyboardListener()` | Registers a keyboard input callback for key press and release events | `src/EssosInstance.cpp` | |
| 334 | +| `EssCtxStart()` | Starts the Essos event loop, connecting to the Wayland display | `src/EssosInstance.cpp` | |
335 | 335 | | `gst_init()` | Initializes the GStreamer framework before any pipeline creation | `src/jsc/JavaScriptEngine.cpp` | |
336 | 336 | | `AAMPPlayer_LoadJS()` | Loads AAMP JS bindings into a JSC global context (static mode) | `src/jsc/JavaScriptContext.cpp` | |
337 | 337 | | `AAMPPlayer_UnloadJS()` | Unloads AAMP JS bindings from a JSC global context (static mode) | `src/jsc/JavaScriptContext.cpp` | |
|
0 commit comments