| 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/transport/cast_transport_defines.h" | 9 #include "media/cast/transport/cast_transport_defines.h" |
| 10 #include "media/cast/transport/pacing/paced_sender.h" | 10 #include "media/cast/transport/pacing/paced_sender.h" |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 namespace cast { | 13 namespace cast { |
| 14 namespace transport { | 14 namespace transport { |
| 15 | 15 |
| 16 // Schedule the RTP statistics callback every 33mS. As this interval affects the | 16 // Schedule the RTP statistics callback every 33mS. As this interval affects the |
| 17 // time offset of the render and playout times, we want it in the same ball park | 17 // time offset of the render and playout times, we want it in the same ball park |
| 18 // as the frame rate. | 18 // as the frame rate. |
| 19 static const int kStatsCallbackIntervalMs = 33; | 19 static const int kStatsCallbackIntervalMs = 33; |
| 20 | 20 |
| 21 RtpSender::RtpSender( | 21 RtpSender::RtpSender( |
| 22 base::TickClock* clock, | 22 base::TickClock* clock, |
| 23 LoggingImpl* logging, |
| 23 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner, | 24 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner, |
| 24 PacedSender* const transport) | 25 PacedSender* const transport) |
| 25 : clock_(clock), | 26 : clock_(clock), |
| 27 logging_(logging), |
| 26 transport_(transport), | 28 transport_(transport), |
| 27 stats_callback_(), | 29 stats_callback_(), |
| 28 transport_task_runner_(transport_task_runner), | 30 transport_task_runner_(transport_task_runner), |
| 29 weak_factory_(this) { | 31 weak_factory_(this) { |
| 30 // Randomly set sequence number start value. | 32 // Randomly set sequence number start value. |
| 31 config_.sequence_number = base::RandInt(0, 65535); | 33 config_.sequence_number = base::RandInt(0, 65535); |
| 32 } | 34 } |
| 33 | 35 |
| 34 RtpSender::~RtpSender() {} | 36 RtpSender::~RtpSender() {} |
| 35 | 37 |
| 36 void RtpSender::InitializeAudio(const CastTransportAudioConfig& config) { | 38 void RtpSender::InitializeAudio(const CastTransportAudioConfig& config) { |
| 37 storage_.reset(new PacketStorage(clock_, config.base.rtp_config.history_ms)); | 39 storage_.reset(new PacketStorage(clock_, config.base.rtp_config.history_ms)); |
| 38 config_.audio = true; | 40 config_.audio = true; |
| 39 config_.ssrc = config.base.ssrc; | 41 config_.ssrc = config.base.ssrc; |
| 40 config_.payload_type = config.base.rtp_config.payload_type; | 42 config_.payload_type = config.base.rtp_config.payload_type; |
| 41 config_.frequency = config.frequency; | 43 config_.frequency = config.frequency; |
| 42 config_.audio_codec = config.codec; | 44 config_.audio_codec = config.codec; |
| 43 packetizer_.reset(new RtpPacketizer(transport_, storage_.get(), config_)); | 45 packetizer_.reset( |
| 46 new RtpPacketizer(transport_, storage_.get(), config_, clock_, logging_)); |
| 44 } | 47 } |
| 45 | 48 |
| 46 void RtpSender::InitializeVideo(const CastTransportVideoConfig& config) { | 49 void RtpSender::InitializeVideo(const CastTransportVideoConfig& config) { |
| 47 storage_.reset(new PacketStorage(clock_, config.base.rtp_config.history_ms)); | 50 storage_.reset(new PacketStorage(clock_, config.base.rtp_config.history_ms)); |
| 48 config_.audio = false; | 51 config_.audio = false; |
| 49 config_.ssrc = config.base.ssrc; | 52 config_.ssrc = config.base.ssrc; |
| 50 config_.payload_type = config.base.rtp_config.payload_type; | 53 config_.payload_type = config.base.rtp_config.payload_type; |
| 51 config_.frequency = kVideoFrequency; | 54 config_.frequency = kVideoFrequency; |
| 52 config_.video_codec = config.codec; | 55 config_.video_codec = config.codec; |
| 53 packetizer_.reset(new RtpPacketizer(transport_, storage_.get(), config_)); | 56 packetizer_.reset( |
| 57 new RtpPacketizer(transport_, storage_.get(), config_, clock_, logging_)); |
| 54 } | 58 } |
| 55 | 59 |
| 56 void RtpSender::IncomingEncodedVideoFrame(const EncodedVideoFrame* video_frame, | 60 void RtpSender::IncomingEncodedVideoFrame(const EncodedVideoFrame* video_frame, |
| 57 const base::TimeTicks& capture_time) { | 61 const base::TimeTicks& capture_time) { |
| 58 DCHECK(packetizer_); | 62 DCHECK(packetizer_); |
| 59 packetizer_->IncomingEncodedVideoFrame(video_frame, capture_time); | 63 packetizer_->IncomingEncodedVideoFrame(video_frame, capture_time); |
| 60 } | 64 } |
| 61 | 65 |
| 62 void RtpSender::IncomingEncodedAudioFrame( | 66 void RtpSender::IncomingEncodedAudioFrame( |
| 63 const EncodedAudioFrame* audio_frame, | 67 const EncodedAudioFrame* audio_frame, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 packetizer_->LastSentTimestamp(&time_sent, &rtp_timestamp); | 150 packetizer_->LastSentTimestamp(&time_sent, &rtp_timestamp); |
| 147 sender_info.send_packet_count = packetizer_->send_packets_count(); | 151 sender_info.send_packet_count = packetizer_->send_packets_count(); |
| 148 sender_info.send_octet_count = packetizer_->send_octet_count(); | 152 sender_info.send_octet_count = packetizer_->send_octet_count(); |
| 149 stats_callback_.Run(sender_info, time_sent, rtp_timestamp); | 153 stats_callback_.Run(sender_info, time_sent, rtp_timestamp); |
| 150 ScheduleNextStatsReport(); | 154 ScheduleNextStatsReport(); |
| 151 } | 155 } |
| 152 | 156 |
| 153 } // namespace transport | 157 } // namespace transport |
| 154 } // namespace cast | 158 } // namespace cast |
| 155 } // namespace media | 159 } // namespace media |
| OLD | NEW |