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

Unified Diff: media/capture/video/android/video_capture_device_android.cc

Issue 2272873002: Android video capture: only use reference time for outbound timestamp. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: estimate a timestamp in Camera1 callback Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/capture/video/android/video_capture_device_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/capture/video/android/video_capture_device_android.cc
diff --git a/media/capture/video/android/video_capture_device_android.cc b/media/capture/video/android/video_capture_device_android.cc
index b56fc7452502aa9ee0d9055bf6e918f9ebfa86c9..f8e852fdc887b3dae88092194f15c1aab9890e3f 100644
--- a/media/capture/video/android/video_capture_device_android.cc
+++ b/media/capture/video/android/video_capture_device_android.cc
@@ -252,7 +252,6 @@ void VideoCaptureDeviceAndroid::OnFrameAvailable(
if (!got_first_frame_) {
// Set aside one frame allowance for fluctuation.
expected_next_frame_time_ = current_time - frame_interval_;
- first_ref_time_ = current_time;
got_first_frame_ = true;
for (const auto& request : photo_requests_queue_)
@@ -263,6 +262,11 @@ void VideoCaptureDeviceAndroid::OnFrameAvailable(
// Deliver the frame when it doesn't arrive too early.
if (expected_next_frame_time_ <= current_time) {
+ // Using |expected_next_frame_time_| to estimate a proper capture timestamp
+ // since android.hardware.Camera API doesn't expose a better timestamp.
+ const base::TimeDelta capture_time =
+ expected_next_frame_time_ - base::TimeTicks();
+
expected_next_frame_time_ += frame_interval_;
// TODO(qiangchen): Investigate how to get raw timestamp for Android,
@@ -272,7 +276,7 @@ void VideoCaptureDeviceAndroid::OnFrameAvailable(
return;
client_->OnIncomingCapturedData(reinterpret_cast<uint8_t*>(buffer), length,
capture_format_, rotation, current_time,
- current_time - first_ref_time_);
+ capture_time);
}
env->ReleaseByteArrayElements(data, buffer, JNI_ABORT);
@@ -288,12 +292,17 @@ void VideoCaptureDeviceAndroid::OnI420FrameAvailable(JNIEnv* env,
jint uv_pixel_stride,
jint width,
jint height,
- jint rotation) {
+ jint rotation,
+ jlong timestamp) {
{
base::AutoLock lock(lock_);
if (state_ != kConfigured || !client_)
return;
}
+ const int64_t absolute_micro =
+ timestamp / base::Time::kNanosecondsPerMicrosecond;
+ const base::TimeDelta capture_time =
+ base::TimeDelta::FromMicroseconds(absolute_micro);
const base::TimeTicks current_time = base::TimeTicks::Now();
{
@@ -301,7 +310,6 @@ void VideoCaptureDeviceAndroid::OnI420FrameAvailable(JNIEnv* env,
if (!got_first_frame_) {
// Set aside one frame allowance for fluctuation.
expected_next_frame_time_ = current_time - frame_interval_;
- first_ref_time_ = current_time;
got_first_frame_ = true;
for (const auto& request : photo_requests_queue_)
@@ -342,7 +350,7 @@ void VideoCaptureDeviceAndroid::OnI420FrameAvailable(JNIEnv* env,
return;
client_->OnIncomingCapturedData(buffer.get(), buffer_length,
capture_format_, rotation, current_time,
- current_time - first_ref_time_);
+ capture_time);
}
}
« no previous file with comments | « media/capture/video/android/video_capture_device_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698