Fork me on GitHub

开源倾情奉献:基于.NET打造IP智能网络视频监控系统(四)服务端介绍

本文为 Dennis Gao 原创技术文章,发表于博客园博客,未经作者本人允许禁止任何形式的转载。

开源倾情奉献系列链接

服务端介绍

目前在服务端实现了 4 个 WCF 服务:

  • ServiceDiscovery(简称 SVD)
  • DeviceConnector(简称 DVC)
  • DeviceProfile(简称 DPS)
  • MediaPublisher(简称 MPS)

服务建议启动顺序

  1. SVD - 服务发现目前有时后启动不太稳定,暂时没有调试这个问题。
  2. DVC
  3. DPS
  4. MPS

Service Discovery Service

SVD 服务实现 WCF Discovery ,当有服务上线时接收注册,并通过服务接口实现向外提供检索指定类型服务的功能。

1   [ServiceContract(SessionMode = SessionMode.Allowed)]
2   [ManagedServiceContract]
3   public interface IServiceDiscoveryService
4   {
5     [FaultContract(typeof(ServiceDiscoveryServiceFault))]
6     [OperationContract]
7     GetServicesResponse GetServices(GetServicesRequest request);
8   }

Device Connector Service

DVC 服务负责提供接口创建、连接、保活摄像机设备。

  1. 使用 Gimela.Data.MagpieDatabase 文档数据库进行本地数据存取。
  2. 使用 Gimela.Media.Video 进行媒体流数据的建立。
  3. 使用 Gimela.Net.Rtp 进行媒体流的封装。
  4. 使用 Gimela.Net.Sockets 进行媒体流的传输。
  1   [ManagedServiceContractAttribute]
  2   [ServiceContract(SessionMode = SessionMode.Allowed, CallbackContract = typeof(IDeviceConnectorCallbackService))]
  3   public interface IDeviceConnectorService
  4   {
  5     /// <summary>
  6     /// 获取摄像机源列表
  7     /// </summary>
  8     /// <param name="request"></param>
  9     /// <returns></returns>
 10     [OperationContract]
 11     [FaultContract(typeof(DeviceConnectorServiceFault))]
 12     GetCameraFiltersResponse GetCameraFilters(GetCameraFiltersRequest request);
 13     
 14     /// <summary>
 15     /// 获取桌面源列表
 16     /// </summary>
 17     /// <param name="request"></param>
 18     /// <returns></returns>
 19     [OperationContract]
 20     [FaultContract(typeof(DeviceConnectorServiceFault))]
 21     GetDesktopFiltersResponse GetDesktopFilters(GetDesktopFiltersRequest request);
 22 
 23     /// <summary>
 24     /// 获取指定的摄像机
 25     /// </summary>
 26     /// <param name="request"></param>
 27     /// <returns></returns>
 28     [OperationContract]
 29     [FaultContract(typeof(DeviceConnectorServiceFault))]
 30     GetCameraResponse GetCamera(GetCameraRequest request);
 31 
 32     /// <summary>
 33     /// 获取全部的摄像机
 34     /// </summary>
 35     /// <param name="request"></param>
 36     /// <returns></returns>
 37     [OperationContract]
 38     [FaultContract(typeof(DeviceConnectorServiceFault))]
 39     GetCamerasResponse GetCameras(GetCamerasRequest request);
 40 
 41     /// <summary>
 42     /// 创建摄像机
 43     /// </summary>
 44     /// <param name="request"></param>
 45     /// <returns></returns>
 46     [OperationContract]
 47     [FaultContract(typeof(DeviceConnectorServiceFault))]
 48     CreateCameraResponse CreateCamera(CreateCameraRequest request);
 49 
 50     /// <summary>
 51     /// 修改摄像机
 52     /// </summary>
 53     /// <param name="request"></param>
 54     /// <returns></returns>
 55     [OperationContract]
 56     [FaultContract(typeof(DeviceConnectorServiceFault))]
 57     UpdateCameraResponse UpdateCamera(UpdateCameraRequest request);
 58 
 59     /// <summary>
 60     /// 删除摄像机
 61     /// </summary>
 62     /// <param name="request"></param>
 63     /// <returns></returns>
 64     [OperationContract]
 65     [FaultContract(typeof(DeviceConnectorServiceFault))]
 66     DeleteCameraResponse DeleteCamera(DeleteCameraRequest request);
 67 
 68     /// <summary>
 69     /// 检测摄像机
 70     /// </summary>
 71     /// <param name="request"></param>
 72     /// <returns></returns>
 73     [OperationContract]
 74     [FaultContract(typeof(DeviceConnectorServiceFault))]
 75     PingCameraResponse PingCamera(PingCameraRequest request);
 76 
 77     /// <summary>
 78     /// 获取摄像机最新的快照图像
 79     /// </summary>
 80     /// <param name="request"></param>
 81     /// <returns></returns>
 82     [OperationContract]
 83     [FaultContract(typeof(DeviceConnectorServiceFault))]
 84     GetCameraSnapshotResponse GetCameraSnapshot(GetCameraSnapshotRequest request);
 85 
 86     /// <summary>
 87     /// 获取已发布摄像机的信息
 88     /// </summary>
 89     /// <param name="request"></param>
 90     /// <returns></returns>
 91     [OperationContract]
 92     [FaultContract(typeof(DeviceConnectorServiceFault))]
 93     GetPublishedCamerasResponse GetPublishedCameras(GetPublishedCamerasRequest request);
 94 
 95     /// <summary>
 96     /// 发布摄像机视频流至指定接收器
 97     /// </summary>
 98     /// <param name="request"></param>
 99     /// <returns></returns>
100     [OperationContract]
101     [FaultContract(typeof(DeviceConnectorServiceFault))]
102     PublishCameraResponse PublishCamera(PublishCameraRequest request);
103 
104     /// <summary>
105     /// 取消发布摄像机视频流
106     /// </summary>
107     /// <param name="request"></param>
108     /// <returns></returns>
109     [OperationContract]
110     [FaultContract(typeof(DeviceConnectorServiceFault))]
111     UnpublishCameraResponse UnpublishCamera(UnpublishCameraRequest request);
112 
113     /// <summary>
114     /// 发布的摄像机保活机制
115     /// </summary>
116     /// <param name="request">摄像机保活机制请求消息</param>
117     /// <returns>摄像机保活机制响应消息</returns>
118     [OperationContract]
119     [FaultContract(typeof(DeviceConnectorServiceFault))]
120     KeepPublishedCameraAliveResponse KeepPublishedCameraAlive(KeepPublishedCameraAliveRequest request);
121   }
View Code

Device Profile Service

DPS 服务暴露简洁的接口,对外提供摄像机的基本信息,主要用以屏蔽或代理 DVC 服务。

 1   /// <summary>
 2   /// 设备信息服务接口
 3   /// </summary>
 4   [ManagedServiceContractAttribute]
 5   [ServiceContract(SessionMode = SessionMode.Allowed)]
 6   public interface IDeviceProfileService
 7   {
 8     /// <summary>
 9     /// 获取全部摄像机的信息
10     /// </summary>
11     /// <param name="request">获取全部摄像机的请求信息</param>
12     /// <returns>全部摄像机的响应信息</returns>
13     [OperationContract]
14     [FaultContract(typeof(DeviceProfileServiceFault))]
15     GetCamerasResponse GetCameras(GetCamerasRequest request);
16 
17     /// <summary>
18     /// 获取摄像机的信息
19     /// </summary>
20     /// <param name="request">获取摄像机的请求信息</param>
21     /// <returns>摄像机的响应信息</returns>
22     [OperationContract]
23     [FaultContract(typeof(DeviceProfileServiceFault))]
24     GetCameraResponse GetCamera(GetCameraRequest request);
25   }
View Code

Media Publisher Service

MPS 服务负责配置摄像机的媒体流的发布。

 1   [ManagedServiceContractAttribute]
 2   [ServiceContract(SessionMode = SessionMode.Allowed)]
 3   public interface IMediaPublisherService
 4   {
 5     /// <summary>
 6     /// 获取已发布摄像机的信息
 7     /// </summary>
 8     /// <param name="request"></param>
 9     /// <returns></returns>
10     [OperationContract]
11     [FaultContract(typeof(MediaPublisherServiceFault))]
12     GetPublishedCamerasResponse GetPublishedCameras(GetPublishedCamerasRequest request);
13 
14     /// <summary>
15     /// 发布摄像机视频流至指定接收器
16     /// </summary>
17     /// <param name="request"></param>
18     /// <returns></returns>
19     [OperationContract]
20     [FaultContract(typeof(MediaPublisherServiceFault))]
21     PublishCameraResponse PublishCamera(PublishCameraRequest request);
22 
23     /// <summary>
24     /// 取消发布摄像机视频流
25     /// </summary>
26     /// <param name="request"></param>
27     /// <returns></returns>
28     [OperationContract]
29     [FaultContract(typeof(MediaPublisherServiceFault))]
30     UnpublishCameraResponse UnpublishCamera(UnpublishCameraRequest request);
31   }

本文为 Dennis Gao 原创技术文章,发表于博客园博客,未经作者本人允许禁止任何形式的转载。

posted @ 2013-11-19 10:07 匠心十年 阅读(...) 评论(...) 编辑 收藏