当前位置: 首页 > news >正文

网站开发安全性想学编程去哪里找培训班

网站开发安全性,想学编程去哪里找培训班,wordpress 设置域名,wordpress配置文件数据库背景 我们在做GB28181设备接入模块的时候,考虑到好多设备性能一般,我们一般的设计思路是,先注册设备到平台侧,平台侧发calalog过来,获取设备信息,然后,设备侧和国标平台侧维持心跳,…

背景

我们在做GB28181设备接入模块的时候,考虑到好多设备性能一般,我们一般的设计思路是,先注册设备到平台侧,平台侧发calalog过来,获取设备信息,然后,设备侧和国标平台侧维持心跳,如果有位置订阅信息,按照订阅时间间隔,实时上报设备位置信息。

如果本地没有录像诉求,或者,国标平台侧不发起invite请求,Android平台GB28181设备接入端,不做视频编码,甚至可以连摄像头都不打开,等有实时录像或国标平台侧视频预览播放请求的时候,再打开摄像头,毕竟摄像头单纯的打开,设备都有性能损耗,甚至一些中低端记录仪,还没编码就开始发热。

技术实现

本文以大牛直播SDK的Android平台GB28181设备接入侧为例,先启动GB28181,启动后,直接注册到国标平台侧,整体设计架构图如下:

class ButtonGB28181AgentListener implements View.OnClickListener {public void onClick(View v) {stopAudioPlayer();destoryRTPReceiver();gb_broadcast_source_id_ = null;gb_broadcast_target_id_ = null;btnGB28181AudioBroadcast.setText("GB28181语音广播");btnGB28181AudioBroadcast.setEnabled(false);stopGB28181Stream();destoryRTPSender();if (null == gb28181_agent_ ) {if( !initGB28181Agent() )return;}if (gb28181_agent_.isRunning()) {gb28181_agent_.terminateAllPlays(true);// 目前测试下来,发送BYE之后,有些服务器会立即发送INVITE,是否发送BYE根据实际情况看gb28181_agent_.stop();btnGB28181Agent.setText("启动GB28181");}else {if ( gb28181_agent_.start() ) {btnGB28181Agent.setText("停止GB28181");}}}
}

其中,initGB28181Agent()做的工作如下:

private boolean initGB28181Agent() {if ( gb28181_agent_ != null )return  true;getLocation(context_);String local_ip_addr = IPAddrUtils.getIpAddress(context_);Log.i(TAG, "[daniusdk]initGB28181Agent local ip addr: " + local_ip_addr);if ( local_ip_addr == null || local_ip_addr.isEmpty() ) {Log.e(TAG, "[daniusdk]initGB28181Agent local ip is empty");return  false;}gb28181_agent_ = GBSIPAgentFactory.getInstance().create();if ( gb28181_agent_ == null ) {Log.e(TAG, "[daniusdk]initGB28181Agent create agent failed");return false;}gb28181_agent_.addListener(this);gb28181_agent_.addPlayListener(this);gb28181_agent_.addAudioBroadcastListener(this);gb28181_agent_.addDeviceControlListener(this);gb28181_agent_.addQueryCommandListener(this);// 必填信息gb28181_agent_.setLocalAddress(local_ip_addr);gb28181_agent_.setServerParameter(gb28181_sip_server_addr_, gb28181_sip_server_port_, gb28181_sip_server_id_, gb28181_sip_domain_);gb28181_agent_.setUserInfo(gb28181_sip_username_, gb28181_sip_password_);//gb28181_agent_.setUserInfo(gb28181_sip_username_, gb28181_sip_username_, gb28181_sip_password_);// 可选参数gb28181_agent_.setUserAgent(gb28181_sip_user_agent_filed_);gb28181_agent_.setTransportProtocol(gb28181_sip_trans_protocol_==0?"UDP":"TCP");// GB28181配置gb28181_agent_.config(gb28181_reg_expired_, gb28181_heartbeat_interval_, gb28181_heartbeat_count_);com.gb.ntsignalling.Device gb_device = new com.gb.ntsignalling.Device("34020000001380000001", "安卓测试设备", Build.MANUFACTURER, Build.MODEL,"宇宙","火星1","火星", true);if (mLongitude != null && mLatitude != null) {com.gb.ntsignalling.DevicePosition device_pos = new com.gb.ntsignalling.DevicePosition();device_pos.setTime(mLocationTime);device_pos.setLongitude(mLongitude);device_pos.setLatitude(mLatitude);gb_device.setPosition(device_pos);gb_device.setSupportMobilePosition(true); // 设置支持移动位置上报}gb28181_agent_.addDevice(gb_device);if (!gb28181_agent_.createSipStack()) {gb28181_agent_ = null;Log.e(TAG, "[daniusdk]initGB28181Agent gb28181_agent_.createSipStack failed.");return  false;}boolean is_bind_local_port_ok = false;// 最多尝试5000个端口int try_end_port = gb28181_sip_local_port_base_ + 5000;try_end_port = try_end_port > 65536 ?65536: try_end_port;for (int i = gb28181_sip_local_port_base_; i < try_end_port; ++i) {if (gb28181_agent_.bindLocalPort(i)) {is_bind_local_port_ok = true;break;}}if (!is_bind_local_port_ok) {gb28181_agent_.releaseSipStack();gb28181_agent_ = null;Log.e(TAG, "[daniusdk]initGB28181Agent gb28181_agent_.bindLocalPort failed.");return  false;}if (!gb28181_agent_.initialize()) {gb28181_agent_.unBindLocalPort();gb28181_agent_.releaseSipStack();gb28181_agent_ = null;Log.e(TAG, "[daniusdk]initGB28181Agent gb28181_agent_.initialize failed.");return  false;}return true;
}

注册成功后,会把国标平台侧返回200 OK时带的时间返回上来,便于Android平台GB28181设备侧做校时,如有注册异常,也会返回:

@Override
public void ntsRegisterOK(String dateString) {Log.i(TAG, "ntsRegisterOK Date: " + (dateString!= null? dateString : ""));
}@Override
public void ntsRegisterTimeout() {Log.e(TAG, "ntsRegisterTimeout");
}@Override
public void ntsRegisterTransportError(String errorInfo) {Log.e(TAG, "ntsRegisterTransportError error:" + (errorInfo != null?errorInfo :""));
}

周期性的心跳,如有异常,我们也回调到上层:

@Override
public void ntsOnHeartBeatException(int exceptionCount,  String lastExceptionInfo) {Log.e(TAG, "ntsOnHeartBeatException heart beat timeout count reached, count:" + exceptionCount+", exception info:" + (lastExceptionInfo!=null?lastExceptionInfo:""));// 停止信令, 然后重启handler_.postDelayed(new Runnable() {@Overridepublic void run() {Log.i(TAG, "gb28281_heart_beart_timeout");stopAudioPlayer();destoryRTPReceiver();if (gb_broadcast_source_id_ != null && gb_broadcast_target_id_ != null && gb28181_agent_ != null)gb28181_agent_.byeAudioBroadcast(gb_broadcast_source_id_, gb_broadcast_target_id_);gb_broadcast_source_id_ = null;gb_broadcast_target_id_ = null;btnGB28181AudioBroadcast.setText("GB28181语音广播");btnGB28181AudioBroadcast.setEnabled(false);stopGB28181Stream();destoryRTPSender();if (gb28181_agent_ != null) {gb28181_agent_.terminateAllPlays(true);Log.i(TAG, "gb28281_heart_beart_timeout sip stop");gb28181_agent_.stop();String local_ip_addr = IPAddrUtils.getIpAddress(context_);if (local_ip_addr != null && !local_ip_addr.isEmpty() ) {Log.i(TAG, "gb28281_heart_beart_timeout get local ip addr: " + local_ip_addr);gb28181_agent_.setLocalAddress(local_ip_addr);}Log.i(TAG, "gb28281_heart_beart_timeout sip start");gb28181_agent_.start();}}},0);
}

如果国标平台侧订阅了实时位置信息,我们的处理如下:

@Override
public void ntsOnDevicePositionRequest(String deviceId, int interval) {handler_.postDelayed(new Runnable() {@Overridepublic void run() {getLocation(context_);if (mLongitude != null && mLatitude != null) {com.gb.ntsignalling.DevicePosition device_pos = new com.gb.ntsignalling.DevicePosition();device_pos.setTime(mLocationTime);device_pos.setLongitude(mLongitude);device_pos.setLatitude(mLatitude);if (gb28181_agent_ != null ) {gb28181_agent_.updateDevicePosition(device_id_, device_pos);}}}private String device_id_;private int interval_;public Runnable set(String device_id, int interval) {this.device_id_ = device_id;this.interval_ = interval;return this;}}.set(deviceId, interval),0);
}

如果平台侧发起预览请求,我们的处理如下:

@Override
public void ntsOnInvitePlay(String deviceId, SessionDescription session_des) {handler_.postDelayed(new Runnable() {@Overridepublic void run() {// 先振铃响应下gb28181_agent_.respondPlayInvite(180, device_id_);MediaSessionDescription video_des = null;SDPRtpMapAttribute ps_rtpmap_attr = null;// 28181 视频使用PS打包Vector<MediaSessionDescription> video_des_list = session_des_.getVideoPSDescriptions();if (video_des_list != null && !video_des_list.isEmpty()) {for(MediaSessionDescription m : video_des_list) {if (m != null && m.isValidAddressType() && m.isHasAddress() ) {video_des = m;ps_rtpmap_attr = video_des.getPSRtpMapAttribute();break;}}}if (null == video_des) {gb28181_agent_.respondPlayInvite(488, device_id_);Log.i(TAG, "ntsOnInvitePlay get video description is null, response 488, device_id:" + device_id_);return;}if (null == ps_rtpmap_attr) {gb28181_agent_.respondPlayInvite(488, device_id_);Log.i(TAG, "ntsOnInvitePlay get ps rtp map attribute is null, response 488, device_id:" + device_id_);return;}long rtp_sender_handle = libPublisher.CreateRTPSender(0);if ( rtp_sender_handle == 0 ) {gb28181_agent_.respondPlayInvite(488, device_id_);Log.i(TAG, "ntsOnInvitePlay CreateRTPSender failed, response 488, device_id:" + device_id_);return;}gb28181_rtp_payload_type_  = ps_rtpmap_attr.getPayloadType();gb28181_rtp_encoding_name_ =  ps_rtpmap_attr.getEncodingName();libPublisher.SetRTPSenderTransportProtocol(rtp_sender_handle, video_des.isRTPOverUDP()?0:1);libPublisher.SetRTPSenderIPAddressType(rtp_sender_handle, video_des.isIPv4()?0:1);libPublisher.SetRTPSenderLocalPort(rtp_sender_handle, 0);libPublisher.SetRTPSenderSSRC(rtp_sender_handle, video_des.getSSRC());libPublisher.SetRTPSenderSocketSendBuffer(rtp_sender_handle, 2*1024*1024); // 设置到2MlibPublisher.SetRTPSenderClockRate(rtp_sender_handle, ps_rtpmap_attr.getClockRate());libPublisher.SetRTPSenderDestination(rtp_sender_handle, video_des.getAddress(), video_des.getPort());if ( libPublisher.InitRTPSender(rtp_sender_handle) != 0 ) {gb28181_agent_.respondPlayInvite(488, device_id_);libPublisher.DestoryRTPSender(rtp_sender_handle);return;}int local_port = libPublisher.GetRTPSenderLocalPort(rtp_sender_handle);if (local_port == 0) {gb28181_agent_.respondPlayInvite(488, device_id_);libPublisher.DestoryRTPSender(rtp_sender_handle);return;}Log.i(TAG,"get local_port:" + local_port);String local_ip_addr = IPAddrUtils.getIpAddress(context_);MediaSessionDescription local_video_des = new MediaSessionDescription(video_des.getType());local_video_des.addFormat(String.valueOf(ps_rtpmap_attr.getPayloadType()));local_video_des.addRtpMapAttribute(ps_rtpmap_attr);local_video_des.setAddressType(video_des.getAddressType());local_video_des.setAddress(local_ip_addr);local_video_des.setPort(local_port);local_video_des.setTransportProtocol(video_des.getTransportProtocol());local_video_des.setSSRC(video_des.getSSRC());if (!gb28181_agent_.respondPlayInviteOK(device_id_,local_video_des) ) {libPublisher.DestoryRTPSender(rtp_sender_handle);Log.e(TAG, "ntsOnInvitePlay call respondPlayInviteOK failed.");return;}gb28181_rtp_sender_handle_ = rtp_sender_handle;}private String device_id_;private SessionDescription session_des_;public Runnable set(String device_id, SessionDescription session_des) {this.device_id_ = device_id;this.session_des_ = session_des;return this;}}.set(deviceId, session_des),0);
}

收到Ack后,才开始真正发送数据:

@Override
public void ntsOnAckPlay(String deviceId) {handler_.postDelayed(new Runnable() {@Overridepublic void run() {Log.i(TAG,"ntsOnACKPlay, device_id:" +device_id_);if (!isRTSPPublisherRunning && !isPushingRtmp && !isRecording) {InitAndSetConfig();}libPublisher.SetGB28181RTPSender(publisherHandle, gb28181_rtp_sender_handle_, gb28181_rtp_payload_type_, gb28181_rtp_encoding_name_);//libPublisher.SetGBTCPConnectTimeout(publisherHandle, 10*60*1000);//libPublisher.SetGBInitialTCPReconnectInterval(publisherHandle, 1000);//libPublisher.SetGBInitialTCPMaxReconnectAttempts(publisherHandle, 3);int startRet = libPublisher.StartGB28181MediaStream(publisherHandle);if (startRet != 0) {if (!isRTSPPublisherRunning && !isPushingRtmp  && !isRecording) {if (publisherHandle != 0) {long handle = publisherHandle;publisherHandle = 0;libPublisher.SmartPublisherClose(handle);}}destoryRTPSender();Log.e(TAG, "Failed to start GB28181 service..");return;}if (!isRTSPPublisherRunning && !isPushingRtmp && !isRecording) {CheckInitAudioRecorder();}startLayerPostThread();isGB28181StreamRunning = true;}private String device_id_;public Runnable set(String device_id) {this.device_id_ = device_id;return this;}}.set(deviceId),0);
}

总结

除此之外,还有语音广播和语音对讲,这里不再赘述,GB28181规范普及之前,要想从外网远程访问局域网内的监控设备非常麻烦,一般要么RTSP转RTMP推到RTMP服务器,此外还要单独构建信令。GB28181规范,让远程、跨网访问监控设备更方便,把GB28181平台部署到外网后,前端设备只要注册到国标服务器,就可以被远程访问、管理和调取视频。但由于设备侧性能并不是非常好,如果要有好的稳定性和性能要求,需尽可能的减少性能消耗,按需打开摄像头、按需编码等。

 


文章转载自:
http://dinncofalchion.ssfq.cn
http://dinncofeatherhead.ssfq.cn
http://dinnconeuritis.ssfq.cn
http://dinncoexcerption.ssfq.cn
http://dinncoepithelia.ssfq.cn
http://dinncointerview.ssfq.cn
http://dinncofurl.ssfq.cn
http://dinncoconflagrate.ssfq.cn
http://dinncoshitticism.ssfq.cn
http://dinncooverwind.ssfq.cn
http://dinncosibb.ssfq.cn
http://dinncoreconstruction.ssfq.cn
http://dinncolag.ssfq.cn
http://dinncozapu.ssfq.cn
http://dinncoxylographic.ssfq.cn
http://dinncohabitual.ssfq.cn
http://dinncoherpesvirus.ssfq.cn
http://dinncocoruscate.ssfq.cn
http://dinncopalaeoanthropic.ssfq.cn
http://dinncoinconsumable.ssfq.cn
http://dinncodownbent.ssfq.cn
http://dinncosprint.ssfq.cn
http://dinncoimbue.ssfq.cn
http://dinncocabobs.ssfq.cn
http://dinncomicrococcic.ssfq.cn
http://dinncosymphily.ssfq.cn
http://dinncotroopie.ssfq.cn
http://dinncomailplane.ssfq.cn
http://dinncocryptorchism.ssfq.cn
http://dinncoprocrustean.ssfq.cn
http://dinnconominator.ssfq.cn
http://dinncoreanimation.ssfq.cn
http://dinncogamophyllous.ssfq.cn
http://dinncoherero.ssfq.cn
http://dinncoachromatophil.ssfq.cn
http://dinncojinricksha.ssfq.cn
http://dinncobaryon.ssfq.cn
http://dinncofalteringly.ssfq.cn
http://dinncomidrib.ssfq.cn
http://dinncojainism.ssfq.cn
http://dinncokazakh.ssfq.cn
http://dinncosunstone.ssfq.cn
http://dinncounderwing.ssfq.cn
http://dinncodeficient.ssfq.cn
http://dinncohibernian.ssfq.cn
http://dinncoductor.ssfq.cn
http://dinncoabed.ssfq.cn
http://dinncoemeute.ssfq.cn
http://dinncoharmlessly.ssfq.cn
http://dinncomediae.ssfq.cn
http://dinncoafrica.ssfq.cn
http://dinncosortation.ssfq.cn
http://dinncoflocci.ssfq.cn
http://dinncoaluminate.ssfq.cn
http://dinncoreformism.ssfq.cn
http://dinncogermanize.ssfq.cn
http://dinncounsuspecting.ssfq.cn
http://dinncoleprosarium.ssfq.cn
http://dinncoamyotonia.ssfq.cn
http://dinncominorite.ssfq.cn
http://dinncobiennialy.ssfq.cn
http://dinncoacidanthera.ssfq.cn
http://dinncoinclose.ssfq.cn
http://dinncobluppy.ssfq.cn
http://dinncoisoceraunic.ssfq.cn
http://dinncoepagoge.ssfq.cn
http://dinncoendomyocarditis.ssfq.cn
http://dinncoasarh.ssfq.cn
http://dinncoflocculous.ssfq.cn
http://dinncostrikethrough.ssfq.cn
http://dinncodiscipline.ssfq.cn
http://dinncoogrish.ssfq.cn
http://dinncotribromoethyl.ssfq.cn
http://dinncoeconomy.ssfq.cn
http://dinncounsphere.ssfq.cn
http://dinncoflowerer.ssfq.cn
http://dinncosconce.ssfq.cn
http://dinncoairlog.ssfq.cn
http://dinncopromulgate.ssfq.cn
http://dinncohewett.ssfq.cn
http://dinncophonologist.ssfq.cn
http://dinncoprocrastination.ssfq.cn
http://dinncomicrococcal.ssfq.cn
http://dinncobespattered.ssfq.cn
http://dinncomolluscan.ssfq.cn
http://dinncobogus.ssfq.cn
http://dinncoproclinate.ssfq.cn
http://dinncospecs.ssfq.cn
http://dinncoimpersonalize.ssfq.cn
http://dinncosoldierly.ssfq.cn
http://dinncowillet.ssfq.cn
http://dinncopolygamy.ssfq.cn
http://dinncoobtainable.ssfq.cn
http://dinncoidentifier.ssfq.cn
http://dinncoflexile.ssfq.cn
http://dinncoazure.ssfq.cn
http://dinnconpn.ssfq.cn
http://dinncoleisured.ssfq.cn
http://dinncogenerator.ssfq.cn
http://dinncoaccessary.ssfq.cn
http://www.dinnco.com/news/114237.html

相关文章:

  • 做网站是怎样赚钱的北海seo快速排名
  • 贸易公司做推广的网站广州企业网站推广
  • 网站每天更新的内容是内链吗微商软文范例大全100
  • 网络专业的网站建设价格网站生成app工具
  • 有关网站开发的国外书籍电子商务
  • 免费网站模块免费推广引流平台
  • 做网站开发的公司企业网页
  • 企业官方网站管理制度电商网站开发需要多少钱
  • vb语言做的网站关键词怎么做快速的有排名
  • 食品企业网站建设方案seo优化广告
  • 如何快速找到做网站的客户商业推广
  • 长业建设集团有限公司网站中国职业培训在线官方网站
  • 网站建设xs029网络推广怎么找客户
  • 服务佳的网站建设百度网址大全 简单版
  • 网站做签到功能竞价恶意点击立案标准
  • 厦门网站建设公司排名百度账号购买1元40个
  • 海珠做网站要多少钱枸橼酸西地那非片是什么
  • 临朐网站做的好的网络优化
  • 手机传奇网站武汉seo百度
  • 做网站的专业术语seo优化公司如何做
  • 广州建设厅网站苏州搜索引擎排名优化商家
  • 酒楼网站模板sem工作内容
  • 网站设置在设备之间共享什么意思海外独立站
  • 新手学做网站教程海外广告联盟平台推广
  • 建设信息网站广州seo优化效果
  • 那个网站可以做空比特币百度推广登录网站
  • 电子商务网站栏目搜索引擎营销的特点有
  • 长沙网建站如何外贸推广
  • 百度收录网站标题电脑培训班附近有吗
  • 做网站banner图起名最好的网站排名