Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: talk/app/webrtc/java/jni/peerconnection_jni.cc

Issue 1257043004: AppRTCDemo: Render each video in a separate SurfaceView (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 : j_callbacks_(jni, j_callbacks), 739 : j_callbacks_(jni, j_callbacks),
740 j_render_frame_id_(GetMethodID( 740 j_render_frame_id_(GetMethodID(
741 jni, GetObjectClass(jni, j_callbacks), "renderFrame", 741 jni, GetObjectClass(jni, j_callbacks), "renderFrame",
742 "(Lorg/webrtc/VideoRenderer$I420Frame;)V")), 742 "(Lorg/webrtc/VideoRenderer$I420Frame;)V")),
743 j_can_apply_rotation_id_(GetMethodID( 743 j_can_apply_rotation_id_(GetMethodID(
744 jni, GetObjectClass(jni, j_callbacks), 744 jni, GetObjectClass(jni, j_callbacks),
745 "canApplyRotation", "()Z")), 745 "canApplyRotation", "()Z")),
746 j_frame_class_(jni, 746 j_frame_class_(jni,
747 FindClass(jni, "org/webrtc/VideoRenderer$I420Frame")), 747 FindClass(jni, "org/webrtc/VideoRenderer$I420Frame")),
748 j_i420_frame_ctor_id_(GetMethodID( 748 j_i420_frame_ctor_id_(GetMethodID(
749 jni, *j_frame_class_, "<init>", "(III[I[Ljava/nio/ByteBuffer;)V")), 749 jni, *j_frame_class_, "<init>", "(III[I[Ljava/nio/ByteBuffer;J)V")),
750 j_texture_frame_ctor_id_(GetMethodID( 750 j_texture_frame_ctor_id_(GetMethodID(
751 jni, *j_frame_class_, "<init>", 751 jni, *j_frame_class_, "<init>",
752 "(IIILjava/lang/Object;I)V")), 752 "(IIILjava/lang/Object;IJ)V")),
753 j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")), 753 j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")),
754 can_apply_rotation_set_(false), 754 can_apply_rotation_set_(false),
755 can_apply_rotation_(false) { 755 can_apply_rotation_(false) {
756 CHECK_EXCEPTION(jni); 756 CHECK_EXCEPTION(jni);
757 } 757 }
758 758
759 virtual ~JavaVideoRendererWrapper() {} 759 virtual ~JavaVideoRendererWrapper() {}
760 760
761 void RenderFrame(const cricket::VideoFrame* video_frame) override { 761 void RenderFrame(const cricket::VideoFrame* video_frame) override {
762 ScopedLocalRefFrame local_ref_frame(jni()); 762 ScopedLocalRefFrame local_ref_frame(jni());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 const_cast<uint8*>(frame->GetUPlane()), frame->GetChromaSize()); 810 const_cast<uint8*>(frame->GetUPlane()), frame->GetChromaSize());
811 jobject v_buffer = jni()->NewDirectByteBuffer( 811 jobject v_buffer = jni()->NewDirectByteBuffer(
812 const_cast<uint8*>(frame->GetVPlane()), frame->GetChromaSize()); 812 const_cast<uint8*>(frame->GetVPlane()), frame->GetChromaSize());
813 jni()->SetObjectArrayElement(planes, 0, y_buffer); 813 jni()->SetObjectArrayElement(planes, 0, y_buffer);
814 jni()->SetObjectArrayElement(planes, 1, u_buffer); 814 jni()->SetObjectArrayElement(planes, 1, u_buffer);
815 jni()->SetObjectArrayElement(planes, 2, v_buffer); 815 jni()->SetObjectArrayElement(planes, 2, v_buffer);
816 return jni()->NewObject( 816 return jni()->NewObject(
817 *j_frame_class_, j_i420_frame_ctor_id_, 817 *j_frame_class_, j_i420_frame_ctor_id_,
818 frame->GetWidth(), frame->GetHeight(), 818 frame->GetWidth(), frame->GetHeight(),
819 static_cast<int>(frame->GetVideoRotation()), 819 static_cast<int>(frame->GetVideoRotation()),
820 strides, planes); 820 strides, planes, frame);
821 } 821 }
822 822
823 // Return a VideoRenderer.I420Frame referring texture object in |frame|. 823 // Return a VideoRenderer.I420Frame referring texture object in |frame|.
824 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) { 824 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) {
825 NativeHandleImpl* handle = 825 NativeHandleImpl* handle =
826 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle()); 826 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle());
827 jobject texture_object = reinterpret_cast<jobject>(handle->GetHandle()); 827 jobject texture_object = reinterpret_cast<jobject>(handle->GetHandle());
828 int texture_id = handle->GetTextureId(); 828 int texture_id = handle->GetTextureId();
829 return jni()->NewObject( 829 return jni()->NewObject(
830 *j_frame_class_, j_texture_frame_ctor_id_, 830 *j_frame_class_, j_texture_frame_ctor_id_,
831 frame->GetWidth(), frame->GetHeight(), 831 frame->GetWidth(), frame->GetHeight(),
832 static_cast<int>(frame->GetVideoRotation()), 832 static_cast<int>(frame->GetVideoRotation()),
833 texture_object, texture_id); 833 texture_object, texture_id, frame);
834 } 834 }
835 835
836 JNIEnv* jni() { 836 JNIEnv* jni() {
837 return AttachCurrentThreadIfNeeded(); 837 return AttachCurrentThreadIfNeeded();
838 } 838 }
839 839
840 ScopedGlobalRef<jobject> j_callbacks_; 840 ScopedGlobalRef<jobject> j_callbacks_;
841 jmethodID j_render_frame_id_; 841 jmethodID j_render_frame_id_;
842 jmethodID j_can_apply_rotation_id_; 842 jmethodID j_can_apply_rotation_id_;
843 ScopedGlobalRef<jclass> j_frame_class_; 843 ScopedGlobalRef<jclass> j_frame_class_;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 } 947 }
948 948
949 JOW(void, VideoRenderer_freeGuiVideoRenderer)(JNIEnv*, jclass, jlong j_p) { 949 JOW(void, VideoRenderer_freeGuiVideoRenderer)(JNIEnv*, jclass, jlong j_p) {
950 delete reinterpret_cast<VideoRendererWrapper*>(j_p); 950 delete reinterpret_cast<VideoRendererWrapper*>(j_p);
951 } 951 }
952 952
953 JOW(void, VideoRenderer_freeWrappedVideoRenderer)(JNIEnv*, jclass, jlong j_p) { 953 JOW(void, VideoRenderer_freeWrappedVideoRenderer)(JNIEnv*, jclass, jlong j_p) {
954 delete reinterpret_cast<JavaVideoRendererWrapper*>(j_p); 954 delete reinterpret_cast<JavaVideoRendererWrapper*>(j_p);
955 } 955 }
956 956
957 JOW(long, VideoRenderer_shallowCopyNativeFrame)(
958 JNIEnv* jni, jclass, jlong j_frame_ptr) {
959 return reinterpret_cast<long>(
960 reinterpret_cast<const cricket::VideoFrame*>(j_frame_ptr)->Copy());
961 }
962
963 JOW(void, VideoRenderer_releaseNativeFrame)(
964 JNIEnv* jni, jclass, jlong j_frame_ptr) {
965 delete reinterpret_cast<const cricket::VideoFrame*>(j_frame_ptr);
966 }
967
957 JOW(void, MediaStreamTrack_free)(JNIEnv*, jclass, jlong j_p) { 968 JOW(void, MediaStreamTrack_free)(JNIEnv*, jclass, jlong j_p) {
958 CHECK_RELEASE(reinterpret_cast<MediaStreamTrackInterface*>(j_p)); 969 CHECK_RELEASE(reinterpret_cast<MediaStreamTrackInterface*>(j_p));
959 } 970 }
960 971
961 JOW(jboolean, MediaStream_nativeAddAudioTrack)( 972 JOW(jboolean, MediaStream_nativeAddAudioTrack)(
962 JNIEnv* jni, jclass, jlong pointer, jlong j_audio_track_pointer) { 973 JNIEnv* jni, jclass, jlong pointer, jlong j_audio_track_pointer) {
963 return reinterpret_cast<MediaStreamInterface*>(pointer)->AddTrack( 974 return reinterpret_cast<MediaStreamInterface*>(pointer)->AddTrack(
964 reinterpret_cast<AudioTrackInterface*>(j_audio_track_pointer)); 975 reinterpret_cast<AudioTrackInterface*>(j_audio_track_pointer));
965 } 976 }
966 977
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 } 1718 }
1708 1719
1709 JOW(void, VideoTrack_nativeRemoveRenderer)( 1720 JOW(void, VideoTrack_nativeRemoveRenderer)(
1710 JNIEnv* jni, jclass, 1721 JNIEnv* jni, jclass,
1711 jlong j_video_track_pointer, jlong j_renderer_pointer) { 1722 jlong j_video_track_pointer, jlong j_renderer_pointer) {
1712 reinterpret_cast<VideoTrackInterface*>(j_video_track_pointer)->RemoveRenderer( 1723 reinterpret_cast<VideoTrackInterface*>(j_video_track_pointer)->RemoveRenderer(
1713 reinterpret_cast<VideoRendererInterface*>(j_renderer_pointer)); 1724 reinterpret_cast<VideoRendererInterface*>(j_renderer_pointer));
1714 } 1725 }
1715 1726
1716 } // namespace webrtc_jni 1727 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698