背景分析

近年来,国内视频监控应用发展迅猛,系统接入规模不断扩大,涌现了大量平台提供商,平台提供商的接入协议各不相同,终端制造商需要给每款终端维护提供各种不同平台的软件版本,造成了极大的资源浪费。各地视频大规模建设后,省级、国家级集中调阅,对重特大事件通过视频掌握现场并进行指挥调度的需求逐步涌现,然而不同平台间缺乏统一的互通协议。在这样的产业背景下,基于终端标准化、平台互联互通的需求,GB/T28181应运而生。

如下浏览器采集音频源码摘自LiveGBS GB28181流媒体平台的前端web源码:
​​​ https://github.com/livegbs/GB28181-Server​

前端页面语音采集示例

   function  talkStart(e) {
if(this.recorder) {
return;
}
var $target = $(e.currentTarget);
LiveRecorder.get((rec, err) => {
if(err) {
alert(err);
return
}
this.muted_bak = this.muted;
this.$refs["player"].setMuted(true);
$target.addClass("active");
this.recorder = rec;
this.recorder.start();
}, {
sampleBits: 16,
sampleRate: 8000,
pcmCallback: pcm => {
if(this.bAudioSendError) return;
var reader = new window.FileReader();
reader.onloadend = () => {
var base64 = reader.result;
var base64 = base64.split(',')[1];
this.bAudioSending = true;
$.get("/api/v1/control/talk", {
serial: this.serial,
code: this.code,
audio: base64,
}).error(() => {
if(!this.bAudioSendError) {
this.bAudioSendError = true;
setTimeout(() => {
this.bAudioSendError = false;
}, 10000);
}
}).always(() => {
this.bAudioSending = false;
})
}
reader.readAsDataURL(pcm);
}
})
}
function talkStop() {
if(this.recorder) {
this.recorder.stop();
this.recorder = null;
$(this.$el).find(".fa-microphone.active, .ptz-talk.active").removeClass("active");
this.$refs["player"].setMuted(this.muted_bak);
return;
}
},