Channels
A channel is an established connection between two VT modules.
channel_start
Start channel/output.
JSON request
example:
request
{
"type": "command",
"to": "WbaqzsMXqeQiwuoa", // manager id
"command": {
"command": "channel_start",
"channel": "mp://mplaylist _ML_UID:{42CE8DCF-14EC-00DA-9625-91768E3ED46E}", // channel name
"props": "mode='NDI'" // mode - output device name (only for receiver channel)
}
}
C# code example:
public void Start(string device = null)
{
var message = new
{
type = "command",
to = Manager.Id,
command = new
{
command = "channel_start",
channel = Name,
props = Manager.Name == "_VT_MNG_RCV_" ? $"mode='{device ?? "NDI"}'" : "",
},
};
Action<SocketIOResponse> callback = (response) => Console.WriteLine($"<-- response: {response}");
Client.Emit("request", message, callback);
}
channel stop
Stop channel/output.
JSON request
example:
request
{
"type": "command",
"to": "gBZX5HEiKGqmIMWR", // manager id
"command": {
"command": "channel_stop",
"channel": "mp://mplaylist", // channel name
"props": ""
}
}
C# code example:
public void Stop()
{
var message = new
{
type = "command",
to = Manager.Id,
command = new
{
command = "channel_stop",
channel = Name,
props = "",
},
};
Action<SocketIOResponse> callback = (response) => Console.WriteLine($"<-- response: {response}");
Client.Emit("request", message, callback);
}
message, callback);
}
channel_info_get
Get channel properties values (statistics).
JSON request
example:
request
{
"type": "command",
"to": "yPj3mDK3575JB0Qb", // manager id
"command": {
"command": "channel_info_get",
"channel": "mp://mplaylist", // channel name
"props": [ // props names
"type",
"video_format",
"video_fps",
"stat::status"
]
}
}
JSON callback
example:
callback
[
{
"channel": "mp://mplaylist",
"channelState": 3,
"channelType": 3,
"objectName": "VT_Publisher [hpH4R3SLtsNp5NCT]",
"previewURL": "[<https://vt08.medialooks.com:8080/CDqjLuf4CFwkkeW+>]",
"props": [ // props values
{
"type": "mp"
},
{
"video_format": "1920x1080@24.00p 48.0:4ch"
},
{
"video_fps": "24.00"
},
{
"stat::status": "(Web20:0) Ready for connect VT20 GW:3 W:0 C:0 "
}
],
"type": "info"
},
null
]
C# code example:
ppublic async Task<string> GetProps(string name)
{
var request = new
{
type = "command",
to = Manager.Id,
command = new
{
command = "channel_info_get",
channel = Name,
props = new string[] { name },
},
};
string value = null;
Action<SocketIOResponse> callback = (response) =>
{
Console.WriteLine($"<-- response: {response}");
try
{
value = response.GetValue(0)
.GetProperty("props")
.EnumerateArray()
.Select(i => i.EnumerateObject().FirstOrDefault())
.First()
.Value
.ToString();
}
catch (Exception e)
{
Console.WriteLine($"exception: {e.Message}");
}
};
Client.Emit("request", request, callback);
await Task.Delay(500);
return value;
}
channel_props_set
Set channel props values
JSON message
example:
message
{
"type": "command",
"to": "yPj3mDK3575JB0Qb", // manager id
"command": {
"command": "channel_props_set",
"channel": "mp://mplaylist", // channel name
"props": "video_bitrate=\\"15M\\"" // props name and new value
}
}
C# code example:
public void SetProps(string name, string value)
{
var message = new
{
type = "command",
to = Manager.Id,
command = new
{
command = "channel_props_set",
channel = Name,
props = $"{name}=\"{value}\"",
},
};
Client.Emit("message", message);
}
channel_props_remove
Remove channel props.
JSON message
example:
message
{
"type": "command",
"to": "yPj3mDK3575JB0Qb", // manager id
"command": {
"command": "channel_props_remove",
"channel": "mp://mplaylist", // channel name
"props": [ // props names
"test_pops"
]
}
}
C# code example:
public void RemoveProps(string name)
{
var message = new
{
type = "command",
to = Manager.Id,
command = new
{
command = "channel_props_remove",
channel = Name,
props = new string[] { name },
},
};
Client.Emit("message", message);
}
channel_frame_get
Get a picture from the channel.
JSON request
example:
request
{
"type": "command",
"to": "yPj3mDK3575JB0Qb", // manager id
"command": {
"command": "channel_frame_get",
"channel": "mp://mplaylist", // channel name
"maxWidth": 300, // frame size constraints
"maxHeight": 250
}
}
JSON callback
example:
callback
[
{
"binary": {
"type": "Buffer",
"data": [...] // byte array of frame image in JPG format
},
"payload": {
"channel": "USB Video Device",
"msec_updated": "0.087000",
"objectName": "VT_Publisher [VO0Ero58L6lA8iub]",
"type": "image",
"vt_getimage_msec": "922",
"vt_time": "1653593491843"
},
"to": [],
"type": "command"
},
null
]
C# code example:
public void GetFrame()
{
var request = new
{
type = "command",
to = Manager.Id,
command = new
{
command = "channel_frame_get",
channel = Name,
maxWidth = 300,
maxHeight = 250,
},
};
Action<SocketIOResponse> callback = (response) =>
{
Console.WriteLine($"<-- response: {response}");
try
{
if (response.GetValue(0).TryGetProperty("binary", out var binary))
{
byte[] buffer = binary.GetProperty("data")
.EnumerateArray()
.Select(i => i.GetByte())
.ToArray();
using var stream = new MemoryStream(buffer);
Application.Current.Dispatcher.Invoke(() =>
{
var window = new FrameWindow() { Owner = Application.Current.MainWindow };
var image = new BitmapImage();
image.BeginInit();
image.StreamSource = stream;
image.EndInit();
window.Image.Source = image;
window.ShowDialog();
});
}
}
catch (Exception e)
{
Console.WriteLine($"exception: {e.Message}");
}
};
Client.Emit("request", request, callback);
}
webguest:control:get
Get the Web Guest settings.
JSON request
example:
request
{
"type": "command",
"to": "YaQ2BMnUvaw7vzMJSI5SP", // channel peer id from "peer:id" props value
"command": {
"type": "webguest:control:get"
}
}
JSON callback
example:
callback
[
null,
{
"type": "command:response",
"command": {
"type": "webguest:control:get"
},
"response": [ // setting collection
{
"name": "Name", // display name (to show on UI)
"fieldName": "name", // inner field name
"value": "Guest1178" // value
},
{
"name": "Location",
"fieldName": "location",
"value": "Web"
},
{
"name": "Resolution",
"fieldName": "resolution",
"value": "640x480",
"options": [ // collection of possible values for selectors
{
"value": "320x240", // value
"label": "320x240" // label to show on UI
},
{
"value": "640x360",
"label": "640x360"
},
...
]
},
...
]
}
]
C# code example:
public async Task<string> GetWebGuestSettings()
{
string peerId = await GetProps("peer::id");
var request = new
{
type = "command",
to = peerId,
command = new
{
type = "webguest:control:get",
},
};
string settings = null;
Action<SocketIOResponse> callback = (response) =>
{
Console.WriteLine($"<-- response: {response}");
try
{
if (response.GetValue(0).GetString() == null)
{
settings = response.GetValue(1).GetProperty("response").GetRawText();
}
}
catch (Exception e)
{
Console.WriteLine($"exception: {e.Message}");
}
};
Client.Emit("request", request, callback);
await Task.Delay(200);
return settings;
}
webguest:control:set
Set the Web Guest settings.
JSON message example
message
{
"type": "command",
"to": "YaQ2BMnUvaw7vzMJSI5SP", // channel peer id from "peer:id" props value
"command": { // settings collection (see settings format in webguest:control:get)
"type": "webguest:control:set",
"settings": [
{
"name": "Name",
"fieldName": "name",
"value": "GuestTest"
},
{
"name": "Location",
"fieldName": "location",
"value": "Web"
},
{
"name": "Resolution",
"fieldName": "resolution",
"value": "640x480",
"options": [
{
"value": "320x240",
"label": "320x240"
},
{
"value": "640x360",
"label": "640x360"
},
{
"value": "640x480",
"label": "640x480"
},
...
]
},
...
]
}
}
Last updated