| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // AndroidVideoCapturerJni or the C++ SurfaceTextureHelper, to keep | 96 // AndroidVideoCapturerJni or the C++ SurfaceTextureHelper, to keep |
| 97 // a global reference. TODO(nisse): Make this a reference to the C++ | 97 // a global reference. TODO(nisse): Make this a reference to the C++ |
| 98 // SurfaceTextureHelper instead, but that requires some refactoring | 98 // SurfaceTextureHelper instead, but that requires some refactoring |
| 99 // of AndroidVideoCapturerJni. | 99 // of AndroidVideoCapturerJni. |
| 100 jobject surface_texture_helper_; | 100 jobject surface_texture_helper_; |
| 101 rtc::Callback0<void> no_longer_used_cb_; | 101 rtc::Callback0<void> no_longer_used_cb_; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 class AndroidVideoBuffer : public AndroidVideoFrameBuffer { | 104 class AndroidVideoBuffer : public AndroidVideoFrameBuffer { |
| 105 public: | 105 public: |
| 106 // Wraps an existing reference to a Java VideoBuffer. Retain will not be |
| 107 // called but release will be called when the C++ object is destroyed. |
| 108 static rtc::scoped_refptr<AndroidVideoBuffer> WrapReference( |
| 109 JNIEnv* jni, |
| 110 jmethodID j_release_id, |
| 111 int width, |
| 112 int height, |
| 113 jobject j_video_frame_buffer); |
| 114 |
| 106 AndroidVideoBuffer(JNIEnv* jni, | 115 AndroidVideoBuffer(JNIEnv* jni, |
| 107 jmethodID j_retain_id, | 116 jmethodID j_retain_id, |
| 108 jmethodID j_release_id, | 117 jmethodID j_release_id, |
| 109 int width, | 118 int width, |
| 110 int height, | 119 int height, |
| 111 jobject j_video_frame_buffer); | 120 jobject j_video_frame_buffer); |
| 121 // Should not be called directly. Wraps a reference. Use |
| 122 // AndroidVideoBuffer::WrapReference instead for clarity. |
| 123 AndroidVideoBuffer(JNIEnv* jni, |
| 124 jmethodID j_release_id, |
| 125 int width, |
| 126 int height, |
| 127 jobject j_video_frame_buffer); |
| 112 ~AndroidVideoBuffer() override; | 128 ~AndroidVideoBuffer() override; |
| 113 | 129 |
| 114 jobject video_frame_buffer() const; | 130 jobject video_frame_buffer() const; |
| 115 | 131 |
| 116 // Returns an instance of VideoRenderer.I420Frame (deprecated) | 132 // Returns an instance of VideoRenderer.I420Frame (deprecated) |
| 117 jobject ToJavaI420Frame(JNIEnv* jni, int rotation); | 133 jobject ToJavaI420Frame(JNIEnv* jni, int rotation); |
| 118 | 134 |
| 119 private: | 135 private: |
| 120 Type type() const override; | 136 Type type() const override; |
| 121 int width() const override; | 137 int width() const override; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 133 }; | 149 }; |
| 134 | 150 |
| 135 class AndroidVideoBufferFactory { | 151 class AndroidVideoBufferFactory { |
| 136 public: | 152 public: |
| 137 explicit AndroidVideoBufferFactory(JNIEnv* jni); | 153 explicit AndroidVideoBufferFactory(JNIEnv* jni); |
| 138 | 154 |
| 139 webrtc::VideoFrame CreateFrame(JNIEnv* jni, | 155 webrtc::VideoFrame CreateFrame(JNIEnv* jni, |
| 140 jobject j_video_frame, | 156 jobject j_video_frame, |
| 141 uint32_t timestamp_rtp) const; | 157 uint32_t timestamp_rtp) const; |
| 142 | 158 |
| 159 // Wraps a buffer to AndroidVideoBuffer without incrementing the reference |
| 160 // count. |
| 161 rtc::scoped_refptr<AndroidVideoBuffer> WrapBuffer( |
| 162 JNIEnv* jni, |
| 163 jobject j_video_frame_buffer) const; |
| 164 |
| 143 rtc::scoped_refptr<AndroidVideoBuffer> CreateBuffer( | 165 rtc::scoped_refptr<AndroidVideoBuffer> CreateBuffer( |
| 166 JNIEnv* jni, |
| 144 jobject j_video_frame_buffer) const; | 167 jobject j_video_frame_buffer) const; |
| 145 | 168 |
| 146 private: | 169 private: |
| 147 ScopedGlobalRef<jclass> j_video_frame_class_; | 170 ScopedGlobalRef<jclass> j_video_frame_class_; |
| 148 jmethodID j_get_buffer_id_; | 171 jmethodID j_get_buffer_id_; |
| 149 jmethodID j_get_rotation_id_; | 172 jmethodID j_get_rotation_id_; |
| 150 jmethodID j_get_timestamp_ns_id_; | 173 jmethodID j_get_timestamp_ns_id_; |
| 151 | 174 |
| 152 ScopedGlobalRef<jclass> j_video_frame_buffer_class_; | 175 ScopedGlobalRef<jclass> j_video_frame_buffer_class_; |
| 153 jmethodID j_retain_id_; | 176 jmethodID j_retain_id_; |
| 154 jmethodID j_release_id_; | 177 jmethodID j_release_id_; |
| 155 jmethodID j_get_width_id_; | 178 jmethodID j_get_width_id_; |
| 156 jmethodID j_get_height_id_; | 179 jmethodID j_get_height_id_; |
| 157 }; | 180 }; |
| 158 | 181 |
| 159 class JavaVideoFrameFactory { | 182 class JavaVideoFrameFactory { |
| 160 public: | 183 public: |
| 161 JavaVideoFrameFactory(JNIEnv* jni); | 184 JavaVideoFrameFactory(JNIEnv* jni); |
| 162 | 185 |
| 163 jobject ToJavaFrame(JNIEnv* jni, const webrtc::VideoFrame& frame) const; | 186 jobject ToJavaFrame(JNIEnv* jni, const webrtc::VideoFrame& frame) const; |
| 164 | 187 |
| 165 private: | 188 private: |
| 166 ScopedGlobalRef<jclass> j_video_frame_class_; | 189 ScopedGlobalRef<jclass> j_video_frame_class_; |
| 167 jmethodID j_video_frame_constructor_id_; | 190 jmethodID j_video_frame_constructor_id_; |
| 168 }; | 191 }; |
| 169 | 192 |
| 170 } // namespace webrtc_jni | 193 } // namespace webrtc_jni |
| 171 | 194 |
| 172 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_NATIVE_HANDLE_IMPL_H_ | 195 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_NATIVE_HANDLE_IMPL_H_ |
| OLD | NEW |