OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_recorder/media_recorder_handler.h" | 5 #include "content/renderer/media_recorder/media_recorder_handler.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 285 |
286 ScopedWebCallbacks<WebMediaCapabilitiesQueryCallbacks> scoped_callbacks = | 286 ScopedWebCallbacks<WebMediaCapabilitiesQueryCallbacks> scoped_callbacks = |
287 make_scoped_web_callbacks(callbacks.release(), | 287 make_scoped_web_callbacks(callbacks.release(), |
288 base::Bind(&OnEncodingInfoError)); | 288 base::Bind(&OnEncodingInfoError)); |
289 | 289 |
290 std::unique_ptr<blink::WebMediaCapabilitiesInfo> info( | 290 std::unique_ptr<blink::WebMediaCapabilitiesInfo> info( |
291 new blink::WebMediaCapabilitiesInfo()); | 291 new blink::WebMediaCapabilitiesInfo()); |
292 | 292 |
293 // TODO(mcasas): Support the case when both video and audio configurations are | 293 // TODO(mcasas): Support the case when both video and audio configurations are |
294 // specified: https://crbug.com/709181. | 294 // specified: https://crbug.com/709181. |
295 std::string content_type; | 295 blink::WebString mime_type; |
296 if (configuration.video_configuration) | 296 blink::WebString codec; |
297 content_type = configuration.video_configuration->content_type.Ascii(); | 297 if (configuration.video_configuration) { |
298 else | 298 mime_type = configuration.video_configuration->mime_type; |
299 content_type = configuration.audio_configuration->content_type.Ascii(); | 299 codec = configuration.video_configuration->codec; |
300 | 300 } else { |
301 // |content_type| should be of the form "bla;codecs=foo", where "bla" is the | 301 mime_type = configuration.audio_configuration->mime_type; |
302 // type and "codecs=foo" is the parameter ("foo" is the parameter value), see | 302 codec = configuration.audio_configuration->codec; |
303 // RFC 2231 [1]. CanSupportMimeType() operates on type and parameter value. | |
304 // [1] https://tools.ietf.org/html/rfc2231 | |
305 base::StringTokenizer mime_tokenizer(content_type, ";"); | |
306 blink::WebString web_type; | |
307 blink::WebString web_codecs; | |
308 if (mime_tokenizer.GetNext()) | |
309 web_type = blink::WebString::FromASCII(mime_tokenizer.token()); | |
310 if (mime_tokenizer.GetNext()) { | |
311 const std::string parameters = mime_tokenizer.token(); | |
312 base::StringTokenizer parameter_tokenizer(parameters, "="); | |
313 if (parameter_tokenizer.GetNext() && | |
314 base::ToLowerASCII(parameter_tokenizer.token()) == "codecs" && | |
315 parameter_tokenizer.GetNext()) { | |
316 web_codecs = blink::WebString::FromASCII(parameter_tokenizer.token()); | |
317 } | |
318 } | 303 } |
319 | 304 |
320 info->supported = CanSupportMimeType(web_type, web_codecs); | 305 // See RFC 2231. https://tools.ietf.org/html/rfc2231 |
321 DVLOG(1) << "type: " << web_type.Ascii() << ", params:" << web_codecs.Ascii() | 306 info->supported = CanSupportMimeType(mime_type, codec); |
| 307 DVLOG(1) << "type: " << mime_type.Ascii() << ", codec:" << codec.Ascii() |
322 << " is" << (info->supported ? " supported" : " NOT supported"); | 308 << " is" << (info->supported ? " supported" : " NOT supported"); |
323 | 309 |
324 scoped_callbacks.PassCallbacks()->OnSuccess(std::move(info)); | 310 scoped_callbacks.PassCallbacks()->OnSuccess(std::move(info)); |
325 } | 311 } |
326 | 312 |
327 void MediaRecorderHandler::OnEncodedVideo( | 313 void MediaRecorderHandler::OnEncodedVideo( |
328 const media::WebmMuxer::VideoParameters& params, | 314 const media::WebmMuxer::VideoParameters& params, |
329 std::unique_ptr<std::string> encoded_data, | 315 std::unique_ptr<std::string> encoded_data, |
330 std::unique_ptr<std::string> encoded_alpha, | 316 std::unique_ptr<std::string> encoded_alpha, |
331 TimeTicks timestamp, | 317 TimeTicks timestamp, |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 recorder->OnData(audio_bus, timestamp); | 418 recorder->OnData(audio_bus, timestamp); |
433 } | 419 } |
434 | 420 |
435 void MediaRecorderHandler::SetAudioFormatForTesting( | 421 void MediaRecorderHandler::SetAudioFormatForTesting( |
436 const media::AudioParameters& params) { | 422 const media::AudioParameters& params) { |
437 for (const auto& recorder : audio_recorders_) | 423 for (const auto& recorder : audio_recorders_) |
438 recorder->OnSetFormat(params); | 424 recorder->OnSetFormat(params); |
439 } | 425 } |
440 | 426 |
441 } // namespace content | 427 } // namespace content |
OLD | NEW |