api.video-reactnative-live-stream icon indicating copy to clipboard operation
api.video-reactnative-live-stream copied to clipboard

[Feat]: Unpublish stream

Open talhatsk opened this issue 9 months ago • 29 comments

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

talhatsk avatar May 15 '24 12:05 talhatsk

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?

ThibaultBee avatar May 15 '24 14:05 ThibaultBee

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 avatar May 15 '24 14:05 talhatsk

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

talhatsk avatar May 15 '24 14:05 talhatsk

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.

ThibaultBee avatar May 16 '24 07:05 ThibaultBee

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

talhatsk avatar May 16 '24 07:05 talhatsk

Hi,

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

ThibaultBee avatar May 16 '24 11:05 ThibaultBee

Hi,

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

Yes, that would also work

talhatsk avatar May 16 '24 11:05 talhatsk

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

ThibaultBee avatar May 23 '24 07:05 ThibaultBee

HaishinKit.swift

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

talhatsk avatar May 23 '24 09:05 talhatsk

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

ThibaultBee avatar Jun 10 '24 08:06 ThibaultBee

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

yes thats correct

talhatsk avatar Jun 10 '24 09:06 talhatsk

Could you test the iOS version of the main branch?

ThibaultBee avatar Jun 10 '24 13:06 ThibaultBee

Could you test the iOS version of the main branch?

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

talhatsk avatar Jun 10 '24 15:06 talhatsk

Yes Please :) You can run:

yarn && yarn example ios

ThibaultBee avatar Jun 10 '24 15:06 ThibaultBee

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.

talhatsk avatar Jun 11 '24 13:06 talhatsk

hmm. I can see FCUnpublish in Wireshark in the iOS example. See: Screenshot 2024-06-11 at 16 50 16

ThibaultBee avatar Jun 11 '24 14:06 ThibaultBee

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.

xoraingroup avatar Jun 12 '24 05:06 xoraingroup

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

talhatsk avatar Jun 12 '24 07:06 talhatsk

Could you add an issue for this in HaishinKit?

ThibaultBee avatar Jun 12 '24 07:06 ThibaultBee

FCUnpublish() followed by closeStream()

reported. Link

talhatsk avatar Jun 12 '24 08:06 talhatsk

Could you test the android version on main branch?

ThibaultBee avatar Jul 12 '24 09:07 ThibaultBee

Have you made any progress on the iOS part?

ThibaultBee avatar Jul 23 '24 07:07 ThibaultBee

Have you made any progress on the iOS part?

it is in progress yet.

talhatsk avatar Jul 24 '24 09:07 talhatsk

Have you made any progress on the iOS part?

@ThibaultBee PR is up for iOS haishinkit

talhatsk avatar Jul 29 '24 07:07 talhatsk

Have you made any progress on the iOS part?

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

talhatsk avatar Jul 30 '24 08:07 talhatsk

Waiting for next HK release

ThibaultBee avatar Aug 08 '24 13:08 ThibaultBee

Have you test the fix made for Android?

ThibaultBee avatar Aug 26 '24 14:08 ThibaultBee

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

ThibaultBee avatar Sep 11 '24 09:09 ThibaultBee

Could you test on 2.0.1?

ThibaultBee avatar Sep 11 '24 09:09 ThibaultBee