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

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

Issue 2714813004: Create the SrtpTransportInterface. (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 unified diff | Download patch
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 RTCErrorOr<std::unique_ptr<SrtpTransportInterface>> CreateSrtpTransport(
53 const RtcpParameters& rtcp_parameters,
54 PacketTransportInterface* rtp,
55 PacketTransportInterface* rtcp,
56 RtpTransportControllerInterface* transport_controller) override;
57
58 RtpCapabilities GetRtpSenderCapabilities(
59 cricket::MediaType kind) const override;
60
61 RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> CreateRtpSender(
62 rtc::scoped_refptr<MediaStreamTrackInterface> track,
63 RtpTransportInterface* transport) override;
64
65 RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> CreateRtpSender(
66 cricket::MediaType kind,
67 RtpTransportInterface* transport) override;
68
69 RtpCapabilities GetRtpReceiverCapabilities(
70 cricket::MediaType kind) const override;
71
72 RTCErrorOr<std::unique_ptr<OrtcRtpReceiverInterface>> CreateRtpReceiver(
73 cricket::MediaType kind,
74 RtpTransportInterface* transport) override;
75
76 RTCErrorOr<std::unique_ptr<UdpTransportInterface>>
77 CreateUdpTransport(int family, uint16_t min_port, uint16_t max_port) override;
78
79 rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
80 const cricket::AudioOptions& options) override;
81
82 rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
83 std::unique_ptr<cricket::VideoCapturer> capturer,
84 const MediaConstraintsInterface* constraints) override;
85
86 rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
87 const std::string& id,
88 VideoTrackSourceInterface* source) override;
89
90 rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack(
91 const std::string& id,
92 AudioSourceInterface* source) override;
93
94 rtc::Thread* network_thread() { return network_thread_; }
95 rtc::Thread* worker_thread() { return worker_thread_.get(); }
96 rtc::Thread* signaling_thread() { return signaling_thread_; }
97
98 private:
99 // Should only be called by OrtcFactoryInterface::Create.
100 OrtcFactory(rtc::Thread* network_thread,
101 rtc::Thread* signaling_thread,
102 rtc::NetworkManager* network_manager,
103 rtc::PacketSocketFactory* socket_factory,
104 AudioDeviceModule* adm);
105
106 // Performs initialization that can fail. Called by factory method after
107 // construction, and if it fails, no object is returned.
108 RTCError Initialize(
109 std::unique_ptr<cricket::MediaEngineInterface> media_engine);
110 std::unique_ptr<cricket::MediaEngineInterface> CreateMediaEngine_w();
111
112 // Threads and networking objects.
113 rtc::Thread* network_thread_;
114 rtc::Thread* signaling_thread_;
115 rtc::NetworkManager* network_manager_;
116 rtc::PacketSocketFactory* socket_factory_;
117 AudioDeviceModule* adm_;
118 // If we created/own the objects above, these will be non-null and thus will
119 // be released automatically upon destruction.
120 std::unique_ptr<rtc::Thread> owned_network_thread_;
121 bool wraps_signaling_thread_ = false;
122 std::unique_ptr<rtc::NetworkManager> owned_network_manager_;
123 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_;
124 // We always own the worker thread.
125 std::unique_ptr<rtc::Thread> worker_thread_;
126 // Media-releated objects.
127 std::unique_ptr<RtcEventLog> null_event_log_;
128 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory_;
129 std::unique_ptr<cricket::ChannelManager> channel_manager_;
130 // Default CNAME to use for RtpTransports if none is passed in.
131 std::string default_cname_;
132
133 friend class OrtcFactoryInterface;
134
135 RTC_DISALLOW_COPY_AND_ASSIGN(OrtcFactory);
136 };
137
138 } // namespace webrtc
139
140 #endif // WEBRTC_ORTC_ORTCFACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698