API beta

xMediaNode Server Client

Overview

xMediaNode is a cross-platform, easy-to-use, modular product that allows you to receive media data from files, capture cards, and other software and hardware products, encode, decode, and transmit them over the internet using known standards (such as UDP, SRT, RTP, RTMP, HLS, etc.), including the ability to bypass NAT without the need to open ports. The product consists of the following components:

  • Signaling server (required to establish connections between nodes and centralized management)

  • Auth server (authorization server)

  • xMediaNode server (media data processing server)

  • xMediaNode client (management client)

All xMediaNode server instances under one license are interconnected via the Signaling server and can be managed using the xMediaNode client.

Installation

Download the xmedia-client source code

npm install "path_to_xmedia-client_folder"

Example of Using xMedia

To start broadcasting to NDI from a local file, you need to:

  • Run xnodeserver at the location where you have access to the media data you plan to work with under your license.

  • Import XMediaService into your project:

    import { XMediaService } from "xmedia-node";
  • Create an xMediaService object:

    const xMediaService = XMediaService();
  • Authenticate using your license details:

    xMediaService.login({
        username: user.username,
        password: user.password,
        signaling_url: user.signaling_url
    } as ILicense);
  • Get the list of locations (xNodeServer instances running under the same license):

    const locations = xMediaService.getLocations(onLocationsChanged); // you can pass a callback to be invoked when locations connect or disconnect
  • Create a source of type "file":

    const source = {
        id: string,           // unique ID
        direction: "src" | "dst", // source or destination flag
        name: string, // name
        busy: boolean, // orchestration parameter (initialize as false)
        chosen: boolean, // orchestration parameter (initialize as true)
        channelId: string, // unique stream ID
        type: endpointType, // source type
        props: currentSrcProps // source settings
    };

    Example:

    {
      "id": "4ec9b2b8-62d5-47f3-b8b8-1a3510b07a27",
      "direction": "src",
      "name": "Source 0",
      "busy": false,
      "chosen": true,
      "channelId": "00",
      "type": "File",
      "props": {
        "path": {
          "moduleData": {
            "type": "demux",
            "propName": "open_url"
          },
          "type": "STRING",
          "value": "/home/rtc/xsdk/ori.mp4"
        },
        "in": {
          "moduleData": {
            "type": "demux",
            "propName": "in"
          },
          "type": "NUMBER",
          "value": 0
        },
        "loop": {
          "moduleData": {
            "type": "demux",
            "propName": "loop"
          },
          "type": "BOOL",
          "value": true
        },
        "out": {
          "moduleData": {
            "type": "demux",
            "propName": "loop"
          },
          "type": "NUMBER",
          "value": 0
        }
      }
    }
  • Create a destination of type NDI:

    const destination = {
        id: "a7c3380a-41b6-4f17-a292-c03f37b10666",
        direction: "dst",
        name: "Destination 0",
        busy: false,
        chosen: true,
        channelId: "00",
        type: "NDI",
        props: {
            "streamName": {
                "moduleData": {
                    "type": "deviceRenderer",
                    "propName": "open_url"
                },
                "type": "STRING",
                "value": "ndi"
            }
        }
    };
  • Initialize the channel:

    const initChannelResult = await xMediaService.initChannel(
        locations[0], // target location with running xNodeServer
        channelId,
        [source],
        [destination]
    );

xMediaService API

All API methods return a response matching the IResponse interface, which contains one or two fields:

  • response (mandatory): if the request is processed without errors, this field contains the response data described in the table below. In case of an error, this field contains the error description.

  • failed (optional boolean): true if an error occurred.

Last updated