summaryrefslogtreecommitdiffstats
path: root/webkit/media/crypto/ppapi_decryptor.h
blob: 841bb30b44821d37bf4d647c5999d109985a27e8 (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
// Copyright (c) 2012 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 WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_
#define WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_

#include <string>

#include "base/memory/ref_counted.h"
#include "media/base/decryptor.h"

namespace base {
class MessageLoopProxy;
}

namespace media {
class DecryptorClient;
}

namespace webkit {
namespace ppapi {
class PluginInstance;
}
}

namespace webkit_media {

// PpapiDecrypor implements media::Decryptor and forwards all calls to the
// PluginInstance.
// This class should always be created on the main renderer thread.
class PpapiDecryptor : public media::Decryptor {
 public:
  PpapiDecryptor(
    media::DecryptorClient* client,
    const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance);
  virtual ~PpapiDecryptor();

  // media::Decryptor implementation.
  virtual void GenerateKeyRequest(const std::string& key_system,
                                  const uint8* init_data,
                                  int init_data_length) OVERRIDE;
  virtual void AddKey(const std::string& key_system,
                      const uint8* key,
                      int key_length,
                      const uint8* init_data,
                      int init_data_length,
                      const std::string& session_id) OVERRIDE;
  virtual void CancelKeyRequest(const std::string& key_system,
                                const std::string& session_id) OVERRIDE;
  virtual void Decrypt(const scoped_refptr<media::DecoderBuffer>& encrypted,
                       const DecryptCB& decrypt_cb) OVERRIDE;
  virtual void Stop() OVERRIDE;

 private:
  void ReportFailureToCallPlugin(const std::string& key_system,
                                 const std::string& session_id);

  media::DecryptorClient* client_;
  scoped_refptr<webkit::ppapi::PluginInstance> cdm_plugin_;
  scoped_refptr<base::MessageLoopProxy> render_loop_proxy_;

  DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor);
};

}  // namespace webkit_media

#endif  // WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_