Open BackPackerDz opened 8 years ago
In WebRtcClient save your VideoCaptureAndroid.
VideoCapturerAndroid videoCapture = getVideoCapturer();
... to switch use
videoCapture.switchCamera(new Runnable() {
@Override
public void run() {
//update your UI
VideoRendererGui.update(localRenderer ...
}
});
@DanielMor Hi,When I try to use ur way but it still unsuccessful Log is VideoCapturerAndroid Camera has not been started
@orangeai
In WebRtcClient.java at line 28 after videoSource
add your videoCapture
instance
private VideoCapturerAndroid videoCapture;
Go to method setCamera
, line 351, before videoSource create a videoCapture
videoCapture = getVideoCapturer();
videoSource = factory.createVideoSource(videoCapture, videoConstraints);
If you want, i suggest rename getVideoCapturer
to createVideoCapturer()
The switchCamera should be the same.
Note:
You only use switch camera after all inicialization. If you need start with back camera you need to change getVideoCapturer()
to start with back camera;
@DanielMor Hi ,I try it but it still can not work
public VideoCapturerAndroid getVideoCaptureAndroid(boolean face){ if(face) return (VideoCapturerAndroid)getVideoCapturer(); else return (VideoCapturerAndroid)createVideoCapturer(); }
and at the switchbutton
Switchcamera.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View v) {
System.out.println(TAG+" change camera" );
isFace = !isFace;
client.getVideoCaptureAndroid(isFace).switchCamera(new Runnable() {
@Override
public void run() {
//update your UI
VideoRendererGui.update(remoteRender,
REMOTE_X, REMOTE_Y,
REMOTE_WIDTH, REMOTE_HEIGHT, scalingType,true);
VideoRendererGui.update(localRender,
LOCAL_X_CONNECTED, LOCAL_Y_CONNECTED,
LOCAL_WIDTH_CONNECTED, LOCAL_HEIGHT_CONNECTED,
scalingType,true);
}
});
}
});`
I already set videocapture instance at setCamera()
at VideoCapturerAndroid.class
camerthread is null so Log show Camera has not been started
thanks for your help
It Works, Thanks @DanielMor
Any solution please ?