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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 const cricket::VideoFrame* frame = | 738 const cricket::VideoFrame* frame = |
739 video_frame->GetCopyWithRotationApplied(); | 739 video_frame->GetCopyWithRotationApplied(); |
740 if (width_ != frame->GetWidth() || height_ != frame->GetHeight()) { | 740 if (width_ != frame->GetWidth() || height_ != frame->GetHeight()) { |
741 width_ = frame->GetWidth(); | 741 width_ = frame->GetWidth(); |
742 height_ = frame->GetHeight(); | 742 height_ = frame->GetHeight(); |
743 renderer_->SetSize(width_, height_, 0); | 743 renderer_->SetSize(width_, height_, 0); |
744 } | 744 } |
745 renderer_->RenderFrame(frame); | 745 renderer_->RenderFrame(frame); |
746 } | 746 } |
747 | 747 |
748 // TODO(guoweis): Remove this once chrome code base is updated. | |
749 bool CanApplyRotation() override { return true; } | |
750 | |
751 private: | 748 private: |
752 explicit VideoRendererWrapper(cricket::VideoRenderer* renderer) | 749 explicit VideoRendererWrapper(cricket::VideoRenderer* renderer) |
753 : width_(0), height_(0), renderer_(renderer) {} | 750 : width_(0), height_(0), renderer_(renderer) {} |
754 int width_, height_; | 751 int width_, height_; |
755 scoped_ptr<cricket::VideoRenderer> renderer_; | 752 scoped_ptr<cricket::VideoRenderer> renderer_; |
756 }; | 753 }; |
757 | 754 |
758 // Wrapper dispatching webrtc::VideoRendererInterface to a Java VideoRenderer | 755 // Wrapper dispatching webrtc::VideoRendererInterface to a Java VideoRenderer |
759 // instance. | 756 // instance. |
760 class JavaVideoRendererWrapper : public VideoRendererInterface { | 757 class JavaVideoRendererWrapper : public VideoRendererInterface { |
(...skipping 21 matching lines...) Expand all Loading... |
782 // Make a shallow copy. |j_callbacks_| is responsible for releasing the | 779 // Make a shallow copy. |j_callbacks_| is responsible for releasing the |
783 // copy by calling VideoRenderer.renderFrameDone(). | 780 // copy by calling VideoRenderer.renderFrameDone(). |
784 video_frame = video_frame->Copy(); | 781 video_frame = video_frame->Copy(); |
785 jobject j_frame = (video_frame->GetNativeHandle() != nullptr) | 782 jobject j_frame = (video_frame->GetNativeHandle() != nullptr) |
786 ? CricketToJavaTextureFrame(video_frame) | 783 ? CricketToJavaTextureFrame(video_frame) |
787 : CricketToJavaI420Frame(video_frame); | 784 : CricketToJavaI420Frame(video_frame); |
788 jni()->CallVoidMethod(*j_callbacks_, j_render_frame_id_, j_frame); | 785 jni()->CallVoidMethod(*j_callbacks_, j_render_frame_id_, j_frame); |
789 CHECK_EXCEPTION(jni()); | 786 CHECK_EXCEPTION(jni()); |
790 } | 787 } |
791 | 788 |
792 // TODO(guoweis): Report that rotation is supported as RenderFrame calls | |
793 // GetCopyWithRotationApplied. | |
794 virtual bool CanApplyRotation() override { return true; } | |
795 | |
796 private: | 789 private: |
797 // Return a VideoRenderer.I420Frame referring to the data in |frame|. | 790 // Return a VideoRenderer.I420Frame referring to the data in |frame|. |
798 jobject CricketToJavaI420Frame(const cricket::VideoFrame* frame) { | 791 jobject CricketToJavaI420Frame(const cricket::VideoFrame* frame) { |
799 jintArray strides = jni()->NewIntArray(3); | 792 jintArray strides = jni()->NewIntArray(3); |
800 jint* strides_array = jni()->GetIntArrayElements(strides, NULL); | 793 jint* strides_array = jni()->GetIntArrayElements(strides, NULL); |
801 strides_array[0] = frame->GetYPitch(); | 794 strides_array[0] = frame->GetYPitch(); |
802 strides_array[1] = frame->GetUPitch(); | 795 strides_array[1] = frame->GetUPitch(); |
803 strides_array[2] = frame->GetVPitch(); | 796 strides_array[2] = frame->GetVPitch(); |
804 jni()->ReleaseIntArrayElements(strides, strides_array, 0); | 797 jni()->ReleaseIntArrayElements(strides, strides_array, 0); |
805 jobjectArray planes = jni()->NewObjectArray(3, *j_byte_buffer_class_, NULL); | 798 jobjectArray planes = jni()->NewObjectArray(3, *j_byte_buffer_class_, NULL); |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size))); | 1819 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size))); |
1827 stream->ReadAll(buffer.get(), log_size, &read, nullptr); | 1820 stream->ReadAll(buffer.get(), log_size, &read, nullptr); |
1828 | 1821 |
1829 jbyteArray result = jni->NewByteArray(read); | 1822 jbyteArray result = jni->NewByteArray(read); |
1830 jni->SetByteArrayRegion(result, 0, read, buffer.get()); | 1823 jni->SetByteArrayRegion(result, 0, read, buffer.get()); |
1831 | 1824 |
1832 return result; | 1825 return result; |
1833 } | 1826 } |
1834 | 1827 |
1835 } // namespace webrtc_jni | 1828 } // namespace webrtc_jni |
OLD | NEW |