2014-12-09 10:36:40 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2014 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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MEDIA_ENGINE_SIMULCAST_ENCODER_ADAPTER_H_
|
|
|
|
|
#define MEDIA_ENGINE_SIMULCAST_ENCODER_ADAPTER_H_
|
2014-12-09 10:36:40 +00:00
|
|
|
|
2021-02-02 18:23:40 +01:00
|
|
|
#include <list>
|
2016-02-29 05:51:59 -08:00
|
|
|
#include <memory>
|
Reland of use allocated encoders in SimulcastEncoderAdapter. (patchset #1 id:1 of https://codereview.webrtc.org/2893003002/ )
Reason for reland:
Chrome encoder implementation fixed.
Original issue's description:
> Revert of Reuse allocated encoders in SimulcastEncoderAdapter. (patchset #15 id:320001 of https://codereview.webrtc.org/2830793005/ )
>
> Reason for revert:
> Breaks Chrome tests.
>
> Original issue's description:
> > Reuse allocated encoders in SimulcastEncoderAdapter.
> >
> > Prior to this change, the SimulcastEncoderAdapter would destroy and create
> > encoders whenever it is being reinitialized. After this change, the
> > SimulcastEncoderAdapter will cache the already allocated encoders, and reuse
> > them after reinitialization.
> >
> > This change will help in reducing the number of PictureID "jumps" that have
> > been seen around encoder reinitialization.
> >
> > TESTED=AppRTCMobile, Chrome desktop, and internal app, with forced encoder reinits every 30 frames and https://codereview.webrtc.org/2833493003/ applied.
> > BUG=webrtc:7475
> >
> > Review-Url: https://codereview.webrtc.org/2830793005
> > Cr-Commit-Position: refs/heads/master@{#18215}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/0b8bfb9d98b7a2011d80bcdf3f430bc040370dad
>
> TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7475
>
> Review-Url: https://codereview.webrtc.org/2893003002
> Cr-Commit-Position: refs/heads/master@{#18216}
> Committed: https://chromium.googlesource.com/external/webrtc/+/56e119e2e8b30d2d41c55c3a7983b077a5262718
TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7475
Review-Url: https://codereview.webrtc.org/2901493002
Cr-Commit-Position: refs/heads/master@{#18228}
2017-05-23 03:32:16 -07:00
|
|
|
#include <stack>
|
2016-01-20 15:53:55 +01:00
|
|
|
#include <string>
|
Reland of use allocated encoders in SimulcastEncoderAdapter. (patchset #1 id:1 of https://codereview.webrtc.org/2893003002/ )
Reason for reland:
Chrome encoder implementation fixed.
Original issue's description:
> Revert of Reuse allocated encoders in SimulcastEncoderAdapter. (patchset #15 id:320001 of https://codereview.webrtc.org/2830793005/ )
>
> Reason for revert:
> Breaks Chrome tests.
>
> Original issue's description:
> > Reuse allocated encoders in SimulcastEncoderAdapter.
> >
> > Prior to this change, the SimulcastEncoderAdapter would destroy and create
> > encoders whenever it is being reinitialized. After this change, the
> > SimulcastEncoderAdapter will cache the already allocated encoders, and reuse
> > them after reinitialization.
> >
> > This change will help in reducing the number of PictureID "jumps" that have
> > been seen around encoder reinitialization.
> >
> > TESTED=AppRTCMobile, Chrome desktop, and internal app, with forced encoder reinits every 30 frames and https://codereview.webrtc.org/2833493003/ applied.
> > BUG=webrtc:7475
> >
> > Review-Url: https://codereview.webrtc.org/2830793005
> > Cr-Commit-Position: refs/heads/master@{#18215}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/0b8bfb9d98b7a2011d80bcdf3f430bc040370dad
>
> TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7475
>
> Review-Url: https://codereview.webrtc.org/2893003002
> Cr-Commit-Position: refs/heads/master@{#18216}
> Committed: https://chromium.googlesource.com/external/webrtc/+/56e119e2e8b30d2d41c55c3a7983b077a5262718
TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7475
Review-Url: https://codereview.webrtc.org/2901493002
Cr-Commit-Position: refs/heads/master@{#18228}
2017-05-23 03:32:16 -07:00
|
|
|
#include <utility>
|
2014-12-09 10:36:40 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
2018-08-27 11:07:48 +02:00
|
|
|
#include "absl/types/optional.h"
|
2019-06-28 15:19:43 +02:00
|
|
|
#include "api/fec_controller_override.h"
|
2021-02-10 14:31:24 +01:00
|
|
|
#include "api/sequence_checker.h"
|
2018-10-19 00:51:18 -07:00
|
|
|
#include "api/video_codecs/sdp_video_format.h"
|
2019-06-11 14:57:57 +02:00
|
|
|
#include "api/video_codecs/video_encoder.h"
|
2021-01-14 16:37:26 +01:00
|
|
|
#include "api/video_codecs/video_encoder_factory.h"
|
2018-06-21 16:16:38 +02:00
|
|
|
#include "modules/video_coding/include/video_codec_interface.h"
|
2019-12-16 18:07:05 +01:00
|
|
|
#include "modules/video_coding/utility/framerate_controller.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/atomic_ops.h"
|
2021-01-20 15:36:13 +01:00
|
|
|
#include "rtc_base/experiments/encoder_info_settings.h"
|
2020-11-23 11:07:42 +01:00
|
|
|
#include "rtc_base/system/no_unique_address.h"
|
2019-04-02 11:33:59 +02:00
|
|
|
#include "rtc_base/system/rtc_export.h"
|
2014-12-09 10:36:40 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// SimulcastEncoderAdapter implements simulcast support by creating multiple
|
|
|
|
|
// webrtc::VideoEncoder instances with the given VideoEncoderFactory.
|
Reland of use allocated encoders in SimulcastEncoderAdapter. (patchset #1 id:1 of https://codereview.webrtc.org/2893003002/ )
Reason for reland:
Chrome encoder implementation fixed.
Original issue's description:
> Revert of Reuse allocated encoders in SimulcastEncoderAdapter. (patchset #15 id:320001 of https://codereview.webrtc.org/2830793005/ )
>
> Reason for revert:
> Breaks Chrome tests.
>
> Original issue's description:
> > Reuse allocated encoders in SimulcastEncoderAdapter.
> >
> > Prior to this change, the SimulcastEncoderAdapter would destroy and create
> > encoders whenever it is being reinitialized. After this change, the
> > SimulcastEncoderAdapter will cache the already allocated encoders, and reuse
> > them after reinitialization.
> >
> > This change will help in reducing the number of PictureID "jumps" that have
> > been seen around encoder reinitialization.
> >
> > TESTED=AppRTCMobile, Chrome desktop, and internal app, with forced encoder reinits every 30 frames and https://codereview.webrtc.org/2833493003/ applied.
> > BUG=webrtc:7475
> >
> > Review-Url: https://codereview.webrtc.org/2830793005
> > Cr-Commit-Position: refs/heads/master@{#18215}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/0b8bfb9d98b7a2011d80bcdf3f430bc040370dad
>
> TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7475
>
> Review-Url: https://codereview.webrtc.org/2893003002
> Cr-Commit-Position: refs/heads/master@{#18216}
> Committed: https://chromium.googlesource.com/external/webrtc/+/56e119e2e8b30d2d41c55c3a7983b077a5262718
TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7475
Review-Url: https://codereview.webrtc.org/2901493002
Cr-Commit-Position: refs/heads/master@{#18228}
2017-05-23 03:32:16 -07:00
|
|
|
// The object is created and destroyed on the worker thread, but all public
|
|
|
|
|
// interfaces should be called from the encoder task queue.
|
2019-04-02 11:33:59 +02:00
|
|
|
class RTC_EXPORT SimulcastEncoderAdapter : public VideoEncoder {
|
2014-12-09 10:36:40 +00:00
|
|
|
public:
|
2019-10-01 18:50:03 +02:00
|
|
|
// TODO(bugs.webrtc.org/11000): Remove when downstream usage is gone.
|
|
|
|
|
SimulcastEncoderAdapter(VideoEncoderFactory* primarty_factory,
|
|
|
|
|
const SdpVideoFormat& format);
|
|
|
|
|
// |primary_factory| produces the first-choice encoders to use.
|
|
|
|
|
// |fallback_factory|, if non-null, is used to create fallback encoder that
|
|
|
|
|
// will be used if InitEncode() fails for the primary encoder.
|
|
|
|
|
SimulcastEncoderAdapter(VideoEncoderFactory* primary_factory,
|
|
|
|
|
VideoEncoderFactory* fallback_factory,
|
|
|
|
|
const SdpVideoFormat& format);
|
2019-11-27 17:26:58 +01:00
|
|
|
~SimulcastEncoderAdapter() override;
|
2014-12-09 10:36:40 +00:00
|
|
|
|
Reland of use allocated encoders in SimulcastEncoderAdapter. (patchset #1 id:1 of https://codereview.webrtc.org/2893003002/ )
Reason for reland:
Chrome encoder implementation fixed.
Original issue's description:
> Revert of Reuse allocated encoders in SimulcastEncoderAdapter. (patchset #15 id:320001 of https://codereview.webrtc.org/2830793005/ )
>
> Reason for revert:
> Breaks Chrome tests.
>
> Original issue's description:
> > Reuse allocated encoders in SimulcastEncoderAdapter.
> >
> > Prior to this change, the SimulcastEncoderAdapter would destroy and create
> > encoders whenever it is being reinitialized. After this change, the
> > SimulcastEncoderAdapter will cache the already allocated encoders, and reuse
> > them after reinitialization.
> >
> > This change will help in reducing the number of PictureID "jumps" that have
> > been seen around encoder reinitialization.
> >
> > TESTED=AppRTCMobile, Chrome desktop, and internal app, with forced encoder reinits every 30 frames and https://codereview.webrtc.org/2833493003/ applied.
> > BUG=webrtc:7475
> >
> > Review-Url: https://codereview.webrtc.org/2830793005
> > Cr-Commit-Position: refs/heads/master@{#18215}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/0b8bfb9d98b7a2011d80bcdf3f430bc040370dad
>
> TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7475
>
> Review-Url: https://codereview.webrtc.org/2893003002
> Cr-Commit-Position: refs/heads/master@{#18216}
> Committed: https://chromium.googlesource.com/external/webrtc/+/56e119e2e8b30d2d41c55c3a7983b077a5262718
TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7475
Review-Url: https://codereview.webrtc.org/2901493002
Cr-Commit-Position: refs/heads/master@{#18228}
2017-05-23 03:32:16 -07:00
|
|
|
// Implements VideoEncoder.
|
2019-06-28 15:19:43 +02:00
|
|
|
void SetFecControllerOverride(
|
|
|
|
|
FecControllerOverride* fec_controller_override) override;
|
2015-03-04 12:58:35 +00:00
|
|
|
int Release() override;
|
2019-06-11 14:57:57 +02:00
|
|
|
int InitEncode(const VideoCodec* codec_settings,
|
|
|
|
|
const VideoEncoder::Settings& settings) override;
|
2015-05-29 17:21:40 -07:00
|
|
|
int Encode(const VideoFrame& input_image,
|
2019-03-07 10:18:23 +01:00
|
|
|
const std::vector<VideoFrameType>* frame_types) override;
|
2015-03-04 12:58:35 +00:00
|
|
|
int RegisterEncodeCompleteCallback(EncodedImageCallback* callback) override;
|
2019-04-12 13:59:09 +02:00
|
|
|
void SetRates(const RateControlParameters& parameters) override;
|
2019-06-28 18:43:44 +02:00
|
|
|
void OnPacketLossRateUpdate(float packet_loss_rate) override;
|
|
|
|
|
void OnRttUpdate(int64_t rtt_ms) override;
|
|
|
|
|
void OnLossNotification(const LossNotification& loss_notification) override;
|
2014-12-09 10:36:40 +00:00
|
|
|
|
2018-11-01 14:52:30 +01:00
|
|
|
EncoderInfo GetEncoderInfo() const override;
|
2015-04-21 15:30:11 -07:00
|
|
|
|
2014-12-09 10:36:40 +00:00
|
|
|
private:
|
2021-02-02 18:23:40 +01:00
|
|
|
class EncoderContext {
|
2021-01-14 16:37:26 +01:00
|
|
|
public:
|
2021-02-02 18:23:40 +01:00
|
|
|
EncoderContext(std::unique_ptr<VideoEncoder> encoder,
|
2021-07-13 16:27:11 +02:00
|
|
|
bool prefer_temporal_support,
|
|
|
|
|
VideoEncoder::EncoderInfo primary_info,
|
|
|
|
|
VideoEncoder::EncoderInfo fallback_info);
|
2021-01-14 16:37:26 +01:00
|
|
|
EncoderContext& operator=(EncoderContext&&) = delete;
|
2021-02-02 18:23:40 +01:00
|
|
|
|
|
|
|
|
VideoEncoder& encoder() { return *encoder_; }
|
|
|
|
|
bool prefer_temporal_support() { return prefer_temporal_support_; }
|
|
|
|
|
void Release();
|
|
|
|
|
|
2021-07-13 16:27:11 +02:00
|
|
|
const VideoEncoder::EncoderInfo& PrimaryInfo() { return primary_info_; }
|
|
|
|
|
|
|
|
|
|
const VideoEncoder::EncoderInfo& FallbackInfo() { return fallback_info_; }
|
|
|
|
|
|
2021-02-02 18:23:40 +01:00
|
|
|
private:
|
|
|
|
|
std::unique_ptr<VideoEncoder> encoder_;
|
|
|
|
|
bool prefer_temporal_support_;
|
2021-07-13 16:27:11 +02:00
|
|
|
const VideoEncoder::EncoderInfo primary_info_;
|
|
|
|
|
const VideoEncoder::EncoderInfo fallback_info_;
|
2021-02-02 18:23:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class StreamContext : public EncodedImageCallback {
|
|
|
|
|
public:
|
|
|
|
|
StreamContext(SimulcastEncoderAdapter* parent,
|
|
|
|
|
std::unique_ptr<EncoderContext> encoder_context,
|
|
|
|
|
std::unique_ptr<FramerateController> framerate_controller,
|
|
|
|
|
int stream_idx,
|
|
|
|
|
uint16_t width,
|
|
|
|
|
uint16_t height,
|
|
|
|
|
bool send_stream);
|
|
|
|
|
StreamContext(StreamContext&& rhs);
|
|
|
|
|
StreamContext& operator=(StreamContext&&) = delete;
|
|
|
|
|
~StreamContext() override;
|
2021-01-14 16:37:26 +01:00
|
|
|
|
|
|
|
|
Result OnEncodedImage(
|
|
|
|
|
const EncodedImage& encoded_image,
|
|
|
|
|
const CodecSpecificInfo* codec_specific_info) override;
|
|
|
|
|
void OnDroppedFrame(DropReason reason) override;
|
|
|
|
|
|
2021-02-02 18:23:40 +01:00
|
|
|
VideoEncoder& encoder() { return encoder_context_->encoder(); }
|
|
|
|
|
const VideoEncoder& encoder() const { return encoder_context_->encoder(); }
|
|
|
|
|
int stream_idx() const { return stream_idx_; }
|
2021-01-14 16:37:26 +01:00
|
|
|
uint16_t width() const { return width_; }
|
|
|
|
|
uint16_t height() const { return height_; }
|
2021-02-02 18:23:40 +01:00
|
|
|
bool is_keyframe_needed() const {
|
|
|
|
|
return !is_paused_ && is_keyframe_needed_;
|
|
|
|
|
}
|
|
|
|
|
void set_is_keyframe_needed() { is_keyframe_needed_ = true; }
|
|
|
|
|
bool is_paused() const { return is_paused_; }
|
|
|
|
|
void set_is_paused(bool is_paused) { is_paused_ = is_paused; }
|
2021-01-14 16:37:26 +01:00
|
|
|
absl::optional<float> target_fps() const {
|
|
|
|
|
return framerate_controller_ == nullptr
|
|
|
|
|
? absl::nullopt
|
|
|
|
|
: absl::optional<float>(
|
|
|
|
|
framerate_controller_->GetTargetRate());
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-02 18:23:40 +01:00
|
|
|
std::unique_ptr<EncoderContext> ReleaseEncoderContext() &&;
|
2021-01-14 16:37:26 +01:00
|
|
|
void OnKeyframe(Timestamp timestamp);
|
|
|
|
|
bool ShouldDropFrame(Timestamp timestamp);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
SimulcastEncoderAdapter* const parent_;
|
2021-02-02 18:23:40 +01:00
|
|
|
std::unique_ptr<EncoderContext> encoder_context_;
|
2021-01-14 16:37:26 +01:00
|
|
|
std::unique_ptr<FramerateController> framerate_controller_;
|
|
|
|
|
const int stream_idx_;
|
|
|
|
|
const uint16_t width_;
|
|
|
|
|
const uint16_t height_;
|
2021-02-02 18:23:40 +01:00
|
|
|
bool is_keyframe_needed_;
|
|
|
|
|
bool is_paused_;
|
2019-01-21 14:33:02 +01:00
|
|
|
};
|
|
|
|
|
|
2014-12-09 10:36:40 +00:00
|
|
|
bool Initialized() const;
|
|
|
|
|
|
Reland of use allocated encoders in SimulcastEncoderAdapter. (patchset #1 id:1 of https://codereview.webrtc.org/2893003002/ )
Reason for reland:
Chrome encoder implementation fixed.
Original issue's description:
> Revert of Reuse allocated encoders in SimulcastEncoderAdapter. (patchset #15 id:320001 of https://codereview.webrtc.org/2830793005/ )
>
> Reason for revert:
> Breaks Chrome tests.
>
> Original issue's description:
> > Reuse allocated encoders in SimulcastEncoderAdapter.
> >
> > Prior to this change, the SimulcastEncoderAdapter would destroy and create
> > encoders whenever it is being reinitialized. After this change, the
> > SimulcastEncoderAdapter will cache the already allocated encoders, and reuse
> > them after reinitialization.
> >
> > This change will help in reducing the number of PictureID "jumps" that have
> > been seen around encoder reinitialization.
> >
> > TESTED=AppRTCMobile, Chrome desktop, and internal app, with forced encoder reinits every 30 frames and https://codereview.webrtc.org/2833493003/ applied.
> > BUG=webrtc:7475
> >
> > Review-Url: https://codereview.webrtc.org/2830793005
> > Cr-Commit-Position: refs/heads/master@{#18215}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/0b8bfb9d98b7a2011d80bcdf3f430bc040370dad
>
> TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7475
>
> Review-Url: https://codereview.webrtc.org/2893003002
> Cr-Commit-Position: refs/heads/master@{#18216}
> Committed: https://chromium.googlesource.com/external/webrtc/+/56e119e2e8b30d2d41c55c3a7983b077a5262718
TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7475
Review-Url: https://codereview.webrtc.org/2901493002
Cr-Commit-Position: refs/heads/master@{#18228}
2017-05-23 03:32:16 -07:00
|
|
|
void DestroyStoredEncoders();
|
|
|
|
|
|
2021-07-13 16:27:11 +02:00
|
|
|
// This method creates encoder. May reuse previously created encoders from
|
|
|
|
|
// |cached_encoder_contexts_|. It's const because it's used from
|
|
|
|
|
// const GetEncoderInfo().
|
2021-02-02 18:23:40 +01:00
|
|
|
std::unique_ptr<EncoderContext> FetchOrCreateEncoderContext(
|
2021-07-13 16:27:11 +02:00
|
|
|
bool is_lowest_quality_stream) const;
|
2021-02-02 18:23:40 +01:00
|
|
|
|
|
|
|
|
webrtc::VideoCodec MakeStreamCodec(const webrtc::VideoCodec& codec,
|
|
|
|
|
int stream_idx,
|
|
|
|
|
uint32_t start_bitrate_kbps,
|
|
|
|
|
bool is_lowest_quality_stream,
|
|
|
|
|
bool is_highest_quality_stream);
|
|
|
|
|
|
2021-01-14 16:37:26 +01:00
|
|
|
EncodedImageCallback::Result OnEncodedImage(
|
|
|
|
|
size_t stream_idx,
|
|
|
|
|
const EncodedImage& encoded_image,
|
|
|
|
|
const CodecSpecificInfo* codec_specific_info);
|
|
|
|
|
|
|
|
|
|
void OnDroppedFrame(size_t stream_idx);
|
|
|
|
|
|
2021-01-15 15:03:31 +01:00
|
|
|
void OverrideFromFieldTrial(VideoEncoder::EncoderInfo* info) const;
|
|
|
|
|
|
Reland of use allocated encoders in SimulcastEncoderAdapter. (patchset #1 id:1 of https://codereview.webrtc.org/2893003002/ )
Reason for reland:
Chrome encoder implementation fixed.
Original issue's description:
> Revert of Reuse allocated encoders in SimulcastEncoderAdapter. (patchset #15 id:320001 of https://codereview.webrtc.org/2830793005/ )
>
> Reason for revert:
> Breaks Chrome tests.
>
> Original issue's description:
> > Reuse allocated encoders in SimulcastEncoderAdapter.
> >
> > Prior to this change, the SimulcastEncoderAdapter would destroy and create
> > encoders whenever it is being reinitialized. After this change, the
> > SimulcastEncoderAdapter will cache the already allocated encoders, and reuse
> > them after reinitialization.
> >
> > This change will help in reducing the number of PictureID "jumps" that have
> > been seen around encoder reinitialization.
> >
> > TESTED=AppRTCMobile, Chrome desktop, and internal app, with forced encoder reinits every 30 frames and https://codereview.webrtc.org/2833493003/ applied.
> > BUG=webrtc:7475
> >
> > Review-Url: https://codereview.webrtc.org/2830793005
> > Cr-Commit-Position: refs/heads/master@{#18215}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/0b8bfb9d98b7a2011d80bcdf3f430bc040370dad
>
> TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7475
>
> Review-Url: https://codereview.webrtc.org/2893003002
> Cr-Commit-Position: refs/heads/master@{#18216}
> Committed: https://chromium.googlesource.com/external/webrtc/+/56e119e2e8b30d2d41c55c3a7983b077a5262718
TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7475
Review-Url: https://codereview.webrtc.org/2901493002
Cr-Commit-Position: refs/heads/master@{#18228}
2017-05-23 03:32:16 -07:00
|
|
|
volatile int inited_; // Accessed atomically.
|
2019-10-01 18:50:03 +02:00
|
|
|
VideoEncoderFactory* const primary_encoder_factory_;
|
|
|
|
|
VideoEncoderFactory* const fallback_encoder_factory_;
|
2018-05-28 10:24:22 +02:00
|
|
|
const SdpVideoFormat video_format_;
|
2014-12-09 10:36:40 +00:00
|
|
|
VideoCodec codec_;
|
2021-02-02 18:23:40 +01:00
|
|
|
int total_streams_count_;
|
|
|
|
|
bool bypass_mode_;
|
|
|
|
|
std::vector<StreamContext> stream_contexts_;
|
2014-12-09 10:36:40 +00:00
|
|
|
EncodedImageCallback* encoded_complete_callback_;
|
Reland of use allocated encoders in SimulcastEncoderAdapter. (patchset #1 id:1 of https://codereview.webrtc.org/2893003002/ )
Reason for reland:
Chrome encoder implementation fixed.
Original issue's description:
> Revert of Reuse allocated encoders in SimulcastEncoderAdapter. (patchset #15 id:320001 of https://codereview.webrtc.org/2830793005/ )
>
> Reason for revert:
> Breaks Chrome tests.
>
> Original issue's description:
> > Reuse allocated encoders in SimulcastEncoderAdapter.
> >
> > Prior to this change, the SimulcastEncoderAdapter would destroy and create
> > encoders whenever it is being reinitialized. After this change, the
> > SimulcastEncoderAdapter will cache the already allocated encoders, and reuse
> > them after reinitialization.
> >
> > This change will help in reducing the number of PictureID "jumps" that have
> > been seen around encoder reinitialization.
> >
> > TESTED=AppRTCMobile, Chrome desktop, and internal app, with forced encoder reinits every 30 frames and https://codereview.webrtc.org/2833493003/ applied.
> > BUG=webrtc:7475
> >
> > Review-Url: https://codereview.webrtc.org/2830793005
> > Cr-Commit-Position: refs/heads/master@{#18215}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/0b8bfb9d98b7a2011d80bcdf3f430bc040370dad
>
> TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7475
>
> Review-Url: https://codereview.webrtc.org/2893003002
> Cr-Commit-Position: refs/heads/master@{#18216}
> Committed: https://chromium.googlesource.com/external/webrtc/+/56e119e2e8b30d2d41c55c3a7983b077a5262718
TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7475
Review-Url: https://codereview.webrtc.org/2901493002
Cr-Commit-Position: refs/heads/master@{#18228}
2017-05-23 03:32:16 -07:00
|
|
|
|
|
|
|
|
// Used for checking the single-threaded access of the encoder interface.
|
2020-11-23 11:07:42 +01:00
|
|
|
RTC_NO_UNIQUE_ADDRESS SequenceChecker encoder_queue_;
|
Reland of use allocated encoders in SimulcastEncoderAdapter. (patchset #1 id:1 of https://codereview.webrtc.org/2893003002/ )
Reason for reland:
Chrome encoder implementation fixed.
Original issue's description:
> Revert of Reuse allocated encoders in SimulcastEncoderAdapter. (patchset #15 id:320001 of https://codereview.webrtc.org/2830793005/ )
>
> Reason for revert:
> Breaks Chrome tests.
>
> Original issue's description:
> > Reuse allocated encoders in SimulcastEncoderAdapter.
> >
> > Prior to this change, the SimulcastEncoderAdapter would destroy and create
> > encoders whenever it is being reinitialized. After this change, the
> > SimulcastEncoderAdapter will cache the already allocated encoders, and reuse
> > them after reinitialization.
> >
> > This change will help in reducing the number of PictureID "jumps" that have
> > been seen around encoder reinitialization.
> >
> > TESTED=AppRTCMobile, Chrome desktop, and internal app, with forced encoder reinits every 30 frames and https://codereview.webrtc.org/2833493003/ applied.
> > BUG=webrtc:7475
> >
> > Review-Url: https://codereview.webrtc.org/2830793005
> > Cr-Commit-Position: refs/heads/master@{#18215}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/0b8bfb9d98b7a2011d80bcdf3f430bc040370dad
>
> TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7475
>
> Review-Url: https://codereview.webrtc.org/2893003002
> Cr-Commit-Position: refs/heads/master@{#18216}
> Committed: https://chromium.googlesource.com/external/webrtc/+/56e119e2e8b30d2d41c55c3a7983b077a5262718
TBR=stefan@webrtc.org,noahric@chromium.org,glaznev@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7475
Review-Url: https://codereview.webrtc.org/2901493002
Cr-Commit-Position: refs/heads/master@{#18228}
2017-05-23 03:32:16 -07:00
|
|
|
|
2021-07-13 16:27:11 +02:00
|
|
|
// Store previously created and released encoders , so they don't have to be
|
|
|
|
|
// recreated. Remaining encoders are destroyed by the destructor.
|
|
|
|
|
// Marked as |mutable| becuase we may need to temporarily create encoder in
|
|
|
|
|
// GetEncoderInfo(), which is const.
|
|
|
|
|
mutable std::list<std::unique_ptr<EncoderContext>> cached_encoder_contexts_;
|
2018-08-27 11:07:48 +02:00
|
|
|
|
|
|
|
|
const absl::optional<unsigned int> experimental_boosted_screenshare_qp_;
|
2019-02-13 10:49:37 +01:00
|
|
|
const bool boost_base_layer_quality_;
|
2020-01-31 13:51:12 +01:00
|
|
|
const bool prefer_temporal_support_on_base_layer_;
|
2021-01-15 15:03:31 +01:00
|
|
|
|
2021-01-20 15:36:13 +01:00
|
|
|
const SimulcastEncoderAdapterEncoderInfoSettings encoder_info_override_;
|
2014-12-09 10:36:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MEDIA_ENGINE_SIMULCAST_ENCODER_ADAPTER_H_
|