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

Side by Side Diff: webrtc/ortc/ortcfactory.h

Issue 2675173003: Adding "adapter" ORTC objects on top of ChannelManager/BaseChannel/etc. (Closed)
Patch Set: Add memcheck suppression for end-to-end tests. Created 3 years, 10 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 | « webrtc/ortc/dummy_test.cc ('k') | webrtc/ortc/ortcfactory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_ORTC_ORTCFACTORY_H_
12 #define WEBRTC_ORTC_ORTCFACTORY_H_
13
14 #include <memory>
15 #include <string>
16
17 #include "webrtc/api/ortc/ortcfactoryinterface.h"
18 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/base/scoped_ref_ptr.h"
20 #include "webrtc/media/base/mediaengine.h"
21 #include "webrtc/media/engine/webrtcmediaengine.h"
22 #include "webrtc/pc/channelmanager.h"
23
24 namespace webrtc {
25
26 // Implementation of OrtcFactoryInterface.
27 //
28 // See ortcfactoryinterface.h for documentation.
29 class OrtcFactory : public OrtcFactoryInterface {
30 public:
31 ~OrtcFactory() override;
32
33 // Internal-only Create method that allows passing in a fake media engine,
34 // for testing.
35 static RTCErrorOr<std::unique_ptr<OrtcFactoryInterface>> Create(
36 rtc::Thread* network_thread,
37 rtc::Thread* signaling_thread,
38 rtc::NetworkManager* network_manager,
39 rtc::PacketSocketFactory* socket_factory,
40 AudioDeviceModule* adm,
41 std::unique_ptr<cricket::MediaEngineInterface> media_engine);
42
43 RTCErrorOr<std::unique_ptr<RtpTransportControllerInterface>>
44 CreateRtpTransportController() override;
45
46 RTCErrorOr<std::unique_ptr<RtpTransportInterface>> CreateRtpTransport(
47 const RtcpParameters& rtcp_parameters,
48 PacketTransportInterface* rtp,
49 PacketTransportInterface* rtcp,
50 RtpTransportControllerInterface* transport_controller) override;
51
52 RtpCapabilities GetRtpSenderCapabilities(
53 cricket::MediaType kind) const override;
54
55 RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> CreateRtpSender(
56 rtc::scoped_refptr<MediaStreamTrackInterface> track,
57 RtpTransportInterface* transport) override;
58
59 RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> CreateRtpSender(
60 cricket::MediaType kind,
61 RtpTransportInterface* transport) override;
62
63 RtpCapabilities GetRtpReceiverCapabilities(
64 cricket::MediaType kind) const override;
65
66 RTCErrorOr<std::unique_ptr<OrtcRtpReceiverInterface>> CreateRtpReceiver(
67 cricket::MediaType kind,
68 RtpTransportInterface* transport) override;
69
70 RTCErrorOr<std::unique_ptr<UdpTransportInterface>>
71 CreateUdpTransport(int family, uint16_t min_port, uint16_t max_port) override;
72
73 rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
74 const cricket::AudioOptions& options) override;
75
76 rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
77 std::unique_ptr<cricket::VideoCapturer> capturer,
78 const MediaConstraintsInterface* constraints) override;
79
80 rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
81 const std::string& id,
82 VideoTrackSourceInterface* source) override;
83
84 rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack(
85 const std::string& id,
86 AudioSourceInterface* source) override;
87
88 rtc::Thread* network_thread() { return network_thread_; }
89 rtc::Thread* worker_thread() { return worker_thread_.get(); }
90 rtc::Thread* signaling_thread() { return signaling_thread_; }
91
92 private:
93 // Should only be called by OrtcFactoryInterface::Create.
94 OrtcFactory(rtc::Thread* network_thread,
95 rtc::Thread* signaling_thread,
96 rtc::NetworkManager* network_manager,
97 rtc::PacketSocketFactory* socket_factory,
98 AudioDeviceModule* adm);
99
100 // Thread::Invoke doesn't support move-only arguments, so we need to remove
101 // the unique_ptr wrapper from media_engine. TODO(deadbeef): Fix this.
102 static RTCErrorOr<std::unique_ptr<OrtcFactoryInterface>> Create_s(
103 rtc::Thread* network_thread,
104 rtc::Thread* signaling_thread,
105 rtc::NetworkManager* network_manager,
106 rtc::PacketSocketFactory* socket_factory,
107 AudioDeviceModule* adm,
108 cricket::MediaEngineInterface* media_engine);
109
110 // Performs initialization that can fail. Called by factory method after
111 // construction, and if it fails, no object is returned.
112 RTCError Initialize(
113 std::unique_ptr<cricket::MediaEngineInterface> media_engine);
114 std::unique_ptr<cricket::MediaEngineInterface> CreateMediaEngine_w();
115
116 // Threads and networking objects.
117 rtc::Thread* network_thread_;
118 rtc::Thread* signaling_thread_;
119 rtc::NetworkManager* network_manager_;
120 rtc::PacketSocketFactory* socket_factory_;
121 AudioDeviceModule* adm_;
122 // If we created/own the objects above, these will be non-null and thus will
123 // be released automatically upon destruction.
124 std::unique_ptr<rtc::Thread> owned_network_thread_;
125 bool wraps_signaling_thread_ = false;
126 std::unique_ptr<rtc::NetworkManager> owned_network_manager_;
127 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_;
128 // We always own the worker thread.
129 std::unique_ptr<rtc::Thread> worker_thread_;
130 // Media-releated objects.
131 std::unique_ptr<RtcEventLog> null_event_log_;
132 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory_;
133 std::unique_ptr<cricket::ChannelManager> channel_manager_;
134 // Default CNAME to use for RtpTransports if none is passed in.
135 std::string default_cname_;
136
137 friend class OrtcFactoryInterface;
138
139 RTC_DISALLOW_COPY_AND_ASSIGN(OrtcFactory);
140 };
141
142 } // namespace webrtc
143
144 #endif // WEBRTC_ORTC_ORTCFACTORY_H_
OLDNEW
« no previous file with comments | « webrtc/ortc/dummy_test.cc ('k') | webrtc/ortc/ortcfactory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698