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

Side by Side Diff: remoting/protocol/webrtc_transport.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
« no previous file with comments | « remoting/protocol/webrtc_data_stream_adapter.cc ('k') | remoting/protocol/webrtc_transport.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_TRANSPORT_H_ 5 #ifndef REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
6 #define REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ 6 #define REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 12 matching lines...) Expand all
23 23
24 namespace webrtc { 24 namespace webrtc {
25 class FakeAudioDeviceModule; 25 class FakeAudioDeviceModule;
26 } // namespace webrtc 26 } // namespace webrtc
27 27
28 namespace remoting { 28 namespace remoting {
29 namespace protocol { 29 namespace protocol {
30 30
31 class TransportContext; 31 class TransportContext;
32 class MessageChannelFactory; 32 class MessageChannelFactory;
33 class MessagePipe;
33 34
34 class WebrtcTransport : public Transport, 35 class WebrtcTransport : public Transport,
35 public webrtc::PeerConnectionObserver { 36 public webrtc::PeerConnectionObserver {
36 public: 37 public:
37 class EventHandler { 38 class EventHandler {
38 public: 39 public:
39 // Called after |peer_connection| has been created but before handshake. The 40 // Called after |peer_connection| has been created but before handshake. The
40 // handler should create data channels and media streams. Renegotiation will 41 // handler should create data channels and media streams. Renegotiation will
41 // be required in two cases after this method returns: 42 // be required in two cases after this method returns:
42 // 1. When the first data channel is created, if it wasn't created by this 43 // 1. When the first data channel is created, if it wasn't created by this
43 // event handler. 44 // event handler.
44 // 2. Whenever a media stream is added or removed. 45 // 2. Whenever a media stream is added or removed.
45 virtual void OnWebrtcTransportConnecting() = 0; 46 virtual void OnWebrtcTransportConnecting() = 0;
46 47
47 // Called when the transport is connected. 48 // Called when the transport is connected.
48 virtual void OnWebrtcTransportConnected() = 0; 49 virtual void OnWebrtcTransportConnected() = 0;
49 50
50 // Called when there is an error connecting the session. 51 // Called when there is an error connecting the session.
51 virtual void OnWebrtcTransportError(ErrorCode error) = 0; 52 virtual void OnWebrtcTransportError(ErrorCode error) = 0;
52 53
54 // Called when a new data channel is created by the peer.
55 virtual void OnWebrtcTransportIncomingDataChannel(
56 const std::string& name,
57 std::unique_ptr<MessagePipe> pipe) = 0;
58
53 // Called when an incoming media stream is added or removed. 59 // Called when an incoming media stream is added or removed.
54 virtual void OnWebrtcTransportMediaStreamAdded( 60 virtual void OnWebrtcTransportMediaStreamAdded(
55 scoped_refptr<webrtc::MediaStreamInterface> stream) = 0; 61 scoped_refptr<webrtc::MediaStreamInterface> stream) = 0;
56 virtual void OnWebrtcTransportMediaStreamRemoved( 62 virtual void OnWebrtcTransportMediaStreamRemoved(
57 scoped_refptr<webrtc::MediaStreamInterface> stream) = 0; 63 scoped_refptr<webrtc::MediaStreamInterface> stream) = 0;
64
65 protected:
66 virtual ~EventHandler() {}
58 }; 67 };
59 68
60 WebrtcTransport(rtc::Thread* worker_thread, 69 WebrtcTransport(rtc::Thread* worker_thread,
61 scoped_refptr<TransportContext> transport_context, 70 scoped_refptr<TransportContext> transport_context,
62 EventHandler* event_handler); 71 EventHandler* event_handler);
63 ~WebrtcTransport() override; 72 ~WebrtcTransport() override;
64 73
65 webrtc::PeerConnectionInterface* peer_connection() { 74 webrtc::PeerConnectionInterface* peer_connection() {
66 return peer_connection_; 75 return peer_connection_;
67 } 76 }
68 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { 77 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() {
69 return peer_connection_factory_; 78 return peer_connection_factory_;
70 } 79 }
71 remoting::WebrtcVideoEncoderFactory* video_encoder_factory() { 80 remoting::WebrtcVideoEncoderFactory* video_encoder_factory() {
72 return video_encoder_factory_; 81 return video_encoder_factory_;
73 } 82 }
74 83
75 // Factories for outgoing and incoming data channels. Must be used only after 84 // Factory for outgoing data channels. Must be used only after the transport
76 // the transport is connected. 85 // is connected.
77 MessageChannelFactory* outgoing_channel_factory() { 86 MessageChannelFactory* outgoing_channel_factory() {
78 return &outgoing_data_stream_adapter_; 87 return data_stream_adapter_.get();
79 }
80 MessageChannelFactory* incoming_channel_factory() {
81 return &incoming_data_stream_adapter_;
82 } 88 }
83 89
84 // Transport interface. 90 // Transport interface.
85 void Start(Authenticator* authenticator, 91 void Start(Authenticator* authenticator,
86 SendTransportInfoCallback send_transport_info_callback) override; 92 SendTransportInfoCallback send_transport_info_callback) override;
87 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; 93 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override;
88 void Close(ErrorCode error); 94 void Close(ErrorCode error);
89 95
90 private: 96 private:
91 void OnLocalSessionDescriptionCreated( 97 void OnLocalSessionDescriptionCreated(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 143
138 bool negotiation_pending_ = false; 144 bool negotiation_pending_ = false;
139 145
140 bool connected_ = false; 146 bool connected_ = false;
141 147
142 std::unique_ptr<buzz::XmlElement> pending_transport_info_message_; 148 std::unique_ptr<buzz::XmlElement> pending_transport_info_message_;
143 base::OneShotTimer transport_info_timer_; 149 base::OneShotTimer transport_info_timer_;
144 150
145 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_; 151 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_;
146 152
147 WebrtcDataStreamAdapter outgoing_data_stream_adapter_; 153 std::unique_ptr<WebrtcDataStreamAdapter> data_stream_adapter_;
148 WebrtcDataStreamAdapter incoming_data_stream_adapter_;
149 154
150 base::WeakPtrFactory<WebrtcTransport> weak_factory_; 155 base::WeakPtrFactory<WebrtcTransport> weak_factory_;
151 156
152 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport); 157 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport);
153 }; 158 };
154 159
155 } // namespace protocol 160 } // namespace protocol
156 } // namespace remoting 161 } // namespace remoting
157 162
158 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ 163 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
OLDNEW
« no previous file with comments | « remoting/protocol/webrtc_data_stream_adapter.cc ('k') | remoting/protocol/webrtc_transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698