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

服务关系型网站怎么做网站建设 企业文化

服务关系型网站怎么做,网站建设 企业文化,哪些经营范围是包含网站开发的,东莞网站推广哪家好GB28181语音广播这块#xff0c;我们依据GB/T28181-2016针对流程和实例代码#xff0c;做过详细的描述#xff0c;本次主要是探讨下#xff0c;广播数据过来后#xff0c;如何处理。 鉴于我们之前有非常成熟的RTMP|RTSP低延迟播放模块#xff0c;语音广播数据过来后我们依据GB/T28181-2016针对流程和实例代码做过详细的描述本次主要是探讨下广播数据过来后如何处理。 鉴于我们之前有非常成熟的RTMP|RTSP低延迟播放模块语音广播数据过来后调用startAudioPlay()ntsOnInviteAudioBroadcastResponse()处理如下 Override public void ntsOnInviteAudioBroadcastResponse(String sourceID, String targetID, int statusCode, PlaySessionDescription sessionDescription) {handler_.postDelayed(new Runnable() {Overridepublic void run() {Log.i(TAG, ntsOnInviteAudioBroadcastResponse, statusCode: status_code_ sourceID: source_id_ , targetID: target_id_);boolean is_need_destory_rtp true;if (gb28181_agent_ ! null ) {boolean is_need_bye 200status_code_;if (200 status_code_ session_description_ ! null rtp_receiver_handle_ ! 0 ) {MediaSessionDescription audio_des session_description_.getAudioDescription();SDPRtpMapAttribute audio_attr null;if (audio_des ! null audio_des.getRtpMapAttributes() ! null !audio_des.getRtpMapAttributes().isEmpty() )audio_attr audio_des.getRtpMapAttributes().get(0);if ( audio_des ! null audio_attr ! null ) {lib_player_.SetRTPReceiverSSRC(rtp_receiver_handle_, audio_des.getSSRC());lib_player_.SetRTPReceiverPayloadType(rtp_receiver_handle_, audio_attr.getPayloadType(),audio_attr.getEncodingName(), 2, audio_attr.getClockRate());// 如果是PCMA, SDK会默认填 采样率8000, 通道1, 其他音频编码需要手动填入// lib_player_.SetRTPReceiverAudioSamplingRate(rtp_receiver_handle_, 8000);// lib_player_.SetRTPReceiverAudioChannels(rtp_receiver_handle_, 1);lib_player_.SetRTPReceiverRemoteAddress(rtp_receiver_handle_, audio_des.getAddress(), audio_des.getPort());lib_player_.InitRTPReceiver(rtp_receiver_handle_);if (startAudioPlay()) {is_need_bye false;is_need_destory_rtp false;gb_broadcast_source_id_ source_id_;gb_broadcast_target_id_ target_id_;btnGB28181AudioBroadcast.setText(终止GB28181语音广播);btnGB28181AudioBroadcast.setEnabled(true);}}} else {btnGB28181AudioBroadcast.setText(GB28181语音广播);}if (is_need_bye)gb28181_agent_.byeAudioBroadcast(source_id_, target_id_);}if (is_need_destory_rtp)destoryRTPReceiver();}private String source_id_;private String target_id_;private int status_code_;private PlaySessionDescription session_description_;public Runnable set(String source_id, String target_id, int status_code, PlaySessionDescription session_description) {this.source_id_ source_id;this.target_id_ target_id;this.status_code_ status_code;this.session_description_ session_description;return this;}}.set(sourceID, targetID, statusCode, sessionDescription),0); } startAudioPlay()初始化实例后为了保证低延迟拉流端设置0 buffer处于调试方便设置download speed回调2-5秒一次可以看到是不是有音频数据过来由于只需要播放音频不需要视频所以不要设置surface下去然后设置拉流数据回调需要注意的是拉到的audio数据不要转aac输出 private boolean startAudioPlay() {if (player_handle_ ! 0 )return false;player_handle_ lib_player_.SmartPlayerOpen(context_);if (player_handle_ 0)return false;lib_player_.SetSmartPlayerEventCallbackV2(player_handle_,new EventHandePlayerV2());// 缓存大小可以调整lib_player_.SmartPlayerSetBuffer(player_handle_, 0);// lib_player_.SmartPlayerSetFastStartup(player_handle_, 0);// set report download speed(默认2秒一次回调 用户可自行调整report间隔)lib_player_.SmartPlayerSetReportDownloadSpeed(player_handle_, 1, 20);lib_player_.SmartPlayerClearRtpReceivers(player_handle_);lib_player_.SmartPlayerAddRtpReceiver(player_handle_, rtp_receiver_handle_);lib_player_.SmartPlayerSetSurface(player_handle_, null);// lib_player_.SmartPlayerSetRenderScaleMode(player_handle_, 1);lib_player_.SmartPlayerSetAudioOutputType(player_handle_, 1);lib_player_.SmartPlayerSetMute(player_handle_, 0);lib_player_.SmartPlayerSetAudioVolume(player_handle_, 100);lib_player_.SmartPlayerSetExternalAudioOutput(player_handle_, new PlayerExternalPCMOutput());lib_player_.SmartPlayerSetUrl(player_handle_, rtp://ntinternal/rtpreceiver/implemention0);if (0 ! lib_player_.SmartPlayerStartPlay(player_handle_)) {lib_player_.SmartPlayerClose(player_handle_);player_handle_ 0;Log.e(TAG, start audio paly failed);return false;}lib_player_.SmartPlayerSetAudioDataCallback(player_handle_, new PlayerAudioDataOutput());lib_player_.SmartPlayerSetPullStreamAudioTranscodeAAC(player_handle_, 0);if (0 lib_player_.SmartPlayerStartPullStream(player_handle_) ) {// 启动定时器长时间收不到音频数据则停止播放发送BYElast_received_audio_data_time_.set(SystemClock.elapsedRealtime());handler_.postDelayed(new AudioPlayerPCMTimer(player_handle_), AudioPlayerPCMTimer.INTERVAL_MS);}return true; } 调用StartPlay后拿到的audio数据塞到publisher端做回音消除处理 class PlayerExternalPCMOutput implements NTExternalAudioOutput {private int buffer_size_ 0;private ByteBuffer pcm_buffer_ null;Overridepublic ByteBuffer getPcmByteBuffer(int size) {//Log.i(getPcmByteBuffer, size: size);if(size 1)return null;if(buffer_size_ ! size) {buffer_size_ size;pcm_buffer_ ByteBuffer.allocateDirect(buffer_size_);}return pcm_buffer_;}public void onGetPcmFrame(int ret, int sampleRate, int channel, int sampleSize, int is_low_latency) {/*Log.i(onGetPcmFrame, ret: ret , sampleRate: sampleRate , channel: channel , sampleSize: sampleSize ,is_low_latency: is_low_latency buffer_size buffer_size);*/if (null pcm_buffer_)return;pcm_buffer_.rewind();if (ret 0 isGB28181StreamRunning publisherHandle ! 0 )libPublisher.SmartPublisherOnFarEndPCMData(publisherHandle, pcm_buffer_, sampleRate, channel, sampleSize, is_low_latency);} }private static int align(int d, int a) { return (d (a - 1)) ~(a - 1); }class PlayerAudioDataOutput implements NTAudioDataCallback {private int buffer_size_ 0;private int param_info_size_ 0;private ByteBuffer buffer_ null;private ByteBuffer parameter_info_ null;Overridepublic ByteBuffer getAudioByteBuffer(int size) {//Log.i(getAudioByteBuffer, size: size);if( size 1 ) return null;if (size buffer_size_ buffer_ ! null )return buffer_;buffer_size_ align(size 256, 16);buffer_ ByteBuffer.allocateDirect(buffer_size_);// Log.i(getAudioByteBuffer, size: size buffer_size: audio_buffer_size);return buffer_;}Overridepublic ByteBuffer getAudioParameterInfo(int size) {//Log.i(getAudioParameterInfo, size: size);if(size 1) return null;if ( size param_info_size_ parameter_info_ ! null )return parameter_info_;param_info_size_ align(size 32, 16);parameter_info_ ByteBuffer.allocateDirect(param_info_size_);//Log.i(getAudioParameterInfo, size: size buffer_size: param_info_size);return parameter_info_;}public void onAudioDataCallback(int ret, int audio_codec_id, int sample_size, int is_key_frame, long timestamp, int sample_rate, int channel, int parameter_info_size, long reserve) {/*Log.i(onAudioDataCallback, ret: ret , audio_codec_id: audio_codec_id , sample_size: sample_size , timestamp: timestamp ,sample_rate: sample_rate);*/last_received_audio_data_time_.set(SystemClock.elapsedRealtime());} } 如果长时间收不到数据主动断掉音频广播 class AudioPlayerPCMTimer implements Runnable {public static final int THRESHOLD_MS 60*1000; // 暂时设置到1分钟public static final int INTERVAL_MS 10*1000; // 十秒一次, 太频繁影响主线程public AudioPlayerPCMTimer(long handle) {handle_ handle;}Overridepublic void run() {if (0 handle_)return;if (handle_ ! player_handle_) {Log.i(TAG, AudioPlayerPCMTimer handle changed, will stop this timer, handle: handle_ new handle: player_handle_);return;}long last_update_time last_received_audio_data_time_.get();long cur_time SystemClock.elapsedRealtime();// Log.i(TAG, AudioPlayerPCMTimer last_update_time: last_update_time cur_time: cur_time);if ( (last_update_time this.THRESHOLD_MS) cur_time) {// 继续定时器handler_.postDelayed(new AudioPlayerPCMTimer(this.handle_), this.INTERVAL_MS);// Log.i(TAG, AudioPlayerPCMTimer running.);}else {Log.i(TAG, AudioPlayerPCMTimer,trigger threshold, bye audio, stop player.);if (gb_broadcast_source_id_ ! null gb_broadcast_target_id_ ! null) {if (gb28181_agent_ ! null)gb28181_agent_.byeAudioBroadcast(gb_broadcast_source_id_, gb_broadcast_target_id_);}gb_broadcast_source_id_ null;gb_broadcast_target_id_ null;stopAudioPlayer();destoryRTPReceiver();btnGB28181AudioBroadcast.setText(GB28181语音广播);btnGB28181AudioBroadcast.setEnabled(false);}}private long handle_; } 停止广播数据播放 private void stopAudioPlayer() {if (player_handle_ ! 0 ) {lib_player_.SmartPlayerStopPullStream(player_handle_);lib_player_.SmartPlayerStopPlay(player_handle_);lib_player_.SmartPlayerClose(player_handle_);player_handle_ 0;} }销毁RTPReceiver private void destoryRTPReceiver() {if (rtp_receiver_handle_ ! 0) {lib_player_.UnInitRTPReceiver(rtp_receiver_handle_);lib_player_.DestoryRTPReceiverSession(rtp_receiver_handle_);lib_player_.DestoryRTPReceiver(rtp_receiver_handle_);rtp_receiver_handle_ 0;} } 以上是针对GB28181平台端音频广播播放的一点说明感兴趣的开发者可以酌情参考也可以和我探讨Android平台GB28181接入模块的测试。
http://wiki.neutronadmin.com/news/55878/

相关文章:

  • 哈尔滨门户网站设计报价wordpress外链自动保存
  • ps模板下载网站oa网站建设价格
  • 如何创建网站难吗最新网站建设视频
  • 集团公司网站建设求网站资源懂的2021
  • 住房城市乡建设部网站深圳市深度设计咨询有限公司
  • 营销型品牌网站建设价格哪些网站适合推广
  • 网站开发项目的需求分析湘阴网站建设
  • 网站建设课程ppt查询seo
  • 免费个人网站建设直播网站开发要多久
  • 国外创意网站欣赏怎么申请网站空间
  • 国外外贸网站在哪个网站做游戏视频好
  • 网站建设问题表房源网
  • 免费海报素材网站大全网站开发公司需要投入什么资源
  • 企业门户网站用户类型window做网站的软件下载
  • 互联网广告营销公司昆山做网站优化
  • 海兴县网站建设价格无极招聘信息网
  • 佛山新网站建设方案网络营销理论包括哪些
  • 如何在淘宝上接单网站建设短视频制作app
  • 加强信息管理 维护网站建设重庆市建设工程招标投标交易信息网
  • 自己做音乐网站wordpress最新文章
  • 上海有限公司网络seo优化
  • 深圳网站制作联系电话聊城做wap网站公司
  • 怎么创建网站 免费的wordpress 白屏
  • 如何进行公司网站的建设天津网站建设公司哪家好
  • 微信公众号设计网站柳州网站网站建设
  • 网站优化可以做哪些优化西安手机商城网站建设
  • 可信网站 如何验证logo图案生成器
  • 黄岛做网站哪家好网站开发 mvc
  • 济南物流公司网站建设网站优化反馈机制 seo
  • 网站建设思路方法网站制作rss