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

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: rebased Created 4 years, 9 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
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 std::vector<VideoCodec> video_codecs_; 123 std::vector<VideoCodec> video_codecs_;
124 124
125 bool initialized_; 125 bool initialized_;
126 126
127 WebRtcVideoDecoderFactory* external_decoder_factory_; 127 WebRtcVideoDecoderFactory* external_decoder_factory_;
128 WebRtcVideoEncoderFactory* external_encoder_factory_; 128 WebRtcVideoEncoderFactory* external_encoder_factory_;
129 rtc::scoped_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_; 129 rtc::scoped_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_;
130 }; 130 };
131 131
132 class WebRtcVideoChannel2 : public VideoMediaChannel, 132 class WebRtcVideoChannel2 : public VideoMediaChannel, public webrtc::Transport {
133 public webrtc::Transport,
134 public webrtc::LoadObserver {
135 public: 133 public:
136 WebRtcVideoChannel2(webrtc::Call* call, 134 WebRtcVideoChannel2(webrtc::Call* call,
137 const MediaConfig& config, 135 const MediaConfig& config,
138 const VideoOptions& options, 136 const VideoOptions& options,
139 const std::vector<VideoCodec>& recv_codecs, 137 const std::vector<VideoCodec>& recv_codecs,
140 WebRtcVideoEncoderFactory* external_encoder_factory, 138 WebRtcVideoEncoderFactory* external_encoder_factory,
141 WebRtcVideoDecoderFactory* external_decoder_factory); 139 WebRtcVideoDecoderFactory* external_decoder_factory);
142 ~WebRtcVideoChannel2() override; 140 ~WebRtcVideoChannel2() override;
143 141
144 // VideoMediaChannel implementation 142 // VideoMediaChannel implementation
(...skipping 16 matching lines...) Expand all
161 bool GetStats(VideoMediaInfo* info) override; 159 bool GetStats(VideoMediaInfo* info) override;
162 bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) override; 160 bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) override;
163 161
164 void OnPacketReceived(rtc::Buffer* packet, 162 void OnPacketReceived(rtc::Buffer* packet,
165 const rtc::PacketTime& packet_time) override; 163 const rtc::PacketTime& packet_time) override;
166 void OnRtcpReceived(rtc::Buffer* packet, 164 void OnRtcpReceived(rtc::Buffer* packet,
167 const rtc::PacketTime& packet_time) override; 165 const rtc::PacketTime& packet_time) override;
168 void OnReadyToSend(bool ready) override; 166 void OnReadyToSend(bool ready) override;
169 void SetInterface(NetworkInterface* iface) override; 167 void SetInterface(NetworkInterface* iface) override;
170 168
171 void OnLoadUpdate(Load load) override;
172
173 // Implemented for VideoMediaChannelTest. 169 // Implemented for VideoMediaChannelTest.
174 bool sending() const { return sending_; } 170 bool sending() const { return sending_; }
175 uint32_t GetDefaultSendChannelSsrc() { return default_send_ssrc_; } 171 uint32_t GetDefaultSendChannelSsrc() { return default_send_ssrc_; }
176 172
177 private: 173 private:
178 class WebRtcVideoReceiveStream; 174 class WebRtcVideoReceiveStream;
179 struct VideoCodecSettings { 175 struct VideoCodecSettings {
180 VideoCodecSettings(); 176 VideoCodecSettings();
181 177
182 bool operator==(const VideoCodecSettings& other) const; 178 bool operator==(const VideoCodecSettings& other) const;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); 219 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_);
224 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) 220 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream)
225 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); 221 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_);
226 222
227 static std::string CodecSettingsVectorToString( 223 static std::string CodecSettingsVectorToString(
228 const std::vector<VideoCodecSettings>& codecs); 224 const std::vector<VideoCodecSettings>& codecs);
229 225
230 // 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
231 // frames are then converted from cricket frames to webrtc frames. 227 // frames are then converted from cricket frames to webrtc frames.
232 class WebRtcVideoSendStream 228 class WebRtcVideoSendStream
233 : public rtc::VideoSinkInterface<cricket::VideoFrame> { 229 : public rtc::VideoSinkInterface<cricket::VideoFrame>,
230 public webrtc::LoadObserver {
234 public: 231 public:
235 WebRtcVideoSendStream( 232 WebRtcVideoSendStream(
236 webrtc::Call* call, 233 webrtc::Call* call,
237 const StreamParams& sp, 234 const StreamParams& sp,
238 const webrtc::VideoSendStream::Config& config, 235 const webrtc::VideoSendStream::Config& config,
239 WebRtcVideoEncoderFactory* external_encoder_factory, 236 WebRtcVideoEncoderFactory* external_encoder_factory,
237 bool enable_cpu_overuse_detection,
240 int max_bitrate_bps, 238 int max_bitrate_bps,
241 const rtc::Optional<VideoCodecSettings>& codec_settings, 239 const rtc::Optional<VideoCodecSettings>& codec_settings,
242 const std::vector<webrtc::RtpExtension>& rtp_extensions, 240 const std::vector<webrtc::RtpExtension>& rtp_extensions,
243 const VideoSendParameters& send_params); 241 const VideoSendParameters& send_params);
244 virtual ~WebRtcVideoSendStream(); 242 virtual ~WebRtcVideoSendStream();
245 243
246 void SetOptions(const VideoOptions& options); 244 void SetOptions(const VideoOptions& options);
247 // TODO(pbos): Move logic from SetOptions into this method. 245 // TODO(pbos): Move logic from SetOptions into this method.
248 void SetSendParameters(const ChangedSendParameters& send_params); 246 void SetSendParameters(const ChangedSendParameters& send_params);
249 247
250 void OnFrame(const cricket::VideoFrame& frame) override; 248 void OnFrame(const cricket::VideoFrame& frame) override;
251 bool SetCapturer(VideoCapturer* capturer); 249 bool SetCapturer(VideoCapturer* capturer);
252 void MuteStream(bool mute); 250 void MuteStream(bool mute);
253 bool DisconnectCapturer(); 251 bool DisconnectCapturer();
254 252
255 void Start(); 253 void Start();
256 void Stop(); 254 void Stop();
257 255
256 // Implements webrtc::LoadObserver.
257 void OnLoadUpdate(Load load) override;
258
258 const std::vector<uint32_t>& GetSsrcs() const; 259 const std::vector<uint32_t>& GetSsrcs() const;
259 VideoSenderInfo GetVideoSenderInfo(); 260 VideoSenderInfo GetVideoSenderInfo();
260 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); 261 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info);
261 262
262 private: 263 private:
263 // Parameters needed to reconstruct the underlying stream. 264 // Parameters needed to reconstruct the underlying stream.
264 // webrtc::VideoSendStream doesn't support setting a lot of options on the 265 // 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 266 // fly, so when those need to be changed we tear down and reconstruct with
266 // similar parameters depending on which options changed etc. 267 // similar parameters depending on which options changed etc.
267 struct VideoSendStreamParameters { 268 struct VideoSendStreamParameters {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 void SetCodecAndOptions(const VideoCodecSettings& codec, 335 void SetCodecAndOptions(const VideoCodecSettings& codec,
335 const VideoOptions& options) 336 const VideoOptions& options)
336 EXCLUSIVE_LOCKS_REQUIRED(lock_); 337 EXCLUSIVE_LOCKS_REQUIRED(lock_);
337 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_); 338 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_);
338 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( 339 webrtc::VideoEncoderConfig CreateVideoEncoderConfig(
339 const Dimensions& dimensions, 340 const Dimensions& dimensions,
340 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_); 341 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_);
341 void SetDimensions(int width, int height, bool is_screencast) 342 void SetDimensions(int width, int height, bool is_screencast)
342 EXCLUSIVE_LOCKS_REQUIRED(lock_); 343 EXCLUSIVE_LOCKS_REQUIRED(lock_);
343 344
345 rtc::ThreadChecker thread_checker_;
344 const std::vector<uint32_t> ssrcs_; 346 const std::vector<uint32_t> ssrcs_;
345 const std::vector<SsrcGroup> ssrc_groups_; 347 const std::vector<SsrcGroup> ssrc_groups_;
346 webrtc::Call* const call_; 348 webrtc::Call* const call_;
347 rtc::VideoSinkWants sink_wants_; 349 rtc::VideoSinkWants sink_wants_;
350 bool cpu_adapted_;
351 int number_of_cpu_adapt_changes_;
352 class LoadObserverProxy;
353 rtc::scoped_ptr<LoadObserverProxy> load_proxy_;
348 WebRtcVideoEncoderFactory* const external_encoder_factory_ 354 WebRtcVideoEncoderFactory* const external_encoder_factory_
349 GUARDED_BY(lock_); 355 GUARDED_BY(lock_);
350 356
351 rtc::CriticalSection lock_; 357 rtc::CriticalSection lock_;
352 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); 358 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_);
353 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); 359 VideoSendStreamParameters parameters_ GUARDED_BY(lock_);
354 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); 360 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_);
355 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); 361 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_);
356 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); 362 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_);
357 Dimensions last_dimensions_ GUARDED_BY(lock_); 363 Dimensions last_dimensions_ GUARDED_BY(lock_);
358 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = 364 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) =
359 webrtc::kVideoRotation_0; 365 webrtc::kVideoRotation_0;
360 366
361 VideoCapturer* capturer_ GUARDED_BY(lock_); 367 VideoCapturer* capturer_ GUARDED_BY(lock_);
362 bool sending_ GUARDED_BY(lock_); 368 bool sending_ GUARDED_BY(lock_);
363 bool muted_ GUARDED_BY(lock_); 369 bool muted_ GUARDED_BY(lock_);
364 int old_adapt_changes_ GUARDED_BY(lock_);
365 370
366 // The timestamp of the first frame received 371 // The timestamp of the first frame received
367 // Used to generate the timestamps of subsequent frames 372 // Used to generate the timestamps of subsequent frames
368 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_); 373 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_);
369 374
370 // The timestamp of the last frame received 375 // The timestamp of the last frame received
371 // Used to generate timestamp for the black frame when capturer is removed 376 // Used to generate timestamp for the black frame when capturer is removed
372 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); 377 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_);
373 }; 378 };
374 379
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 webrtc::Call::Config::BitrateConfig bitrate_config_; 521 webrtc::Call::Config::BitrateConfig bitrate_config_;
517 // TODO(deadbeef): Don't duplicate information between 522 // TODO(deadbeef): Don't duplicate information between
518 // send_params/recv_params, rtp_extensions, options, etc. 523 // send_params/recv_params, rtp_extensions, options, etc.
519 VideoSendParameters send_params_; 524 VideoSendParameters send_params_;
520 VideoRecvParameters recv_params_; 525 VideoRecvParameters recv_params_;
521 }; 526 };
522 527
523 } // namespace cricket 528 } // namespace cricket
524 529
525 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ 530 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698