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 "media/cast/audio_sender/audio_sender.h" | 5 #include "media/cast/audio_sender/audio_sender.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "media/cast/audio_sender/audio_encoder.h" | 10 #include "media/cast/audio_sender/audio_encoder.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 transport_sender_(transport_sender), | 43 transport_sender_(transport_sender), |
44 rtp_stats_(audio_config.frequency), | 44 rtp_stats_(audio_config.frequency), |
45 rtcp_feedback_(new LocalRtcpAudioSenderFeedback(this)), | 45 rtcp_feedback_(new LocalRtcpAudioSenderFeedback(this)), |
46 rtcp_(cast_environment, | 46 rtcp_(cast_environment, |
47 rtcp_feedback_.get(), | 47 rtcp_feedback_.get(), |
48 transport_sender_, | 48 transport_sender_, |
49 NULL, // paced sender. | 49 NULL, // paced sender. |
50 NULL, | 50 NULL, |
51 audio_config.rtcp_mode, | 51 audio_config.rtcp_mode, |
52 base::TimeDelta::FromMilliseconds(audio_config.rtcp_interval), | 52 base::TimeDelta::FromMilliseconds(audio_config.rtcp_interval), |
53 audio_config.sender_ssrc, | 53 audio_config.rtp_config.ssrc, |
54 audio_config.incoming_feedback_ssrc, | 54 audio_config.incoming_feedback_ssrc, |
55 audio_config.rtcp_c_name), | 55 audio_config.rtcp_c_name), |
56 timers_initialized_(false), | 56 timers_initialized_(false), |
57 cast_initialization_cb_(STATUS_AUDIO_UNINITIALIZED), | 57 cast_initialization_cb_(STATUS_AUDIO_UNINITIALIZED), |
58 weak_factory_(this) { | 58 weak_factory_(this) { |
59 rtcp_.SetCastReceiverEventHistorySize(kReceiverRtcpEventHistorySize); | 59 rtcp_.SetCastReceiverEventHistorySize(kReceiverRtcpEventHistorySize); |
60 if (!audio_config.use_external_encoder) { | 60 if (!audio_config.use_external_encoder) { |
61 audio_encoder_.reset( | 61 audio_encoder_.reset( |
62 new AudioEncoder(cast_environment, | 62 new AudioEncoder(cast_environment, |
63 audio_config, | 63 audio_config, |
64 base::Bind(&AudioSender::SendEncodedAudioFrame, | 64 base::Bind(&AudioSender::SendEncodedAudioFrame, |
65 weak_factory_.GetWeakPtr()))); | 65 weak_factory_.GetWeakPtr()))); |
66 cast_initialization_cb_ = audio_encoder_->InitializationResult(); | 66 cast_initialization_cb_ = audio_encoder_->InitializationResult(); |
67 } | 67 } |
| 68 |
| 69 media::cast::transport::CastTransportAudioConfig transport_config; |
| 70 transport_config.codec = audio_config.codec; |
| 71 transport_config.rtp.config = audio_config.rtp_config; |
| 72 transport_config.frequency = audio_config.frequency; |
| 73 transport_config.channels = audio_config.channels; |
| 74 transport_config.rtp.max_outstanding_frames = |
| 75 audio_config.rtp_config.max_delay_ms / 100 + 1; |
| 76 transport_sender_->InitializeAudio(transport_config); |
| 77 |
68 transport_sender_->SubscribeAudioRtpStatsCallback( | 78 transport_sender_->SubscribeAudioRtpStatsCallback( |
69 base::Bind(&AudioSender::StoreStatistics, weak_factory_.GetWeakPtr())); | 79 base::Bind(&AudioSender::StoreStatistics, weak_factory_.GetWeakPtr())); |
70 } | 80 } |
71 | 81 |
72 AudioSender::~AudioSender() {} | 82 AudioSender::~AudioSender() {} |
73 | 83 |
74 void AudioSender::InitializeTimers() { | 84 void AudioSender::InitializeTimers() { |
75 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 85 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
76 if (!timers_initialized_) { | 86 if (!timers_initialized_) { |
77 timers_initialized_ = true; | 87 timers_initialized_ = true; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // We don't send audio logging messages since all captured audio frames will | 142 // We don't send audio logging messages since all captured audio frames will |
133 // be sent. | 143 // be sent. |
134 transport::RtcpSenderLogMessage empty_msg; | 144 transport::RtcpSenderLogMessage empty_msg; |
135 rtp_stats_.UpdateInfo(cast_environment_->Clock()->NowTicks()); | 145 rtp_stats_.UpdateInfo(cast_environment_->Clock()->NowTicks()); |
136 rtcp_.SendRtcpFromRtpSender(empty_msg, rtp_stats_.sender_info()); | 146 rtcp_.SendRtcpFromRtpSender(empty_msg, rtp_stats_.sender_info()); |
137 ScheduleNextRtcpReport(); | 147 ScheduleNextRtcpReport(); |
138 } | 148 } |
139 | 149 |
140 } // namespace cast | 150 } // namespace cast |
141 } // namespace media | 151 } // namespace media |
OLD | NEW |