pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.52k stars 770 forks source link

UnsupportedOperationException: eglCreateWindowSurface() Android 4.1.1 on swith camera or stop #5

Closed dimkinware closed 7 years ago

dimkinware commented 7 years ago

Hi! I tried to use your library in project and found few bugs. One of them:

Problem device: ASUS Padfone 2 with Android 4.1.1 (API 16)

App crashes on camera switch or stop streaming. Exception: java.lang.UnsupportedOperationException: eglCreateWindowSurface() can only be called with an instance of SurfaceView, SurfaceHolder or SurfaceTexture at the moment, this will be fixed later. In Camera1ApiManager.clearSurface() method

My solution change argument of this method from Surface to SurfaceHolder:

clearSurface(surfaceView.getHolder());

private void clearSurface(SurfaceHolder texture) {
...
}

I am not expert in video streaming, but I hope you wil use my solution to do your library better.

This fix works fine on all my devices:

ASUS Padfone 2 with Android 4.1.1 (API 16) Samsung Galaxy Tab Pro with Android 4.4.2 Nexus 5 with Android 6.0.1

pedroSG94 commented 7 years ago

fixed. Thanks!!