Reason for revert: Looks like there's still one failing perf test: RampUpTest.UpDownUpTransportSequenceNumberPacketLoss Original issue's description: > Reland of Periodically update codec bit/frame rate settings. (patchset #1 id:1 of https://codereview.webrtc.org/2923993002/ ) > > Reason for revert: > Create reland cl that we can patch with fix. > > Original issue's description: > > Revert of Periodically update codec bit/frame rate settings. (patchset #8 id:140001 of https://codereview.webrtc.org/2883963002/ ) > > > > Reason for revert: > > Breaks some Call perf tests that are not run by the try bots.... > > > > Original issue's description: > > > Fix bug in vie_encoder.cc which caused channel parameters not to be updated at regular intervals, as it was intended. > > > > > > That however exposes a bunch of failed test, so this CL also fixed a few other things: > > > * FakeEncoder should trust the configured FPS value rather than guesstimating itself based on the realtime clock, so as not to completely undershoot targets in offline mode. Also, compensate for key-frame overshoots when outputting delta frames. > > > * FrameDropper should not assuming incoming frame rate is 0 if no frames have been seen. > > > * Fix a bunch of test cases that started failing because they were relying on the fake encoder undershooting. > > > * Fix test > > > > > > BUG=7664 > > > > > > Review-Url: https://codereview.webrtc.org/2883963002 > > > Cr-Commit-Position: refs/heads/master@{#18473} > > > Committed:6431e21da6> > > > TBR=stefan@webrtc.org,holmer@google.com > > # Skipping CQ checks because original CL landed less than 1 days ago. > > NOPRESUBMIT=true > > NOTREECHECKS=true > > NOTRY=true > > BUG=7664 > > > > Review-Url: https://codereview.webrtc.org/2923993002 > > Cr-Commit-Position: refs/heads/master@{#18475} > > Committed:5390c4814d> > TBR=stefan@webrtc.org,holmer@google.com > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=7664 > > Review-Url: https://codereview.webrtc.org/2924023002 > Cr-Commit-Position: refs/heads/master@{#18497} > Committed:cdafeda1cbTBR=stefan@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=7664 Review-Url: https://codereview.webrtc.org/2926283002 Cr-Commit-Position: refs/heads/master@{#18500}
132 lines
4.5 KiB
C++
132 lines
4.5 KiB
C++
/*
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef WEBRTC_TEST_FAKE_ENCODER_H_
|
|
#define WEBRTC_TEST_FAKE_ENCODER_H_
|
|
|
|
#include <vector>
|
|
#include <memory>
|
|
|
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
|
#include "webrtc/base/criticalsection.h"
|
|
#include "webrtc/base/sequenced_task_checker.h"
|
|
#include "webrtc/base/task_queue.h"
|
|
#include "webrtc/common_types.h"
|
|
#include "webrtc/system_wrappers/include/clock.h"
|
|
|
|
namespace webrtc {
|
|
namespace test {
|
|
|
|
class FakeEncoder : public VideoEncoder {
|
|
public:
|
|
explicit FakeEncoder(Clock* clock);
|
|
virtual ~FakeEncoder() = default;
|
|
|
|
// Sets max bitrate. Not thread-safe, call before registering the encoder.
|
|
void SetMaxBitrate(int max_kbps);
|
|
|
|
int32_t InitEncode(const VideoCodec* config,
|
|
int32_t number_of_cores,
|
|
size_t max_payload_size) override;
|
|
int32_t Encode(const VideoFrame& input_image,
|
|
const CodecSpecificInfo* codec_specific_info,
|
|
const std::vector<FrameType>* frame_types) override;
|
|
int32_t RegisterEncodeCompleteCallback(
|
|
EncodedImageCallback* callback) override;
|
|
int32_t Release() override;
|
|
int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
|
|
int32_t SetRateAllocation(const BitrateAllocation& rate_allocation,
|
|
uint32_t framerate) override;
|
|
const char* ImplementationName() const override;
|
|
|
|
static const char* kImplementationName;
|
|
|
|
protected:
|
|
Clock* const clock_;
|
|
VideoCodec config_ GUARDED_BY(crit_sect_);
|
|
EncodedImageCallback* callback_ GUARDED_BY(crit_sect_);
|
|
BitrateAllocation target_bitrate_ GUARDED_BY(crit_sect_);
|
|
int max_target_bitrate_kbps_ GUARDED_BY(crit_sect_);
|
|
int64_t last_encode_time_ms_ GUARDED_BY(crit_sect_);
|
|
rtc::CriticalSection crit_sect_;
|
|
|
|
uint8_t encoded_buffer_[100000];
|
|
};
|
|
|
|
class FakeH264Encoder : public FakeEncoder, public EncodedImageCallback {
|
|
public:
|
|
explicit FakeH264Encoder(Clock* clock);
|
|
virtual ~FakeH264Encoder() = default;
|
|
|
|
int32_t RegisterEncodeCompleteCallback(
|
|
EncodedImageCallback* callback) override;
|
|
|
|
Result OnEncodedImage(const EncodedImage& encodedImage,
|
|
const CodecSpecificInfo* codecSpecificInfo,
|
|
const RTPFragmentationHeader* fragments) override;
|
|
|
|
private:
|
|
EncodedImageCallback* callback_ GUARDED_BY(local_crit_sect_);
|
|
int idr_counter_ GUARDED_BY(local_crit_sect_);
|
|
rtc::CriticalSection local_crit_sect_;
|
|
};
|
|
|
|
class DelayedEncoder : public test::FakeEncoder {
|
|
public:
|
|
DelayedEncoder(Clock* clock, int delay_ms);
|
|
virtual ~DelayedEncoder() = default;
|
|
|
|
void SetDelay(int delay_ms);
|
|
int32_t Encode(const VideoFrame& input_image,
|
|
const CodecSpecificInfo* codec_specific_info,
|
|
const std::vector<FrameType>* frame_types) override;
|
|
|
|
private:
|
|
int delay_ms_ ACCESS_ON(sequence_checker_);
|
|
rtc::SequencedTaskChecker sequence_checker_;
|
|
};
|
|
|
|
// This class implements a multi-threaded fake encoder by posting
|
|
// FakeH264Encoder::Encode(.) tasks to |queue1_| and |queue2_|, in an
|
|
// alternating fashion. The class itself does not need to be thread safe,
|
|
// as it is called from the task queue in ViEEncoder.
|
|
class MultithreadedFakeH264Encoder : public test::FakeH264Encoder {
|
|
public:
|
|
explicit MultithreadedFakeH264Encoder(Clock* clock);
|
|
virtual ~MultithreadedFakeH264Encoder() = default;
|
|
|
|
int32_t InitEncode(const VideoCodec* config,
|
|
int32_t number_of_cores,
|
|
size_t max_payload_size) override;
|
|
|
|
int32_t Encode(const VideoFrame& input_image,
|
|
const CodecSpecificInfo* codec_specific_info,
|
|
const std::vector<FrameType>* frame_types) override;
|
|
|
|
int32_t EncodeCallback(const VideoFrame& input_image,
|
|
const CodecSpecificInfo* codec_specific_info,
|
|
const std::vector<FrameType>* frame_types);
|
|
|
|
int32_t Release() override;
|
|
|
|
protected:
|
|
class EncodeTask;
|
|
|
|
int current_queue_ ACCESS_ON(sequence_checker_);
|
|
std::unique_ptr<rtc::TaskQueue> queue1_ ACCESS_ON(sequence_checker_);
|
|
std::unique_ptr<rtc::TaskQueue> queue2_ ACCESS_ON(sequence_checker_);
|
|
rtc::SequencedTaskChecker sequence_checker_;
|
|
};
|
|
|
|
} // namespace test
|
|
} // namespace webrtc
|
|
|
|
#endif // WEBRTC_TEST_FAKE_ENCODER_H_
|