Expose ViECaptureImpl::DisconnectCaptureDevice() to JNI of WebRTCDemo and call it before releasing camera to deregister the corresponding framecallback. Also stop camera after stop remote rendering as the correct termination order.

BUG=4448
TEST=Manual Test
R=glaznev@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/46649004

Cr-Commit-Position: refs/heads/master@{#8785}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8785 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
braveyao@webrtc.org 2015-03-19 00:12:23 +00:00
parent 8cc47e926c
commit 5506a93efd
3 changed files with 10 additions and 1 deletions

View File

@ -538,6 +538,12 @@ JOWW(jint, VideoEngine_connectCaptureDevice)(JNIEnv* jni, jobject j_vie,
return vie_data->capture->ConnectCaptureDevice(camera_num, channel);
}
JOWW(jint, VideoEngine_disconnectCaptureDevice)(JNIEnv* jni, jobject j_vie,
jint channel) {
VideoEngineData* vie_data = GetVideoEngineData(jni, j_vie);
return vie_data->capture->DisconnectCaptureDevice(channel);
}
JOWW(jint, VideoEngine_startCapture)(JNIEnv* jni, jobject j_vie,
jint camera_num) {
VideoEngineData* vie_data = GetVideoEngineData(jni, j_vie);

View File

@ -468,7 +468,6 @@ public class MediaEngine implements VideoDecodeEncodeObserver {
return;
}
check(vie.stopSend(videoChannel) == 0, "StopSend");
stopCamera();
check(vie.stopReceive(videoChannel) == 0, "StopReceive");
if (externalCodec != null) {
check(vie.deRegisterExternalReceiveCodec(videoChannel,
@ -480,6 +479,7 @@ public class MediaEngine implements VideoDecodeEncodeObserver {
check(vie.stopRender(videoChannel) == 0, "StopRender");
check(vie.removeRenderer(videoChannel) == 0, "RemoveRenderer");
}
stopCamera(); // Stop capturer after remote renderer.
svRemote = null;
vieRunning = false;
}
@ -612,6 +612,8 @@ public class MediaEngine implements VideoDecodeEncodeObserver {
private void stopCamera() {
check(vie.stopCapture(currentCameraHandle) == 0, "Failed StopCapture");
svLocal = null;
check(vie.disconnectCaptureDevice(videoChannel) == 0,
"Failed to disconnect capture device");
check(vie.releaseCaptureDevice(currentCameraHandle) == 0,
"Failed ReleaseCaptureDevice");
}

View File

@ -84,6 +84,7 @@ public class VideoEngine {
public native CameraDesc getCaptureDevice(int index);
public native int allocateCaptureDevice(CameraDesc camera);
public native int connectCaptureDevice(int cameraId, int channel);
public native int disconnectCaptureDevice(int channel);
public native int startCapture(int cameraId);
public native int stopCapture(int cameraId);
public native int releaseCaptureDevice(int cameraId);