STANAG Player  Version 1.11.8
Websockets interface

StPlayer goes beyond being a powerful STANAG player by offering advanced capabilities for automation and seamless integration with custom applications. One of its standout features is the inclusion of a websockets server, which serves as a robust communication channel between the player and external systems. By connecting to StPlayer's websockets server, users can harness the potential of automation by receiving real-time notifications about specific events. These events can be leveraged to trigger actions in custom applications, allowing for intelligent and dynamic control of media playback. Whether it's synchronizing media playback with other devices, integrating with home automation systems, or creating personalized workflows, StPlayer empowers users to tailor their media experience to their unique needs and seamlessly integrate it into their existing applications and environments.

StPlayer's websockets server uses a standard interface, enabling easy connection from desktop or web browser-based applications. Clients can simply specify the server's URL, consisting of an HTTP address, port, and service path, to establish a continuous connection. By staying connected to the endpoint, clients receive real-time events, ensuring an interactive and integrated media experience.

Configuring websockets interface

You can enable or disable the WebSocket interface using the corresponding checkbox, as well as set the service URL. Please note that in order to configure the URL, you should uncheck the checkbox first.

OptionsWebsopckets.png
Websockets interface

Service endpoints

ScreenCoord

screenCoord endpoint allows client to receive (in json format) the information on the mouse events. Two events are supported:

  • Mouse move
  • Mouse down

For example:

{
"event": "MouseMove",
"screenCoord": {
"X": 198.0,
"Y": 484.0,
"Width": 1254.0,
"Height": 707.33333333333337
},
"geoCoord": {
"Lat": -31.077997416828886,
"Lon": 150.4629037274957,
"Alt": "NaN"
},
"klvs": {
"2": 1283400393674348,
"65": 3,
"3": "test",
"10": "15HD BN-2T",
"5": 230.91417,
"6": 7.3512986,
"7": -0.2182073,
"11": "EOW",
"12": "Geodetic WGS84",
"13": -31.0436365758,
"14": 150.4924047228,
"15": 2651.85,
"16": 40.5127,
"17": 22.7887,
"18": 0.1406249498,
"19": -24.0828857124,
"20": 359.5324098317,
"21": 5836.0305,
"22": 4126.5,
"23": -31.073764572399998,
"24": 150.4489174813,
"25": 272.71,
"26": -0.0161184,
"27": 0.0002426,
"28": 0.0034814,
"29": -0.0182836,
"30": 0.0100757,
"31": 0.0041131,
"32": 0.0014191,
"33": 0.0122959,
"40": -31.073764572399998,
"41": 150.4489174813,
"42": 272.71,
"56": 47,
"57": 5329.0336,
"1": 54172
},
"time": "2010-09-02T04:06:33.674348Z",
"pcktNumber": 16
}
Note
To get the klvs, you must have the Recasting option enabled in your license. If it is impossible to calculate the geo coordinates, the geoCoord entry will not be reported.

event - event type - MouseMove or MouseDown. If you want to receive both events, set the WebSocketReportBothMouseDownAndMove to true in the C:\Program Files\ImpleoTV\StPlayer\Bin\x64\StPlayerApp.exe.config file. By default, only MouseDown events will be reported.

screenCoord includes the actual video window width and height + X and Y within this window. The current video resolution can be obtained via REST command.

Note, the information related to the Coordinates is only available with Overlay Tools option.

geoCoord - the geographic coordinates of the chosen point. Please be aware that geoCoords are computed using metadata (excluding DTM). If certain necessary data for the computation is missing, geo coordinates will not be calculated. Furthermore, the accuracy of these coordinates relies on the accuracy of the metadata. Hence, there is no "guarantee" of accuracy.

time - timestamp converted from the Klv time (tag2)

pcktNumber - klv packet number received.

lastPacketGeoJson

The lastPacketGeoJson endpoint enables the client to receive information about the most recently updated Klv Packet in geoJson format. The maximum rate at which the StPlayer will send the geoJson packets can be configured in the StPlayerApp.exe.config file using the parameter MaxLastPacketGeoJsonUpdateRate (in ms). This allows you to limit the frequency at which packets are sent.

Note, the information related to the Metadata recasting is only available with the Metadata Recaster option.

Exxample:

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
150.4909894385,
-31.0454143356
]
},
"properties": {
"description": " Mission Id: test",
"title": " Platform: 15HD BN-2T Mission Id: test",
"name": "Sensor",
"marker-symbol": "camera"
}
},
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
150.4909894385,
-31.0454143356
],
[
150.4476808153,
-31.0759667079
]
]
},
"properties": {
"name": "CameraToTargetLine",
"stroke-width": 1,
"stroke-opacity": 1,
"stroke": "#ff0000"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
150.43868321530002,
-31.1221084079
],
[
150.3933495153,
-31.074462907900003
],
[
150.4570836153,
-31.055513207900002
],
[
150.4728288153,
-31.0720550079
],
[
150.43868321530002,
-31.1221084079
]
]
]
},
"properties": {
"name": "Footprint",
"stroke": "#0000ff",
"stroke-width": 2,
"fill-opacity": 0
}
},
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
150.4909894385,
-31.0454143356
],
[
150.4476808153,
-31.0759667079
]
]
},
"properties": {
"name": "CameraToFrameCenter",
"stroke-width": 1,
"stroke-opacity": 1,
"stroke": "#0000ff"
}
}
]
}

Rendered GeoJSON Output:

geoJson.png
GeoJson

If it is impossible to calculate the geo coordinates, the GeoJson will be an empty JSON object.

Connecting to the services

Here is an example (in js) of how to connect to the service:

import WebSocket from 'ws';
// Create a new WebSocket connection to the screenCoord interface
const socket = new WebSocket('ws://localhost:4888/screenCoord');
// Or create a new WebSocket connection to the lastPacketGeoJson interface
//const socket = new WebSocket('ws://localhost:4888/lastPacketGeoJson');
// Event handler for successful connection
socket.on('open', () => {
console.log('Connected to the server');
});
// Event handler for incoming messages
socket.on('message', (message) => {
// Parse the message as JSON
try {
const json = JSON.parse(message);
console.log('Parsed JSON:', JSON.stringify(json));
} catch (error) {
console.error('Error parsing JSON:', error);
}
});
// Event handler for connection errors
socket.on('error', (error) => {
console.error('WebSocket error:', error);
});
// Event handler for connection close
socket.on('close', (event) => {
console.log('Connection closed:');
});
// Send a message to the server
function sendMessage(message) {
socket.send(message);
}

The demo project source can be found at /WebSocketClientDemo directory.

Untitled 1




 Copyright 2023,    IMPLEOTV SYSTEMS LTD