CN108810475A - A kind of Android video monitoring apparatus based on Onvif standards and Sip agreements - Google Patents
A kind of Android video monitoring apparatus based on Onvif standards and Sip agreements Download PDFInfo
- Publication number
- CN108810475A CN108810475A CN201810652642.8A CN201810652642A CN108810475A CN 108810475 A CN108810475 A CN 108810475A CN 201810652642 A CN201810652642 A CN 201810652642A CN 108810475 A CN108810475 A CN 108810475A
- Authority
- CN
- China
- Prior art keywords
- android
- video
- android device
- sip
- hard disk
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N7/00—Television systems
- H04N7/18—Closed-circuit television [CCTV] systems, i.e. systems in which the video signal is not broadcast
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/60—Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client
- H04N21/63—Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
- H04N21/643—Communication protocols
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N5/00—Details of television systems
- H04N5/76—Television signal recording
- H04N5/78—Television signal recording using magnetic recording
- H04N5/781—Television signal recording using magnetic recording on disks or drums
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Closed-Circuit Television Systems (AREA)
Abstract
一种基于Onvif标准及Sip协议的Android视频监控装置,硬盘录像机通过响应硬盘录像机模块与Android设备端建立连接;通过Web Service交互模块进行用户的鉴权认证和获取Rtsp的交互地址;通过Rtsp交互模块获取Android设备端的视频负载类型及视频解码信息;Android设备端通过视频模块将采集到的视频数据进行编码分包和发送给硬盘录像机或者其它Android用户端;Android设备端通过Sip响应模块与请求的Android用户端建立连接,然后通过Android视频模块发送Rtp包。本发明满足外出执行任务的人员和中心管理人员实时交流。
An Android video monitoring device based on the Onvif standard and the Sip protocol. The hard disk video recorder establishes a connection with the Android device by responding to the hard disk video recorder module; through the Web Service interactive module, user authentication is performed and the interactive address of Rtsp is obtained; through the Rtsp interactive module Obtain the video load type and video decoding information of the Android device; the Android device encodes and subpackages the collected video data through the video module and sends it to the hard disk video recorder or other Android clients; the Android device responds to the requested Android device through the Sip module. The client establishes a connection, and then sends Rtp packets through the Android video module. The invention satisfies the real-time communication between the personnel who go out to perform tasks and the central management personnel.
Description
技术领域technical field
本发明涉及视频监控领域,尤其涉及一种基于Onvif标准及Sip协议的Android视频采集、编码、传输的装置。The invention relates to the field of video monitoring, in particular to a device for collecting, encoding and transmitting Android video based on the Onvif standard and the Sip protocol.
背景技术Background technique
2008年5月,由安讯士(AXIS)联合博世(BOSCH)及索尼(SONY)公司三方宣布携手共同成立一个国际开放型网络视频产品标准网络接口开发论坛,取名为Onvif(Open NetworkVideo Interface Forum,开放型网络视频接口论坛),并以公开、开放的原则共同制定开放性行业标准。Onvif标准将为网络视频设备之间的信息交换定义通用协议,包括装置搜寻、实时视频、音频、元数据和控制信息等。In May 2008, Axis (AXIS), Bosch (BOSCH) and Sony (SONY) jointly announced the establishment of an international open network video product standard network interface development forum, named Onvif (Open NetworkVideo Interface Forum , Open Network Video Interface Forum), and jointly formulate open industry standards based on the principles of openness and openness. The Onvif standard will define a common protocol for information exchange between network video devices, including device discovery, real-time video, audio, metadata and control information.
Onvif规范描述了网络视频的模型、接口、数据类型以及数据交互的模式。并复用了一些现有的标准,如Web Service系列标准等。Onvif规范的目标是实现一个网络视频框架协议,使不同厂商所生产的网络视频产品(包括摄录前端、录像设备等)完全互通。The Onvif specification describes the model, interface, data type and data interaction mode of network video. And reuse some existing standards, such as Web Service series standards. The goal of the Onvif specification is to implement a network video framework protocol, so that network video products produced by different manufacturers (including recording front-ends, video equipment, etc.) are fully interoperable.
Sip(Session Initiation Protocol,会话发起协议)是由IETF(InternetEngineering Task Force,互联网工程任务组)提出的IP电话信令协议,是采用UTF-8字符集来进行编码的文本协议。Sip是一种通信协议,定义了如何在通信设备(计算机,电话,手机等)之间相互连接和信息交换,Sip也是一种信令控制协议,可以配置和管理任何类型的peer-to-peer通信会话,但并不关心媒体类型(语音、短信、游戏、视频等)。Sip协议具有良好的可扩展特性,可以方便地增加定义,嵌入各种用户终端并迅速实现新功能;有较强的互操作能力,良好的开放性。Sip (Session Initiation Protocol, Session Initiation Protocol) is an IP telephony signaling protocol proposed by IETF (Internet Engineering Task Force, Internet Engineering Task Force), and is a text protocol encoded using the UTF-8 character set. Sip is a communication protocol that defines how to connect and exchange information between communication devices (computers, phones, mobile phones, etc.), and Sip is also a signaling control protocol that can configure and manage any type of peer-to-peer Communication sessions, but don't care about the media type (voice, SMS, game, video, etc.). The Sip protocol has good scalability characteristics, can easily add definitions, embed various user terminals and quickly realize new functions; it has strong interoperability and good openness.
目前,国内大多数的摄像前端和硬盘录像机都满足Onvif规范,使得在不同厂商的硬盘录像机上可以存储不同厂商的摄像前端发送过来的视频。但是摄像前端由于受放置位置的影响,只能监控固定的范围,适用于监控学校,医院,道路,机场,政府等固定的场所。Android设备端虽然可以用Sip协议建立会话,然后进行实时视频通话,但是不能保存视频通话中的视频数据。At present, most domestic camera front-ends and hard disk video recorders meet the Onvif specification, so that videos sent by different manufacturers' camera front-ends can be stored on different manufacturers' hard disk video recorders. However, due to the influence of the location of the camera front end, it can only monitor a fixed range, which is suitable for monitoring fixed places such as schools, hospitals, roads, airports, and governments. Although the Android device can use the Sip protocol to establish a session and then make a real-time video call, it cannot save the video data in the video call.
发明内容Contents of the invention
为了解决现有的摄像前端无法满足外出执行任务的人员和中心管理人员实时交流,以及目前Android设备端视频不能将采集的视频内容存储到硬盘录像机中以便日后查看的问题,本发明提供一种基于Onvif标准及Sip协议的Android视频监控装置,能对Android设备端进行视频监控,同时又能将采集到的视频数据存储到硬盘录像机的装置。In order to solve the problem that the existing camera front end cannot meet the real-time communication between the personnel who go out to perform tasks and the center management personnel, and the current Android device video cannot store the collected video content in the hard disk video recorder for future viewing. The Android video surveillance device of Onvif standard and Sip protocol can perform video surveillance on the Android device side, and at the same time can store the collected video data to the device of the hard disk video recorder.
本发明解决其技术问题所采用的技术方案是:The technical solution adopted by the present invention to solve its technical problems is:
一种基于Onvif标准及Sip协议的Android视频监控装置,包括响应硬盘录像机模块、Web Service交互模块、Rtsp(Real Time Streaming Protocol,实时流传输协议)交互模块、Android视频模块、Sip注册模块和Sip响应模块;An Android video monitoring device based on the Onvif standard and the Sip protocol, including a response hard disk video recorder module, a Web Service interaction module, an Rtsp (Real Time Streaming Protocol, real-time streaming protocol) interaction module, an Android video module, a Sip registration module and a Sip response module;
硬盘录像机通过响应硬盘录像机模块与Android设备端建立连接;通过WebService交互模块进行用户的鉴权认证和获取Rtsp的交互地址;通过Rtsp交互模块获取Android设备端的视频负载类型及视频解码信息;Android设备端通过视频模块将采集到的视频数据进行编码分包和发送给硬盘录像机或者其它Android用户端;Android设备端通过Sip注册模块向Sip服务器注册,并按照20秒的间隔向Sip服务器发送心跳包进行保活;通过Sip响应模块与请求的Android用户端建立连接,然后通过Android视频模块发送Rtp包。The hard disk video recorder establishes a connection with the Android device by responding to the hard disk video recorder module; through the WebService interactive module, user authentication is performed and the interactive address of Rtsp is obtained; the video load type and video decoding information of the Android device is obtained through the Rtsp interactive module; Through the video module, the collected video data is encoded and subpackaged and sent to the hard disk video recorder or other Android clients; the Android device registers with the Sip server through the Sip registration module, and sends heartbeat packets to the Sip server at intervals of 20 seconds for protection. Live; establish a connection with the requested Android client through the Sip response module, and then send the Rtp packet through the Android video module.
进一步,在Android设备端开启一个监听硬盘录像机组播的地址和端口服务,当在硬盘录像机的网页客户端上点击搜索网络摄像机时,在同一个局域网内并且满足Onvif标准的Android设备就会收到硬盘录像机发起的Probe消息,获取到消息后要解析出消息体里面的Uuid,然后在回复的消息里携带这个Uuid和获取Android设备信息的Web Service地址,硬盘录像机在收到Android设备端的消息后校对发出的Uuid和收到的消息体里的Uuid,如果一致,则把Android设备端添加到摄像机列表中。Further, open an address and port service on the Android device side to listen to the broadcast of the DVR. When you click to search the network camera on the web client of the DVR, the Android device that is in the same LAN and meets the Onvif standard will receive the The Probe message initiated by the DVR needs to parse out the Uuid in the message body after getting the message, and then carry the Uuid and the Web Service address to obtain the Android device information in the reply message, and the DVR will proofread after receiving the message from the Android device. If the sent Uuid is consistent with the Uuid in the received message body, add the Android device to the camera list.
再进一步,硬盘录像机会根据搜索到的Android设备端IP信息,向Android设备端进行Web Service方法的调用,Web Service就相当于一个Http服务器,需要在收到Http消息时回复Http消息,但是由于Android设备的硬件资源有限,所以在Android设备端搭建一个轻量级Http服务器,因为Http的底层使用Socket进行通信,而Socket是一种轻量级的远程通信,这里选择将Socket消息封装Http消息进行发送。在Android设备端先进行用户认证,然后获取Android设备端的硬件信息和支持的视频分辨率信息,通过硬盘录像机和Android设备端进行交互的过程中的两次鉴权,提高Android设备端的安全性,Android设备端支持三种视频分辨率,以满足不同网络状况下的视频监控。Further, the hard disk video recorder will call the Web Service method to the Android device according to the searched IP information of the Android device. The hardware resources of the device are limited, so a lightweight Http server is built on the Android device side, because the underlying layer of Http uses Socket for communication, and Socket is a lightweight remote communication, here we choose to encapsulate Socket messages into Http messages for sending . First perform user authentication on the Android device, then obtain the hardware information and supported video resolution information of the Android device, and improve the security of the Android device through two authentications during the interaction between the DVR and the Android device. The device side supports three video resolutions to meet video surveillance under different network conditions.
更进一步,Android设备端开启摄像头进行视频数据的采集,对采集来的原始数据调用Android原生的Api进行H264硬编码,编码后的数据是H264裸数据,当编码后的一帧数据的长度大于Rtp包的最大长度,还要通过分片,封装成Rtp包。先将分片好的Rtp包缓存到队列里,一个线程往队列里面存Rtp包,一个线程按照一定的速率往队列里取Rtp包发送,来实现匀速发送Rtp包。Furthermore, the Android device side turns on the camera to collect video data, calls the Android native Api for H264 hard coding on the collected raw data, and the encoded data is H264 raw data. When the length of one frame of encoded data is greater than Rtp The maximum length of the packet must be fragmented and encapsulated into an Rtp packet. First cache the fragmented Rtp packets in the queue, one thread stores Rtp packets in the queue, and one thread fetches Rtp packets from the queue and sends them at a certain rate, so as to realize sending Rtp packets at a uniform speed.
当其它Android用户端来请求该Android设备端时,建立Sip会话,并从Sip会话中判断是否需要需要与硬盘录像机建立连接,如果需要建立连接,就开启Android的响应硬盘录像机模块,那么只要该Android设备端已经在硬盘录像机的摄像机列表中,该Android设备端在向发起请求的Android用户端传输视频数据的同时也会向硬盘录像机发送相同的数据,实现了Android设备端视频数据的存储以及Web客户端和Android用户端对Android设备端的视频监控。所述响应硬盘录像机模块,当硬盘录像机发起组播,搜索同个局域网中所有满足Onvif标准的网络摄像机时,满足Onvif标准的Android设备端(Android设备端为被请求视频的Android端)将会收到探测信息,并将设备的IP(Internet Protocol,网络之间互连的协议)等信息封装成符合Soap(Simple Object Access Protocol,简单对象访问协议)格式,通过Socket发送给硬盘录像机,此时,硬盘录像机即找到了满足Onvif标准的Android设备端;如果需要进行跨网段搜索Android设备端,则需要提供路由的支持。When other Android clients come to request the Android device, establish a Sip session, and judge from the Sip session whether a connection needs to be established with the DVR, and if a connection needs to be established, the Android response DVR module is opened, so as long as the Android The device is already in the camera list of the DVR. When the Android device transmits video data to the Android client that initiated the request, it will also send the same data to the DVR, realizing the storage of video data on the Android device and Web client The video monitoring of the Android device from the Android client and the Android client. Described response hard disk video recorder module, when hard disk video recorder initiates multicast, when searching for all network cameras that meet the Onvif standard in the same local area network, the Android device end (the Android device end being the Android end of the requested video) that meets the Onvif standard will receive Receive the detection information, and encapsulate the information such as the IP (Internet Protocol, the protocol for interconnection between networks) of the device into a format that conforms to the Soap (Simple Object Access Protocol, Simple Object Access Protocol), and send it to the hard disk video recorder through the Socket. At this time, The hard disk video recorder has found the Android device that meets the Onvif standard; if you need to search for the Android device across network segments, you need to provide routing support.
硬盘录像机会根据搜索到的Android设备端IP信息,向Android设备端进行WebService方法的调用,这里先在进行Android设备端的用户认证,然后会获取Android设备端的硬件信息和支持的视频分辨率信息。The hard disk video recorder will call the WebService method to the Android device according to the searched IP information of the Android device. Here, the user authentication of the Android device is performed first, and then the hardware information and the supported video resolution information of the Android device are obtained.
硬盘录像机会和Android设备端进行Rtsp交互,这里会先向Android设备进行用户认证,然后获取Android设备端视频的负载类型、数据传输方式、视频流的地址和端口及Android设备端视频的SSRC(Synchronization source,同步源)标示信息;同时,Android设备端会获取到应该往硬盘录像机哪个端口发送的信息。The hard disk video recorder will interact with the Android device through Rtsp. Here, it will first authenticate the user to the Android device, and then obtain the load type, data transmission method, address and port of the video stream on the Android device, and the SSRC (Synchronization source, synchronization source) to indicate the information; at the same time, the Android device will get the information to which port the DVR should send.
Android设备端在收到硬盘录像机发来的视频播放信息时,就会打开Android摄像头,将摄像头采集到的数据进行H264的编码,然后进行Rtp(Real-time TransportProtocol,实时传输协议)封装,将封装好的Rtp包放入缓存,然后按一定的速率向硬盘录像机发送。When the Android device receives the video playback information sent by the hard disk video recorder, it will open the Android camera, encode the data collected by the camera in H264, and then perform Rtp (Real-time Transport Protocol, real-time transport protocol) encapsulation. Good Rtp packets are put into the cache, and then sent to the hard disk video recorder at a certain rate.
优选的,Android设备端通过Sip注册模块向Sip服务器注册,注册成功以后就向Sip服务器发送心跳消息,Sip服务器就知道哪些Android设备端在线,这样当其它Android用户端(Android用户端为请求视频的Android端)来向该Android设备端请求视频时,其它Android用户端先把请求视频消息发送给Sip服务器,Sip服务器检测到被请求的Android设备端在线,就将消息转发到该Android设备端,这样Android设备端与Android用户端之间建立了Sip会话,Android设备端从Sip消息中判断是否需要与硬盘录像机建立连接,如果需要建立连接,就开启Android设备端的响应硬盘录像机模块,那么只要该Android设备端已经在硬盘录像机的摄像机列表中,该Android设备端在向发起请求的Android用户端传输视频数据的同时也会向硬盘录像机发送相同的数据,这样就实现了Android设备端与用户端之间实时视频和视频数据的保存。Preferably, the Android device end registers to the Sip server by the Sip registration module, and after the registration is successful, it sends a heartbeat message to the Sip server, and the Sip server just knows which Android device ends are online, so that when other Android clients (Android clients are requesting video) Android end) to this Android device end when requesting video, other Android client ends send request video message to Sip server first, and Sip server detects that the requested Android device end is online, and just forwards the message to this Android device end, like this A Sip session is established between the Android device and the Android client. The Android device judges from the Sip message whether it needs to establish a connection with the DVR. If it needs to establish a connection, it opens the response DVR module of the Android device. The device is already in the camera list of the DVR, and the Android device will also send the same data to the DVR while transmitting the video data to the Android client that initiates the request, thus realizing the real-time connection between the Android device and the client. Preservation of video and video data.
本发明的技术构思为:Android作为一种Linux自由及开源代码的操作系统为定制化了提供了良好的基础,而且随着移动网络的发展和移动终端的普及使得在移动网络上的远距离视频通信成为可能。外出执行任务的人员会随身携带手机,这时中心管理系统可以利用手机进行远程指挥调度或对现场的情况进行查看,做出相应的措施。同时,视频信息会保存在硬盘录像机上以便日后的查看。硬盘录像机和Android设备的结合既满足了便携性的要求又能和摄像机一样存储在硬盘录像机中,并且可以用硬盘录像机的网页客户端直接查看Android设备视频,具有较高的工程意义和市场价值。The technical idea of the present invention is: Android, as a Linux free and open source operating system, provides a good foundation for customization, and with the development of mobile networks and the popularization of mobile terminals, remote video on mobile networks Communication becomes possible. Personnel who go out to perform tasks will carry their mobile phones with them. At this time, the center management system can use the mobile phone to conduct remote command and dispatch or check the situation on the spot and take corresponding measures. At the same time, the video information will be saved on the hard disk video recorder for future viewing. The combination of DVR and Android device not only meets the requirements of portability, but also can be stored in the DVR like the camera, and the video of the Android device can be directly viewed with the web client of the DVR, which has high engineering significance and market value.
本发明的Android监控前端装置,它支持三种不同的分辨率数字码流,分别是720P(1280*720),D1(720*576),CIF(352*288)三种分辨率,这样可以根据Android设备所处的网络质量来选择不同的分辨率。The Android monitoring front-end device of the present invention supports three different resolution digital code streams, which are respectively 720P (1280*720), D1 (720*576), and three resolutions of CIF (352*288). Choose different resolutions according to the network quality of the Android device.
本发明的有益效果主要表现在:(1)Android设备满足Onvif标准即可以在监控网络摄像机的终端上直接查看Android设备的视频,并存储到硬盘录像机中。(3)Android设备使用Sip协议可以在Android设备端之间进行点对点的视频通话。(2)多种分辨率的数字码流可以满足不同网络状况下的视频查看。The beneficial effects of the present invention are mainly manifested in: (1) the Android device meets the Onvif standard, that is, the video of the Android device can be directly viewed on the terminal of the monitoring network camera, and stored in the hard disk video recorder. (3) Android devices use the Sip protocol to conduct point-to-point video calls between Android devices. (2) Digital code streams with multiple resolutions can satisfy video viewing under different network conditions.
附图说明Description of drawings
图1是基于Onvif标准及Sip协议的Android视频监控装置的软件框架设计图。Figure 1 is a software framework design diagram of an Android video surveillance device based on the Onvif standard and the Sip protocol.
图2是响应硬盘录像机模块。Figure 2 is the response to the DVR module.
图3是Web service交互模块。Figure 3 is the Web service interaction module.
图4是RTSP交互模块。Figure 4 is the RTSP interactive module.
图5是Android视频模块。Figure 5 is the Android video module.
图6是Sip注册模块。Figure 6 is the Sip registration module.
图7是Sip响应模块。Figure 7 is a Sip response module.
具体实施方式Detailed ways
下面结合附图对本发明作进一步描述。The present invention will be further described below in conjunction with the accompanying drawings.
参照图1,一种基于Onvif标准及Sip协议的Android视频监控装置,所述装置为两路视频发送装置,包括响应硬盘录像机模块、Web Service交互模块、Rtsp交互模块、Android视频模块、Sip注册模块和Sip响应模块;With reference to Fig. 1, a kind of Android video monitoring device based on Onvif standard and Sip agreement, described device is two-way video sending device, comprises response hard disk video recorder module, Web Service interactive module, Rtsp interactive module, Android video module, Sip registration module and Sip response module;
硬盘录像机通过响应硬盘录像机模块与Android设备端建立连接;通过WebService交互模块进行用户的鉴权认证和获取Rtsp的交互地址;通过Rtsp交互模块获取Android设备端的视频负载类型及视频解码信息;Android设备端通过视频模块将采集到的视频数据进行编码分包和发送给硬盘录像机或者其它Android用户端;Android设备端通过Sip注册模块向Sip服务器注册,并按照20秒的间隔向Sip服务器发送心跳包进行保活;通过Sip响应模块与请求的Android用户端建立连接,然后通过Android视频模块发送Rtp包。进一步,在Android设备端开启一个监听硬盘录像机组播的地址和端口服务,当在硬盘录像机的网页客户端上点击搜索网络摄像机时,在同一个局域网内并且满足Onvif标准的Android设备就会收到硬盘录像机发起的Probe消息,获取到消息后要解析出消息体里面的Uuid,然后在回复的消息里携带这个Uuid和获取Android设备信息的Web Service地址,硬盘录像机在收到Android设备端的消息后校对发出的Uuid和收到的消息体里的Uuid,如果一致,则把Android设备端添加到摄像机列表中。The hard disk video recorder establishes a connection with the Android device by responding to the hard disk video recorder module; through the WebService interactive module, user authentication is performed and the interactive address of Rtsp is obtained; the video load type and video decoding information of the Android device is obtained through the Rtsp interactive module; Through the video module, the collected video data is encoded and subpackaged and sent to the hard disk video recorder or other Android clients; the Android device registers with the Sip server through the Sip registration module, and sends heartbeat packets to the Sip server at intervals of 20 seconds for protection. Live; establish a connection with the requested Android client through the Sip response module, and then send the Rtp packet through the Android video module. Further, open an address and port service on the Android device side to listen to the broadcast of the DVR. When you click to search the network camera on the web client of the DVR, the Android device that is in the same LAN and meets the Onvif standard will receive the The Probe message initiated by the DVR needs to parse out the Uuid in the message body after getting the message, and then carry the Uuid and the Web Service address to obtain the Android device information in the reply message, and the DVR will proofread after receiving the message from the Android device. If the sent Uuid is consistent with the Uuid in the received message body, add the Android device to the camera list.
再进一步,硬盘录像机会根据搜索到的Android设备端IP信息,向Android设备端进行Web Service方法的调用,Web Service就相当于一个Http服务器,需要在收到Http消息时回复Http消息,但是由于Android设备的硬件资源有限,所以在Android设备端搭建一个轻量级Http服务器,因为Http的底层使用Socket进行通信,而Socket是一种轻量级的远程通信,这里选择将Socket消息封装Http消息进行发送。在Android设备端先进行用户认证,然后获取Android设备端的硬件信息和支持的视频分辨率信息,通过硬盘录像机和Android设备端进行交互的过程中的两次鉴权,提高Android设备端的安全性,Android设备端支持三种视频分辨率,以满足不同网络状况下的视频监控。Further, the hard disk video recorder will call the Web Service method to the Android device according to the searched IP information of the Android device. The hardware resources of the device are limited, so a lightweight Http server is built on the Android device side, because the underlying layer of Http uses Socket for communication, and Socket is a lightweight remote communication, here we choose to encapsulate Socket messages into Http messages for sending . First perform user authentication on the Android device, then obtain the hardware information and supported video resolution information of the Android device, and improve the security of the Android device through two authentications during the interaction between the DVR and the Android device. The device side supports three video resolutions to meet video surveillance under different network conditions.
更进一步,Android设备端开启摄像头进行视频数据的采集,对采集来的原始数据调用Android原生的Api进行H264硬编码,编码后的数据是H264裸数据,当编码后的一帧数据的长度大于Rtp包的最大长度,还要通过分片,封装成Rtp包。先将分片好的Rtp包缓存到队列里,一个线程往队列里面存Rtp包,一个线程按照一定的速率往队列里取Rtp包发送,来实现匀速发送Rtp包。Furthermore, the Android device side turns on the camera to collect video data, calls the Android native Api for H264 hard coding on the collected raw data, and the encoded data is H264 raw data. When the length of one frame of encoded data is greater than Rtp The maximum length of the packet must be fragmented and encapsulated into an Rtp packet. First cache the fragmented Rtp packets in the queue, one thread stores Rtp packets in the queue, and one thread fetches Rtp packets from the queue and sends them at a certain rate, so as to realize sending Rtp packets at a uniform speed.
当其它Android用户端来请求该Android设备端时,建立Sip会话,并从Sip会话中判断是否需要需要与硬盘录像机建立连接,如果需要建立连接,就开启Android的响应硬盘录像机模块,那么只要该Android设备端已经在硬盘录像机的摄像机列表中,该Android设备端在向发起请求的Android用户端传输视频数据的同时也会向硬盘录像机发送相同的数据,实现了Android设备端视频数据的存储以及Web客户端和Android用户端对Android设备端的视频监控。When other Android clients come to request the Android device, establish a Sip session, and judge from the Sip session whether a connection needs to be established with the DVR, and if a connection needs to be established, the Android response DVR module is opened, so as long as the Android The device is already in the camera list of the DVR. When the Android device transmits video data to the Android client that initiated the request, it will also send the same data to the DVR, realizing the storage of video data on the Android device and Web client The video monitoring of the Android device from the Android client and the Android client.
图2显示了硬盘录像机和Android设备端建立连接的交互过程,先通过抓包分析硬盘录像机发送组播的地址和端口,然后在Android设备端开启一个监听硬盘录像机组播的地址和端口服务,当在硬盘录像机的网页客户端上点击搜索网络摄像机时,在同一个局域网内并且满足Onvif标准的Android设备端就会收到硬盘录像机发起的Probe消息,获取到消息后要解析出消息体里面的Uuid,然后在回复的消息里携带这个Uuid和获取Android设备信息的Web Service地址,硬盘录像机在收到Android设备端的消息后校对发出的Uuid和收到的消息体里的Uuid,如果一致,则把Android设备端添加到摄像机列表中。Figure 2 shows the interactive process of establishing a connection between the DVR and the Android device. First, analyze the multicast address and port sent by the DVR through packet capture, and then open a service on the Android device to monitor the broadcast address and port of the DVR. When you click to search the network camera on the web client of the DVR, the Android device that is in the same LAN and meets the Onvif standard will receive the Probe message initiated by the DVR. After getting the message, you need to parse out the Uuid in the message body , and then carry this Uuid and the Web Service address for obtaining Android device information in the reply message. After receiving the message from the Android device, the DVR checks the sent Uuid and the Uuid in the received message body. If they are consistent, the Android The device side is added to the camera list.
参照图3,其中硬盘录像机和Android设备端的交互是以Web Service的形式进行。Web Service是一种基于网络的、分布式的模块化组件,执行特定的任务。Web Service主要利用Http(Hyper Text Transport Protocol,超文本传输协议)和Soap使数据在Web上传输。Web用户能够使用Soap和Http通过Web来调用远程对象。而Soap是基于XML(ExtensibleMarkup Language,可扩展的标识语言)的一种协议,一条Soap消息就是一个普通的XML文档,包含下列元素:必需的Envelope元素,可把此XML文档标识为一条Soap消息;可选的Header元素,包含头部信息;必需的Body元素,包含所有的调用和响应信息;可选的Fault元素,提供有关在处理此消息所发生错误的信息。因为Web Service就相当于一个Http服务器,需要在收到Http消息时回复Http消息,但是由于Android设备的硬件资源有限,所以只能在Android设备端搭建一个轻量级Http服务器,因为Http的底层使用Socket进行通信,而Socket是一种轻量级的远程通信,这里选择将Socket消息封装Http消息进行发送。在经过图2中的步骤后,点击搜索到的Android设备,并输入Android设备的账号密码,然后向图2中步骤获取到的Web Service地址请求Android设备端的DeviceInformation,这时的消息体中不携带鉴权消息;Android设备端收到消息后就回复一个带有密钥的Unauthorized的消息;硬盘录像机收到消息后就将账号,加密后的密码信息发送给Android设备端;Android设备端确认密码正确后会将自己的硬件信息发送给硬盘录像机;接着硬盘录像机就会向Android设备端请求关于Media的Web Service地址;Android设备端收到消息后,就会把响应的Web Service地址发送给硬盘录像机;硬盘录像机收到消息后就会向该地址再发送一个鉴权消息;Andorid设备端收到消息后因为消息头不含鉴权消息,会生成一个新的密钥发送给硬盘录像机;硬盘录像机收到带有密钥的消息后会把账号,加密后的密码信息发送给Android设备端;Android设备端收到消息后,会把设备支持的视频的分辨率信息发送给硬盘录像机。这里硬盘录像机和Android设备端进行交互的过程中进行两次的鉴权,可以提高Android设备的安全性。Referring to Fig. 3, the interaction between the hard disk video recorder and the Android device is carried out in the form of Web Service. Web Service is a network-based, distributed modular component that performs specific tasks. Web Service mainly utilizes Http (Hyper Text Transport Protocol, hypertext transfer protocol) and Soap to transmit data on the Web. Web users can use Soap and Http to call remote objects through the Web. And Soap is a kind of agreement based on XML (ExtensibleMarkup Language, extensible markup language), and a Soap message is exactly a common XML document, comprises following element: necessary Envelope element, can mark this XML document as a Soap message; The optional Header element contains header information; the required Body element contains all call and response information; the optional Fault element provides information about errors that occurred while processing this message. Because the Web Service is equivalent to an Http server, it needs to reply the Http message when receiving the Http message, but due to the limited hardware resources of the Android device, it can only build a lightweight Http server on the Android device side, because the bottom layer of Http uses Socket communicates, and Socket is a lightweight remote communication. Here, the Socket message is selected to encapsulate the Http message for sending. After going through the steps in Figure 2, click on the searched Android device, enter the account password of the Android device, and then request the DeviceInformation on the Android device from the Web Service address obtained in the steps in Figure 2. At this time, the message body does not carry Authentication message; the Android device will reply with an Unauthorized message with the key after receiving the message; the DVR will send the account number and encrypted password information to the Android device after receiving the message; the Android device will confirm that the password is correct After that, it will send its own hardware information to the DVR; then the DVR will request the Web Service address of Media from the Android device; after the Android device receives the message, it will send the corresponding Web Service address to the DVR; After the DVR receives the message, it will send another authentication message to the address; after receiving the message, the Andorid device will generate a new key and send it to the DVR because the message header does not contain the authentication message; the DVR receives After the message with the key, the account number and encrypted password information will be sent to the Android device; after receiving the message, the Android device will send the resolution information of the video supported by the device to the DVR. Here, two authentications are performed during the interaction between the DVR and the Android device, which can improve the security of the Android device.
参照图4,在图3的步骤执行完成之后,可以在硬盘录像机的网页客户端上选择一种分辨率,选择好分辨率后会给Android设备端发送一个Describe消息,消息体中不携带鉴权消息;Android设备端收到不带鉴权消息的Describe消息,回复一个鉴权失败的消息,并携带自己的密钥信息;硬盘录像机收到带密钥的鉴权失败的消息,就通过约定好的加密算法对Android设备端的密码进行加密,然后发送回给Android设备端;Android设备端将接受到的加密信息进行解密,如果解密结果和自己的密码一致则发送视频的Describe消息,消息里包含视频负载类型,视频解码信息等内容;硬盘录像机收到Describe消息后,回复一个带有自身接收Rtp包的端口信息;Android设备端收到消息后也回复一个自身发送Rtp包的端口消息,这样Android设备端就知道往硬盘录像机哪个端口发送Rtp包;硬盘录像机收到Android设备端的端口消息后,就知道Andorid设备端从哪个端口发Rtp包,然后就向Android设备端发送一个开始播放的消息;Android设备端收到开始播放的消息后,就开启一个线程发送Rtp包。Referring to Figure 4, after the steps in Figure 3 are executed, a resolution can be selected on the web client of the DVR, and a Describe message will be sent to the Android device after the resolution is selected, and the message body does not carry authentication message; the Android device receives a Describe message without an authentication message, and replies with a message of authentication failure, and carries its own key information; the DVR receives a message of authentication failure with a key, and passes the agreement The encryption algorithm encrypts the password of the Android device, and then sends it back to the Android device; the Android device decrypts the received encrypted information, and if the decryption result is consistent with its own password, it sends a Describe message of the video, which contains the video Load type, video decoding information, etc.; after receiving the Describe message, the DVR will reply with a port message with its own Rtp packet received; after receiving the message, the Android device will also reply with a port message with its own Rtp packet sent, so that the Android device The end will know which port to send the Rtp packet to the DVR; after the DVR receives the port message from the Android device, it will know which port the Andorid device sends the Rtp packet from, and then send a message to the Android device to start playing; the Android device After the end receives the message to start playing, it starts a thread to send the Rtp packet.
参照图5,Android设备端收到开始发送Rtp包的消息后,就会开启Android设备的摄像头进行视频数据的采集,采集来的是没有编码过的原始数据,这里需要调用Android原生的Api对原始数据进行H264硬编码,硬编码后的数据是H264裸数据,不能直接传输,当编码后的一帧数据的长度大于Rtp包的最大长度,还要通过分片,封装成Rtp包。考虑经过H.264压缩编码得到的视频主帧和辅帧数据大小差别较大,手机底层硬件是按照相同速率进行视频采集的,故每一帧的停留时间是相同的。若帧率为25,则每一帧的停留时间都是1/25秒。如果采用编码后直接打包发送的策略,因为主帧数据大,分片包多,所以主帧期间发包速率高。相对的,因为辅帧数据小,分片包少,所以辅帧期间发包速率低。且因为辅帧之间数据大小也不是相等的,所以辅帧之间的发包速率也存在差异。可见此种发包机制的发包速率不稳定,包发送速率是由帧的大小决定,这样会出现发包高峰期,造成网络阻塞,从而导致丢包率升高,影响了接收端的图像质量,所以先将分片好的Rtp包缓存到队列里,一个线程往队列里面存Rtp包,一个线程按照一定的速率往队列里取Rtp包发送。Android设备端视频模块根据需要向流媒体服务器或者硬盘录像机发送Rtp包。Referring to Figure 5, after the Android device receives the message of starting to send Rtp packets, it will turn on the camera of the Android device to collect video data. The data is hard-coded in H264. The hard-coded data is H264 bare data and cannot be directly transmitted. When the length of a frame of encoded data is greater than the maximum length of the Rtp packet, it must be fragmented and encapsulated into an Rtp packet. Considering that the data size of the main frame and sub-frame of the video obtained through H.264 compression encoding is quite different, and the underlying hardware of the mobile phone collects video at the same rate, so the dwell time of each frame is the same. If the frame rate is 25, the dwell time of each frame is 1/25 second. If the strategy of directly packaging and sending after encoding is adopted, the packet sending rate during the main frame is high because the data in the main frame is large and there are many fragmented packets. In contrast, because the sub-frame data is small and there are few fragmented packets, the packet sending rate during the sub-frame is low. And because the data size between the sub-frames is not equal, there is also a difference in the packet sending rate between the sub-frames. It can be seen that the packet sending rate of this kind of packet sending mechanism is unstable, and the packet sending rate is determined by the size of the frame. This will cause a packet sending peak period, causing network congestion, resulting in an increase in the packet loss rate and affecting the image quality of the receiving end. Fragmented Rtp packets are cached in the queue, one thread stores Rtp packets in the queue, and one thread fetches Rtp packets from the queue and sends them at a certain rate. The Android device-side video module sends Rtp packets to the streaming media server or hard disk video recorder as needed.
参照图6,Android设备端首先需要进行设备注册,需要向Sip服务器发送Register消息。服务器收到Sip消息后,会对该Sip消息进行解析,回复200 OK给Android设备端,并在消息体中携带了第二步注册时需要的加密种子。Android设备端收到服务器回复的200 OK后,解析出加密种子Seed后,经过MD5算法得出密码,并将携带了密码的Register消息发送给服务器,服务器收到消息后解析出密码并通过验证后,若密码正确则回复200 OK给Android设备端,若错误则回复401给Android设备端表示登陆失败。为了能够让Android设备端和服务器保持在线并且进行提示,Android设备端间隔20秒钟发送一次Register消息到Sip服务器,消息体中的字段为HeartBeat。服务器收到Sip消息并解析出是HeartBeat字段时,则判断该消息为心跳保活注册消息,并回复200 OK给Android设备端作为响应。Referring to Figure 6, the Android device first needs to perform device registration, and needs to send a Register message to the Sip server. After receiving the Sip message, the server will analyze the Sip message, reply 200 OK to the Android device, and carry the encrypted seed required for the second step of registration in the message body. After receiving the 200 OK reply from the server, the Android device parses out the encrypted seed, obtains the password through the MD5 algorithm, and sends the Register message carrying the password to the server. After receiving the message, the server parses out the password and passes the verification. , if the password is correct, it will reply 200 OK to the Android device, and if it is wrong, it will reply 401 to the Android device, indicating that the login failed. In order to keep the Android device and the server online and provide a reminder, the Android device sends a Register message to the Sip server every 20 seconds, and the field in the message body is HeartBeat. When the server receives the Sip message and parses out the HeartBeat field, it judges that the message is a heartbeat keep-alive registration message, and replies 200 OK to the Android device as a response.
参照图7,Android视频请求端通过Sip服务器首先向Android设备端发送一个Request消息,这个请求消息包含着本次视频请求是否需要将视频数据存储到硬盘录像机还有Rtp包发送的端口和Ip地址,当Android设备端收到消息后,解析消息如果需要将视频进行存储,则开启响应硬盘录像机模块,连接硬盘录像机,然后回复一个RequestResponse消息表明自己收到消息,当Android用户端收到RequestResponse消息,就向Android设备端发送一个请求本次视频数据的Media消息,Android设备端收到消息后,就将本次视频通话的分辨率,帧率发送回给请求端,然后开启Android视频模块,视频模块根据需要向硬盘录像机和Android视频请求端发送Rtp数据包,这样即实现了实时视频和视频数据的存储。最后当Android用户端要结束视频时,向Android设备端发送一个结束消息,Android设备端收到消息后关闭视频模块。Referring to Figure 7, the Android video requester first sends a Request message to the Android device through the Sip server. This request message includes whether the video request needs to store the video data in the hard disk video recorder and the port and Ip address for sending the Rtp packet. When the Android device receives the message, if it needs to store the video after parsing the message, it will open the response DVR module, connect the DVR, and then reply a RequestResponse message to indicate that it has received the message. When the Android client receives the RequestResponse message, it will Send a Media message requesting this video data to the Android device. After receiving the message, the Android device sends the resolution and frame rate of this video call back to the requesting end, and then starts the Android video module. The video module is based on It is necessary to send Rtp data packets to the hard disk video recorder and the Android video request end, thus realizing the storage of real-time video and video data. Finally, when the Android client is about to end the video, it sends an end message to the Android device, and the Android device closes the video module after receiving the message.
Claims (5)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810652642.8A CN108810475B (en) | 2018-06-22 | 2018-06-22 | An Android video surveillance device based on Onvif standard and Sip protocol |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810652642.8A CN108810475B (en) | 2018-06-22 | 2018-06-22 | An Android video surveillance device based on Onvif standard and Sip protocol |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN108810475A true CN108810475A (en) | 2018-11-13 |
| CN108810475B CN108810475B (en) | 2020-10-30 |
Family
ID=64084747
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201810652642.8A Active CN108810475B (en) | 2018-06-22 | 2018-06-22 | An Android video surveillance device based on Onvif standard and Sip protocol |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN108810475B (en) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109729312A (en) * | 2018-12-20 | 2019-05-07 | 杭州当虹科技股份有限公司 | A kind of video monitoring method of the ONVIF agreement under Internet network |
| CN110247900A (en) * | 2019-05-29 | 2019-09-17 | 金华诺普视信息技术研究所有限公司 | By the intelligent gateway of the real-time video deposit ONVIF storage equipment of SIP monitor supervision platform |
| CN112911348A (en) * | 2021-01-27 | 2021-06-04 | 石家庄铁道大学 | Video management system, method and terminal based on ONVIF protocol |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102185894A (en) * | 2011-04-11 | 2011-09-14 | 中国电信股份有限公司 | Multimedia acquisition and transmission method and system |
| CN102547239A (en) * | 2011-12-29 | 2012-07-04 | 浙江工业大学 | Android mobile terminal-based video monitoring system |
| US8601518B1 (en) * | 2012-11-13 | 2013-12-03 | Jet Optoelectronics Co., Ltd. | Vehicle display system |
| CN103647940A (en) * | 2013-11-25 | 2014-03-19 | 北京百纳威尔科技有限公司 | Intelligent monitoring mobile phone, remote video monitoring system and monitoring method thereof |
| CN107864125A (en) * | 2017-10-26 | 2018-03-30 | 苏州市伏泰信息科技股份有限公司 | Environmental sanitation unified monitoring management platform |
-
2018
- 2018-06-22 CN CN201810652642.8A patent/CN108810475B/en active Active
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102185894A (en) * | 2011-04-11 | 2011-09-14 | 中国电信股份有限公司 | Multimedia acquisition and transmission method and system |
| CN102547239A (en) * | 2011-12-29 | 2012-07-04 | 浙江工业大学 | Android mobile terminal-based video monitoring system |
| US8601518B1 (en) * | 2012-11-13 | 2013-12-03 | Jet Optoelectronics Co., Ltd. | Vehicle display system |
| CN103647940A (en) * | 2013-11-25 | 2014-03-19 | 北京百纳威尔科技有限公司 | Intelligent monitoring mobile phone, remote video monitoring system and monitoring method thereof |
| CN107864125A (en) * | 2017-10-26 | 2018-03-30 | 苏州市伏泰信息科技股份有限公司 | Environmental sanitation unified monitoring management platform |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109729312A (en) * | 2018-12-20 | 2019-05-07 | 杭州当虹科技股份有限公司 | A kind of video monitoring method of the ONVIF agreement under Internet network |
| CN110247900A (en) * | 2019-05-29 | 2019-09-17 | 金华诺普视信息技术研究所有限公司 | By the intelligent gateway of the real-time video deposit ONVIF storage equipment of SIP monitor supervision platform |
| CN112911348A (en) * | 2021-01-27 | 2021-06-04 | 石家庄铁道大学 | Video management system, method and terminal based on ONVIF protocol |
Also Published As
| Publication number | Publication date |
|---|---|
| CN108810475B (en) | 2020-10-30 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11212334B2 (en) | Mechanisms to support adaptive constrained application protocol (CoAP) streaming for Internet of Things (IoT) systems | |
| CN106331581B (en) | Method and device for communication between mobile terminal and video network terminal | |
| US8046479B2 (en) | Media channel management | |
| CN103581699B (en) | Video playing method, streaming media server and streaming media playing system | |
| US11316910B2 (en) | Method for uploading and downloading streaming media resources, distribution system and streaming media server | |
| US20080209065A1 (en) | Method for sending stream media, signaling forwarding device and stream media system | |
| MX2013001513A (en) | Session control for media stream transmission. | |
| CN102045537A (en) | Method and device for connecting video conference system and video monitoring system | |
| CN104113727A (en) | Monitoring video playing method, device and system | |
| CN101729862A (en) | Method and system for passing media through NAT by using video monitoring system | |
| EP3059945A1 (en) | Method and system for video surveillance content adaptation, and central server and device | |
| CN112995234A (en) | Media transmission link management method and device | |
| CN115865872B (en) | A solution to the national standard flow without plug-in | |
| KR20250170596A (en) | Signaling use of PDU sets and burst end markings for communicating WEBRTC media data. | |
| CN101754002B (en) | Video monitoring system and realization method for dual-stream monitoring front end thereof | |
| CN112422583A (en) | Method and system for fusion and intercommunication of multi-protocol video application | |
| CN101742265A (en) | Video monitoring method, fixed network video monitoring service platform and mobile terminal | |
| CN114244908A (en) | Cross-domain RTSP streaming media transmission method | |
| EP4060964B1 (en) | Method and apparatus for processing multicast signal | |
| CN110740300B (en) | Multimedia data transmission method, system, client and video monitoring equipment | |
| CN108810475B (en) | An Android video surveillance device based on Onvif standard and Sip protocol | |
| CN104284142A (en) | Communication method, device and system | |
| CN109194697B (en) | Internet monitoring method under GB28181 by SIP protocol | |
| CN101977306B (en) | Two-way video monitoring method and system | |
| CN101635716B (en) | Method and system for remotely controlling network audio/video coder |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |