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

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

Issue 1471333003: Add support for scaling textures in AndroidVideoCapturer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed magjeds comments Created 5 years 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 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
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
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.
magjed_webrtc 2015/11/26 10:08:33 Add a CHECK_EQ(cropped_input_width, width()) and C
perkj_webrtc 2015/11/26 10:56:14 Done.
81 // Here we use Bind magic to add a reference count to |this| until the newly
82 // created AndroidTextureBuffer is destructed. ScaledFrameNotInUse will be
83 // called that happens and when it finishes, the reference count to |this|
84 // will be decreased by one.
85 return new rtc::RefCountedObject<AndroidTextureBuffer>(
86 dst_widht, dst_height, native_handle_,
87 rtc::Bind(&ScaledFrameNotInUse, this));
88 }
89
67 } // namespace webrtc_jni 90 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698