Index: media/cast/net/udp_transport.cc |
diff --git a/media/cast/net/udp_transport.cc b/media/cast/net/udp_transport.cc |
index 43ef86284085a59d1f3e8bf5080b69bea2f15de5..6afe6bdb61fed404c1965e22f6c2a1be13d185b8 100644 |
--- a/media/cast/net/udp_transport.cc |
+++ b/media/cast/net/udp_transport.cc |
@@ -65,7 +65,7 @@ UdpTransport::UdpTransport( |
UdpTransport::~UdpTransport() {} |
void UdpTransport::StartReceiving( |
- const PacketReceiverCallback& packet_receiver) { |
+ const PacketReceiverCallbackWithStatus& packet_receiver) { |
DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); |
packet_receiver_ = packet_receiver; |
@@ -94,6 +94,12 @@ void UdpTransport::StartReceiving( |
ScheduleReceiveNextPacket(); |
} |
+void UdpTransport::StopReceiving() { |
+ DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); |
+ packet_receiver_ = PacketReceiverCallbackWithStatus(); |
+} |
+ |
+ |
void UdpTransport::SetDscp(net::DiffServCodePoint dscp) { |
DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); |
next_dscp_value_ = dscp; |
@@ -150,16 +156,22 @@ void UdpTransport::ReceiveNextPacket(int length_or_status) { |
remote_addr_ = recv_addr_; |
VLOG(1) << "Setting remote address from first received packet: " |
<< remote_addr_.ToString(); |
+ next_packet_->resize(length_or_status); |
+ if (!packet_receiver_.Run(next_packet_.Pass())) { |
+ VLOG(1) << "Packet was not valid, resetting remote address."; |
+ remote_addr_ = net::IPEndPoint(); |
+ } |
+ length_or_status = net::ERR_IO_PENDING; |
} else if (!IsEqual(remote_addr_, recv_addr_)) { |
VLOG(1) << "Ignoring packet received from an unrecognized address: " |
<< recv_addr_.ToString() << "."; |
length_or_status = net::ERR_IO_PENDING; |
continue; |
miu
2014/12/04 04:18:55
Don't need the continue-statement anymore.
hubbe
2014/12/05 23:57:20
Done.
|
+ } else { |
+ next_packet_->resize(length_or_status); |
+ packet_receiver_.Run(next_packet_.Pass()); |
+ length_or_status = net::ERR_IO_PENDING; |
miu
2014/12/04 04:18:55
Since length_or_status is assigned the same from a
hubbe
2014/12/05 23:57:20
Done.
|
} |
- |
- next_packet_->resize(length_or_status); |
- packet_receiver_.Run(next_packet_.Pass()); |
- length_or_status = net::ERR_IO_PENDING; |
} |
} |