OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 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 10 matching lines...) Expand all Loading... |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "talk/app/webrtc/java/jni/native_handle_impl.h" | 28 #include "talk/app/webrtc/java/jni/native_handle_impl.h" |
29 | 29 |
30 #include "webrtc/base/checks.h" | 30 #include "webrtc/base/checks.h" |
| 31 #include "webrtc/base/bind.h" |
| 32 |
| 33 using rtc::scoped_refptr; |
| 34 using webrtc::NativeHandleBuffer; |
31 | 35 |
32 namespace webrtc_jni { | 36 namespace webrtc_jni { |
33 | 37 |
| 38 namespace { |
| 39 void ScaledFrameNotInUse(scoped_refptr<NativeHandleBuffer> original) {} |
| 40 } // anonymous namespace |
| 41 |
34 NativeHandleImpl::NativeHandleImpl(JNIEnv* jni, | 42 NativeHandleImpl::NativeHandleImpl(JNIEnv* jni, |
35 jint j_oes_texture_id, | 43 jint j_oes_texture_id, |
36 jfloatArray j_transform_matrix) | 44 jfloatArray j_transform_matrix) |
37 : oes_texture_id(j_oes_texture_id) { | 45 : oes_texture_id(j_oes_texture_id) { |
38 RTC_CHECK_EQ(16, jni->GetArrayLength(j_transform_matrix)); | 46 RTC_CHECK_EQ(16, jni->GetArrayLength(j_transform_matrix)); |
39 jfloat* transform_matrix_ptr = | 47 jfloat* transform_matrix_ptr = |
40 jni->GetFloatArrayElements(j_transform_matrix, nullptr); | 48 jni->GetFloatArrayElements(j_transform_matrix, nullptr); |
41 for (int i = 0; i < 16; ++i) { | 49 for (int i = 0; i < 16; ++i) { |
42 sampling_matrix[i] = transform_matrix_ptr[i]; | 50 sampling_matrix[i] = transform_matrix_ptr[i]; |
43 } | 51 } |
(...skipping 13 matching lines...) Expand all Loading... |
57 no_longer_used_cb_(); | 65 no_longer_used_cb_(); |
58 } | 66 } |
59 | 67 |
60 rtc::scoped_refptr<webrtc::VideoFrameBuffer> | 68 rtc::scoped_refptr<webrtc::VideoFrameBuffer> |
61 AndroidTextureBuffer::NativeToI420Buffer() { | 69 AndroidTextureBuffer::NativeToI420Buffer() { |
62 RTC_NOTREACHED() | 70 RTC_NOTREACHED() |
63 << "AndroidTextureBuffer::NativeToI420Buffer not implemented."; | 71 << "AndroidTextureBuffer::NativeToI420Buffer not implemented."; |
64 return nullptr; | 72 return nullptr; |
65 } | 73 } |
66 | 74 |
| 75 rtc::scoped_refptr<AndroidTextureBuffer> AndroidTextureBuffer::CropAndScale( |
| 76 int cropped_input_width, |
| 77 int cropped_input_height, |
| 78 int dst_widht, |
| 79 int dst_height) { |
| 80 // TODO(perkj) Implement cropping. |
| 81 RTC_CHECK_EQ(cropped_input_width, width_); |
| 82 RTC_CHECK_EQ(cropped_input_height, height_); |
| 83 |
| 84 // Here we use Bind magic to add a reference count to |this| until the newly |
| 85 // created AndroidTextureBuffer is destructed. ScaledFrameNotInUse will be |
| 86 // called that happens and when it finishes, the reference count to |this| |
| 87 // will be decreased by one. |
| 88 return new rtc::RefCountedObject<AndroidTextureBuffer>( |
| 89 dst_widht, dst_height, native_handle_, |
| 90 rtc::Bind(&ScaledFrameNotInUse, this)); |
| 91 } |
| 92 |
67 } // namespace webrtc_jni | 93 } // namespace webrtc_jni |
OLD | NEW |