RootEncoder icon indicating copy to clipboard operation
RootEncoder copied to clipboard

Picture in Picture Mode

Open mneckoee opened this issue 4 years ago • 9 comments

Hi, I want to implement PIP mode for live Streamer. How can I change the texture view while streaming?

mneckoee avatar Jan 04 '22 10:01 mneckoee

In this case you can use background example to know how to replace actual view using replaceView method (You will need use a service to avoid remove stream instance).

The idea is use replaceView with context on surfaceDestroyed callback and wait until your new openglview is recreated and use replaceView on surfaceChanged to reload your preview and if you want go back to activity exactly the same.

pedroSG94 avatar Jan 05 '22 10:01 pedroSG94

What is a "replaceView" ? Do you mean the new openGLView?

mneckoee avatar Jan 05 '22 11:01 mneckoee

This is the method: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtplibrary/src/main/java/com/pedro/rtplibrary/base/Camera2Base.java#L452 https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtplibrary/src/main/java/com/pedro/rtplibrary/base/Camera2Base.java#L457

This method allow you change preview on fly. Context if you want go to background and OpenGlView if you want change OpenGlView (maybe because you last OpenGlView was destroyed and it is not usable anymore).

with new OpenGlView I mean that for Picture in Picture maybe you need to use a widget or other different view that make your Activity die so you can use replaceView for this case.

pedroSG94 avatar Jan 05 '22 11:01 pedroSG94

image

mneckoee avatar Jan 05 '22 11:01 mneckoee

This is the method: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtplibrary/src/main/java/com/pedro/rtplibrary/base/Camera2Base.java#L452 https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtplibrary/src/main/java/com/pedro/rtplibrary/base/Camera2Base.java#L457

This method allow you change preview on fly. Context if you want go to background and OpenGlView if you want change OpenGlView (maybe because you last OpenGlView was destroyed and it is not usable anymore).

with new OpenGlView I mean that for Picture in Picture maybe you need to use a widget or other different view that make your Activity die so you can use replaceView for this case.

you are awesome, I inspect your suggested method and inform you about the result

mneckoee avatar Jan 05 '22 11:01 mneckoee

@mneckoee Hi, did you manage to implement pip mode? @pedroSG94 These url's don't work, can you give working links?

https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtplibrary/src/main/java/com/pedro/rtplibrary/base/Camera2Base.java#L452 https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtplibrary/src/main/java/com/pedro/rtplibrary/base/Camera2Base.java#L457

DenisStadnichenko avatar Feb 01 '24 13:02 DenisStadnichenko

My problem is that after starting the stream, when changing the orientation I want to change the orientation of the preview, but since the stream is already in progress I get an error "Streaming or preview stopped, ignored"

Maybe someone can help me, thank you all in advance!

DenisStadnichenko avatar Feb 01 '24 13:02 DenisStadnichenko

Hello,

Updated links: https://github.com/pedroSG94/RootEncoder/blob/master/library/src/main/java/com/pedro/library/base/Camera2Base.java#L465 https://github.com/pedroSG94/RootEncoder/blob/master/library/src/main/java/com/pedro/library/base/Camera2Base.java#L470

About your case. You can test rotation example in the app module: https://github.com/pedroSG94/RootEncoder/tree/master/app/src/main/java/com/pedro/streamer/rotation

Try to compile the project and test rotation example.

pedroSG94 avatar Feb 01 '24 13:02 pedroSG94

thanks for the quick reply

DenisStadnichenko avatar Feb 01 '24 14:02 DenisStadnichenko