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

Side by Side Diff: webrtc/api/java/jni/androidvideocapturer_jni.cc

Issue 2017443003: Implement timestamp translation/filter in VideoCapturer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix offset update equation, and nits. Created 4 years, 6 months 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
« no previous file with comments | « no previous file | webrtc/media/base/videocapturer.h » ('j') | webrtc/media/base/videocapturer.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 || 173 RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 ||
174 rotation == 270); 174 rotation == 270);
175 rtc::CritScope cs(&capturer_lock_); 175 rtc::CritScope cs(&capturer_lock_);
176 176
177 int adapted_width; 177 int adapted_width;
178 int adapted_height; 178 int adapted_height;
179 int crop_width; 179 int crop_width;
180 int crop_height; 180 int crop_height;
181 int crop_x; 181 int crop_x;
182 int crop_y; 182 int crop_y;
183 int64_t time_us;
pthatcher1 2016/05/27 22:47:43 Can you be a little more specific about what the t
nisse-webrtc 2016/05/30 08:57:29 I changed it to translated_capture_time_us. Better
183 184
184 if (!capturer_->AdaptFrame(width, height, timestamp_ns, 185 if (!capturer_->AdaptFrame(width, height, timestamp_ns,
185 &adapted_width, &adapted_height, 186 &adapted_width, &adapted_height,
186 &crop_width, &crop_height, &crop_x, &crop_y)) { 187 &crop_width, &crop_height, &crop_x, &crop_y,
188 &time_us)) {
187 return; 189 return;
188 } 190 }
189 191
190 int rotated_width = crop_width; 192 int rotated_width = crop_width;
191 int rotated_height = crop_height; 193 int rotated_height = crop_height;
192 194
193 if (capturer_->apply_rotation() && (rotation == 90 || rotation == 270)) { 195 if (capturer_->apply_rotation() && (rotation == 90 || rotation == 270)) {
194 std::swap(adapted_width, adapted_height); 196 std::swap(adapted_width, adapted_height);
195 std::swap(rotated_width, rotated_height); 197 std::swap(rotated_width, rotated_height);
196 } 198 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 scaled->MutableDataY(), scaled->StrideY(), 231 scaled->MutableDataY(), scaled->StrideY(),
230 scaled->MutableDataU(), scaled->StrideU(), 232 scaled->MutableDataU(), scaled->StrideU(),
231 scaled->MutableDataV(), scaled->StrideV(), 233 scaled->MutableDataV(), scaled->StrideV(),
232 adapted_width, adapted_height, 234 adapted_width, adapted_height,
233 libyuv::kFilterBox) < 0) { 235 libyuv::kFilterBox) < 0) {
234 LOG(LS_WARNING) << "I420Scale failed"; 236 LOG(LS_WARNING) << "I420Scale failed";
235 return; 237 return;
236 } 238 }
237 buffer = scaled; 239 buffer = scaled;
238 } 240 }
239 // TODO(nisse): Use microsecond time instead.
240 capturer_->OnFrame(cricket::WebRtcVideoFrame( 241 capturer_->OnFrame(cricket::WebRtcVideoFrame(
241 buffer, timestamp_ns, 242 buffer,
242 capturer_->apply_rotation() 243 capturer_->apply_rotation()
243 ? webrtc::kVideoRotation_0 244 ? webrtc::kVideoRotation_0
244 : static_cast<webrtc::VideoRotation>(rotation)), 245 : static_cast<webrtc::VideoRotation>(rotation),
246 time_us),
245 width, height); 247 width, height);
246 } 248 }
247 249
248 void AndroidVideoCapturerJni::OnTextureFrame(int width, 250 void AndroidVideoCapturerJni::OnTextureFrame(int width,
249 int height, 251 int height,
250 int rotation, 252 int rotation,
251 int64_t timestamp_ns, 253 int64_t timestamp_ns,
252 const NativeHandleImpl& handle) { 254 const NativeHandleImpl& handle) {
253 RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 || 255 RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 ||
254 rotation == 270); 256 rotation == 270);
255 rtc::CritScope cs(&capturer_lock_); 257 rtc::CritScope cs(&capturer_lock_);
256 258
257 int adapted_width; 259 int adapted_width;
258 int adapted_height; 260 int adapted_height;
259 int crop_width; 261 int crop_width;
260 int crop_height; 262 int crop_height;
261 int crop_x; 263 int crop_x;
262 int crop_y; 264 int crop_y;
265 int64_t time_us;
263 266
264 if (!capturer_->AdaptFrame(width, height, timestamp_ns, 267 if (!capturer_->AdaptFrame(width, height, timestamp_ns,
265 &adapted_width, &adapted_height, 268 &adapted_width, &adapted_height,
266 &crop_width, &crop_height, &crop_x, &crop_y)) { 269 &crop_width, &crop_height, &crop_x, &crop_y,
270 &time_us)) {
267 return; 271 return;
268 } 272 }
269 273
270 Matrix matrix = handle.sampling_matrix; 274 Matrix matrix = handle.sampling_matrix;
271 275
272 matrix.Crop(crop_width / static_cast<float>(width), 276 matrix.Crop(crop_width / static_cast<float>(width),
273 crop_height / static_cast<float>(height), 277 crop_height / static_cast<float>(height),
274 crop_x / static_cast<float>(width), 278 crop_x / static_cast<float>(width),
275 crop_y / static_cast<float>(height)); 279 crop_y / static_cast<float>(height));
276 280
277 if (capturer_->apply_rotation()) { 281 if (capturer_->apply_rotation()) {
278 if (rotation == webrtc::kVideoRotation_90 || 282 if (rotation == webrtc::kVideoRotation_90 ||
279 rotation == webrtc::kVideoRotation_270) { 283 rotation == webrtc::kVideoRotation_270) {
280 std::swap(adapted_width, adapted_height); 284 std::swap(adapted_width, adapted_height);
281 } 285 }
282 matrix.Rotate(static_cast<webrtc::VideoRotation>(rotation)); 286 matrix.Rotate(static_cast<webrtc::VideoRotation>(rotation));
283 } 287 }
284 288
285 // TODO(nisse): Use microsecond time instead.
286 capturer_->OnFrame( 289 capturer_->OnFrame(
287 cricket::WebRtcVideoFrame( 290 cricket::WebRtcVideoFrame(
288 surface_texture_helper_->CreateTextureFrame( 291 surface_texture_helper_->CreateTextureFrame(
289 adapted_width, adapted_height, 292 adapted_width, adapted_height,
290 NativeHandleImpl(handle.oes_texture_id, matrix)), 293 NativeHandleImpl(handle.oes_texture_id, matrix)),
291 timestamp_ns, capturer_->apply_rotation() 294 capturer_->apply_rotation()
292 ? webrtc::kVideoRotation_0 295 ? webrtc::kVideoRotation_0
293 : static_cast<webrtc::VideoRotation>(rotation)), 296 : static_cast<webrtc::VideoRotation>(rotation),
297 time_us),
294 width, height); 298 width, height);
295 } 299 }
296 300
297 void AndroidVideoCapturerJni::OnOutputFormatRequest(int width, 301 void AndroidVideoCapturerJni::OnOutputFormatRequest(int width,
298 int height, 302 int height,
299 int fps) { 303 int fps) {
300 AsyncCapturerInvoke("OnOutputFormatRequest", 304 AsyncCapturerInvoke("OnOutputFormatRequest",
301 &webrtc::AndroidVideoCapturer::OnOutputFormatRequest, 305 &webrtc::AndroidVideoCapturer::OnOutputFormatRequest,
302 width, height, fps); 306 width, height, fps);
303 } 307 }
(...skipping 30 matching lines...) Expand all
334 338
335 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest) 339 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest)
336 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, 340 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height,
337 jint j_fps) { 341 jint j_fps) {
338 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; 342 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest";
339 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( 343 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest(
340 j_width, j_height, j_fps); 344 j_width, j_height, j_fps);
341 } 345 }
342 346
343 } // namespace webrtc_jni 347 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « no previous file | webrtc/media/base/videocapturer.h » ('j') | webrtc/media/base/videocapturer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698