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

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

Issue 1394103005: Revert "Android MediaCodecVideoDecoder: Manage lifetime of texture frames" (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fork NativeHandleImpl and disable texture capture, plus some revert rebase nits 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 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 : j_callbacks_(jni, j_callbacks), 764 : j_callbacks_(jni, j_callbacks),
765 j_render_frame_id_(GetMethodID( 765 j_render_frame_id_(GetMethodID(
766 jni, GetObjectClass(jni, j_callbacks), "renderFrame", 766 jni, GetObjectClass(jni, j_callbacks), "renderFrame",
767 "(Lorg/webrtc/VideoRenderer$I420Frame;)V")), 767 "(Lorg/webrtc/VideoRenderer$I420Frame;)V")),
768 j_frame_class_(jni, 768 j_frame_class_(jni,
769 FindClass(jni, "org/webrtc/VideoRenderer$I420Frame")), 769 FindClass(jni, "org/webrtc/VideoRenderer$I420Frame")),
770 j_i420_frame_ctor_id_(GetMethodID( 770 j_i420_frame_ctor_id_(GetMethodID(
771 jni, *j_frame_class_, "<init>", "(III[I[Ljava/nio/ByteBuffer;J)V")), 771 jni, *j_frame_class_, "<init>", "(III[I[Ljava/nio/ByteBuffer;J)V")),
772 j_texture_frame_ctor_id_(GetMethodID( 772 j_texture_frame_ctor_id_(GetMethodID(
773 jni, *j_frame_class_, "<init>", 773 jni, *j_frame_class_, "<init>",
774 "(IIII[FJ)V")), 774 "(IIILjava/lang/Object;IJ)V")),
775 j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")) { 775 j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")) {
776 CHECK_EXCEPTION(jni); 776 CHECK_EXCEPTION(jni);
777 } 777 }
778 778
779 virtual ~JavaVideoRendererWrapper() {} 779 virtual ~JavaVideoRendererWrapper() {}
780 780
781 void RenderFrame(const cricket::VideoFrame* video_frame) override { 781 void RenderFrame(const cricket::VideoFrame* video_frame) override {
782 ScopedLocalRefFrame local_ref_frame(jni()); 782 ScopedLocalRefFrame local_ref_frame(jni());
783 jobject j_frame = (video_frame->GetNativeHandle() != nullptr) 783 jobject j_frame = (video_frame->GetNativeHandle() != nullptr)
784 ? CricketToJavaTextureFrame(video_frame) 784 ? CricketToJavaTextureFrame(video_frame)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 *j_frame_class_, j_i420_frame_ctor_id_, 820 *j_frame_class_, j_i420_frame_ctor_id_,
821 frame->GetWidth(), frame->GetHeight(), 821 frame->GetWidth(), frame->GetHeight(),
822 static_cast<int>(frame->GetVideoRotation()), 822 static_cast<int>(frame->GetVideoRotation()),
823 strides, planes, javaShallowCopy(frame)); 823 strides, planes, javaShallowCopy(frame));
824 } 824 }
825 825
826 // Return a VideoRenderer.I420Frame referring texture object in |frame|. 826 // Return a VideoRenderer.I420Frame referring texture object in |frame|.
827 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) { 827 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) {
828 NativeHandleImpl* handle = 828 NativeHandleImpl* handle =
829 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle()); 829 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle());
830 jfloatArray sampling_matrix = jni()->NewFloatArray(16); 830 jobject texture_object = reinterpret_cast<jobject>(handle->GetHandle());
831 jni()->SetFloatArrayRegion(sampling_matrix, 0, 16, handle->sampling_matrix); 831 int texture_id = handle->GetTextureId();
832 return jni()->NewObject( 832 return jni()->NewObject(
833 *j_frame_class_, j_texture_frame_ctor_id_, 833 *j_frame_class_, j_texture_frame_ctor_id_,
834 frame->GetWidth(), frame->GetHeight(), 834 frame->GetWidth(), frame->GetHeight(),
835 static_cast<int>(frame->GetVideoRotation()), 835 static_cast<int>(frame->GetVideoRotation()),
836 handle->oes_texture_id, sampling_matrix, javaShallowCopy(frame)); 836 texture_object, texture_id, javaShallowCopy(frame));
837 } 837 }
838 838
839 JNIEnv* jni() { 839 JNIEnv* jni() {
840 return AttachCurrentThreadIfNeeded(); 840 return AttachCurrentThreadIfNeeded();
841 } 841 }
842 842
843 ScopedGlobalRef<jobject> j_callbacks_; 843 ScopedGlobalRef<jobject> j_callbacks_;
844 jmethodID j_render_frame_id_; 844 jmethodID j_render_frame_id_;
845 ScopedGlobalRef<jclass> j_frame_class_; 845 ScopedGlobalRef<jclass> j_frame_class_;
846 jmethodID j_i420_frame_ctor_id_; 846 jmethodID j_i420_frame_ctor_id_;
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 return JavaStringFromStdString( 2011 return JavaStringFromStdString(
2012 jni, 2012 jni,
2013 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); 2013 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id());
2014 } 2014 }
2015 2015
2016 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { 2016 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) {
2017 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); 2017 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release();
2018 } 2018 }
2019 2019
2020 } // namespace webrtc_jni 2020 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698