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

Side by Side Diff: webrtc/video/vie_encoder.cc

Issue 2772033002: Add content type information to encoded images and corresponding rtp extension header (Closed)
Patch Set: Fix Mac CE Created 3 years, 8 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 DegradationPreference degradation_preference_ GUARDED_BY(&crit_); 249 DegradationPreference degradation_preference_ GUARDED_BY(&crit_);
250 rtc::VideoSourceInterface<VideoFrame>* source_ GUARDED_BY(&crit_); 250 rtc::VideoSourceInterface<VideoFrame>* source_ GUARDED_BY(&crit_);
251 251
252 RTC_DISALLOW_COPY_AND_ASSIGN(VideoSourceProxy); 252 RTC_DISALLOW_COPY_AND_ASSIGN(VideoSourceProxy);
253 }; 253 };
254 254
255 ViEEncoder::ViEEncoder(uint32_t number_of_cores, 255 ViEEncoder::ViEEncoder(uint32_t number_of_cores,
256 SendStatisticsProxy* stats_proxy, 256 SendStatisticsProxy* stats_proxy,
257 const VideoSendStream::Config::EncoderSettings& settings, 257 const VideoSendStream::Config::EncoderSettings& settings,
258 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, 258 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback,
259 EncodedFrameObserver* encoder_timing) 259 EncodedFrameObserver* encoder_timing,
260 VideoEncoderConfig::ContentType content_type)
260 : shutdown_event_(true /* manual_reset */, false), 261 : shutdown_event_(true /* manual_reset */, false),
261 number_of_cores_(number_of_cores), 262 number_of_cores_(number_of_cores),
262 initial_rampup_(0), 263 initial_rampup_(0),
263 source_proxy_(new VideoSourceProxy(this)), 264 source_proxy_(new VideoSourceProxy(this)),
264 sink_(nullptr), 265 sink_(nullptr),
265 settings_(settings), 266 settings_(settings),
266 codec_type_(PayloadNameToCodecType(settings.payload_name) 267 codec_type_(PayloadNameToCodecType(settings.payload_name)
267 .value_or(VideoCodecType::kVideoCodecUnknown)), 268 .value_or(VideoCodecType::kVideoCodecUnknown)),
269 content_type_(content_type),
268 video_sender_(Clock::GetRealTimeClock(), this, this), 270 video_sender_(Clock::GetRealTimeClock(), this, this),
269 overuse_detector_(GetCpuOveruseOptions(settings.full_overuse_time), 271 overuse_detector_(GetCpuOveruseOptions(settings.full_overuse_time),
270 this, 272 this,
271 encoder_timing, 273 encoder_timing,
272 stats_proxy), 274 stats_proxy),
273 stats_proxy_(stats_proxy), 275 stats_proxy_(stats_proxy),
274 pre_encode_callback_(pre_encode_callback), 276 pre_encode_callback_(pre_encode_callback),
275 module_process_thread_(nullptr), 277 module_process_thread_(nullptr),
276 pending_encoder_reconfiguration_(false), 278 pending_encoder_reconfiguration_(false),
277 encoder_start_bitrate_bps_(0), 279 encoder_start_bitrate_bps_(0),
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 encoder_config_ = std::move(config); 399 encoder_config_ = std::move(config);
398 pending_encoder_reconfiguration_ = true; 400 pending_encoder_reconfiguration_ = true;
399 401
400 // Reconfigure the encoder now if the encoder has an internal source or 402 // Reconfigure the encoder now if the encoder has an internal source or
401 // if the frame resolution is known. Otherwise, the reconfiguration is 403 // if the frame resolution is known. Otherwise, the reconfiguration is
402 // deferred until the next frame to minimize the number of reconfigurations. 404 // deferred until the next frame to minimize the number of reconfigurations.
403 // The codec configuration depends on incoming video frame size. 405 // The codec configuration depends on incoming video frame size.
404 if (last_frame_info_) { 406 if (last_frame_info_) {
405 ReconfigureEncoder(); 407 ReconfigureEncoder();
406 } else if (settings_.internal_source) { 408 } else if (settings_.internal_source) {
407 last_frame_info_ = rtc::Optional<VideoFrameInfo>( 409 last_frame_info_ = rtc::Optional<VideoFrameInfo>(VideoFrameInfo(
408 VideoFrameInfo(176, 144, kVideoRotation_0, false)); 410 176, 144, kVideoRotation_0, VideoContentType::kDefault, false));
409 ReconfigureEncoder(); 411 ReconfigureEncoder();
410 } 412 }
411 } 413 }
412 414
413 void ViEEncoder::ReconfigureEncoder() { 415 void ViEEncoder::ReconfigureEncoder() {
414 RTC_DCHECK_RUN_ON(&encoder_queue_); 416 RTC_DCHECK_RUN_ON(&encoder_queue_);
415 RTC_DCHECK(pending_encoder_reconfiguration_); 417 RTC_DCHECK(pending_encoder_reconfiguration_);
416 std::vector<VideoStream> streams = 418 std::vector<VideoStream> streams =
417 encoder_config_.video_stream_factory->CreateEncoderStreams( 419 encoder_config_.video_stream_factory->CreateEncoderStreams(
418 last_frame_info_->width, last_frame_info_->height, encoder_config_); 420 last_frame_info_->width, last_frame_info_->height, encoder_config_);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 } 480 }
479 } else { 481 } else {
480 quality_scaler_.reset(nullptr); 482 quality_scaler_.reset(nullptr);
481 initial_rampup_ = kMaxInitialFramedrop; 483 initial_rampup_ = kMaxInitialFramedrop;
482 } 484 }
483 } 485 }
484 486
485 void ViEEncoder::OnFrame(const VideoFrame& video_frame) { 487 void ViEEncoder::OnFrame(const VideoFrame& video_frame) {
486 RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_); 488 RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_);
487 VideoFrame incoming_frame = video_frame; 489 VideoFrame incoming_frame = video_frame;
488 490 if (content_type_ == VideoEncoderConfig::ContentType::kScreen)
491 incoming_frame.set_content_type(VideoContentType::kScreenshare);
489 // Local time in webrtc time base. 492 // Local time in webrtc time base.
490 int64_t current_time_us = clock_->TimeInMicroseconds(); 493 int64_t current_time_us = clock_->TimeInMicroseconds();
491 int64_t current_time_ms = current_time_us / rtc::kNumMicrosecsPerMillisec; 494 int64_t current_time_ms = current_time_us / rtc::kNumMicrosecsPerMillisec;
492 // TODO(nisse): This always overrides the incoming timestamp. Don't 495 // TODO(nisse): This always overrides the incoming timestamp. Don't
493 // do that, trust the frame source. 496 // do that, trust the frame source.
494 incoming_frame.set_timestamp_us(current_time_us); 497 incoming_frame.set_timestamp_us(current_time_us);
495 498
496 // Capture time may come from clock with an offset and drift from clock_. 499 // Capture time may come from clock with an offset and drift from clock_.
497 int64_t capture_ntp_time_ms; 500 int64_t capture_ntp_time_ms;
498 if (video_frame.ntp_time_ms() > 0) { 501 if (video_frame.ntp_time_ms() > 0) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 RTC_DCHECK_RUN_ON(&encoder_queue_); 565 RTC_DCHECK_RUN_ON(&encoder_queue_);
563 566
564 if (pre_encode_callback_) 567 if (pre_encode_callback_)
565 pre_encode_callback_->OnFrame(video_frame); 568 pre_encode_callback_->OnFrame(video_frame);
566 569
567 if (!last_frame_info_ || video_frame.width() != last_frame_info_->width || 570 if (!last_frame_info_ || video_frame.width() != last_frame_info_->width ||
568 video_frame.height() != last_frame_info_->height || 571 video_frame.height() != last_frame_info_->height ||
569 video_frame.rotation() != last_frame_info_->rotation || 572 video_frame.rotation() != last_frame_info_->rotation ||
570 video_frame.is_texture() != last_frame_info_->is_texture) { 573 video_frame.is_texture() != last_frame_info_->is_texture) {
571 pending_encoder_reconfiguration_ = true; 574 pending_encoder_reconfiguration_ = true;
572 last_frame_info_ = rtc::Optional<VideoFrameInfo>( 575 last_frame_info_ = rtc::Optional<VideoFrameInfo>(VideoFrameInfo(
573 VideoFrameInfo(video_frame.width(), video_frame.height(), 576 video_frame.width(), video_frame.height(), video_frame.rotation(),
574 video_frame.rotation(), video_frame.is_texture())); 577 video_frame.content_type(), video_frame.is_texture()));
575 LOG(LS_INFO) << "Video frame parameters changed: dimensions=" 578 LOG(LS_INFO) << "Video frame parameters changed: dimensions="
576 << last_frame_info_->width << "x" << last_frame_info_->height 579 << last_frame_info_->width << "x" << last_frame_info_->height
577 << ", rotation=" << last_frame_info_->rotation 580 << ", rotation=" << last_frame_info_->rotation
578 << ", texture=" << last_frame_info_->is_texture; 581 << ", texture=" << last_frame_info_->is_texture;
579 } 582 }
580 583
581 if (initial_rampup_ < kMaxInitialFramedrop && 584 if (initial_rampup_ < kMaxInitialFramedrop &&
582 video_frame.size() > 585 video_frame.size() >
583 MaximumFrameSizeForBitrate(encoder_start_bitrate_bps_ / 1000)) { 586 MaximumFrameSizeForBitrate(encoder_start_bitrate_bps_ / 1000)) {
584 LOG(LS_INFO) << "Dropping frame. Too large for target bitrate."; 587 LOG(LS_INFO) << "Dropping frame. Too large for target bitrate.";
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 --scale_counter_[reason]; 780 --scale_counter_[reason];
778 source_proxy_->RequestHigherResolutionThan(current_pixel_count); 781 source_proxy_->RequestHigherResolutionThan(current_pixel_count);
779 LOG(LS_INFO) << "Scaling up resolution."; 782 LOG(LS_INFO) << "Scaling up resolution.";
780 for (size_t i = 0; i < kScaleReasonSize; ++i) { 783 for (size_t i = 0; i < kScaleReasonSize; ++i) {
781 LOG(LS_INFO) << "Scaled " << scale_counter_[i] 784 LOG(LS_INFO) << "Scaled " << scale_counter_[i]
782 << " times for reason: " << (i ? "cpu" : "quality"); 785 << " times for reason: " << (i ? "cpu" : "quality");
783 } 786 }
784 } 787 }
785 788
786 } // namespace webrtc 789 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698