xMediaNode client API beta
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:
Signalling server (required to establish connections between nodes and centralized management)
Auth server (authorization server)
xMediaNode server (media data processing server)
xMediaNode client (management client)
Signalling server and Auth server located on Medialooks sites during a testing stages, lately we will be able to provide it for your on-premises installations via Docker.
All xMediaNode server instances under one licence are interconnected via the Signalling server and can be managed using the xMediaNode client.
Installation
npm install xmedia-node
Before we begin, you have to run the xMediaNode server with valid licence.
Imports
import React, { useMemo, useState } from 'react';
import {
XMediaService,
IChannel,
IDestination,
ISource,
EndpointDirection,
EndpointTypes,
EndpointPropsType,
ModuleTypes,
xServer
} from 'xmedia-node';
import { v4 as uuid } from 'uuid';
XMediaService
XMediaService
is the core object responsible for handling the interaction with the media server. It allows you to manage channels, sources, destinations, and other operations.
Methods:
Authentication:
login
andlogout
for user sessions.Channel Management: Methods to initialize, restore, start, and stop channels.
Configuration Retrieval:
getLocations
,getSourceOptions
, andgetDestinationOptions
for fetching available resources.Real-time Monitoring: Methods to subscribe/unsubscribe from preview frames and get channel state updates.
Logging:
setLogger
to configure logging for operations.
export interface IXMediaService {
login: (credentials: ILicense) => Promise<IResponse>;
logout: () => Promise<IResponse>;
getLocations: (onLocationsChange: (locations: xServer[]) => void, publisherId?: string) => Promise<IResponse>;
getSourceOptions: (location: xServer, endpointType: EndpointTypes, endpoint?: IEndpoint) => Promise<IResponse>;
getDestinationOptions: (location: xServer, endpointType: EndpointTypes, endpoint?: IEndpoint) => Promise<IResponse>;
initChannel: (location: xServer, channelId: string, sources: ISource[], destinations: IDestination[]) => Promise<IResponse>;
restoreChannel: (channel: IChannel) => Promise<IResponse>;
getChannelsList: (location: xServer) => Promise<IResponse>;
getChannelStat: (channel: IChannel, nodePath?: string[]) => Promise<IResponse>;
getModuleStat: (location: xServer, nodePath: string[]) => Promise<IResponse>;
getChannelState: (channel: IChannel, onChannelStateChanged?: (state: ChannelState) => void) => Promise<IResponse>;
clearChannel: (channel: IChannel) => Promise<IResponse>;
getLocationStruct: (location: xServer, path: string[]) => Promise<IResponse>;
clearLocationStruct: (location: xServer) => Promise<IResponse>;
startChannel: (channel: IChannel) => Promise<IResponse>;
stopChannel: (channel: IChannel) => Promise<IResponse>;
subscribeToPreview: (channel: IChannel, onFrameCb: (frameB64String: string) => void, previewParams?: MediaGetCommand) => Promise<IResponse>;
unSubscribeFromPreview: (channel: IChannel) => Promise<IResponse>;
setLogger: (logger: ILogger) => IResponse;
}
Channels
Channels represent a flow of media data that consists of one or more sources (inputs) and one or more destinations (outputs).
IChannel
Represents a media channel.
interface IChannel {
id: string;
struct: any; // Channel structure
}
Sources and Destinations:
Source: Represents an incoming media stream (e.g., video or audio).
ISource
Represents a media source.
interface ISource { id: string; direction: EndpointDirection; name: string; decodeMedia: boolean; selected: boolean; busy: boolean; channelIds: string[]; type: EndpointTypes; props: { sourceUrl: { moduleData: { type: ModuleTypes; propName: string }; type: EndpointPropsType; value: string }; container: { moduleData: { type: ModuleTypes; propName: string }; type: EndpointPropsType; value: string }; };
Destination: Represents an outgoing media stream (e.g., a broadcast to a specific URL).
IDestination
Represents a media destination.
interface IDestination { id: string; direction: EndpointDirection; name: string; selected: boolean; busy: boolean; channelIds: string[]; type: EndpointTypes; props: { audioEncoder: { moduleData: { type: ModuleTypes; propName: string }; type: EndpointPropsType; value: string }; videoEncoder: { moduleData: { type: ModuleTypes; propName: string }; type: EndpointPropsType; value: string }; container: { moduleData: { type: ModuleTypes; propName: string }; type: EndpointPropsType; value: string }; audioStreamsCount: { moduleData: { type: ModuleTypes; propName: string }; type: EndpointPropsType; value: number }; videoStreamsCount: { moduleData: { type: ModuleTypes; propName: string }; type: EndpointPropsType; value: number }; outputUrl: { moduleData: { type: ModuleTypes; propName: string }; type: EndpointPropsType; value: string }; }; }
ModuleTypes
Specify the input-module type for ISource or IDestination instances
enum ModuleTypes {
srtSource, // SRT Source module type
audioEncoder, // Audio encoder module type
videoEncoder, // Video encoder module type
demux, // Demuxing module type, required for transcoding without re-encoding
mux, // Muxing module type
srtDst // SRT Destination module type
}
EndpointType
Specify the end-module type for ISource or IDestination instances
export enum EndpointTypes {
NDI = "NDI",
SRT = "SRT",
UDP = "UDP",
BMD = "BMD",
File = "File",
SRT_ICE = "SRT_ICE", // special mode for SRT with ICE protocol on the top of if, no needs to open ports
}
ILicense
Represents the licensing credentials used for authentication.
typescriptCopy codeinterface ILicense {
signaling_url: string;
username: string;
password: string;
}
Last updated