OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/renderer/media/android/proxy_media_keys.h" | 5 #include "content/renderer/media/android/proxy_media_keys.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 media_keys_id_(media_keys_id), | 25 media_keys_id_(media_keys_id), |
26 session_created_cb_(session_created_cb), | 26 session_created_cb_(session_created_cb), |
27 session_message_cb_(session_message_cb), | 27 session_message_cb_(session_message_cb), |
28 session_ready_cb_(session_ready_cb), | 28 session_ready_cb_(session_ready_cb), |
29 session_closed_cb_(session_closed_cb), | 29 session_closed_cb_(session_closed_cb), |
30 session_error_cb_(session_error_cb) { | 30 session_error_cb_(session_error_cb) { |
31 DCHECK(manager_); | 31 DCHECK(manager_); |
32 } | 32 } |
33 | 33 |
34 ProxyMediaKeys::~ProxyMediaKeys() { | 34 ProxyMediaKeys::~ProxyMediaKeys() { |
35 for (base::hash_set<uint32>::iterator i = requested_session_id_.begin(); | |
36 i != requested_session_id_.end(); ++i) { | |
37 manager_->CancelSession(media_keys_id_, *i); | |
38 } | |
35 } | 39 } |
36 | 40 |
37 void ProxyMediaKeys::InitializeCDM(const std::string& key_system, | 41 void ProxyMediaKeys::InitializeCDM(const std::string& key_system, |
38 const GURL& frame_url) { | 42 const GURL& frame_url) { |
39 #if defined(ENABLE_PEPPER_CDMS) | 43 #if defined(ENABLE_PEPPER_CDMS) |
40 NOTIMPLEMENTED(); | 44 NOTIMPLEMENTED(); |
41 #elif defined(OS_ANDROID) | 45 #elif defined(OS_ANDROID) |
42 std::vector<uint8> uuid = GetUUID(key_system); | 46 std::vector<uint8> uuid = GetUUID(key_system); |
43 DCHECK(!uuid.empty()); | 47 DCHECK(!uuid.empty()); |
44 manager_->InitializeCDM(media_keys_id_, this, uuid, frame_url); | 48 manager_->InitializeCDM(media_keys_id_, this, uuid, frame_url); |
45 #endif | 49 #endif |
46 } | 50 } |
47 | 51 |
48 bool ProxyMediaKeys::CreateSession(uint32 session_id, | 52 bool ProxyMediaKeys::CreateSession(uint32 session_id, |
49 const std::string& type, | 53 const std::string& type, |
50 const uint8* init_data, | 54 const uint8* init_data, |
51 int init_data_length) { | 55 int init_data_length) { |
56 requested_session_id_.insert(session_id); | |
52 manager_->CreateSession( | 57 manager_->CreateSession( |
53 media_keys_id_, | 58 media_keys_id_, |
54 session_id, | 59 session_id, |
55 type, | 60 type, |
56 std::vector<uint8>(init_data, init_data + init_data_length)); | 61 std::vector<uint8>(init_data, init_data + init_data_length)); |
57 return true; | 62 return true; |
58 } | 63 } |
59 | 64 |
60 void ProxyMediaKeys::UpdateSession(uint32 session_id, | 65 void ProxyMediaKeys::UpdateSession(uint32 session_id, |
61 const uint8* response, | 66 const uint8* response, |
62 int response_length) { | 67 int response_length) { |
63 manager_->UpdateSession( | 68 manager_->UpdateSession( |
64 media_keys_id_, | 69 media_keys_id_, |
65 session_id, | 70 session_id, |
66 std::vector<uint8>(response, response + response_length)); | 71 std::vector<uint8>(response, response + response_length)); |
67 } | 72 } |
68 | 73 |
69 void ProxyMediaKeys::ReleaseSession(uint32 session_id) { | 74 void ProxyMediaKeys::ReleaseSession(uint32 session_id) { |
75 requested_session_id_.erase(session_id); | |
ddorwin
2013/12/20 23:59:52
You probably don't need this here. See last commen
Kibeom Kim (inactive)
2013/12/30 12:33:05
Done.
| |
70 manager_->ReleaseSession(media_keys_id_, session_id); | 76 manager_->ReleaseSession(media_keys_id_, session_id); |
71 } | 77 } |
72 | 78 |
73 void ProxyMediaKeys::OnSessionCreated(uint32 session_id, | 79 void ProxyMediaKeys::OnSessionCreated(uint32 session_id, |
74 const std::string& web_session_id) { | 80 const std::string& web_session_id) { |
75 session_created_cb_.Run(session_id, web_session_id); | 81 session_created_cb_.Run(session_id, web_session_id); |
76 } | 82 } |
77 | 83 |
78 void ProxyMediaKeys::OnSessionMessage(uint32 session_id, | 84 void ProxyMediaKeys::OnSessionMessage(uint32 session_id, |
79 const std::vector<uint8>& message, | 85 const std::vector<uint8>& message, |
80 const std::string& destination_url) { | 86 const std::string& destination_url) { |
81 session_message_cb_.Run(session_id, message, destination_url); | 87 session_message_cb_.Run(session_id, message, destination_url); |
82 } | 88 } |
83 | 89 |
84 void ProxyMediaKeys::OnSessionReady(uint32 session_id) { | 90 void ProxyMediaKeys::OnSessionReady(uint32 session_id) { |
85 session_ready_cb_.Run(session_id); | 91 session_ready_cb_.Run(session_id); |
86 } | 92 } |
87 | 93 |
88 void ProxyMediaKeys::OnSessionClosed(uint32 session_id) { | 94 void ProxyMediaKeys::OnSessionClosed(uint32 session_id) { |
95 requested_session_id_.erase(session_id); | |
ddorwin
2013/12/20 23:59:52
I can't find documentation, but I assume this is a
Kibeom Kim (inactive)
2013/12/30 12:33:05
(I just assumed the spec is equal to std::set<>::e
| |
89 session_closed_cb_.Run(session_id); | 96 session_closed_cb_.Run(session_id); |
90 } | 97 } |
91 | 98 |
99 void ProxyMediaKeys::OnSessionApproved(uint32 session_id, bool success) { | |
ddorwin
2013/12/20 23:59:52
Can we just use OnSessionCreated for success and h
xhwang
2013/12/21 00:40:48
Can we have a CancelAllPendingSessionCreations(med
ddorwin
2013/12/21 00:44:56
Good point. This class is always tied to media_key
Kibeom Kim (inactive)
2013/12/21 01:50:43
So, looks like it's just a matter of which class w
| |
100 requested_session_id_.erase(session_id); | |
101 } | |
102 | |
92 void ProxyMediaKeys::OnSessionError(uint32 session_id, | 103 void ProxyMediaKeys::OnSessionError(uint32 session_id, |
93 media::MediaKeys::KeyError error_code, | 104 media::MediaKeys::KeyError error_code, |
94 int system_code) { | 105 int system_code) { |
95 session_error_cb_.Run(session_id, error_code, system_code); | 106 session_error_cb_.Run(session_id, error_code, system_code); |
96 } | 107 } |
97 | 108 |
98 } // namespace content | 109 } // namespace content |
OLD | NEW |