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

Side by Side Diff: webrtc/media/engine/webrtcvideoengine2.h

Issue 1695263002: Move direct use of VideoCapturer::VideoAdapter to VideoSinkWants. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added from_width && from_height in resolution change req. Created 4 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
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 #ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ 11 #ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_
12 #define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ 12 #define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_
13 13
14 #include <map> 14 #include <map>
15 #include <set> 15 #include <set>
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "webrtc/base/criticalsection.h" 19 #include "webrtc/base/criticalsection.h"
20 #include "webrtc/base/scoped_ptr.h" 20 #include "webrtc/base/scoped_ptr.h"
21 #include "webrtc/base/thread_annotations.h" 21 #include "webrtc/base/thread_annotations.h"
22 #include "webrtc/base/thread_checker.h" 22 #include "webrtc/base/thread_checker.h"
23 #include "webrtc/media/base/videosinkinterface.h" 23 #include "webrtc/media/base/videosinkinterface.h"
24 #include "webrtc/media/base/videosourceinterface.h" 24 #include "webrtc/media/base/videosourceinterface.h"
25 #include "webrtc/call.h" 25 #include "webrtc/call.h"
26 #include "webrtc/media/base/asyncproxy.h"
26 #include "webrtc/media/base/mediaengine.h" 27 #include "webrtc/media/base/mediaengine.h"
27 #include "webrtc/media/engine/webrtcvideochannelfactory.h" 28 #include "webrtc/media/engine/webrtcvideochannelfactory.h"
28 #include "webrtc/media/engine/webrtcvideodecoderfactory.h" 29 #include "webrtc/media/engine/webrtcvideodecoderfactory.h"
29 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" 30 #include "webrtc/media/engine/webrtcvideoencoderfactory.h"
30 #include "webrtc/transport.h" 31 #include "webrtc/transport.h"
31 #include "webrtc/video_frame.h" 32 #include "webrtc/video_frame.h"
32 #include "webrtc/video_receive_stream.h" 33 #include "webrtc/video_receive_stream.h"
33 #include "webrtc/video_renderer.h" 34 #include "webrtc/video_renderer.h"
34 #include "webrtc/video_send_stream.h" 35 #include "webrtc/video_send_stream.h"
35 36
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 123
123 std::vector<VideoCodec> video_codecs_; 124 std::vector<VideoCodec> video_codecs_;
124 125
125 bool initialized_; 126 bool initialized_;
126 127
127 WebRtcVideoDecoderFactory* external_decoder_factory_; 128 WebRtcVideoDecoderFactory* external_decoder_factory_;
128 WebRtcVideoEncoderFactory* external_encoder_factory_; 129 WebRtcVideoEncoderFactory* external_encoder_factory_;
129 rtc::scoped_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_; 130 rtc::scoped_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_;
130 }; 131 };
131 132
132 class WebRtcVideoChannel2 : public VideoMediaChannel, 133 class WebRtcVideoChannel2 : public VideoMediaChannel, public webrtc::Transport {
133 public webrtc::Transport,
134 public webrtc::LoadObserver {
135 public: 134 public:
136 WebRtcVideoChannel2(webrtc::Call* call, 135 WebRtcVideoChannel2(webrtc::Call* call,
137 const MediaConfig& config, 136 const MediaConfig& config,
138 const VideoOptions& options, 137 const VideoOptions& options,
139 const std::vector<VideoCodec>& recv_codecs, 138 const std::vector<VideoCodec>& recv_codecs,
140 WebRtcVideoEncoderFactory* external_encoder_factory, 139 WebRtcVideoEncoderFactory* external_encoder_factory,
141 WebRtcVideoDecoderFactory* external_decoder_factory); 140 WebRtcVideoDecoderFactory* external_decoder_factory);
142 ~WebRtcVideoChannel2() override; 141 ~WebRtcVideoChannel2() override;
143 142
144 // VideoMediaChannel implementation 143 // VideoMediaChannel implementation
(...skipping 16 matching lines...) Expand all
161 bool GetStats(VideoMediaInfo* info) override; 160 bool GetStats(VideoMediaInfo* info) override;
162 bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) override; 161 bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) override;
163 162
164 void OnPacketReceived(rtc::Buffer* packet, 163 void OnPacketReceived(rtc::Buffer* packet,
165 const rtc::PacketTime& packet_time) override; 164 const rtc::PacketTime& packet_time) override;
166 void OnRtcpReceived(rtc::Buffer* packet, 165 void OnRtcpReceived(rtc::Buffer* packet,
167 const rtc::PacketTime& packet_time) override; 166 const rtc::PacketTime& packet_time) override;
168 void OnReadyToSend(bool ready) override; 167 void OnReadyToSend(bool ready) override;
169 void SetInterface(NetworkInterface* iface) override; 168 void SetInterface(NetworkInterface* iface) override;
170 169
171 void OnLoadUpdate(Load load) override;
172
173 // Implemented for VideoMediaChannelTest. 170 // Implemented for VideoMediaChannelTest.
174 bool sending() const { return sending_; } 171 bool sending() const { return sending_; }
175 uint32_t GetDefaultSendChannelSsrc() { return default_send_ssrc_; } 172 uint32_t GetDefaultSendChannelSsrc() { return default_send_ssrc_; }
176 173
177 private: 174 private:
178 class WebRtcVideoReceiveStream; 175 class WebRtcVideoReceiveStream;
179 struct VideoCodecSettings { 176 struct VideoCodecSettings {
180 VideoCodecSettings(); 177 VideoCodecSettings();
181 178
182 bool operator==(const VideoCodecSettings& other) const; 179 bool operator==(const VideoCodecSettings& other) const;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); 219 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_);
223 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) 220 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream)
224 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); 221 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_);
225 222
226 static std::string CodecSettingsVectorToString( 223 static std::string CodecSettingsVectorToString(
227 const std::vector<VideoCodecSettings>& codecs); 224 const std::vector<VideoCodecSettings>& codecs);
228 225
229 // Wrapper for the sender part, this is where the capturer is connected and 226 // Wrapper for the sender part, this is where the capturer is connected and
230 // frames are then converted from cricket frames to webrtc frames. 227 // frames are then converted from cricket frames to webrtc frames.
231 class WebRtcVideoSendStream 228 class WebRtcVideoSendStream
232 : public rtc::VideoSinkInterface<cricket::VideoFrame> { 229 : public rtc::VideoSinkInterface<cricket::VideoFrame>,
230 public webrtc::LoadObserver {
233 public: 231 public:
234 WebRtcVideoSendStream( 232 WebRtcVideoSendStream(
235 webrtc::Call* call, 233 webrtc::Call* call,
236 const StreamParams& sp, 234 const StreamParams& sp,
237 const webrtc::VideoSendStream::Config& config, 235 const webrtc::VideoSendStream::Config& config,
238 WebRtcVideoEncoderFactory* external_encoder_factory, 236 WebRtcVideoEncoderFactory* external_encoder_factory,
239 const VideoOptions& options, 237 const VideoOptions& options,
238 bool enable_cpu_overuse_detection,
240 int max_bitrate_bps, 239 int max_bitrate_bps,
241 const rtc::Optional<VideoCodecSettings>& codec_settings, 240 const rtc::Optional<VideoCodecSettings>& codec_settings,
242 const std::vector<webrtc::RtpExtension>& rtp_extensions, 241 const std::vector<webrtc::RtpExtension>& rtp_extensions,
243 const VideoSendParameters& send_params); 242 const VideoSendParameters& send_params);
244 virtual ~WebRtcVideoSendStream(); 243 virtual ~WebRtcVideoSendStream();
245 244
246 void SetOptions(const VideoOptions& options); 245 void SetOptions(const VideoOptions& options);
247 // TODO(pbos): Move logic from SetOptions into this method. 246 // TODO(pbos): Move logic from SetOptions into this method.
248 void SetSendParameters(const ChangedSendParameters& send_params); 247 void SetSendParameters(const ChangedSendParameters& send_params);
249 248
250 void OnFrame(const cricket::VideoFrame& frame) override; 249 void OnFrame(const cricket::VideoFrame& frame) override;
251 bool SetCapturer(VideoCapturer* capturer); 250 bool SetCapturer(VideoCapturer* capturer);
252 void MuteStream(bool mute); 251 void MuteStream(bool mute);
253 bool DisconnectCapturer(); 252 bool DisconnectCapturer();
254 253
255 void Start(); 254 void Start();
256 void Stop(); 255 void Stop();
257 256
257 // Implements webrtc::LoadObserver.
258 void OnLoadUpdate(Load load) override;
259
258 const std::vector<uint32_t>& GetSsrcs() const; 260 const std::vector<uint32_t>& GetSsrcs() const;
259 VideoSenderInfo GetVideoSenderInfo(); 261 VideoSenderInfo GetVideoSenderInfo();
260 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); 262 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info);
261 263
262 private: 264 private:
263 // Parameters needed to reconstruct the underlying stream. 265 // Parameters needed to reconstruct the underlying stream.
264 // webrtc::VideoSendStream doesn't support setting a lot of options on the 266 // webrtc::VideoSendStream doesn't support setting a lot of options on the
265 // fly, so when those need to be changed we tear down and reconstruct with 267 // fly, so when those need to be changed we tear down and reconstruct with
266 // similar parameters depending on which options changed etc. 268 // similar parameters depending on which options changed etc.
267 struct VideoSendStreamParameters { 269 struct VideoSendStreamParameters {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 void SetCodecAndOptions(const VideoCodecSettings& codec, 335 void SetCodecAndOptions(const VideoCodecSettings& codec,
334 const VideoOptions& options) 336 const VideoOptions& options)
335 EXCLUSIVE_LOCKS_REQUIRED(lock_); 337 EXCLUSIVE_LOCKS_REQUIRED(lock_);
336 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_); 338 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_);
337 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( 339 webrtc::VideoEncoderConfig CreateVideoEncoderConfig(
338 const Dimensions& dimensions, 340 const Dimensions& dimensions,
339 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_); 341 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_);
340 void SetDimensions(int width, int height, bool is_screencast) 342 void SetDimensions(int width, int height, bool is_screencast)
341 EXCLUSIVE_LOCKS_REQUIRED(lock_); 343 EXCLUSIVE_LOCKS_REQUIRED(lock_);
342 344
345 rtc::ThreadChecker thread_checker_;
343 const std::vector<uint32_t> ssrcs_; 346 const std::vector<uint32_t> ssrcs_;
344 const std::vector<SsrcGroup> ssrc_groups_; 347 const std::vector<SsrcGroup> ssrc_groups_;
345 webrtc::Call* const call_; 348 webrtc::Call* const call_;
346 rtc::VideoSinkWants sink_wants_; 349 rtc::VideoSinkWants sink_wants_;
350 rtc::LoadObserverProxy load_proxy_;
347 WebRtcVideoEncoderFactory* const external_encoder_factory_ 351 WebRtcVideoEncoderFactory* const external_encoder_factory_
348 GUARDED_BY(lock_); 352 GUARDED_BY(lock_);
349 353
350 rtc::CriticalSection lock_; 354 rtc::CriticalSection lock_;
351 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); 355 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_);
352 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); 356 VideoSendStreamParameters parameters_ GUARDED_BY(lock_);
353 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); 357 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_);
354 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); 358 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_);
355 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); 359 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_);
356 Dimensions last_dimensions_ GUARDED_BY(lock_); 360 Dimensions last_dimensions_ GUARDED_BY(lock_);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 VideoOptions options_; 521 VideoOptions options_;
518 // TODO(deadbeef): Don't duplicate information between 522 // TODO(deadbeef): Don't duplicate information between
519 // send_params/recv_params, rtp_extensions, options, etc. 523 // send_params/recv_params, rtp_extensions, options, etc.
520 VideoSendParameters send_params_; 524 VideoSendParameters send_params_;
521 VideoRecvParameters recv_params_; 525 VideoRecvParameters recv_params_;
522 }; 526 };
523 527
524 } // namespace cricket 528 } // namespace cricket
525 529
526 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ 530 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698