Java VideoRenderer class may be backed by two different native

classes depending on type of rendering.
Fix crash in AppRtcDemo by calling correct destructor on exit.

BUG=
R=braveyao@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7202 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
glaznev@webrtc.org 2014-09-17 03:26:59 +00:00
parent 40c2aa36f2
commit a59c501c99
2 changed files with 12 additions and 3 deletions

View File

@ -2707,10 +2707,14 @@ JOW(void, VideoCapturer_free)(JNIEnv*, jclass, jlong j_p) {
delete reinterpret_cast<cricket::VideoCapturer*>(j_p); delete reinterpret_cast<cricket::VideoCapturer*>(j_p);
} }
JOW(void, VideoRenderer_free)(JNIEnv*, jclass, jlong j_p) { JOW(void, VideoRenderer_freeGuiVideoRenderer)(JNIEnv*, jclass, jlong j_p) {
delete reinterpret_cast<VideoRendererWrapper*>(j_p); delete reinterpret_cast<VideoRendererWrapper*>(j_p);
} }
JOW(void, VideoRenderer_freeWrappedVideoRenderer)(JNIEnv*, jclass, jlong j_p) {
delete reinterpret_cast<JavaVideoRendererWrapper*>(j_p);
}
JOW(void, MediaStreamTrack_free)(JNIEnv*, jclass, jlong j_p) { JOW(void, MediaStreamTrack_free)(JNIEnv*, jclass, jlong j_p) {
CHECK_RELEASE(reinterpret_cast<MediaStreamTrackInterface*>(j_p)); CHECK_RELEASE(reinterpret_cast<MediaStreamTrackInterface*>(j_p));
} }

View File

@ -176,11 +176,16 @@ public class VideoRenderer {
} }
public void dispose() { public void dispose() {
free(nativeVideoRenderer); if (callbacks == null) {
freeGuiVideoRenderer(nativeVideoRenderer);
} else {
freeWrappedVideoRenderer(nativeVideoRenderer);
}
} }
private static native long nativeCreateGuiVideoRenderer(int x, int y); private static native long nativeCreateGuiVideoRenderer(int x, int y);
private static native long nativeWrapVideoRenderer(Callbacks callbacks); private static native long nativeWrapVideoRenderer(Callbacks callbacks);
private static native void free(long nativeVideoRenderer); private static native void freeGuiVideoRenderer(long nativeVideoRenderer);
private static native void freeWrappedVideoRenderer(long nativeVideoRenderer);
} }