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

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

Issue 1936503002: Removed SSRC knowledge from ViEEncoder. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@move_payload_router2
Patch Set: Fix unittest. Created 4 years, 7 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #include "webrtc/video/video_send_stream.h" 11 #include "webrtc/video/video_send_stream.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <sstream> 14 #include <sstream>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
20 #include "webrtc/base/trace_event.h" 20 #include "webrtc/base/trace_event.h"
21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
22 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 22 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
23 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" 23 #include "webrtc/modules/congestion_controller/include/congestion_controller.h"
24 #include "webrtc/modules/pacing/packet_router.h" 24 #include "webrtc/modules/pacing/packet_router.h"
25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
26 #include "webrtc/modules/utility/include/process_thread.h" 26 #include "webrtc/modules/utility/include/process_thread.h"
27 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h"
27 #include "webrtc/video/call_stats.h" 28 #include "webrtc/video/call_stats.h"
28 #include "webrtc/video/video_capture_input.h" 29 #include "webrtc/video/video_capture_input.h"
29 #include "webrtc/video/vie_remb.h" 30 #include "webrtc/video/vie_remb.h"
30 #include "webrtc/video_send_stream.h" 31 #include "webrtc/video_send_stream.h"
31 32
32 namespace webrtc { 33 namespace webrtc {
33 34
34 class RtcpIntraFrameObserver; 35 class RtcpIntraFrameObserver;
35 class TransportFeedbackObserver; 36 class TransportFeedbackObserver;
36 37
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 remb_(remb), 366 remb_(remb),
366 encoder_thread_(EncoderThreadFunction, this, "EncoderThread"), 367 encoder_thread_(EncoderThreadFunction, this, "EncoderThread"),
367 encoder_wakeup_event_(false, false), 368 encoder_wakeup_event_(false, false),
368 stop_encoder_thread_(0), 369 stop_encoder_thread_(0),
369 overuse_detector_( 370 overuse_detector_(
370 Clock::GetRealTimeClock(), 371 Clock::GetRealTimeClock(),
371 GetCpuOveruseOptions(config.encoder_settings.full_overuse_time), 372 GetCpuOveruseOptions(config.encoder_settings.full_overuse_time),
372 this, 373 this,
373 config.post_encode_callback, 374 config.post_encode_callback,
374 &stats_proxy_), 375 &stats_proxy_),
376 encoder_feedback_(Clock::GetRealTimeClock()),
375 vie_encoder_(num_cpu_cores, 377 vie_encoder_(num_cpu_cores,
376 config_.rtp.ssrcs,
377 module_process_thread_, 378 module_process_thread_,
378 &stats_proxy_, 379 &stats_proxy_,
379 config.pre_encode_callback, 380 config.pre_encode_callback,
380 &overuse_detector_, 381 &overuse_detector_,
381 congestion_controller_->pacer()), 382 congestion_controller_->pacer()),
382 video_sender_(vie_encoder_.video_sender()), 383 video_sender_(vie_encoder_.video_sender()),
383 bandwidth_observer_(congestion_controller_->GetBitrateController() 384 bandwidth_observer_(congestion_controller_->GetBitrateController()
384 ->CreateRtcpBandwidthObserver()), 385 ->CreateRtcpBandwidthObserver()),
385 rtp_rtcp_modules_(CreateRtpRtcpModules( 386 rtp_rtcp_modules_(CreateRtpRtcpModules(
386 config.send_transport, 387 config.send_transport,
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 encoder_settings->video_codec.startBitrate = 560 encoder_settings->video_codec.startBitrate =
560 bitrate_allocator_->AddObserver( 561 bitrate_allocator_->AddObserver(
561 this, encoder_settings->video_codec.minBitrate * 1000, 562 this, encoder_settings->video_codec.minBitrate * 1000,
562 encoder_settings->video_codec.maxBitrate * 1000) / 563 encoder_settings->video_codec.maxBitrate * 1000) /
563 1000; 564 1000;
564 565
565 payload_router_.SetSendStreams(encoder_settings->streams); 566 payload_router_.SetSendStreams(encoder_settings->streams);
566 vie_encoder_.SetEncoder(encoder_settings->video_codec, 567 vie_encoder_.SetEncoder(encoder_settings->video_codec,
567 encoder_settings->min_transmit_bitrate_bps, 568 encoder_settings->min_transmit_bitrate_bps,
568 payload_router_.MaxPayloadLength(), this); 569 payload_router_.MaxPayloadLength(), this);
570
571 // Clear stats for disabled layers.
572 for (size_t i = encoder_settings->streams.size();
573 i < config_.rtp.ssrcs.size(); ++i) {
574 stats_proxy_.OnInactiveSsrc(config_.rtp.ssrcs[i]);
575 }
576
569 if (config_.suspend_below_min_bitrate) { 577 if (config_.suspend_below_min_bitrate) {
570 video_sender_->SuspendBelowMinBitrate(); 578 video_sender_->SuspendBelowMinBitrate();
571 bitrate_allocator_->EnforceMinBitrate(false); 579 bitrate_allocator_->EnforceMinBitrate(false);
572 } 580 }
573 // We might've gotten new settings while configuring the encoder settings, 581 // We might've gotten new settings while configuring the encoder settings,
574 // restart from the top to see if that's the case before trying to encode 582 // restart from the top to see if that's the case before trying to encode
575 // a frame (which might correspond to the last frame size). 583 // a frame (which might correspond to the last frame size).
576 encoder_wakeup_event_.Set(); 584 encoder_wakeup_event_.Set();
577 continue; 585 continue;
578 } 586 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 if (config_.overuse_callback) 621 if (config_.overuse_callback)
614 config_.overuse_callback->OnLoadUpdate(LoadObserver::kUnderuse); 622 config_.overuse_callback->OnLoadUpdate(LoadObserver::kUnderuse);
615 } 623 }
616 624
617 int32_t VideoSendStream::Encoded(const EncodedImage& encoded_image, 625 int32_t VideoSendStream::Encoded(const EncodedImage& encoded_image,
618 const CodecSpecificInfo* codec_specific_info, 626 const CodecSpecificInfo* codec_specific_info,
619 const RTPFragmentationHeader* fragmentation) { 627 const RTPFragmentationHeader* fragmentation) {
620 // |encoded_frame_proxy_| forwards frames to |config_.post_encode_callback|; 628 // |encoded_frame_proxy_| forwards frames to |config_.post_encode_callback|;
621 encoded_frame_proxy_.Encoded(encoded_image, codec_specific_info, 629 encoded_frame_proxy_.Encoded(encoded_image, codec_specific_info,
622 fragmentation); 630 fragmentation);
623 return payload_router_.Encoded(encoded_image, codec_specific_info, 631 int32_t return_value = payload_router_.Encoded(
624 fragmentation); 632 encoded_image, codec_specific_info, fragmentation);
633
634 if (kEnableFrameRecording) {
635 int layer = codec_specific_info->codecType == kVideoCodecVP8
636 ? codec_specific_info->codecSpecific.VP8.simulcastIdx
637 : 0;
638 IvfFileWriter* file_writer;
639 {
640 if (file_writers_[layer] == nullptr) {
641 std::ostringstream oss;
642 oss << "send_bitstream_ssrc";
643 for (uint32_t ssrc : config_.rtp.ssrcs)
644 oss << "_" << ssrc;
645 oss << "_layer" << layer << ".ivf";
646 file_writers_[layer] =
647 IvfFileWriter::Open(oss.str(), codec_specific_info->codecType);
648 }
649 file_writer = file_writers_[layer].get();
650 }
651 if (file_writer) {
652 bool ok = file_writer->WriteFrame(encoded_image);
653 RTC_DCHECK(ok);
654 }
655 }
656
657 return return_value;
625 } 658 }
626 659
627 void VideoSendStream::ConfigureProtection() { 660 void VideoSendStream::ConfigureProtection() {
628 // Enable NACK, FEC or both. 661 // Enable NACK, FEC or both.
629 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; 662 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0;
630 bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1; 663 bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1;
631 // Payload types without picture ID cannot determine that a stream is complete 664 // Payload types without picture ID cannot determine that a stream is complete
632 // without retransmitting FEC, so using FEC + NACK for H.264 (for instance) is 665 // without retransmitting FEC, so using FEC + NACK for H.264 (for instance) is
633 // a waste of bandwidth since FEC packets still have to be transmitted. Note 666 // a waste of bandwidth since FEC packets still have to be transmitted. Note
634 // that this is not the case with FLEXFEC. 667 // that this is not the case with FLEXFEC.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 &module_nack_rate); 800 &module_nack_rate);
768 *sent_video_rate_bps += module_video_rate; 801 *sent_video_rate_bps += module_video_rate;
769 *sent_nack_rate_bps += module_nack_rate; 802 *sent_nack_rate_bps += module_nack_rate;
770 *sent_fec_rate_bps += module_fec_rate; 803 *sent_fec_rate_bps += module_fec_rate;
771 } 804 }
772 return 0; 805 return 0;
773 } 806 }
774 807
775 } // namespace internal 808 } // namespace internal
776 } // namespace webrtc 809 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698