apivideo / api.video-reactnative-live-stream

React Native RTMP live stream client. Made with ♥ by api.video
https://api.video
MIT License
181 stars 33 forks source link

[Feat]: Unpublish stream #79

Open talhatsk opened 6 months ago

talhatsk commented 6 months ago

Version

2.0.0

Environment that reproduces the issue

Device iPhone xs max iOS 16.1

Use case description

Currently, the stop() method disconnects the stream but doesn't unpublish it from the server. How can we unpublish the stream?

Proposed solution

There should be a method to unpublish the stream from server as well.

Alternative solutions

No response

ThibaultBee commented 6 months ago

Hi,

I guess you are talking about RTMP Command message. I don't think there is an official unpublish message. Which command message do you have in mind? (FCUnpublish, closeStream?)

I am just curious, what server do you use? Because if the connection is closed. There is no need to explicit unpublish.

Do you have the same issue with Android?

talhatsk commented 6 months ago

Hi,

I guess you are talking about RTMP Command message. I don't think there is an official unpublish message. Which command message do you have in mind? (FCUnpublish, closeStream?)

I am just curious, what server do you use? Because if the connection is closed. There is no need to explicit unpublish.

Do you have the same issue with Android?

its FCUnpublish command. so what happen is if the stream gets unpublished then we get webhooks from rtmp server and if we close the stream (which is happening right now), webhooks won't be triggered and we have to wait for the timeout. Can we get any method which can send FCUnpublish command

talhatsk commented 6 months ago

Hi,

I guess you are talking about RTMP Command message. I don't think there is an official unpublish message. Which command message do you have in mind? (FCUnpublish, closeStream?)

I am just curious, what server do you use? Because if the connection is closed. There is no need to explicit unpublish.

Do you have the same issue with Android?

and yes it is same for android

ThibaultBee commented 6 months ago

Hi, I guess you are talking about RTMP Command message. I don't think there is an official unpublish message. Which command message do you have in mind? (FCUnpublish, closeStream?) I am just curious, what server do you use? Because if the connection is closed. There is no need to explicit unpublish. Do you have the same issue with Android?

its FCUnpublish command. so what happen is if the stream gets unpublished then we get webhooks from rtmp server and if we close the stream (which is happening right now), webhooks won't be triggered and we have to wait for the timeout. Can we get any method which can send FCUnpublish command

If the connection between the device and your server is lost, you won't get a FCUnpublish and your webhooks won't be triggered. In that case, you will face the same issue and there is nothing we can do about it.

talhatsk commented 6 months ago

Hi, I guess you are talking about RTMP Command message. I don't think there is an official unpublish message. Which command message do you have in mind? (FCUnpublish, closeStream?) I am just curious, what server do you use? Because if the connection is closed. There is no need to explicit unpublish. Do you have the same issue with Android?

its FCUnpublish command. so what happen is if the stream gets unpublished then we get webhooks from rtmp server and if we close the stream (which is happening right now), webhooks won't be triggered and we have to wait for the timeout. Can we get any method which can send FCUnpublish command

If the connection between the device and your server is lost, you won't get a FCUnpublish and your webhooks won't be triggered. In that case, you will face the same issue and there is nothing we can do about it.

Yes that is ok, network outage may occur or peer disconnections. But that is usually rare.
But we need intentional control to unpublish our stream to complete the flow. So a method would be good enough to unpublish stream along with existing closing stream

ThibaultBee commented 6 months ago

Hi,

For the implementation, I would rather like that stopStream calls FCUnpublish automatically instead of adding a specific method.

talhatsk commented 6 months ago

Hi,

For the implementation, I would rather like that stopStream calls FCUnpublish automatically instead of adding a specific method.

Yes, that would also work

ThibaultBee commented 5 months ago

I made a fix in the Android library. Could you have a look at HaishinKit.swift (the iOS library)?

talhatsk commented 5 months ago

HaishinKit.swift

it checks FCUnpublish to send a call to server to unpublish if let fcPublishName { connection.call("FCUnpublish", responder: nil, arguments: fcPublishName) }

ThibaultBee commented 5 months ago

Just to confirm. The argument in the FCUnpublish is going to be the provided StreamKey. Is it what you expect?

talhatsk commented 5 months ago

Just to confirm. The argument in the FCUnpublish is going to be the provided StreamKey. Is it what you expect?

yes thats correct

ThibaultBee commented 5 months ago

Could you test the iOS version of the main branch?

talhatsk commented 5 months ago

Could you test the iOS version of the main branch?

sure, i have to test the example folder on the main branch?

ThibaultBee commented 5 months ago

Yes Please :) You can run:

yarn && yarn example ios
talhatsk commented 5 months ago

Could you test the iOS version of the main branch?

so i've tested the main branch code, unfortunately its behaving the same way as before. I'm not getting any webhooks fired as it should be on the call of unpublish. The patchset is not working i guess.

ThibaultBee commented 5 months ago

hmm. I can see FCUnpublish in Wireshark in the iOS example. See:

Screenshot 2024-06-11 at 16 50 16
xoraingroup commented 5 months ago

Hi there,

I was testing the main branch as well. The FCUnpublish() followed by closeStream() does not delete the stream properly from rtmp server. RTMP server reports connection closed by peerdue to closeStream() which is not the intended effect. In term of unpublishing the stream FCUnpublish command must be followed by deleteStream() command.

Here is the packet captured from OBS while starting and stopping.

image

Can you provide an updated build with above modification.

talhatsk commented 5 months ago

@ThibaultBee I guess that must be the issue, closeStream() is not killing the stream properly. can we replace or add deleteStream()?

ThibaultBee commented 5 months ago

Could you add an issue for this in HaishinKit?

talhatsk commented 5 months ago

FCUnpublish() followed by closeStream()

reported. Link

ThibaultBee commented 4 months ago

Could you test the android version on main branch?

ThibaultBee commented 3 months ago

Have you made any progress on the iOS part?

talhatsk commented 3 months ago

Have you made any progress on the iOS part?

it is in progress yet.

talhatsk commented 3 months ago

Have you made any progress on the iOS part?

@ThibaultBee PR is up for iOS haishinkit

talhatsk commented 3 months ago

Have you made any progress on the iOS part?

deleteStream PR is merged @ThibaultBee. You can integrate it in the package now.

ThibaultBee commented 3 months ago

Waiting for next HK release

ThibaultBee commented 2 months ago

Have you test the fix made for Android?

ThibaultBee commented 2 months ago

Release 2.0.1 is made with HK 1.9.3 that should fix this.

ThibaultBee commented 2 months ago

Could you test on 2.0.1?