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

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

Issue 1470043002: Support texture scaling in Androids MediaEncoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added test in VideoCapturerAndroid 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 }
41 } // anonymous namespace
42
34 NativeHandleImpl::NativeHandleImpl(JNIEnv* jni, 43 NativeHandleImpl::NativeHandleImpl(JNIEnv* jni,
35 jint j_oes_texture_id, 44 jint j_oes_texture_id,
36 jfloatArray j_transform_matrix) 45 jfloatArray j_transform_matrix)
37 : oes_texture_id(j_oes_texture_id) { 46 : oes_texture_id(j_oes_texture_id) {
38 RTC_CHECK_EQ(16, jni->GetArrayLength(j_transform_matrix)); 47 RTC_CHECK_EQ(16, jni->GetArrayLength(j_transform_matrix));
39 jfloat* transform_matrix_ptr = 48 jfloat* transform_matrix_ptr =
40 jni->GetFloatArrayElements(j_transform_matrix, nullptr); 49 jni->GetFloatArrayElements(j_transform_matrix, nullptr);
41 for (int i = 0; i < 16; ++i) { 50 for (int i = 0; i < 16; ++i) {
42 sampling_matrix[i] = transform_matrix_ptr[i]; 51 sampling_matrix[i] = transform_matrix_ptr[i];
43 } 52 }
(...skipping 13 matching lines...) Expand all
57 no_longer_used_cb_(); 66 no_longer_used_cb_();
58 } 67 }
59 68
60 rtc::scoped_refptr<webrtc::VideoFrameBuffer> 69 rtc::scoped_refptr<webrtc::VideoFrameBuffer>
61 AndroidTextureBuffer::NativeToI420Buffer() { 70 AndroidTextureBuffer::NativeToI420Buffer() {
62 RTC_NOTREACHED() 71 RTC_NOTREACHED()
63 << "AndroidTextureBuffer::NativeToI420Buffer not implemented."; 72 << "AndroidTextureBuffer::NativeToI420Buffer not implemented.";
64 return nullptr; 73 return nullptr;
65 } 74 }
66 75
76 rtc::scoped_refptr<AndroidTextureBuffer> AndroidTextureBuffer::CropAndScale(
77 int cropped_input_width,
78 int cropped_input_height,
79 int dst_widht,
80 int dst_height) {
81 // TODO(perkj) Implement cropping.
82 // Here we use Bind magic to keep a reference to |this| until the newly
83 // created AndroidTextureBuffer goes out of scope. ScaledFrameNotInUse will be
84 // called when the new buffer is no longer used.
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