OLD | NEW |
(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/engine/webrtcmediaengine.h" |
| 21 #include "webrtc/pc/channelmanager.h" |
| 22 |
| 23 namespace webrtc { |
| 24 |
| 25 // Implementation of OrtcFactoryInterface. |
| 26 // |
| 27 // See ortcfactoryinterface.h for documentation. |
| 28 class OrtcFactory : public OrtcFactoryInterface { |
| 29 public: |
| 30 ~OrtcFactory() override; |
| 31 |
| 32 RTCErrorOr<std::unique_ptr<RtpTransportControllerInterface>> |
| 33 CreateRtpTransportController() override; |
| 34 |
| 35 RTCErrorOr<std::unique_ptr<RtpTransportInterface>> CreateRtpTransport( |
| 36 const RtcpParameters& rtcp_parameters, |
| 37 PacketTransportInterface* rtp, |
| 38 PacketTransportInterface* rtcp, |
| 39 RtpTransportControllerInterface* transport_controller) override; |
| 40 |
| 41 RtpCapabilities GetRtpSenderCapabilities( |
| 42 cricket::MediaType kind) const override; |
| 43 |
| 44 RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> CreateRtpSender( |
| 45 rtc::scoped_refptr<MediaStreamTrackInterface> track, |
| 46 RtpTransportInterface* transport) override; |
| 47 |
| 48 RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> CreateRtpSender( |
| 49 cricket::MediaType kind, |
| 50 RtpTransportInterface* transport) override; |
| 51 |
| 52 RtpCapabilities GetRtpReceiverCapabilities( |
| 53 cricket::MediaType kind) const override; |
| 54 |
| 55 RTCErrorOr<std::unique_ptr<OrtcRtpReceiverInterface>> CreateRtpReceiver( |
| 56 cricket::MediaType kind, |
| 57 RtpTransportInterface* transport) override; |
| 58 |
| 59 RTCErrorOr<std::unique_ptr<UdpTransportInterface>> |
| 60 CreateUdpTransport(int family, uint16_t min_port, uint16_t max_port) override; |
| 61 |
| 62 rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource( |
| 63 const cricket::AudioOptions& options) override; |
| 64 |
| 65 rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource( |
| 66 std::unique_ptr<cricket::VideoCapturer> capturer, |
| 67 const MediaConstraintsInterface* constraints) override; |
| 68 |
| 69 rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack( |
| 70 const std::string& id, |
| 71 VideoTrackSourceInterface* source) override; |
| 72 |
| 73 rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack( |
| 74 const std::string& id, |
| 75 AudioSourceInterface* source) override; |
| 76 |
| 77 rtc::Thread* network_thread() { return network_thread_; } |
| 78 rtc::Thread* worker_thread() { return worker_thread_.get(); } |
| 79 rtc::Thread* signaling_thread() { return signaling_thread_; } |
| 80 |
| 81 private: |
| 82 // Should only be called by OrtcFactoryInterface::Create. |
| 83 OrtcFactory(rtc::Thread* network_thread, |
| 84 rtc::Thread* signaling_thread, |
| 85 rtc::NetworkManager* network_manager, |
| 86 rtc::PacketSocketFactory* socket_factory, |
| 87 AudioDeviceModule* adm); |
| 88 |
| 89 // Performs initialization that can fail. Called by factory method after |
| 90 // construction, and if it fails, no object is returned. |
| 91 RTCError Initialize(); |
| 92 std::unique_ptr<cricket::MediaEngineInterface> CreateMediaEngine_w(); |
| 93 |
| 94 // Threads and networking objects. |
| 95 rtc::Thread* network_thread_; |
| 96 rtc::Thread* signaling_thread_; |
| 97 rtc::NetworkManager* network_manager_; |
| 98 rtc::PacketSocketFactory* socket_factory_; |
| 99 AudioDeviceModule* adm_; |
| 100 // If we created/own the objects above, these will be non-null and thus will |
| 101 // be released automatically upon destruction. |
| 102 std::unique_ptr<rtc::Thread> owned_network_thread_; |
| 103 bool wraps_signaling_thread_ = false; |
| 104 std::unique_ptr<rtc::NetworkManager> owned_network_manager_; |
| 105 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_; |
| 106 // We always own the worker thread. |
| 107 std::unique_ptr<rtc::Thread> worker_thread_; |
| 108 // Media-releated objects. |
| 109 std::unique_ptr<RtcEventLog> null_event_log_; |
| 110 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory_; |
| 111 std::unique_ptr<cricket::ChannelManager> channel_manager_; |
| 112 |
| 113 friend class OrtcFactoryInterface; |
| 114 |
| 115 RTC_DISALLOW_COPY_AND_ASSIGN(OrtcFactory); |
| 116 }; |
| 117 |
| 118 } // namespace webrtc |
| 119 |
| 120 #endif // WEBRTC_ORTC_ORTCFACTORY_H_ |
OLD | NEW |