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

Unified Diff: remoting/protocol/webrtc_transport.h

Issue 1427003009: Implement WebrtcTransport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@transport_session.h
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/webrtc_transport.h
diff --git a/remoting/protocol/webrtc_transport.h b/remoting/protocol/webrtc_transport.h
new file mode 100644
index 0000000000000000000000000000000000000000..cbc6458d8bc550c2aa9ebf0a118ecb19a0b4a004
--- /dev/null
+++ b/remoting/protocol/webrtc_transport.h
@@ -0,0 +1,124 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
+#define REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread.h"
+#include "base/threading/thread_checker.h"
+#include "base/timer/timer.h"
+#include "remoting/protocol/transport.h"
+#include "remoting/signaling/signal_strategy.h"
+#include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h"
+
+namespace webrtc {
+class FakeAudioDeviceModule;
+} // namespace webrtc
+
+namespace remoting {
+namespace protocol {
+
+class WebrtcTransport : public Transport,
+ public webrtc::PeerConnectionObserver {
+ public:
+ WebrtcTransport(
+ rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
+ port_allocator_factory,
+ TransportRole role,
+ scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner);
+ ~WebrtcTransport() override;
+
+ // Transport interface.
+ void Start(EventHandler* event_handler,
+ Authenticator* authenticator) override;
+ bool ProcessTransportInfo(buzz::XmlElement* transport_info) override;
+ DatagramChannelFactory* GetDatagramChannelFactory() override;
+ StreamChannelFactory* GetStreamChannelFactory() override;
+ StreamChannelFactory* GetMultiplexedChannelFactory() override;
+
+ private:
+ void DoStart(rtc::Thread* worker_thread);
+ void OnLocalSessionDescriptionCreated(
+ scoped_ptr<webrtc::SessionDescriptionInterface> description,
+ const std::string& error);
+ void OnLocalDescriptionSet(bool success, const std::string& error);
+ void OnRemoteDescriptionSet(bool success, const std::string& error);
+
+ // webrtc::PeerConnectionObserver interface.
+ void OnSignalingChange(
+ webrtc::PeerConnectionInterface::SignalingState new_state) override;
+ void OnAddStream(webrtc::MediaStreamInterface* stream) override;
+ void OnRemoveStream(webrtc::MediaStreamInterface* stream) override;
+ void OnDataChannel(webrtc::DataChannelInterface* data_channel) override;
+ void OnRenegotiationNeeded() override;
+ void OnIceConnectionChange(
+ webrtc::PeerConnectionInterface::IceConnectionState new_state) override;
+ void OnIceGatheringChange(
+ webrtc::PeerConnectionInterface::IceGatheringState new_state) override;
+ void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
+
+ void EnsurePendingTransportInfoMessage();
+ void SendTransportInfo();
+ void AddPendingCandidatesIfPossible();
+
+ void Close(ErrorCode error);
+
+ base::ThreadChecker thread_checker_;
+
+ rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
+ port_allocator_factory_;
+ TransportRole role_;
+ EventHandler* event_handler_ = nullptr;
+ scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_;
+
+ scoped_ptr<webrtc::FakeAudioDeviceModule> fake_audio_device_module_;
+
+ rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
+ peer_connection_factory_;
+ rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
+
+ scoped_ptr<buzz::XmlElement> pending_transport_info_message_;
+ base::OneShotTimer transport_info_timer_;
+
+ ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_;
+
+ std::list<rtc::scoped_refptr<webrtc::MediaStreamInterface>>
+ unclaimed_streams_;
+
+ base::WeakPtrFactory<WebrtcTransport> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebrtcTransport);
+};
+
+class WebrtcTransportFactory : public TransportFactory {
+ public:
+ WebrtcTransportFactory(
+ SignalStrategy* signal_strategy,
+ rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
+ port_allocator_factory,
+ TransportRole role);
+ ~WebrtcTransportFactory() override;
+
+ // TransportFactory interface.
+ scoped_ptr<Transport> CreateTransport() override;
+
+ private:
+ SignalStrategy* signal_strategy_;
+ rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
+ port_allocator_factory_;
+ TransportRole role_;
+
+ base::Thread worker_thread_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebrtcTransportFactory);
+};
+
+} // namespace protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_

Powered by Google App Engine
This is Rietveld 408576698