Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: media/filters/pipeline_integration_test.cc

Issue 105383002: Rename EME WD call parameters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nit Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cdm/ppapi/clear_key_cdm.cc ('k') | ppapi/api/private/ppb_content_decryptor_private.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/filters/pipeline_integration_test_base.h" 5 #include "media/filters/pipeline_integration_test_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 // Note: Tests using this class only exercise the DecryptingDemuxerStream path. 74 // Note: Tests using this class only exercise the DecryptingDemuxerStream path.
75 // They do not exercise the Decrypting{Audio|Video}Decoder path. 75 // They do not exercise the Decrypting{Audio|Video}Decoder path.
76 class FakeEncryptedMedia { 76 class FakeEncryptedMedia {
77 public: 77 public:
78 // Defines the behavior of the "app" that responds to EME events. 78 // Defines the behavior of the "app" that responds to EME events.
79 class AppBase { 79 class AppBase {
80 public: 80 public:
81 virtual ~AppBase() {} 81 virtual ~AppBase() {}
82 82
83 virtual void SetSession(uint32 reference_id, 83 virtual void OnSessionCreated(uint32 session_id,
84 const std::string& session_id) = 0; 84 const std::string& web_session_id) = 0;
85 85
86 virtual void Message(uint32 reference_id, 86 virtual void OnSessionMessage(uint32 session_id,
87 const std::vector<uint8>& message, 87 const std::vector<uint8>& message,
88 const std::string& destination_url) = 0; 88 const std::string& destination_url) = 0;
89 89
90 virtual void Ready(uint32 reference_id) = 0; 90 virtual void OnSessionReady(uint32 session_id) = 0;
91 91
92 virtual void Closed(uint32 reference_id) = 0; 92 virtual void OnSessionClosed(uint32 session_id) = 0;
93 93
94 // Errors are not expected unless overridden. 94 // Errors are not expected unless overridden.
95 virtual void Error(uint32 reference_id, 95 virtual void OnSessionError(uint32 session_id,
96 MediaKeys::KeyError error_code, 96 MediaKeys::KeyError error_code,
97 int system_code) { 97 int system_code) {
98 FAIL() << "Unexpected Key Error"; 98 FAIL() << "Unexpected Key Error";
99 } 99 }
100 100
101 virtual void NeedKey(const std::string& type, 101 virtual void NeedKey(const std::string& type,
102 const std::vector<uint8>& init_data, 102 const std::vector<uint8>& init_data,
103 AesDecryptor* decryptor) = 0; 103 AesDecryptor* decryptor) = 0;
104 }; 104 };
105 105
106 FakeEncryptedMedia(AppBase* app) 106 FakeEncryptedMedia(AppBase* app)
107 : decryptor_( 107 : decryptor_(base::Bind(&FakeEncryptedMedia::OnSessionCreated,
108 base::Bind(&FakeEncryptedMedia::SetSession, base::Unretained(this)), 108 base::Unretained(this)),
109 base::Bind(&FakeEncryptedMedia::Message, base::Unretained(this)), 109 base::Bind(&FakeEncryptedMedia::OnSessionMessage,
110 base::Bind(&FakeEncryptedMedia::Ready, base::Unretained(this)), 110 base::Unretained(this)),
111 base::Bind(&FakeEncryptedMedia::Closed, base::Unretained(this)), 111 base::Bind(&FakeEncryptedMedia::OnSessionReady,
112 base::Bind(&FakeEncryptedMedia::Error, base::Unretained(this))), 112 base::Unretained(this)),
113 app_(app) { 113 base::Bind(&FakeEncryptedMedia::OnSessionClosed,
114 } 114 base::Unretained(this)),
115 base::Bind(&FakeEncryptedMedia::OnSessionError,
116 base::Unretained(this))),
117 app_(app) {}
115 118
116 AesDecryptor* decryptor() { 119 AesDecryptor* decryptor() {
117 return &decryptor_; 120 return &decryptor_;
118 } 121 }
119 122
120 // Callbacks for firing session events. Delegate to |app_|. 123 // Callbacks for firing session events. Delegate to |app_|.
121 void SetSession(uint32 reference_id, const std::string& session_id) { 124 void OnSessionCreated(uint32 session_id, const std::string& web_session_id) {
122 app_->SetSession(reference_id, session_id); 125 app_->OnSessionCreated(session_id, web_session_id);
123 } 126 }
124 127
125 void Message(uint32 reference_id, 128 void OnSessionMessage(uint32 session_id,
126 const std::vector<uint8>& message, 129 const std::vector<uint8>& message,
127 const std::string& destination_url) { 130 const std::string& destination_url) {
128 app_->Message(reference_id, message, destination_url); 131 app_->OnSessionMessage(session_id, message, destination_url);
129 } 132 }
130 133
131 void Ready(uint32 reference_id) { 134 void OnSessionReady(uint32 session_id) {
132 app_->Ready(reference_id); 135 app_->OnSessionReady(session_id);
133 } 136 }
134 137
135 void Closed(uint32 reference_id) { 138 void OnSessionClosed(uint32 session_id) {
136 app_->Closed(reference_id); 139 app_->OnSessionClosed(session_id);
137 } 140 }
138 141
139 void Error(uint32 reference_id, 142 void OnSessionError(uint32 session_id,
140 MediaKeys::KeyError error_code, 143 MediaKeys::KeyError error_code,
141 int system_code) { 144 int system_code) {
142 app_->Error(reference_id, error_code, system_code); 145 app_->OnSessionError(session_id, error_code, system_code);
143 } 146 }
144 147
145 void NeedKey(const std::string& type, 148 void NeedKey(const std::string& type,
146 const std::vector<uint8>& init_data) { 149 const std::vector<uint8>& init_data) {
147 app_->NeedKey(type, init_data, &decryptor_); 150 app_->NeedKey(type, init_data, &decryptor_);
148 } 151 }
149 152
150 private: 153 private:
151 AesDecryptor decryptor_; 154 AesDecryptor decryptor_;
152 scoped_ptr<AppBase> app_; 155 scoped_ptr<AppBase> app_;
153 }; 156 };
154 157
155 // Provides |kSecretKey| in response to needkey. 158 // Provides |kSecretKey| in response to needkey.
156 class KeyProvidingApp : public FakeEncryptedMedia::AppBase { 159 class KeyProvidingApp : public FakeEncryptedMedia::AppBase {
157 public: 160 public:
158 KeyProvidingApp() : current_reference_id_(0) {} 161 KeyProvidingApp() : current_session_id_(0) {}
159 162
160 virtual void SetSession(uint32 reference_id, 163 virtual void OnSessionCreated(uint32 session_id,
161 const std::string& session_id) OVERRIDE { 164 const std::string& web_session_id) OVERRIDE {
162 EXPECT_GT(reference_id, 0u); 165 EXPECT_GT(session_id, 0u);
163 EXPECT_FALSE(session_id.empty()); 166 EXPECT_FALSE(web_session_id.empty());
164 } 167 }
165 168
166 virtual void Message(uint32 reference_id, 169 virtual void OnSessionMessage(uint32 session_id,
167 const std::vector<uint8>& message, 170 const std::vector<uint8>& message,
168 const std::string& default_url) OVERRIDE { 171 const std::string& default_url) OVERRIDE {
169 EXPECT_GT(reference_id, 0u); 172 EXPECT_GT(session_id, 0u);
170 EXPECT_FALSE(message.empty()); 173 EXPECT_FALSE(message.empty());
171 174
172 current_reference_id_ = reference_id; 175 current_session_id_ = session_id;
173 } 176 }
174 177
175 virtual void Ready(uint32 reference_id) OVERRIDE { 178 virtual void OnSessionReady(uint32 session_id) OVERRIDE {
176 EXPECT_GT(reference_id, 0u); 179 EXPECT_GT(session_id, 0u);
177 } 180 }
178 181
179 virtual void Closed(uint32 reference_id) OVERRIDE { 182 virtual void OnSessionClosed(uint32 session_id) OVERRIDE {
180 EXPECT_GT(reference_id, 0u); 183 EXPECT_GT(session_id, 0u);
181 } 184 }
182 185
183 virtual void NeedKey(const std::string& type, 186 virtual void NeedKey(const std::string& type,
184 const std::vector<uint8>& init_data, 187 const std::vector<uint8>& init_data,
185 AesDecryptor* decryptor) OVERRIDE { 188 AesDecryptor* decryptor) OVERRIDE {
186 if (current_reference_id_ == 0u) { 189 if (current_session_id_ == 0u) {
187 EXPECT_TRUE( 190 EXPECT_TRUE(
188 decryptor->CreateSession(12, type, kInitData, arraysize(kInitData))); 191 decryptor->CreateSession(12, type, kInitData, arraysize(kInitData)));
189 } 192 }
190 193
191 EXPECT_EQ(current_reference_id_, 12u); 194 EXPECT_EQ(current_session_id_, 12u);
192 195
193 // Clear Key really needs the key ID in |init_data|. For WebM, they are the 196 // Clear Key really needs the key ID in |init_data|. For WebM, they are the
194 // same, but this is not the case for ISO CENC. Therefore, provide the 197 // same, but this is not the case for ISO CENC. Therefore, provide the
195 // correct key ID. 198 // correct key ID.
196 const uint8* key_id = init_data.empty() ? NULL : &init_data[0]; 199 const uint8* key_id = init_data.empty() ? NULL : &init_data[0];
197 size_t key_id_length = init_data.size(); 200 size_t key_id_length = init_data.size();
198 if (type == kMP4AudioType || type == kMP4VideoType) { 201 if (type == kMP4AudioType || type == kMP4VideoType) {
199 key_id = kKeyId; 202 key_id = kKeyId;
200 key_id_length = arraysize(kKeyId); 203 key_id_length = arraysize(kKeyId);
201 } 204 }
202 205
203 // Convert key into a JSON structure and then add it. 206 // Convert key into a JSON structure and then add it.
204 std::string jwk = GenerateJWKSet( 207 std::string jwk = GenerateJWKSet(
205 kSecretKey, arraysize(kSecretKey), key_id, key_id_length); 208 kSecretKey, arraysize(kSecretKey), key_id, key_id_length);
206 decryptor->UpdateSession(current_reference_id_, 209 decryptor->UpdateSession(current_session_id_,
207 reinterpret_cast<const uint8*>(jwk.data()), 210 reinterpret_cast<const uint8*>(jwk.data()),
208 jwk.size()); 211 jwk.size());
209 } 212 }
210 213
211 uint32 current_reference_id_; 214 uint32 current_session_id_;
212 }; 215 };
213 216
214 // Ignores needkey and does not perform a license request 217 // Ignores needkey and does not perform a license request
215 class NoResponseApp : public FakeEncryptedMedia::AppBase { 218 class NoResponseApp : public FakeEncryptedMedia::AppBase {
216 public: 219 public:
217 virtual void SetSession(uint32 reference_id, 220 virtual void OnSessionCreated(uint32 session_id,
218 const std::string& session_id) OVERRIDE { 221 const std::string& web_session_id) OVERRIDE {
219 EXPECT_GT(reference_id, 0u); 222 EXPECT_GT(session_id, 0u);
220 EXPECT_FALSE(session_id.empty()); 223 EXPECT_FALSE(web_session_id.empty());
221 } 224 }
222 225
223 virtual void Message(uint32 reference_id, 226 virtual void OnSessionMessage(uint32 session_id,
224 const std::vector<uint8>& message, 227 const std::vector<uint8>& message,
225 const std::string& default_url) OVERRIDE { 228 const std::string& default_url) OVERRIDE {
226 EXPECT_GT(reference_id, 0u); 229 EXPECT_GT(session_id, 0u);
227 EXPECT_FALSE(message.empty()); 230 EXPECT_FALSE(message.empty());
228 FAIL() << "Unexpected KeyMessage"; 231 FAIL() << "Unexpected KeyMessage";
229 } 232 }
230 233
231 virtual void Ready(uint32 reference_id) OVERRIDE { 234 virtual void OnSessionReady(uint32 session_id) OVERRIDE {
232 EXPECT_GT(reference_id, 0u); 235 EXPECT_GT(session_id, 0u);
233 FAIL() << "Unexpected Ready"; 236 FAIL() << "Unexpected Ready";
234 } 237 }
235 238
236 virtual void Closed(uint32 reference_id) OVERRIDE { 239 virtual void OnSessionClosed(uint32 session_id) OVERRIDE {
237 EXPECT_GT(reference_id, 0u); 240 EXPECT_GT(session_id, 0u);
238 FAIL() << "Unexpected Closed"; 241 FAIL() << "Unexpected Closed";
239 } 242 }
240 243
241 virtual void NeedKey(const std::string& type, 244 virtual void NeedKey(const std::string& type,
242 const std::vector<uint8>& init_data, 245 const std::vector<uint8>& init_data,
243 AesDecryptor* decryptor) OVERRIDE { 246 AesDecryptor* decryptor) OVERRIDE {
244 } 247 }
245 }; 248 };
246 249
247 // Helper class that emulates calls made on the ChunkDemuxer by the 250 // Helper class that emulates calls made on the ChunkDemuxer by the
248 // Media Source API. 251 // Media Source API.
249 class MockMediaSource { 252 class MockMediaSource {
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 // Verify that VP8 video with inband text track can be played back. 1113 // Verify that VP8 video with inband text track can be played back.
1111 TEST_F(PipelineIntegrationTest, 1114 TEST_F(PipelineIntegrationTest,
1112 BasicPlayback_VP8_WebVTT_WebM) { 1115 BasicPlayback_VP8_WebVTT_WebM) {
1113 ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"), 1116 ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"),
1114 PIPELINE_OK)); 1117 PIPELINE_OK));
1115 Play(); 1118 Play();
1116 ASSERT_TRUE(WaitUntilOnEnded()); 1119 ASSERT_TRUE(WaitUntilOnEnded());
1117 } 1120 }
1118 1121
1119 } // namespace media 1122 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/ppapi/clear_key_cdm.cc ('k') | ppapi/api/private/ppb_content_decryptor_private.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698