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

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

Issue 1846893002: Interface with webrtc through encoded frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed sergeyu comments and rebased Created 4 years, 8 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_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 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 #include "crypto/hmac.h" 17 #include "crypto/hmac.h"
17 #include "remoting/protocol/transport.h" 18 #include "remoting/protocol/transport.h"
18 #include "remoting/protocol/webrtc_data_stream_adapter.h" 19 #include "remoting/protocol/webrtc_data_stream_adapter.h"
20 #include "remoting/protocol/webrtc_video_encoder.h"
19 #include "remoting/signaling/signal_strategy.h" 21 #include "remoting/signaling/signal_strategy.h"
20 #include "third_party/webrtc/api/peerconnectioninterface.h" 22 #include "third_party/webrtc/api/peerconnectioninterface.h"
21 23
22 namespace webrtc { 24 namespace webrtc {
23 class FakeAudioDeviceModule; 25 class FakeAudioDeviceModule;
24 } // namespace webrtc 26 } // namespace webrtc
25 27
26 namespace remoting { 28 namespace remoting {
27 namespace protocol { 29 namespace protocol {
28 30
(...skipping 30 matching lines...) Expand all
59 scoped_refptr<TransportContext> transport_context, 61 scoped_refptr<TransportContext> transport_context,
60 EventHandler* event_handler); 62 EventHandler* event_handler);
61 ~WebrtcTransport() override; 63 ~WebrtcTransport() override;
62 64
63 webrtc::PeerConnectionInterface* peer_connection() { 65 webrtc::PeerConnectionInterface* peer_connection() {
64 return peer_connection_; 66 return peer_connection_;
65 } 67 }
66 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { 68 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() {
67 return peer_connection_factory_; 69 return peer_connection_factory_;
68 } 70 }
71 remoting::WebRtcVideoEncoderFactory* video_encoder_factory() {
72 return video_encoder_factory_;
73 }
69 74
70 // Factories for outgoing and incoming data channels. Must be used only after 75 // Factories for outgoing and incoming data channels. Must be used only after
71 // the transport is connected. 76 // the transport is connected.
72 MessageChannelFactory* outgoing_channel_factory() { 77 MessageChannelFactory* outgoing_channel_factory() {
73 return &outgoing_data_stream_adapter_; 78 return &outgoing_data_stream_adapter_;
74 } 79 }
75 MessageChannelFactory* incoming_channel_factory() { 80 MessageChannelFactory* incoming_channel_factory() {
76 return &incoming_data_stream_adapter_; 81 return &incoming_data_stream_adapter_;
77 } 82 }
78 83
79 // Transport interface. 84 // Transport interface.
80 void Start(Authenticator* authenticator, 85 void Start(Authenticator* authenticator,
81 SendTransportInfoCallback send_transport_info_callback) override; 86 SendTransportInfoCallback send_transport_info_callback) override;
82 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; 87 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override;
88 void Close(ErrorCode error);
83 89
84 private: 90 private:
85 void OnLocalSessionDescriptionCreated( 91 void OnLocalSessionDescriptionCreated(
86 std::unique_ptr<webrtc::SessionDescriptionInterface> description, 92 std::unique_ptr<webrtc::SessionDescriptionInterface> description,
87 const std::string& error); 93 const std::string& error);
88 void OnLocalDescriptionSet(bool success, const std::string& error); 94 void OnLocalDescriptionSet(bool success, const std::string& error);
89 void OnRemoteDescriptionSet(bool send_answer, 95 void OnRemoteDescriptionSet(bool send_answer,
90 bool success, 96 bool success,
91 const std::string& error); 97 const std::string& error);
92 98
93 // webrtc::PeerConnectionObserver interface. 99 // webrtc::PeerConnectionObserver interface.
94 void OnSignalingChange( 100 void OnSignalingChange(
95 webrtc::PeerConnectionInterface::SignalingState new_state) override; 101 webrtc::PeerConnectionInterface::SignalingState new_state) override;
96 void OnAddStream(webrtc::MediaStreamInterface* stream) override; 102 void OnAddStream(webrtc::MediaStreamInterface* stream) override;
97 void OnRemoveStream(webrtc::MediaStreamInterface* stream) override; 103 void OnRemoveStream(webrtc::MediaStreamInterface* stream) override;
98 void OnDataChannel(webrtc::DataChannelInterface* data_channel) override; 104 void OnDataChannel(webrtc::DataChannelInterface* data_channel) override;
99 void OnRenegotiationNeeded() override; 105 void OnRenegotiationNeeded() override;
100 void OnIceConnectionChange( 106 void OnIceConnectionChange(
101 webrtc::PeerConnectionInterface::IceConnectionState new_state) override; 107 webrtc::PeerConnectionInterface::IceConnectionState new_state) override;
102 void OnIceGatheringChange( 108 void OnIceGatheringChange(
103 webrtc::PeerConnectionInterface::IceGatheringState new_state) override; 109 webrtc::PeerConnectionInterface::IceGatheringState new_state) override;
104 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override; 110 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
105 111
106 void RequestNegotiation(); 112 void RequestNegotiation();
107 void SendOffer(); 113 void SendOffer();
108 void EnsurePendingTransportInfoMessage(); 114 void EnsurePendingTransportInfoMessage();
109 void SendTransportInfo(); 115 void SendTransportInfo();
110 void AddPendingCandidatesIfPossible(); 116 void AddPendingCandidatesIfPossible();
111 117
112 void Close(ErrorCode error);
113
114 base::ThreadChecker thread_checker_; 118 base::ThreadChecker thread_checker_;
115 119
116 rtc::Thread* worker_thread_; 120 rtc::Thread* worker_thread_;
117 scoped_refptr<TransportContext> transport_context_; 121 scoped_refptr<TransportContext> transport_context_;
118 EventHandler* event_handler_ = nullptr; 122 EventHandler* event_handler_ = nullptr;
119 SendTransportInfoCallback send_transport_info_callback_; 123 SendTransportInfoCallback send_transport_info_callback_;
120 124
121 crypto::HMAC handshake_hmac_; 125 crypto::HMAC handshake_hmac_;
122 126
123 std::unique_ptr<webrtc::FakeAudioDeviceModule> fake_audio_device_module_; 127 std::unique_ptr<webrtc::FakeAudioDeviceModule> fake_audio_device_module_;
124 128
125 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> 129 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
126 peer_connection_factory_; 130 peer_connection_factory_;
127 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; 131 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
128 132
133 remoting::WebRtcVideoEncoderFactory* video_encoder_factory_;
134
129 bool negotiation_pending_ = false; 135 bool negotiation_pending_ = false;
130 136
131 bool connected_ = false; 137 bool connected_ = false;
132 138
133 std::unique_ptr<buzz::XmlElement> pending_transport_info_message_; 139 std::unique_ptr<buzz::XmlElement> pending_transport_info_message_;
134 base::OneShotTimer transport_info_timer_; 140 base::OneShotTimer transport_info_timer_;
135 141
136 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_; 142 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_;
137 143
138 WebrtcDataStreamAdapter outgoing_data_stream_adapter_; 144 WebrtcDataStreamAdapter outgoing_data_stream_adapter_;
139 WebrtcDataStreamAdapter incoming_data_stream_adapter_; 145 WebrtcDataStreamAdapter incoming_data_stream_adapter_;
140 146
141 base::WeakPtrFactory<WebrtcTransport> weak_factory_; 147 base::WeakPtrFactory<WebrtcTransport> weak_factory_;
142 148
143 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport); 149 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport);
144 }; 150 };
145 151
146 } // namespace protocol 152 } // namespace protocol
147 } // namespace remoting 153 } // namespace remoting
148 154
149 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ 155 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698