2020-09-08 18:12:55 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "DecoderInputBackCompat.h"
|
|
|
|
|
#include "AudioDevice.h"
|
|
|
|
|
#include "AudioDeviceManager.h"
|
|
|
|
|
#include "Interfaces/IAudioFormat.h"
|
|
|
|
|
#include "AudioDecompress.h"
|
|
|
|
|
#include "Sound/SoundWave.h"
|
|
|
|
|
#include "DecoderBackCompat.h"
|
|
|
|
|
|
|
|
|
|
namespace Audio
|
|
|
|
|
{
|
|
|
|
|
ICompressedAudioInfo* FBackCompatInput::GetInfo(
|
|
|
|
|
FFormatDescriptorSection* OutDescriptor /*= nullptr*/) const
|
|
|
|
|
{
|
|
|
|
|
FAudioDeviceHandle Handle = FAudioDeviceManager::Get()->GetActiveAudioDevice();
|
|
|
|
|
|
|
|
|
|
if (!OldInfoObject.IsValid())
|
|
|
|
|
{
|
2021-02-26 02:30:51 -04:00
|
|
|
OldInfoObject.Reset(Handle->CreateCompressedAudioInfo(Wave));
|
2020-09-08 18:12:55 -04:00
|
|
|
audio_ensure(OldInfoObject.IsValid());
|
|
|
|
|
|
|
|
|
|
FSoundQualityInfo Info;
|
|
|
|
|
if (Wave->IsStreaming())
|
|
|
|
|
{
|
2021-02-26 02:30:51 -04:00
|
|
|
if (!OldInfoObject->StreamCompressedInfo(Wave, &Info))
|
2020-09-08 18:12:55 -04:00
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-01-24 16:12:59 -04:00
|
|
|
// FSoundWaveProxy needs to be updated to support non-streaming audio
|
|
|
|
|
return nullptr;
|
2020-09-08 18:12:55 -04:00
|
|
|
|
2021-01-24 16:12:59 -04:00
|
|
|
// if (Wave->ResourceData == nullptr)
|
|
|
|
|
// {
|
|
|
|
|
// Wave->InitAudioResource(Wave->GetRuntimeFormat());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (!OldInfoObject->ReadCompressedInfo(Wave->ResourceData, Wave->ResourceSize, &Info))
|
|
|
|
|
// {
|
|
|
|
|
// return nullptr;
|
|
|
|
|
// }
|
2020-09-08 18:12:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Desc.NumChannels = Info.NumChannels;
|
|
|
|
|
Desc.NumFramesPerSec = Info.SampleRate;
|
|
|
|
|
Desc.NumFrames = (uint32)((float)Info.Duration * Info.SampleRate);
|
|
|
|
|
Desc.NumBytesPerPacket = ~0;
|
|
|
|
|
|
|
|
|
|
Desc.CodecName = FBackCompatCodec::GetDetailsStatic().Name;
|
|
|
|
|
Desc.CodecFamilyName = FBackCompatCodec::GetDetailsStatic().FamilyName;
|
|
|
|
|
Desc.CodecVersion = FBackCompatCodec::GetDetailsStatic().Version;
|
|
|
|
|
}
|
|
|
|
|
if( OutDescriptor )
|
|
|
|
|
{
|
|
|
|
|
*OutDescriptor = Desc;
|
|
|
|
|
}
|
|
|
|
|
return OldInfoObject.Get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FBackCompatInput::FindSection(FEncodedSectionBase& OutSection)
|
|
|
|
|
{
|
|
|
|
|
if (FFormatDescriptorSection::kSectionName == OutSection.SectionName)
|
|
|
|
|
{
|
|
|
|
|
FFormatDescriptorSection& Descriptor = static_cast<FFormatDescriptorSection&>(OutSection);
|
|
|
|
|
return GetInfo(&Descriptor) != nullptr;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FBackCompatInput::HasError() const
|
|
|
|
|
{
|
|
|
|
|
return GetInfo() == nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64 FBackCompatInput::Tell() const
|
|
|
|
|
{
|
|
|
|
|
// Not implemented.
|
|
|
|
|
audio_ensure(false);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 22:10:18 -04:00
|
|
|
void FBackCompatInput::SeekToTime(const float InSeconds)
|
|
|
|
|
{
|
|
|
|
|
ICompressedAudioInfo* Info = GetInfo();
|
|
|
|
|
ensure(Info);
|
|
|
|
|
|
|
|
|
|
Info->SeekToTime(InSeconds);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-08 18:12:55 -04:00
|
|
|
bool FBackCompatInput::IsEndOfStream() const
|
|
|
|
|
{
|
|
|
|
|
// Not implemented.
|
|
|
|
|
audio_ensure(false);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArrayView<const uint8> FBackCompatInput::PeekNextPacket(int32 InMaxPacketLength) const
|
|
|
|
|
{
|
|
|
|
|
// Not implemented.
|
|
|
|
|
audio_ensure(false);
|
|
|
|
|
return MakeArrayView<const uint8>(nullptr,0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArrayView<const uint8> FBackCompatInput::PopNextPacket(int32 InPacketSize)
|
|
|
|
|
{
|
|
|
|
|
// Not implemented.
|
|
|
|
|
audio_ensure(false);
|
|
|
|
|
return MakeArrayView<const uint8>(nullptr,0);
|
|
|
|
|
}
|
|
|
|
|
}
|