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

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

Issue 147993010: Cast: end2end bug fixes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + nits Created 6 years, 10 months 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/cast/audio_sender/audio_encoder.cc ('k') | media/cast/cast_config.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_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
43 : transport_sender_(transport_sender), 43 : transport_sender_(transport_sender),
44 frequency_(0), 44 frequency_(0),
45 sender_info_(), 45 sender_info_(),
46 rtp_timestamp_(0) { 46 rtp_timestamp_(0) {
47 transport_sender_->SubscribeAudioRtpStatsCallback(base::Bind( 47 transport_sender_->SubscribeAudioRtpStatsCallback(base::Bind(
48 &LocalRtpSenderStatistics::StoreStatistics, base::Unretained(this))); 48 &LocalRtpSenderStatistics::StoreStatistics, base::Unretained(this)));
49 } 49 }
50 50
51 virtual void GetStatistics(const base::TimeTicks& now, 51 virtual void GetStatistics(const base::TimeTicks& now,
52 transport::RtcpSenderInfo* sender_info) OVERRIDE { 52 transport::RtcpSenderInfo* sender_info) OVERRIDE {
53 // Update RTP timestamp and return last stored statistics. 53 // Update and return last stored statistics.
54 if (rtp_timestamp_) { 54 uint32 ntp_seconds = 0;
55 uint32 ntp_fraction = 0;
56 uint32 rtp_timestamp = 0;
57 if (rtp_timestamp_ > 0) {
55 base::TimeDelta time_since_last_send = now - time_sent_; 58 base::TimeDelta time_since_last_send = now - time_sent_;
56 sender_info_.rtp_timestamp = 59 rtp_timestamp = rtp_timestamp_ + time_since_last_send.InMilliseconds() *
57 rtp_timestamp_ + 60 (frequency_ / 1000);
58 time_since_last_send.InMilliseconds() * (frequency_ / 1000); 61 // Update NTP time to current time.
59 } else { 62 ConvertTimeTicksToNtp(now, &ntp_seconds, &ntp_fraction);
60 sender_info_.rtp_timestamp = 0;
61 } 63 }
62 memcpy(sender_info, &sender_info_, sizeof(transport::RtcpSenderInfo)); 64 // Populate sender info.
65 sender_info->rtp_timestamp = rtp_timestamp;
66 sender_info->ntp_seconds = sender_info_.ntp_seconds;
67 sender_info->ntp_fraction = sender_info_.ntp_fraction;
68 sender_info->send_packet_count = sender_info_.send_packet_count;
69 sender_info->send_octet_count = sender_info_.send_octet_count;
63 } 70 }
64 71
65 void StoreStatistics(transport::RtcpSenderInfo& sender_info, 72 void StoreStatistics(transport::RtcpSenderInfo& sender_info,
66 base::TimeTicks time_sent, 73 base::TimeTicks time_sent,
67 uint32 rtp_timestamp) { 74 uint32 rtp_timestamp) {
68 sender_info_ = sender_info; 75 sender_info_ = sender_info;
69 time_sent_ = time_sent; 76 time_sent_ = time_sent;
70 rtp_timestamp_ = rtp_timestamp; 77 rtp_timestamp_ = rtp_timestamp;
71 } 78 }
72 79
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 202 }
196 203
197 void AudioSender::ResendPacketsOnTransportThread( 204 void AudioSender::ResendPacketsOnTransportThread(
198 const transport::MissingFramesAndPacketsMap& missing_packets) { 205 const transport::MissingFramesAndPacketsMap& missing_packets) {
199 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::TRANSPORT)); 206 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::TRANSPORT));
200 transport_sender_->ResendPackets(true, missing_packets); 207 transport_sender_->ResendPackets(true, missing_packets);
201 } 208 }
202 209
203 } // namespace cast 210 } // namespace cast
204 } // namespace media 211 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/audio_sender/audio_encoder.cc ('k') | media/cast/cast_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698