-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Forward: support config full rtmp url forward to other server #2799
Forward: support config full rtmp url forward to other server #2799
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2799 +/- ##
===========================================
+ Coverage 60.09% 60.94% +0.84%
===========================================
Files 121 121
Lines 51332 53546 +2214
===========================================
+ Hits 30850 32634 +1784
- Misses 20482 20912 +430 | Impacted Files | Coverage Δ | |' Translated to English while maintaining the markdown structure: '| Impacted Files | Coverage Δ | | Translated to English while maintaining the markdown structure: '| trunk/src/app/srs_app_config.hpp | Continue to review full report at Codecov.
Translated to English while maintaining the markdown structure: '|
|
First of all, thank you for submitting the PR. 👍 Then, for comments and explanations, remember to use markdown, don't force adding spaces, for example:
Finally, please take a look at these issues, as they mention some specific scenarios.
Forwarding improvements need to consider these scenarios and require a more comprehensive solution.
|
Okay, I will take a look at these issues and consider how to improve them better. Previously, I also had the idea of writing an API interface to send forward relay tasks support API to send forward relay to other servers. If Mr. Yang is available, please ask him to help check if it is feasible.
|
You gave me a bunch of code, but I can't figure out the specific idea behind it. Could you please refine it for me? Also, please don't mention it in this PR. Please create a separate PR for it. Let's resolve this PR first before simultaneously raising another one. PR is not just about code, it also involves aligning everyone's way of working and thinking.
|
Scenario 1: Domain-level forwarding configuration (supported feature)
curl http://127.0.0.1:1985/api/v1/forward/live/livestream?vhost=ossrs.net&forward_url=rtmp://alicdn.com/live01/livestream01
|
These five scenarios can be covered by one solution. I have made a note of it here: link. Consider whether it is feasible or not, or reply to that issue. Generally, pull requests do not discuss solutions, but rather discuss suitable code implementations.
|
2b0da1a
to
26835b1
Compare
forward backend configuration has been updated to implement the logic. The backend server can refer to server.py for implementation. When users push the stream, they can parse it in conjunction with the backend backend service through the custom push stream Push stream address:
backend Response format:
|
6ac5da9
to
623ca78
Compare
This comment has been minimized.
This comment has been minimized.
You should go to issue #1342 to discuss question. @phusinh |
26835b1
to
109fdc7
Compare
0649ea6
to
109fdc7
Compare
…der to other server.(ossrs#1342)
109fdc7
to
6458e37
Compare
trunk/src/app/srs_app_http_hooks.cpp
Outdated
@@ -482,6 +482,100 @@ srs_error_t SrsHttpHooks::discover_co_workers(string url, string& host, int& por | |||
return err; | |||
} | |||
|
|||
// Request: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put it in full.conf
TRANS_BY_GPT3
trunk/src/app/srs_app_source.cpp
Outdated
} | ||
} | ||
|
||
conf = _srs_config->get_forwards(req->vhost); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a backend, the destination will no longer be used.
TRANS_BY_GPT3
trunk/src/app/srs_app_source.cpp
Outdated
SrsConfDirective* conf = _srs_config->get_forward_backend(req->vhost); | ||
if (conf) { | ||
int count = conf->args.size(); | ||
for (int i = 0; i < count; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not currently supporting multiple.
TRANS_BY_GPT3
trunk/src/app/srs_app_http_hooks.cpp
Outdated
// "code": 0, | ||
// "data": { | ||
// "forwards":[{ | ||
// "url": "rtmp://ossrs.net:1935/live/livestream?auth_token=xxx" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data: {
urls: ["rtmp://xxx", "rtmp://xxx"]
}
If you want to expand:
data {
forwards: xxx
}
TRANS_BY_GPT3
trunk/src/app/srs_app_source.cpp
Outdated
|
||
// For backend config | ||
if (true) { | ||
SrsConfDirective* conf = _srs_config->get_forward_backend(req->vhost); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translate to English:
'Change it into a function.'
Make sure to maintain the markdown structure.
TRANS_BY_GPT3
trunk/src/app/srs_app_source.cpp
Outdated
} | ||
} | ||
|
||
// For destanition config | ||
SrsConfDirective* conf = _srs_config->get_forwards(req->vhost); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translate to English:
'Change the member variable to req_
'
Make sure to maintain the markdown structure.
TRANS_BY_GPT3
trunk/src/app/srs_app_source.cpp
Outdated
|
||
// create temp SrsRequest by url | ||
SrsRequest* freq = new SrsRequest(); | ||
SrsAutoFree(SrsRequest, freq); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to req
.
TRANS_BY_GPT3
trunk/research/api-server/server.py
Outdated
|
||
# match vhost+app+stream to forward url | ||
self.__forwards.append({ | ||
"vhost":"ossrs.net", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to slave,
TRANS_BY_GPT3
trunk/conf/full.conf
Outdated
# "code": 0, | ||
# "data": { | ||
# "urls":[ | ||
# "rtmp://ossrs.net:1935/live/livestream?auth_token=xxx", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change it to slave.
TRANS_BY_GPT3
trunk/src/app/srs_app_source.cpp
Outdated
// For backend config | ||
// If you configure backend service, return backend status(default: false) | ||
bool backend_status = false; | ||
if (((err = create_backend_forwarders(backend_status)) != srs_success) || backend_status) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applied_backend_server
// If the user has enabled the backend and the application is successful, ignore the destination.
// If backend is enabled and applied, ignore destination.
bool applied_backend_server = false;
if (((err = create_backend_forwarders(applied_backend_server)) != srs_success)) {
return err; // srs_error_wrap(err, "create backend applied=%d", applied_backend_server);
}
// If the backend has already been applied, ignore the destination.
// Already applied backend server, ignore destination.
if (applied_backend_server) {
return err;
}
TRANS_BY_GPT3
trunk/src/app/srs_app_source.cpp
Outdated
// get urls on forward backend | ||
std::vector<std::string> urls; | ||
if ((err = SrsHttpHooks::on_forward_backend(backend_url, req_, urls)) != srs_success) { | ||
return srs_error_wrap(err, "get forward backend failed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return srs_error_wrap(err, "get forward backend failed, backend=%s", backend_url.c_str());
trunk/src/app/srs_app_source.cpp
Outdated
// get urls on forward backend | ||
std::vector<std::string> urls; | ||
if ((err = SrsHttpHooks::on_forward_backend(backend_url, req_, urls)) != srs_success) { | ||
return srs_error_wrap(err, "get forward backend failed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return srs_error_wrap(err, "get forward backend failed, backend=%s", backend_url.c_str());
trunk/src/app/srs_app_source.cpp
Outdated
|
||
// initialize the forwarder with request. | ||
if ((err = forwarder->initialize(req, forward_server.str())) != srs_success) { | ||
return srs_error_wrap(err, "init forwarder"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forward_server
You can specify livestream forward the full rtmp address to other server, for example:
Scene: client publish url carry
forward=
forward url has domain and port
forward url is full rtmp address
Scene: backend server configure forward address