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

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

Issue 1440343002: Reland again Android MediaCodecVideoDecoder: Manage lifetime of texture frames (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased Created 5 years, 1 month 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 new rtc::RefCountedObject<webrtc::WrappedI420Buffer>( 173 new rtc::RefCountedObject<webrtc::WrappedI420Buffer>(
174 width, height, y_plane, y_stride, u_plane, uv_stride, v_plane, 174 width, height, y_plane, y_stride, u_plane, uv_stride, v_plane,
175 uv_stride, 175 uv_stride,
176 rtc::Bind(&AndroidVideoCapturerJni::ReturnBuffer, this, 176 rtc::Bind(&AndroidVideoCapturerJni::ReturnBuffer, this,
177 timestamp_ns))); 177 timestamp_ns)));
178 AsyncCapturerInvoke("OnIncomingFrame", 178 AsyncCapturerInvoke("OnIncomingFrame",
179 &webrtc::AndroidVideoCapturer::OnIncomingFrame, 179 &webrtc::AndroidVideoCapturer::OnIncomingFrame,
180 buffer, rotation, timestamp_ns); 180 buffer, rotation, timestamp_ns);
181 } 181 }
182 182
183 void AndroidVideoCapturerJni::OnTextureFrame( 183 void AndroidVideoCapturerJni::OnTextureFrame(int width,
184 int width, 184 int height,
185 int height, 185 int64_t timestamp_ns,
186 int64_t timestamp_ns, 186 const NativeHandleImpl& handle) {
187 const NativeTextureHandleImpl& handle) {
188 // TODO(magjed): Fix this. See bug webrtc:4993.
189 RTC_NOTREACHED()
190 << "The rest of the stack for Android expects the native "
191 "handle to be a NativeHandleImpl with a SurfaceTexture, not a "
192 "NativeTextureHandleImpl";
193 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer( 187 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer(
194 new rtc::RefCountedObject<AndroidTextureBuffer>( 188 new rtc::RefCountedObject<AndroidTextureBuffer>(
195 width, height, handle, 189 width, height, handle,
196 rtc::Bind(&AndroidVideoCapturerJni::ReturnBuffer, this, 190 rtc::Bind(&AndroidVideoCapturerJni::ReturnBuffer, this,
197 timestamp_ns))); 191 timestamp_ns)));
198 AsyncCapturerInvoke("OnIncomingFrame", 192 AsyncCapturerInvoke("OnIncomingFrame",
199 &webrtc::AndroidVideoCapturer::OnIncomingFrame, 193 &webrtc::AndroidVideoCapturer::OnIncomingFrame,
200 buffer, 0, timestamp_ns); 194 buffer, 0, timestamp_ns);
201 } 195 }
202 196
(...skipping 24 matching lines...) Expand all
227 ->OnMemoryBufferFrame(bytes, length, width, height, rotation, timestamp); 221 ->OnMemoryBufferFrame(bytes, length, width, height, rotation, timestamp);
228 jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT); 222 jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT);
229 } 223 }
230 224
231 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnTextureFrameCaptured) 225 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnTextureFrameCaptured)
232 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, 226 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height,
233 jint j_oes_texture_id, jfloatArray j_transform_matrix, 227 jint j_oes_texture_id, jfloatArray j_transform_matrix,
234 jlong j_timestamp) { 228 jlong j_timestamp) {
235 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer) 229 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)
236 ->OnTextureFrame(j_width, j_height, j_timestamp, 230 ->OnTextureFrame(j_width, j_height, j_timestamp,
237 NativeTextureHandleImpl(jni, j_oes_texture_id, 231 NativeHandleImpl(jni, j_oes_texture_id,
238 j_transform_matrix)); 232 j_transform_matrix));
239 } 233 }
240 234
241 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeCapturerStarted) 235 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeCapturerStarted)
242 (JNIEnv* jni, jclass, jlong j_capturer, jboolean j_success) { 236 (JNIEnv* jni, jclass, jlong j_capturer, jboolean j_success) {
243 LOG(LS_INFO) << "NativeObserver_nativeCapturerStarted"; 237 LOG(LS_INFO) << "NativeObserver_nativeCapturerStarted";
244 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnCapturerStarted( 238 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnCapturerStarted(
245 j_success); 239 j_success);
246 } 240 }
247 241
248 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnOutputFormatRequest) 242 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnOutputFormatRequest)
249 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, 243 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height,
250 jint j_fps) { 244 jint j_fps) {
251 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; 245 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest";
252 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( 246 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest(
253 j_width, j_height, j_fps); 247 j_width, j_height, j_fps);
254 } 248 }
255 249
256 JOW(jlong, VideoCapturerAndroid_nativeCreateVideoCapturer) 250 JOW(jlong, VideoCapturerAndroid_nativeCreateVideoCapturer)
257 (JNIEnv* jni, jclass, jobject j_video_capturer) { 251 (JNIEnv* jni, jclass, jobject j_video_capturer) {
258 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate = 252 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate =
259 new rtc::RefCountedObject<AndroidVideoCapturerJni>(jni, j_video_capturer); 253 new rtc::RefCountedObject<AndroidVideoCapturerJni>(jni, j_video_capturer);
260 rtc::scoped_ptr<cricket::VideoCapturer> capturer( 254 rtc::scoped_ptr<cricket::VideoCapturer> capturer(
261 new webrtc::AndroidVideoCapturer(delegate)); 255 new webrtc::AndroidVideoCapturer(delegate));
262 // Caller takes ownership of the cricket::VideoCapturer* pointer. 256 // Caller takes ownership of the cricket::VideoCapturer* pointer.
263 return jlongFromPointer(capturer.release()); 257 return jlongFromPointer(capturer.release());
264 } 258 }
265 259
266 } // namespace webrtc_jni 260 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « talk/app/webrtc/java/jni/androidvideocapturer_jni.h ('k') | talk/app/webrtc/java/jni/classreferenceholder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698