summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-20 12:53:43 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-20 12:53:43 +0000
commit578562213f5b17a6da6c3fac8d062ff86424e560 (patch)
tree4ca38199cdbca3969c89df52f809dd723cb437b4
parent2f442a2b501e5865f1e00724394986858f12002a (diff)
downloadchromium_src-578562213f5b17a6da6c3fac8d062ff86424e560.zip
chromium_src-578562213f5b17a6da6c3fac8d062ff86424e560.tar.gz
chromium_src-578562213f5b17a6da6c3fac8d062ff86424e560.tar.bz2
Cast: Use DSCP AF41 for all traffic if possible.
Turns on DSCP AF41 to give cast traffic a higher priority. BUG=385768 TBR=miu Review URL: https://codereview.chromium.org/344953003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278683 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--media/cast/transport/cast_transport_sender_impl.cc6
-rw-r--r--media/cast/transport/transport/udp_transport.cc16
-rw-r--r--media/cast/transport/transport/udp_transport.h6
3 files changed, 28 insertions, 0 deletions
diff --git a/media/cast/transport/cast_transport_sender_impl.cc b/media/cast/transport/cast_transport_sender_impl.cc
index 2f51a93..c440c6c 100644
--- a/media/cast/transport/cast_transport_sender_impl.cc
+++ b/media/cast/transport/cast_transport_sender_impl.cc
@@ -7,6 +7,7 @@
#include "base/single_thread_task_runner.h"
#include "media/cast/transport/cast_transport_config.h"
#include "media/cast/transport/cast_transport_defines.h"
+#include "net/base/net_util.h"
namespace media {
namespace cast {
@@ -66,6 +67,11 @@ CastTransportSenderImpl::CastTransportSenderImpl(
this,
&CastTransportSenderImpl::SendRawEvents);
}
+ if (transport_) {
+ // The default DSCP value for cast is AF41. Which gives it a higher
+ // priority over other traffic.
+ transport_->SetDscp(net::DSCP_AF41);
+ }
}
CastTransportSenderImpl::~CastTransportSenderImpl() {
diff --git a/media/cast/transport/transport/udp_transport.cc b/media/cast/transport/transport/udp_transport.cc
index bcce4f7..9669b17 100644
--- a/media/cast/transport/transport/udp_transport.cc
+++ b/media/cast/transport/transport/udp_transport.cc
@@ -54,6 +54,7 @@ UdpTransport::UdpTransport(
send_pending_(false),
receive_pending_(false),
client_connected_(false),
+ next_dscp_value_(net::DSCP_NO_CHANGE),
status_callback_(status_callback),
weak_factory_(this) {
DCHECK(!IsEmpty(local_end_point) || !IsEmpty(remote_end_point));
@@ -88,6 +89,11 @@ void UdpTransport::StartReceiving(
ScheduleReceiveNextPacket();
}
+void UdpTransport::SetDscp(net::DiffServCodePoint dscp) {
+ DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread());
+ next_dscp_value_ = dscp;
+}
+
void UdpTransport::ScheduleReceiveNextPacket() {
DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread());
if (!packet_receiver_.is_null() && !receive_pending_) {
@@ -162,6 +168,16 @@ bool UdpTransport::SendPacket(PacketRef packet, const base::Closure& cb) {
return true;
}
+ if (next_dscp_value_ != net::DSCP_NO_CHANGE) {
+ int result = udp_socket_->SetDiffServCodePoint(next_dscp_value_);
+ if (result != net::OK) {
+ LOG(ERROR) << "Unable to set DSCP: " << next_dscp_value_
+ << " to socket; Error: " << result;
+ }
+ // Don't change DSCP in next send.
+ next_dscp_value_ = net::DSCP_NO_CHANGE;
+ }
+
scoped_refptr<net::IOBuffer> buf =
new net::WrappedIOBuffer(reinterpret_cast<char*>(&packet->data.front()));
diff --git a/media/cast/transport/transport/udp_transport.h b/media/cast/transport/transport/udp_transport.h
index 17b0d77..1a56850 100644
--- a/media/cast/transport/transport/udp_transport.h
+++ b/media/cast/transport/transport/udp_transport.h
@@ -12,6 +12,7 @@
#include "media/cast/transport/cast_transport_config.h"
#include "media/cast/transport/cast_transport_sender.h"
#include "net/base/ip_endpoint.h"
+#include "net/base/net_util.h"
#include "net/udp/udp_socket.h"
namespace net {
@@ -46,6 +47,10 @@ class UdpTransport : public PacketSender {
// Start receiving packets. Packets are submitted to |packet_receiver|.
void StartReceiving(const PacketReceiverCallback& packet_receiver);
+ // Set a new DSCP value to the socket. The value will be set right before
+ // the next send.
+ void SetDscp(net::DiffServCodePoint dscp);
+
// PacketSender implementations.
virtual bool SendPacket(PacketRef packet,
const base::Closure& cb) OVERRIDE;
@@ -72,6 +77,7 @@ class UdpTransport : public PacketSender {
bool send_pending_;
bool receive_pending_;
bool client_connected_;
+ net::DiffServCodePoint next_dscp_value_;
scoped_ptr<Packet> next_packet_;
scoped_refptr<net::WrappedIOBuffer> recv_buf_;
net::IPEndPoint recv_addr_;