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

Side by Side Diff: chromecast/media/cma/base/decoder_config_adapter.cc

Issue 2156193003: [Chromecast] Add a custom CastMediaClient for Chromecast (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@codecs
Patch Set: Mark MediaCapShlib::IsSupportedVideoConfig as weak symbol Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chromecast/media/cma/base/decoder_config_adapter.h" 5 #include "chromecast/media/cma/base/decoder_config_adapter.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chromecast/media/base/media_codec_support.h"
8 #include "media/base/channel_layout.h" 9 #include "media/base/channel_layout.h"
9 10
10 namespace chromecast { 11 namespace chromecast {
11 namespace media { 12 namespace media {
12 13
13 namespace { 14 namespace {
14 15
15 // Converts ::media::AudioCodec to chromecast::media::AudioCodec. Any unknown or 16 // Converts ::media::AudioCodec to chromecast::media::AudioCodec. Any unknown or
16 // unsupported codec will be converted to chromecast::media::kCodecUnknown. 17 // unsupported codec will be converted to chromecast::media::kCodecUnknown.
17 AudioCodec ToAudioCodec(const ::media::AudioCodec audio_codec) { 18 AudioCodec ToAudioCodec(const ::media::AudioCodec audio_codec) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return kSampleFormatPlanarS16; 59 return kSampleFormatPlanarS16;
59 case ::media::kSampleFormatPlanarF32: 60 case ::media::kSampleFormatPlanarF32:
60 return kSampleFormatPlanarF32; 61 return kSampleFormatPlanarF32;
61 case ::media::kSampleFormatPlanarS32: 62 case ::media::kSampleFormatPlanarS32:
62 return kSampleFormatPlanarS32; 63 return kSampleFormatPlanarS32;
63 } 64 }
64 NOTREACHED(); 65 NOTREACHED();
65 return kUnknownSampleFormat; 66 return kUnknownSampleFormat;
66 } 67 }
67 68
68 // Converts ::media::VideoCodec to chromecast::media::VideoCodec. Any unknown or
69 // unsupported codec will be converted to chromecast::media::kCodecUnknown.
70 VideoCodec ToVideoCodec(const ::media::VideoCodec video_codec) {
71 switch (video_codec) {
72 case ::media::kCodecH264:
73 return kCodecH264;
74 case ::media::kCodecVP8:
75 return kCodecVP8;
76 case ::media::kCodecVP9:
77 return kCodecVP9;
78 case ::media::kCodecHEVC:
79 return kCodecHEVC;
80 default:
81 LOG(ERROR) << "Unsupported video codec " << video_codec;
82 }
83 return kVideoCodecUnknown;
84 }
85
86 // Converts ::media::VideoCodecProfile to chromecast::media::VideoProfile.
87 VideoProfile ToVideoProfile(const ::media::VideoCodecProfile codec_profile) {
88 switch (codec_profile) {
89 case ::media::H264PROFILE_BASELINE:
90 return kH264Baseline;
91 case ::media::H264PROFILE_MAIN:
92 return kH264Main;
93 case ::media::H264PROFILE_EXTENDED:
94 return kH264Extended;
95 case ::media::H264PROFILE_HIGH:
96 return kH264High;
97 case ::media::H264PROFILE_HIGH10PROFILE:
98 return kH264High10;
99 case ::media::H264PROFILE_HIGH422PROFILE:
100 return kH264High422;
101 case ::media::H264PROFILE_HIGH444PREDICTIVEPROFILE:
102 return kH264High444Predictive;
103 case ::media::H264PROFILE_SCALABLEBASELINE:
104 return kH264ScalableBaseline;
105 case ::media::H264PROFILE_SCALABLEHIGH:
106 return kH264ScalableHigh;
107 case ::media::H264PROFILE_STEREOHIGH:
108 return kH264Stereohigh;
109 case ::media::H264PROFILE_MULTIVIEWHIGH:
110 return kH264MultiviewHigh;
111 case ::media::VP8PROFILE_ANY:
112 return kVP8ProfileAny;
113 case ::media::VP9PROFILE_PROFILE0:
114 return kVP9Profile0;
115 case ::media::VP9PROFILE_PROFILE1:
116 return kVP9Profile1;
117 case ::media::VP9PROFILE_PROFILE2:
118 return kVP9Profile2;
119 case ::media::VP9PROFILE_PROFILE3:
120 return kVP9Profile3;
121 default:
122 LOG(INFO) << "Unsupported video codec profile " << codec_profile;
123 }
124 return kVideoProfileUnknown;
125 }
126
127 ::media::ChannelLayout ToMediaChannelLayout(int channel_number) { 69 ::media::ChannelLayout ToMediaChannelLayout(int channel_number) {
128 switch (channel_number) { 70 switch (channel_number) {
129 case 1: 71 case 1:
130 return ::media::ChannelLayout::CHANNEL_LAYOUT_MONO; 72 return ::media::ChannelLayout::CHANNEL_LAYOUT_MONO;
131 case 2: 73 case 2:
132 return ::media::ChannelLayout::CHANNEL_LAYOUT_STEREO; 74 return ::media::ChannelLayout::CHANNEL_LAYOUT_STEREO;
133 default: 75 default:
134 return ::media::ChannelLayout::CHANNEL_LAYOUT_UNSUPPORTED; 76 return ::media::ChannelLayout::CHANNEL_LAYOUT_UNSUPPORTED;
135 } 77 }
136 } 78 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 // static 224 // static
283 VideoConfig DecoderConfigAdapter::ToCastVideoConfig( 225 VideoConfig DecoderConfigAdapter::ToCastVideoConfig(
284 StreamId id, 226 StreamId id,
285 const ::media::VideoDecoderConfig& config) { 227 const ::media::VideoDecoderConfig& config) {
286 VideoConfig video_config; 228 VideoConfig video_config;
287 if (!config.IsValidConfig()) { 229 if (!config.IsValidConfig()) {
288 return video_config; 230 return video_config;
289 } 231 }
290 232
291 video_config.id = id; 233 video_config.id = id;
292 video_config.codec = ToVideoCodec(config.codec()); 234 video_config.codec = ToCastVideoCodec(config.codec());
293 video_config.profile = ToVideoProfile(config.profile()); 235 video_config.profile = ToCastVideoProfile(config.profile());
294 video_config.extra_data = config.extra_data(); 236 video_config.extra_data = config.extra_data();
295 video_config.encryption_scheme = ToEncryptionScheme( 237 video_config.encryption_scheme = ToEncryptionScheme(
296 config.encryption_scheme()); 238 config.encryption_scheme());
297 return video_config; 239 return video_config;
298 } 240 }
299 241
300 } // namespace media 242 } // namespace media
301 } // namespace chromecast 243 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698