summaryrefslogtreecommitdiff
path: root/chromium/media/cdm/library_cdm/cdm_host_proxy_impl.h
blob: cb813946e91a2b2a8cf20b9f6c5f691ca83b21e3 (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
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
122
123
124
125
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_CDM_LIBRARY_CDM_CDM_HOST_PROXY_IMPL_H_
#define MEDIA_CDM_LIBRARY_CDM_CDM_HOST_PROXY_IMPL_H_

#include "base/memory/raw_ptr.h"
#include "media/cdm/library_cdm/cdm_host_proxy.h"

namespace media {

// A templated implementation of CdmHostProxy to forward Host calls to the
// correct CDM Host.
template <typename HostInterface>
class CdmHostProxyImpl : public CdmHostProxy {
 public:
  explicit CdmHostProxyImpl(HostInterface* host) : host_(host) {}

  CdmHostProxyImpl(const CdmHostProxyImpl&) = delete;
  CdmHostProxyImpl& operator=(const CdmHostProxyImpl&) = delete;

  ~CdmHostProxyImpl() override {}

  void OnInitialized(bool success) final {
    return host_->OnInitialized(success);
  }

  cdm::Buffer* Allocate(uint32_t capacity) final {
    return host_->Allocate(capacity);
  }

  void SetTimer(int64_t delay_ms, void* context) final {
    host_->SetTimer(delay_ms, context);
  }

  cdm::Time GetCurrentWallTime() final { return host_->GetCurrentWallTime(); }

  void OnResolveKeyStatusPromise(uint32_t promise_id,
                                 cdm::KeyStatus key_status) final {
    host_->OnResolveKeyStatusPromise(promise_id, key_status);
  }

  void OnResolveNewSessionPromise(uint32_t promise_id,
                                  const char* session_id,
                                  uint32_t session_id_size) final {
    host_->OnResolveNewSessionPromise(promise_id, session_id, session_id_size);
  }

  void OnResolvePromise(uint32_t promise_id) final {
    host_->OnResolvePromise(promise_id);
  }

  void OnRejectPromise(uint32_t promise_id,
                       cdm::Exception exception,
                       uint32_t system_code,
                       const char* error_message,
                       uint32_t error_message_size) final {
    host_->OnRejectPromise(promise_id, exception, system_code, error_message,
                           error_message_size);
  }

  void OnSessionMessage(const char* session_id,
                        uint32_t session_id_size,
                        cdm::MessageType message_type,
                        const char* message,
                        uint32_t message_size) final {
    host_->OnSessionMessage(session_id, session_id_size, message_type, message,
                            message_size);
  }

  void OnSessionKeysChange(const char* session_id,
                           uint32_t session_id_size,
                           bool has_additional_usable_key,
                           const cdm::KeyInformation* keys_info,
                           uint32_t keys_info_count) final {
    host_->OnSessionKeysChange(session_id, session_id_size,
                               has_additional_usable_key, keys_info,
                               keys_info_count);
  }

  void OnExpirationChange(const char* session_id,
                          uint32_t session_id_size,
                          cdm::Time new_expiry_time) final {
    host_->OnExpirationChange(session_id, session_id_size, new_expiry_time);
  }

  void OnSessionClosed(const char* session_id, uint32_t session_id_size) final {
    host_->OnSessionClosed(session_id, session_id_size);
  }

  void SendPlatformChallenge(const char* service_id,
                             uint32_t service_id_size,
                             const char* challenge,
                             uint32_t challenge_size) final {
    host_->SendPlatformChallenge(service_id, service_id_size, challenge,
                                 challenge_size);
  }

  void EnableOutputProtection(uint32_t desired_protection_mask) final {
    host_->EnableOutputProtection(desired_protection_mask);
  }

  void QueryOutputProtectionStatus() final {
    host_->QueryOutputProtectionStatus();
  }

  void OnDeferredInitializationDone(cdm::StreamType stream_type,
                                    cdm::Status decoder_status) final {}

  cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) final {
    return host_->CreateFileIO(client);
  }

  void RequestStorageId(uint32_t version) final {
    host_->RequestStorageId(version);
  }

 private:
  const raw_ptr<HostInterface> host_ = nullptr;
};

}  // namespace media

#endif  // MEDIA_CDM_LIBRARY_CDM_CDM_HOST_PROXY_IMPL_H_