jt808/jt1078

基于jt808协议调用指令下发获取实时视频 qq:2055150936

一开始接到这个需求时,查看 1078 协议文档发现,只是在文档中简单介绍了实时音视频传输的指令,以及设备收到指令后上传的音视频 RTP 负载包格式。

什么?只有设备上传音视频相关的文档说明,既然是对讲,那么麦克风语音如何传给设备呢?

个人觉得,这些部标协议用到的技术都比较老旧了,比如检索设备视频并上传文件,竟然还用 FTP?现在一般都是把文件存到第三方的对象存储服务了,比如:阿里云的OSS。用 FTP 的话我们就有可能需要在 FTP 那边接收到文件然后又转存一次存到 OSS,岂不是多此一举?实时音视频传输也是一样的,为什么不用第三方的流媒体服务器?非要传RTP包然后再转发一次到流媒体服务器?

废话不多说了,之前说到麦克风语音如何传给设备,文档里没有说明,那我们就去猜吧,实际上传输和设备传给视频转发服务器一样,也是用的文档中的 RTP 负载包格式。

    MDVR终端音频参数配置说明
    采样率:8K
    采样精度:16位
    采样点:320
    编码格式:
        AUDIO_CODEC_G711A,
        AUDIO_CODEC_G726_MEDIA_40K,
        AUDIO_CODEC_G726_MEDIA_32K,
        AUDIO_CODEC_G726_40K,
        AUDIO_CODEC_G726_32K,
    可以选以上几种编码格式。
    重要提示:
    1、由于采用海思芯片编码,每帧音频帧都会在标准音频帧前面增加4个字节的音频帧头信息,平台解码时需要去掉前面4个字节。
    2、G726编码格式含有多种压缩率格式,很多标准播放器的解码库只支持AUDIO_CODEC_G726_MEDIA_40K和AUDIO_CODEC_G726_MEDIA_32K两种编码格式,不支持AUDIO_CODEC_G726_40K和AUDIO_CODEC_G726_32K,虽然看上去压缩率一样,但是编码规则不一样,需要留意音频解码参数的配置。
    3、相对G726编码而言G711A编码则比较简单,调试时可以先选择这种编码格式。
    4、举例:采样率8K,采样精度16位,采样点:320
    原始音频数据码率:8K*16bit=128kpbs
    每秒音频帧数:8K/320=25帧
    比如选择AUDIO_CODEC_G726_40K编码,则每帧长度40Kbit/8bit/25=200字节长度,既每帧编码后的音频帧长度是200个字节,那么设备上传的就是204个字节,前面4个字节是海思音频编码私有帧头数据。

Speex转码成PCM也有需要注意的地方,因为根据上面我们厂商文档中说明,采样率是8K,采样点320,所以可以知道传输的每帧PCM字节数是320,对应的是Speex的窄带(160 sample,一个 sample 占两个字节,所以解码出的 PCM 刚好是 320 字节),那么我们在解码Speex为PCM的时候就应该选择窄带解码模式。

    #region Using directives
    using System.Runtime.InteropServices;
    using System;
    // using System;
    // using System.IO;
    // using System.Collections.Generic;
    // using System.Text;
    // using System.Runtime.InteropServices;
    // using System.Diagnostics;
    #endregion Using directives
    namespace GpsNET.RTMP
    {
        public enum SpeexCtlCode {
            // Set enhancement on/off (decoder only)
            SPEEX_SET_ENH=0,
            // Get enhancement state (decoder only)
            SPEEX_GET_ENH=1,
            // Obtain frame size used by encoder/decoder
            SPEEX_GET_FRAME_SIZE=3,
            // Set quality value
            SPEEX_SET_QUALITY=4,
            // Get current quality setting
            // SPEEX_GET_QUALITY=5 -- Doesn't make much sense, does it? */,
            // Set sub-mode to use
            SPEEX_SET_MODE=6,
            // Get current sub-mode in use
            SPEEX_GET_MODE=7,
            // Set low-band sub-mode to use (wideband only
            SPEEX_SET_LOW_MODE=8,
            // Get current low-band mode in use (wideband only
            SPEEX_GET_LOW_MODE=9,
            // Set high-band sub-mode to use (wideband only
            SPEEX_SET_HIGH_MODE=10,
            // Get current high-band mode in use (wideband only
            SPEEX_GET_HIGH_MODE=11,
            // Set VBR on (1) or off (0)
            SPEEX_SET_VBR=12,
            // Get VBR status (1 for on, 0 for off)
            SPEEX_GET_VBR=13,
            // Set quality value for VBR encoding (0-10)
            SPEEX_SET_VBR_QUALITY=14,
            // Get current quality value for VBR encoding (0-10)
            SPEEX_GET_VBR_QUALITY=15,
            // Set complexity of the encoder (0-10)
            SPEEX_SET_COMPLEXITY=16,
            // Get current complexity of the encoder (0-10)
            SPEEX_GET_COMPLEXITY=17,
            // Set bit-rate used by the encoder (or lower)
            SPEEX_SET_BITRATE=18,
            // Get current bit-rate used by the encoder or decoder
            SPEEX_GET_BITRATE=19,
            // Define a handler function for in-band Speex reques
            SPEEX_SET_HANDLER=20,
            // Define a handler function for in-band user-defined reques
            SPEEX_SET_USER_HANDLER=22,
            // Set sampling rate used in bit-rate computation
            SPEEX_SET_SAMPLING_RATE=24,
            // Get sampling rate used in bit-rate computation
            SPEEX_GET_SAMPLING_RATE=25,
            // Reset the encoder/decoder memories to zer
            SPEEX_RESET_STATE=26,
            // Get VBR info (mostly used internally)
            SPEEX_GET_RELATIVE_QUALITY=29,
            // Set VAD status (1 for on, 0 for off)
            SPEEX_SET_VAD=30,
            // Get VAD status (1 for on, 0 for off)
            SPEEX_GET_VAD=31,
            // Set Average Bit-Rate (ABR) to n bits per seconds
            SPEEX_SET_ABR=32,
            // Get Average Bit-Rate (ABR) setting (in bps)
            SPEEX_GET_ABR=33,
            // Set DTX status (1 for on, 0 for off)
            SPEEX_SET_DTX=34,
            // Get DTX status (1 for on, 0 for off)
            SPEEX_GET_DTX=35,
            // Set submode encoding in each frame (1 for yes, 0 for no, setting to no breaks the standard)
            SPEEX_SET_SUBMODE_ENCODING=36,
            // Get submode encoding in each frame
            SPEEX_GET_SUBMODE_ENCODING=37,
            // SPEEX_SET_LOOKAHEAD=38,
            // Returns the lookahead used by Speex
            SPEEX_GET_LOOKAHEAD=39,
            // Sets tuning for packet-loss concealment (expected loss rate)
            SPEEX_SET_PLC_TUNING=40,
            // Gets tuning for PLC
            SPEEX_GET_PLC_TUNING=41,
            // Sets the max bit-rate allowed in VBR mode
            SPEEX_SET_VBR_MAX_BITRATE=42,
            // Gets the max bit-rate allowed in VBR mode
            SPEEX_GET_VBR_MAX_BITRATE=43,
            // Turn on/off input/output high-pass filtering
            SPEEX_SET_HIGHPASS=44,
            // Get status of input/output high-pass filtering
            SPEEX_GET_HIGHPASS=45,
            // Get "activity level" of the last decoded frame, i.e, 
            // how much damage we cause if we remove the frame
            SPEEX_GET_ACTIVITY=47
        }
        // Preserving compatibility:
        public enum SpeexCompatCode {
            // Equivalent to SPEEX_SET_ENH
            SPEEX_SET_PF=0,
            // Equivalent to SPEEX_GET_ENH
            SPEEX_GET_PF=1
        }
        // Values allowed for mode queries
        public enum SpeexModeQuery {
            // Query the frame size of a mode
            SPEEX_MODE_FRAME_SIZE=0,
            // Query the size of an encoded frame for a particular sub-mode
            SPEEX_SUBMODE_BITS_PER_FRAME=1
        }
        public enum SpeexVersion {
            // Get major Speex version
            SPEEX_LIB_GET_MAJOR_VERSION=1,
            // Get minor Speex version
            SPEEX_LIB_GET_MINOR_VERSION=3,
            // Get micro Speex version
            SPEEX_LIB_GET_MICRO_VERSION=5,
            // Get extra Speex version
            SPEEX_LIB_GET_EXTRA_VERSI
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值