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/transport/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/rtcp/rtcp_defines.h" | |
10 #include "media/cast/transport/cast_transport_defines.h" | 9 #include "media/cast/transport/cast_transport_defines.h" |
11 #include "media/cast/transport/pacing/paced_sender.h" | 10 #include "media/cast/transport/pacing/paced_sender.h" |
12 #include "net/base/big_endian.h" | 11 #include "net/base/big_endian.h" |
13 | 12 |
14 namespace media { | 13 namespace media { |
15 namespace cast { | 14 namespace cast { |
16 namespace transport { | 15 namespace transport { |
17 | 16 |
18 RtpSender::RtpSender(scoped_refptr<CastEnvironment> cast_environment, | 17 RtpSender::RtpSender(base::TickClock* clock, |
19 const AudioSenderConfig* audio_config, | 18 const AudioSenderConfig* audio_config, |
20 const VideoSenderConfig* video_config, | 19 const VideoSenderConfig* video_config, |
21 PacedPacketSender* transport) | 20 PacedPacketSender* transport) |
22 : cast_environment_(cast_environment), | 21 : config_(), |
23 config_(), | |
24 transport_(transport) { | 22 transport_(transport) { |
25 // Store generic cast config and create packetizer config. | 23 // Store generic cast config and create packetizer config. |
26 DCHECK(audio_config || video_config) << "Invalid argument"; | 24 DCHECK(audio_config || video_config) << "Invalid argument"; |
27 if (audio_config) { | 25 if (audio_config) { |
28 storage_.reset(new PacketStorage(cast_environment->Clock(), | 26 storage_.reset(new PacketStorage(clock, audio_config->rtp_history_ms)); |
29 audio_config->rtp_history_ms)); | |
30 config_.audio = true; | 27 config_.audio = true; |
31 config_.ssrc = audio_config->sender_ssrc; | 28 config_.ssrc = audio_config->sender_ssrc; |
32 config_.payload_type = audio_config->rtp_payload_type; | 29 config_.payload_type = audio_config->rtp_payload_type; |
33 config_.frequency = audio_config->frequency; | 30 config_.frequency = audio_config->frequency; |
34 config_.audio_codec = audio_config->codec; | 31 config_.audio_codec = audio_config->codec; |
35 } else { | 32 } else { |
36 storage_.reset(new PacketStorage(cast_environment->Clock(), | 33 storage_.reset(new PacketStorage(clock, video_config->rtp_history_ms)); |
37 video_config->rtp_history_ms)); | |
38 config_.audio = false; | 34 config_.audio = false; |
39 config_.ssrc = video_config->sender_ssrc; | 35 config_.ssrc = video_config->sender_ssrc; |
40 config_.payload_type = video_config->rtp_payload_type; | 36 config_.payload_type = video_config->rtp_payload_type; |
41 config_.frequency = kVideoFrequency; | 37 config_.frequency = kVideoFrequency; |
42 config_.video_codec = video_config->codec; | 38 config_.video_codec = video_config->codec; |
43 } | 39 } |
44 // Randomly set start values. | 40 // Randomly set start values. |
45 config_.sequence_number = base::RandInt(0, 65535); | 41 config_.sequence_number = base::RandInt(0, 65535); |
46 config_.rtp_timestamp = base::RandInt(0, 65535); | 42 config_.rtp_timestamp = base::RandInt(0, 65535); |
47 config_.rtp_timestamp += base::RandInt(0, 65535) << 16; | 43 config_.rtp_timestamp += base::RandInt(0, 65535) << 16; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } else { | 134 } else { |
139 sender_info->rtp_timestamp = 0; | 135 sender_info->rtp_timestamp = 0; |
140 } | 136 } |
141 sender_info->send_packet_count = packetizer_->send_packets_count(); | 137 sender_info->send_packet_count = packetizer_->send_packets_count(); |
142 sender_info->send_octet_count = packetizer_->send_octet_count(); | 138 sender_info->send_octet_count = packetizer_->send_octet_count(); |
143 } | 139 } |
144 | 140 |
145 } // namespace transport | 141 } // namespace transport |
146 } // namespace cast | 142 } // namespace cast |
147 } // namespace media | 143 } // namespace media |
OLD | NEW |