webrtc_m130/test/fuzzers/audio_encoder_opus_fuzzer.cc
Danil Chapovalov 1932b44aa2 Provide Environment for AudioEncoderOpus in tests when created using the trait
To allow delete old signature of the AudioEncoderOpus::MakeAudioEncoder function and thus guarantee Opus AudioEncoder always has an Environment

Bug: webrtc:343086059
Change-Id: Ib660678aeb5a549dddd1dffa3d8c28b2ec6b9d0b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/356981
Reviewed-by: Jakob Ivarsson‎ <jakobi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42690}
2024-07-30 09:29:11 +00:00

35 lines
1.2 KiB
C++

/*
* Copyright (c) 2018 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.
*/
#include "api/audio_codecs/opus/audio_encoder_opus.h"
#include "api/environment/environment.h"
#include "api/environment/environment_factory.h"
#include "rtc_base/checks.h"
#include "test/fuzzers/audio_encoder_fuzzer.h"
namespace webrtc {
void FuzzOneInput(const uint8_t* data, size_t size) {
// Create Environment once because creating it for each input noticably
// reduces the speed of the fuzzer.
static const Environment* const env = new Environment(CreateEnvironment());
AudioEncoderOpus::Config config;
config.frame_size_ms = 20;
RTC_CHECK(config.IsOk());
FuzzAudioEncoder(
/*data_view=*/{data, size},
/*encoder=*/AudioEncoderOpus::MakeAudioEncoder(*env, config,
{.payload_type = 100}));
}
} // namespace webrtc