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

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

Issue 2379253003: Video Capture Service: typemap video_capture's and media's VideoCaptureFormat (Closed)
Patch Set: 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 #ifndef SERVICES_VIDEO_CAPTURE_PUBLIC_INTERFACES_VIDEO_CAPTURE_FORMAT_TYPEMAP_H_
6 #define SERVICES_VIDEO_CAPTURE_PUBLIC_INTERFACES_VIDEO_CAPTURE_FORMAT_TYPEMAP_H_
7
8 #include "media/base/video_capture_types.h"
9 #include "mojo/common/common_custom_types_struct_traits.h"
10 #include "services/video_capture/public/interfaces/video_capture_format.mojom.h"
11 #include "ui/gfx/geometry/mojo/geometry.mojom.h"
12 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h"
13
14 namespace mojo {
15
16 template <>
17 struct StructTraits<video_capture::mojom::VideoCaptureFormatDataView,
18 media::VideoCaptureFormat> {
19
20 static gfx::Size frame_size(const media::VideoCaptureFormat& r) {
21 return gfx::Size(r.frame_size.width(), r.frame_size.height());
22 }
23
24 static float frame_rate(const media::VideoCaptureFormat& r) {
25 return r.frame_rate;
26 }
27
28 static media::mojom::VideoFormat pixel_format(
29 const media::VideoCaptureFormat& r) {
30 return static_cast<media::mojom::VideoFormat>(r.pixel_format);
dcheng 2016/10/03 01:03:08 Mojo has EnumTraits for mapping enums. Example: ht
mcasas 2016/10/03 07:31:51 Using it for VideoPixelStorage in l.33, but re. th
chfremer 2016/10/03 16:26:59 In my take on using the typmapping, I ended up rem
dcheng 2016/10/03 20:45:53 My recollection is the //media code predated the a
31 }
32
33 static video_capture::mojom::VideoPixelStorage pixel_storage(
34 const media::VideoCaptureFormat& r) {
35 return static_cast<video_capture::mojom::VideoPixelStorage>(
36 r.pixel_storage);
37 }
38
39 static bool Read(video_capture::mojom::VideoCaptureFormatDataView data,
dcheng 2016/10/03 01:03:08 Nit: Out-of-line this.
mcasas 2016/10/03 07:31:51 Done.
40 media::VideoCaptureFormat* out) {
41 gfx::Size frame_size;
42 data.ReadFrameSize(&frame_size);
dcheng 2016/10/03 01:03:08 Nit: read directly into out->frame_size, and check
mcasas 2016/10/03 07:31:51 Done.
43 out->frame_size = frame_size;
44 out->frame_rate = data.frame_rate();
45 out->pixel_format =
46 static_cast<media::VideoPixelFormat>(data.pixel_format());
47 out->pixel_storage =
48 static_cast<media::VideoPixelStorage>(data.pixel_storage());
49 return true;
50 }
51 };
52
53 }
54
55 #endif // SERVICES_VIDEO_CAPTURE_PUBLIC_INTERFACES_VIDEO_CAPTURE_FORMAT_TYPEMAP _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698