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

Unified Diff: webrtc/api/ortcfactoryinterface.h

Issue 2675173003: Adding "adapter" ORTC objects on top of ChannelManager/BaseChannel/etc. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/api/ortcfactoryinterface.h
diff --git a/webrtc/api/ortcfactoryinterface.h b/webrtc/api/ortcfactoryinterface.h
index 8d46d6865eb1e69b0422a751a74bd2818fc050f1..caaf8abfaf0e21f60a1c4a297ede01af1764d90d 100644
--- a/webrtc/api/ortcfactoryinterface.h
+++ b/webrtc/api/ortcfactoryinterface.h
@@ -13,13 +13,28 @@
#include <memory>
+#include "webrtc/api/mediaconstraintsinterface.h"
+#include "webrtc/api/mediastreaminterface.h"
+#include "webrtc/api/mediatypes.h"
+#include "webrtc/api/ortcrtpreceiverinterface.h"
+#include "webrtc/api/ortcrtpsenderinterface.h"
+#include "webrtc/api/packettransportinterface.h"
+#include "webrtc/api/rtcerror.h"
+#include "webrtc/api/rtpparameters.h"
+#include "webrtc/api/rtptransportcontrollerinterface.h"
+#include "webrtc/api/rtptransportinterface.h"
#include "webrtc/api/udptransportinterface.h"
#include "webrtc/base/network.h"
+#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/base/thread.h"
#include "webrtc/p2p/base/packetsocketfactory.h"
namespace webrtc {
+// TODO(deadbeef): This should be part of /api/, but currently it's not and
+// including its header violates checkdeps rules.
+class AudioDeviceModule;
+
// WARNING: This is experimental/under development, so use at your own risk; no
// guarantee about API stability is guaranteed here yet.
//
@@ -29,6 +44,9 @@ namespace webrtc {
// Some of these objects may not be represented by the ORTC specification, but
// follow the same general principles.
//
+// If one of the factory methods takes another object as an argument, it MUST
+// have been created by the same OrtcFactory.
+//
// On object lifetimes: The factory must not be destroyed before destroying the
// objects it created, and the objects passed into the factory must not be
// destroyed before destroying the factory.
@@ -50,28 +68,148 @@ class OrtcFactoryInterface {
// it's null, a default implementation will be used, which assumes
// |network_thread| is a normal rtc::Thread.
//
+ // |adm| is optional, and allows a different audio device implementation to
+ // be injected; otherwise a platform-specific module will be used that will
+ // use the default audio input.
+ //
// Note that the OrtcFactoryInterface does not take ownership of any of the
- // objects
- // passed in, and as previously stated, these objects can't be destroyed
- // before the factory is.
- static std::unique_ptr<OrtcFactoryInterface> Create(
+ // objects passed in, and as previously stated, these objects can't be
+ // destroyed before the factory is.
+ static RTCErrorOr<std::unique_ptr<OrtcFactoryInterface>> Create(
rtc::Thread* network_thread,
rtc::Thread* signaling_thread,
rtc::NetworkManager* network_manager,
- rtc::PacketSocketFactory* socket_factory);
+ rtc::PacketSocketFactory* socket_factory,
+ AudioDeviceModule* adm);
+
// Constructor for convenience which uses default implementations of
// everything (though does still require that the current thread runs a
// message loop; see above).
- static std::unique_ptr<OrtcFactoryInterface> Create() {
- return Create(nullptr, nullptr, nullptr, nullptr);
+ static RTCErrorOr<std::unique_ptr<OrtcFactoryInterface>> Create() {
+ return Create(nullptr, nullptr, nullptr, nullptr, nullptr);
}
virtual ~OrtcFactoryInterface() {}
- virtual std::unique_ptr<UdpTransportInterface>
+ // Creates an RTP transport controller, which is required for calls to
+ // CreateRtpTransport methods. If your application has some notion of a
+ // "call", you should create one transport controller per call.
+ // TODO(deadbeef): Add MediaConfig and RtcEventLog arguments?
+ virtual RTCErrorOr<std::unique_ptr<RtpTransportControllerInterface>>
+ CreateRtpTransportController() = 0;
+
+ // Creates an RTP transport using the provided packet transports and
+ // transport controller.
+ //
+ // |rtp| will be used for sending RTP packets, and |rtcp| for RTCP packets.
+ //
+ // |rtp| can't be null. |rtcp| can if RTCP muxing is being used immediately,
+ // meaning |rtcp_parameters.mux| is true.
+ //
+ // |transport_controller| must not be null.
+ virtual RTCErrorOr<std::unique_ptr<RtpTransportInterface>> CreateRtpTransport(
+ const RtcpParameters& rtcp_parameters,
+ PacketTransportInterface* rtp,
+ PacketTransportInterface* rtcp,
+ RtpTransportControllerInterface* transport_controller) = 0;
+
+ // Returns the capabilities of an RTP sender of type |kind|. These
+ // capabilities can be used to determine what RtpParameters to use to create
+ // an RtpSender.
+ //
+ // If for some reason you pass in MEDIA_TYPE_DATA, returns an empty structure.
+ virtual RtpCapabilities GetRtpSenderCapabilities(
+ cricket::MediaType kind) const = 0;
+
+ // Creates an RTP sender and starts sending the provided |track| (assuming an
+ // active encoding exists in |rtp_parameters|).
+ //
+ // |track| and |transport| must not be null.
+ virtual RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> CreateRtpSender(
+ rtc::scoped_refptr<MediaStreamTrackInterface> track,
+ const RtpParameters& rtp_parameters,
+ RtpTransportInterface* transport) = 0;
+
+ // Same as above, but allows creating the sender without a track.
+ //
+ // |kind| must be MEDIA_TYPE_AUDIO or MEDIA_TYPE_VIDEO.
+ virtual RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> CreateRtpSender(
+ cricket::MediaType kind,
+ const RtpParameters& rtp_parameters,
+ RtpTransportInterface* transport) = 0;
+
+ // Returns the capabilities of an RTP receiver of type |kind|. These
+ // capabilities can be used to determine what RtpParameters to use to create
+ // an RtpReceiver.
+ //
+ // If for some reason you pass in MEDIA_TYPE_DATA, returns an empty structure.
+ virtual RtpCapabilities GetRtpReceiverCapabilities(
+ cricket::MediaType kind) const = 0;
+
+ // Creates an RTP receiver and prepares to receive a MediaStreamTrack
+ // described by |rtp_parameters|.
+ //
+ // |kind| must be MEDIA_TYPE_AUDIO or MEDIA_TYPE_VIDEO.
+ //
+ // |transport| must not be null.
+ virtual RTCErrorOr<std::unique_ptr<OrtcRtpReceiverInterface>>
+ CreateRtpReceiver(cricket::MediaType kind,
+ const RtpParameters& rtp_parameters,
+ RtpTransportInterface* transport) = 0;
+
+ // Create a UDP transport with IP address family |family|, using a port
+ // within the specified range.
+ //
+ // |family| must be AF_INET or AF_INET6.
+ //
+ // |min_port|/|max_port| values of 0 indicate no range restriction.
+ //
+ // Returns an error if the transport wasn't successfully created.
+ virtual RTCErrorOr<std::unique_ptr<UdpTransportInterface>>
CreateUdpTransport(int family, uint16_t min_port, uint16_t max_port) = 0;
+
+ // NOTE: The methods below to create tracks/sources return scoped_refptrs
+ // rather than unique_ptrs, because these interfaces are also used with
+ // PeerConnection, where everything is ref-counted.
+
+ // Creates a audio source representing the default microphone input.
+ // |options| decides audio processing settings.
+ virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
+ const cricket::AudioOptions& options) = 0;
+
+ // Version of the above method that uses default options.
+ rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource() {
+ return CreateAudioSource(cricket::AudioOptions());
+ }
+
+ // Creates a video source object wrapping and taking ownership of |capturer|.
+ //
+ // |constraints| can be used for selection of resolution and frame rate, and
+ // may be null if no constraints are desired.
+ virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
+ std::unique_ptr<cricket::VideoCapturer> capturer,
+ const MediaConstraintsInterface* constraints) = 0;
+
+ // Version of the above method that omits |constraints|.
+ rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
+ std::unique_ptr<cricket::VideoCapturer> capturer) {
+ return CreateVideoSource(std::move(capturer), nullptr);
+ }
+
+ // Creates a new local video track wrapping |source|. The same |source| can
+ // be used in several tracks.
+ virtual rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
+ const std::string& id,
+ VideoTrackSourceInterface* source) = 0;
+
+ // Creates an new local audio track wrapping |source|.
+ virtual rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack(
+ const std::string& id,
+ AudioSourceInterface* source) = 0;
+
// Method for convenience that has no port range restrictions.
- std::unique_ptr<UdpTransportInterface> CreateUdpTransport(int family) {
+ RTCErrorOr<std::unique_ptr<UdpTransportInterface>> CreateUdpTransport(
+ int family) {
return CreateUdpTransport(family, 0, 0);
}
};

Powered by Google App Engine
This is Rietveld 408576698