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