简体   繁体   English

如何在Red5中处理多个视频流?

[英]How to handle multiple video streams in Red5?

I am writing a Red5 application that provides 1-on-1 video chat to a Flash client over RTMP . 我正在编写一个Red5应用程序,它通过RTMP向Flash客户端提供一对一的视频聊天。

Unfortunately most tutorials I was able to find were sketchy at best and the documentation of Red5 itself tends to be vague when it comes to API concepts and intended usage. 遗憾的是,我能够找到的大多数教程都是粗略的,而且当涉及API概念和预期用法时,Red5本身的文档往往含糊不清。

In short, I am a bit stuck and looking for hints on Red5 ApplicationAdapter implementation. 简而言之,我有点卡住并寻找有关Red5 ApplicationAdapter实现的提示。 Gnarly details are as follows: Gnarly细节如下:

  • First of all, the connections come in two flavors: visitors and consultants. 首先,这些联系有两种:访客和顾问。 A visitor should be able to indicate which consultant it wishes to communicate with. 访问者应该能够指出它希望与哪个顾问沟通。 A consultant simply gets connected to the requesting visitor as long as the consultant is not busy servicing another. 只要顾问不忙于为另一个顾问服务,顾问就会直接与请求的访问者建立联系。

  • Obviously, every RTMP connection has two-way traffic: both sending and receiving video. 显然,每个RTMP连接都有双向流量:发送和接收视频。 From the standpoint of the server, connections bring in a bunch of video streams that get their receiving endpoints assigned by request. 从服务器的角度来看,连接带来了一堆视频流,这些视频流可以通过请求分配接收端点。

  • Since several video conversations can be in progress simultaneously, the main task of the application is to handle the mapping of visitor streams to consultants and provide a list indicating each consultant's state (busy/available) via AMF . 由于几个视频对话可以同时进行,因此应用程序的主要任务是处理访客流到顾问的映射,并提供一个列表,通过AMF指示每个顾问的状态(忙/可用)。

So, all in all, I have a pretty good idea what I am aiming for but how to achieve it with Red5 is still a bit of a mystery. 所以,总而言之,我非常清楚我的目标是什么,但如何用Red5实现它仍然有点神秘。

Hopefully someone can enlighten me in any or all of the following: 希望有人可以在以下任何或所有方面启发我:

  1. What is the easiest way to establish the connection type (visitor/consultant)? 建立连接类型(访客/顾问)的最简单方法是什么?

  2. Which API classes should be used to implement a persistent, globally accessible list of active connections for reporting the state of each consultant? 应该使用哪些API类来实现持久的,全局可访问的活动连接列表,以报告每个顾问的状态?

  3. How to switch receving endpoints dynamically when the goal is to connect a specific visitor to the selected consultant? 当目标是将特定访问者连接到选定的顾问时,如何动态切换接收端点?

Saul , 扫罗,

1.What is the easiest way to establish the connection type (visitor/consultant)? 1.建立连接类型(访客/顾问)的最简单方法是什么?

assuming that both(visitor/consultant) are using flex client via which they start publishing their live video stream ,here you need to make sure that each published video stream name is unique (HOWTO is already mentioned in demo apps) 假设两个(访客/顾问)都使用Flex客户端开始发布他们的实时视频流,这里你需要确保每个发布的视频流名称都是唯一的 (HOWTO已经在演示应用程序中提到)

2.Which API classes should be used to implement a persistent, globally accessible list of active connections for reporting the state of each consultant? 2.应该使用哪些API类来实现持久的,全局可访问的活动连接列表,以报告每个顾问的状态?

and for providing the list of active connections you simply need to store(preferably in your db) each user's id with the stream name (which is also available as a tutorial demo app ) to connect to. 并且为了提供活动连接列表,您只需要存储(最好在您的数据库中)每个用户的id以及要连接的流名称(也可作为教程演示应用程序提供 )。

I believe all the code is available for the red5 demos Do try oflaDemo , simpleSubscriber , fitcDemo demo apps. 我相信所有代码都可用于red5演示尝试oflaDemo,simpleSubscriber,fitcDemo演示应用程序。

I hope I am closer to your solution. 我希望我更接近你的解决方案。

Since Oflademo or red5 is capable of 1v1 chats, then replicate this code to make around 50 chats. 由于Oflademo或red5能够进行1v1聊天,然后复制此代码以进行大约50次聊天。 You can maintain a table with the following columns : 您可以使用以下列维护表:

  • chat room number (1 to 50) 聊天室号码(1到50)
  • user1 USER1
  • user2 用户2
  • status(0 or 1 - unoccupied or occupied) 状态(0或1 - 未占用或占用)

If let say a visitor V22 wants to get consulted from consultor C33, then a program can detect the first unoccupied room from 1 to 50, if the 7th room is unoccupied then, redirect V22 and C33 to room 7 and change status to 1(occupied). 如果让访客V22想要咨询顾问C33,那么程序可以从1到50检测到第一个未占用的房间,如果第7个房间未被占用,则将V22和C33重定向到房间7并将状态改为1(占用) )。 After the video call, the status can be reset to 0, and the table at roomno:7 , user1 of roomno:7, user2 of roomno:7, can be set to NULL. 在视频通话之后,状态可以重置为0,并且roomno:7的user1,roomno:7的user1,roomno:7的user2的表可以设置为NULL。 Its like maintaining tables in a restaurant in a computer. 它就像在电脑里的餐厅里维护桌子一样。

You can basically develop multiple chatting using 1to1 using a database and php queries, no need to edit any swf code or maintain a complicated server etc. 您基本上可以使用1to1使用数据库和php查询开发多个聊天,无需编辑任何swf代码或维护复杂的服务器等。

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

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