Chromium Code Reviews| Index: content/renderer/media_recorder/media_recorder_handler.cc |
| diff --git a/content/renderer/media_recorder/media_recorder_handler.cc b/content/renderer/media_recorder/media_recorder_handler.cc |
| index 139868935f0f755b0761768b5eb3ddb21ec07cf4..09af9641b84af547a3af156b53ab79210efb78bc 100644 |
| --- a/content/renderer/media_recorder/media_recorder_handler.cc |
| +++ b/content/renderer/media_recorder/media_recorder_handler.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/macros.h" |
| #include "base/strings/string_tokenizer.h" |
| #include "base/strings/string_util.h" |
| +#include "content/child/scoped_web_callbacks.h" |
| #include "content/renderer/media/media_stream_audio_track.h" |
| #include "content/renderer/media/media_stream_track.h" |
| #include "content/renderer/media/webrtc_uma_histograms.h" |
| @@ -25,6 +26,7 @@ |
| #include "third_party/WebKit/public/platform/WebMediaRecorderHandlerClient.h" |
| #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| #include "third_party/WebKit/public/platform/WebString.h" |
| +#include "third_party/WebKit/public/platform/modules/media_capabilities/WebMediaConfiguration.h" |
| using base::TimeDelta; |
| using base::TimeTicks; |
| @@ -32,6 +34,8 @@ using base::ToLowerASCII; |
| namespace content { |
| +using blink::WebMediaCapabilitiesQueryCallbacks; |
| + |
| namespace { |
| media::VideoCodec CodecIdToMediaVideoCodec(VideoTrackRecorder::CodecId id) { |
| @@ -51,6 +55,11 @@ media::VideoCodec CodecIdToMediaVideoCodec(VideoTrackRecorder::CodecId id) { |
| return media::kUnknownVideoCodec; |
| } |
| +void OnEncodingInfoError( |
| + std::unique_ptr<WebMediaCapabilitiesQueryCallbacks> callbacks) { |
| + callbacks->OnError(); |
| +} |
| + |
| } // anonymous namespace |
| MediaRecorderHandler::MediaRecorderHandler() |
| @@ -267,6 +276,53 @@ void MediaRecorderHandler::Resume() { |
| webm_muxer_->Resume(); |
| } |
| +void MediaRecorderHandler::EncodingInfo( |
| + const blink::WebMediaConfiguration& configuration, |
| + std::unique_ptr<blink::WebMediaCapabilitiesQueryCallbacks> callbacks) { |
| + DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
| + |
| + ScopedWebCallbacks<WebMediaCapabilitiesQueryCallbacks> scoped_callbacks = |
| + make_scoped_web_callbacks(callbacks.release(), |
| + base::Bind(&OnEncodingInfoError)); |
| + |
| + if (!configuration.video_configuration && !configuration.audio_configuration) |
| + return; |
|
mlamouri (slow - plz ping)
2017/04/18 12:24:35
That should not happen.
mcasas
2017/04/18 21:41:51
The current code allows for this to happen. What
d
|
| + |
| + std::unique_ptr<blink::WebMediaCapabilitiesInfo> info( |
| + new blink::WebMediaCapabilitiesInfo()); |
| + |
| + std::string content_type; |
| + if (configuration.video_configuration) |
| + content_type = configuration.video_configuration->content_type.Ascii(); |
| + else |
| + content_type = configuration.audio_configuration->content_type.Ascii(); |
|
mlamouri (slow - plz ping)
2017/04/18 12:24:35
what if there is audio and video?
mcasas
2017/04/18 21:41:51
TODO :-)
|
| + |
| + // |content_type| should be of the form "bla;codecs=foo", where "bla" is the |
| + // type and "codecs=foo" is the parameter ("foo" is the parameter value), see |
| + // RFC 2231 [1]. CanSupportMimeType() operates on type and parameter value. |
| + // [1] https://tools.ietf.org/html/rfc2231 |
| + base::StringTokenizer mime_tokenizer(content_type, ";"); |
| + blink::WebString web_type; |
| + blink::WebString web_codecs; |
| + if (mime_tokenizer.GetNext()) |
| + web_type = blink::WebString::FromASCII(mime_tokenizer.token()); |
| + if (mime_tokenizer.GetNext()) { |
| + const std::string parameters = mime_tokenizer.token(); |
| + base::StringTokenizer parameter_tokenizer(parameters, "="); |
| + if (parameter_tokenizer.GetNext() && |
| + base::ToLowerASCII(parameter_tokenizer.token()) == "codecs" && |
| + parameter_tokenizer.GetNext()) { |
| + web_codecs = blink::WebString::FromASCII(parameter_tokenizer.token()); |
| + } |
| + } |
|
mlamouri (slow - plz ping)
2017/04/18 12:24:35
I think most of this is going to be moved to Blink
mcasas
2017/04/18 21:41:51
That'd be great but for that we'd need to split
W
mlamouri (slow - plz ping)
2017/04/20 13:37:13
chcunningham@ has a CL for that. Worse case I gues
|
| + |
| + info->supported = CanSupportMimeType(web_type, web_codecs); |
| + DVLOG(1) << "type: " << web_type.Ascii() << ", params:" << web_codecs.Ascii() |
| + << " is" << (info->supported ? " supported" : " NOT supported"); |
| + |
| + scoped_callbacks.PassCallbacks()->OnSuccess(std::move(info)); |
| +} |
| + |
| void MediaRecorderHandler::OnEncodedVideo( |
| const media::WebmMuxer::VideoParameters& params, |
| std::unique_ptr<std::string> encoded_data, |