| 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 void CameraDeviceContext::SetState(State state) { |
| 16 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 17 state_ = state; |
| 18 if (state_ == kCapturing) { |
| 19 client_->OnStarted(); |
| 20 } |
| 21 } |
| 22 |
| 23 CameraDeviceContext::State CameraDeviceContext::GetState() { |
| 24 return state_; |
| 25 } |
| 26 |
| 27 void CameraDeviceContext::SetErrorState( |
| 28 const tracked_objects::Location& from_here, |
| 29 const std::string& reason) { |
| 30 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 31 state_ = kError; |
| 32 LOG(ERROR) << reason; |
| 33 client_->OnError(from_here, reason); |
| 34 } |
| 35 |
| 36 void CameraDeviceContext::LogToClient(std::string message) { |
| 37 client_->OnLog(message); |
| 38 } |
| 39 |
| 40 void CameraDeviceContext::SubmitCapturedData( |
| 41 const uint8_t* data, |
| 42 int length, |
| 43 const VideoCaptureFormat& frame_format, |
| 44 base::TimeTicks reference_time, |
| 45 base::TimeDelta timestamp) { |
| 46 client_->OnIncomingCapturedData(data, length, frame_format, rotation_, |
| 47 reference_time, timestamp); |
| 48 } |
| 49 |
| 50 void CameraDeviceContext::SetRotation(int rotation) { |
| 51 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 52 DCHECK(rotation >= 0 && rotation < 360 && rotation % 90 == 0); |
| 53 rotation_ = rotation; |
| 54 } |
| 55 |
| 56 } // namespace media |
| OLD | NEW |