| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 "services/video_capture/public/interfaces/video_capture_format_traits.h
" | |
| 6 | |
| 7 #include "ui/gfx/geometry/mojo/geometry.mojom.h" | |
| 8 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" | |
| 9 | |
| 10 namespace mojo { | |
| 11 | |
| 12 // static | |
| 13 bool StructTraits<video_capture::mojom::VideoCaptureFormatDataView, | |
| 14 media::VideoCaptureFormat>:: | |
| 15 Read(video_capture::mojom::VideoCaptureFormatDataView data, | |
| 16 media::VideoCaptureFormat* out) { | |
| 17 if (!data.ReadFrameSize(&out->frame_size)) | |
| 18 return false; | |
| 19 out->frame_rate = data.frame_rate(); | |
| 20 | |
| 21 // Since there are static_asserts in place in | |
| 22 // media/mojo/common/media_type_converters.cc to guarantee equality of the | |
| 23 // underlying representations, we can simply static_cast to convert. | |
| 24 // TODO(mcasas): Use EnumTraits for VideoPixelFormat, https://crbug.com/651897 | |
| 25 out->pixel_format = | |
| 26 static_cast<media::VideoPixelFormat>(data.pixel_format()); | |
| 27 if (!data.ReadPixelStorage(&out->pixel_storage)) | |
| 28 return false; | |
| 29 return true; | |
| 30 } | |
| 31 | |
| 32 // static | |
| 33 video_capture::mojom::VideoPixelStorage | |
| 34 EnumTraits<video_capture::mojom::VideoPixelStorage, media::VideoPixelStorage>:: | |
| 35 ToMojom(media::VideoPixelStorage video_pixel_storage) { | |
| 36 DCHECK_EQ(media::PIXEL_STORAGE_CPU, video_pixel_storage); | |
| 37 return video_capture::mojom::VideoPixelStorage::CPU; | |
| 38 } | |
| 39 | |
| 40 // static | |
| 41 bool EnumTraits<video_capture::mojom::VideoPixelStorage, | |
| 42 media::VideoPixelStorage>:: | |
| 43 FromMojom(video_capture::mojom::VideoPixelStorage input, | |
| 44 media::VideoPixelStorage* out) { | |
| 45 DCHECK_EQ(video_capture::mojom::VideoPixelStorage::CPU, input); | |
| 46 *out = media::PIXEL_STORAGE_CPU; | |
| 47 return true; | |
| 48 } | |
| 49 | |
| 50 } // namespace mojo | |
| OLD | NEW |