Significance of Android front-end audio and video data access to GB28181 platform

Posted by nabeelkhan on Tue, 08 Mar 2022 04:20:44 +0100

Technical background

Before we developed the front-end audio and video access module of GB28181 on Android platform, what we heard most in the industry was how to use Android or Windows to simulate the signaling and media streaming interaction process of GB28181 and realize the test of the overall scheme of GB28181 without national standard IPC equipment?

Is it really unnecessary to make an access module supporting GB28181 on the Android side?

If a device side IPC national standard device access simulation module is to complete the work from 0 to 1, then from the device side IPC simulation to a producible Android platform GB28181 front-end audio and video access module, it needs to be more rigorous and in line with relevant spec s to realize the Android terminal without national standard audio and video capability through platform registration, Access to the existing GB28181 service, and finally use it in scenarios such as intelligent monitoring, smart retail, smart education, remote office, production and transportation, smart transportation, on-board or law enforcement recorder. It can be said that the application scenarios are very wide.

In addition to supporting conventional audio and video media streaming data access, it can also support Subscribe to Subscribe to real-time mobile position and real-time directory query to complete the docking of standard services. In terms of product design, the media stream supports UDP and TCP passive modes of the latest GB28181-2016, parameter configuration, registration validity, heartbeat interval, heartbeat interval times, TCP/UDP signaling settings, RTP Sender IP address type, RTP socket local port, SS-R-C, RTP socket sending Buffer size, RTP timestamp clock frequency settings, successful registration, registration timeout Callback of INVITE, ACK and BYE status.

Design ideas

Signaling design and media data transmission are separated. The upper layer realizes the registration, cancellation, catalog, invite, ACK, BYE, SUBSCRIBE and other interactive processing of the national standard GB28181. If the registration is successful, return the registration time and detect the abnormal status such as transmission or heartbeat. After the server sends the catalog request, organize the local catalog information and send it to the server in the form of message, After receiving the relevant information, the server starts to send the invite request. The client parses the SDP information returned by the invite, organizes the relevant response, creates the RTP Sender, and sets the relevant parameters according to the returned information. After receiving the ACK from the server, send the encoded and packaged media stream data. During this period, keepalive is sent regularly according to the set interval.

‚Äč

As shown in the figure above, in addition to the conventional audio and video parameter configuration of the module, the system can realize RTMP push, RTSP push, lightweight RTSP service, real-time video recording and GB28181 front-end access at the same time or separately.

Signaling interface design:

public interface GBSIPAgent {
    void addListener(GBSIPAgentListener listener);
 
    /*
     * Set SIP local link address
     * @param address Local IP address, such as 192.168.0.111
     * @param port Local SIP port, such as 15070
     */
    void setLocalAddressInfo(String address, int port);
 
    /*
     * Set SIP Server configuration parameters
     * @param address SIP Server address, such as 192.168.0.101
     * @param port SIP Server port, such as 15060
     * @param id SIP Server ID, such as 3402000000200000001
     * @param domain SIP Server domain, such as 3402000000
     */
    void setServerParameter(String address, int port, String id, String domain);
 
    /*
     * Set GB28181 SIP User configuration parameters
     * @param userName SIP User name, such as 34020000001110000045
     * @param password E.g. 123456
     */
    void setUserInfo(String userName, String password);
 
 
    /*
     * Set UserAgent in SIP request header
     * @param userAgent user agent 
     */
    void setUserAgent(String userAgent);
 
    /*
     * Set SIP transport protocol
     * @param transport_protocol, Set the SIP signaling transmission protocol: UDP, TCP. The default is UDP
     */
    void setTransportProtocol(String transport_protocol);
 
    /*
     * Set GB28181 configuration parameters
     * @param regExpired Registration validity period, unit: seconds, such as 3600
     * @param heartBeatInterval Heartbeat interval, unit: second, default: 60
     * @param heartBeatCount Heartbeat timeout times, 3 times by default
     */
    void config(int regExpired, int heartBeatInterval, int heartBeatCount);
 
    void clearDevices();
 
    boolean addDevice(Device device);
 
    boolean initialize();
 
    /*
    *start-up
     */
    boolean start();
 
    boolean isRunning();
 
    /*
    *Respond to Invite play 200OK
     */
    boolean respondPlayInviteOK(String deviceId, String localAddress, int localPort);
 
    /*
    *Respond to Invite play other status codes
     */
    boolean respondPlayInvite(int statusCode, String deviceId);
 
    /*
    *Terminate session
     */
    void terminatePlay(String deviceId, boolean isSendBYE);
 
    /*
    *Terminate all sessions
     */
    void terminateAllPlays(boolean isSendBYE);
 
    /*
     *stop it
     */
    void stop();
 
    void unInitialize();
}

Related status callback:

public interface GBSIPAgentListener
{
    /*login was successful
    * @param dateString: The server date is used to correct the device time. The user decides whether to correct the device time
    */
    void ntsRegisterOK(String dateString);
 
    /*
    *Registration timeout
    */
    void ntsRegisterTimeout();
 
    /*
    *Registered network transmission was abnormal
    */
    void ntsRegisterTransportError(String errorInfo);
 
    /*
    *Number of abnormal heartbeat
    */
    void ntsOnHeartBeatException(int exceptionCount, String lastExceptionInfo);
 
    /*
    *Receive real-time video and audio on demand of s=Play
    */
    void ntsOnInvitePlay(String deviceId, InvitePlaySessionDescription sessionDescription);
 
    /*
    *Send play invite response exception
    */
    void ntsOnPlayInviteResponseException(String deviceId, int statusCode, String errorInfo);
 
    /*
     * Received CANCEL play INVITE request
    */
    void ntsOnCancelPlay(String deviceId);
 
    /*
     * Got it, Ack
    */
    void ntsOnAckPlay(String deviceId);
 
    /*
     * Got it, Bye
    */
    void ntsOnByePlay(String deviceId);
 
    /*
     * Play When the conversation corresponding to the session is terminated, the callback will not start. At present, it may start only after the response is 200K but the ACK has not been received after 64*T1 time
    After receiving this, please clean it up
    */
    void ntsOnPlayDialogTerminated(String deviceId);
}

summary

Before the research and development of GB28181 audio and video access module on Android platform, Daniel live SDK (official) has accumulated for many years in RTSP, RTMP, audio and video acquisition, coding and transmission. For GB28181 access, we only complete signaling interaction and data packaging and transmission on the basis of the existing architecture (H264 and h265 are packaged into PS streams, and then disassembled into RTP packets for transmission), RTP transmission supports TCP and UDP modes, and cooperates with the national standard 28181 server test. The delay is very low. The design supports multi-channel, which can realize the conversion of RTSP or RTMP stream data to GB28181. Enable the Android platform to smoothly connect the camera, screen, microphone or external RTSP and RTMP streams to the GB28181 platform like the IPC supporting the GB28181 protocol.