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

Support composited bridges for 1:N protocols converting. v6.0.41 #3392

Merged
merged 22 commits into from
Apr 1, 2023

Conversation

winlinvip
Copy link
Member

@winlinvip winlinvip commented Jan 28, 2023

In SRS 5.0, the bridge is attached to source, used to covert from one protocol to another one. For example, when configured RTMP to RTC:

vhost __defaultVhost__ {
    rtc { enabled on;  rtmp_to_rtc on; }
}

When publish stream to SRS by RTMP client, a bridge will be created and attached to source:

srs_error_t SrsRtmpConn::acquire_publish(SrsLiveSource* source) {
    SrsRtmpToRtcBridge* bridge = new SrsRtmpToRtcBridge(rtc);
    source->set_bridge(bridge);
}

Then all RTMP packets will be fed to bridge and allowd to be devliered by WebRTC. Similarly, a SrsSrtToRtmpBridge is used to convert SRT to RTMP stream, and a SrsRtcToRtmpBridge is for coverting RTC to RTMP.

It works well for SRT => RTMP, RTMP => RTC, RTC => RTMP. But, what happends if need SRT => RTC? Well, it actually combiles two bridges, first SRT => RTMP then RTMP => RTC, this is complex and an extra layer is introduced, this PR is to refine the bridge to allow directly and simultaneously coverting, such as:

SRT => RTMP
SRT => RTC

In this PR, we need to:

1. Rename SrsRtcFromRtmpBridge to SrsRtmpToRtcBridge
2. Rename SrsRtmpFromRtcBridge to SrsRtcToRtmpBridge
3. Rename SrsRtmpFromSrtBridge to SrsSrtToRtmpBridge
@winlinvip winlinvip changed the title Refine bridge to bridge chain for 1:N protocol covert Refine to bridge chain for 1:N protocol covert Jan 28, 2023
@winlinvip winlinvip changed the title Refine to bridge chain for 1:N protocol covert Refine to composite bridges for 1:N protocol covert Jan 28, 2023
@winlinvip winlinvip changed the title Refine to composite bridges for 1:N protocol covert Refine to composite bridges for 1:N protocols covert Jan 28, 2023
@winlinvip winlinvip changed the title Refine to composite bridges for 1:N protocols covert Refine to composite bridges for 1:N protocols coverting Jan 28, 2023
@winlinvip winlinvip added the ReadyToMerge Can be merged with the final review. label Feb 18, 2023
@xiaozhihong
Copy link
Collaborator

xiaozhihong commented Feb 24, 2023

The current structure may have one issue. If all bridges are closed, any protocol can push the same named stream. For example, rtmp can push live/livestream, srt can push live/livestream, rtc can push live/livestream. However, these three streams have different content.

In the future, it may be possible to create an independent source that is not tied to any specific protocol, which can be used to manage streams.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Feb 25, 2023

The current structure may have one problem. If all bridges are closed, any protocol can push the same named stream. For example, rtmp pushes live/livestream, srt pushes live/livestream, rtc pushes live/livestream, but these three streams have different contents.

In the future, it may be possible to create a protocol-independent source to manage streams.

Confirmed, currently it checks if the stream exists regardless of whether the bridge is enabled or not, but there is a non-atomic operation issue. Created a separate issue to address it. #3491

TRANS_BY_GPT3

Copy link
Collaborator

@xiaozhihong xiaozhihong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@winlinvip winlinvip force-pushed the develop branch 3 times, most recently from c056094 to 2ac9eb8 Compare March 23, 2023 06:02
@winlinvip winlinvip changed the title Refine to composite bridges for 1:N protocols coverting Support composited bridges for 1:N protocols converting. v6.0.41 Apr 1, 2023
@winlinvip winlinvip merged commit dcd02fe into ossrs:develop Apr 1, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ReadyToMerge Can be merged with the final review. TransByAI Translated by AI/GPT.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants