Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ |
| 7 | 7 |
| 8 #include "content/common/content_export.h" | 8 #include "content/common/content_export.h" |
| 9 #include "content/common/p2p_socket_type.h" | 9 #include "content/common/p2p_socket_type.h" |
| 10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
| 11 #include "net/udp/datagram_socket.h" | 11 #include "net/udp/datagram_socket.h" |
| 12 | 12 |
| 13 namespace IPC { | 13 namespace IPC { |
| 14 class Sender; | 14 class Sender; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 class URLRequestContextGetter; | 18 class URLRequestContextGetter; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace talk_base { | 21 namespace talk_base { |
| 22 struct PacketOptions; | 22 struct PacketOptions; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 class P2PMessageThrottler; | 26 class P2PMessageThrottler; |
| 27 | 27 |
| 28 namespace packet_processing_helpers { | |
| 29 | |
| 30 // This method can handle only RTP packet, otherwise this method must not be | |
| 31 // called. It will try to do, 1. update absolute send time extension header | |
| 32 // if present with current time and 2. update HMAC in RTP packet. | |
| 33 // If time_in_sec is 0, ApplyPacketOption will call get current time from | |
| 34 // system. | |
| 35 bool ApplyPacketOptions(char* data, int length, | |
| 36 const talk_base::PacketOptions& options, | |
| 37 uint64 time_in_sec); | |
|
Solis
2014/03/07 09:39:42
I'm sorry, but "time_in_sec" is wrong. This value
Mallinath (Gone from Chromium)
2014/03/07 22:17:22
That's very good point. Thanks.
On 2014/03/07 09:3
| |
| 38 | |
| 39 // Helper method which finds RTP ofset and length if the packet is encapsulated | |
| 40 // in a TURN Channel Message or TURN Send Indication message. | |
| 41 bool GetRtpPacketStartPositionAndLength(char* data, int length, | |
| 42 int* rtp_start_pos, | |
| 43 int* rtp_packet_length); | |
| 44 // Helper method which updates absoulute send time extension if present. | |
| 45 bool UpdateRtpAbsSendTimeExtn(char* rtp, int length, | |
| 46 int extension_id, uint64 time_in_sec); | |
| 47 | |
| 48 } // packet_processing_helpers | |
| 49 | |
| 28 // Base class for P2P sockets. | 50 // Base class for P2P sockets. |
| 29 class CONTENT_EXPORT P2PSocketHost { | 51 class CONTENT_EXPORT P2PSocketHost { |
| 30 public: | 52 public: |
| 31 static const int kStunHeaderSize = 20; | 53 static const int kStunHeaderSize = 20; |
| 32 // Creates P2PSocketHost of the specific type. | 54 // Creates P2PSocketHost of the specific type. |
| 33 static P2PSocketHost* Create(IPC::Sender* message_sender, | 55 static P2PSocketHost* Create(IPC::Sender* message_sender, |
| 34 int id, P2PSocketType type, | 56 int id, P2PSocketType type, |
| 35 net::URLRequestContextGetter* url_context, | 57 net::URLRequestContextGetter* url_context, |
| 36 P2PMessageThrottler* throttler); | 58 P2PMessageThrottler* throttler); |
| 37 | 59 |
| 38 virtual ~P2PSocketHost(); | 60 virtual ~P2PSocketHost(); |
| 39 | 61 |
| 40 // Initalizes the socket. Returns false when initiazations fails. | 62 // Initalizes the socket. Returns false when initiazations fails. |
| 41 virtual bool Init(const net::IPEndPoint& local_address, | 63 virtual bool Init(const net::IPEndPoint& local_address, |
| 42 const net::IPEndPoint& remote_address) = 0; | 64 const net::IPEndPoint& remote_address) = 0; |
| 43 | 65 |
| 44 // Sends |data| on the socket to |to|. | 66 // Sends |data| on the socket to |to|. |
| 45 virtual void Send(const net::IPEndPoint& to, | 67 virtual void Send(const net::IPEndPoint& to, |
| 46 const std::vector<char>& data, | 68 const std::vector<char>& data, |
| 47 const talk_base::PacketOptions& options, | 69 const talk_base::PacketOptions& options, |
| 48 uint64 packet_id) = 0; | 70 uint64 packet_id) = 0; |
| 49 | 71 |
| 50 virtual P2PSocketHost* AcceptIncomingTcpConnection( | 72 virtual P2PSocketHost* AcceptIncomingTcpConnection( |
| 51 const net::IPEndPoint& remote_address, int id) = 0; | 73 const net::IPEndPoint& remote_address, int id) = 0; |
| 52 | 74 |
| 53 virtual bool SetOption(P2PSocketOption option, int value) = 0; | 75 virtual bool SetOption(P2PSocketOption option, int value) = 0; |
| 54 | 76 |
| 55 protected: | 77 protected: |
| 56 friend class P2PSocketHostTcpTestBase; | |
| 57 | 78 |
| 58 // TODO(mallinath) - Remove this below enum and use one defined in | 79 // TODO(mallinath) - Remove this below enum and use one defined in |
| 59 // libjingle/souce/talk/p2p/base/stun.h | 80 // libjingle/souce/talk/p2p/base/stun.h |
| 60 enum StunMessageType { | 81 enum StunMessageType { |
| 61 STUN_BINDING_REQUEST = 0x0001, | 82 STUN_BINDING_REQUEST = 0x0001, |
| 62 STUN_BINDING_RESPONSE = 0x0101, | 83 STUN_BINDING_RESPONSE = 0x0101, |
| 63 STUN_BINDING_ERROR_RESPONSE = 0x0111, | 84 STUN_BINDING_ERROR_RESPONSE = 0x0111, |
| 64 STUN_SHARED_SECRET_REQUEST = 0x0002, | 85 STUN_SHARED_SECRET_REQUEST = 0x0002, |
| 65 STUN_SHARED_SECRET_RESPONSE = 0x0102, | 86 STUN_SHARED_SECRET_RESPONSE = 0x0102, |
| 66 STUN_SHARED_SECRET_ERROR_RESPONSE = 0x0112, | 87 STUN_SHARED_SECRET_ERROR_RESPONSE = 0x0112, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 IPC::Sender* message_sender_; | 121 IPC::Sender* message_sender_; |
| 101 int id_; | 122 int id_; |
| 102 State state_; | 123 State state_; |
| 103 | 124 |
| 104 DISALLOW_COPY_AND_ASSIGN(P2PSocketHost); | 125 DISALLOW_COPY_AND_ASSIGN(P2PSocketHost); |
| 105 }; | 126 }; |
| 106 | 127 |
| 107 } // namespace content | 128 } // namespace content |
| 108 | 129 |
| 109 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ | 130 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ |
| OLD | NEW |