| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/renderer/media/cast_rtp_stream.h" | 5 #include "chrome/renderer/media/cast_rtp_stream.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 std::vector<CastRtpParams> SupportedAudioParams() { | 145 std::vector<CastRtpParams> SupportedAudioParams() { |
| 146 // TODO(hclam): Fill in more codecs here. | 146 // TODO(hclam): Fill in more codecs here. |
| 147 std::vector<CastRtpParams> supported_params; | 147 std::vector<CastRtpParams> supported_params; |
| 148 supported_params.push_back(CastRtpParams(DefaultOpusPayload())); | 148 supported_params.push_back(CastRtpParams(DefaultOpusPayload())); |
| 149 return supported_params; | 149 return supported_params; |
| 150 } | 150 } |
| 151 | 151 |
| 152 std::vector<CastRtpParams> SupportedVideoParams() { | 152 std::vector<CastRtpParams> SupportedVideoParams() { |
| 153 std::vector<CastRtpParams> supported_params; | 153 std::vector<CastRtpParams> supported_params; |
| 154 |
| 155 // Prefer VP8 over H.264 for hardware encoder. |
| 156 if (IsHardwareVP8EncodingSupported()) |
| 157 supported_params.push_back(CastRtpParams(DefaultVp8Payload())); |
| 154 if (IsHardwareH264EncodingSupported()) | 158 if (IsHardwareH264EncodingSupported()) |
| 155 supported_params.push_back(CastRtpParams(DefaultH264Payload())); | 159 supported_params.push_back(CastRtpParams(DefaultH264Payload())); |
| 156 supported_params.push_back(CastRtpParams(DefaultVp8Payload())); | 160 |
| 161 // Propose the default software VP8 encoder, if no hardware encoders are |
| 162 // available. |
| 163 if (supported_params.empty()) |
| 164 supported_params.push_back(CastRtpParams(DefaultVp8Payload())); |
| 165 |
| 157 return supported_params; | 166 return supported_params; |
| 158 } | 167 } |
| 159 | 168 |
| 160 bool ToAudioSenderConfig(const CastRtpParams& params, | 169 bool ToAudioSenderConfig(const CastRtpParams& params, |
| 161 AudioSenderConfig* config) { | 170 AudioSenderConfig* config) { |
| 162 config->ssrc = params.payload.ssrc; | 171 config->ssrc = params.payload.ssrc; |
| 163 config->receiver_ssrc = params.payload.feedback_ssrc; | 172 config->receiver_ssrc = params.payload.feedback_ssrc; |
| 164 if (config->ssrc == config->receiver_ssrc) | 173 if (config->ssrc == config->receiver_ssrc) |
| 165 return false; | 174 return false; |
| 166 config->min_playout_delay = | 175 config->min_playout_delay = |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 void CastRtpStream::DidEncounterError(const std::string& message) { | 572 void CastRtpStream::DidEncounterError(const std::string& message) { |
| 564 DVLOG(1) << "CastRtpStream::DidEncounterError(" << message << ") = " | 573 DVLOG(1) << "CastRtpStream::DidEncounterError(" << message << ") = " |
| 565 << (IsAudio() ? "audio" : "video"); | 574 << (IsAudio() ? "audio" : "video"); |
| 566 // Save the WeakPtr first because the error callback might delete this object. | 575 // Save the WeakPtr first because the error callback might delete this object. |
| 567 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); | 576 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); |
| 568 error_callback_.Run(message); | 577 error_callback_.Run(message); |
| 569 content::RenderThread::Get()->GetTaskRunner()->PostTask( | 578 content::RenderThread::Get()->GetTaskRunner()->PostTask( |
| 570 FROM_HERE, | 579 FROM_HERE, |
| 571 base::Bind(&CastRtpStream::Stop, ptr)); | 580 base::Bind(&CastRtpStream::Stop, ptr)); |
| 572 } | 581 } |
| OLD | NEW |