Commit 57856221 authored by hclam@chromium.org's avatar hclam@chromium.org

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
parent 2f442a2b
......@@ -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() {
......
......@@ -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()));
......
......@@ -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_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment