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/public/common/p2p_socket_type.h" | 9 #include "content/public/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 { |
| 22 struct PacketOptions; |
| 23 } |
| 24 |
21 namespace content { | 25 namespace content { |
22 class P2PMessageThrottler; | 26 class P2PMessageThrottler; |
23 | 27 |
24 // Base class for P2P sockets. | 28 // Base class for P2P sockets. |
25 class CONTENT_EXPORT P2PSocketHost { | 29 class CONTENT_EXPORT P2PSocketHost { |
26 public: | 30 public: |
27 static const int kStunHeaderSize = 20; | 31 static const int kStunHeaderSize = 20; |
28 // Creates P2PSocketHost of the specific type. | 32 // Creates P2PSocketHost of the specific type. |
29 static P2PSocketHost* Create(IPC::Sender* message_sender, | 33 static P2PSocketHost* Create(IPC::Sender* message_sender, |
30 int id, P2PSocketType type, | 34 int id, P2PSocketType type, |
(...skipping 11 matching lines...) Expand all Loading... |
42 const std::vector<char>& data, | 46 const std::vector<char>& data, |
43 net::DiffServCodePoint dscp, | 47 net::DiffServCodePoint dscp, |
44 uint64 packet_id) = 0; | 48 uint64 packet_id) = 0; |
45 | 49 |
46 virtual P2PSocketHost* AcceptIncomingTcpConnection( | 50 virtual P2PSocketHost* AcceptIncomingTcpConnection( |
47 const net::IPEndPoint& remote_address, int id) = 0; | 51 const net::IPEndPoint& remote_address, int id) = 0; |
48 | 52 |
49 virtual bool SetOption(P2PSocketOption option, int value) = 0; | 53 virtual bool SetOption(P2PSocketOption option, int value) = 0; |
50 | 54 |
51 protected: | 55 protected: |
| 56 void MaybeUpdateRtpSendTimeExtn(char* data, int length, |
| 57 const talk_base::PacketOptions& options); |
| 58 |
52 friend class P2PSocketHostTcpTestBase; | 59 friend class P2PSocketHostTcpTestBase; |
53 | 60 |
54 // TODO(mallinath) - Remove this below enum and use one defined in | 61 // TODO(mallinath) - Remove this below enum and use one defined in |
55 // libjingle/souce/talk/p2p/base/stun.h | 62 // libjingle/souce/talk/p2p/base/stun.h |
56 enum StunMessageType { | 63 enum StunMessageType { |
57 STUN_BINDING_REQUEST = 0x0001, | 64 STUN_BINDING_REQUEST = 0x0001, |
58 STUN_BINDING_RESPONSE = 0x0101, | 65 STUN_BINDING_RESPONSE = 0x0101, |
59 STUN_BINDING_ERROR_RESPONSE = 0x0111, | 66 STUN_BINDING_ERROR_RESPONSE = 0x0111, |
60 STUN_SHARED_SECRET_REQUEST = 0x0002, | 67 STUN_SHARED_SECRET_REQUEST = 0x0002, |
61 STUN_SHARED_SECRET_RESPONSE = 0x0102, | 68 STUN_SHARED_SECRET_RESPONSE = 0x0102, |
(...skipping 24 matching lines...) Expand all Loading... |
86 }; | 93 }; |
87 | 94 |
88 P2PSocketHost(IPC::Sender* message_sender, int id); | 95 P2PSocketHost(IPC::Sender* message_sender, int id); |
89 | 96 |
90 // Verifies that the packet |data| has a valid STUN header. In case | 97 // Verifies that the packet |data| has a valid STUN header. In case |
91 // of success stores type of the message in |type|. | 98 // of success stores type of the message in |type|. |
92 static bool GetStunPacketType(const char* data, int data_size, | 99 static bool GetStunPacketType(const char* data, int data_size, |
93 StunMessageType* type); | 100 StunMessageType* type); |
94 static bool IsRequestOrResponse(StunMessageType type); | 101 static bool IsRequestOrResponse(StunMessageType type); |
95 | 102 |
| 103 bool FindAndUpdateRtpAbsSendTimeExtension( |
| 104 char* data, int len, const talk_base::PacketOptions& options); |
| 105 void UpdateRtpAbsSendTimeExtension(char* data, int len); |
| 106 |
| 107 void UpdateHmac(char* packet, int len, |
| 108 const talk_base::PacketOptions& options); |
| 109 |
96 IPC::Sender* message_sender_; | 110 IPC::Sender* message_sender_; |
97 int id_; | 111 int id_; |
98 State state_; | 112 State state_; |
99 | 113 |
100 DISALLOW_COPY_AND_ASSIGN(P2PSocketHost); | 114 DISALLOW_COPY_AND_ASSIGN(P2PSocketHost); |
101 }; | 115 }; |
102 | 116 |
103 } // namespace content | 117 } // namespace content |
104 | 118 |
105 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ | 119 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ |
OLD | NEW |