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

Side by Side Diff: webrtc/api/ortc/ortcfactoryinterface.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, 9 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/api/mediatypes.cc ('k') | webrtc/api/ortc/ortcrtpreceiverinterface.h » ('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_API_ORTC_ORTCFACTORYINTERFACE_H_
12 #define WEBRTC_API_ORTC_ORTCFACTORYINTERFACE_H_
13
14 #include <memory>
15 #include <string>
16 #include <utility> // For std::move.
17
18 #include "webrtc/api/mediaconstraintsinterface.h"
19 #include "webrtc/api/mediastreaminterface.h"
20 #include "webrtc/api/mediatypes.h"
21 #include "webrtc/api/ortc/ortcrtpreceiverinterface.h"
22 #include "webrtc/api/ortc/ortcrtpsenderinterface.h"
23 #include "webrtc/api/ortc/packettransportinterface.h"
24 #include "webrtc/api/ortc/rtptransportcontrollerinterface.h"
25 #include "webrtc/api/ortc/rtptransportinterface.h"
26 #include "webrtc/api/ortc/udptransportinterface.h"
27 #include "webrtc/api/rtcerror.h"
28 #include "webrtc/api/rtpparameters.h"
29 #include "webrtc/base/network.h"
30 #include "webrtc/base/scoped_ref_ptr.h"
31 #include "webrtc/base/thread.h"
32 #include "webrtc/p2p/base/packetsocketfactory.h"
33
34 namespace webrtc {
35
36 // TODO(deadbeef): This should be part of /api/, but currently it's not and
37 // including its header violates checkdeps rules.
38 class AudioDeviceModule;
39
40 // WARNING: This is experimental/under development, so use at your own risk; no
41 // guarantee about API stability is guaranteed here yet.
42 //
43 // This class is the ORTC analog of PeerConnectionFactory. It acts as a factory
44 // for ORTC objects that can be connected to each other.
45 //
46 // Some of these objects may not be represented by the ORTC specification, but
47 // follow the same general principles.
48 //
49 // If one of the factory methods takes another object as an argument, it MUST
50 // have been created by the same OrtcFactory.
51 //
52 // On object lifetimes: objects should be destroyed in this order:
53 // 1. Objects created by the factory.
54 // 2. The factory itself.
55 // 3. Objects passed into OrtcFactoryInterface::Create.
56 class OrtcFactoryInterface {
57 public:
58 // |network_thread| is the thread on which packets are sent and received.
59 // If null, a new rtc::Thread with a default socket server is created.
60 //
61 // |signaling_thread| is used for callbacks to the consumer of the API. If
62 // null, the current thread will be used, which assumes that the API consumer
63 // is running a message loop on this thread (either using an existing
64 // rtc::Thread, or by calling rtc::Thread::Current()->ProcessMessages).
65 //
66 // |network_manager| is used to determine which network interfaces are
67 // available. This is used for ICE, for example. If null, a default
68 // implementation will be used. Only accessed on |network_thread|.
69 //
70 // |socket_factory| is used (on the network thread) for creating sockets. If
71 // it's null, a default implementation will be used, which assumes
72 // |network_thread| is a normal rtc::Thread.
73 //
74 // |adm| is optional, and allows a different audio device implementation to
75 // be injected; otherwise a platform-specific module will be used that will
76 // use the default audio input.
77 //
78 // Note that the OrtcFactoryInterface does not take ownership of any of the
79 // objects passed in, and as previously stated, these objects can't be
80 // destroyed before the factory is.
81 static RTCErrorOr<std::unique_ptr<OrtcFactoryInterface>> Create(
82 rtc::Thread* network_thread,
83 rtc::Thread* signaling_thread,
84 rtc::NetworkManager* network_manager,
85 rtc::PacketSocketFactory* socket_factory,
86 AudioDeviceModule* adm);
87
88 // Constructor for convenience which uses default implementations of
89 // everything (though does still require that the current thread runs a
90 // message loop; see above).
91 static RTCErrorOr<std::unique_ptr<OrtcFactoryInterface>> Create() {
92 return Create(nullptr, nullptr, nullptr, nullptr, nullptr);
93 }
94
95 virtual ~OrtcFactoryInterface() {}
96
97 // Creates an RTP transport controller, which is used in calls to
98 // CreateRtpTransport methods. If your application has some notion of a
99 // "call", you should create one transport controller per call.
100 //
101 // However, if you only are using one RtpTransport object, this doesn't need
102 // to be called explicitly; CreateRtpTransport will create one automatically
103 // if |rtp_transport_controller| is null. See below.
104 //
105 // TODO(deadbeef): Add MediaConfig and RtcEventLog arguments?
106 virtual RTCErrorOr<std::unique_ptr<RtpTransportControllerInterface>>
107 CreateRtpTransportController() = 0;
108
109 // Creates an RTP transport using the provided packet transports and
110 // transport controller.
111 //
112 // |rtp| will be used for sending RTP packets, and |rtcp| for RTCP packets.
113 //
114 // |rtp| can't be null. |rtcp| must be non-null if and only if
115 // |rtcp_parameters.mux| is false, indicating that RTCP muxing isn't used.
116 // Note that if RTCP muxing isn't enabled initially, it can still enabled
117 // later through SetRtcpParameters.
118 //
119 // If |transport_controller| is null, one will automatically be created, and
120 // its lifetime managed by the returned RtpTransport. This should only be
121 // done if a single RtpTransport is being used to communicate with the remote
122 // endpoint.
123 virtual RTCErrorOr<std::unique_ptr<RtpTransportInterface>> CreateRtpTransport(
124 const RtcpParameters& rtcp_parameters,
125 PacketTransportInterface* rtp,
126 PacketTransportInterface* rtcp,
127 RtpTransportControllerInterface* transport_controller) = 0;
128
129 // Returns the capabilities of an RTP sender of type |kind|. These
130 // capabilities can be used to determine what RtpParameters to use to create
131 // an RtpSender.
132 //
133 // If for some reason you pass in MEDIA_TYPE_DATA, returns an empty structure.
134 virtual RtpCapabilities GetRtpSenderCapabilities(
135 cricket::MediaType kind) const = 0;
136
137 // Creates an RTP sender with |track|. Will not start sending until Send is
138 // called. This is provided as a convenience; it's equivalent to calling
139 // CreateRtpSender with a kind (see below), followed by SetTrack.
140 //
141 // |track| and |transport| must not be null.
142 virtual RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> CreateRtpSender(
143 rtc::scoped_refptr<MediaStreamTrackInterface> track,
144 RtpTransportInterface* transport) = 0;
145
146 // Overload of CreateRtpSender allows creating the sender without a track.
147 //
148 // |kind| must be MEDIA_TYPE_AUDIO or MEDIA_TYPE_VIDEO.
149 virtual RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> CreateRtpSender(
150 cricket::MediaType kind,
151 RtpTransportInterface* transport) = 0;
152
153 // Returns the capabilities of an RTP receiver of type |kind|. These
154 // capabilities can be used to determine what RtpParameters to use to create
155 // an RtpReceiver.
156 //
157 // If for some reason you pass in MEDIA_TYPE_DATA, returns an empty structure.
158 virtual RtpCapabilities GetRtpReceiverCapabilities(
159 cricket::MediaType kind) const = 0;
160
161 // Creates an RTP receiver of type |kind|. Will not start receiving media
162 // until Receive is called.
163 //
164 // |kind| must be MEDIA_TYPE_AUDIO or MEDIA_TYPE_VIDEO.
165 //
166 // |transport| must not be null.
167 virtual RTCErrorOr<std::unique_ptr<OrtcRtpReceiverInterface>>
168 CreateRtpReceiver(cricket::MediaType kind,
169 RtpTransportInterface* transport) = 0;
170
171 // Create a UDP transport with IP address family |family|, using a port
172 // within the specified range.
173 //
174 // |family| must be AF_INET or AF_INET6.
175 //
176 // |min_port|/|max_port| values of 0 indicate no range restriction.
177 //
178 // Returns an error if the transport wasn't successfully created.
179 virtual RTCErrorOr<std::unique_ptr<UdpTransportInterface>>
180 CreateUdpTransport(int family, uint16_t min_port, uint16_t max_port) = 0;
181
182 // Method for convenience that has no port range restrictions.
183 RTCErrorOr<std::unique_ptr<UdpTransportInterface>> CreateUdpTransport(
184 int family) {
185 return CreateUdpTransport(family, 0, 0);
186 }
187
188 // NOTE: The methods below to create tracks/sources return scoped_refptrs
189 // rather than unique_ptrs, because these interfaces are also used with
190 // PeerConnection, where everything is ref-counted.
191
192 // Creates a audio source representing the default microphone input.
193 // |options| decides audio processing settings.
194 virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
195 const cricket::AudioOptions& options) = 0;
196
197 // Version of the above method that uses default options.
198 rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource() {
199 return CreateAudioSource(cricket::AudioOptions());
200 }
201
202 // Creates a video source object wrapping and taking ownership of |capturer|.
203 //
204 // |constraints| can be used for selection of resolution and frame rate, and
205 // may be null if no constraints are desired.
206 virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
207 std::unique_ptr<cricket::VideoCapturer> capturer,
208 const MediaConstraintsInterface* constraints) = 0;
209
210 // Version of the above method that omits |constraints|.
211 rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
212 std::unique_ptr<cricket::VideoCapturer> capturer) {
213 return CreateVideoSource(std::move(capturer), nullptr);
214 }
215
216 // Creates a new local video track wrapping |source|. The same |source| can
217 // be used in several tracks.
218 virtual rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
219 const std::string& id,
220 VideoTrackSourceInterface* source) = 0;
221
222 // Creates an new local audio track wrapping |source|.
223 virtual rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack(
224 const std::string& id,
225 AudioSourceInterface* source) = 0;
226 };
227
228 } // namespace webrtc
229
230 #endif // WEBRTC_API_ORTC_ORTCFACTORYINTERFACE_H_
OLDNEW
« no previous file with comments | « webrtc/api/mediatypes.cc ('k') | webrtc/api/ortc/ortcrtpreceiverinterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698