#include "third_party/blink/renderer/modules/webcodecs/codec_pressure_gauge.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#if !BUILDFLAG(IS_WIN)
#define USE_SHARED_INSTANCE
#endif
#if BUILDFLAG(IS_WIN)
constexpr int kDecoderPressureThreshold = 6;
constexpr int kEncoderPressureThreshold = 0;
#elif BUILDFLAG(IS_CHROMEOS)
constexpr int kSharedPressureThreshold = 3;
#elif BUILDFLAG(IS_MAC)
constexpr int kSharedPressureThreshold = 24;
#elif BUILDFLAG(IS_ANDROID)
constexpr int kSharedPressureThreshold = 4;
#else
constexpr int kSharedPressureThreshold = …;
#endif
namespace blink {
CodecPressureGauge::CodecPressureGauge(size_t pressure_threshold)
: … { … }
CodecPressureGauge& CodecPressureGauge::GetInstance(
ReclaimableCodec::CodecType type) { … }
#if defined(USE_SHARED_INSTANCE)
CodecPressureGauge& CodecPressureGauge::SharedInstance() { … }
#else
CodecPressureGauge& CodecPressureGauge::DecoderInstance() {
DEFINE_THREAD_SAFE_STATIC_LOCAL(CodecPressureGauge, decoder_instance,
(kDecoderPressureThreshold));
return decoder_instance;
}
CodecPressureGauge& CodecPressureGauge::EncoderInstance() {
DEFINE_THREAD_SAFE_STATIC_LOCAL(CodecPressureGauge, encoder_instance,
(kEncoderPressureThreshold));
return encoder_instance;
}
#endif
#undef USE_SHARED_INSTANCE
void CodecPressureGauge::Increment() { … }
void CodecPressureGauge::Decrement() { … }
std::pair<CodecPressureGauge::PressureCallbackId, bool>
CodecPressureGauge::RegisterPressureCallback(
PressureThresholdChangedCallback pressure_callback) { … }
void CodecPressureGauge::UnregisterPressureCallback(
PressureCallbackId callback_id,
size_t pressure_released) { … }
void CodecPressureGauge::CheckForThresholdChanges_Locked() { … }
}