apivideo / api.video-flutter-live-stream

Flutter RTMP live stream client. Made with ♥ by api.video
MIT License
65 stars 39 forks source link

[Bug]: Android stream goes on error after some seconds #35

Closed TheFe91 closed 1 year ago

TheFe91 commented 1 year ago

Version

v1.1.1

Which operating systems have you used?

Environment that reproduces the issue

Is it reproducible in the example application?

No

RTMP Server

MUX

Reproduction steps

await apiVideoLiveStreamController.initialize();

await apiVideoLiveStreamController.startStreaming( streamKey: sc.currentStreamKey.value!, url: Strings.muxBaseRtmpUrl, );

* Stream starts normally
* wait 5 to 10 seconds
* Stream goes on error

### Expected result

StreamPack streams over given RTMP

### Actual result

`PlatformException: io.github.thibaultbee.streampack.error.StreamPackError`

### Additional context

Flutter 3.10.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision f92f44110e (5 days ago) • 2023-06-01 18:17:33 -0500 Engine • revision 2a3401c9bb Tools • Dart 3.0.3 • DevTools 2.23.1


### Relevant logs output

```shell
No error is raised in the example application.

Mine is:

PlatformException(io.github.thibaultbee.streampack.error.StreamPackError, io.github.thibaultbee.streampack.error.StreamPackError: java.net.SocketException: Connection error, io.github.thibaultbee.streampack.error.StreamPackError: io.github.thibaultbee.streampack.error.StreamPackError: java.net.SocketException: Connection error
I/flutter (22744): │ ⛔  at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$videoEncoderListener$1.onOutputFrame(BaseStreamer.kt:123)
I/flutter (22744): │ ⛔  at io.github.thibaultbee.streampack.internal.encoders.MediaCodecEncoder$encoderCallback$1.onOutputBufferAvailable(MediaCodecEncoder.kt:109)
I/flutter (22744): │ ⛔  at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1854)
I/flutter (22744): │ ⛔  at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1752)
I/flutter (22744): │ ⛔  at android.os.Handler.dispatchMessage(Handler.java:106)
I/flutter (22744): │ ⛔  at android.os.Looper.loopOnce(Looper.java:226)
I/flutter (22744): │ ⛔  at android.os.Looper.loop(Looper.java:313)
I/flutter (22744): │ ⛔  at android.os.HandlerThread.run(HandlerThread.java:67)
I/flutter (22744): │ ⛔ Caused by: io.github.thibaultbee.streampack.error.StreamPackError: java.net.SocketException: Connection error
I/flutter (22744): │ ⛔  at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$muxListener$1.onOutputFrame(BaseStreamer.kt:135)
I/flutter (22744): │ ⛔  at io.github.thibaultbee.streampack.internal.muxers.flv.FlvMuxer.encode(FlvMuxer.kt:77)
I/flutter (22744): │ ⛔  at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$videoEncoderListener$1.onOutputFrame(BaseStreamer.kt:120)
I/flutter (22744): │ ⛔  ... 7 more
I/flutter (22744): │ ⛔ Caused by: java.net.SocketException: Connection error
I/flutter (22744): │ ⛔  at video.api.rtmpdroid.Rtmp.write(Rtmp.kt:139)
I/flutter (22744): │ ⛔  at io.github.thibaultbee.streampack.ext.rtmp.internal.endpoints.RtmpProducer.write(RtmpProducer.kt:94)
I/flutter (22744): │ ⛔  at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$muxListener$1.onOutputFrame(BaseStreamer.kt:132)
I/flutter (22744): │ ⛔  ... 9 more
I/flutter (22744): │ ⛔ , null)
TheFe91 commented 1 year ago

More logs:

E/RtmpProducer(28643): java.net.SocketException: Connection error
E/RtmpProducer(28643):  at video.api.rtmpdroid.Rtmp.write(Rtmp.kt:139)
E/RtmpProducer(28643):  at io.github.thibaultbee.streampack.ext.rtmp.internal.endpoints.RtmpProducer.write(RtmpProducer.kt:94)
E/RtmpProducer(28643):  at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$muxListener$1.onOutputFrame(BaseStreamer.kt:132)
E/RtmpProducer(28643):  at io.github.thibaultbee.streampack.internal.muxers.flv.FlvMuxer.encode(FlvMuxer.kt:77)
E/RtmpProducer(28643):  at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$videoEncoderListener$1.onOutputFrame(BaseStreamer.kt:120)
E/RtmpProducer(28643):  at io.github.thibaultbee.streampack.internal.encoders.MediaCodecEncoder$encoderCallback$1.onOutputBufferAvailable(MediaCodecEncoder.kt:109)
E/RtmpProducer(28643):  at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1854)
E/RtmpProducer(28643):  at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1752)
E/RtmpProducer(28643):  at android.os.Handler.dispatchMessage(Handler.java:106)
E/RtmpProducer(28643):  at android.os.Looper.loopOnce(Looper.java:226)
E/RtmpProducer(28643):  at android.os.Looper.loop(Looper.java:313)
E/RtmpProducer(28643):  at android.os.HandlerThread.run(HandlerThread.java:67)
TheFe91 commented 1 year ago

Just tried with Android emulator (Pixel 6A API 33) and it works... I really don't understand, I'm astonished

TheFe91 commented 1 year ago

I tried from my app to stream over my youtube channel and it worked. So it must be something related to my app + mux...From the example app + mux however it worked as I wrote above. Hope these details help!

TheFe91 commented 1 year ago

I think I solved the problem. I was missing the scaffoldKey from the main Scaffold, so it probably had a re-render that caused an error within StreamPack.

Closing