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

Side by Side Diff: content/renderer/media/webcontentdecryptionmodulesession_impl.cc

Issue 472493003: Convert between |init_data_type| and content type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix. Created 6 years, 4 months 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
OLDNEW
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/webcontentdecryptionmodulesession_impl.h" 5 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { 80 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const {
81 return blink::WebString::fromUTF8(web_session_id_); 81 return blink::WebString::fromUTF8(web_session_id_);
82 } 82 }
83 83
84 void WebContentDecryptionModuleSessionImpl::initializeNewSession( 84 void WebContentDecryptionModuleSessionImpl::initializeNewSession(
85 const blink::WebString& init_data_type, 85 const blink::WebString& init_data_type,
86 const uint8* init_data, 86 const uint8* init_data,
87 size_t init_data_length) { 87 size_t init_data_length) {
88 // TODO(ddorwin): Guard against this in supported types check and remove this. 88 // TODO(ddorwin): Guard against this in supported types check and remove this.
ddorwin 2014/08/13 20:59:54 Here's another TODO for more pushing stuff up into
sandersd (OOO until July 31) 2014/08/13 21:36:19 Done.
89 // Chromium only supports ASCII MIME types. 89 // Chromium only supports ASCII MIME types.
90 if (!base::IsStringASCII(init_data_type)) { 90 if (!base::IsStringASCII(init_data_type)) {
91 NOTREACHED(); 91 NOTREACHED();
92 OnSessionError(media::MediaKeys::NOT_SUPPORTED_ERROR, 92 OnSessionError(media::MediaKeys::NOT_SUPPORTED_ERROR,
93 0, 93 0,
94 "The initialization data type " + init_data_type.utf8() + 94 "The initialization data type " + init_data_type.utf8() +
95 " is not supported by the key system."); 95 " is not supported by the key system.");
96 return; 96 return;
97 } 97 }
98 98
99 std::string init_data_type_as_ascii = base::UTF16ToASCII(init_data_type); 99 std::string init_data_type_as_ascii = base::UTF16ToASCII(init_data_type);
100 DLOG_IF(WARNING, init_data_type_as_ascii.find('/') != std::string::npos) 100
101 << "init_data_type '" << init_data_type_as_ascii 101 if (init_data_type_as_ascii.find('/') != std::string::npos) {
102 << "' may be a MIME type"; 102 DLOG(WARNING) << "init_data_type '" << init_data_type_as_ascii
ddorwin 2014/08/13 20:59:54 IIRC, the DLOG_IF was a heads up that you may have
sandersd (OOO until July 31) 2014/08/13 21:36:19 Done.
103 << "' may be a MIME type";
104 // Attempt to translate content types.
105 // TODO(sandersd): Move to ProxyDecryptor. http://crbug.com/385874
ddorwin 2014/08/13 20:59:55 When? After converting the prefixed APIs and tests
sandersd (OOO until July 31) 2014/08/13 21:36:19 Done.
106 if (init_data_type_as_ascii == "audio/mp4" ||
ddorwin 2014/08/13 20:59:54 Use braces for this complex multi-line conditional
sandersd (OOO until July 31) 2014/08/13 21:36:19 Done.
107 init_data_type_as_ascii == "video/mp4")
108 init_data_type_as_ascii = "cenc";
109 else if (init_data_type_as_ascii == "audio/webm" ||
110 init_data_type_as_ascii == "video/webm")
111 init_data_type_as_ascii = "webm";
112 }
103 113
104 scoped_ptr<media::NewSessionCdmPromise> promise( 114 scoped_ptr<media::NewSessionCdmPromise> promise(
105 new media::NewSessionCdmPromise( 115 new media::NewSessionCdmPromise(
106 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionCreated, 116 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionCreated,
107 weak_ptr_factory_.GetWeakPtr(), 117 weak_ptr_factory_.GetWeakPtr(),
108 kReservedIndex), 118 kReservedIndex),
109 base::Bind(&WebContentDecryptionModuleSessionImpl::OnSessionError, 119 base::Bind(&WebContentDecryptionModuleSessionImpl::OnSessionError,
110 weak_ptr_factory_.GetWeakPtr()))); 120 weak_ptr_factory_.GetWeakPtr())));
111 adapter_->InitializeNewSession(init_data_type_as_ascii, 121 adapter_->InitializeNewSession(init_data_type_as_ascii,
112 init_data, 122 init_data,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 308
299 uint32 WebContentDecryptionModuleSessionImpl::AddResult( 309 uint32 WebContentDecryptionModuleSessionImpl::AddResult(
300 blink::WebContentDecryptionModuleResult result) { 310 blink::WebContentDecryptionModuleResult result) {
301 uint32 result_index = next_available_result_index_++; 311 uint32 result_index = next_available_result_index_++;
302 DCHECK(result_index != kReservedIndex); 312 DCHECK(result_index != kReservedIndex);
303 outstanding_results_.insert(std::make_pair(result_index, result)); 313 outstanding_results_.insert(std::make_pair(result_index, result));
304 return result_index; 314 return result_index;
305 } 315 }
306 316
307 } // namespace content 317 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698