Files
UnrealEngineUWP/Engine/Source/Runtime/SignalProcessing/Public/DSP/FileEncoder.h
ryan durand 0f0464a30e Updating copyright for Engine Runtime.
#rnx
#rb none


#ROBOMERGE-OWNER: ryan.durand
#ROBOMERGE-AUTHOR: ryan.durand
#ROBOMERGE-SOURCE: CL 10869210 via CL 10869511 via CL 10869900
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870549 by ryan durand in Main branch]
2019-12-26 14:45:42 -05:00

49 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "DSP/Encoders/IAudioEncoder.h"
#include "Interfaces/IAudioFormat.h"
namespace Audio
{
class SIGNALPROCESSING_API FAudioFileWriter
{
public:
// Constructor. Takes an absolute file path and metadata about the audio in question.
// Immediately allocates all data necessary.
FAudioFileWriter(const FString& InPath, const FSoundQualityInfo& InInfo);
// Calling the destructor on this class finalizes and closes out the file.
~FAudioFileWriter();
// Returns file information.
void GetFileInfo(FSoundQualityInfo& OutInfo);
// Use this to push audio to the file writer.
// If you'd like to move encoding and file writing to a separate thread from PushAudio,
// Call this with bEncodeIfPossible = false.
bool PushAudio(const float* InAudio, int32 NumSamples, bool bEncodeIfPossible = true);
// If PushAudio is called with bEncodeIfPossible set to false, this will need to be called.
bool EncodeIfPossible();
private:
FAudioFileWriter();
FSoundQualityInfo QualityInfo;
TArray<uint8> DataBuffer;
// Compressor we are using.
TUniquePtr<IAudioEncoder> Encoder;
// Handle to file we are writing to.
TUniquePtr<IFileHandle> FileHandle;
IAudioEncoder* GetNewEncoderForFile(const FString& InPath);
FString GetExtensionForFile(const FString& InPath);
void FlushEncoderToFile(int32 DataBufferSize = 4096);
};
}