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

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

Issue 2172423002: Simplify WebrtcDataStreamAdapter (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 | « no previous file | remoting/protocol/webrtc_data_stream_adapter.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_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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "remoting/protocol/errors.h" 13 #include "remoting/protocol/message_pipe.h"
14 #include "remoting/protocol/message_channel_factory.h"
15 #include "third_party/webrtc/api/peerconnectioninterface.h" 14 #include "third_party/webrtc/api/peerconnectioninterface.h"
16 #include "third_party/webrtc/base/refcount.h" 15 #include "third_party/webrtc/base/refcount.h"
17 16
18 namespace rtc {
19 class PeerConnectionInterface;
20 } // namespace rtc
21
22 namespace remoting { 17 namespace remoting {
23 namespace protocol { 18 namespace protocol {
24 19
25 // WebrtcDataStreamAdapter wraps MessagePipe for WebRTC data channels. 20 // WebrtcDataStreamAdapter implements MessagePipe for WebRTC data channels.
26 class WebrtcDataStreamAdapter { 21 class WebrtcDataStreamAdapter : public MessagePipe,
22 public webrtc::DataChannelObserver {
27 public: 23 public:
28 typedef base::Callback<void(ErrorCode)> ErrorCallback; 24 explicit WebrtcDataStreamAdapter(
25 rtc::scoped_refptr<webrtc::DataChannelInterface> channel);
26 ~WebrtcDataStreamAdapter() override;
29 27
30 explicit WebrtcDataStreamAdapter( 28 std::string name() { return channel_->label(); }
31 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection);
32 ~WebrtcDataStreamAdapter();
33 29
34 // Creates outgoing data channel. 30 // MessagePipe interface.
35 std::unique_ptr<MessagePipe> CreateOutgoingChannel(const std::string& name); 31 void Start(EventHandler* event_handler) override;
36 32 void Send(google::protobuf::MessageLite* message,
37 // Creates incoming data channel. 33 const base::Closure& done) override;
38 std::unique_ptr<MessagePipe> WrapIncomingDataChannel(
39 rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel);
40 34
41 private: 35 private:
42 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; 36 enum class State { CONNECTING, OPEN, CLOSED };
37
38 // webrtc::DataChannelObserver interface.
39 void OnStateChange() override;
40 void OnMessage(const webrtc::DataBuffer& buffer) override;
Jamie 2016/07/25 18:25:59 These are public in the DataChannelObserver interf
Sergey Ulanov 2016/07/25 18:48:19 Putting this interface in private section makes it
41
42 void OnConnected();
43
44 void OnClosed();
45
46 rtc::scoped_refptr<webrtc::DataChannelInterface> channel_;
47
48 EventHandler* event_handler_ = nullptr;
49
50 State state_ = State::CONNECTING;
43 51
44 DISALLOW_COPY_AND_ASSIGN(WebrtcDataStreamAdapter); 52 DISALLOW_COPY_AND_ASSIGN(WebrtcDataStreamAdapter);
45 }; 53 };
46 54
47 } // namespace protocol 55 } // namespace protocol
48 } // namespace remoting 56 } // namespace remoting
49 57
50 #endif // REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_ 58 #endif // REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/protocol/webrtc_data_stream_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698