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.
5 #ifndef CHROME_RENDERER_MEDIA_CAST_UDP_TRANSPORT_H_
6 #define CHROME_RENDERER_MEDIA_CAST_UDP_TRANSPORT_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "content/public/renderer/p2p_socket_client.h"
12 #include "content/public/renderer/p2p_socket_client_delegate.h"
13 #include "net/base/host_port_pair.h"
17 // This class represents the transport mechanism used by Cast RTP streams
18 // to connect to a remote client. It specifies the destination address
19 // and network protocol used to send Cast RTP streams.
20 class CastUdpTransport
: public content::P2PSocketClientDelegate
{
22 explicit CastUdpTransport(const scoped_refptr
<CastSession
>& session
);
23 virtual ~CastUdpTransport();
25 // Specify the remote IP address and port.
26 void SetDestination(const net::IPEndPoint
& remote_address
);
29 // content::P2PSocketClient::Delegate Implementation
30 virtual void OnOpen(const net::IPEndPoint
& address
) OVERRIDE
;
31 virtual void OnIncomingTcpConnection(
32 const net::IPEndPoint
& address
,
33 content::P2PSocketClient
* client
) OVERRIDE
;
34 virtual void OnSendComplete() OVERRIDE
;
35 virtual void OnError() OVERRIDE
;
36 virtual void OnDataReceived(const net::IPEndPoint
& address
,
37 const std::vector
<char>& data
,
38 const base::TimeTicks
& timestamp
) OVERRIDE
;
41 void SendPacket(const std::vector
<char>& packet
);
43 const scoped_refptr
<CastSession
> cast_session_
;
44 scoped_refptr
<content::P2PSocketClient
> socket_
;
45 net::IPEndPoint remote_address_
;
46 base::WeakPtrFactory
<CastUdpTransport
> weak_factory_
;
48 DISALLOW_COPY_AND_ASSIGN(CastUdpTransport
);
51 #endif // CHROME_RENDERER_MEDIA_CAST_UDP_TRANSPORT_H_