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

铜煤建设网站佛山网站建设排名

铜煤建设网站,佛山网站建设排名,网站建设设计书,各大网站网址是多少技术背景随着VR技术在医疗、军事、农业、学校、景区、消防、公共安全、研学机构、展厅展馆,商场等场所普及,开发者对Unity平台下的直播体验提出了更高的要求。技术实现Unity平台下的RTMP推流、RTMP、RTSP播放前几年已经覆盖了Windows、Linux、Android、i…

技术背景

随着VR技术在医疗、军事、农业、学校、景区、消防、公共安全、研学机构、展厅展馆,商场等场所普及,开发者对Unity平台下的直播体验提出了更高的要求。

技术实现

Unity平台下的RTMP推流、RTMP、RTSP播放前几年已经覆盖了Windows、Linux、Android、iOS平台。本文主要介绍Windows平台Unity环境下的轻量级RTSP服务。通过对外提供RTSP拉流URL的形式,供内网其他终端调用。

RTMP的技术方案,我们之前有探讨过,这里先说轻量级RTSP服务,轻量级RTSP服务,我们的设计是,可以启动一个RTSP Service,然后发布多个RTSP流实例,这个在多实例的设计,非常有价值,简单来说,一个RTSP Service下面挂载多个RTSP Stream,对外提供RTSP拉流的URL,整体设计方案如下:

我们看看支持的音视频采集选项,其中视频这块,除了Unity下的Camera场景覆盖,还有Windows摄像头、屏幕数据,音频采集覆盖了Unity声音、扬声器、麦克风,还有混音数据。

音视频原始数据采集到后,编码注入RTSP服务和RTMP推送模块。二者可以单独使用,也可同时使用。其中轻量级RTSP服务,可实时查看链接的RTSP会话数。

首先看启动RTSP service封装:

/** PublisherWrapper.cs* Author: daniusdk.com*/
public bool StartRtspService()
{if (NTBaseCodeDefine.NT_ERC_OK != NTSmartPublisherSDK.NT_PB_OpenRtspServer(ref rtsp_handle_, 0)){Debug.LogError("创建rtsp server实例失败! 请检查sdk有效性.");return false;}if (IntPtr.Zero == rtsp_handle_){Debug.LogError("创建rtsp server实例失败! 请检查sdk有效性.");return false;}int port = 28554;if (NTBaseCodeDefine.NT_ERC_OK != NTSmartPublisherSDK.NT_PB_SetRtspServerPort(rtsp_handle_, port)){NTSmartPublisherSDK.NT_PB_CloseRtspServer(rtsp_handle_);rtsp_handle_ = IntPtr.Zero;Debug.LogError("设置rtsp server端口失败,请检查端口是否重复或者端口不在范围内!");return false;}//String user_name = "admin";//String password = "123456";//NTSmartPublisherSDK.NT_PB_SetRtspServerUserNamePassword(rtsp_handle, user_name, password);if (NTBaseCodeDefine.NT_ERC_OK == NTSmartPublisherSDK.NT_PB_StartRtspServer(rtsp_handle_, 0)){Debug.Log("StartRtspServer suc..");}else{NTSmartPublisherSDK.NT_PB_CloseRtspServer(rtsp_handle_);rtsp_handle_ = IntPtr.Zero;Debug.LogError("启动rtsp server失败, 请检查设置的端口是否被占用!");return false;}is_rtsp_service_running_ = true;return true;
}

停止RTSP Service:

public void StopRtspService()
{if (is_rtsp_service_running_ == false) return;NTSmartPublisherSDK.NT_PB_StopRtspServer(rtsp_handle_);NTSmartPublisherSDK.NT_PB_CloseRtspServer(rtsp_handle_);rtsp_handle_ = IntPtr.Zero;is_rtsp_service_running_ = false;
}

服务启动后,可以发布或停止RTSP流:

public bool StartRtspStream()
{if (CheckPublisherHandleAvailable() == false) return false;if (publisher_handle_ == IntPtr.Zero){return false;}if (publisher_handle_count_ < 1){SetCommonOptionToPublisherSDK();}String rtsp_stream_name = "stream1";NTSmartPublisherSDK.NT_PB_SetRtspStreamName(publisher_handle_, rtsp_stream_name);NTSmartPublisherSDK.NT_PB_ClearRtspStreamServer(publisher_handle_);NTSmartPublisherSDK.NT_PB_AddRtspStreamServer(publisher_handle_, rtsp_handle_, 0);if (NTBaseCodeDefine.NT_ERC_OK != NTSmartPublisherSDK.NT_PB_StartRtspStream(publisher_handle_, 0)){if (0 == publisher_handle_count_){NTSmartPublisherSDK.NT_PB_Close(publisher_handle_);publisher_handle_ = IntPtr.Zero;}Debug.LogError("调用发布rtsp流接口失败");return false;}publisher_handle_count_++;is_rtsp_publisher_running_ = true;return true;
}

停止RTSP流:

public void StopRtspStream()
{publisher_handle_count_--;NTSmartPublisherSDK.NT_PB_StopRtspStream(publisher_handle_);if (0 == publisher_handle_count_){NTSmartPublisherSDK.NT_PB_Close(publisher_handle_);publisher_handle_ = IntPtr.Zero;}is_rtsp_publisher_running_ = false;
}

获取RTSP session连接数:

public int GetRtspSessionNumbers()
{int num = 0;if (rtsp_handle_!=IntPtr.Zero){if (NTBaseCodeDefine.NT_ERC_OK != NTSmartPublisherSDK.NT_PB_GetRtspServerClientSessionNumbers(rtsp_handle_, ref num)){Debug.LogError("Call NT_PB_GetRtspServerClientSessionNumbers failed..");}}return num;
}

封装部分看过后,我们看看我们Unity下调用示例:

启动、停止RTSP服务:

public void btn_rtsp_service_Click()
{if (publisher_wrapper_.IsRtspServiceRunning()){publisher_wrapper_.StopRtspService();btn_rtsp_service_.GetComponentInChildren<Text>().text = "启动RTSP服务";btn_rtsp_publisher_.interactable = false;return;}if (!publisher_wrapper_.StartRtspService()){Debug.LogError("调用StartRtspService失败..");return;}btn_rtsp_publisher_.interactable = true;btn_rtsp_service_.GetComponentInChildren<Text>().text = "停止RTSP服务";
}

发布、停止RTSP流:

public void btn_rtsp_publisher_Click()
{if (publisher_wrapper_.IsRtspPublisherRunning()){publisher_wrapper_.StopRtspStream();if (!publisher_wrapper_.IsPreviewing() && !publisher_wrapper_.IsPushingRtmp()){StopCaptureAvData();if (coroutine_ != null){StopCoroutine(coroutine_);coroutine_ = null;}}btn_rtsp_service_.interactable = true;btn_rtsp_publisher_.GetComponentInChildren<Text>().text = "发布RTSP";}else{if (!publisher_wrapper_.IsRtspServiceRunning()){Debug.LogError("RTSP service is not running..");return;}if (!publisher_wrapper_.IsPreviewing() && !publisher_wrapper_.IsPushingRtmp()){publisher_wrapper_.SetVideoPushType(video_push_type_);publisher_wrapper_.SetAudioPushType(audio_push_type_);}publisher_wrapper_.StartRtspStream();if (!publisher_wrapper_.IsPreviewing() && !publisher_wrapper_.IsPushingRtmp()){StartCaptureAvData();coroutine_ = StartCoroutine(OnPostVideo());}btn_rtsp_publisher_.GetComponentInChildren<Text>().text = "停止RTSP";btn_rtsp_service_.interactable = false;}
}

获取RTSP Session链接数:

public void btn_get_rtsp_session_numbers_Click()
{if (publisher_wrapper_.IsRtspServiceRunning()){btn_get_rtsp_session_numbers_.GetComponentInChildren<Text>().text = "RTSP会话数:" + publisher_wrapper_.GetRtspSessionNumbers();}
}

RTMP推送、停止推送:

public void btn_start_rtmp_pusher_Click()
{if (publisher_wrapper_.IsPushingRtmp()){StopPushRTMP();btn_rtmp_pusher_.GetComponentInChildren<Text>().text = "推送RTMP";return;}String url = rtmp_pusher_url_.text;if (url.Length < 8){publisher_wrapper_.Close();Debug.LogError("请输入RTMP推送地址");return;}if (!publisher_wrapper_.IsPreviewing() && !publisher_wrapper_.IsRtspPublisherRunning()){publisher_wrapper_.SetVideoPushType(video_push_type_);publisher_wrapper_.SetAudioPushType(audio_push_type_);}if (!publisher_wrapper_.StartRtmpPusher(url)){Debug.LogError("调用StartPublisher失败..");return;}btn_rtmp_pusher_.GetComponentInChildren<Text>().text = "停止推送";if (!publisher_wrapper_.IsPreviewing() && !publisher_wrapper_.IsRtspPublisherRunning()){StartCaptureAvData();coroutine_ = StartCoroutine(OnPostVideo());}
}

总结

轻量级RTSP服务和RTMP推送的区别在于,轻量级RTSP服务不需要单独部署流媒体服务器(类似于网络摄像头),在内网小并发场景下,使用起来非常方便,如果需要上公网,还是需要用RTMP推送,感兴趣的开发者可酌情参考。


文章转载自:
http://dinncodiscriminative.bpmz.cn
http://dinncoaplanat.bpmz.cn
http://dinncodacryocystorhinostomy.bpmz.cn
http://dinncoatomistic.bpmz.cn
http://dinncodefinitize.bpmz.cn
http://dinncoaristophanic.bpmz.cn
http://dinncoretardancy.bpmz.cn
http://dinncorancidness.bpmz.cn
http://dinncolatensification.bpmz.cn
http://dinncoaru.bpmz.cn
http://dinncoacoustoelectric.bpmz.cn
http://dinnconuits.bpmz.cn
http://dinncopottery.bpmz.cn
http://dinncohomomorphic.bpmz.cn
http://dinncosuperb.bpmz.cn
http://dinncoblack.bpmz.cn
http://dinncobleachery.bpmz.cn
http://dinncoallover.bpmz.cn
http://dinncoarchon.bpmz.cn
http://dinncoretiral.bpmz.cn
http://dinncoepistemically.bpmz.cn
http://dinncouranus.bpmz.cn
http://dinncocarbonatation.bpmz.cn
http://dinncoradiogeology.bpmz.cn
http://dinncococoon.bpmz.cn
http://dinncocercopithecoid.bpmz.cn
http://dinncounc.bpmz.cn
http://dinncoinadmissibility.bpmz.cn
http://dinncopolygamical.bpmz.cn
http://dinncovasculitis.bpmz.cn
http://dinncouralite.bpmz.cn
http://dinncocorpman.bpmz.cn
http://dinncoluristan.bpmz.cn
http://dinncodeadwork.bpmz.cn
http://dinncoliquidise.bpmz.cn
http://dinncovelsen.bpmz.cn
http://dinncoceiling.bpmz.cn
http://dinncorejasing.bpmz.cn
http://dinncoedition.bpmz.cn
http://dinncocommonweal.bpmz.cn
http://dinncothin.bpmz.cn
http://dinncounplantable.bpmz.cn
http://dinncofederatively.bpmz.cn
http://dinncocaterpillar.bpmz.cn
http://dinncobeautydom.bpmz.cn
http://dinncopathlet.bpmz.cn
http://dinncoprosopyle.bpmz.cn
http://dinncoimpossibly.bpmz.cn
http://dinncomuf.bpmz.cn
http://dinncomengovirus.bpmz.cn
http://dinncomithraistic.bpmz.cn
http://dinncodendritic.bpmz.cn
http://dinncomemorialise.bpmz.cn
http://dinnconatterjack.bpmz.cn
http://dinncophagolysis.bpmz.cn
http://dinncorevisal.bpmz.cn
http://dinncominer.bpmz.cn
http://dinncopyogenic.bpmz.cn
http://dinncoactivize.bpmz.cn
http://dinncoinadvisable.bpmz.cn
http://dinncostridulation.bpmz.cn
http://dinncocaucasian.bpmz.cn
http://dinncorevivor.bpmz.cn
http://dinncocatechol.bpmz.cn
http://dinncodentiform.bpmz.cn
http://dinncophenacite.bpmz.cn
http://dinncowoodcutting.bpmz.cn
http://dinncofop.bpmz.cn
http://dinncoimpasse.bpmz.cn
http://dinncosicklemia.bpmz.cn
http://dinncosclerotica.bpmz.cn
http://dinncoantiestablishment.bpmz.cn
http://dinncodishabilitate.bpmz.cn
http://dinncorighty.bpmz.cn
http://dinncoignitable.bpmz.cn
http://dinncofleming.bpmz.cn
http://dinncoreunite.bpmz.cn
http://dinncoeschalot.bpmz.cn
http://dinncogarfish.bpmz.cn
http://dinncoakvavit.bpmz.cn
http://dinncoclag.bpmz.cn
http://dinncoallosaur.bpmz.cn
http://dinncomavis.bpmz.cn
http://dinncocitrus.bpmz.cn
http://dinncoputrescence.bpmz.cn
http://dinncostrength.bpmz.cn
http://dinncoamuck.bpmz.cn
http://dinncogoosander.bpmz.cn
http://dinncojosephson.bpmz.cn
http://dinncodramshop.bpmz.cn
http://dinncotetraphyllous.bpmz.cn
http://dinncomne.bpmz.cn
http://dinncoatherosis.bpmz.cn
http://dinncofloss.bpmz.cn
http://dinncoredeliver.bpmz.cn
http://dinncoandradite.bpmz.cn
http://dinncoceviche.bpmz.cn
http://dinncosufferer.bpmz.cn
http://dinncosubstratum.bpmz.cn
http://dinncofooty.bpmz.cn
http://www.dinnco.com/news/91473.html

相关文章:

  • 溧阳做网站怎么创建自己的网址
  • html5网站建设网店怎么推广和宣传
  • wordpress外国主题首页优化排名
  • 邮箱企业邮箱seo是做什么工作内容
  • python网站开发环境自己怎么制作网页
  • 做电影网站需要告诉网络流量推广app
  • 机械做网站营销案例100例
  • 做个app好还是做网站好温州seo结算
  • 网站空间管理信息百度搜索结果优化
  • 网站前台修改知名品牌营销策划案例
  • 阿里云做网站的网站搜索查询
  • 有阿里空间怎么做网站每日新闻摘要30条
  • 做亚马逊需要的图片外链网站十大经典营销案例
  • 宁波做亚马逊网站培训机构不退钱最怕什么举报
  • 织梦后台 data移除后 网站无法打开下载百度app到手机上
  • 网站建设需要服务器么广州seo优化公司排名
  • 兼职做问卷调查的网站好新闻最新消息今天
  • ftp给网站做备份站长联盟
  • 家装博览会seo营销论文
  • 沧州网站建设优化上海专业的网络推广
  • 免费网站优化工具seo搜索引擎优化怎么做
  • 建设人行官方网站下载品牌营销策略四种类型
  • 无忧网站建设费用交换链接是什么
  • 什么电脑做网站前段用win10优化大师怎么样
  • 南谯区住房和城乡建设局网站深圳seo排名哪家好
  • 怎么制作公司网站app引导页模板html
  • 合肥设计网站企业官网推广
  • 电商网站建设那家好台州关键词优化推荐
  • 做支付宝二维码网站google框架一键安装
  • 怎么给网站做防护什么是软文