OLD | NEW |
(Empty) | |
| 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 CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ |
| 6 #define CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <map> |
| 11 #include <string> |
| 12 |
| 13 #include "base/callback.h" |
| 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" |
| 16 #include "media/base/browser_cdm.h" |
| 17 |
| 18 namespace chromecast { |
| 19 namespace media { |
| 20 class DecryptContext; |
| 21 |
| 22 // BrowserCdmCast is an extension of BrowserCdm that provides common |
| 23 // functionality across CDM implementations. |
| 24 // All these additional functions are synchronous so: |
| 25 // - either both the CDM and the media pipeline must be running on the same |
| 26 // thread, |
| 27 // - or BrowserCdmCast implementations must use some locks. |
| 28 // |
| 29 class BrowserCdmCast : public ::media::BrowserCdm { |
| 30 public: |
| 31 BrowserCdmCast(); |
| 32 virtual ~BrowserCdmCast() override; |
| 33 |
| 34 // PlayerTracker implementation. |
| 35 int RegisterPlayer(const base::Closure& new_key_cb, |
| 36 const base::Closure& cdm_unset_cb) override; |
| 37 void UnregisterPlayer(int registration_id) override; |
| 38 |
| 39 // Returns the decryption context needed to decrypt frames encrypted with |
| 40 // |key_id|. |
| 41 // Returns null if |key_id| is not available. |
| 42 virtual scoped_refptr<DecryptContext> GetDecryptContext( |
| 43 const std::string& key_id) const = 0; |
| 44 |
| 45 protected: |
| 46 // Notifies all listeners a new key was added on the next message loop cycle. |
| 47 void NotifyKeyAdded() const; |
| 48 |
| 49 private: |
| 50 uint32_t next_registration_id_; |
| 51 std::map<uint32_t, base::Closure> new_key_callbacks_; |
| 52 std::map<uint32_t, base::Closure> cdm_unset_callbacks_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(BrowserCdmCast); |
| 55 }; |
| 56 |
| 57 } // namespace media |
| 58 } // namespace chromecast |
| 59 |
| 60 #endif // CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ |
OLD | NEW |