Chromium Code Reviews| Index: media/capture/video/video_capture_device_client.cc |
| diff --git a/media/capture/video/video_capture_device_client.cc b/media/capture/video/video_capture_device_client.cc |
| index 215785ea4f72f144c3cb16c4220e1e170271e0d4..3ef8fc5d2732d188133419b69703160596f39b4a 100644 |
| --- a/media/capture/video/video_capture_device_client.cc |
| +++ b/media/capture/video/video_capture_device_client.cc |
| @@ -80,6 +80,7 @@ VideoCaptureDeviceClient::VideoCaptureDeviceClient( |
| jpeg_decoder_factory_callback_(jpeg_decoder_factory), |
| external_jpeg_decoder_initialized_(false), |
| buffer_pool_(buffer_pool), |
| + is_back_camera_(false), |
| last_captured_pixel_format_(media::PIXEL_FORMAT_UNKNOWN) {} |
| VideoCaptureDeviceClient::~VideoCaptureDeviceClient() { |
| @@ -133,6 +134,14 @@ void VideoCaptureDeviceClient::OnIncomingCapturedData( |
| DCHECK_EQ(0, rotation % 90) << " Rotation must be a multiple of 90, now: " |
| << rotation; |
| + |
| + if (is_back_camera_) { |
| + // For back camera, we need to rotate (360 - screen_rotation). |
| + // Ex: when screen rotation is 90, we have to rotate the frame by 270 |
| + // clockwise. |
| + rotation = (360 - rotation) % 360; |
|
wuchengli
2016/11/16 12:15:19
Can we calculate the right rotation in VideoCaptur
shenghao
2016/11/17 08:41:45
Done.
|
| + } |
| + |
| libyuv::RotationMode rotation_mode = libyuv::kRotate0; |
| if (rotation == 90) |
| rotation_mode = libyuv::kRotate90; |
| @@ -355,6 +364,10 @@ double VideoCaptureDeviceClient::GetBufferPoolUtilization() const { |
| return buffer_pool_->GetBufferPoolUtilization(); |
| } |
| +void VideoCaptureDeviceClient::SetCameraFacing(bool is_back_camera) { |
| + is_back_camera_ = is_back_camera; |
| +} |
| + |
| std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> |
| VideoCaptureDeviceClient::ReserveI420OutputBuffer( |
| const gfx::Size& dimensions, |