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

Side by Side Diff: media/cast/net/cast_transport_sender_impl.cc

Issue 654843007: Cast: Increase UDP socket send buffer size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move code Created 6 years, 2 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
« no previous file with comments | « media/cast/net/cast_transport_config.cc ('k') | media/cast/net/udp_transport.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/cast_transport_sender_impl.h" 5 #include "media/cast/net/cast_transport_sender_impl.h"
6 6
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "media/cast/net/cast_transport_config.h" 9 #include "media/cast/net/cast_transport_config.h"
10 #include "media/cast/net/cast_transport_defines.h" 10 #include "media/cast/net/cast_transport_defines.h"
11 #include "media/cast/net/udp_transport.h" 11 #include "media/cast/net/udp_transport.h"
12 #include "net/base/net_errors.h"
12 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
13 14
14 namespace media { 15 namespace media {
15 namespace cast { 16 namespace cast {
16 17
17 namespace { 18 namespace {
18 int LookupOptionWithDefault(const base::DictionaryValue& options, 19 int LookupOptionWithDefault(const base::DictionaryValue& options,
19 const std::string& path, 20 const std::string& path,
20 int default_value) { 21 int default_value) {
21 int ret; 22 int ret;
22 if (options.GetInteger(path, &ret)) { 23 if (options.GetInteger(path, &ret)) {
23 return ret; 24 return ret;
24 } else { 25 } else {
25 return default_value; 26 return default_value;
26 } 27 }
27 }; 28 };
28 29
30 // See header file for what these mean.
31 const char kOptionPacerTargetBurstSize[] = "pacer_target_burst_size";
32 const char kOptionPacerMaxBurstSize[] = "pacer_max_burst_size";
33 const char kOptionDscp[] = "DSCP";
34 const char kOptionWifiDisableScan[] = "disable_wifi_scan";
35 const char kOptionWifiMediaStreamingMode[] = "media_streaming_mode";
36
37 // 802.11n is the most commonly used network for cast streaming.
38 // The maximum MAC level data unit is 64KB as defined in the standard.
39 const int k802dot11nMaxAMPDUSize = 65536;
miu 2014/10/15 21:20:20 This will lower the default setting on Linux. Are
40
29 } // namespace 41 } // namespace
30 42
31 scoped_ptr<CastTransportSender> CastTransportSender::Create( 43 scoped_ptr<CastTransportSender> CastTransportSender::Create(
32 net::NetLog* net_log, 44 net::NetLog* net_log,
33 base::TickClock* clock, 45 base::TickClock* clock,
34 const net::IPEndPoint& remote_end_point, 46 const net::IPEndPoint& remote_end_point,
35 scoped_ptr<base::DictionaryValue> options, 47 scoped_ptr<base::DictionaryValue> options,
36 const CastTransportStatusCallback& status_callback, 48 const CastTransportStatusCallback& status_callback,
37 const BulkRawEventsCallback& raw_events_callback, 49 const BulkRawEventsCallback& raw_events_callback,
38 base::TimeDelta raw_events_callback_interval, 50 base::TimeDelta raw_events_callback_interval,
(...skipping 27 matching lines...) Expand all
66 : clock_(clock), 78 : clock_(clock),
67 status_callback_(status_callback), 79 status_callback_(status_callback),
68 transport_task_runner_(transport_task_runner), 80 transport_task_runner_(transport_task_runner),
69 transport_(external_transport ? NULL 81 transport_(external_transport ? NULL
70 : new UdpTransport(net_log, 82 : new UdpTransport(net_log,
71 transport_task_runner, 83 transport_task_runner,
72 net::IPEndPoint(), 84 net::IPEndPoint(),
73 remote_end_point, 85 remote_end_point,
74 status_callback)), 86 status_callback)),
75 pacer_(LookupOptionWithDefault(*options.get(), 87 pacer_(LookupOptionWithDefault(*options.get(),
76 "pacer_target_burst_size", 88 kOptionPacerTargetBurstSize,
77 kTargetBurstSize), 89 kTargetBurstSize),
78 LookupOptionWithDefault(*options.get(), 90 LookupOptionWithDefault(*options.get(),
79 "pacer_max_burst_size", 91 kOptionPacerMaxBurstSize,
80 kMaxBurstSize), 92 kMaxBurstSize),
81 clock, 93 clock,
82 &logging_, 94 &logging_,
83 external_transport ? external_transport : transport_.get(), 95 external_transport ? external_transport : transport_.get(),
84 transport_task_runner), 96 transport_task_runner),
85 raw_events_callback_(raw_events_callback), 97 raw_events_callback_(raw_events_callback),
86 raw_events_callback_interval_(raw_events_callback_interval), 98 raw_events_callback_interval_(raw_events_callback_interval),
87 last_byte_acked_for_audio_(0), 99 last_byte_acked_for_audio_(0),
88 weak_factory_(this) { 100 weak_factory_(this) {
89 DCHECK(clock_); 101 DCHECK(clock_);
90 if (!raw_events_callback_.is_null()) { 102 if (!raw_events_callback_.is_null()) {
91 DCHECK(raw_events_callback_interval > base::TimeDelta()); 103 DCHECK(raw_events_callback_interval > base::TimeDelta());
92 event_subscriber_.reset(new SimpleEventSubscriber); 104 event_subscriber_.reset(new SimpleEventSubscriber);
93 logging_.AddRawEventSubscriber(event_subscriber_.get()); 105 logging_.AddRawEventSubscriber(event_subscriber_.get());
94 transport_task_runner->PostDelayedTask( 106 transport_task_runner->PostDelayedTask(
95 FROM_HERE, 107 FROM_HERE,
96 base::Bind(&CastTransportSenderImpl::SendRawEvents, 108 base::Bind(&CastTransportSenderImpl::SendRawEvents,
97 weak_factory_.GetWeakPtr()), 109 weak_factory_.GetWeakPtr()),
98 raw_events_callback_interval); 110 raw_events_callback_interval);
99 } 111 }
100 if (transport_) { 112 if (transport_) {
101 if (options->HasKey("DSCP")) { 113 if (options->HasKey(kOptionDscp)) {
102 // The default DSCP value for cast is AF41. Which gives it a higher 114 // The default DSCP value for cast is AF41. Which gives it a higher
103 // priority over other traffic. 115 // priority over other traffic.
104 transport_->SetDscp(net::DSCP_AF41); 116 transport_->SetDscp(net::DSCP_AF41);
105 } 117 }
106 transport_->StartReceiving( 118 transport_->StartReceiving(
107 base::Bind(&CastTransportSenderImpl::OnReceivedPacket, 119 base::Bind(&CastTransportSenderImpl::OnReceivedPacket,
108 weak_factory_.GetWeakPtr())); 120 weak_factory_.GetWeakPtr()));
121
122 // Socket send buffer size needs to be at least greater than one burst size
123 // and greater than MAC protocol data unit. We use the MPDU value of
124 // 802.11n since it is the most commonly used network for Cast Streaming.
125 int send_buffer_size = std::max<int32>(
miu 2014/10/15 21:20:21 int, not int32 here.
Alpha Left Google 2014/10/15 23:07:26 Done.
126 k802dot11nMaxAMPDUSize,
127 LookupOptionWithDefault(*options.get(), kOptionPacerMaxBurstSize,
128 kMaxBurstSize) * kMaxIpPacketSize);
129 if (transport_->SetSendBufferSize(send_buffer_size) != net::OK) {
miu 2014/10/15 21:20:21 Please make this a ctor argument to UdpTransport (
Alpha Left Google 2014/10/15 23:07:26 Done.
130 VLOG(1) << "Cannot set send buffer size.";
131 }
109 int wifi_options = 0; 132 int wifi_options = 0;
110 if (options->HasKey("disable_wifi_scan")) { 133 if (options->HasKey(kOptionWifiDisableScan)) {
111 wifi_options |= net::WIFI_OPTIONS_DISABLE_SCAN; 134 wifi_options |= net::WIFI_OPTIONS_DISABLE_SCAN;
112 } 135 }
113 if (options->HasKey("media_streaming_mode")) { 136 if (options->HasKey(kOptionWifiMediaStreamingMode)) {
114 wifi_options |= net::WIFI_OPTIONS_MEDIA_STREAMING_MODE; 137 wifi_options |= net::WIFI_OPTIONS_MEDIA_STREAMING_MODE;
115 } 138 }
116 if (wifi_options) { 139 if (wifi_options) {
117 wifi_options_autoreset_ = net::SetWifiOptions(wifi_options); 140 wifi_options_autoreset_ = net::SetWifiOptions(wifi_options);
miu 2014/10/15 21:20:20 Do we restore the old wifi options when Cast strea
118 } 141 }
119 } 142 }
120 } 143 }
121 144
122 CastTransportSenderImpl::~CastTransportSenderImpl() { 145 CastTransportSenderImpl::~CastTransportSenderImpl() {
123 if (event_subscriber_.get()) 146 if (event_subscriber_.get())
124 logging_.RemoveRawEventSubscriber(event_subscriber_.get()); 147 logging_.RemoveRawEventSubscriber(event_subscriber_.get());
125 } 148 }
126 149
127 void CastTransportSenderImpl::InitializeAudio( 150 void CastTransportSenderImpl::InitializeAudio(
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // 2. Specifies a deduplication window. For video this would be the most 416 // 2. Specifies a deduplication window. For video this would be the most
394 // recent RTT. For audio there is no deduplication. 417 // recent RTT. For audio there is no deduplication.
395 ResendPackets(ssrc, 418 ResendPackets(ssrc,
396 cast_message.missing_frames_and_packets, 419 cast_message.missing_frames_and_packets,
397 true, 420 true,
398 dedup_info); 421 dedup_info);
399 } 422 }
400 423
401 } // namespace cast 424 } // namespace cast
402 } // namespace media 425 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/net/cast_transport_config.cc ('k') | media/cast/net/udp_transport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698