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

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: more traits methods inlining 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 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 switch (video_pixel_storage) {
37 case media::PIXEL_STORAGE_CPU:
38 return video_capture::mojom::VideoPixelStorage::CPU;
39 case media::PIXEL_STORAGE_GPUMEMORYBUFFER:
40 return video_capture::mojom::VideoPixelStorage::GPUMEMORYBUFFER;
41 }
42 NOTREACHED();
43 return video_capture::mojom::VideoPixelStorage::CPU;
44 }
45
46 // static
47 bool EnumTraits<video_capture::mojom::VideoPixelStorage,
48 media::VideoPixelStorage>::
49 FromMojom(video_capture::mojom::VideoPixelStorage input,
50 media::VideoPixelStorage* out) {
51 switch (input) {
52 case video_capture::mojom::VideoPixelStorage::CPU:
53 *out = media::PIXEL_STORAGE_CPU;
54 return true;
55 case video_capture::mojom::VideoPixelStorage::GPUMEMORYBUFFER:
56 *out = media::PIXEL_STORAGE_GPUMEMORYBUFFER;
57 return true;
58 }
59 NOTREACHED();
60 return false;
61 }
62
63 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698