diff options
author | gunsch <gunsch@chromium.org> | 2015-04-20 18:01:16 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-21 01:02:12 +0000 |
commit | 6b56c57d9229a4ee713f0487c70c6798cb0d37f0 (patch) | |
tree | a25ba74aa316c9de76604e47c36afdd0fd9ba631 /chromecast | |
parent | f5d7ecd32a30e6d7a6d5656b11c905ed687b2181 (diff) | |
download | chromium_src-6b56c57d9229a4ee713f0487c70c6798cb0d37f0.zip chromium_src-6b56c57d9229a4ee713f0487c70c6798cb0d37f0.tar.gz chromium_src-6b56c57d9229a4ee713f0487c70c6798cb0d37f0.tar.bz2 |
Chromecast: temporary shim files for internal media codec callbacks.
R=servolk@chromium.org,lcwu@chromium.org
BUG=None
Review URL: https://codereview.chromium.org/1097833002
Cr-Commit-Position: refs/heads/master@{#325959}
Diffstat (limited to 'chromecast')
-rw-r--r-- | chromecast/media/base/media_codec_support.cc | 16 | ||||
-rw-r--r-- | chromecast/media/base/media_codec_support.h | 34 | ||||
-rw-r--r-- | chromecast/media/base/media_codec_support_simple.cc | 97 | ||||
-rw-r--r-- | chromecast/media/media.gyp | 2 |
4 files changed, 53 insertions, 96 deletions
diff --git a/chromecast/media/base/media_codec_support.cc b/chromecast/media/base/media_codec_support.cc new file mode 100644 index 0000000..b04a077 --- /dev/null +++ b/chromecast/media/base/media_codec_support.cc @@ -0,0 +1,16 @@ +// Copyright 2015 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. + +#include "chromecast/media/base/media_codec_support.h" + +// TODO(gunsch/servolk): delete this file once a solution exists upstream. + +namespace net { + +bool DefaultIsCodecSupported(const std::string&) { + return true; +} + +} // namespace net + diff --git a/chromecast/media/base/media_codec_support.h b/chromecast/media/base/media_codec_support.h new file mode 100644 index 0000000..e961177 --- /dev/null +++ b/chromecast/media/base/media_codec_support.h @@ -0,0 +1,34 @@ +// Copyright 2015 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 CHROMECAST_MEDIA_BASE_MEDIA_CODEC_SUPPORT_H_ +#define CHROMECAST_MEDIA_BASE_MEDIA_CODEC_SUPPORT_H_ + +#include <string> + +#include "base/callback.h" +#include "net/base/mime_util.h" + +// TODO(gunsch/servolk): remove when this definition exists upstream. + +namespace net { +typedef base::Callback<bool(const std::string&)> IsCodecSupportedCB; +bool DefaultIsCodecSupported(const std::string&); +} + +namespace chromecast { +namespace media { + +// This function should return a callback capable of deciding whether a given +// codec (passed in as a string representation of the codec id conforming to +// RFC 6381) is supported or not. The implementation of this function is +// expected to be provided somewhere in the vendor platform-specific libraries +// that will get linked with cast_shell_common target. +net::IsCodecSupportedCB GetIsCodecSupportedOnChromecastCB(); + +} // namespace media +} // namespace chromecast + +#endif // CHROMECAST_MEDIA_BASE_MEDIA_CODEC_SUPPORT_H_ + diff --git a/chromecast/media/base/media_codec_support_simple.cc b/chromecast/media/base/media_codec_support_simple.cc index 634babd..efdda17 100644 --- a/chromecast/media/base/media_codec_support_simple.cc +++ b/chromecast/media/base/media_codec_support_simple.cc @@ -2,102 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <string> - -#include "base/bind.h" -#include "base/callback.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_util.h" - -// TODO(servolk): Temp definitions to fix Chromecast build until media mime -// type refactoring checks are properly upstreamed. -namespace net { - -typedef base::Callback<bool(const std::string&)> IsCodecSupportedCB; - -static bool IsValidH264BaselineProfile(const std::string& profile_str) { - uint32 constraint_set_bits; - if (profile_str.size() != 4 || - profile_str[0] != '4' || - profile_str[1] != '2' || - profile_str[3] != '0' || - !base::HexStringToUInt(base::StringPiece(profile_str.c_str() + 2, 1), - &constraint_set_bits)) { - return false; - } - - return constraint_set_bits >= 8; -} - -static bool IsValidH264Level(const std::string& level_str) { - uint32 level; - if (level_str.size() != 2 || !base::HexStringToUInt(level_str, &level)) - return false; - - // Valid levels taken from Table A-1 in ISO-14496-10. - // Essentially |level_str| is toHex(10 * level). - return ((level >= 10 && level <= 13) || - (level >= 20 && level <= 22) || - (level >= 30 && level <= 32) || - (level >= 40 && level <= 42) || - (level >= 50 && level <= 51)); -} - -static bool ParseH264CodecID(const std::string& codec_id, - bool* is_ambiguous) { - // Make sure we have avc1.xxxxxx or avc3.xxxxxx - if (codec_id.size() != 11 || - (!StartsWithASCII(codec_id, "avc1.", true) && - !StartsWithASCII(codec_id, "avc3.", true))) { - return false; - } - - std::string profile = StringToUpperASCII(codec_id.substr(5, 4)); - if (IsValidH264BaselineProfile(profile) || - profile == "4D40" || profile == "6400") { - *is_ambiguous = !IsValidH264Level(StringToUpperASCII(codec_id.substr(9))); - } else { - *is_ambiguous = true; - } - - return true; -} - -bool DefaultIsCodecSupported(const std::string& codec) { - if (codec == "1" /*PCM*/ || codec == "vorbis" || codec == "opus" || - codec == "theora" || codec == "vp8" || codec == "vp8.0" || - codec == "vp9" || codec == "vp9.0") - return true; - - if (codec == "mp3" || codec == "mp4a.66" || codec == "mp4a.67" || - codec == "mp4a.68" || codec == "mp4a.69" || codec == "mp4a.6B" || - codec == "mp4a.40.2" || codec == "mp4a.40.02" || codec == "mp4a.40.29" || - codec == "mp4a.40.5" || codec == "mp4a.40.05" || codec == "mp4a.40") - return true; - -#if defined(ENABLE_MPEG2TS_STREAM_PARSER) - // iOS 3.0 to 3.1.2 used non-standard codec ids for H.264 Baseline and Main - // profiles in HTTP Live Streaming (HLS). Apple recommends using these - // non-standard strings for compatibility with older iOS devices, and so many - // HLS apps still use these. See - // https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/FrequentlyAskedQuestions/FrequentlyAskedQuestions.html - // mp4a.40.34 is also Apple-specific name for MP3 in mpeg2ts container for HLS - if (codec == "avc1.66.30" || codec == "avc1.77.30" || codec == "mp4a.40.34") - return true; -#endif - - - bool is_ambiguous = true; - if (codec == "avc1" || codec == "avc3" || - ParseH264CodecID(codec, &is_ambiguous)) { - return true; - } - - // Unknown codec id - return false; -} - -} +#include "chromecast/media/base/media_codec_support.h" namespace chromecast { namespace media { diff --git a/chromecast/media/media.gyp b/chromecast/media/media.gyp index 68d2423..8b98ec9 100644 --- a/chromecast/media/media.gyp +++ b/chromecast/media/media.gyp @@ -25,6 +25,8 @@ 'base/key_systems_common.h', 'base/media_caps.cc', 'base/media_caps.h', + 'base/media_codec_support.cc', + 'base/media_codec_support.h', 'base/switching_media_renderer.cc', 'base/switching_media_renderer.h', ], |