1 // Copyright 2014 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.
5 #ifndef CONTENT_RENDERER_MEDIA_CRYPTO_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_
6 #define CONTENT_RENDERER_MEDIA_CRYPTO_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_
8 #include "media/base/decryptor.h"
9 #include "media/base/demuxer.h"
10 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
13 class WebContentDecryptionModule
;
14 class WebContentDecryptionModuleResult
;
16 class WebMediaPlayerClient
;
22 class EncryptedMediaPlayerSupport
{
24 // Creates a new instance of EncryptedMediaPlayerSupport for |client|. This
25 // method must always return a valid pointer.
26 static scoped_ptr
<EncryptedMediaPlayerSupport
> Create(
27 blink::WebMediaPlayerClient
* client
);
29 EncryptedMediaPlayerSupport();
30 virtual ~EncryptedMediaPlayerSupport();
32 // Prefixed API methods.
33 virtual blink::WebMediaPlayer::MediaKeyException
GenerateKeyRequest(
34 blink::WebLocalFrame
* frame
,
35 const blink::WebString
& key_system
,
36 const unsigned char* init_data
,
37 unsigned init_data_length
) = 0;
39 virtual blink::WebMediaPlayer::MediaKeyException
AddKey(
40 const blink::WebString
& key_system
,
41 const unsigned char* key
,
43 const unsigned char* init_data
,
44 unsigned init_data_length
,
45 const blink::WebString
& session_id
) = 0;
47 virtual blink::WebMediaPlayer::MediaKeyException
CancelKeyRequest(
48 const blink::WebString
& key_system
,
49 const blink::WebString
& session_id
) = 0;
52 // Unprefixed API methods.
53 virtual void SetContentDecryptionModule(
54 blink::WebContentDecryptionModule
* cdm
) = 0;
55 virtual void SetContentDecryptionModule(
56 blink::WebContentDecryptionModule
* cdm
,
57 blink::WebContentDecryptionModuleResult result
) = 0;
58 virtual void SetContentDecryptionModuleSync(
59 blink::WebContentDecryptionModule
* cdm
) = 0;
62 // Callback factory and notification methods used by WebMediaPlayerImpl.
64 // Creates a callback that Demuxers can use to signal that the content
65 // requires a key. This method make sure the callback returned can be safely
66 // invoked from any thread.
67 virtual media::Demuxer::NeedKeyCB
CreateNeedKeyCB() = 0;
69 // Creates a callback that renderers can use to set decryptor
70 // ready callback. This method make sure the callback returned can be safely
71 // invoked from any thread.
72 virtual media::SetDecryptorReadyCB
CreateSetDecryptorReadyCB() = 0;
74 // Called to inform this object that the media pipeline encountered
75 // and handled a decryption error.
76 virtual void OnPipelineDecryptError() = 0;
79 DISALLOW_COPY_AND_ASSIGN(EncryptedMediaPlayerSupport
);
82 } // namespace content
84 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_