Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Unified Diff: media/cast/transport/transport/udp_transport.h

Issue 125713002: Implement UdpTransport for Cast (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/transport/transport/transport.cc ('k') | media/cast/transport/transport/udp_transport.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/transport/transport/udp_transport.h
diff --git a/media/cast/transport/transport/udp_transport.h b/media/cast/transport/transport/udp_transport.h
new file mode 100644
index 0000000000000000000000000000000000000000..0487561daf35d294e0986d2904e27252ba5df569
--- /dev/null
+++ b/media/cast/transport/transport/udp_transport.h
@@ -0,0 +1,68 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_CAST_TRANSPORT_TRANSPORT_UDP_TRANSPORT_H_
+#define MEDIA_CAST_TRANSPORT_TRANSPORT_UDP_TRANSPORT_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "media/cast/cast_config.h"
+#include "media/cast/cast_environment.h"
+#include "net/base/ip_endpoint.h"
+#include "net/udp/udp_server_socket.h"
+
+namespace net {
+class IOBuffer;
+class IPEndPoint;
+} // namespace net
+
+namespace media {
+namespace cast {
+namespace transport {
+
+// This class implements UDP transport mechanism for Cast.
+class UdpTransport : public PacketSender {
+ public:
+ // Construct a UDP transport.
+ // All methods must be called on |io_thread_proxy|.
+ // |local_end_point| specifies the address and port to bind and listen
+ // to incoming packets.
+ // |remote_end_point| specifies the address and port to send packets
+ // to. If the value is 0.0.0.0:0 the the end point is set to the source
+ // address of the first packet received.
+ UdpTransport(const scoped_refptr<base::TaskRunner>& io_thread_proxy,
+ const net::IPEndPoint& local_end_point,
+ const net::IPEndPoint& remote_end_point);
+ virtual ~UdpTransport();
+
+ // Start receiving packets. Packets are submitted to |packet_receiver|.
+ void StartReceiving(PacketReceiver* packet_receiver);
+
+ // PacketSender implementations.
+ virtual bool SendPackets(const PacketList& packets) OVERRIDE;
+ virtual bool SendPacket(const Packet& packet) OVERRIDE;
+
+ private:
+ void ReceiveOnePacket();
+ void OnReceived(int result);
+ void OnSent(const scoped_refptr<net::IOBuffer>& buf, int result);
+
+ scoped_refptr<base::TaskRunner> io_thread_proxy_;
+ net::IPEndPoint local_addr_;
+ net::IPEndPoint remote_addr_;
+ scoped_ptr<net::UDPServerSocket> udp_socket_;
+ scoped_refptr<net::IOBuffer> recv_buf_;
+ net::IPEndPoint recv_addr_;
+ PacketReceiver* packet_receiver_;
+ base::WeakPtrFactory<UdpTransport> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(UdpTransport);
+};
+
+} // namespace transport
+} // namespace cast
+} // namespace media
+
+#endif // MEDIA_CAST_TRANSPORT_TRANSPORT_UDP_TRANSPORT_H_
« no previous file with comments | « media/cast/transport/transport/transport.cc ('k') | media/cast/transport/transport/udp_transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698