1// Copyright 2013 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#ifndef CONTENT_RENDERER_MEDIA_CRYPTO_KEY_SYSTEMS_H_
6#define CONTENT_RENDERER_MEDIA_CRYPTO_KEY_SYSTEMS_H_
7
8#include <string>
9#include <vector>
10
11#include "base/memory/scoped_ptr.h"
12#include "content/common/content_export.h"
13
14namespace content {
15
16// Prefixed EME API only supports prefixed (webkit-) key system name for
17// certain key systems. But internally only unprefixed key systems are
18// supported. The following two functions help convert between prefixed and
19// unprefixed key system names.
20
21// Gets the unprefixed key system name for |key_system|.
22std::string GetUnprefixedKeySystemName(const std::string& key_system);
23
24// Gets the prefixed key system name for |key_system|.
25std::string GetPrefixedKeySystemName(const std::string& key_system);
26
27// Returns whether |key_system| is a real supported key system that can be
28// instantiated.
29// Abstract parent |key_system| strings will return false.
30// Call IsSupportedKeySystemWithMediaMimeType() to determine whether a
31// |key_system| supports a specific type of media or to check parent key
32// systems.
33CONTENT_EXPORT bool IsConcreteSupportedKeySystem(const std::string& key_system);
34
35// Returns whether |key_sytem| supports the specified media type and codec(s).
36CONTENT_EXPORT bool IsSupportedKeySystemWithMediaMimeType(
37    const std::string& mime_type,
38    const std::vector<std::string>& codecs,
39    const std::string& key_system);
40
41// Returns a name for |key_system| suitable to UMA logging.
42CONTENT_EXPORT std::string KeySystemNameForUMA(const std::string& key_system);
43
44// Returns whether AesDecryptor can be used for the given |concrete_key_system|.
45CONTENT_EXPORT bool CanUseAesDecryptor(const std::string& concrete_key_system);
46
47#if defined(ENABLE_PEPPER_CDMS)
48// Returns the Pepper MIME type for |concrete_key_system|.
49// Returns empty string if |concrete_key_system| is unknown or not Pepper-based.
50CONTENT_EXPORT std::string GetPepperType(
51    const std::string& concrete_key_system);
52#endif
53
54#if defined(UNIT_TEST)
55// Helper functions to add container/codec types for testing purposes.
56CONTENT_EXPORT void AddContainerMask(const std::string& container, uint32 mask);
57CONTENT_EXPORT void AddCodecMask(const std::string& codec, uint32 mask);
58#endif  // defined(UNIT_TEST)
59
60}  // namespace content
61
62#endif  // CONTENT_RENDERER_MEDIA_CRYPTO_KEY_SYSTEMS_H_
63