Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 if (!buffer) { | 177 if (!buffer) { |
| 178 LOG(ERROR) << "VideoCaptureDeviceAndroid::OnFrameAvailable: " | 178 LOG(ERROR) << "VideoCaptureDeviceAndroid::OnFrameAvailable: " |
| 179 "failed to GetByteArrayElements"; | 179 "failed to GetByteArrayElements"; |
| 180 return; | 180 return; |
| 181 } | 181 } |
| 182 | 182 |
| 183 base::TimeTicks current_time = base::TimeTicks::Now(); | 183 base::TimeTicks current_time = base::TimeTicks::Now(); |
| 184 if (!got_first_frame_) { | 184 if (!got_first_frame_) { |
| 185 // Set aside one frame allowance for fluctuation. | 185 // Set aside one frame allowance for fluctuation. |
| 186 expected_next_frame_time_ = current_time - frame_interval_; | 186 expected_next_frame_time_ = current_time - frame_interval_; |
| 187 first_ref_time_ = current_time; | |
|
miu
2016/05/18 22:35:40
There's probably a way to pass the video capture t
qiangchen
2016/05/20 17:55:14
Done.
| |
| 187 got_first_frame_ = true; | 188 got_first_frame_ = true; |
| 188 } | 189 } |
| 189 | 190 |
| 190 // Deliver the frame when it doesn't arrive too early. | 191 // Deliver the frame when it doesn't arrive too early. |
| 191 if (expected_next_frame_time_ <= current_time) { | 192 if (expected_next_frame_time_ <= current_time) { |
| 192 expected_next_frame_time_ += frame_interval_; | 193 expected_next_frame_time_ += frame_interval_; |
| 193 | 194 |
| 194 client_->OnIncomingCapturedData(reinterpret_cast<uint8_t*>(buffer), length, | 195 client_->OnIncomingCapturedData(reinterpret_cast<uint8_t*>(buffer), length, |
| 195 capture_format_, rotation, | 196 capture_format_, rotation, current_time, |
| 196 base::TimeTicks::Now()); | 197 current_time - first_ref_time_); |
| 197 } | 198 } |
| 198 | 199 |
| 199 env->ReleaseByteArrayElements(data, buffer, JNI_ABORT); | 200 env->ReleaseByteArrayElements(data, buffer, JNI_ABORT); |
| 200 } | 201 } |
| 201 | 202 |
| 202 void VideoCaptureDeviceAndroid::OnError(JNIEnv* env, | 203 void VideoCaptureDeviceAndroid::OnError(JNIEnv* env, |
| 203 const JavaParamRef<jobject>& obj, | 204 const JavaParamRef<jobject>& obj, |
| 204 const JavaParamRef<jstring>& message) { | 205 const JavaParamRef<jstring>& message) { |
| 205 SetErrorState(FROM_HERE, | 206 SetErrorState(FROM_HERE, |
| 206 base::android::ConvertJavaStringToUTF8(env, message)); | 207 base::android::ConvertJavaStringToUTF8(env, message)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 const tracked_objects::Location& from_here, | 256 const tracked_objects::Location& from_here, |
| 256 const std::string& reason) { | 257 const std::string& reason) { |
| 257 { | 258 { |
| 258 base::AutoLock lock(lock_); | 259 base::AutoLock lock(lock_); |
| 259 state_ = kError; | 260 state_ = kError; |
| 260 } | 261 } |
| 261 client_->OnError(from_here, reason); | 262 client_->OnError(from_here, reason); |
| 262 } | 263 } |
| 263 | 264 |
| 264 } // namespace media | 265 } // namespace media |
| OLD | NEW |