Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: media/cast/audio_receiver/audio_receiver.cc

Issue 70713002: Cast: Restructure RTCP interface to better fit our usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing line lost in merge Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cast/audio_receiver/audio_receiver.h ('k') | media/cast/audio_sender/audio_sender.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_receiver/audio_receiver.h" 5 #include "media/cast/audio_receiver/audio_receiver.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_receiver/audio_decoder.h" 10 #include "media/cast/audio_receiver/audio_decoder.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 private: 73 private:
74 RtpReceiver* rtp_receiver_; 74 RtpReceiver* rtp_receiver_;
75 }; 75 };
76 76
77 AudioReceiver::AudioReceiver(scoped_refptr<CastEnvironment> cast_environment, 77 AudioReceiver::AudioReceiver(scoped_refptr<CastEnvironment> cast_environment,
78 const AudioReceiverConfig& audio_config, 78 const AudioReceiverConfig& audio_config,
79 PacedPacketSender* const packet_sender) 79 PacedPacketSender* const packet_sender)
80 : cast_environment_(cast_environment), 80 : cast_environment_(cast_environment),
81 codec_(audio_config.codec), 81 codec_(audio_config.codec),
82 incoming_ssrc_(audio_config.incoming_ssrc),
83 frequency_(audio_config.frequency), 82 frequency_(audio_config.frequency),
84 audio_buffer_(), 83 audio_buffer_(),
85 audio_decoder_(), 84 audio_decoder_(),
86 time_offset_(), 85 time_offset_(),
87 weak_factory_(this) { 86 weak_factory_(this) {
88 target_delay_delta_ = 87 target_delay_delta_ =
89 base::TimeDelta::FromMilliseconds(audio_config.rtp_max_delay_ms); 88 base::TimeDelta::FromMilliseconds(audio_config.rtp_max_delay_ms);
90 incoming_payload_callback_.reset(new LocalRtpAudioData(this)); 89 incoming_payload_callback_.reset(new LocalRtpAudioData(this));
91 incoming_payload_feedback_.reset(new LocalRtpAudioFeedback(this)); 90 incoming_payload_feedback_.reset(new LocalRtpAudioFeedback(this));
92 if (audio_config.use_external_decoder) { 91 if (audio_config.use_external_decoder) {
(...skipping 13 matching lines...) Expand all
106 new LocalRtpReceiverStatistics(rtp_receiver_.get())); 105 new LocalRtpReceiverStatistics(rtp_receiver_.get()));
107 base::TimeDelta rtcp_interval_delta = 106 base::TimeDelta rtcp_interval_delta =
108 base::TimeDelta::FromMilliseconds(audio_config.rtcp_interval); 107 base::TimeDelta::FromMilliseconds(audio_config.rtcp_interval);
109 rtcp_.reset(new Rtcp(cast_environment->Clock(), 108 rtcp_.reset(new Rtcp(cast_environment->Clock(),
110 NULL, 109 NULL,
111 packet_sender, 110 packet_sender,
112 NULL, 111 NULL,
113 rtp_audio_receiver_statistics_.get(), 112 rtp_audio_receiver_statistics_.get(),
114 audio_config.rtcp_mode, 113 audio_config.rtcp_mode,
115 rtcp_interval_delta, 114 rtcp_interval_delta,
116 false,
117 audio_config.feedback_ssrc, 115 audio_config.feedback_ssrc,
116 audio_config.incoming_ssrc,
118 audio_config.rtcp_c_name)); 117 audio_config.rtcp_c_name));
119 rtcp_->SetRemoteSSRC(audio_config.incoming_ssrc);
120 } 118 }
121 119
122 AudioReceiver::~AudioReceiver() {} 120 AudioReceiver::~AudioReceiver() {}
123 121
124 void AudioReceiver::InitializeTimers() { 122 void AudioReceiver::InitializeTimers() {
125 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 123 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
126 ScheduleNextRtcpReport(); 124 ScheduleNextRtcpReport();
127 ScheduleNextCastMessage(); 125 ScheduleNextCastMessage();
128 } 126 }
129 127
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 bool rtcp_packet = Rtcp::IsRtcpPacket(packet, length); 281 bool rtcp_packet = Rtcp::IsRtcpPacket(packet, length);
284 if (!rtcp_packet) { 282 if (!rtcp_packet) {
285 rtp_receiver_->ReceivedPacket(packet, length); 283 rtp_receiver_->ReceivedPacket(packet, length);
286 } else { 284 } else {
287 rtcp_->IncomingRtcpPacket(packet, length); 285 rtcp_->IncomingRtcpPacket(packet, length);
288 } 286 }
289 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, callback); 287 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, callback);
290 } 288 }
291 289
292 void AudioReceiver::CastFeedback(const RtcpCastMessage& cast_message) { 290 void AudioReceiver::CastFeedback(const RtcpCastMessage& cast_message) {
293 rtcp_->SendRtcpCast(cast_message); 291 // TODO(pwestin): add logging.
292 rtcp_->SendRtcpFromRtpReceiver(&cast_message, NULL);
294 } 293 }
295 294
296 base::TimeTicks AudioReceiver::GetPlayoutTime(base::TimeTicks now, 295 base::TimeTicks AudioReceiver::GetPlayoutTime(base::TimeTicks now,
297 uint32 rtp_timestamp) { 296 uint32 rtp_timestamp) {
298 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 297 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
299 // Senders time in ms when this frame was recorded. 298 // Senders time in ms when this frame was recorded.
300 // Note: the senders clock and our local clock might not be synced. 299 // Note: the senders clock and our local clock might not be synced.
301 base::TimeTicks rtp_timestamp_in_ticks; 300 base::TimeTicks rtp_timestamp_in_ticks;
302 if (time_offset_ == base::TimeDelta()) { 301 if (time_offset_ == base::TimeDelta()) {
303 if (rtcp_->RtpTimestampInSenderTime(frequency_, 302 if (rtcp_->RtpTimestampInSenderTime(frequency_,
(...skipping 29 matching lines...) Expand all
333 time_to_send = std::max(time_to_send, 332 time_to_send = std::max(time_to_send,
334 base::TimeDelta::FromMilliseconds(kMinSchedulingDelayMs)); 333 base::TimeDelta::FromMilliseconds(kMinSchedulingDelayMs));
335 334
336 cast_environment_->PostDelayedTask(CastEnvironment::MAIN, FROM_HERE, 335 cast_environment_->PostDelayedTask(CastEnvironment::MAIN, FROM_HERE,
337 base::Bind(&AudioReceiver::SendNextRtcpReport, 336 base::Bind(&AudioReceiver::SendNextRtcpReport,
338 weak_factory_.GetWeakPtr()), time_to_send); 337 weak_factory_.GetWeakPtr()), time_to_send);
339 } 338 }
340 339
341 void AudioReceiver::SendNextRtcpReport() { 340 void AudioReceiver::SendNextRtcpReport() {
342 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 341 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
343 rtcp_->SendRtcpReport(incoming_ssrc_); 342 // TODO(pwestin): add logging.
343 rtcp_->SendRtcpFromRtpReceiver(NULL, NULL);
344 ScheduleNextRtcpReport(); 344 ScheduleNextRtcpReport();
345 } 345 }
346 346
347 // Cast messages should be sent within a maximum interval. Schedule a call 347 // Cast messages should be sent within a maximum interval. Schedule a call
348 // if not triggered elsewhere, e.g. by the cast message_builder. 348 // if not triggered elsewhere, e.g. by the cast message_builder.
349 void AudioReceiver::ScheduleNextCastMessage() { 349 void AudioReceiver::ScheduleNextCastMessage() {
350 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 350 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
351 if (audio_buffer_) { 351 if (audio_buffer_) {
352 base::TimeTicks send_time; 352 base::TimeTicks send_time;
353 audio_buffer_->TimeToSendNextCastMessage(&send_time); 353 audio_buffer_->TimeToSendNextCastMessage(&send_time);
(...skipping 10 matching lines...) Expand all
364 364
365 void AudioReceiver::SendNextCastMessage() { 365 void AudioReceiver::SendNextCastMessage() {
366 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 366 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
367 DCHECK(audio_buffer_) << "Invalid function call in this configuration"; 367 DCHECK(audio_buffer_) << "Invalid function call in this configuration";
368 audio_buffer_->SendCastMessage(); // Will only send a message if it is time. 368 audio_buffer_->SendCastMessage(); // Will only send a message if it is time.
369 ScheduleNextCastMessage(); 369 ScheduleNextCastMessage();
370 } 370 }
371 371
372 } // namespace cast 372 } // namespace cast
373 } // namespace media 373 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/audio_receiver/audio_receiver.h ('k') | media/cast/audio_sender/audio_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698