chromium/third_party/blink/renderer/modules/mediarecorder/audio_track_mojo_encoder.h

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_AUDIO_TRACK_MOJO_ENCODER_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_AUDIO_TRACK_MOJO_ENCODER_H_

#include <memory>
#include <optional>

#include "base/containers/queue.h"
#include "base/memory/weak_ptr.h"
#include "media/base/audio_encoder.h"
#include "media/base/encoder_status.h"
#include "third_party/blink/renderer/modules/mediarecorder/audio_track_encoder.h"
#include "third_party/blink/renderer/modules/mediarecorder/audio_track_recorder.h"
#include "third_party/blink/renderer/modules/modules_export.h"

namespace base {
class TimeTicks;
}

namespace media {
class AudioBus;
class AudioParameters;
class MojoAudioEncoder;
}  // namespace media

namespace blink {

// A thin wrapper for platform audio encoders which run in the GPU process.
// Currently, the only available encoder implementation is AAC, and only on
// Windows and Mac.
//
// This class uses a MojoAudioEncoder, which requires us to be async, so input
// may be buffered in this class, and will be asynchronously delivered via
// `on_encoded_audio_cb_`.
//
// Some encoders may buffer input frames, and MediaRecorder's abrupt stop design
// does not allow us to Flush. So, we may never receive the output for them,
// losing some audio at the end of the recording.
class MODULES_EXPORT AudioTrackMojoEncoder : public AudioTrackEncoder {};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_AUDIO_TRACK_MOJO_ENCODER_H_