1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
// Copyright 2014 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 MEDIA_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_
#define MEDIA_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "media/base/cdm_context.h"
#include "media/base/cdm_factory.h"
#include "media/base/demuxer.h"
#include "media/cdm/proxy_decryptor.h"
#include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
#include "third_party/WebKit/public/platform/WebMediaPlayer.h"
namespace blink {
class WebContentDecryptionModule;
class WebLocalFrame;
class WebMediaPlayerClient;
class WebString;
}
namespace media {
class MediaPermission;
class WebContentDecryptionModuleImpl;
// Provides support to prefixed EME implementation.
// Do NOT add unprefixed EME functionality to this class!
// TODO(xhwang): When deprecating prefixed EME support, drop this whole file.
class EncryptedMediaPlayerSupport
: public base::SupportsWeakPtr<EncryptedMediaPlayerSupport> {
public:
typedef base::Callback<void(CdmContext*, const CdmAttachedCB&)>
SetCdmContextCB;
EncryptedMediaPlayerSupport(scoped_ptr<CdmFactory> cdm_factory,
blink::WebMediaPlayerClient* client,
MediaPermission* media_permission,
const SetCdmContextCB& set_cdm_context_cb);
~EncryptedMediaPlayerSupport();
blink::WebMediaPlayer::MediaKeyException GenerateKeyRequest(
blink::WebLocalFrame* frame,
const blink::WebString& key_system,
const unsigned char* init_data,
unsigned init_data_length);
blink::WebMediaPlayer::MediaKeyException AddKey(
const blink::WebString& key_system,
const unsigned char* key,
unsigned key_length,
const unsigned char* init_data,
unsigned init_data_length,
const blink::WebString& session_id);
blink::WebMediaPlayer::MediaKeyException CancelKeyRequest(
const blink::WebString& key_system,
const blink::WebString& session_id);
void SetInitDataType(const std::string& init_data_type);
void OnPipelineDecryptError();
private:
blink::WebMediaPlayer::MediaKeyException GenerateKeyRequestInternal(
blink::WebLocalFrame* frame,
const std::string& key_system,
const unsigned char* init_data,
unsigned init_data_length);
blink::WebMediaPlayer::MediaKeyException AddKeyInternal(
const std::string& key_system,
const unsigned char* key,
unsigned key_length,
const unsigned char* init_data,
unsigned init_data_length,
const std::string& session_id);
blink::WebMediaPlayer::MediaKeyException CancelKeyRequestInternal(
const std::string& key_system,
const std::string& session_id);
void OnKeyAdded(const std::string& session_id);
void OnKeyError(const std::string& session_id,
MediaKeys::KeyError error_code,
uint32 system_code);
void OnKeyMessage(const std::string& session_id,
const std::vector<uint8>& message,
const GURL& destination_url);
scoped_ptr<CdmFactory> cdm_factory_;
blink::WebMediaPlayerClient* client_;
MediaPermission* media_permission_;
// The currently selected key system. Empty string means that no key system
// has been selected.
std::string current_key_system_;
// We assume all streams are from the same container, thus have the same
// init data type.
std::string init_data_type_;
SetCdmContextCB set_cdm_context_cb_;
// Manages decryption keys and decrypts encrypted frames.
scoped_ptr<ProxyDecryptor> proxy_decryptor_;
DISALLOW_COPY_AND_ASSIGN(EncryptedMediaPlayerSupport);
};
} // namespace media
#endif // MEDIA_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_
|