Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 const ScopedGlobalRef<jobject> j_observer_global_; | 715 const ScopedGlobalRef<jobject> j_observer_global_; |
| 716 const ScopedGlobalRef<jclass> j_observer_class_; | 716 const ScopedGlobalRef<jclass> j_observer_class_; |
| 717 const ScopedGlobalRef<jclass> j_stats_report_class_; | 717 const ScopedGlobalRef<jclass> j_stats_report_class_; |
| 718 const jmethodID j_stats_report_ctor_; | 718 const jmethodID j_stats_report_ctor_; |
| 719 const ScopedGlobalRef<jclass> j_value_class_; | 719 const ScopedGlobalRef<jclass> j_value_class_; |
| 720 const jmethodID j_value_ctor_; | 720 const jmethodID j_value_ctor_; |
| 721 }; | 721 }; |
| 722 | 722 |
| 723 // Adapter presenting a cricket::VideoRenderer as a | 723 // Adapter presenting a cricket::VideoRenderer as a |
| 724 // webrtc::VideoRendererInterface. | 724 // webrtc::VideoRendererInterface. |
| 725 class VideoRendererWrapper : public VideoRendererInterface { | 725 class VideoRendererWrapper : public VideoRendererInterface { |
|
perkj_webrtc
2015/10/05 07:28:34
Can we split this out in a separate file in a fol
magjed_webrtc
2015/10/05 09:49:55
Yes.
| |
| 726 public: | 726 public: |
| 727 static VideoRendererWrapper* Create(cricket::VideoRenderer* renderer) { | 727 static VideoRendererWrapper* Create(cricket::VideoRenderer* renderer) { |
| 728 if (renderer) | 728 if (renderer) |
| 729 return new VideoRendererWrapper(renderer); | 729 return new VideoRendererWrapper(renderer); |
| 730 return NULL; | 730 return NULL; |
| 731 } | 731 } |
| 732 | 732 |
| 733 virtual ~VideoRendererWrapper() {} | 733 virtual ~VideoRendererWrapper() {} |
| 734 | 734 |
| 735 // This wraps VideoRenderer which still has SetSize. | 735 // This wraps VideoRenderer which still has SetSize. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 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 jobject j_frame = (video_frame->GetNativeHandle() != nullptr) | 779 jobject j_frame = (video_frame->GetNativeHandle() != nullptr) |
| 780 ? CricketToJavaTextureFrame(video_frame) | 780 ? CricketToJavaTextureFrame(video_frame) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 816 *j_frame_class_, j_i420_frame_ctor_id_, | 816 *j_frame_class_, j_i420_frame_ctor_id_, |
| 817 frame->GetWidth(), frame->GetHeight(), | 817 frame->GetWidth(), frame->GetHeight(), |
| 818 static_cast<int>(frame->GetVideoRotation()), | 818 static_cast<int>(frame->GetVideoRotation()), |
| 819 strides, planes, javaShallowCopy(frame)); | 819 strides, planes, javaShallowCopy(frame)); |
| 820 } | 820 } |
| 821 | 821 |
| 822 // Return a VideoRenderer.I420Frame referring texture object in |frame|. | 822 // Return a VideoRenderer.I420Frame referring texture object in |frame|. |
| 823 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) { | 823 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) { |
| 824 NativeHandleImpl* handle = | 824 NativeHandleImpl* handle = |
| 825 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle()); | 825 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle()); |
| 826 jobject texture_object = reinterpret_cast<jobject>(handle->GetHandle()); | 826 jfloatArray sampling_matrix = jni()->NewFloatArray(16); |
| 827 int texture_id = handle->GetTextureId(); | 827 jni()->SetFloatArrayRegion(sampling_matrix, 0, 16, handle->sampling_matrix); |
| 828 return jni()->NewObject( | 828 return jni()->NewObject( |
| 829 *j_frame_class_, j_texture_frame_ctor_id_, | 829 *j_frame_class_, j_texture_frame_ctor_id_, |
| 830 frame->GetWidth(), frame->GetHeight(), | 830 frame->GetWidth(), frame->GetHeight(), |
| 831 static_cast<int>(frame->GetVideoRotation()), | 831 static_cast<int>(frame->GetVideoRotation()), |
| 832 texture_object, texture_id, javaShallowCopy(frame)); | 832 handle->oes_texture_id, sampling_matrix, javaShallowCopy(frame)); |
| 833 } | 833 } |
| 834 | 834 |
| 835 JNIEnv* jni() { | 835 JNIEnv* jni() { |
| 836 return AttachCurrentThreadIfNeeded(); | 836 return AttachCurrentThreadIfNeeded(); |
| 837 } | 837 } |
| 838 | 838 |
| 839 ScopedGlobalRef<jobject> j_callbacks_; | 839 ScopedGlobalRef<jobject> j_callbacks_; |
| 840 jmethodID j_render_frame_id_; | 840 jmethodID j_render_frame_id_; |
| 841 ScopedGlobalRef<jclass> j_frame_class_; | 841 ScopedGlobalRef<jclass> j_frame_class_; |
| 842 jmethodID j_i420_frame_ctor_id_; | 842 jmethodID j_i420_frame_ctor_id_; |
| (...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1861 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size))); | 1861 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size))); |
| 1862 stream->ReadAll(buffer.get(), log_size, &read, nullptr); | 1862 stream->ReadAll(buffer.get(), log_size, &read, nullptr); |
| 1863 | 1863 |
| 1864 jbyteArray result = jni->NewByteArray(read); | 1864 jbyteArray result = jni->NewByteArray(read); |
| 1865 jni->SetByteArrayRegion(result, 0, read, buffer.get()); | 1865 jni->SetByteArrayRegion(result, 0, read, buffer.get()); |
| 1866 | 1866 |
| 1867 return result; | 1867 return result; |
| 1868 } | 1868 } |
| 1869 | 1869 |
| 1870 } // namespace webrtc_jni | 1870 } // namespace webrtc_jni |
| OLD | NEW |