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

Side by Side Diff: media/cast/transport/rtp_sender/rtp_sender.cc

Issue 100823015: Cast: move net->transport (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up Created 7 years 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
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/net/rtp_sender/rtp_sender.h" 5 #include "media/cast/transport/rtp_sender/rtp_sender.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "media/cast/cast_defines.h" 9 #include "media/cast/cast_defines.h"
10 #include "media/cast/net/pacing/paced_sender.h"
11 #include "media/cast/rtcp/rtcp_defines.h" 10 #include "media/cast/rtcp/rtcp_defines.h"
11 #include "media/cast/transport/pacing/paced_sender.h"
12 #include "net/base/big_endian.h" 12 #include "net/base/big_endian.h"
13 13
14 namespace media { 14 namespace media {
15 namespace cast { 15 namespace cast {
16 namespace transport {
16 17
17 RtpSender::RtpSender(scoped_refptr<CastEnvironment> cast_environment, 18 RtpSender::RtpSender(scoped_refptr<CastEnvironment> cast_environment,
18 const AudioSenderConfig* audio_config, 19 const AudioSenderConfig* audio_config,
19 const VideoSenderConfig* video_config, 20 const VideoSenderConfig* video_config,
20 PacedPacketSender* transport) 21 PacedPacketSender* transport)
21 : cast_environment_(cast_environment), 22 : cast_environment_(cast_environment),
22 config_(), 23 config_(),
23 transport_(transport) { 24 transport_(transport) {
24 // Store generic cast config and create packetizer config. 25 // Store generic cast config and create packetizer config.
25 DCHECK(audio_config || video_config) << "Invalid argument"; 26 DCHECK(audio_config || video_config) << "Invalid argument";
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 111 }
111 112
112 void RtpSender::UpdateSequenceNumber(Packet* packet) { 113 void RtpSender::UpdateSequenceNumber(Packet* packet) {
113 uint16 new_sequence_number = packetizer_->NextSequenceNumber(); 114 uint16 new_sequence_number = packetizer_->NextSequenceNumber();
114 int index = 2; 115 int index = 2;
115 (*packet)[index] = (static_cast<uint8>(new_sequence_number)); 116 (*packet)[index] = (static_cast<uint8>(new_sequence_number));
116 (*packet)[index + 1] =(static_cast<uint8>(new_sequence_number >> 8)); 117 (*packet)[index + 1] =(static_cast<uint8>(new_sequence_number >> 8));
117 } 118 }
118 119
119 void RtpSender::RtpStatistics(const base::TimeTicks& now, 120 void RtpSender::RtpStatistics(const base::TimeTicks& now,
120 RtcpSenderInfo* sender_info) { 121 media::cast::RtcpSenderInfo* sender_info) {
121 // The timestamp of this Rtcp packet should be estimated as the timestamp of 122 // The timestamp of this Rtcp packet should be estimated as the timestamp of
122 // the frame being captured at this moment. We are calculating that 123 // the frame being captured at this moment. We are calculating that
123 // timestamp as the last frame's timestamp + the time since the last frame 124 // timestamp as the last frame's timestamp + the time since the last frame
124 // was captured. 125 // was captured.
125 uint32 ntp_seconds = 0; 126 uint32 ntp_seconds = 0;
126 uint32 ntp_fraction = 0; 127 uint32 ntp_fraction = 0;
127 ConvertTimeTicksToNtp(now, &ntp_seconds, &ntp_fraction); 128 ConvertTimeTicksToNtp(now, &ntp_seconds, &ntp_fraction);
128 sender_info->ntp_seconds = ntp_seconds; 129 sender_info->ntp_seconds = ntp_seconds;
129 sender_info->ntp_fraction = ntp_fraction; 130 sender_info->ntp_fraction = ntp_fraction;
130 131
131 base::TimeTicks time_sent; 132 base::TimeTicks time_sent;
132 uint32 rtp_timestamp; 133 uint32 rtp_timestamp;
133 if (packetizer_->LastSentTimestamp(&time_sent, &rtp_timestamp)) { 134 if (packetizer_->LastSentTimestamp(&time_sent, &rtp_timestamp)) {
134 base::TimeDelta time_since_last_send = now - time_sent; 135 base::TimeDelta time_since_last_send = now - time_sent;
135 sender_info->rtp_timestamp = rtp_timestamp + 136 sender_info->rtp_timestamp = rtp_timestamp +
136 time_since_last_send.InMilliseconds() * (config_.frequency / 1000); 137 time_since_last_send.InMilliseconds() * (config_.frequency / 1000);
137 } else { 138 } else {
138 sender_info->rtp_timestamp = 0; 139 sender_info->rtp_timestamp = 0;
139 } 140 }
140 sender_info->send_packet_count = packetizer_->send_packets_count(); 141 sender_info->send_packet_count = packetizer_->send_packets_count();
141 sender_info->send_octet_count = packetizer_->send_octet_count(); 142 sender_info->send_octet_count = packetizer_->send_octet_count();
142 } 143 }
143 144
145 } // namespace transport
144 } // namespace cast 146 } // namespace cast
145 } // namespace media 147 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698