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/json_web_key.h" | |
17 #include "media/cdm/player_tracker_impl.h" | 18 #include "media/cdm/player_tracker_impl.h" |
18 | 19 |
19 namespace chromecast { | 20 namespace chromecast { |
20 namespace media { | 21 namespace media { |
21 class DecryptContext; | 22 class DecryptContext; |
22 | 23 |
23 // BrowserCdmCast is an extension of BrowserCdm that provides common | 24 // BrowserCdmCast is an extension of BrowserCdm that provides common |
24 // functionality across CDM implementations. | 25 // functionality across CDM implementations. |
25 // All these additional functions are synchronous so: | 26 // All these additional functions are synchronous so: |
26 // - 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 |
27 // thread, | 28 // thread, |
28 // - or BrowserCdmCast implementations must use some locks. | 29 // - or BrowserCdmCast implementations must use some locks. |
29 // | 30 // |
30 class BrowserCdmCast : public ::media::BrowserCdm { | 31 class BrowserCdmCast : public ::media::BrowserCdm { |
31 public: | 32 public: |
32 BrowserCdmCast(); | 33 BrowserCdmCast(); |
33 ~BrowserCdmCast() override; | 34 ~BrowserCdmCast() override; |
34 | 35 |
36 void SetCallbacks( | |
37 const ::media::SessionMessageCB& session_message_cb, | |
38 const ::media::SessionClosedCB& session_closed_cb, | |
39 const ::media::SessionErrorCB& session_error_cb, | |
40 const ::media::SessionKeysChangeCB& session_keys_change_cb, | |
41 const ::media::SessionExpirationUpdateCB& session_expiration_update_cb); | |
lcwu1
2015/02/02 19:56:49
Do you plan to hook up the new MediaKeys APIs in a
gunsch
2015/02/02 20:00:25
discussed offline, not necessary since:
a) we don'
| |
42 | |
35 // PlayerTracker implementation. | 43 // PlayerTracker implementation. |
36 int RegisterPlayer(const base::Closure& new_key_cb, | 44 int RegisterPlayer(const base::Closure& new_key_cb, |
37 const base::Closure& cdm_unset_cb) override; | 45 const base::Closure& cdm_unset_cb) override; |
38 void UnregisterPlayer(int registration_id) override; | 46 void UnregisterPlayer(int registration_id) override; |
39 | 47 |
40 // Returns the decryption context needed to decrypt frames encrypted with | 48 // Returns the decryption context needed to decrypt frames encrypted with |
41 // |key_id|. | 49 // |key_id|. |
42 // Returns null if |key_id| is not available. | 50 // Returns null if |key_id| is not available. |
43 virtual scoped_refptr<DecryptContext> GetDecryptContext( | 51 virtual scoped_refptr<DecryptContext> GetDecryptContext( |
44 const std::string& key_id) const = 0; | 52 const std::string& key_id) const = 0; |
45 | 53 |
46 protected: | 54 protected: |
47 // Notifies all listeners a new key was added. | 55 void OnSessionMessage(const std::string& web_session_id, |
48 void NotifyKeyAdded(); | 56 const std::vector<uint8>& message, |
57 const GURL& destination_url); | |
58 void OnSessionClosed(const std::string& web_session_id); | |
59 void OnSessionKeysChange(const std::string& web_session_id, | |
60 const ::media::KeyIdAndKeyPairs& keys); | |
49 | 61 |
50 private: | 62 private: |
63 ::media::SessionMessageCB session_message_cb_; | |
64 ::media::SessionClosedCB session_closed_cb_; | |
65 ::media::SessionErrorCB session_error_cb_; | |
66 ::media::SessionKeysChangeCB session_keys_change_cb_; | |
67 ::media::SessionExpirationUpdateCB session_expiration_update_cb_; | |
68 | |
51 ::media::PlayerTrackerImpl player_tracker_; | 69 ::media::PlayerTrackerImpl player_tracker_; |
52 | 70 |
53 DISALLOW_COPY_AND_ASSIGN(BrowserCdmCast); | 71 DISALLOW_COPY_AND_ASSIGN(BrowserCdmCast); |
54 }; | 72 }; |
55 | 73 |
56 } // namespace media | 74 } // namespace media |
57 } // namespace chromecast | 75 } // namespace chromecast |
58 | 76 |
59 #endif // CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ | 77 #endif // CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ |
OLD | NEW |