summaryrefslogtreecommitdiffstats
path: root/media/blink/encrypted_media_player_support.h
blob: b3876866c7d1508c0e5037532625d19e1fc5503f (plain)
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
// 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 "media/base/decryptor.h"
#include "media/base/demuxer.h"
#include "media/base/media_export.h"
#include "third_party/WebKit/public/platform/WebMediaPlayer.h"

namespace blink {
class WebContentDecryptionModule;
class WebContentDecryptionModuleResult;
class WebLocalFrame;
class WebMediaPlayerClient;
class WebString;
}

namespace media {

class MEDIA_EXPORT EncryptedMediaPlayerSupport {
 public:
  EncryptedMediaPlayerSupport();
  virtual ~EncryptedMediaPlayerSupport();

  // Prefixed API methods.
  virtual blink::WebMediaPlayer::MediaKeyException GenerateKeyRequest(
      blink::WebLocalFrame* frame,
      const blink::WebString& key_system,
      const unsigned char* init_data,
      unsigned init_data_length) = 0;

  virtual 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) = 0;

  virtual blink::WebMediaPlayer::MediaKeyException CancelKeyRequest(
      const blink::WebString& key_system,
      const blink::WebString& session_id) = 0;


  // Unprefixed API methods.
  virtual void SetContentDecryptionModule(
      blink::WebContentDecryptionModule* cdm) = 0;
  virtual void SetContentDecryptionModule(
      blink::WebContentDecryptionModule* cdm,
      blink::WebContentDecryptionModuleResult result) = 0;
  virtual void SetContentDecryptionModuleSync(
      blink::WebContentDecryptionModule* cdm) = 0;


  // Callback factory and notification methods used by WebMediaPlayerImpl.

  // Creates a callback that Demuxers can use to signal that the content
  // requires a key. This method make sure the callback returned can be safely
  // invoked from any thread.
  virtual Demuxer::NeedKeyCB CreateNeedKeyCB() = 0;

  // Creates a callback that renderers can use to set decryptor
  // ready callback. This method make sure the callback returned can be safely
  // invoked from any thread.
  virtual SetDecryptorReadyCB CreateSetDecryptorReadyCB() = 0;

  // Called to inform this object that the media pipeline encountered
  // and handled a decryption error.
  virtual void OnPipelineDecryptError() = 0;

 private:
  DISALLOW_COPY_AND_ASSIGN(EncryptedMediaPlayerSupport);
};

}  // namespace media

#endif  // MEDIA_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_