| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 CHROMECAST_MEDIA_CDM_CAST_CDM_PROXY_H_ | |
| 6 #define CHROMECAST_MEDIA_CDM_CAST_CDM_PROXY_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/threading/thread_checker.h" | |
| 11 #include "chromecast/media/cdm/cast_cdm.h" | |
| 12 | |
| 13 namespace base { | |
| 14 class SingleThreadTaskRunner; | |
| 15 } | |
| 16 | |
| 17 namespace chromecast { | |
| 18 namespace media { | |
| 19 | |
| 20 // MediaKeys implementation that lives on the UI thread and forwards all calls | |
| 21 // to a CastCdm instance on the CMA thread. This is used to simplify the | |
| 22 // UI-CMA threading interaction. | |
| 23 // TODO(slan): Remove this class when CMA is deprecated. | |
| 24 class CastCdmProxy : public ::media::MediaKeys { | |
| 25 public: | |
| 26 CastCdmProxy(const scoped_refptr<CastCdm>& cast_cdm, | |
| 27 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | |
| 28 | |
| 29 // Returns the CDM instance which lives on the CMA thread. | |
| 30 CastCdm* cast_cdm() const; | |
| 31 | |
| 32 private: | |
| 33 ~CastCdmProxy() override; | |
| 34 | |
| 35 // ::media::MediaKeys implementation: | |
| 36 void SetServerCertificate( | |
| 37 const std::vector<uint8_t>& certificate, | |
| 38 std::unique_ptr<::media::SimpleCdmPromise> promise) override; | |
| 39 void CreateSessionAndGenerateRequest( | |
| 40 ::media::MediaKeys::SessionType session_type, | |
| 41 ::media::EmeInitDataType init_data_type, | |
| 42 const std::vector<uint8_t>& init_data, | |
| 43 std::unique_ptr<::media::NewSessionCdmPromise> promise) override; | |
| 44 void LoadSession( | |
| 45 ::media::MediaKeys::SessionType session_type, | |
| 46 const std::string& session_id, | |
| 47 std::unique_ptr<::media::NewSessionCdmPromise> promise) override; | |
| 48 void UpdateSession( | |
| 49 const std::string& session_id, | |
| 50 const std::vector<uint8_t>& response, | |
| 51 std::unique_ptr<::media::SimpleCdmPromise> promise) override; | |
| 52 void CloseSession( | |
| 53 const std::string& session_id, | |
| 54 std::unique_ptr<::media::SimpleCdmPromise> promise) override; | |
| 55 void RemoveSession( | |
| 56 const std::string& session_id, | |
| 57 std::unique_ptr<::media::SimpleCdmPromise> promise) override; | |
| 58 ::media::CdmContext* GetCdmContext() override; | |
| 59 | |
| 60 scoped_refptr<CastCdm> cast_cdm_; | |
| 61 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
| 62 | |
| 63 base::ThreadChecker thread_checker_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(CastCdmProxy); | |
| 66 }; | |
| 67 | |
| 68 } // namespace media | |
| 69 } // namespace chromecast | |
| 70 | |
| 71 #endif // CHROMECAST_MEDIA_CDM_CAST_CDM_PROXY_H_ | |
| OLD | NEW |