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

Add stream_id in the http_callback interface callback of on_publish #2838

Closed
wants to merge 1 commit into from

Conversation

stormbirds
Copy link

@stormbirds stormbirds commented Jan 3, 2022

#2837
Added the stream ID attribute in the on_publish callback event, currently only implemented for rtmp connection, not yet understood the process for rtc.


TRANS_BY_GPT3

@codecov-commenter
Copy link

codecov-commenter commented Jan 3, 2022

Codecov Report

Merging #2838 (144fb82) into feature/gb28181 (72ad526) will decrease coverage by 0.00%.
The diff coverage is 17.54%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           feature/gb28181    #2838      +/-   ##
===================================================
- Coverage            59.86%   59.85%   -0.01%     
===================================================
  Files                  121      121              
  Lines                51333    51353      +20     
===================================================
+ Hits                 30729    30738       +9     
- Misses               20604    20615      +11     

| Impacted Files | Coverage Δ | |'

Translated to English while maintaining the markdown structure:

'| Impacted Files | Coverage Δ | |
|---|---|---|
| trunk/src/app/srs_app_edge.cpp | 0.00% <0.00%> (ø) | |
| trunk/src/app/srs_app_http_hooks.cpp | 0.00% <0.00%> (ø) | |
| trunk/src/app/srs_app_http_stream.cpp | 0.00% <0.00%> (ø) | |
| trunk/src/app/srs_app_rtc_api.cpp | 0.00% <0.00%> (ø) | |

Translated to English while maintaining the markdown structure:

| trunk/src/app/srs_app_edge.cpp | 0.00% <0.00%> (ø) | |
| trunk/src/app/srs_app_http_hooks.cpp | 0.00% <0.00%> (ø) | |
| trunk/src/app/srs_app_http_stream.cpp | 0.00% <0.00%> (ø) | |
| trunk/src/app/srs_app_rtc_api.cpp | 0.00% <0.00%> (ø) | |
| trunk/src/app/srs_app_rtc_conn.cpp | 10.39% <0.00%> (-0.02%) | ⬇️ |
| trunk/src/app/srs_app_rtc_source.cpp | 12.45% <0.00%> (-0.02%) | ⬇️ |
| trunk/src/app/srs_app_rtc_source.hpp | 9.09% <ø> (ø) | |
| trunk/src/app/srs_app_rtmp_conn.cpp | 0.00% <0.00%> (ø) | |
| trunk/src/app/srs_app_source.cpp | 0.66% <0.00%> (ø) | |

Translated to English while maintaining the markdown structure:

| trunk/src/app/srs_app_rtc_source.hpp | 9.09% <ø> (ø) | |
| trunk/src/app/srs_app_rtmp_conn.cpp | 0.00% <0.00%> (ø) | |
| trunk/src/app/srs_app_source.cpp | 0.66% <0.00%> (ø) | |
| trunk/src/app/srs_app_statistic.cpp | 28.22% <42.10%> (+0.67%) | ⬆️ |
| ... and 2 more | |


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 72ad526...144fb82. Read the comment docs.

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Jan 4, 2022

👍 Take matters into your own hands, and you will have enough clothing and food.

TRANS_BY_GPT3

return srs_error_wrap(err, "rtmp: callback on publish");
}

std::string stream_id = "vid-" + srs_random_str(7);
Copy link

@jinleileiking jinleileiking Jan 4, 2022

Choose a reason for hiding this comment

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

stream_id has already been generated, right? There is no need to generate it again here.

TRANS_BY_GPT3

Copy link
Member

@winlinvip winlinvip Jan 4, 2022

Choose a reason for hiding this comment

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

According to the URL, it is better to obtain the statistic stream object and then retrieve the ID.

TRANS_BY_GPT3

Copy link
Author

@stormbirds stormbirds Jan 4, 2022

Choose a reason for hiding this comment

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

It is better to obtain the statistic stream object based on the URL and then retrieve the ID.

I just tested it and it is possible to obtain the statistic stream object through the URL. This method is actually more reasonable. Previously, I didn't think of it because I haven't looked at the SRS source code much. I will submit a new method here, so I suggest closing this PR. Also, thank you for providing the idea.

TRANS_BY_GPT3

Copy link
Member

Choose a reason for hiding this comment

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

NICE 👍

@@ -825,17 +826,18 @@ srs_error_t SrsRtmpConn::publishing(SrsLiveSource* source)
return srs_error_wrap(err, "rtmp: referer check");
}
}

if ((err = http_hooks_on_publish()) != srs_success) {
return srs_error_wrap(err, "rtmp: callback on publish");
Copy link

@jinleileiking jinleileiking Jan 4, 2022

Choose a reason for hiding this comment

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

This part has been deleted, cannot be restored, and will not invoke this hook anymore?

TRANS_BY_GPT3

@duiniuluantanqin
Copy link
Member

duiniuluantanqin commented Jan 4, 2022

The changes you made are too significant.
17 files and a series of interfaces have been modified. What if we need app_id/vhost_id/param_id in the future?
And this hasn't even involved rtc and gb yet.

Can we refer to the handling method of server_id?

obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));

Alternatively, we can discuss other more reasonable approaches.

ps:
#2837 (comment)
After reviewing your requirements, can't the app and stream be combined into one continuous flow? I don't think the stream_id is necessary.

TRANS_BY_GPT3

@stormbirds
Copy link
Author

stormbirds commented Jan 4, 2022

This change you made is too big. 17 files, a series of interfaces have been modified. What if we need app_id/vhost_id/param_id in the future? And this hasn't even involved rtc and gb yet.

Can we refer to the handling method of server_id?

obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));

Or we can discuss other more reasonable approaches.

ps: #2837 (comment) I went back to look at your requirement, can't the app+stream determine the stream? I feel like stream_id is not necessary.

Yes, it can be determined. The problem is that every time I need this stream information, I have to request the streams API to fetch the entire list, and then compare and filter out the streams that meet the criteria. I think it would be better to directly retrieve the specific information of this stream using the streams?id=streamId method.

TRANS_BY_GPT3

@stormbirds
Copy link
Author

stormbirds commented Jan 4, 2022

This change you made is too big. 17 files, a series of interfaces have been modified. What if we need app_id/vhost_id/param_id in the future? And this hasn't even involved rtc and gb yet.

Can we refer to the handling method of server_id?

obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));

Or we can discuss other more reasonable approaches.

ps: #2837 (comment) I went back to look at your requirement, can't the app+stream determine the stream together? I feel like stream_id is not necessary.

Also, if multiple playback requests in gb28181 use the same app and stream, it seems that it is impossible to distinguish which specific stream.

TRANS_BY_GPT3

@stormbirds stormbirds closed this Jan 4, 2022
@winlinvip winlinvip changed the title 在on_publish的http_callback接口回调中增加stream_id Add stream_id in the http_callback interface callback of on_publish Jul 29, 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
TransByAI Translated by AI/GPT.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hope to add the stream_id attribute in the on_publish callback interface.
5 participants