Index: services/video_capture/public/interfaces/video_capture_format_traits.h |
diff --git a/services/video_capture/public/interfaces/video_capture_format_traits.h b/services/video_capture/public/interfaces/video_capture_format_traits.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a33beb287b999155968d140c9a70abeaffa5005a |
--- /dev/null |
+++ b/services/video_capture/public/interfaces/video_capture_format_traits.h |
@@ -0,0 +1,51 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef SERVICES_VIDEO_CAPTURE_PUBLIC_INTERFACES_VIDEO_CAPTURE_FORMAT_TYPEMAP_H_ |
+#define SERVICES_VIDEO_CAPTURE_PUBLIC_INTERFACES_VIDEO_CAPTURE_FORMAT_TYPEMAP_H_ |
+ |
+#include "media/base/video_capture_types.h" |
+#include "mojo/common/common_custom_types_struct_traits.h" |
+#include "services/video_capture/public/interfaces/video_capture_format.mojom.h" |
+ |
+namespace mojo { |
+ |
+template <> |
+struct StructTraits<video_capture::mojom::VideoCaptureFormatDataView, |
+ media::VideoCaptureFormat> { |
+ static const gfx::Size& frame_size(const media::VideoCaptureFormat& format) { |
+ return format.frame_size; |
+ } |
+ |
+ static float frame_rate(const media::VideoCaptureFormat& format) { |
+ return format.frame_rate; |
+ } |
+ |
+ static media::mojom::VideoFormat pixel_format( |
+ const media::VideoCaptureFormat& format) { |
+ return static_cast<media::mojom::VideoFormat>(format.pixel_format); |
+ } |
+ |
+ static video_capture::mojom::VideoPixelStorage pixel_storage( |
+ const media::VideoCaptureFormat& format) { |
+ return static_cast<video_capture::mojom::VideoPixelStorage>( |
+ format.pixel_storage); |
+} |
+ |
+ static bool Read(video_capture::mojom::VideoCaptureFormatDataView data, |
+ media::VideoCaptureFormat* out); |
+}; |
+ |
+template <> |
+struct EnumTraits<video_capture::mojom::VideoPixelStorage, |
+ media::VideoPixelStorage> { |
+ static video_capture::mojom::VideoPixelStorage ToMojom( |
+ media::VideoPixelStorage video_pixel_storage); |
+ |
+ static bool FromMojom(video_capture::mojom::VideoPixelStorage input, |
+ media::VideoPixelStorage* out); |
+}; |
+} |
+ |
+#endif // SERVICES_VIDEO_CAPTURE_PUBLIC_INTERFACES_VIDEO_CAPTURE_FORMAT_TYPEMAP_H_ |