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

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

Issue 344953003: Cast: Use DSCP AF41 for all traffic if possible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dcheck Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « media/cast/transport/transport/udp_transport.h ('k') | no next file » | 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/transport/transport/udp_transport.h" 5 #include "media/cast/transport/transport/udp_transport.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 : io_thread_proxy_(io_thread_proxy), 47 : io_thread_proxy_(io_thread_proxy),
48 local_addr_(local_end_point), 48 local_addr_(local_end_point),
49 remote_addr_(remote_end_point), 49 remote_addr_(remote_end_point),
50 udp_socket_(new net::UDPSocket(net::DatagramSocket::DEFAULT_BIND, 50 udp_socket_(new net::UDPSocket(net::DatagramSocket::DEFAULT_BIND,
51 net::RandIntCallback(), 51 net::RandIntCallback(),
52 net_log, 52 net_log,
53 net::NetLog::Source())), 53 net::NetLog::Source())),
54 send_pending_(false), 54 send_pending_(false),
55 receive_pending_(false), 55 receive_pending_(false),
56 client_connected_(false), 56 client_connected_(false),
57 next_dscp_value_(net::DSCP_NO_CHANGE),
57 status_callback_(status_callback), 58 status_callback_(status_callback),
58 weak_factory_(this) { 59 weak_factory_(this) {
59 DCHECK(!IsEmpty(local_end_point) || !IsEmpty(remote_end_point)); 60 DCHECK(!IsEmpty(local_end_point) || !IsEmpty(remote_end_point));
60 } 61 }
61 62
62 UdpTransport::~UdpTransport() {} 63 UdpTransport::~UdpTransport() {}
63 64
64 void UdpTransport::StartReceiving( 65 void UdpTransport::StartReceiving(
65 const PacketReceiverCallback& packet_receiver) { 66 const PacketReceiverCallback& packet_receiver) {
66 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); 67 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread());
(...skipping 14 matching lines...) Expand all
81 return; 82 return;
82 } 83 }
83 client_connected_ = true; 84 client_connected_ = true;
84 } else { 85 } else {
85 NOTREACHED() << "Either local or remote address has to be defined."; 86 NOTREACHED() << "Either local or remote address has to be defined.";
86 } 87 }
87 88
88 ScheduleReceiveNextPacket(); 89 ScheduleReceiveNextPacket();
89 } 90 }
90 91
92 void UdpTransport::SetDscp(net::DiffServCodePoint dscp) {
93 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread());
94 next_dscp_value_ = dscp;
95 }
96
91 void UdpTransport::ScheduleReceiveNextPacket() { 97 void UdpTransport::ScheduleReceiveNextPacket() {
92 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); 98 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread());
93 if (!packet_receiver_.is_null() && !receive_pending_) { 99 if (!packet_receiver_.is_null() && !receive_pending_) {
94 receive_pending_ = true; 100 receive_pending_ = true;
95 io_thread_proxy_->PostTask(FROM_HERE, 101 io_thread_proxy_->PostTask(FROM_HERE,
96 base::Bind(&UdpTransport::ReceiveNextPacket, 102 base::Bind(&UdpTransport::ReceiveNextPacket,
97 weak_factory_.GetWeakPtr(), 103 weak_factory_.GetWeakPtr(),
98 net::ERR_IO_PENDING)); 104 net::ERR_IO_PENDING));
99 } 105 }
100 } 106 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 161
156 bool UdpTransport::SendPacket(PacketRef packet, const base::Closure& cb) { 162 bool UdpTransport::SendPacket(PacketRef packet, const base::Closure& cb) {
157 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); 163 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread());
158 164
159 DCHECK(!send_pending_); 165 DCHECK(!send_pending_);
160 if (send_pending_) { 166 if (send_pending_) {
161 VLOG(1) << "Cannot send because of pending IO."; 167 VLOG(1) << "Cannot send because of pending IO.";
162 return true; 168 return true;
163 } 169 }
164 170
171 if (next_dscp_value_ != net::DSCP_NO_CHANGE) {
172 int result = udp_socket_->SetDiffServCodePoint(next_dscp_value_);
173 if (result != net::OK) {
174 LOG(ERROR) << "Unable to set DSCP: " << next_dscp_value_
175 << " to socket; Error: " << result;
176 }
177 // Don't change DSCP in next send.
178 next_dscp_value_ = net::DSCP_NO_CHANGE;
179 }
180
165 scoped_refptr<net::IOBuffer> buf = 181 scoped_refptr<net::IOBuffer> buf =
166 new net::WrappedIOBuffer(reinterpret_cast<char*>(&packet->data.front())); 182 new net::WrappedIOBuffer(reinterpret_cast<char*>(&packet->data.front()));
167 183
168 int result; 184 int result;
169 base::Callback<void(int)> callback = base::Bind(&UdpTransport::OnSent, 185 base::Callback<void(int)> callback = base::Bind(&UdpTransport::OnSent,
170 weak_factory_.GetWeakPtr(), 186 weak_factory_.GetWeakPtr(),
171 buf, 187 buf,
172 packet, 188 packet,
173 cb); 189 cb);
174 if (client_connected_) { 190 if (client_connected_) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 233 }
218 234
219 if (!cb.is_null()) { 235 if (!cb.is_null()) {
220 cb.Run(); 236 cb.Run();
221 } 237 }
222 } 238 }
223 239
224 } // namespace transport 240 } // namespace transport
225 } // namespace cast 241 } // namespace cast
226 } // namespace media 242 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/transport/transport/udp_transport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698