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 Simulcast To RTMP #2792

Merged

Conversation

johzzy
Copy link
Contributor

@johzzy johzzy commented Dec 16, 2021

Rule: One simulcast(low,mid,high) stream to Multiple rtmp streams ( rtmp://xxx_{low,mid,high} )

Related Link: #2420, #2659

(cherry picked from commit e147e4acb29494591244884e635a4661a2b7fb46)
(cherry picked from commit 4f5bc370ca42257937df047a813eca870198e04b)
(cherry picked from commit 98559793a446cafee1f06d1d5162937e78d26d21)
(cherry picked from commit b8a3796dfd3e38142014b2ec0667d5c2e3368e7d)
… rtmp.

(cherry picked from commit 35e442a45def4beda2d8625114e731366935b98e)
(cherry picked from commit f7d3d392a998cced55fc82e169b21853dcd02fa1)
@codecov-commenter
Copy link

codecov-commenter commented Dec 16, 2021

Codecov Report

Merging #2792 (ac0159b) into feature/simulcast (ea11d6c) will decrease coverage by 0.16%.
The diff coverage is 0.00%.

Impacted file tree graph

@@                  Coverage Diff                  @@
##           feature/simulcast    #2792      +/-   ##
=====================================================
- Coverage              59.78%   59.62%   -0.17%     
=====================================================
  Files                    121      121              
  Lines                  51394    51535     +141     
=====================================================
  Hits                   30727    30727              
- Misses                 20667    20808     +141     

| Impacted Files | Coverage Δ | |'

Translated to English while maintaining the markdown structure:

'| Impacted Files | Coverage Δ | |
|---|---|---|
| trunk/src/app/srs_app_rtc_conn.cpp | 9.73% <0.00%> (-0.10%) | ⬇️ |
| trunk/src/app/srs_app_rtc_source.cpp | 11.30% <0.00%> (-0.93%) | ⬇️ |
| trunk/src/app/srs_app_rtc_source.hpp | 9.09% <ø> (ø) | |'

Translated to English while maintaining the markdown structure:

| trunk/src/app/srs_app_rtc_source.hpp | 9.09% <ø> (ø) | |
| trunk/src/app/srs_app_source.cpp | 0.66% <0.00%> (-0.01%) | ⬇️ |


Continue to review full report at Codecov.

Legend - Click here to learn more
| Δ = absolute <relative> (impact), ø = not affected, ? = missing data |

Translated to English while maintaining the markdown structure:

| Δ = absolute <relative> (impact), ø = not affected, ? = missing data |

Powered by Codecov. Last update ea11d6c...ac0159b. Read the comment docs.

TRANS_BY_GPT3

@xiaozhihong xiaozhihong self-assigned this Dec 16, 2021
return err;
}

srs_error_t do_bridger(SrsRtmpFromRtcBridger *&bridger, SrsRequest* r, std::vector<SrsRtcVideoRecvTrack*>& video_tracks) {
Copy link
Collaborator

@xiaozhihong xiaozhihong Dec 19, 2021

Choose a reason for hiding this comment

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

This should be classified as a member function of SrsRTCPublishStream.

TRANS_BY_GPT3

Copy link
Member

@winlinvip winlinvip Dec 21, 2021

Choose a reason for hiding this comment

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

Does this part of the code look like a Refactor improvement?

Please don't go off-topic, CR. This PR is to solve the issue of supporting Simulcast for RTMP, so unrelated modifications should not be made.

If you want to improve the code, please kindly create a separate PR. This way, it will be easier for everyone to reach a consensus.

Thank you!

TRANS_BY_GPT3

@@ -1123,6 +1123,56 @@ SrsRtcPublishStream::~SrsRtcPublishStream()
stat->on_disconnect(cid_.c_str());
}

#ifdef SRS_FFMPEG_FIT
inline SrsRtmpFromRtcBridger* create_bridger(SrsLiveSource *rtmp) {
Copy link
Collaborator

@xiaozhihong xiaozhihong Dec 19, 2021

Choose a reason for hiding this comment

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

This writing style is a bit flashy. Currently, the hierarchy is not that complex. Can we directly create a new object at the place where this function is called?

TRANS_BY_GPT3

Copy link
Contributor Author

@johzzy johzzy Dec 20, 2021

Choose a reason for hiding this comment

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

This is to open a door for the development of future business using the factory pattern.

TRANS_BY_GPT3

Copy link
Member

@winlinvip winlinvip Dec 21, 2021

Choose a reason for hiding this comment

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

Do not design and use packaging excessively in advance. If the factory pattern is not currently needed, do not use it prematurely.

If the factory pattern is needed later, it is not too late to use it.

First of all, everyone should be able to understand why this change is made. We all need to be able to understand it, and this is the first principle. Understanding does not only mean being able to read the code, but also recognizing that this modification is reasonable and optimal.

TRANS_BY_GPT3


extern srs_error_t do_bridger_for_single(SrsRtmpFromRtcBridger *&bridger, SrsRequest *r);

std::string update_stream(size_t i, const SrsRtcTrackDescription* track_desc, const SrsRequest* rr) {
Copy link
Collaborator

@xiaozhihong xiaozhihong Dec 19, 2021

Choose a reason for hiding this comment

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

You can add some comments here to indicate the change of stream name from simulcast rtc to rtmp.

TRANS_BY_GPT3

SrsRtmpFromRtcBridger* bridger;

srs_error_t create_bridger(size_t i, SrsRequest* rr) {
assert(!bridger);
Copy link
Collaborator

@xiaozhihong xiaozhihong Dec 19, 2021

Choose a reason for hiding this comment

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

Should use srs_assert

TRANS_BY_GPT3

public:
SimulcastBridgerAdapter(std::vector<SrsRtcVideoRecvTrack*>& video_tracks): SrsRtmpFromRtcBridger(nullptr) {
for (auto& track: video_tracks) {
contexts_.emplace_back(BridgerContext{track->track_desc_, nullptr, nullptr});
Copy link
Collaborator

@xiaozhihong xiaozhihong Dec 19, 2021

Choose a reason for hiding this comment

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

C++11 is not recommended for temporary use

TRANS_BY_GPT3

return err;
}

srs_error_t on_rtp(SrsRtpPacket *pkt) override {
Copy link
Collaborator

@xiaozhihong xiaozhihong Dec 19, 2021

Choose a reason for hiding this comment

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

This function seems to be duplicated

TRANS_BY_GPT3

Copy link
Contributor Author

@johzzy johzzy Dec 20, 2021

Choose a reason for hiding this comment

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

No, this is necessary.

TRANS_BY_GPT3

Copy link
Collaborator

@xiaozhihong xiaozhihong Dec 28, 2021

Choose a reason for hiding this comment

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

SrsRtmpFromRtcBridger::on_rtp
srs_error_t on_rtp(SrsRtpPacket *pkt) override

image
image

Is it really unnecessary?

TRANS_BY_GPT3

@@ -1669,6 +1670,7 @@ srs_error_t SrsMetaCache::update_data(SrsMessageHeader* header, SrsOnMetaDataPac

srs_error_t SrsMetaCache::update_ash(SrsSharedPtrMessage* msg)
{
assert(msg->payload);
Copy link
Member

@winlinvip winlinvip Dec 21, 2021

Choose a reason for hiding this comment

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

If you want to use assert, please use srs_assert.

TRANS_BY_GPT3

@johzzy johzzy force-pushed the johnny/feature/simulcast branch 4 times, most recently from e405359 to edaae38 Compare December 22, 2021 08:36
contexts_.emplace_back(BridgerContext{track->track_desc_, NULL, NULL});
}
}

Copy link
Collaborator

@xiaozhihong xiaozhihong Dec 28, 2021

Choose a reason for hiding this comment

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

The entire function below is also repetitive code, only the implementation of dispatch_audio is necessary.

TRANS_BY_GPT3

std::map<uint32_t, SrsRtmpFromRtcBridger*> bridgers_;
std::vector<SrsLiveSource*> sources_;

SrsCommonMessage copy;
Copy link
Collaborator

@xiaozhihong xiaozhihong Dec 28, 2021

Choose a reason for hiding this comment

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

This member variable is not needed, it can be directly defined in the function.

TRANS_BY_GPT3

}
};

class SimulcastBridgerAdapter: public SrsRtmpFromRtcBridger {
Copy link
Collaborator

@xiaozhihong xiaozhihong Dec 28, 2021

Choose a reason for hiding this comment

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

In addition, it is best to define classes in hpp files to maintain consistent code style.

TRANS_BY_GPT3

break;
}

// restore
Copy link
Collaborator

@xiaozhihong xiaozhihong Dec 28, 2021

Choose a reason for hiding this comment

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

C++11 functions, not recommended, replace them.

TRANS_BY_GPT3

johzzy added a commit to johzzy/srs that referenced this pull request Feb 14, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Feb 14, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Feb 14, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Feb 15, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Feb 16, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Feb 17, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Feb 18, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Feb 26, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Mar 1, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Mar 4, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Mar 7, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Mar 9, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Mar 14, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Mar 15, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Mar 17, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Mar 19, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Mar 19, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Mar 28, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Apr 1, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Apr 6, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Apr 7, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Apr 11, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request May 9, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request May 18, 2022
* add SimulcastBridgerAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Jun 10, 2022
* add SimulcastBridgeAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Jun 19, 2022
* add SimulcastBridgeAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Jul 9, 2022
* add SimulcastBridgeAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
johzzy added a commit to johzzy/srs that referenced this pull request Jun 26, 2023
* add SimulcastBridgeAdapter, support simulcast to rtmp.
* shared rtmp packet for dispatch_audio.
@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
TransByAI Translated by AI/GPT.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants