diff options
-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_; |