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 "base/synchronization/lock.h" |
16 #include "media/base/browser_cdm.h" | 17 #include "media/base/browser_cdm.h" |
17 #include "media/cdm/json_web_key.h" | 18 #include "media/cdm/json_web_key.h" |
18 #include "media/cdm/player_tracker_impl.h" | |
19 | 19 |
20 namespace chromecast { | 20 namespace chromecast { |
21 namespace media { | 21 namespace media { |
22 class DecryptContext; | 22 class DecryptContext; |
23 | 23 |
24 // BrowserCdmCast is an extension of BrowserCdm that provides common | 24 // BrowserCdmCast is an extension of BrowserCdm that provides common |
25 // functionality across CDM implementations. | 25 // functionality across CDM implementations. |
26 // All these additional functions are synchronous so: | 26 // All these additional functions are synchronous so: |
27 // - either both the CDM and the media pipeline must be running on the same | 27 // - either both the CDM and the media pipeline must be running on the same |
28 // thread, | 28 // thread, |
(...skipping 13 matching lines...) Expand all Loading... |
42 | 42 |
43 // PlayerTracker implementation. | 43 // PlayerTracker implementation. |
44 int RegisterPlayer(const base::Closure& new_key_cb, | 44 int RegisterPlayer(const base::Closure& new_key_cb, |
45 const base::Closure& cdm_unset_cb) override; | 45 const base::Closure& cdm_unset_cb) override; |
46 void UnregisterPlayer(int registration_id) override; | 46 void UnregisterPlayer(int registration_id) override; |
47 | 47 |
48 // Returns the decryption context needed to decrypt frames encrypted with | 48 // Returns the decryption context needed to decrypt frames encrypted with |
49 // |key_id|. | 49 // |key_id|. |
50 // Returns null if |key_id| is not available. | 50 // Returns null if |key_id| is not available. |
51 virtual scoped_refptr<DecryptContext> GetDecryptContext( | 51 virtual scoped_refptr<DecryptContext> GetDecryptContext( |
52 const std::string& key_id) const = 0; | 52 const std::string& key_id) = 0; |
53 | 53 |
54 protected: | 54 protected: |
55 void OnSessionMessage(const std::string& web_session_id, | 55 void OnSessionMessage(const std::string& web_session_id, |
56 const std::vector<uint8>& message, | 56 const std::vector<uint8>& message, |
57 const GURL& destination_url); | 57 const GURL& destination_url); |
58 void OnSessionClosed(const std::string& web_session_id); | 58 void OnSessionClosed(const std::string& web_session_id); |
59 void OnSessionKeysChange(const std::string& web_session_id, | 59 void OnSessionKeysChange(const std::string& web_session_id, |
60 const ::media::KeyIdAndKeyPairs& keys); | 60 const ::media::KeyIdAndKeyPairs& keys); |
61 | 61 |
62 private: | 62 private: |
63 ::media::SessionMessageCB session_message_cb_; | 63 ::media::SessionMessageCB session_message_cb_; |
64 ::media::SessionClosedCB session_closed_cb_; | 64 ::media::SessionClosedCB session_closed_cb_; |
65 ::media::SessionErrorCB session_error_cb_; | 65 ::media::SessionErrorCB session_error_cb_; |
66 ::media::SessionKeysChangeCB session_keys_change_cb_; | 66 ::media::SessionKeysChangeCB session_keys_change_cb_; |
67 ::media::SessionExpirationUpdateCB session_expiration_update_cb_; | 67 ::media::SessionExpirationUpdateCB session_expiration_update_cb_; |
68 | 68 |
69 ::media::PlayerTrackerImpl player_tracker_; | 69 base::Lock callback_lock_; |
| 70 uint32_t next_registration_id_; |
| 71 std::map<uint32_t, base::Closure> new_key_callbacks_; |
| 72 std::map<uint32_t, base::Closure> cdm_unset_callbacks_; |
70 | 73 |
71 DISALLOW_COPY_AND_ASSIGN(BrowserCdmCast); | 74 DISALLOW_COPY_AND_ASSIGN(BrowserCdmCast); |
72 }; | 75 }; |
73 | 76 |
74 } // namespace media | 77 } // namespace media |
75 } // namespace chromecast | 78 } // namespace chromecast |
76 | 79 |
77 #endif // CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ | 80 #endif // CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ |
OLD | NEW |