| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "extensions/renderer/api/display_source/wifi_display/wifi_display_media
_manager.h" | 5 #include "extensions/renderer/api/display_source/wifi_display/wifi_display_media
_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "content/public/renderer/media_stream_api.h" | 9 #include "content/public/renderer/media_stream_api.h" |
| 10 | 10 |
| 11 namespace extensions { | 11 namespace extensions { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 const char kErrorNoVideoFormatData[] = | 15 const char kErrorNoVideoFormatData[] = |
| 16 "Failed to get video format data from the given MediaStreamTrack object"; | 16 "Failed to get video format data from the given MediaStreamTrack object"; |
| 17 const char kErrorSinkCannotPlayVideo[] = | 17 const char kErrorSinkCannotPlayVideo[] = |
| 18 "The sink cannot play video from the given MediaStreamTrack object"; | 18 "The sink cannot play video from the given MediaStreamTrack object"; |
| 19 | 19 const char kErrorSinkCannotPlayAudio[] = |
| 20 "The sink cannot play audio from the given MediaStreamTrack object"; |
| 20 } // namespace | 21 } // namespace |
| 21 | 22 |
| 22 WiFiDisplayMediaManager::WiFiDisplayMediaManager( | 23 WiFiDisplayMediaManager::WiFiDisplayMediaManager( |
| 23 const blink::WebMediaStreamTrack& video_track, | 24 const blink::WebMediaStreamTrack& video_track, |
| 24 const blink::WebMediaStreamTrack& audio_track, | 25 const blink::WebMediaStreamTrack& audio_track, |
| 25 const ErrorCallback& error_callback) | 26 const ErrorCallback& error_callback) |
| 26 : video_track_(video_track), | 27 : video_track_(video_track), |
| 27 audio_track_(audio_track), | 28 audio_track_(audio_track), |
| 28 error_callback_(error_callback) { | 29 error_callback_(error_callback) { |
| 29 DCHECK(!video_track.isNull() || !audio_track.isNull()); | 30 DCHECK(!video_track.isNull() || !audio_track.isNull()); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 capture_format, sink_supported_codecs, &optimal_video_format_)) { | 215 capture_format, sink_supported_codecs, &optimal_video_format_)) { |
| 215 error_callback_.Run(kErrorSinkCannotPlayVideo); | 216 error_callback_.Run(kErrorSinkCannotPlayVideo); |
| 216 return false; | 217 return false; |
| 217 } | 218 } |
| 218 | 219 |
| 219 return true; | 220 return true; |
| 220 } | 221 } |
| 221 | 222 |
| 222 bool WiFiDisplayMediaManager::InitOptimalAudioFormat( | 223 bool WiFiDisplayMediaManager::InitOptimalAudioFormat( |
| 223 const std::vector<wds::AudioCodec>& sink_codecs) { | 224 const std::vector<wds::AudioCodec>& sink_codecs) { |
| 224 NOTIMPLEMENTED(); | 225 for (const wds::AudioCodec& codec : sink_codecs) { |
| 226 // MediaStreamTrack contains LPCM audio. |
| 227 if (codec.format == wds::LPCM) { |
| 228 optimal_audio_codec_ = codec; |
| 229 // Picking a single mode. |
| 230 wds::AudioModes optimal_mode; |
| 231 if (codec.modes.test(wds::LPCM_44_1K_16B_2CH)) |
| 232 optimal_mode.set(wds::LPCM_44_1K_16B_2CH); |
| 233 else |
| 234 optimal_mode.set(wds::LPCM_48K_16B_2CH); |
| 235 optimal_audio_codec_.modes = optimal_mode; |
| 236 return true; |
| 237 } |
| 238 } |
| 239 error_callback_.Run(kErrorSinkCannotPlayAudio); |
| 225 return false; | 240 return false; |
| 226 } | 241 } |
| 227 | 242 |
| 228 wds::AudioCodec WiFiDisplayMediaManager::GetOptimalAudioFormat() const { | 243 wds::AudioCodec WiFiDisplayMediaManager::GetOptimalAudioFormat() const { |
| 229 NOTIMPLEMENTED(); | 244 return optimal_audio_codec_; |
| 230 return wds::AudioCodec(); | |
| 231 } | 245 } |
| 232 | 246 |
| 233 } // namespace extensions | 247 } // namespace extensions |
| OLD | NEW |