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

Side by Side Diff: services/video_capture/mojo_media_conversions.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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/video_capture/mojo_media_conversions.h" 5 #include "services/video_capture/mojo_media_conversions.h"
6 6
7 namespace video_capture { 7 namespace video_capture {
8 8
9 media::VideoCaptureFormat ConvertFromMojoToMedia(
10 mojom::VideoCaptureFormatPtr format) {
11 media::VideoCaptureFormat result;
12 result.pixel_format = ConvertFromMojoToMedia(format->pixel_format);
13 result.pixel_storage = ConvertFromMojoToMedia(format->pixel_storage);
14 result.frame_size.SetSize(format->frame_size.width(),
15 format->frame_size.height());
16 result.frame_rate = format->frame_rate;
17 return result;
18 }
19
20 media::VideoPixelFormat ConvertFromMojoToMedia(
21 media::mojom::VideoFormat format) {
22 // Since there are static_asserts in place in
23 // media/mojo/common/media_type_converters.cc to guarantee equality of the
24 // underlying representations, we can simply static_cast to convert.
25 return static_cast<media::VideoPixelFormat>(format);
26 }
27
28 media::VideoPixelStorage ConvertFromMojoToMedia(
29 mojom::VideoPixelStorage storage) {
30 switch (storage) {
31 case mojom::VideoPixelStorage::CPU:
32 return media::PIXEL_STORAGE_CPU;
33 case mojom::VideoPixelStorage::GPUMEMORYBUFFER:
34 return media::PIXEL_STORAGE_GPUMEMORYBUFFER;
35 }
36 NOTREACHED();
37 return media::PIXEL_STORAGE_CPU;
38 }
39
40 media::ResolutionChangePolicy ConvertFromMojoToMedia( 9 media::ResolutionChangePolicy ConvertFromMojoToMedia(
41 mojom::ResolutionChangePolicy policy) { 10 mojom::ResolutionChangePolicy policy) {
42 switch (policy) { 11 switch (policy) {
43 case mojom::ResolutionChangePolicy::FIXED_RESOLUTION: 12 case mojom::ResolutionChangePolicy::FIXED_RESOLUTION:
44 return media::RESOLUTION_POLICY_FIXED_RESOLUTION; 13 return media::RESOLUTION_POLICY_FIXED_RESOLUTION;
45 case mojom::ResolutionChangePolicy::FIXED_ASPECT_RATIO: 14 case mojom::ResolutionChangePolicy::FIXED_ASPECT_RATIO:
46 return media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO; 15 return media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO;
47 case mojom::ResolutionChangePolicy::ANY_WITHIN_LIMIT: 16 case mojom::ResolutionChangePolicy::ANY_WITHIN_LIMIT:
48 return media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT; 17 return media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT;
49 } 18 }
50 NOTREACHED(); 19 NOTREACHED();
51 return media::RESOLUTION_POLICY_FIXED_RESOLUTION; 20 return media::RESOLUTION_POLICY_FIXED_RESOLUTION;
52 } 21 }
53 22
54 media::PowerLineFrequency ConvertFromMojoToMedia( 23 media::PowerLineFrequency ConvertFromMojoToMedia(
55 mojom::PowerLineFrequency frequency) { 24 mojom::PowerLineFrequency frequency) {
56 switch (frequency) { 25 switch (frequency) {
57 case mojom::PowerLineFrequency::DEFAULT: 26 case mojom::PowerLineFrequency::DEFAULT:
58 return media::PowerLineFrequency::FREQUENCY_DEFAULT; 27 return media::PowerLineFrequency::FREQUENCY_DEFAULT;
59 case mojom::PowerLineFrequency::HZ_50: 28 case mojom::PowerLineFrequency::HZ_50:
60 return media::PowerLineFrequency::FREQUENCY_50HZ; 29 return media::PowerLineFrequency::FREQUENCY_50HZ;
61 case mojom::PowerLineFrequency::HZ_60: 30 case mojom::PowerLineFrequency::HZ_60:
62 return media::PowerLineFrequency::FREQUENCY_60HZ; 31 return media::PowerLineFrequency::FREQUENCY_60HZ;
63 } 32 }
64 NOTREACHED(); 33 NOTREACHED();
65 return media::PowerLineFrequency::FREQUENCY_DEFAULT; 34 return media::PowerLineFrequency::FREQUENCY_DEFAULT;
66 } 35 }
67 36
68 } // namespace video_capture 37 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/mojo_media_conversions.h ('k') | services/video_capture/public/interfaces/typemaps.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698