OLD | NEW |
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/test/utility/udp_proxy.h" | 5 #include "media/cast/test/utility/udp_proxy.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 | 662 |
663 class UDPProxyImpl : public UDPProxy { | 663 class UDPProxyImpl : public UDPProxy { |
664 public: | 664 public: |
665 UDPProxyImpl(const net::IPEndPoint& local_port, | 665 UDPProxyImpl(const net::IPEndPoint& local_port, |
666 const net::IPEndPoint& destination, | 666 const net::IPEndPoint& destination, |
667 scoped_ptr<PacketPipe> to_dest_pipe, | 667 scoped_ptr<PacketPipe> to_dest_pipe, |
668 scoped_ptr<PacketPipe> from_dest_pipe, | 668 scoped_ptr<PacketPipe> from_dest_pipe, |
669 net::NetLog* net_log) | 669 net::NetLog* net_log) |
670 : local_port_(local_port), | 670 : local_port_(local_port), |
671 destination_(destination), | 671 destination_(destination), |
672 destination_is_mutable_(destination.address().empty()), | 672 destination_is_mutable_(destination.address_number().empty()), |
673 proxy_thread_("media::cast::test::UdpProxy Thread"), | 673 proxy_thread_("media::cast::test::UdpProxy Thread"), |
674 to_dest_pipe_(std::move(to_dest_pipe)), | 674 to_dest_pipe_(std::move(to_dest_pipe)), |
675 from_dest_pipe_(std::move(from_dest_pipe)), | 675 from_dest_pipe_(std::move(from_dest_pipe)), |
676 blocked_(false), | 676 blocked_(false), |
677 weak_factory_(this) { | 677 weak_factory_(this) { |
678 proxy_thread_.StartWithOptions( | 678 proxy_thread_.StartWithOptions( |
679 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 679 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
680 base::WaitableEvent start_event(false, false); | 680 base::WaitableEvent start_event(false, false); |
681 proxy_thread_.task_runner()->PostTask( | 681 proxy_thread_.task_runner()->PostTask( |
682 FROM_HERE, | 682 FROM_HERE, |
(...skipping 22 matching lines...) Expand all Loading... |
705 return; | 705 return; |
706 } | 706 } |
707 | 707 |
708 VLOG(1) << "Sending packet, len = " << packet->size(); | 708 VLOG(1) << "Sending packet, len = " << packet->size(); |
709 // We ignore all problems, callbacks and errors. | 709 // We ignore all problems, callbacks and errors. |
710 // If it didn't work we just drop the packet at and call it a day. | 710 // If it didn't work we just drop the packet at and call it a day. |
711 scoped_refptr<net::IOBuffer> buf = | 711 scoped_refptr<net::IOBuffer> buf = |
712 new net::WrappedIOBuffer(reinterpret_cast<char*>(&packet->front())); | 712 new net::WrappedIOBuffer(reinterpret_cast<char*>(&packet->front())); |
713 size_t buf_size = packet->size(); | 713 size_t buf_size = packet->size(); |
714 int result; | 714 int result; |
715 if (destination.address().empty()) { | 715 if (destination.address_number().empty()) { |
716 VLOG(1) << "Destination has not been set yet."; | 716 VLOG(1) << "Destination has not been set yet."; |
717 result = net::ERR_INVALID_ARGUMENT; | 717 result = net::ERR_INVALID_ARGUMENT; |
718 } else { | 718 } else { |
719 VLOG(1) << "Destination:" << destination.ToString(); | 719 VLOG(1) << "Destination:" << destination.ToString(); |
720 result = socket_->SendTo(buf.get(), | 720 result = socket_->SendTo(buf.get(), |
721 static_cast<int>(buf_size), | 721 static_cast<int>(buf_size), |
722 destination, | 722 destination, |
723 base::Bind(&UDPProxyImpl::AllowWrite, | 723 base::Bind(&UDPProxyImpl::AllowWrite, |
724 weak_factory_.GetWeakPtr(), | 724 weak_factory_.GetWeakPtr(), |
725 buf, | 725 buf, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 net::NetLog* net_log) { | 850 net::NetLog* net_log) { |
851 scoped_ptr<UDPProxy> ret( | 851 scoped_ptr<UDPProxy> ret( |
852 new UDPProxyImpl(local_port, destination, std::move(to_dest_pipe), | 852 new UDPProxyImpl(local_port, destination, std::move(to_dest_pipe), |
853 std::move(from_dest_pipe), net_log)); | 853 std::move(from_dest_pipe), net_log)); |
854 return ret; | 854 return ret; |
855 } | 855 } |
856 | 856 |
857 } // namespace test | 857 } // namespace test |
858 } // namespace cast | 858 } // namespace cast |
859 } // namespace media | 859 } // namespace media |
OLD | NEW |