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

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

Issue 268983002: Revert of Cast: Fix two video freezing problems (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
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/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"
(...skipping 15 matching lines...) Expand all
26 transport_(transport), 26 transport_(transport),
27 stats_callback_(), 27 stats_callback_(),
28 transport_task_runner_(transport_task_runner), 28 transport_task_runner_(transport_task_runner),
29 weak_factory_(this) { 29 weak_factory_(this) {
30 // Randomly set sequence number start value. 30 // Randomly set sequence number start value.
31 config_.sequence_number = base::RandInt(0, 65535); 31 config_.sequence_number = base::RandInt(0, 65535);
32 } 32 }
33 33
34 RtpSender::~RtpSender() {} 34 RtpSender::~RtpSender() {}
35 35
36 bool RtpSender::InitializeAudio(const CastTransportAudioConfig& config) { 36 void RtpSender::InitializeAudio(const CastTransportAudioConfig& config) {
37 storage_.reset(new PacketStorage(config.rtp.max_outstanding_frames)); 37 storage_.reset(new PacketStorage(clock_, config.base.rtp_config.history_ms));
38 if (!storage_->IsValid()) {
39 return false;
40 }
41 config_.audio = true; 38 config_.audio = true;
42 config_.ssrc = config.rtp.config.ssrc; 39 config_.ssrc = config.base.ssrc;
43 config_.payload_type = config.rtp.config.payload_type; 40 config_.payload_type = config.base.rtp_config.payload_type;
44 config_.frequency = config.frequency; 41 config_.frequency = config.frequency;
45 config_.audio_codec = config.codec; 42 config_.audio_codec = config.codec;
46 packetizer_.reset(new RtpPacketizer(transport_, storage_.get(), config_)); 43 packetizer_.reset(
47 return true; 44 new RtpPacketizer(transport_, storage_.get(), config_));
48 } 45 }
49 46
50 bool RtpSender::InitializeVideo(const CastTransportVideoConfig& config) { 47 void RtpSender::InitializeVideo(const CastTransportVideoConfig& config) {
51 storage_.reset(new PacketStorage(config.rtp.max_outstanding_frames)); 48 storage_.reset(new PacketStorage(clock_, config.base.rtp_config.history_ms));
52 if (!storage_->IsValid()) {
53 return false;
54 }
55 config_.audio = false; 49 config_.audio = false;
56 config_.ssrc = config.rtp.config.ssrc; 50 config_.ssrc = config.base.ssrc;
57 config_.payload_type = config.rtp.config.payload_type; 51 config_.payload_type = config.base.rtp_config.payload_type;
58 config_.frequency = kVideoFrequency; 52 config_.frequency = kVideoFrequency;
59 config_.video_codec = config.codec; 53 config_.video_codec = config.codec;
60 packetizer_.reset(new RtpPacketizer(transport_, storage_.get(), config_)); 54 packetizer_.reset(
61 return true; 55 new RtpPacketizer(transport_, storage_.get(), config_));
62 } 56 }
63 57
64 void RtpSender::IncomingEncodedVideoFrame(const EncodedVideoFrame* video_frame, 58 void RtpSender::IncomingEncodedVideoFrame(const EncodedVideoFrame* video_frame,
65 const base::TimeTicks& capture_time) { 59 const base::TimeTicks& capture_time) {
66 DCHECK(packetizer_); 60 DCHECK(packetizer_);
67 packetizer_->IncomingEncodedVideoFrame(video_frame, capture_time); 61 packetizer_->IncomingEncodedVideoFrame(video_frame, capture_time);
68 } 62 }
69 63
70 void RtpSender::IncomingEncodedAudioFrame( 64 void RtpSender::IncomingEncodedAudioFrame(
71 const EncodedAudioFrame* audio_frame, 65 const EncodedAudioFrame* audio_frame,
(...skipping 16 matching lines...) Expand all
88 bool success = false; 82 bool success = false;
89 83
90 if (packets_set.empty()) { 84 if (packets_set.empty()) {
91 VLOG(3) << "Missing all packets in frame " << static_cast<int>(frame_id); 85 VLOG(3) << "Missing all packets in frame " << static_cast<int>(frame_id);
92 86
93 uint16 packet_id = 0; 87 uint16 packet_id = 0;
94 do { 88 do {
95 // Get packet from storage. 89 // Get packet from storage.
96 success = storage_->GetPacket(frame_id, packet_id, &packets_to_resend); 90 success = storage_->GetPacket(frame_id, packet_id, &packets_to_resend);
97 91
98 // Check that we got at least one packet.
99 DCHECK(packet_id != 0 || success)
100 << "Failed to resend frame " << static_cast<int>(frame_id);
101
102 // Resend packet to the network. 92 // Resend packet to the network.
103 if (success) { 93 if (success) {
104 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":" 94 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":"
105 << packet_id; 95 << packet_id;
106 // Set a unique incremental sequence number for every packet. 96 // Set a unique incremental sequence number for every packet.
107 PacketRef packet = packets_to_resend.back().second; 97 PacketRef packet = packets_to_resend.back().second;
108 UpdateSequenceNumber(&packet->data); 98 UpdateSequenceNumber(&packet->data);
109 // Set the size as correspond to each frame. 99 // Set the size as correspond to each frame.
110 ++packet_id; 100 ++packet_id;
111 } 101 }
112 } while (success); 102 } while (success);
113 } else { 103 } else {
114 // Iterate over all of the packets in the frame. 104 // Iterate over all of the packets in the frame.
115 for (PacketIdSet::const_iterator set_it = packets_set.begin(); 105 for (PacketIdSet::const_iterator set_it = packets_set.begin();
116 set_it != packets_set.end(); 106 set_it != packets_set.end();
117 ++set_it) { 107 ++set_it) {
118 uint16 packet_id = *set_it; 108 uint16 packet_id = *set_it;
119 success = storage_->GetPacket(frame_id, packet_id, &packets_to_resend); 109 success = storage_->GetPacket(frame_id, packet_id, &packets_to_resend);
120 110
121 // Check that we got at least one packet.
122 DCHECK(set_it != packets_set.begin() || success)
123 << "Failed to resend frame " << frame_id;
124
125 // Resend packet to the network. 111 // Resend packet to the network.
126 if (success) { 112 if (success) {
127 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":" 113 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":"
128 << packet_id; 114 << packet_id;
129 PacketRef packet = packets_to_resend.back().second; 115 PacketRef packet = packets_to_resend.back().second;
130 UpdateSequenceNumber(&packet->data); 116 UpdateSequenceNumber(&packet->data);
131 } 117 }
132 } 118 }
133 } 119 }
134 transport_->ResendPackets(packets_to_resend); 120 transport_->ResendPackets(packets_to_resend);
(...skipping 27 matching lines...) Expand all
162 packetizer_->LastSentTimestamp(&time_sent, &rtp_timestamp); 148 packetizer_->LastSentTimestamp(&time_sent, &rtp_timestamp);
163 sender_info.send_packet_count = packetizer_->send_packets_count(); 149 sender_info.send_packet_count = packetizer_->send_packets_count();
164 sender_info.send_octet_count = packetizer_->send_octet_count(); 150 sender_info.send_octet_count = packetizer_->send_octet_count();
165 stats_callback_.Run(sender_info, time_sent, rtp_timestamp); 151 stats_callback_.Run(sender_info, time_sent, rtp_timestamp);
166 ScheduleNextStatsReport(); 152 ScheduleNextStatsReport();
167 } 153 }
168 154
169 } // namespace transport 155 } // namespace transport
170 } // namespace cast 156 } // namespace cast
171 } // namespace media 157 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/transport/rtp_sender/rtp_sender.h ('k') | media/cast/transport/transport/udp_transport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698