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

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

Issue 1357923002: wip Move SurfaceTexture.updateTexImage() from video renderers into MediaCodecVideoDecoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 : j_callbacks_(jni, j_callbacks), 760 : j_callbacks_(jni, j_callbacks),
761 j_render_frame_id_(GetMethodID( 761 j_render_frame_id_(GetMethodID(
762 jni, GetObjectClass(jni, j_callbacks), "renderFrame", 762 jni, GetObjectClass(jni, j_callbacks), "renderFrame",
763 "(Lorg/webrtc/VideoRenderer$I420Frame;)V")), 763 "(Lorg/webrtc/VideoRenderer$I420Frame;)V")),
764 j_frame_class_(jni, 764 j_frame_class_(jni,
765 FindClass(jni, "org/webrtc/VideoRenderer$I420Frame")), 765 FindClass(jni, "org/webrtc/VideoRenderer$I420Frame")),
766 j_i420_frame_ctor_id_(GetMethodID( 766 j_i420_frame_ctor_id_(GetMethodID(
767 jni, *j_frame_class_, "<init>", "(III[I[Ljava/nio/ByteBuffer;J)V")), 767 jni, *j_frame_class_, "<init>", "(III[I[Ljava/nio/ByteBuffer;J)V")),
768 j_texture_frame_ctor_id_(GetMethodID( 768 j_texture_frame_ctor_id_(GetMethodID(
769 jni, *j_frame_class_, "<init>", 769 jni, *j_frame_class_, "<init>",
770 "(IIILjava/lang/Object;IJ)V")), 770 "(IIII[FJ)V")),
771 j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")) { 771 j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")) {
772 CHECK_EXCEPTION(jni); 772 CHECK_EXCEPTION(jni);
773 } 773 }
774 774
775 virtual ~JavaVideoRendererWrapper() {} 775 virtual ~JavaVideoRendererWrapper() {}
776 776
777 void RenderFrame(const cricket::VideoFrame* video_frame) override { 777 void RenderFrame(const cricket::VideoFrame* video_frame) override {
778 ScopedLocalRefFrame local_ref_frame(jni()); 778 ScopedLocalRefFrame local_ref_frame(jni());
779 // Make a shallow copy. |j_callbacks_| is responsible for releasing the 779 // Make a shallow copy. |j_callbacks_| is responsible for releasing the
780 // copy by calling VideoRenderer.renderFrameDone(). 780 // copy by calling VideoRenderer.renderFrameDone().
(...skipping 22 matching lines...) Expand all
803 const_cast<uint8*>(frame->GetUPlane()), frame->GetChromaSize()); 803 const_cast<uint8*>(frame->GetUPlane()), frame->GetChromaSize());
804 jobject v_buffer = jni()->NewDirectByteBuffer( 804 jobject v_buffer = jni()->NewDirectByteBuffer(
805 const_cast<uint8*>(frame->GetVPlane()), frame->GetChromaSize()); 805 const_cast<uint8*>(frame->GetVPlane()), frame->GetChromaSize());
806 jni()->SetObjectArrayElement(planes, 0, y_buffer); 806 jni()->SetObjectArrayElement(planes, 0, y_buffer);
807 jni()->SetObjectArrayElement(planes, 1, u_buffer); 807 jni()->SetObjectArrayElement(planes, 1, u_buffer);
808 jni()->SetObjectArrayElement(planes, 2, v_buffer); 808 jni()->SetObjectArrayElement(planes, 2, v_buffer);
809 return jni()->NewObject( 809 return jni()->NewObject(
810 *j_frame_class_, j_i420_frame_ctor_id_, 810 *j_frame_class_, j_i420_frame_ctor_id_,
811 frame->GetWidth(), frame->GetHeight(), 811 frame->GetWidth(), frame->GetHeight(),
812 static_cast<int>(frame->GetVideoRotation()), 812 static_cast<int>(frame->GetVideoRotation()),
813 strides, planes, frame); 813 strides, planes, jlongFromPointer(frame));
814 } 814 }
815 815
816 // Return a VideoRenderer.I420Frame referring texture object in |frame|. 816 // Return a VideoRenderer.I420Frame referring texture object in |frame|.
817 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) { 817 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) {
818 NativeHandleImpl* handle = 818 NativeHandleImpl* handle =
819 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle()); 819 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle());
820 jobject texture_object = reinterpret_cast<jobject>(handle->GetHandle()); 820 jfloatArray sampling_matrix = jni()->NewFloatArray(16);
821 int texture_id = handle->GetTextureId(); 821 jni()->SetFloatArrayRegion(sampling_matrix, 0, 16, handle->sampling_matrix);
822 return jni()->NewObject( 822 return jni()->NewObject(
823 *j_frame_class_, j_texture_frame_ctor_id_, 823 *j_frame_class_, j_texture_frame_ctor_id_,
824 frame->GetWidth(), frame->GetHeight(), 824 frame->GetWidth(), frame->GetHeight(),
825 static_cast<int>(frame->GetVideoRotation()), 825 static_cast<int>(frame->GetVideoRotation()),
826 texture_object, texture_id, frame); 826 handle->oes_texture_id, sampling_matrix, jlongFromPointer(frame));
827 } 827 }
828 828
829 JNIEnv* jni() { 829 JNIEnv* jni() {
830 return AttachCurrentThreadIfNeeded(); 830 return AttachCurrentThreadIfNeeded();
831 } 831 }
832 832
833 ScopedGlobalRef<jobject> j_callbacks_; 833 ScopedGlobalRef<jobject> j_callbacks_;
834 jmethodID j_render_frame_id_; 834 jmethodID j_render_frame_id_;
835 ScopedGlobalRef<jclass> j_frame_class_; 835 ScopedGlobalRef<jclass> j_frame_class_;
836 jmethodID j_i420_frame_ctor_id_; 836 jmethodID j_i420_frame_ctor_id_;
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size))); 1822 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size)));
1823 stream->ReadAll(buffer.get(), log_size, &read, nullptr); 1823 stream->ReadAll(buffer.get(), log_size, &read, nullptr);
1824 1824
1825 jbyteArray result = jni->NewByteArray(read); 1825 jbyteArray result = jni->NewByteArray(read);
1826 jni->SetByteArrayRegion(result, 0, read, buffer.get()); 1826 jni->SetByteArrayRegion(result, 0, read, buffer.get());
1827 1827
1828 return result; 1828 return result;
1829 } 1829 }
1830 1830
1831 } // namespace webrtc_jni 1831 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698