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 const gfx::Size& StructTraits<video_capture::mojom::VideoCaptureFormatDataView, | |
14 media::VideoCaptureFormat>:: | |
15 frame_size(const media::VideoCaptureFormat& format) { | |
16 return format.frame_size; | |
dcheng
2016/10/04 22:09:26
Inline, since we're just returning a member refere
mcasas
2016/10/04 22:16:56
Done.
| |
17 } | |
18 | |
19 // static | |
20 media::mojom::VideoFormat StructTraits< | |
21 video_capture::mojom::VideoCaptureFormatDataView, | |
22 media::VideoCaptureFormat>::pixel_format(const media::VideoCaptureFormat& | |
23 format) { | |
24 return static_cast<media::mojom::VideoFormat>(format.pixel_format); | |
dcheng
2016/10/04 22:09:26
Ditto, inline these as well.
mcasas
2016/10/04 22:16:56
Done.
| |
25 } | |
26 | |
27 // static | |
28 video_capture::mojom::VideoPixelStorage StructTraits< | |
29 video_capture::mojom::VideoCaptureFormatDataView, | |
30 media::VideoCaptureFormat>::pixel_storage(const media::VideoCaptureFormat& | |
31 format) { | |
32 return static_cast<video_capture::mojom::VideoPixelStorage>( | |
33 format.pixel_storage); | |
34 } | |
35 | |
36 // static | |
37 bool StructTraits<video_capture::mojom::VideoCaptureFormatDataView, | |
38 media::VideoCaptureFormat>:: | |
39 Read(video_capture::mojom::VideoCaptureFormatDataView data, | |
40 media::VideoCaptureFormat* out) { | |
41 if (!data.ReadFrameSize(&out->frame_size)) | |
42 return false; | |
43 out->frame_rate = data.frame_rate(); | |
44 | |
45 // Since there are static_asserts in place in | |
46 // media/mojo/common/media_type_converters.cc to guarantee equality of the | |
47 // underlying representations, we can simply static_cast to convert. | |
48 // TODO(mcasas): Use EnumTraits for VideoPixelFormat, https://crbug.com/651897 | |
49 out->pixel_format = | |
50 static_cast<media::VideoPixelFormat>(data.pixel_format()); | |
51 if (!data.ReadPixelStorage(&out->pixel_storage)) | |
52 return false; | |
53 return true; | |
54 } | |
55 | |
56 // static | |
57 video_capture::mojom::VideoPixelStorage | |
58 EnumTraits<video_capture::mojom::VideoPixelStorage, media::VideoPixelStorage>:: | |
59 ToMojom(media::VideoPixelStorage video_pixel_storage) { | |
60 switch (video_pixel_storage) { | |
61 case media::PIXEL_STORAGE_CPU: | |
62 return video_capture::mojom::VideoPixelStorage::CPU; | |
63 case media::PIXEL_STORAGE_GPUMEMORYBUFFER: | |
64 return video_capture::mojom::VideoPixelStorage::GPUMEMORYBUFFER; | |
65 } | |
66 NOTREACHED(); | |
67 return video_capture::mojom::VideoPixelStorage::CPU; | |
68 } | |
69 | |
70 // static | |
71 bool EnumTraits<video_capture::mojom::VideoPixelStorage, | |
72 media::VideoPixelStorage>:: | |
73 FromMojom(video_capture::mojom::VideoPixelStorage input, | |
74 media::VideoPixelStorage* out) { | |
75 switch (input) { | |
76 case video_capture::mojom::VideoPixelStorage::CPU: | |
77 *out = media::PIXEL_STORAGE_CPU; | |
78 return true; | |
79 case video_capture::mojom::VideoPixelStorage::GPUMEMORYBUFFER: | |
80 *out = media::PIXEL_STORAGE_GPUMEMORYBUFFER; | |
81 return true; | |
82 } | |
83 NOTREACHED(); | |
84 return false; | |
85 } | |
86 | |
87 } // namespace mojo | |
OLD | NEW |