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

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

Issue 2675173003: Adding "adapter" ORTC objects on top of ChannelManager/BaseChannel/etc. (Closed)
Patch Set: Rebase onto split-off RtcError CL 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/rtpsendershim.cc ('k') | webrtc/ortc/rtptransportcontrollershim.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_RTPTRANSPORTCONTROLLERSHIM_H_
12 #define WEBRTC_ORTC_RTPTRANSPORTCONTROLLERSHIM_H_
13
14 #include <memory>
15 #include <string>
16 #include <vector>
17
18 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/base/thread.h"
20 #include "webrtc/call/call.h"
21 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
22 #include "webrtc/api/ortc/rtptransportcontrollerinterface.h"
23 #include "webrtc/pc/channelmanager.h"
24 #include "webrtc/pc/mediacontroller.h"
25 #include "webrtc/media/base/mediachannel.h" // For MediaConfig.
26
27 namespace webrtc {
28
29 // Implementation of RtpTransportControllerInterface. Wraps a MediaController,
30 // a VoiceChannel and VideoChannel, and maintains a list of dependent RTP
31 // transports.
32 //
33 // When used along with an RtpSenderShim or RtpReceiverShim, the
34 // sender/receiver passes its parameters along to this class, which turns them
35 // into cricket:: media descriptions (the interface used by BaseChannel).
36 //
37 // Due to the fact that BaseChannel has different subclasses for audio/video,
38 // the actual BaseChannel object is not created until an RtpSender/RtpReceiver
39 // needs them.
40 //
41 // All methods should be called on the signaling thread.
42 //
43 // TODO(deadbeef): When BaseChannel is split apart into separate
44 // "RtpSender"/"RtpTransceiver"/"RtpSender"/"RtpReceiver" objects, this shim
45 // object can be replaced by a "real" one.
46 class RtpTransportControllerShim : public RtpTransportControllerInterface {
47 public:
48 // Creates a proxy that will call "public interface" methods on the correct
49 // thread.
50 //
51 // Doesn't take ownership of any objects passed in.
52 //
53 // |channel_manager| must not be null.
54 static std::unique_ptr<RtpTransportControllerInterface> CreateProxied(
55 const cricket::MediaConfig& config,
56 cricket::ChannelManager* channel_manager,
57 webrtc::RtcEventLog* event_log,
58 rtc::Thread* signaling_thread,
59 rtc::Thread* worker_thread);
60
61 ~RtpTransportControllerShim() override;
62
63 // RtpTransportControllerInterface implementation.
64 std::vector<RtpTransportInterface*> GetTransports() const override;
65
66 // Methods used internally by RtpTransportShim.
67 MediaControllerInterface* media_controller() const {
68 return media_controller_.get();
69 }
70
71 rtc::Thread* signaling_thread() const { return signaling_thread_; }
72 rtc::Thread* worker_thread() const { return worker_thread_; }
73
74 // Doesn't take ownership.
75 //
76 // NOTE: "AddTransport" takes a proxy class, such that "GetTransports()" can
77 // return proxies, but the other methods take a pointer to the inner object,
78 // since these methods are called by the inner object which is unaware of the
79 // proxy.
80 void AddTransport(RtpTransportInterface* transport_proxy);
81 void RemoveTransport(RtpTransportInterface* inner_transport);
82 RTCError SetRtcpParameters(const RtcpParameters& parameters,
83 RtpTransportInterface* inner_transport);
84
85 // Methods used by RtpSenderShim/RtpReceiverShim.
86 //
87 // AttachSender/AttachReceiver ensures only one sender/receiver shim per
88 // media type is trying to use this object simultaneously, and the
89 // sender/receiver for the same media type are using the same transport.
90 // That's all this class currently supports, due to limits of BaseChannel.
91 //
92 // The "Detach" methods will cause the corresponding parameters to be
93 // cleared, and will allow a different sender or receiver to be connected.
94 RTCError AttachAudioSender(RtpTransportInterface* inner_transport);
95 RTCError AttachVideoSender(RtpTransportInterface* inner_transport);
96 RTCError AttachAudioReceiver(RtpTransportInterface* inner_transport);
97 RTCError AttachVideoReceiver(RtpTransportInterface* inner_transport);
98
99 void DetachAudioSender();
100 void DetachVideoSender();
101 void DetachAudioReceiver();
102 void DetachVideoReceiver();
103
104 cricket::VoiceChannel* voice_channel() { return voice_channel_; }
105 cricket::VideoChannel* video_channel() { return video_channel_; }
106
107 // |primary_ssrc| out parameter is filled with either
108 // |parameters.encodings[0].ssrc|, or a generated SSRC if that's left unset.
109 RTCError ValidateAndApplyAudioSenderParameters(
110 const RtpParameters& parameters,
111 uint32_t* primary_ssrc);
112 RTCError ValidateAndApplyVideoSenderParameters(
113 const RtpParameters& parameters,
114 uint32_t* primary_ssrc);
115 RTCError ValidateAndApplyAudioReceiverParameters(
116 const RtpParameters& parameters);
117 RTCError ValidateAndApplyVideoReceiverParameters(
118 const RtpParameters& parameters);
119
120 protected:
121 RtpTransportControllerShim* GetInternal() override { return this; }
122
123 private:
124 // Only expected to be called by RtpTransportControllerShim::CreateProxied.
125 RtpTransportControllerShim(const cricket::MediaConfig& config,
126 cricket::ChannelManager* channel_manager,
127 webrtc::RtcEventLog* event_log,
128 rtc::Thread* signaling_thread,
129 rtc::Thread* worker_thread);
130
131 void CreateVoiceChannel();
132 void CreateVideoChannel();
133 void DestroyVoiceChannel();
134 void DestroyVideoChannel();
135
136 void CopyRtcpParametersToDescriptions(
137 const RtcpParameters& params,
138 cricket::MediaContentDescription* local,
139 cricket::MediaContentDescription* remote);
140
141 // Helper function to generate an SSRC that doesn't match one in any of the
142 // "content description" structs, or in |new_params| (which is needed since
143 // multiple SSRCs may be gneerated in one go).
144 uint32_t GenerateUnusedSsrc(const cricket::StreamParams& new_params) const;
145
146 // |description| is the matching description where existing SSRCs can be
147 // found.
148 // This is a member function because it may need to generate SSRCs
149 // that don't match existing ones.
150 RTCError ValidateAndConvertSenderEncodings(
151 const std::vector<RtpEncodingParameters> encodings,
152 const std::string& cname,
153 const cricket::MediaContentDescription& description,
154 cricket::StreamParamsVec* cricket_streams,
155 bool* sending,
156 int* bandwidth) const;
157
158 rtc::Thread* signaling_thread_;
159 rtc::Thread* worker_thread_;
160 // |transport_proxies_| and |inner_audio_transport_|/|inner_audio_transport_|
161 // are somewhat redundant, but the latter are only set when
162 // RtpSenders/RtpReceivers are attached to the transport.
163 std::vector<RtpTransportInterface*> transport_proxies_;
164 RtpTransportInterface* inner_audio_transport_ = nullptr;
165 RtpTransportInterface* inner_video_transport_ = nullptr;
166 std::unique_ptr<MediaControllerInterface> media_controller_;
167
168 // BaseChannel takes content descriptions as input, so we store them here
169 // such that they can be updated when a new RtpSenderShim/RtpReceiverShim
170 // attaches itself.
171 cricket::AudioContentDescription local_audio_description_;
172 cricket::AudioContentDescription remote_audio_description_;
173 cricket::VideoContentDescription local_video_description_;
174 cricket::VideoContentDescription remote_video_description_;
175 cricket::VoiceChannel* voice_channel_ = nullptr;
176 cricket::VideoChannel* video_channel_ = nullptr;
177 bool have_audio_sender_ = false;
178 bool have_video_sender_ = false;
179 bool have_audio_receiver_ = false;
180 bool have_video_receiver_ = false;
181
182 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtpTransportControllerShim);
183 };
184
185 } // namespace webrtc
186
187 #endif // WEBRTC_ORTC_RTPTRANSPORTCONTROLLERSHIM_H_
OLDNEW
« no previous file with comments | « webrtc/ortc/rtpsendershim.cc ('k') | webrtc/ortc/rtptransportcontrollershim.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698