/**
 * Copyright 2022-2025 Theai, Inc. dba Inworld AI
 */
#pragma once

#include "Audio/InworldAudioCapture.h"
#include "AudioMixerDevice.h"
#include "ISubmixBufferListener.h"

struct FInworldAudioCapture_MasterSubmix : public FInworldAudioCapture, public ISubmixBufferListener
{
public:
	FInworldAudioCapture_MasterSubmix(TWeakObjectPtr<UObject> InOwner, TFunction<void(FInworldAudioCaptureData)> InCallback)
		: FInworldAudioCapture(InOwner, InCallback)
	{
	}
	virtual ~FInworldAudioCapture_MasterSubmix()
	{
		StopCapture();
	}

	virtual void StartCapture() override;
	virtual void StopCapture() override;
	virtual void SetCaptureDeviceById(const FString& DeviceId) override;

protected:
	virtual void OnNewSubmixBuffer(const USoundSubmix* OwningSubmix, float* AudioData, int32 NumSamples, int32 NumChannels,
		const int32 SampleRate, double AudioClock) override;

private:
	/** Audio device Id this buffer listener is registered to. */
	Audio::FDeviceId RegisteredDeviceId = INDEX_NONE;
};
