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

Side by Side Diff: remoting/protocol/webrtc_data_stream_adapter.h

Issue 2146213002: Add support for dynamic channels in WebrtcTransport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_ 5 #ifndef REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_
6 #define REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_ 6 #define REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 10 matching lines...) Expand all
21 21
22 namespace remoting { 22 namespace remoting {
23 namespace protocol { 23 namespace protocol {
24 24
25 // WebrtcDataStreamAdapter is a MessageChannelFactory that creates channels that 25 // WebrtcDataStreamAdapter is a MessageChannelFactory that creates channels that
26 // send and receive messages over PeerConnection data channels. 26 // send and receive messages over PeerConnection data channels.
27 class WebrtcDataStreamAdapter : public MessageChannelFactory { 27 class WebrtcDataStreamAdapter : public MessageChannelFactory {
28 public: 28 public:
29 typedef base::Callback<void(ErrorCode)> ErrorCallback; 29 typedef base::Callback<void(ErrorCode)> ErrorCallback;
30 30
31 explicit WebrtcDataStreamAdapter(bool outgoing, 31 explicit WebrtcDataStreamAdapter(const ErrorCallback& error_callback);
32 const ErrorCallback& error_callback);
33 ~WebrtcDataStreamAdapter() override; 32 ~WebrtcDataStreamAdapter() override;
34 33
35 // Initializes the adapter for |peer_connection|. If |outgoing| is set to true 34 // Initializes the adapter for |peer_connection|. If |outgoing| is set to true
36 // all channels will be created as outgoing. Otherwise CreateChannel() will 35 // all channels will be created as outgoing. Otherwise CreateChannel() will
37 // wait for the other end to create connection. 36 // wait for the other end to create connection.
38 void Initialize( 37 void Initialize(
39 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection); 38 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection);
40 39
41 // Called by WebrtcTransport. 40 // Called by WebrtcTransport.
42 void OnIncomingDataChannel(webrtc::DataChannelInterface* data_channel); 41 void WrapIncomingDataChannel(
42 rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel,
43 const ChannelCreatedCallback& callback);
43 44
44 // MessageChannelFactory interface. 45 // MessageChannelFactory interface.
45 void CreateChannel(const std::string& name, 46 void CreateChannel(const std::string& name,
46 const ChannelCreatedCallback& callback) override; 47 const ChannelCreatedCallback& callback) override;
47 void CancelChannelCreation(const std::string& name) override; 48 void CancelChannelCreation(const std::string& name) override;
48 49
49 private: 50 private:
50 class Channel; 51 class Channel;
51 friend class Channel; 52 friend class Channel;
52 53
53 struct PendingChannel; 54 struct PendingChannel;
54 55
56 void AddPendingChannel(
57 rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel,
58 const ChannelCreatedCallback& callback);
59
55 void OnChannelConnected(Channel* channel); 60 void OnChannelConnected(Channel* channel);
56 void OnChannelError(); 61 void OnChannelError();
57 62
58 const bool outgoing_;
59 ErrorCallback error_callback_; 63 ErrorCallback error_callback_;
60 64
61 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; 65 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
62 66
63 std::map<std::string, PendingChannel> pending_channels_; 67 std::map<std::string, PendingChannel> pending_channels_;
64 68
65 base::WeakPtrFactory<WebrtcDataStreamAdapter> weak_factory_; 69 base::WeakPtrFactory<WebrtcDataStreamAdapter> weak_factory_;
66 70
67 DISALLOW_COPY_AND_ASSIGN(WebrtcDataStreamAdapter); 71 DISALLOW_COPY_AND_ASSIGN(WebrtcDataStreamAdapter);
68 }; 72 };
69 73
70 } // namespace protocol 74 } // namespace protocol
71 } // namespace remoting 75 } // namespace remoting
72 76
73 #endif // REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_ 77 #endif // REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698