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. 4 5 #ifndef MEDIA_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_ 6 #define MEDIA_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_ 7 8 #include "media/base/decryptor.h" 9 #include "media/base/demuxer.h" 10 #include "media/base/media_export.h" 11 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" 12 13 namespace blink { 14 class WebContentDecryptionModule; 15 class WebContentDecryptionModuleResult; 16 class WebLocalFrame; 17 class WebMediaPlayerClient; 18 class WebString; 19 } 20 21 namespace media { 22 23 class MEDIA_EXPORT EncryptedMediaPlayerSupport { 24 public: 25 EncryptedMediaPlayerSupport(); 26 virtual ~EncryptedMediaPlayerSupport(); 27 28 // Prefixed API methods. 29 virtual blink::WebMediaPlayer::MediaKeyException GenerateKeyRequest( 30 blink::WebLocalFrame* frame, 31 const blink::WebString& key_system, 32 const unsigned char* init_data, 33 unsigned init_data_length) = 0; 34 35 virtual blink::WebMediaPlayer::MediaKeyException AddKey( 36 const blink::WebString& key_system, 37 const unsigned char* key, 38 unsigned key_length, 39 const unsigned char* init_data, 40 unsigned init_data_length, 41 const blink::WebString& session_id) = 0; 42 43 virtual blink::WebMediaPlayer::MediaKeyException CancelKeyRequest( 44 const blink::WebString& key_system, 45 const blink::WebString& session_id) = 0; 46 47 48 // Unprefixed API methods. 49 virtual void SetInitialContentDecryptionModule( 50 blink::WebContentDecryptionModule* initial_cdm) = 0; 51 virtual void SetContentDecryptionModule( 52 blink::WebContentDecryptionModule* cdm) = 0; 53 virtual void SetContentDecryptionModule( 54 blink::WebContentDecryptionModule* cdm, 55 blink::WebContentDecryptionModuleResult result) = 0; 56 57 58 // Callback factory and notification methods used by WebMediaPlayerImpl. 59 60 // Creates a callback that Demuxers can use to signal that the content 61 // requires a key. This method make sure the callback returned can be safely 62 // invoked from any thread. 63 virtual Demuxer::NeedKeyCB CreateNeedKeyCB() = 0; 64 65 // Creates a callback that renderers can use to set decryptor 66 // ready callback. This method make sure the callback returned can be safely 67 // invoked from any thread. 68 virtual SetDecryptorReadyCB CreateSetDecryptorReadyCB() = 0; 69 70 // Called to inform this object that the media pipeline encountered 71 // and handled a decryption error. 72 virtual void OnPipelineDecryptError() = 0; 73 74 private: 75 DISALLOW_COPY_AND_ASSIGN(EncryptedMediaPlayerSupport); 76 }; 77 78 } // namespace media 79 80 #endif // MEDIA_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_ 81