VideoFusion API
The VideoFusion API allows you to communicate with cameras via standard web protocols. These requests can be used to communicate with a third-party application. Below are the requests available alongside examples of their use.
Defining the Interface
Our first step will be to define the below interface.
[ServiceContract]
public interface IVideoFusionWebContract
{
[OperationContract]
[WebGet]
int Authenticate(string password);
[OperationContract]
[WebGet]
string NewVideoProviderConnection(int authenticationToken, string systemType, string address,
int port, string username, string password, string param1, string param2);
[OperationContract]
[WebGet]
bool RemoveVideoProviderConnection(int authenticationToken, string connectionId);
[OperationContract]
[WebGet]
bool DisplayLiveVideo(int authenticationToken, string connectionId, string cameraName, string cameraId, string monitorId, string panelId);
[OperationContract]
[WebGet]
List<VideoSourceConnectionInfo> GetVideoProviderConnections(int authenticationToken);
[OperationContract]
List<MonitorInfo> GetMonitors(int authenticationToken);
[OperationContract]
[WebGet]
string GetMonitorLayout(int authenticationToken, string monitorId);
[OperationContract]
[WebGet]
List<VideoSourceProvider> GetAvailableVideoProviders(int authenticationToken);
}
Connecting to the API Server
Using the above interface, we will need to connect to the API server as shown below.
public class VideoFusionCommunicationAdapter
{
private WebChannelFactory<IVideoFusionWebContract> wcf;
private IVideoFusionWebContract channel;
public void CreateChannel(string address)
{
this.wcf = new WebChannelFactory<IVideoFusionWebContract>(new Uri(address));
this.channel = wcf.CreateChannel();
}
}
}
Authenticate
The Authenticate request is used to authenticate the API user against the password configured in VideoFusion. The returned authentication token is used on all subsequent calls made.
Parameters
Paramter Name | Data Type | Description |
---|---|---|
password | String | The password to authenticate with VideoFusion. |
Returns
Returned Item | Data Type | Description |
---|---|---|
authenticationToken | Integer | The authentication token used on all subsequent calls. |
Example
public void Authenticate(string password)
{
WebChannelFactory<IVideoFusionWebContract> wcf =
new WebChannelFactory<IVideoFusionWebContract>(new Uri("127.0.0.1/VideoFusion"));
IVideoFusionWebContract channel = wcf.CreateChannel();
this.token = channel.Authenticate(password);
if (this.token < 1)
{
throw new PasswordIncorrectException("Password is incorrect");
}
}
}
NewVideoProviderConnection
The NewVideoProviderConnection request is used to create a new connection to a Video Provider.
Parameters
Paramter Name | Data Type | Description |
---|---|---|
authenticationToken | Integer | The authentication token retrieved from an Authenticate request. |
videoProviderKey | String | A key used to identify the video provider you are connecting to. |
address | String | The address of the server for the video provider. |
port | Integer | The port number for the video provider connection. |
username | String | This optional parameter is the username for authenticating with the video provider. |
password | String | This optional parameter is the password for authenticating with the video provider. |
param1 | String | This optional parameter is used to send additional information required for the video provider connection. |
param2 | String | This optional parameter is used to send additional information required for the video provider connection. |
Example
public string NewVideoConnection(string systemType, string address, int port, string username, string password, string customParameter1, string customParameter2)
{
WebChannelFactory<IVideoFusionWebContract> wcf =
new WebChannelFactory<IVideoFusionWebContract>(new Uri("127.0.0.1/VideoFusion"));
IVideoFusionWebContract channel = wcf.CreateChannel();
return channel.NewVideoProviderConnection(
token,
systemType,
address,
port,
username,
password,
customParameter1,
customParameter2);
}
}
RemoveVideoProviderConnection
The RemoveVideoProviderConnection request is used to remove the connection to a specified video provider.
Parameters
Parameter Name | Data Type | Description |
---|---|---|
authenticationToken | Integer | The token received from an Authenticate request. |
connectionId | Integer | The identifier of the video provider connection. |
Returns
This returns a boolean value of true on a successful removal, or false if the connection failed to be removed.
Example
public bool RemoveVideoConnection(string connectionId)
{
WebChannelFactory<IVideoFusionWebContract> wcf =
new WebChannelFactory<IVideoFusionWebContract>(new Uri("127.0.0.1/VideoFusion"));
IVideoFusionWebContract channel = wcf.CreateChannel();
return channel.RemoveVideoProviderConnection(token, connectionId);
}
}
DisplayLiveVideo
The DisplayLiveVideo request is used to display a video feed from a video provider on a specified monitor panel.
Parameters
Parameter Name | Data Type | Description |
---|---|---|
authenticationToken | Integer | The authentication token obtained from an Authenticate request. |
connectionId | Integer | The indentifier for the video provider connection. |
cameraName | String | This optional parameter is the name to be displayed on the video pane where the camera's video feed is being shown. |
cameraId | String | This optional parameter is the identifier used by the video provider. |
monitorId | String | The ID of the monitor to display the video feed on. |
panelId | Integer | The ID of the panel to display the video feed on. |
Example
public bool DisplayVideo(string connectionId, string cameraName, string cameraId, string monitorId, string panelId)
{
WebChannelFactory<IVideoFusionWebContract> wcf =
new WebChannelFactory<IVideoFusionWebContract>(new Uri("127.0.0.1/VideoFusion"));
IVideoFusionWebContract channel = wcf.CreateChannel();
return channel.DisplayLiveVideo(token, connectionId, cameraName, cameraId, monitorId, panelId);
}
}
GetVideoProviderConnections
The GetVideoProviderConnections request is used to obtain all connection instances to all connected video providers.
Parameters
Parameter Name | Data Type | Description |
---|---|---|
authenticationToken | Integer | The authentication token obtained from an Authenticate request. |
Returns
This request returns an XML formatted message containing zero or more objects using the below format.
Returned Item | Data Type | Description |
---|---|---|
ConnectionID | Integer | The identifier for the video provider connection. |
VideoProviderKey | String | The key used to identify the video provider. |
Address | String | The address used to connect to the video provider's server. |
CameraIds | Array of Strings | A list of all camera identifiers the video provider connection has access to. |
Example
public List<VideoSourceProvider> GetVideoSourceProviders()
{
WebChannelFactory<IVideoFusionWebContract> wcf =
new WebChannelFactory<IVideoFusionWebContract>(new Uri("127.0.0.1/VideoFusion"));
IVideoFusionWebContract channel = wcf.CreateChannel();
return channel.GetAvailableVideoProviders(token);
}
}
The above request would return a complex type interpreted in .NET using the following DataContract.
[DataContract]
public class VideoSourceConnectionInfo
{
public VideoSourceConnectionInfo(string connectionId, string systemType, string address, List<string> cameraIds)
{
this.ConnectionId = connectionId;
this.VideoProviderKey = systemType;
this.Address = address;
this.CameraIds = cameraIds;
}
[DataMember]
public string ConnectionId { get; private set; }
[DataMember]
public string VideoProviderKey { get; private set; }
[DataMember]
public string Address { get; private set; }
[DataMember]
public List<string> CameraIds { get; private set; }
}
GetMonitors
The GetMonitors request is used to retrieve all monitors VideoFusion has access to. The monitor identifiers can be used as parameters to the GetMonitorLayout request to retrieve this layout.
Parameters
Parameter Name | Data Type | Description |
---|---|---|
authenticationToken | Integer | The authenticationToken obtained from an Authenticate request. |
Returns
This request returns an XML formatted message containing zero or more objects of the below format.
Returned Item | Data Type | Description |
---|---|---|
ID | String | The monitor identifier. |
Name | String | The display name given to the monitor. |
Example
public List<MonitorInfo> GetMonitors()
{
WebChannelFactory<IVideoFusionWebContract> wcf =
new WebChannelFactory<IVideoFusionWebContract>(new Uri("127.0.0.1/VideoFusion"));
IVideoFusionWebContract channel = wcf.CreateChannel();
return channel.GetMonitors(token);
}
The above request returns the below complex type interpreted in .NET using the following DataContract.
[DataContract]
public class MonitorInfo
{
public MonitorInfo(string Id, string Name)
{
this.Id = Id;
this.Name = Name;
}
[DataMember]
public string Id { get; private set; }
[DataMember]
public string Name { get; private set; }
}
GetMonitorLayout
The GetMonitorLayout request is used to retrieve the layout of the provided monitor. This information can be used to display a video feed within a monitor pane.
Parameters
Parameter Name | Data Type | Description |
---|---|---|
authenticationToken | Integer | The authentication token returned from an Authenticate request. |
monitorId | Integer | The monitor identifier. |
Returns
Returned Item | Data Type | Description |
---|---|---|
Monitor Layout | String | The layout of the specified monitor. |
Example
public string GetMonitorLayout(string monitorId)
{
WebChannelFactory<IVideoFusionWebContract> wcf =
new WebChannelFactory<IVideoFusionWebContract>(new Uri("127.0.0.1/VideoFusion"));
IVideoFusionWebContract channel = wcf.CreateChannel();
return channel.GetMonitorLayout(token, monitorId);
}
GetAvailableVideoProviders
The GetAvailableVideoProviders request is used to retrieve the list of video providers currently available in VideoFusion.
Parameters
Parameter Name | Data Type | Description |
---|---|---|
authenticationToken | Integer | The authentication token retrieved from an Authenticate request. |
Returns
This request returns an XML formatted message containing zero or more objects in the below format.
Returned Item | Data Type | Description |
---|---|---|
Key | String | The key for the video provider. |
Description | String | The description for the video provider (e.g., Milestone XProtect) |
Examples
public List<VideoSourceProvider> GetVideoSourceProviders()
{
WebChannelFactory<IVideoFusionWebContract> wcf =
new WebChannelFactory<IVideoFusionWebContract>(new Uri("127.0.0.1/VideoFusion"));
IVideoFusionWebContract channel = wcf.CreateChannel();
return channel.GetAvailableVideoProviders(token);
}
The above example returns a complex type which is interpreted in .NET using the below DataContract.
[DataContract]
public class VideoSourceProvider
{
public VideoSourceProvider(string key, string description)
{
this.Key = key;
this.Description = description;
}
[DataMember]
public string Key { get; set; }
[DataMember]
public string Description { get; set; }
}
ClearPanel
The ClearPanel request is used to remove any displayed feeds from a specified VideoFusion panel.
Parameters
Parameter Name | Data Type | Description |
---|---|---|
authenticationToken | Integer | Am authentication token retrieved from an Authenticate request. |
monitorId | String | The identifier for the monitor containing the panel. |
panel | String | The identifier for the panel to be cleared. |
Returns
This request returns a Boolean value of true if successful, or false if unsuccessful.
Example
public string ClearPanel(string monitorId, string panelId)
{
WebChannelFactory<IVideoFusionWebContract> wcf =
new WebChannelFactory<IVideoFusionWebContract>(new Uri("127.0.0.1/VideoFusion"));
IVideoFusionWebContract channel = wcf.CreateChannel();
return channel.ClearPanel(token, monitorId, panelId);
}
SaveVideoFeeds
The SaveVideoFeeds request is used to save the video feeds to a local file in their respective monitor/pane configuration.
Parameters
Parameter Name | Data Type | Description |
---|---|---|
authenticationToken | Integer | The authentication token retrieved from an Authenticate request. |
filename | String | The name of the file to save to. |
Examples
public string SaveVideoFeeds(string filename)
{
WebChannelFactory<IVideoFusionWebContract> wcf =
new WebChannelFactory<IVideoFusionWebContract>(new Uri("127.0.0.1/VideoFusion"));
IVideoFusionWebContract channel = wcf.CreateChannel();
return channel.GetMonitorLayout(token, filename);
}
LoadVideoFeeds
The LoadVideoFeeds request is used to load a local file containing video feeds and assign them to panels automatically.
Parameters
Parameter Name | Data Type | Description |
---|---|---|
authenticationToken | Integer | The authentication token retrieved from an Authenticate request. |
filename | String | The name of the file containing the saved video feeds. |
Example
public string SaveVideoFeeds(string filename)
{
WebChannelFactory<IVideoFusionWebContract> wcf =
new WebChannelFactory<IVideoFusionWebContract>(new Uri("127.0.0.1/VideoFusion"));
IVideoFusionWebContract channel = wcf.CreateChannel();
return channel.LoadVideoFeeds(token, filename);
}