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

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

Issue 2469993003: Remove WebRtcVideoSendStream2::VideoSink inheritance. Remove sending black frame on source remova… (Closed)
Patch Set: Rebased Created 3 years, 11 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/media/base/videoengine_unittest.h ('k') | webrtc/media/engine/webrtcvideoengine2.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 (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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 bool ValidateSendSsrcAvailability(const StreamParams& sp) const 224 bool ValidateSendSsrcAvailability(const StreamParams& sp) const
225 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); 225 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_);
226 bool ValidateReceiveSsrcAvailability(const StreamParams& sp) const 226 bool ValidateReceiveSsrcAvailability(const StreamParams& sp) const
227 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); 227 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_);
228 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) 228 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream)
229 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); 229 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_);
230 230
231 static std::string CodecSettingsVectorToString( 231 static std::string CodecSettingsVectorToString(
232 const std::vector<VideoCodecSettings>& codecs); 232 const std::vector<VideoCodecSettings>& codecs);
233 233
234 // Wrapper for the sender part, this is where the source is connected and 234 // Wrapper for the sender part.
235 // frames are then converted from cricket frames to webrtc frames.
236 class WebRtcVideoSendStream 235 class WebRtcVideoSendStream
237 : public rtc::VideoSinkInterface<webrtc::VideoFrame>, 236 : public rtc::VideoSourceInterface<webrtc::VideoFrame> {
238 public rtc::VideoSourceInterface<webrtc::VideoFrame> {
239 public: 237 public:
240 WebRtcVideoSendStream( 238 WebRtcVideoSendStream(
241 webrtc::Call* call, 239 webrtc::Call* call,
242 const StreamParams& sp, 240 const StreamParams& sp,
243 webrtc::VideoSendStream::Config config, 241 webrtc::VideoSendStream::Config config,
244 const VideoOptions& options, 242 const VideoOptions& options,
245 WebRtcVideoEncoderFactory* external_encoder_factory, 243 WebRtcVideoEncoderFactory* external_encoder_factory,
246 bool enable_cpu_overuse_detection, 244 bool enable_cpu_overuse_detection,
247 int max_bitrate_bps, 245 int max_bitrate_bps,
248 const rtc::Optional<VideoCodecSettings>& codec_settings, 246 const rtc::Optional<VideoCodecSettings>& codec_settings,
249 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions, 247 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions,
250 const VideoSendParameters& send_params); 248 const VideoSendParameters& send_params);
251 virtual ~WebRtcVideoSendStream(); 249 virtual ~WebRtcVideoSendStream();
252 250
253 void SetSendParameters(const ChangedSendParameters& send_params); 251 void SetSendParameters(const ChangedSendParameters& send_params);
254 bool SetRtpParameters(const webrtc::RtpParameters& parameters); 252 bool SetRtpParameters(const webrtc::RtpParameters& parameters);
255 webrtc::RtpParameters GetRtpParameters() const; 253 webrtc::RtpParameters GetRtpParameters() const;
256 254
257 // Implements rtc::VideoSourceInterface<webrtc::VideoFrame>. 255 // Implements rtc::VideoSourceInterface<webrtc::VideoFrame>.
258 // WebRtcVideoSendStream acts as a source to the webrtc::VideoSendStream 256 // WebRtcVideoSendStream acts as a source to the webrtc::VideoSendStream
259 // in |stream_|. 257 // in |stream_|. This is done to proxy VideoSinkWants from the encoder to
260 // TODO(perkj, nisse): Refactor WebRtcVideoSendStream to directly connect 258 // the worker thread.
261 // the camera input |source_| 259 void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
262 void AddOrUpdateSink(VideoSinkInterface<webrtc::VideoFrame>* sink,
263 const rtc::VideoSinkWants& wants) override; 260 const rtc::VideoSinkWants& wants) override;
264 void RemoveSink(VideoSinkInterface<webrtc::VideoFrame>* sink) override; 261 void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) override;
265 262
266 void OnFrame(const webrtc::VideoFrame& frame) override;
267 bool SetVideoSend(bool mute, 263 bool SetVideoSend(bool mute,
268 const VideoOptions* options, 264 const VideoOptions* options,
269 rtc::VideoSourceInterface<webrtc::VideoFrame>* source); 265 rtc::VideoSourceInterface<webrtc::VideoFrame>* source);
270 266
271 void SetSend(bool send); 267 void SetSend(bool send);
272 268
273 const std::vector<uint32_t>& GetSsrcs() const; 269 const std::vector<uint32_t>& GetSsrcs() const;
274 VideoSenderInfo GetVideoSenderInfo(bool log_stats); 270 VideoSenderInfo GetVideoSenderInfo(bool log_stats);
275 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); 271 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info);
276 272
(...skipping 22 matching lines...) Expand all
299 struct AllocatedEncoder { 295 struct AllocatedEncoder {
300 AllocatedEncoder(webrtc::VideoEncoder* encoder, 296 AllocatedEncoder(webrtc::VideoEncoder* encoder,
301 const cricket::VideoCodec& codec, 297 const cricket::VideoCodec& codec,
302 bool external); 298 bool external);
303 webrtc::VideoEncoder* encoder; 299 webrtc::VideoEncoder* encoder;
304 webrtc::VideoEncoder* external_encoder; 300 webrtc::VideoEncoder* external_encoder;
305 cricket::VideoCodec codec; 301 cricket::VideoCodec codec;
306 bool external; 302 bool external;
307 }; 303 };
308 304
309 // TODO(perkj): VideoFrameInfo is currently used for sending a black frame
310 // when the video source is removed. Consider moving that logic to
311 // VieEncoder or remove it.
312 struct VideoFrameInfo {
313 VideoFrameInfo()
314 : width(0),
315 height(0),
316 rotation(webrtc::kVideoRotation_0),
317 is_texture(false) {}
318 int width;
319 int height;
320 webrtc::VideoRotation rotation;
321 bool is_texture;
322 };
323
324 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings> 305 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings>
325 ConfigureVideoEncoderSettings(const VideoCodec& codec); 306 ConfigureVideoEncoderSettings(const VideoCodec& codec);
326 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec); 307 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec);
327 void DestroyVideoEncoder(AllocatedEncoder* encoder); 308 void DestroyVideoEncoder(AllocatedEncoder* encoder);
328 void SetCodec(const VideoCodecSettings& codec); 309 void SetCodec(const VideoCodecSettings& codec);
329 void RecreateWebRtcStream(); 310 void RecreateWebRtcStream();
330 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( 311 webrtc::VideoEncoderConfig CreateVideoEncoderConfig(
331 const VideoCodec& codec) const; 312 const VideoCodec& codec) const;
332 void ReconfigureEncoder(); 313 void ReconfigureEncoder();
333 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); 314 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters);
334 315
335 // Calls Start or Stop according to whether or not |sending_| is true, 316 // Calls Start or Stop according to whether or not |sending_| is true,
336 // and whether or not the encoding in |rtp_parameters_| is active. 317 // and whether or not the encoding in |rtp_parameters_| is active.
337 void UpdateSendState(); 318 void UpdateSendState();
338 319
339 rtc::ThreadChecker thread_checker_; 320 rtc::ThreadChecker thread_checker_;
340 rtc::AsyncInvoker invoker_; 321 rtc::AsyncInvoker invoker_;
341 rtc::Thread* worker_thread_; 322 rtc::Thread* worker_thread_;
342 const std::vector<uint32_t> ssrcs_ ACCESS_ON(&thread_checker_); 323 const std::vector<uint32_t> ssrcs_ ACCESS_ON(&thread_checker_);
343 const std::vector<SsrcGroup> ssrc_groups_ ACCESS_ON(&thread_checker_); 324 const std::vector<SsrcGroup> ssrc_groups_ ACCESS_ON(&thread_checker_);
344 webrtc::Call* const call_; 325 webrtc::Call* const call_;
345 const bool enable_cpu_overuse_detection_; 326 const bool enable_cpu_overuse_detection_;
346 rtc::VideoSourceInterface<webrtc::VideoFrame>* source_ 327 rtc::VideoSourceInterface<webrtc::VideoFrame>* source_
347 ACCESS_ON(&thread_checker_); 328 ACCESS_ON(&thread_checker_);
348 WebRtcVideoEncoderFactory* const external_encoder_factory_ 329 WebRtcVideoEncoderFactory* const external_encoder_factory_
349 ACCESS_ON(&thread_checker_); 330 ACCESS_ON(&thread_checker_);
350 331
351 rtc::CriticalSection lock_;
352 webrtc::VideoSendStream* stream_ ACCESS_ON(&thread_checker_); 332 webrtc::VideoSendStream* stream_ ACCESS_ON(&thread_checker_);
353 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_ 333 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_
354 GUARDED_BY(lock_); 334 ACCESS_ON(&thread_checker_);
355 // Contains settings that are the same for all streams in the MediaChannel, 335 // Contains settings that are the same for all streams in the MediaChannel,
356 // such as codecs, header extensions, and the global bitrate limit for the 336 // such as codecs, header extensions, and the global bitrate limit for the
357 // entire channel. 337 // entire channel.
358 VideoSendStreamParameters parameters_ ACCESS_ON(&thread_checker_); 338 VideoSendStreamParameters parameters_ ACCESS_ON(&thread_checker_);
359 // Contains settings that are unique for each stream, such as max_bitrate. 339 // Contains settings that are unique for each stream, such as max_bitrate.
360 // Does *not* contain codecs, however. 340 // Does *not* contain codecs, however.
361 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_. 341 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_.
362 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only 342 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only
363 // one stream per MediaChannel. 343 // one stream per MediaChannel.
364 webrtc::RtpParameters rtp_parameters_ ACCESS_ON(&thread_checker_); 344 webrtc::RtpParameters rtp_parameters_ ACCESS_ON(&thread_checker_);
365 AllocatedEncoder allocated_encoder_ ACCESS_ON(&thread_checker_); 345 AllocatedEncoder allocated_encoder_ ACCESS_ON(&thread_checker_);
366 VideoFrameInfo last_frame_info_ GUARDED_BY(lock_);
367 346
368 bool sending_ ACCESS_ON(&thread_checker_); 347 bool sending_ ACCESS_ON(&thread_checker_);
369
370 // The timestamp of the last frame received
371 // Used to generate timestamp for the black frame when source is removed
372 int64_t last_frame_timestamp_us_ GUARDED_BY(lock_);
373 }; 348 };
374 349
375 // Wrapper for the receiver part, contains configs etc. that are needed to 350 // Wrapper for the receiver part, contains configs etc. that are needed to
376 // reconstruct the underlying VideoReceiveStream. 351 // reconstruct the underlying VideoReceiveStream.
377 class WebRtcVideoReceiveStream 352 class WebRtcVideoReceiveStream
378 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { 353 : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
379 public: 354 public:
380 WebRtcVideoReceiveStream( 355 WebRtcVideoReceiveStream(
381 webrtc::Call* call, 356 webrtc::Call* call,
382 const StreamParams& sp, 357 const StreamParams& sp,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 // send_params/recv_params, rtp_extensions, options, etc. 486 // send_params/recv_params, rtp_extensions, options, etc.
512 VideoSendParameters send_params_; 487 VideoSendParameters send_params_;
513 VideoOptions default_send_options_; 488 VideoOptions default_send_options_;
514 VideoRecvParameters recv_params_; 489 VideoRecvParameters recv_params_;
515 int64_t last_stats_log_ms_; 490 int64_t last_stats_log_ms_;
516 }; 491 };
517 492
518 } // namespace cricket 493 } // namespace cricket
519 494
520 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ 495 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_
OLDNEW
« no previous file with comments | « webrtc/media/base/videoengine_unittest.h ('k') | webrtc/media/engine/webrtcvideoengine2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698