Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "media/capture/video/chromeos/camera_device_context.h" | |
| 6 | |
| 7 namespace media { | |
| 8 | |
| 9 CameraDeviceContext::CameraDeviceContext( | |
| 10 std::unique_ptr<VideoCaptureDevice::Client> client) | |
| 11 : state_(kStopped), rotation_(0), client_(std::move(client)) { | |
| 12 DCHECK(client_); | |
| 13 } | |
| 14 | |
| 15 CameraDeviceContext::~CameraDeviceContext() {} | |
| 16 | |
| 17 void CameraDeviceContext::SetState(State state) { | |
| 18 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | |
| 19 state_ = state; | |
| 20 if (state_ == kCapturing) { | |
| 21 client_->OnStarted(); | |
| 22 } | |
| 23 } | |
| 24 | |
| 25 CameraDeviceContext::State CameraDeviceContext::GetState() { | |
| 26 return state_; | |
| 27 } | |
| 28 | |
| 29 void CameraDeviceContext::SetErrorState( | |
| 30 const tracked_objects::Location& from_here, | |
| 31 const std::string& reason) { | |
| 32 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | |
| 33 state_ = kError; | |
| 34 LOG(ERROR) << reason; | |
| 35 client_->OnError(from_here, reason); | |
| 36 } | |
| 37 | |
| 38 void CameraDeviceContext::LogToClient(std::string message) { | |
| 39 client_->OnLog(message); | |
| 40 } | |
| 41 | |
| 42 void CameraDeviceContext::SubmitCapturedData( | |
| 43 const uint8_t* data, | |
| 44 int length, | |
| 45 const VideoCaptureFormat& frame_format, | |
| 46 base::TimeTicks reference_time, | |
| 47 base::TimeDelta timestamp) { | |
| 48 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
| |
| 49 reference_time, timestamp); | |
| 50 } | |
| 51 | |
| 52 void CameraDeviceContext::SetRotation(int rotation) { | |
| 53 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | |
| 54 DCHECK(rotation >= 0 && rotation < 360 && rotation % 90 == 0); | |
| 55 rotation_ = rotation; | |
| 56 } | |
| 57 | |
| 58 } // namespace media | |
| OLD | NEW |