Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 "components/arc/video_accelerator/video_encode_accelerator_struct_trait s.h" | |
| 6 | |
| 7 namespace mojo { | |
| 8 | |
| 9 // Make sure values in arc::mojom::VideoEncodeAccelerator::Error and | |
| 10 // media::VideoEncodeAccelerator::Error match. | |
| 11 #define CHECK_ERROR_ENUM(value) \ | |
| 12 static_assert( \ | |
| 13 static_cast<int>(arc::mojom::VideoEncodeAccelerator::Error::value) == \ | |
| 14 media::VideoEncodeAccelerator::Error::value, \ | |
| 15 "enum ##value mismatch") | |
| 16 | |
| 17 CHECK_ERROR_ENUM(kIllegalStateError); | |
| 18 CHECK_ERROR_ENUM(kInvalidArgumentError); | |
| 19 CHECK_ERROR_ENUM(kPlatformFailureError); | |
| 20 CHECK_ERROR_ENUM(kErrorMax); | |
| 21 | |
| 22 #undef CHECK_ERROR_ENUM | |
| 23 | |
| 24 // static | |
| 25 arc::mojom::VideoEncodeAccelerator::Error | |
| 26 EnumTraits<arc::mojom::VideoEncodeAccelerator::Error, | |
| 27 media::VideoEncodeAccelerator::Error>:: | |
| 28 ToMojom(media::VideoEncodeAccelerator::Error input) { | |
| 29 return static_cast<arc::mojom::VideoEncodeAccelerator::Error>(input); | |
| 30 } | |
| 31 | |
| 32 // static | |
| 33 bool EnumTraits<arc::mojom::VideoEncodeAccelerator::Error, | |
| 34 media::VideoEncodeAccelerator::Error>:: | |
| 35 FromMojom(arc::mojom::VideoEncodeAccelerator::Error input, | |
| 36 media::VideoEncodeAccelerator::Error* output) { | |
| 37 NOTIMPLEMENTED(); | |
| 38 return false; | |
| 39 } | |
| 40 | |
| 41 // Make sure values in arc::mojom::VideoPixelFormat match to the values in | |
| 42 // media::VideoPixelFormat. The former is a subset of the later. | |
| 43 #define CHECK_PIXEL_FORMAT_ENUM(value) \ | |
| 44 static_assert( \ | |
| 45 static_cast<int>(arc::mojom::VideoPixelFormat::value) == media::value, \ | |
| 46 "enum ##value mismatch") | |
| 47 | |
| 48 CHECK_PIXEL_FORMAT_ENUM(PIXEL_FORMAT_I420); | |
| 49 | |
| 50 #undef CHECK_PXIEL_FORMAT_ENUM | |
| 51 | |
| 52 // static | |
| 53 arc::mojom::VideoPixelFormat | |
| 54 EnumTraits<arc::mojom::VideoPixelFormat, media::VideoPixelFormat>::ToMojom( | |
| 55 media::VideoPixelFormat input) { | |
| 56 NOTIMPLEMENTED(); | |
| 57 return arc::mojom::VideoPixelFormat::PIXEL_FORMAT_I420; | |
| 58 } | |
| 59 | |
| 60 // static | |
| 61 bool EnumTraits<arc::mojom::VideoPixelFormat, media::VideoPixelFormat>:: | |
| 62 FromMojom(arc::mojom::VideoPixelFormat input, | |
| 63 media::VideoPixelFormat* output) { | |
| 64 switch (input) { | |
| 65 case arc::mojom::VideoPixelFormat::PIXEL_FORMAT_I420: | |
| 66 *output = static_cast<media::VideoPixelFormat>(input); | |
| 67 return true; | |
| 68 default: | |
| 69 LOG(ERROR) << "Unknown VideoPixelFormat: " << input; | |
|
dcheng
2017/06/21 09:42:29
Nit: DLOG
| |
| 70 return false; | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 // Make sure values in arc::mojom::VideoCodecProfile match to the values in | |
| 75 // media::VideoCodecProfile. | |
| 76 #define CHECK_PROFILE_ENUM(value) \ | |
| 77 static_assert( \ | |
| 78 static_cast<int>(arc::mojom::VideoCodecProfile::value) == media::value, \ | |
| 79 "enum ##value mismatch") | |
| 80 | |
| 81 CHECK_PROFILE_ENUM(VIDEO_CODEC_PROFILE_UNKNOWN); | |
| 82 CHECK_PROFILE_ENUM(VIDEO_CODEC_PROFILE_MIN); | |
| 83 CHECK_PROFILE_ENUM(H264PROFILE_MIN); | |
| 84 CHECK_PROFILE_ENUM(H264PROFILE_BASELINE); | |
| 85 CHECK_PROFILE_ENUM(H264PROFILE_MAIN); | |
| 86 CHECK_PROFILE_ENUM(H264PROFILE_EXTENDED); | |
| 87 CHECK_PROFILE_ENUM(H264PROFILE_HIGH); | |
| 88 CHECK_PROFILE_ENUM(H264PROFILE_HIGH10PROFILE); | |
| 89 CHECK_PROFILE_ENUM(H264PROFILE_HIGH422PROFILE); | |
| 90 CHECK_PROFILE_ENUM(H264PROFILE_HIGH444PREDICTIVEPROFILE); | |
| 91 CHECK_PROFILE_ENUM(H264PROFILE_SCALABLEBASELINE); | |
| 92 CHECK_PROFILE_ENUM(H264PROFILE_SCALABLEHIGH); | |
| 93 CHECK_PROFILE_ENUM(H264PROFILE_STEREOHIGH); | |
| 94 CHECK_PROFILE_ENUM(H264PROFILE_MULTIVIEWHIGH); | |
| 95 CHECK_PROFILE_ENUM(H264PROFILE_MAX); | |
| 96 CHECK_PROFILE_ENUM(VP8PROFILE_MIN); | |
| 97 CHECK_PROFILE_ENUM(VP8PROFILE_ANY); | |
| 98 CHECK_PROFILE_ENUM(VP8PROFILE_MAX); | |
| 99 CHECK_PROFILE_ENUM(VP9PROFILE_MIN); | |
| 100 CHECK_PROFILE_ENUM(VP9PROFILE_PROFILE0); | |
| 101 CHECK_PROFILE_ENUM(VP9PROFILE_PROFILE1); | |
| 102 CHECK_PROFILE_ENUM(VP9PROFILE_PROFILE2); | |
| 103 CHECK_PROFILE_ENUM(VP9PROFILE_PROFILE3); | |
| 104 CHECK_PROFILE_ENUM(VP9PROFILE_MAX); | |
| 105 CHECK_PROFILE_ENUM(HEVCPROFILE_MIN); | |
| 106 CHECK_PROFILE_ENUM(HEVCPROFILE_MAIN); | |
| 107 CHECK_PROFILE_ENUM(HEVCPROFILE_MAIN10); | |
| 108 CHECK_PROFILE_ENUM(HEVCPROFILE_MAIN_STILL_PICTURE); | |
| 109 CHECK_PROFILE_ENUM(HEVCPROFILE_MAX); | |
| 110 CHECK_PROFILE_ENUM(DOLBYVISION_MIN); | |
| 111 CHECK_PROFILE_ENUM(DOLBYVISION_PROFILE0); | |
| 112 CHECK_PROFILE_ENUM(DOLBYVISION_PROFILE4); | |
| 113 CHECK_PROFILE_ENUM(DOLBYVISION_PROFILE5); | |
| 114 CHECK_PROFILE_ENUM(DOLBYVISION_PROFILE7); | |
| 115 CHECK_PROFILE_ENUM(DOLBYVISION_MAX); | |
| 116 CHECK_PROFILE_ENUM(VIDEO_CODEC_PROFILE_MAX); | |
| 117 | |
| 118 #undef CHECK_PROFILE_ENUM | |
| 119 | |
| 120 // static | |
| 121 arc::mojom::VideoCodecProfile | |
| 122 EnumTraits<arc::mojom::VideoCodecProfile, media::VideoCodecProfile>::ToMojom( | |
| 123 media::VideoCodecProfile input) { | |
| 124 return static_cast<arc::mojom::VideoCodecProfile>(input); | |
| 125 } | |
| 126 | |
| 127 // static | |
| 128 bool EnumTraits<arc::mojom::VideoCodecProfile, media::VideoCodecProfile>:: | |
| 129 FromMojom(arc::mojom::VideoCodecProfile input, | |
| 130 media::VideoCodecProfile* output) { | |
| 131 switch (input) { | |
| 132 case arc::mojom::VideoCodecProfile::VIDEO_CODEC_PROFILE_UNKNOWN: | |
| 133 case arc::mojom::VideoCodecProfile::H264PROFILE_BASELINE: | |
| 134 case arc::mojom::VideoCodecProfile::H264PROFILE_MAIN: | |
| 135 case arc::mojom::VideoCodecProfile::H264PROFILE_EXTENDED: | |
| 136 case arc::mojom::VideoCodecProfile::H264PROFILE_HIGH: | |
| 137 case arc::mojom::VideoCodecProfile::H264PROFILE_HIGH10PROFILE: | |
| 138 case arc::mojom::VideoCodecProfile::H264PROFILE_HIGH422PROFILE: | |
| 139 case arc::mojom::VideoCodecProfile::H264PROFILE_HIGH444PREDICTIVEPROFILE: | |
| 140 case arc::mojom::VideoCodecProfile::H264PROFILE_SCALABLEBASELINE: | |
| 141 case arc::mojom::VideoCodecProfile::H264PROFILE_SCALABLEHIGH: | |
| 142 case arc::mojom::VideoCodecProfile::H264PROFILE_STEREOHIGH: | |
| 143 case arc::mojom::VideoCodecProfile::H264PROFILE_MULTIVIEWHIGH: | |
| 144 case arc::mojom::VideoCodecProfile::VP8PROFILE_ANY: | |
| 145 case arc::mojom::VideoCodecProfile::VP9PROFILE_PROFILE0: | |
| 146 case arc::mojom::VideoCodecProfile::VP9PROFILE_PROFILE1: | |
| 147 case arc::mojom::VideoCodecProfile::VP9PROFILE_PROFILE2: | |
| 148 case arc::mojom::VideoCodecProfile::VP9PROFILE_PROFILE3: | |
| 149 case arc::mojom::VideoCodecProfile::HEVCPROFILE_MAIN: | |
| 150 case arc::mojom::VideoCodecProfile::HEVCPROFILE_MAIN10: | |
| 151 case arc::mojom::VideoCodecProfile::HEVCPROFILE_MAIN_STILL_PICTURE: | |
| 152 case arc::mojom::VideoCodecProfile::DOLBYVISION_PROFILE0: | |
| 153 case arc::mojom::VideoCodecProfile::DOLBYVISION_PROFILE4: | |
| 154 case arc::mojom::VideoCodecProfile::DOLBYVISION_PROFILE5: | |
| 155 case arc::mojom::VideoCodecProfile::DOLBYVISION_PROFILE7: | |
| 156 *output = static_cast<media::VideoCodecProfile>(input); | |
| 157 return true; | |
| 158 } | |
| 159 DLOG(ERROR) << "unknown profile: " << input; | |
| 160 return false; | |
| 161 } | |
| 162 | |
| 163 } // namespace mojo | |
| OLD | NEW |