| 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/video/capture/android/video_capture_device_android.h" | 5 #include "media/video/capture/android/video_capture_device_android.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 if (!got_first_frame_) { | 221 if (!got_first_frame_) { |
| 222 // Set aside one frame allowance for fluctuation. | 222 // Set aside one frame allowance for fluctuation. |
| 223 expected_next_frame_time_ = current_time - frame_interval_; | 223 expected_next_frame_time_ = current_time - frame_interval_; |
| 224 got_first_frame_ = true; | 224 got_first_frame_ = true; |
| 225 } | 225 } |
| 226 | 226 |
| 227 // Deliver the frame when it doesn't arrive too early. | 227 // Deliver the frame when it doesn't arrive too early. |
| 228 if (expected_next_frame_time_ <= current_time) { | 228 if (expected_next_frame_time_ <= current_time) { |
| 229 expected_next_frame_time_ += frame_interval_; | 229 expected_next_frame_time_ += frame_interval_; |
| 230 | 230 |
| 231 client_->OnIncomingCapturedFrame( | 231 client_->OnIncomingCapturedFrame(reinterpret_cast<uint8*>(buffer), |
| 232 reinterpret_cast<uint8*>(buffer), length, base::Time::Now(), | 232 length, |
| 233 rotation, flip_vert, flip_horiz, current_settings_); | 233 base::Time::Now(), |
| 234 rotation, |
| 235 flip_vert, |
| 236 flip_horiz, |
| 237 current_settings_); |
| 234 } | 238 } |
| 235 | 239 |
| 236 env->ReleaseByteArrayElements(data, buffer, JNI_ABORT); | 240 env->ReleaseByteArrayElements(data, buffer, JNI_ABORT); |
| 237 } | 241 } |
| 238 | 242 |
| 239 VideoPixelFormat VideoCaptureDeviceAndroid::GetColorspace() { | 243 VideoPixelFormat VideoCaptureDeviceAndroid::GetColorspace() { |
| 240 JNIEnv* env = AttachCurrentThread(); | 244 JNIEnv* env = AttachCurrentThread(); |
| 241 int current_capture_colorspace = | 245 int current_capture_colorspace = |
| 242 Java_VideoCapture_getColorspace(env, j_capture_.obj()); | 246 Java_VideoCapture_getColorspace(env, j_capture_.obj()); |
| 243 switch (current_capture_colorspace){ | 247 switch (current_capture_colorspace){ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 260 void VideoCaptureDeviceAndroid::SetErrorState(const std::string& reason) { | 264 void VideoCaptureDeviceAndroid::SetErrorState(const std::string& reason) { |
| 261 LOG(ERROR) << "VideoCaptureDeviceAndroid::SetErrorState: " << reason; | 265 LOG(ERROR) << "VideoCaptureDeviceAndroid::SetErrorState: " << reason; |
| 262 { | 266 { |
| 263 base::AutoLock lock(lock_); | 267 base::AutoLock lock(lock_); |
| 264 state_ = kError; | 268 state_ = kError; |
| 265 } | 269 } |
| 266 client_->OnError(); | 270 client_->OnError(); |
| 267 } | 271 } |
| 268 | 272 |
| 269 } // namespace media | 273 } // namespace media |
| OLD | NEW |