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

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

Issue 2046173002: Use VoiceChannel/VideoChannel directly from RtpSender/RtpReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Moving code that needs to execute out of RTC_DCHECKs. 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/mediastreamprovider.h" 21 #include "webrtc/api/mediastreaminterface.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"
27 28
28 namespace webrtc { 29 namespace webrtc {
29 30
30 // Internal interface used by PeerConnection. 31 // Internal interface used by PeerConnection.
31 class RtpSenderInternal : public RtpSenderInterface { 32 class RtpSenderInternal : public RtpSenderInterface {
32 public: 33 public:
33 // Used to set the SSRC of the sender, once a local description has been set. 34 // Used to set the SSRC of the sender, once a local description has been set.
34 // If |ssrc| is 0, this indiates that the sender should disconnect from the 35 // If |ssrc| is 0, this indiates that the sender should disconnect from the
35 // underlying transport (this occurs if the sender isn't seen in a local 36 // underlying transport (this occurs if the sender isn't seen in a local
36 // description). 37 // description).
(...skipping 28 matching lines...) Expand all
65 cricket::AudioSource::Sink* sink_; 66 cricket::AudioSource::Sink* sink_;
66 // Critical section protecting |sink_|. 67 // Critical section protecting |sink_|.
67 rtc::CriticalSection lock_; 68 rtc::CriticalSection lock_;
68 }; 69 };
69 70
70 class AudioRtpSender : public ObserverInterface, 71 class AudioRtpSender : public ObserverInterface,
71 public rtc::RefCountedObject<RtpSenderInternal> { 72 public rtc::RefCountedObject<RtpSenderInternal> {
72 public: 73 public:
73 // StatsCollector provided so that Add/RemoveLocalAudioTrack can be called 74 // StatsCollector provided so that Add/RemoveLocalAudioTrack can be called
74 // at the appropriate times. 75 // at the appropriate times.
76 // |channel| can be null if one does not exist yet.
75 AudioRtpSender(AudioTrackInterface* track, 77 AudioRtpSender(AudioTrackInterface* track,
76 const std::string& stream_id, 78 const std::string& stream_id,
77 AudioProviderInterface* provider, 79 cricket::VoiceChannel* channel,
78 StatsCollector* stats); 80 StatsCollector* stats);
79 81
80 // Randomly generates stream_id. 82 // Randomly generates stream_id.
83 // |channel| can be null if one does not exist yet.
81 AudioRtpSender(AudioTrackInterface* track, 84 AudioRtpSender(AudioTrackInterface* track,
82 AudioProviderInterface* provider, 85 cricket::VoiceChannel* channel,
83 StatsCollector* stats); 86 StatsCollector* stats);
84 87
85 // Randomly generates id and stream_id. 88 // Randomly generates id and stream_id.
86 AudioRtpSender(AudioProviderInterface* provider, StatsCollector* stats); 89 // |channel| can be null if one does not exist yet.
90 AudioRtpSender(cricket::VoiceChannel* channel, StatsCollector* stats);
87 91
88 virtual ~AudioRtpSender(); 92 virtual ~AudioRtpSender();
89 93
90 // ObserverInterface implementation 94 // ObserverInterface implementation
91 void OnChanged() override; 95 void OnChanged() override;
92 96
93 // RtpSenderInterface implementation 97 // RtpSenderInterface implementation
94 bool SetTrack(MediaStreamTrackInterface* track) override; 98 bool SetTrack(MediaStreamTrackInterface* track) override;
95 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { 99 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
96 return track_; 100 return track_;
(...skipping 18 matching lines...) Expand all
115 // RtpSenderInternal implementation. 119 // RtpSenderInternal implementation.
116 void SetSsrc(uint32_t ssrc) override; 120 void SetSsrc(uint32_t ssrc) override;
117 121
118 void set_stream_id(const std::string& stream_id) override { 122 void set_stream_id(const std::string& stream_id) override {
119 stream_id_ = stream_id; 123 stream_id_ = stream_id;
120 } 124 }
121 std::string stream_id() const override { return stream_id_; } 125 std::string stream_id() const override { return stream_id_; }
122 126
123 void Stop() override; 127 void Stop() override;
124 128
129 // Does not take ownership.
130 // Should call SetChannel(nullptr) before |channel| is destroyed.
131 void SetChannel(cricket::VoiceChannel* channel) { channel_ = channel; }
132
125 private: 133 private:
126 // TODO(nisse): Since SSRC == 0 is technically valid, figure out 134 // TODO(nisse): Since SSRC == 0 is technically valid, figure out
127 // some other way to test if we have a valid SSRC. 135 // some other way to test if we have a valid SSRC.
128 bool can_send_track() const { return track_ && ssrc_; } 136 bool can_send_track() const { return track_ && ssrc_; }
129 // Helper function to construct options for 137 // Helper function to construct options for
130 // AudioProviderInterface::SetAudioSend. 138 // AudioProviderInterface::SetAudioSend.
131 void SetAudioSend(); 139 void SetAudioSend();
140 // Helper function to call SetAudioSend with "stop sending" parameters.
141 void ClearAudioSend();
132 142
133 std::string id_; 143 std::string id_;
134 std::string stream_id_; 144 std::string stream_id_;
135 AudioProviderInterface* provider_; 145 cricket::VoiceChannel* channel_ = nullptr;
136 StatsCollector* stats_; 146 StatsCollector* stats_;
137 rtc::scoped_refptr<AudioTrackInterface> track_; 147 rtc::scoped_refptr<AudioTrackInterface> track_;
138 uint32_t ssrc_ = 0; 148 uint32_t ssrc_ = 0;
139 bool cached_track_enabled_ = false; 149 bool cached_track_enabled_ = false;
140 bool stopped_ = false; 150 bool stopped_ = false;
141 151
142 // Used to pass the data callback from the |track_| to the other end of 152 // Used to pass the data callback from the |track_| to the other end of
143 // cricket::AudioSource. 153 // cricket::AudioSource.
144 std::unique_ptr<LocalAudioSinkAdapter> sink_adapter_; 154 std::unique_ptr<LocalAudioSinkAdapter> sink_adapter_;
145 }; 155 };
146 156
147 class VideoRtpSender : public ObserverInterface, 157 class VideoRtpSender : public ObserverInterface,
148 public rtc::RefCountedObject<RtpSenderInternal> { 158 public rtc::RefCountedObject<RtpSenderInternal> {
149 public: 159 public:
160 // |channel| can be null if one does not exist yet.
150 VideoRtpSender(VideoTrackInterface* track, 161 VideoRtpSender(VideoTrackInterface* track,
151 const std::string& stream_id, 162 const std::string& stream_id,
152 VideoProviderInterface* provider); 163 cricket::VideoChannel* channel);
153 164
154 // Randomly generates stream_id. 165 // Randomly generates stream_id.
155 VideoRtpSender(VideoTrackInterface* track, VideoProviderInterface* provider); 166 // |channel| can be null if one does not exist yet.
167 VideoRtpSender(VideoTrackInterface* track, cricket::VideoChannel* channel);
156 168
157 // Randomly generates id and stream_id. 169 // Randomly generates id and stream_id.
158 explicit VideoRtpSender(VideoProviderInterface* provider); 170 // |channel| can be null if one does not exist yet.
171 explicit VideoRtpSender(cricket::VideoChannel* channel);
159 172
160 virtual ~VideoRtpSender(); 173 virtual ~VideoRtpSender();
161 174
162 // ObserverInterface implementation 175 // ObserverInterface implementation
163 void OnChanged() override; 176 void OnChanged() override;
164 177
165 // RtpSenderInterface implementation 178 // RtpSenderInterface implementation
166 bool SetTrack(MediaStreamTrackInterface* track) override; 179 bool SetTrack(MediaStreamTrackInterface* track) override;
167 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { 180 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
168 return track_; 181 return track_;
(...skipping 18 matching lines...) Expand all
187 // RtpSenderInternal implementation. 200 // RtpSenderInternal implementation.
188 void SetSsrc(uint32_t ssrc) override; 201 void SetSsrc(uint32_t ssrc) override;
189 202
190 void set_stream_id(const std::string& stream_id) override { 203 void set_stream_id(const std::string& stream_id) override {
191 stream_id_ = stream_id; 204 stream_id_ = stream_id;
192 } 205 }
193 std::string stream_id() const override { return stream_id_; } 206 std::string stream_id() const override { return stream_id_; }
194 207
195 void Stop() override; 208 void Stop() override;
196 209
210 // Does not take ownership.
211 // Should call SetChannel(nullptr) before |channel| is destroyed.
212 void SetChannel(cricket::VideoChannel* channel) { channel_ = channel; }
213
197 private: 214 private:
198 bool can_send_track() const { return track_ && ssrc_; } 215 bool can_send_track() const { return track_ && ssrc_; }
199 // Helper function to construct options for 216 // Helper function to construct options for
200 // VideoProviderInterface::SetVideoSend. 217 // VideoProviderInterface::SetVideoSend.
201 void SetVideoSend(); 218 void SetVideoSend();
202 // Helper function to call SetVideoSend with "stop sending" parameters. 219 // Helper function to call SetVideoSend with "stop sending" parameters.
203 void ClearVideoSend(); 220 void ClearVideoSend();
204 221
205 std::string id_; 222 std::string id_;
206 std::string stream_id_; 223 std::string stream_id_;
207 VideoProviderInterface* provider_; 224 cricket::VideoChannel* channel_ = nullptr;
208 rtc::scoped_refptr<VideoTrackInterface> track_; 225 rtc::scoped_refptr<VideoTrackInterface> track_;
209 uint32_t ssrc_ = 0; 226 uint32_t ssrc_ = 0;
210 bool cached_track_enabled_ = false; 227 bool cached_track_enabled_ = false;
211 bool stopped_ = false; 228 bool stopped_ = false;
212 }; 229 };
213 230
214 } // namespace webrtc 231 } // namespace webrtc
215 232
216 #endif // WEBRTC_API_RTPSENDER_H_ 233 #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