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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 params.payload.max_latency_ms); | 174 params.payload.max_latency_ms); |
175 config->max_playout_delay = | 175 config->max_playout_delay = |
176 base::TimeDelta::FromMilliseconds(params.payload.max_latency_ms); | 176 base::TimeDelta::FromMilliseconds(params.payload.max_latency_ms); |
177 if (config->min_playout_delay <= base::TimeDelta()) | 177 if (config->min_playout_delay <= base::TimeDelta()) |
178 return false; | 178 return false; |
179 if (config->min_playout_delay > config->max_playout_delay) | 179 if (config->min_playout_delay > config->max_playout_delay) |
180 return false; | 180 return false; |
181 config->rtp_payload_type = params.payload.payload_type; | 181 config->rtp_payload_type = params.payload.payload_type; |
182 config->use_external_encoder = false; | 182 config->use_external_encoder = false; |
183 config->frequency = params.payload.clock_rate; | 183 config->frequency = params.payload.clock_rate; |
184 if (config->frequency < 8000) | 184 if (config->frequency < media::cast::kMinUnackedFrequency) |
miu
2015/09/14 17:55:07
8000 is the largest of the minimum sampling rate r
msu.koo
2015/09/15 00:05:06
Changed to use media::limits::kMinSampleRate inste
miu
2015/09/15 04:16:57
There's a difference: 3000 is an operational lower
| |
185 return false; | 185 return false; |
186 config->channels = params.payload.channels; | 186 config->channels = params.payload.channels; |
187 if (config->channels < 1) | 187 if (config->channels < 1) |
188 return false; | 188 return false; |
189 config->bitrate = params.payload.max_bitrate * kBitrateMultiplier; | 189 config->bitrate = params.payload.max_bitrate * kBitrateMultiplier; |
190 if (params.payload.codec_name == kCodecNameOpus) | 190 if (params.payload.codec_name == kCodecNameOpus) |
191 config->codec = media::cast::CODEC_AUDIO_OPUS; | 191 config->codec = media::cast::CODEC_AUDIO_OPUS; |
192 else | 192 else |
193 return false; | 193 return false; |
194 config->aes_key = params.payload.aes_key; | 194 config->aes_key = params.payload.aes_key; |
(...skipping 20 matching lines...) Expand all Loading... | |
215 return false; | 215 return false; |
216 config->rtp_payload_type = params.payload.payload_type; | 216 config->rtp_payload_type = params.payload.payload_type; |
217 config->min_bitrate = config->start_bitrate = | 217 config->min_bitrate = config->start_bitrate = |
218 params.payload.min_bitrate * kBitrateMultiplier; | 218 params.payload.min_bitrate * kBitrateMultiplier; |
219 config->max_bitrate = params.payload.max_bitrate * kBitrateMultiplier; | 219 config->max_bitrate = params.payload.max_bitrate * kBitrateMultiplier; |
220 if (config->min_bitrate > config->max_bitrate) | 220 if (config->min_bitrate > config->max_bitrate) |
221 return false; | 221 return false; |
222 config->start_bitrate = config->min_bitrate; | 222 config->start_bitrate = config->min_bitrate; |
223 config->max_frame_rate = static_cast<int>( | 223 config->max_frame_rate = static_cast<int>( |
224 std::max(1.0, params.payload.max_frame_rate) + 0.5); | 224 std::max(1.0, params.payload.max_frame_rate) + 0.5); |
225 if (config->max_frame_rate > 120) | 225 if (config->max_frame_rate > media::cast::kMaxUnackedFrames) |
miu
2015/09/14 17:55:07
120 was chosen arbitrarily in the past. Instead,
msu.koo
2015/09/15 00:05:06
Done.
And IMHO, kMaxFramesPerSecond 1000 is too l
| |
226 return false; | 226 return false; |
227 if (params.payload.codec_name == kCodecNameVp8) { | 227 if (params.payload.codec_name == kCodecNameVp8) { |
228 config->use_external_encoder = IsHardwareVP8EncodingSupported(); | 228 config->use_external_encoder = IsHardwareVP8EncodingSupported(); |
229 config->codec = media::cast::CODEC_VIDEO_VP8; | 229 config->codec = media::cast::CODEC_VIDEO_VP8; |
230 } else if (params.payload.codec_name == kCodecNameH264) { | 230 } else if (params.payload.codec_name == kCodecNameH264) { |
231 config->use_external_encoder = IsHardwareH264EncodingSupported(); | 231 config->use_external_encoder = IsHardwareH264EncodingSupported(); |
232 config->codec = media::cast::CODEC_VIDEO_H264; | 232 config->codec = media::cast::CODEC_VIDEO_H264; |
233 } else { | 233 } else { |
234 return false; | 234 return false; |
235 } | 235 } |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 DCHECK(content::RenderThread::Get()); | 575 DCHECK(content::RenderThread::Get()); |
576 DVLOG(1) << "CastRtpStream::DidEncounterError(" << message << ") = " | 576 DVLOG(1) << "CastRtpStream::DidEncounterError(" << message << ") = " |
577 << (IsAudio() ? "audio" : "video"); | 577 << (IsAudio() ? "audio" : "video"); |
578 // Save the WeakPtr first because the error callback might delete this object. | 578 // Save the WeakPtr first because the error callback might delete this object. |
579 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); | 579 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); |
580 error_callback_.Run(message); | 580 error_callback_.Run(message); |
581 base::ThreadTaskRunnerHandle::Get()->PostTask( | 581 base::ThreadTaskRunnerHandle::Get()->PostTask( |
582 FROM_HERE, | 582 FROM_HERE, |
583 base::Bind(&CastRtpStream::Stop, ptr)); | 583 base::Bind(&CastRtpStream::Stop, ptr)); |
584 } | 584 } |
OLD | NEW |