Chromium Code Reviews| 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 gfx::Size StructTraits<video_capture::mojom::VideoCaptureFormatDataView, | |
| 14 media::VideoCaptureFormat>:: | |
| 15 frame_size(const media::VideoCaptureFormat& format) { | |
| 16 return gfx::Size(format.frame_size.width(), format.frame_size.height()); | |
|
dcheng
2016/10/04 01:33:18
Return a const gfx::Size& and return format.frame_
dcheng
2016/10/04 01:34:37
Btw, I should have elaborated in my original messa
mcasas
2016/10/04 02:46:20
Done.
| |
| 17 } | |
| 18 | |
| 19 // static | |
| 20 float StructTraits<video_capture::mojom::VideoCaptureFormatDataView, | |
| 21 media::VideoCaptureFormat>:: | |
| 22 frame_rate(const media::VideoCaptureFormat& format) { | |
| 23 return format.frame_rate; | |
|
dcheng
2016/10/04 01:33:18
Re: inline vs not-inline
If it's just calling a s
mcasas
2016/10/04 02:46:20
Done.
| |
| 24 } | |
| 25 | |
| 26 // static | |
| 27 media::mojom::VideoFormat StructTraits< | |
| 28 video_capture::mojom::VideoCaptureFormatDataView, | |
| 29 media::VideoCaptureFormat>::pixel_format(const media::VideoCaptureFormat& | |
| 30 format) { | |
| 31 return media::mojom::VideoFormat(format.pixel_format); | |
|
dcheng
2016/10/04 01:33:18
Nit: use static_cast to convert between types
mcasas
2016/10/04 02:46:20
Done.
| |
| 32 } | |
| 33 | |
| 34 // static | |
| 35 video_capture::mojom::VideoPixelStorage StructTraits< | |
| 36 video_capture::mojom::VideoCaptureFormatDataView, | |
| 37 media::VideoCaptureFormat>::pixel_storage(const media::VideoCaptureFormat& | |
| 38 format) { | |
| 39 return video_capture::mojom::VideoPixelStorage(format.pixel_storage); | |
| 40 } | |
| 41 | |
| 42 // static | |
| 43 bool StructTraits<video_capture::mojom::VideoCaptureFormatDataView, | |
| 44 media::VideoCaptureFormat>:: | |
| 45 Read(video_capture::mojom::VideoCaptureFormatDataView data, | |
| 46 media::VideoCaptureFormat* out) { | |
| 47 if (!data.ReadFrameSize(&out->frame_size)) | |
| 48 return false; | |
| 49 out->frame_rate = data.frame_rate(); | |
| 50 | |
| 51 // Since there are static_asserts in place in | |
| 52 // media/mojo/common/media_type_converters.cc to guarantee equality of the | |
| 53 // underlying representations, we can simply static_cast to convert. | |
| 54 // TODO(mcasas): Use EnumTraits for VideoPixelFormat, https://crbug.com/651897 | |
| 55 out->pixel_format = | |
| 56 static_cast<media::VideoPixelFormat>(data.pixel_format()); | |
| 57 if (!data.ReadPixelStorage(&out->pixel_storage)) | |
| 58 return false; | |
| 59 return true; | |
| 60 } | |
| 61 | |
| 62 // static | |
| 63 video_capture::mojom::VideoPixelStorage | |
| 64 EnumTraits<video_capture::mojom::VideoPixelStorage, media::VideoPixelStorage>:: | |
| 65 ToMojom(media::VideoPixelStorage video_pixel_storage) { | |
| 66 switch (video_pixel_storage) { | |
| 67 case media::PIXEL_STORAGE_CPU: | |
| 68 return video_capture::mojom::VideoPixelStorage::CPU; | |
| 69 case media::PIXEL_STORAGE_GPUMEMORYBUFFER: | |
| 70 return video_capture::mojom::VideoPixelStorage::GPUMEMORYBUFFER; | |
| 71 } | |
| 72 NOTREACHED(); | |
| 73 return video_capture::mojom::VideoPixelStorage::CPU; | |
| 74 } | |
| 75 | |
| 76 // static | |
| 77 bool EnumTraits<video_capture::mojom::VideoPixelStorage, | |
| 78 media::VideoPixelStorage>:: | |
| 79 FromMojom(video_capture::mojom::VideoPixelStorage input, | |
| 80 media::VideoPixelStorage* out) { | |
| 81 switch (input) { | |
| 82 case video_capture::mojom::VideoPixelStorage::CPU: | |
| 83 *out = media::PIXEL_STORAGE_CPU; | |
| 84 return true; | |
| 85 case video_capture::mojom::VideoPixelStorage::GPUMEMORYBUFFER: | |
| 86 *out = media::PIXEL_STORAGE_GPUMEMORYBUFFER; | |
| 87 return true; | |
| 88 } | |
| 89 NOTREACHED(); | |
| 90 return false; | |
| 91 } | |
| 92 | |
| 93 } // namespace mojo | |
| OLD | NEW |