diff options
author | mikhail.pozdnyakov <mikhail.pozdnyakov@intel.com> | 2016-03-18 13:14:50 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-18 20:16:08 +0000 |
commit | 4282832cc5c90abf964308456f73ca0caf7f67d3 (patch) | |
tree | b07421f6721bdddc456dbb2cb17897e20a726338 /extensions/renderer | |
parent | 8f265dbe451806797bde728047fad52525e89d65 (diff) | |
download | chromium_src-4282832cc5c90abf964308456f73ca0caf7f67d3.zip chromium_src-4282832cc5c90abf964308456f73ca0caf7f67d3.tar.gz chromium_src-4282832cc5c90abf964308456f73ca0caf7f67d3.tar.bz2 |
[chrome.displaySource][WiFi Display] Audio formats capability negotiation
This patch is implementing audio formats capability negotiation based on the
given MediaStreamTrack object (only LPCM is supported).
BUG=242107
Review URL: https://codereview.chromium.org/1817503002
Cr-Commit-Position: refs/heads/master@{#382061}
Diffstat (limited to 'extensions/renderer')
-rw-r--r-- | extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc | 22 | ||||
-rw-r--r-- | extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.h | 1 |
2 files changed, 19 insertions, 4 deletions
diff --git a/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc b/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc index 4ac1a43..f77571d 100644 --- a/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc +++ b/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc @@ -16,7 +16,8 @@ const char kErrorNoVideoFormatData[] = "Failed to get video format data from the given MediaStreamTrack object"; const char kErrorSinkCannotPlayVideo[] = "The sink cannot play video from the given MediaStreamTrack object"; - +const char kErrorSinkCannotPlayAudio[] = + "The sink cannot play audio from the given MediaStreamTrack object"; } // namespace WiFiDisplayMediaManager::WiFiDisplayMediaManager( @@ -221,13 +222,26 @@ bool WiFiDisplayMediaManager::InitOptimalVideoFormat( bool WiFiDisplayMediaManager::InitOptimalAudioFormat( const std::vector<wds::AudioCodec>& sink_codecs) { - NOTIMPLEMENTED(); + for (const wds::AudioCodec& codec : sink_codecs) { + // MediaStreamTrack contains LPCM audio. + if (codec.format == wds::LPCM) { + optimal_audio_codec_ = codec; + // Picking a single mode. + wds::AudioModes optimal_mode; + if (codec.modes.test(wds::LPCM_44_1K_16B_2CH)) + optimal_mode.set(wds::LPCM_44_1K_16B_2CH); + else + optimal_mode.set(wds::LPCM_48K_16B_2CH); + optimal_audio_codec_.modes = optimal_mode; + return true; + } + } + error_callback_.Run(kErrorSinkCannotPlayAudio); return false; } wds::AudioCodec WiFiDisplayMediaManager::GetOptimalAudioFormat() const { - NOTIMPLEMENTED(); - return wds::AudioCodec(); + return optimal_audio_codec_; } } // namespace extensions diff --git a/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.h b/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.h index e28d620..277771c 100644 --- a/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.h +++ b/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.h @@ -57,6 +57,7 @@ class WiFiDisplayMediaManager : public wds::SourceMediaManager { std::pair<int, int> sink_rtp_ports_; wds::H264VideoFormat optimal_video_format_; + wds::AudioCodec optimal_audio_codec_; ErrorCallback error_callback_; |