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

Side by Side Diff: webrtc/api/rtpsender.h

Issue 2099843003: Revert of Use VoiceChannel/VideoChannel directly from RtpSender/RtpReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 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/rtpreceiverinterface.h ('k') | webrtc/api/rtpsender.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 // This file contains classes that implement RtpSenderInterface. 11 // This file contains classes that implement RtpSenderInterface.
12 // An RtpSender associates a MediaStreamTrackInterface with an underlying 12 // An RtpSender associates a MediaStreamTrackInterface with an underlying
13 // transport (provided by AudioProviderInterface/VideoProviderInterface) 13 // transport (provided by AudioProviderInterface/VideoProviderInterface)
14 14
15 #ifndef WEBRTC_API_RTPSENDER_H_ 15 #ifndef WEBRTC_API_RTPSENDER_H_
16 #define WEBRTC_API_RTPSENDER_H_ 16 #define WEBRTC_API_RTPSENDER_H_
17 17
18 #include <memory> 18 #include <memory>
19 #include <string> 19 #include <string>
20 20
21 #include "webrtc/api/mediastreaminterface.h" 21 #include "webrtc/api/mediastreamprovider.h"
22 #include "webrtc/api/rtpsenderinterface.h" 22 #include "webrtc/api/rtpsenderinterface.h"
23 #include "webrtc/api/statscollector.h" 23 #include "webrtc/api/statscollector.h"
24 #include "webrtc/base/basictypes.h" 24 #include "webrtc/base/basictypes.h"
25 #include "webrtc/base/criticalsection.h" 25 #include "webrtc/base/criticalsection.h"
26 #include "webrtc/media/base/audiosource.h" 26 #include "webrtc/media/base/audiosource.h"
27 #include "webrtc/pc/channel.h"
28 27
29 namespace webrtc { 28 namespace webrtc {
30 29
31 // Internal interface used by PeerConnection. 30 // Internal interface used by PeerConnection.
32 class RtpSenderInternal : public RtpSenderInterface { 31 class RtpSenderInternal : public RtpSenderInterface {
33 public: 32 public:
34 // Used to set the SSRC of the sender, once a local description has been set. 33 // Used to set the SSRC of the sender, once a local description has been set.
35 // If |ssrc| is 0, this indiates that the sender should disconnect from the 34 // If |ssrc| is 0, this indiates that the sender should disconnect from the
36 // underlying transport (this occurs if the sender isn't seen in a local 35 // underlying transport (this occurs if the sender isn't seen in a local
37 // description). 36 // description).
(...skipping 28 matching lines...) Expand all
66 cricket::AudioSource::Sink* sink_; 65 cricket::AudioSource::Sink* sink_;
67 // Critical section protecting |sink_|. 66 // Critical section protecting |sink_|.
68 rtc::CriticalSection lock_; 67 rtc::CriticalSection lock_;
69 }; 68 };
70 69
71 class AudioRtpSender : public ObserverInterface, 70 class AudioRtpSender : public ObserverInterface,
72 public rtc::RefCountedObject<RtpSenderInternal> { 71 public rtc::RefCountedObject<RtpSenderInternal> {
73 public: 72 public:
74 // StatsCollector provided so that Add/RemoveLocalAudioTrack can be called 73 // StatsCollector provided so that Add/RemoveLocalAudioTrack can be called
75 // at the appropriate times. 74 // at the appropriate times.
76 // |channel| can be null if one does not exist yet.
77 AudioRtpSender(AudioTrackInterface* track, 75 AudioRtpSender(AudioTrackInterface* track,
78 const std::string& stream_id, 76 const std::string& stream_id,
79 cricket::VoiceChannel* channel, 77 AudioProviderInterface* provider,
80 StatsCollector* stats); 78 StatsCollector* stats);
81 79
82 // Randomly generates stream_id. 80 // Randomly generates stream_id.
83 // |channel| can be null if one does not exist yet.
84 AudioRtpSender(AudioTrackInterface* track, 81 AudioRtpSender(AudioTrackInterface* track,
85 cricket::VoiceChannel* channel, 82 AudioProviderInterface* provider,
86 StatsCollector* stats); 83 StatsCollector* stats);
87 84
88 // Randomly generates id and stream_id. 85 // Randomly generates id and stream_id.
89 // |channel| can be null if one does not exist yet. 86 AudioRtpSender(AudioProviderInterface* provider, StatsCollector* stats);
90 AudioRtpSender(cricket::VoiceChannel* channel, StatsCollector* stats);
91 87
92 virtual ~AudioRtpSender(); 88 virtual ~AudioRtpSender();
93 89
94 // ObserverInterface implementation 90 // ObserverInterface implementation
95 void OnChanged() override; 91 void OnChanged() override;
96 92
97 // RtpSenderInterface implementation 93 // RtpSenderInterface implementation
98 bool SetTrack(MediaStreamTrackInterface* track) override; 94 bool SetTrack(MediaStreamTrackInterface* track) override;
99 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { 95 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
100 return track_; 96 return track_;
(...skipping 18 matching lines...) Expand all
119 // RtpSenderInternal implementation. 115 // RtpSenderInternal implementation.
120 void SetSsrc(uint32_t ssrc) override; 116 void SetSsrc(uint32_t ssrc) override;
121 117
122 void set_stream_id(const std::string& stream_id) override { 118 void set_stream_id(const std::string& stream_id) override {
123 stream_id_ = stream_id; 119 stream_id_ = stream_id;
124 } 120 }
125 std::string stream_id() const override { return stream_id_; } 121 std::string stream_id() const override { return stream_id_; }
126 122
127 void Stop() override; 123 void Stop() override;
128 124
129 // Does not take ownership.
130 // Should call SetChannel(nullptr) before |channel| is destroyed.
131 void SetChannel(cricket::VoiceChannel* channel) { channel_ = channel; }
132
133 private: 125 private:
134 // TODO(nisse): Since SSRC == 0 is technically valid, figure out 126 // TODO(nisse): Since SSRC == 0 is technically valid, figure out
135 // some other way to test if we have a valid SSRC. 127 // some other way to test if we have a valid SSRC.
136 bool can_send_track() const { return track_ && ssrc_; } 128 bool can_send_track() const { return track_ && ssrc_; }
137 // Helper function to construct options for 129 // Helper function to construct options for
138 // AudioProviderInterface::SetAudioSend. 130 // AudioProviderInterface::SetAudioSend.
139 void SetAudioSend(); 131 void SetAudioSend();
140 // Helper function to call SetAudioSend with "stop sending" parameters.
141 void ClearAudioSend();
142 132
143 std::string id_; 133 std::string id_;
144 std::string stream_id_; 134 std::string stream_id_;
145 cricket::VoiceChannel* channel_ = nullptr; 135 AudioProviderInterface* provider_;
146 StatsCollector* stats_; 136 StatsCollector* stats_;
147 rtc::scoped_refptr<AudioTrackInterface> track_; 137 rtc::scoped_refptr<AudioTrackInterface> track_;
148 uint32_t ssrc_ = 0; 138 uint32_t ssrc_ = 0;
149 bool cached_track_enabled_ = false; 139 bool cached_track_enabled_ = false;
150 bool stopped_ = false; 140 bool stopped_ = false;
151 141
152 // Used to pass the data callback from the |track_| to the other end of 142 // Used to pass the data callback from the |track_| to the other end of
153 // cricket::AudioSource. 143 // cricket::AudioSource.
154 std::unique_ptr<LocalAudioSinkAdapter> sink_adapter_; 144 std::unique_ptr<LocalAudioSinkAdapter> sink_adapter_;
155 }; 145 };
156 146
157 class VideoRtpSender : public ObserverInterface, 147 class VideoRtpSender : public ObserverInterface,
158 public rtc::RefCountedObject<RtpSenderInternal> { 148 public rtc::RefCountedObject<RtpSenderInternal> {
159 public: 149 public:
160 // |channel| can be null if one does not exist yet.
161 VideoRtpSender(VideoTrackInterface* track, 150 VideoRtpSender(VideoTrackInterface* track,
162 const std::string& stream_id, 151 const std::string& stream_id,
163 cricket::VideoChannel* channel); 152 VideoProviderInterface* provider);
164 153
165 // Randomly generates stream_id. 154 // Randomly generates stream_id.
166 // |channel| can be null if one does not exist yet. 155 VideoRtpSender(VideoTrackInterface* track, VideoProviderInterface* provider);
167 VideoRtpSender(VideoTrackInterface* track, cricket::VideoChannel* channel);
168 156
169 // Randomly generates id and stream_id. 157 // Randomly generates id and stream_id.
170 // |channel| can be null if one does not exist yet. 158 explicit VideoRtpSender(VideoProviderInterface* provider);
171 explicit VideoRtpSender(cricket::VideoChannel* channel);
172 159
173 virtual ~VideoRtpSender(); 160 virtual ~VideoRtpSender();
174 161
175 // ObserverInterface implementation 162 // ObserverInterface implementation
176 void OnChanged() override; 163 void OnChanged() override;
177 164
178 // RtpSenderInterface implementation 165 // RtpSenderInterface implementation
179 bool SetTrack(MediaStreamTrackInterface* track) override; 166 bool SetTrack(MediaStreamTrackInterface* track) override;
180 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { 167 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
181 return track_; 168 return track_;
(...skipping 18 matching lines...) Expand all
200 // RtpSenderInternal implementation. 187 // RtpSenderInternal implementation.
201 void SetSsrc(uint32_t ssrc) override; 188 void SetSsrc(uint32_t ssrc) override;
202 189
203 void set_stream_id(const std::string& stream_id) override { 190 void set_stream_id(const std::string& stream_id) override {
204 stream_id_ = stream_id; 191 stream_id_ = stream_id;
205 } 192 }
206 std::string stream_id() const override { return stream_id_; } 193 std::string stream_id() const override { return stream_id_; }
207 194
208 void Stop() override; 195 void Stop() override;
209 196
210 // Does not take ownership.
211 // Should call SetChannel(nullptr) before |channel| is destroyed.
212 void SetChannel(cricket::VideoChannel* channel) { channel_ = channel; }
213
214 private: 197 private:
215 bool can_send_track() const { return track_ && ssrc_; } 198 bool can_send_track() const { return track_ && ssrc_; }
216 // Helper function to construct options for 199 // Helper function to construct options for
217 // VideoProviderInterface::SetVideoSend. 200 // VideoProviderInterface::SetVideoSend.
218 void SetVideoSend(); 201 void SetVideoSend();
219 // Helper function to call SetVideoSend with "stop sending" parameters. 202 // Helper function to call SetVideoSend with "stop sending" parameters.
220 void ClearVideoSend(); 203 void ClearVideoSend();
221 204
222 std::string id_; 205 std::string id_;
223 std::string stream_id_; 206 std::string stream_id_;
224 cricket::VideoChannel* channel_ = nullptr; 207 VideoProviderInterface* provider_;
225 rtc::scoped_refptr<VideoTrackInterface> track_; 208 rtc::scoped_refptr<VideoTrackInterface> track_;
226 uint32_t ssrc_ = 0; 209 uint32_t ssrc_ = 0;
227 bool cached_track_enabled_ = false; 210 bool cached_track_enabled_ = false;
228 bool stopped_ = false; 211 bool stopped_ = false;
229 }; 212 };
230 213
231 } // namespace webrtc 214 } // namespace webrtc
232 215
233 #endif // WEBRTC_API_RTPSENDER_H_ 216 #endif // WEBRTC_API_RTPSENDER_H_
OLDNEW
« no previous file with comments | « webrtc/api/rtpreceiverinterface.h ('k') | webrtc/api/rtpsender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698