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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
6 #define REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread.h"
13 #include "base/threading/thread_checker.h"
14 #include "base/timer/timer.h"
15 #include "remoting/protocol/transport.h"
16 #include "remoting/signaling/signal_strategy.h"
17 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h "
18
19 namespace webrtc {
20 class FakeAudioDeviceModule;
21 } // namespace webrtc
22
23 namespace remoting {
24 namespace protocol {
25
26 class WebrtcTransport : public Transport,
27 public webrtc::PeerConnectionObserver {
28 public:
29 WebrtcTransport(
30 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
31 port_allocator_factory,
32 TransportRole role,
33 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner);
34 ~WebrtcTransport() override;
35
36 // Transport interface.
37 void Start(EventHandler* event_handler,
38 Authenticator* authenticator) override;
39 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override;
40 DatagramChannelFactory* GetDatagramChannelFactory() override;
41 StreamChannelFactory* GetStreamChannelFactory() override;
42 StreamChannelFactory* GetMultiplexedChannelFactory() override;
43
44 private:
45 void DoStart(rtc::Thread* worker_thread);
46 void OnLocalSessionDescriptionCreated(
47 scoped_ptr<webrtc::SessionDescriptionInterface> description,
48 const std::string& error);
49 void OnLocalDescriptionSet(bool success, const std::string& error);
50 void OnRemoteDescriptionSet(bool success, const std::string& error);
51
52 // webrtc::PeerConnectionObserver interface.
53 void OnSignalingChange(
54 webrtc::PeerConnectionInterface::SignalingState new_state) override;
55 void OnAddStream(webrtc::MediaStreamInterface* stream) override;
56 void OnRemoveStream(webrtc::MediaStreamInterface* stream) override;
57 void OnDataChannel(webrtc::DataChannelInterface* data_channel) override;
58 void OnRenegotiationNeeded() override;
59 void OnIceConnectionChange(
60 webrtc::PeerConnectionInterface::IceConnectionState new_state) override;
61 void OnIceGatheringChange(
62 webrtc::PeerConnectionInterface::IceGatheringState new_state) override;
63 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
64
65 void EnsurePendingTransportInfoMessage();
66 void SendTransportInfo();
67 void AddPendingCandidatesIfPossible();
68
69 void Close(ErrorCode error);
70
71 base::ThreadChecker thread_checker_;
72
73 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
74 port_allocator_factory_;
75 TransportRole role_;
76 EventHandler* event_handler_ = nullptr;
77 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_;
78
79 scoped_ptr<webrtc::FakeAudioDeviceModule> fake_audio_device_module_;
80
81 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
82 peer_connection_factory_;
83 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
84
85 scoped_ptr<buzz::XmlElement> pending_transport_info_message_;
86 base::OneShotTimer transport_info_timer_;
87
88 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_;
89
90 std::list<rtc::scoped_refptr<webrtc::MediaStreamInterface>>
91 unclaimed_streams_;
92
93 base::WeakPtrFactory<WebrtcTransport> weak_factory_;
94
95 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport);
96 };
97
98 class WebrtcTransportFactory : public TransportFactory {
99 public:
100 WebrtcTransportFactory(
101 SignalStrategy* signal_strategy,
102 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
103 port_allocator_factory,
104 TransportRole role);
105 ~WebrtcTransportFactory() override;
106
107 // TransportFactory interface.
108 scoped_ptr<Transport> CreateTransport() override;
109
110 private:
111 SignalStrategy* signal_strategy_;
112 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
113 port_allocator_factory_;
114 TransportRole role_;
115
116 base::Thread worker_thread_;
117
118 DISALLOW_COPY_AND_ASSIGN(WebrtcTransportFactory);
119 };
120
121 } // namespace protocol
122 } // namespace remoting
123
124 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698