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