Chromium Code Reviews| Index: media/capture/video/chromeos/camera_device_context.cc |
| diff --git a/media/capture/video/chromeos/camera_device_context.cc b/media/capture/video/chromeos/camera_device_context.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b490d150e49814f65de1228ed98b44e1bca5709c |
| --- /dev/null |
| +++ b/media/capture/video/chromeos/camera_device_context.cc |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "media/capture/video/chromeos/camera_device_context.h" |
| + |
| +namespace media { |
| + |
| +CameraDeviceContext::CameraDeviceContext( |
| + std::unique_ptr<VideoCaptureDevice::Client> client) |
| + : state_(kStopped), rotation_(0), client_(std::move(client)) { |
| + DCHECK(client_); |
| +} |
| + |
| +CameraDeviceContext::~CameraDeviceContext() {} |
| + |
| +void CameraDeviceContext::SetState(State state) { |
| + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| + state_ = state; |
| + if (state_ == kCapturing) { |
| + client_->OnStarted(); |
| + } |
| +} |
| + |
| +CameraDeviceContext::State CameraDeviceContext::GetState() { |
| + return state_; |
| +} |
| + |
| +void CameraDeviceContext::SetErrorState( |
| + const tracked_objects::Location& from_here, |
| + const std::string& reason) { |
| + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| + state_ = kError; |
| + LOG(ERROR) << reason; |
| + client_->OnError(from_here, reason); |
| +} |
| + |
| +void CameraDeviceContext::LogToClient(std::string message) { |
| + client_->OnLog(message); |
| +} |
| + |
| +void CameraDeviceContext::SubmitCapturedData( |
| + const uint8_t* data, |
| + int length, |
| + const VideoCaptureFormat& frame_format, |
| + base::TimeTicks reference_time, |
| + base::TimeDelta timestamp) { |
| + client_->OnIncomingCapturedData(data, length, frame_format, rotation_, |
|
Pawel Osciak
2017/06/13 08:40:15
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_)
jcliang
2017/06/14 04:46:04
The |sequence_checker_| is mainly for making sure
|
| + reference_time, timestamp); |
| +} |
| + |
| +void CameraDeviceContext::SetRotation(int rotation) { |
| + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| + DCHECK(rotation >= 0 && rotation < 360 && rotation % 90 == 0); |
| + rotation_ = rotation; |
| +} |
| + |
| +} // namespace media |