Revert "Refactor and remove media_optimization::MediaOptimization."
This reverts commit 07276e4f89a93b1479d7aeefa53b4fc32daf001b. Reason for revert: Speculative revert due to downstream crashes. Original change's description: > Refactor and remove media_optimization::MediaOptimization. > > This CL removes MediaOptmization and folds some of its functionality > into VideoStreamEncoder. > > The FPS tracking is now handled by a RateStatistics instance. Frame > dropping is still handled by FrameDropper. Both of these now live > directly in VideoStreamEncoder. > There is no intended change in behavior from this CL, but due to a new > way of measuring frame rate, some minor perf changes can be expected. > > A small change in behavior is that OnBitrateUpdated is now called > directly rather than on the next frame. Since both encoding frame and > setting rate allocations happen on the encoder worker thread, there's > really no reason to cache bitrates and wait until the next frame. > An edge case though is that if a new bitrate is set before the first > frame, we must remember that bitrate and then apply it after the video > bitrate allocator has been first created. > > In addition to existing unit tests, manual tests have been used to > confirm that frame dropping works as expected with misbehaving encoders. > > Bug: webrtc:10164 > Change-Id: I7ee9c8d3c4f2bcf23c8c420310b05a4d35d94744 > Reviewed-on: https://webrtc-review.googlesource.com/c/115620 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Niels Moller <nisse@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#26147} TBR=nisse@webrtc.org,sprang@webrtc.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:10164 Change-Id: Ie0dae19dd012bc09e793c9661a45823fd760c20c Reviewed-on: https://webrtc-review.googlesource.com/c/116780 Reviewed-by: Niels Moller <nisse@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26191}
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
#include "modules/video_coding/generic_decoder.h"
|
||||
#include "modules/video_coding/generic_encoder.h"
|
||||
#include "modules/video_coding/jitter_buffer.h"
|
||||
#include "modules/video_coding/media_optimization.h"
|
||||
#include "modules/video_coding/receiver.h"
|
||||
#include "modules/video_coding/timing.h"
|
||||
#include "rtc_base/onetimeevent.h"
|
||||
@ -62,6 +63,7 @@ class VideoSender {
|
||||
typedef VideoCodingModule::SenderNackMode SenderNackMode;
|
||||
|
||||
VideoSender(Clock* clock, EncodedImageCallback* post_encode_callback);
|
||||
|
||||
~VideoSender();
|
||||
|
||||
// Register the send codec to be used.
|
||||
@ -73,27 +75,60 @@ class VideoSender {
|
||||
void RegisterExternalEncoder(VideoEncoder* externalEncoder,
|
||||
bool internalSource);
|
||||
|
||||
// Update the the encoder with new bitrate allocation and framerate.
|
||||
int32_t SetChannelParameters(const VideoBitrateAllocation& bitrate_allocation,
|
||||
uint32_t framerate_fps);
|
||||
// Update the channel parameters based on new rates and rtt. This will also
|
||||
// cause an immediate call to VideoEncoder::SetRateAllocation().
|
||||
int32_t SetChannelParameters(
|
||||
uint32_t target_bitrate_bps,
|
||||
VideoBitrateAllocator* bitrate_allocator,
|
||||
VideoBitrateAllocationObserver* bitrate_updated_callback);
|
||||
|
||||
// Updates the channel parameters with a new bitrate allocation, but using the
|
||||
// current targit_bitrate, loss rate and rtt. That is, the distribution or
|
||||
// caps may be updated to a change to a new VideoCodec or allocation mode.
|
||||
// The new parameters will be stored as pending EncoderParameters, and the
|
||||
// encoder will only be updated on the next frame.
|
||||
void UpdateChannelParameters(
|
||||
VideoBitrateAllocator* bitrate_allocator,
|
||||
VideoBitrateAllocationObserver* bitrate_updated_callback);
|
||||
|
||||
int32_t AddVideoFrame(const VideoFrame& videoFrame,
|
||||
const CodecSpecificInfo* codecSpecificInfo,
|
||||
absl::optional<VideoEncoder::EncoderInfo> encoder_info);
|
||||
|
||||
int32_t IntraFrameRequest(size_t stream_index);
|
||||
int32_t EnableFrameDropper(bool enable);
|
||||
|
||||
private:
|
||||
EncoderParameters UpdateEncoderParameters(
|
||||
const EncoderParameters& params,
|
||||
VideoBitrateAllocator* bitrate_allocator,
|
||||
uint32_t target_bitrate_bps);
|
||||
void SetEncoderParameters(EncoderParameters params, bool has_internal_source)
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(encoder_crit_);
|
||||
VideoBitrateAllocation GetAllocation(
|
||||
uint32_t bitrate_bps,
|
||||
uint32_t framerate_fps,
|
||||
VideoBitrateAllocator* bitrate_allocator) const;
|
||||
|
||||
rtc::CriticalSection encoder_crit_;
|
||||
VCMGenericEncoder* _encoder;
|
||||
media_optimization::MediaOptimization _mediaOpt;
|
||||
VCMEncodedFrameCallback _encodedFrameCallback RTC_GUARDED_BY(encoder_crit_);
|
||||
EncodedImageCallback* const post_encode_callback_;
|
||||
VCMEncoderDataBase _codecDataBase RTC_GUARDED_BY(encoder_crit_);
|
||||
|
||||
// If frame dropper is not force disabled, frame dropping might still be
|
||||
// disabled if VideoEncoder::GetEncoderInfo() indicates that the encoder has a
|
||||
// trusted rate controller. This is determined on a per-frame basis, as the
|
||||
// encoder behavior might dynamically change.
|
||||
bool force_disable_frame_dropper_ RTC_GUARDED_BY(encoder_crit_);
|
||||
|
||||
// Must be accessed on the construction thread of VideoSender.
|
||||
VideoCodec current_codec_;
|
||||
rtc::SequencedTaskChecker sequenced_checker_;
|
||||
|
||||
rtc::CriticalSection params_crit_;
|
||||
EncoderParameters encoder_params_ RTC_GUARDED_BY(params_crit_);
|
||||
bool encoder_has_internal_source_ RTC_GUARDED_BY(params_crit_);
|
||||
std::vector<FrameType> next_frame_types_ RTC_GUARDED_BY(params_crit_);
|
||||
};
|
||||
|
Reference in New Issue
Block a user