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

Side by Side Diff: media/capture/video/android/video_capture_device_android.cc

Issue 1983193002: Decouple capture timestamp and reference time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve Comments 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/capture/video/android/video_capture_device_android.h" 5 #include "media/capture/video/android/video_capture_device_android.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (!buffer) { 183 if (!buffer) {
184 LOG(ERROR) << "VideoCaptureDeviceAndroid::OnFrameAvailable: " 184 LOG(ERROR) << "VideoCaptureDeviceAndroid::OnFrameAvailable: "
185 "failed to GetByteArrayElements"; 185 "failed to GetByteArrayElements";
186 return; 186 return;
187 } 187 }
188 188
189 base::TimeTicks current_time = base::TimeTicks::Now(); 189 base::TimeTicks current_time = base::TimeTicks::Now();
190 if (!got_first_frame_) { 190 if (!got_first_frame_) {
191 // Set aside one frame allowance for fluctuation. 191 // Set aside one frame allowance for fluctuation.
192 expected_next_frame_time_ = current_time - frame_interval_; 192 expected_next_frame_time_ = current_time - frame_interval_;
193 first_ref_time_ = current_time;
193 got_first_frame_ = true; 194 got_first_frame_ = true;
194 } 195 }
195 196
196 // Deliver the frame when it doesn't arrive too early. 197 // Deliver the frame when it doesn't arrive too early.
197 if (expected_next_frame_time_ <= current_time) { 198 if (expected_next_frame_time_ <= current_time) {
198 expected_next_frame_time_ += frame_interval_; 199 expected_next_frame_time_ += frame_interval_;
199 200
201 // TODO(qiangchen): Investigate how to get raw timestamp for Android,
202 // rather than using reference time to calculate timestamp.
200 client_->OnIncomingCapturedData(reinterpret_cast<uint8_t*>(buffer), length, 203 client_->OnIncomingCapturedData(reinterpret_cast<uint8_t*>(buffer), length,
201 capture_format_, rotation, 204 capture_format_, rotation, current_time,
202 base::TimeTicks::Now()); 205 current_time - first_ref_time_);
203 } 206 }
204 207
205 env->ReleaseByteArrayElements(data, buffer, JNI_ABORT); 208 env->ReleaseByteArrayElements(data, buffer, JNI_ABORT);
206 } 209 }
207 210
208 void VideoCaptureDeviceAndroid::OnError(JNIEnv* env, 211 void VideoCaptureDeviceAndroid::OnError(JNIEnv* env,
209 const JavaParamRef<jobject>& obj, 212 const JavaParamRef<jobject>& obj,
210 const JavaParamRef<jstring>& message) { 213 const JavaParamRef<jstring>& message) {
211 SetErrorState(FROM_HERE, 214 SetErrorState(FROM_HERE,
212 base::android::ConvertJavaStringToUTF8(env, message)); 215 base::android::ConvertJavaStringToUTF8(env, message));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 const tracked_objects::Location& from_here, 266 const tracked_objects::Location& from_here,
264 const std::string& reason) { 267 const std::string& reason) {
265 { 268 {
266 base::AutoLock lock(lock_); 269 base::AutoLock lock(lock_);
267 state_ = kError; 270 state_ = kError;
268 } 271 }
269 client_->OnError(from_here, reason); 272 client_->OnError(from_here, reason);
270 } 273 }
271 274
272 } // namespace media 275 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/android/video_capture_device_android.h ('k') | media/capture/video/fake_video_capture_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698