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

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

Issue 69603002: Incorporating logging into Cast (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding scoped_ptr include 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 | Annotate | Revision Log
« no previous file with comments | « media/base/audio_bus.h ('k') | media/cast/audio_receiver/audio_receiver_unittest.cc » ('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 "crypto/encryptor.h" 10 #include "crypto/encryptor.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 rtp_receiver_.reset(new RtpReceiver(cast_environment->Clock(), 114 rtp_receiver_.reset(new RtpReceiver(cast_environment->Clock(),
115 &audio_config, 115 &audio_config,
116 NULL, 116 NULL,
117 incoming_payload_callback_.get())); 117 incoming_payload_callback_.get()));
118 rtp_audio_receiver_statistics_.reset( 118 rtp_audio_receiver_statistics_.reset(
119 new LocalRtpReceiverStatistics(rtp_receiver_.get())); 119 new LocalRtpReceiverStatistics(rtp_receiver_.get()));
120 base::TimeDelta rtcp_interval_delta = 120 base::TimeDelta rtcp_interval_delta =
121 base::TimeDelta::FromMilliseconds(audio_config.rtcp_interval); 121 base::TimeDelta::FromMilliseconds(audio_config.rtcp_interval);
122 rtcp_.reset(new Rtcp(cast_environment->Clock(), 122 rtcp_.reset(new Rtcp(cast_environment,
123 NULL, 123 NULL,
124 packet_sender, 124 packet_sender,
125 NULL, 125 NULL,
126 rtp_audio_receiver_statistics_.get(), 126 rtp_audio_receiver_statistics_.get(),
127 audio_config.rtcp_mode, 127 audio_config.rtcp_mode,
128 rtcp_interval_delta, 128 rtcp_interval_delta,
129 audio_config.feedback_ssrc, 129 audio_config.feedback_ssrc,
130 audio_config.incoming_ssrc, 130 audio_config.incoming_ssrc,
131 audio_config.rtcp_c_name)); 131 audio_config.rtcp_c_name));
132 } 132 }
133 133
134 AudioReceiver::~AudioReceiver() {} 134 AudioReceiver::~AudioReceiver() {}
135 135
136 void AudioReceiver::InitializeTimers() { 136 void AudioReceiver::InitializeTimers() {
137 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 137 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
138 ScheduleNextRtcpReport(); 138 ScheduleNextRtcpReport();
139 ScheduleNextCastMessage(); 139 ScheduleNextCastMessage();
140 } 140 }
141 141
142 void AudioReceiver::IncomingParsedRtpPacket(const uint8* payload_data, 142 void AudioReceiver::IncomingParsedRtpPacket(const uint8* payload_data,
143 size_t payload_size, 143 size_t payload_size,
144 const RtpCastHeader& rtp_header) { 144 const RtpCastHeader& rtp_header) {
145 cast_environment_->Logging()->InsertPacketEvent(kPacketReceived,
146 rtp_header.webrtc.header.timestamp, rtp_header.frame_id,
147 rtp_header.packet_id, rtp_header.max_packet_id, payload_size);
148
145 // TODO(pwestin): update this as video to refresh over time. 149 // TODO(pwestin): update this as video to refresh over time.
146 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 150 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
147 if (time_first_incoming_packet_.is_null()) { 151 if (time_first_incoming_packet_.is_null()) {
148 InitializeTimers(); 152 InitializeTimers();
149 first_incoming_rtp_timestamp_ = rtp_header.webrtc.header.timestamp; 153 first_incoming_rtp_timestamp_ = rtp_header.webrtc.header.timestamp;
150 time_first_incoming_packet_ = cast_environment_->Clock()->NowTicks(); 154 time_first_incoming_packet_ = cast_environment_->Clock()->NowTicks();
151 } 155 }
152 156
153 if (audio_decoder_) { 157 if (audio_decoder_) {
154 DCHECK(!audio_buffer_) << "Invalid internal state"; 158 DCHECK(!audio_buffer_) << "Invalid internal state";
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 uint32 rtp_timestamp = 0; 213 uint32 rtp_timestamp = 0;
210 if (!audio_decoder_->GetRawAudioFrame(number_of_10ms_blocks, 214 if (!audio_decoder_->GetRawAudioFrame(number_of_10ms_blocks,
211 desired_frequency, 215 desired_frequency,
212 audio_frame.get(), 216 audio_frame.get(),
213 &rtp_timestamp)) { 217 &rtp_timestamp)) {
214 return; 218 return;
215 } 219 }
216 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); 220 base::TimeTicks now = cast_environment_->Clock()->NowTicks();
217 base::TimeTicks playout_time; 221 base::TimeTicks playout_time;
218 playout_time = GetPlayoutTime(now, rtp_timestamp); 222 playout_time = GetPlayoutTime(now, rtp_timestamp);
223 base::TimeDelta diff = playout_time - now;
224
225 cast_environment_->Logging()->InsertFrameEvent(kAudioPlayoutDelay,
226 rtp_timestamp, diff.InMilliseconds());
219 227
220 // Frame is ready - Send back to the main thread. 228 // Frame is ready - Send back to the main thread.
221 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, 229 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE,
222 base::Bind(callback, 230 base::Bind(callback,
223 base::Passed(&audio_frame), playout_time)); 231 base::Passed(&audio_frame), playout_time));
224 } 232 }
225 233
226 void AudioReceiver::PlayoutTimeout() { 234 void AudioReceiver::PlayoutTimeout() {
227 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 235 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
228 DCHECK(audio_buffer_) << "Invalid function call in this configuration"; 236 DCHECK(audio_buffer_) << "Invalid function call in this configuration";
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 432
425 void AudioReceiver::SendNextCastMessage() { 433 void AudioReceiver::SendNextCastMessage() {
426 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 434 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
427 DCHECK(audio_buffer_) << "Invalid function call in this configuration"; 435 DCHECK(audio_buffer_) << "Invalid function call in this configuration";
428 audio_buffer_->SendCastMessage(); // Will only send a message if it is time. 436 audio_buffer_->SendCastMessage(); // Will only send a message if it is time.
429 ScheduleNextCastMessage(); 437 ScheduleNextCastMessage();
430 } 438 }
431 439
432 } // namespace cast 440 } // namespace cast
433 } // namespace media 441 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_bus.h ('k') | media/cast/audio_receiver/audio_receiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698