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

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: Case-insensitive content types. 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
« no previous file with comments | « content/renderer/media/crypto/proxy_media_keys.cc ('k') | media/cdm/ppapi/cdm_wrapper.h » ('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 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 DCHECK(base::IsStringASCII(init_data_type));
89 // Chromium only supports ASCII MIME types.
90 if (!base::IsStringASCII(init_data_type)) {
91 NOTREACHED();
92 OnSessionError(media::MediaKeys::NOT_SUPPORTED_ERROR,
93 0,
94 "The initialization data type " + init_data_type.utf8() +
95 " is not supported by the key system.");
96 return;
97 }
98 89
99 std::string init_data_type_as_ascii = base::UTF16ToASCII(init_data_type); 90 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) 91 DLOG_IF(WARNING, init_data_type_as_ascii.find('/') != std::string::npos)
101 << "init_data_type '" << init_data_type_as_ascii 92 << "init_data_type '" << init_data_type_as_ascii
102 << "' may be a MIME type"; 93 << "' may be a MIME type";
103 94
95 // Attempt to translate content types.
96 // TODO(sandersd): Remove once tests stop using content types.
97 // http://crbug.com/385874
98 std::string content_type = base::StringToLowerASCII(init_data_type_as_ascii);
99 if (content_type == "audio/mp4" || content_type == "video/mp4") {
100 init_data_type_as_ascii = "cenc";
101 } else if (content_type == "audio/webm" || content_type == "video/webm") {
102 init_data_type_as_ascii = "webm";
103 }
104
104 scoped_ptr<media::NewSessionCdmPromise> promise( 105 scoped_ptr<media::NewSessionCdmPromise> promise(
105 new media::NewSessionCdmPromise( 106 new media::NewSessionCdmPromise(
106 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionCreated, 107 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionCreated,
107 weak_ptr_factory_.GetWeakPtr(), 108 weak_ptr_factory_.GetWeakPtr(),
108 kReservedIndex), 109 kReservedIndex),
109 base::Bind(&WebContentDecryptionModuleSessionImpl::OnSessionError, 110 base::Bind(&WebContentDecryptionModuleSessionImpl::OnSessionError,
110 weak_ptr_factory_.GetWeakPtr()))); 111 weak_ptr_factory_.GetWeakPtr())));
111 adapter_->InitializeNewSession(init_data_type_as_ascii, 112 adapter_->InitializeNewSession(init_data_type_as_ascii,
112 init_data, 113 init_data,
113 init_data_length, 114 init_data_length,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 299
299 uint32 WebContentDecryptionModuleSessionImpl::AddResult( 300 uint32 WebContentDecryptionModuleSessionImpl::AddResult(
300 blink::WebContentDecryptionModuleResult result) { 301 blink::WebContentDecryptionModuleResult result) {
301 uint32 result_index = next_available_result_index_++; 302 uint32 result_index = next_available_result_index_++;
302 DCHECK(result_index != kReservedIndex); 303 DCHECK(result_index != kReservedIndex);
303 outstanding_results_.insert(std::make_pair(result_index, result)); 304 outstanding_results_.insert(std::make_pair(result_index, result));
304 return result_index; 305 return result_index;
305 } 306 }
306 307
307 } // namespace content 308 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/crypto/proxy_media_keys.cc ('k') | media/cdm/ppapi/cdm_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698