简体   繁体   English

视频不流式传输

[英]Video not streaming

I wrote a simple webapp for a huge amount of streamers.我为大量流媒体编写了一个简单的 web 应用程序。 The streams are stable but audio/video not showing up.流是稳定的,但音频/视频不显示。

Maybe you have a clue why.也许你知道为什么。

See https://github.com/enexusde/Maven-Many-Videomeeting-RTC-OnlineServlet3.0https://github.com/enexusde/Maven-Many-Videomeeting-RTC-OnlineServlet3.0

To start the app simply write mvn in the console, all goals are used from the maven defaultGoal.要启动应用程序,只需在控制台中编写mvn ,所有目标都使用 maven 默认目标。

Then start two browser tabs having the url http://localhost:8080/vc/.然后启动两个具有 url http://localhost:8080/vc/ 的浏览器选项卡。

Regards问候

I've forked and modified your project on GitHub.我已经在 GitHub 上分叉并修改了您的项目。 Working code and setup instructions can be found here .工作代码和设置说明可以在这里找到。

Here is how it looks with 4 tabs open.这是打开 4 个选项卡后的外观。 You can see local session id on top right and corresponding sessions ids on each remote videos.您可以在右上角看到本地 session id,并在每个远程视频上看到相应的会话 id。 I used VCam for debugging.我使用VCam进行调试。 That's why the trial text:这就是为什么试用文本: 在此处输入图像描述


There are some issues to fix:有一些问题需要解决:

  1. Major issue is the comparison if (y != "complete") .主要问题是比较if (y != "complete") You are comparing event object with "complete" string.您正在将事件 object 与“完整”字符串进行比较。 You end up sending offer SDP without any ICE candidate.你最终会在没有任何 ICE 候选人的情况下发送 offer SDP。 Using if (self.peerConn.iceGatheringState === "complete") ref fixes part of the problem.使用if (self.peerConn.iceGatheringState === "complete") ref修复了部分问题。 With this change Receiver sees the Sender's video.通过此更改,接收者可以看到发送者的视频。
  2. From Receiver side you create answer and send back SDP immediately .从接收方您创建答案并立即发回 SDP。 ICE candidate collections starts after you call createAnswer() or createOffer() . ICE 候选 collections 在您调用createAnswer()createOffer()后启动。 So you are sending SDP without any ICE candidates.因此,您发送的 SDP 没有任何 ICE 候选人。
    After you fix this other issue is that on Sender side there are no onAddStream and streamEventsChangedHandler handlers.解决此问题后,另一个问题是在 Sender 端没有onAddStreamstreamEventsChangedHandler处理程序。 Thus Sender never gets to set received stream to corresponding <video> element.因此,发件人永远无法将收到的 stream 设置为相应的<video>元素。
  3. RTCPeerConnection is capable of both sending and receiving video/audio streams with same connection object. RTCPeerConnection 能够通过相同的连接 object发送接收视频/音频流。 You can set setRemoteDescription() on Sender as well.您也可以在 Sender 上设置setRemoteDescription() You don't have to maintain separate Sender and Receiver connection objects.您不必维护单独的 Sender 和 Receiver 连接对象。 Major improvement here could be you combine Sender and Receiver classes in to one Connection class.这里的主要改进可能是将 Sender 和 Receiver 类合并到一个Connection class 中。 This way you create only n-1 connections, for n participants, at each participant side.这样,您只需在每个参与者端为 n 个参与者创建 n-1 个连接。 And on server you need to track only n connections and not n*(n-1).在服务器上,您只需要跟踪 n 个连接,而不是 n*(n-1)。
  4. RTCPeerConnection.onaddstream is deprecated . RTCPeerConnection.onaddstream弃用 Use RTCPeerConnection.ontrack property使用RTCPeerConnection.ontrack 属性
  5. Serve web pages over secure channel(HTTPS).通过安全通道 (HTTPS) 提供 web 页面。 Because browsers won't let your web page access media hardware over insecure(HTTP).因为浏览器不会让您的 web 页面通过不安全 (HTTP) 访问媒体硬件。 ref . 参考 Localhost(127.0.0.1) is exception.本地主机(127.0.0.1)是例外。
    You can configure tomcat7-maven-plugin in pom.xml to serve pages on HTTPs.您可以在 pom.xml 中配置tomcat7-maven-plugin以在 HTTPs 上提供页面。 Steps to setup HTTPs are in the README.md file.设置 HTTPs 的步骤在README.md文件中。
  6. You need to have more timeout delay .你需要有更多的超时延迟 2 seconds is very less. 2秒非常少。 Clients may have very low latency streaming among them, due this direct P2P connection, and high latency connecting to your server.由于这种直接的 P2P 连接和连接到您的服务器的高延迟,客户端之间的流式传输延迟可能非常低。 So if they can't connect to server doesn't mean they stopped communicating.因此,如果他们无法连接到服务器并不意味着他们停止了通信。 Once you establish connection between clients the server's role is over until they logoff explicitly.一旦您在客户端之间建立连接,服务器的角色就结束了,直到他们明确注销。
  7. Due to Chrome autoplay policy you can't start playing other's video directly.由于 Chrome自动播放政策,您无法直接开始播放其他人的视频。 So had to add an overly over the page to force user interaction.所以不得不在页面上添加一个过度来强制用户交互。 This won't be an issue once you have login implemented.一旦您实施了登录,这将不是问题。
  8. Acquire local media streams before you create Room object, preferably immediately after page load and before user get past overlay.在创建房间 object 之前获取本地媒体流,最好是在页面加载之后和用户通过覆盖之前。 If user delays providing device access permissions, your Room object will have already completed all connection procedures with other peers without sharing any local audio/video streams.如果用户延迟提供设备访问权限,您的 Room object 将已经完成与其他对等方的所有连接程序,而不会共享任何本地音频/视频流。 If you handle it later you'll have to add tracks/streams to all connections again.如果您稍后处理它,您将不得不再次将曲目/流添加到所有连接。
  9. Did little bit of restructuring.做了一点重组。 On server side I moved public inner classes from MeetSessions.java to separate files.在服务器端,我将公共内部类从MeetSessions.java 移动到单独的文件中。 It was getting hard to understand the code.理解代码变得越来越困难。 Something with the index.html .带有index.html的东西。

    I've tested the code in LAN/Wi-Fi using Windows PC, Android phone, and tablet.我已经使用 Windows PC、Android 手机和平板电脑测试了 LAN/Wi-Fi 中的代码。 If you host your server in public domain you may need TURN server as well for these reasons .如果您在公共域中托管您的服务器,出于这些原因,您可能还需要TURN服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM