Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1499)

Side by Side Diff: services/video_capture/public/interfaces/video_capture_format_traits.cc

Issue 2379253003: Video Capture Service: typemap video_capture's and media's VideoCaptureFormat (Closed)
Patch Set: dcheng@s comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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<
14 video_capture::mojom::VideoCaptureFormatDataView,
15 media::VideoCaptureFormat>::frame_size(const media::VideoCaptureFormat& r) {
chfremer 2016/10/03 16:26:59 Why "r"? Even though this may come from one of the
mcasas 2016/10/03 21:19:07 Done.
16 return gfx::Size(r.frame_size.width(), r.frame_size.height());
17 }
18
19 // static
20 float StructTraits<
21 video_capture::mojom::VideoCaptureFormatDataView,
22 media::VideoCaptureFormat>::frame_rate(const media::VideoCaptureFormat& r) {
23 return r.frame_rate;
24 }
25
26 // static
27 media::mojom::VideoFormat StructTraits<
28 video_capture::mojom::VideoCaptureFormatDataView,
29 media::VideoCaptureFormat>::pixel_format(const media::VideoCaptureFormat&
30 r) {
31 return media::mojom::VideoFormat(r.pixel_format);
32 }
33
34 // static
35 bool StructTraits<video_capture::mojom::VideoCaptureFormatDataView,
36 media::VideoCaptureFormat>::
37 Read(video_capture::mojom::VideoCaptureFormatDataView data,
38 media::VideoCaptureFormat* out) {
39 if (!data.ReadFrameSize(&out->frame_size))
40 return false;
41 out->frame_rate = data.frame_rate();
42
43 // Since there are static_asserts in place in
44 // media/mojo/common/media_type_converters.cc to guarantee equality of the
45 // underlying representations, we can simply static_cast to convert.
46 out->pixel_format =
47 static_cast<media::VideoPixelFormat>(data.pixel_format());
48 if (!data.ReadPixelStorage(&out->pixel_storage))
49 return false;
50 return true;
51 }
52
53 //static
54 video_capture::mojom::VideoPixelStorage
55 EnumTraits<video_capture::mojom::VideoPixelStorage, media::VideoPixelStorage>::
56 ToMojom(media::VideoPixelStorage video_pixel_storage) {
57 switch (video_pixel_storage) {
58 case media::PIXEL_STORAGE_CPU:
59 return video_capture::mojom::VideoPixelStorage::CPU;
60 case media::PIXEL_STORAGE_GPUMEMORYBUFFER:
61 return video_capture::mojom::VideoPixelStorage::GPUMEMORYBUFFER;
62 }
63 NOTREACHED();
64 return video_capture::mojom::VideoPixelStorage::CPU;
65 }
66
67 //static
68 bool EnumTraits<video_capture::mojom::VideoPixelStorage,
69 media::VideoPixelStorage>::
70 FromMojom(video_capture::mojom::VideoPixelStorage input,
71 media::VideoPixelStorage* out) {
72 switch (input) {
73 case video_capture::mojom::VideoPixelStorage::CPU:
74 *out = media::PIXEL_STORAGE_CPU;
75 return true;
76 case video_capture::mojom::VideoPixelStorage::GPUMEMORYBUFFER:
77 *out = media::PIXEL_STORAGE_GPUMEMORYBUFFER;
78 return true;
79 }
80 NOTREACHED();
81 return false;
82 }
83
84 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698