Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何在提供rtmp server服务的同时将接收到的流push到其他rtmp或者rtsp #52

Closed
JermineHu opened this issue Apr 8, 2021 · 2 comments

Comments

@JermineHu
Copy link

通过阅读源码,原本以为可以在实现ServerObserver接口的OnNewRTMPPubSession 方法,然后实现流的读取和push,但是发现并没有暴露io读取或者获取流的方法,所以没有希望能提供相应的方法。这个场景主要是用于多平台推流,比如:本地启动一个lalserver用于rtmp serer端,用obs推流到lalserver,然后lalserver同步到抖音、斗鱼、视频号等其他平台,因为目前obs只能支持一个流推送,所以希望lalserver启动的时候也能同步推流到其他平台的rtmp地址。

@q191201771
Copy link
Owner

lal提供了基于IO之上的,包含协议处理的更高层面的封装。(也即net.Conn之上的各种协议的Server、Session)
你的需求可抽象描述为 1pub对多push。(pub/push含义: https://pengrl.com/lal/#/Session)

你可以考虑:

一. 自己基于lal的基础库实现1pub对多push,最基本的实现大概几十行代码,步骤为:

  1. 创建rtmp.Server,设置新session的事件监听回调
  2. 为pub session设置接收数据回调
  3. 创建多个push session
  4. 将pub session的数据转发给多个push session

我后续可能会在app/demo中增加一个示例

二. 直接修改lalserver logic中拼接的逻辑

lalserver目前已支持1pub多push,但是push地址的规则只能指定push的TCP地址(通过配置文件)。push的流名称、参数等信息使用的是pub的流名称。你的需求,各个push的流名称都不相同,和pub的也不相同,所以现阶段没法直接使用lalserver。

你可以直接修改lalserver logic中push地址的拼接逻辑。

我后续可能会:

  1. 配置文件中支持指定push完整url列表。(push TCP地址列表依然保留,业务方可自由选择使用)
  2. HTTP API增加push接口。lalserver通过HTTP Notify向业务方模块回调pub事件,业务方通过HTTP API告知lalserver如何push出去

@q191201771 q191201771 mentioned this issue Jan 23, 2022
32 tasks
@q191201771
Copy link
Owner

这个issue超时移入 #37 中管理了,有问题可随时打开,感谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants