Home | History | Annotate | Download | only in transport
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef MEDIA_CAST_TEST_TRANSPORT_TRANSPORT_H_
      6 #define MEDIA_CAST_TEST_TRANSPORT_TRANSPORT_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 #include "media/cast/cast_config.h"
     10 #include "media/cast/cast_environment.h"
     11 #include "net/udp/udp_server_socket.h"
     12 
     13 
     14 namespace media {
     15 namespace cast {
     16 namespace test {
     17 
     18 class LocalUdpTransportData;
     19 class LocalPacketSender;
     20 
     21 // Helper class for Cast test applications.
     22 class Transport {
     23  public:
     24   Transport(scoped_refptr<base::TaskRunner> io_thread_proxy);
     25   ~Transport();
     26 
     27   // Specifies the ports and IP address to receive packets on.
     28   // Will start listening immediately.
     29   void SetLocalReceiver(PacketReceiver* packet_receiver,
     30                         std::string ip_address,
     31                         std::string local_ip_address,
     32                         int port);
     33 
     34   // Specifies the destination port and IP address.
     35   void SetSendDestination(std::string ip_address, int port);
     36 
     37   PacketSender* packet_sender();
     38 
     39   void SetSendSidePacketLoss(int percentage);
     40 
     41   void StopReceiving();
     42 
     43  private:
     44   scoped_ptr<net::UDPServerSocket> udp_socket_;
     45   scoped_refptr<LocalPacketSender> packet_sender_;
     46   scoped_refptr<LocalUdpTransportData> local_udp_transport_data_;
     47   scoped_refptr<base::TaskRunner> io_thread_proxy_;
     48 
     49   DISALLOW_COPY_AND_ASSIGN(Transport);
     50 };
     51 
     52 }  // namespace test
     53 }  // namespace cast
     54 }  // namespace media
     55 
     56 #endif  // MEDIA_CAST_TEST_TRANSPORT_TRANSPORT_H_
     57