Cider Isn't Darwin Emulation, Really
Something went wrong. Try again.
2.1 kB · 94 lines
C++
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495/*This file is part of Darling.
Copyright (C) 2020 Lubos Dolezel
Darling is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.
Darling is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.
You should have received a copy of the GNU General Public Licensealong with Darling. If not, see <http://www.gnu.org/licenses/>.*/#include "AVFormatFileObject.h"#include <sstream>#include "AudioFileFormatMP3.h"
extern "C" {#include <libavformat/avformat.h>}
#pragma GCC visibility push(default)AUDIOCOMPONENT_ENTRY(AudioFileComponentFactory, AVFormatFileObject);#pragma GCC visibility pop
AVFormatFileObject::AVFormatFileObject(AudioComponentInstance inInstance): AudioFileObjectComponentBase(inInstance){
}
// Analyze mAudioFileObject and return an AudioFileFormat based on thatAudioFileFormat* AVFormatFileObject::GetAudioFormat() const{ uint8_t buffer[1024 + AVPROBE_PADDING_SIZE]; AVProbeData probeData;
probeData.filename = ""; probeData.buf = buffer; probeData.buf_size = 1024;
if (mAudioFileObject->ReadBytes(false, 0, (UInt32*)&probeData.buf_size, probeData.buf) != noErr) return nullptr;
AVInputFormat* fmt = av_probe_input_format(&probeData, true); if (!fmt) return nullptr;
std::istringstream ss(fmt->name); std::string formatName;
while (std::getline(ss, formatName, ',')) { if (formatName == "aac") // Raw AAC {
} else if (formatName == "ac3") {
} else if (formatName == "aiff") {
} else if (formatName == "caff") {
} else if (formatName == "mp3") { return AudioFileFormatMP3::instance(); } else if (formatName == "mov" || formatName == "mp4") {
} else if (formatName == "au") {
} else if (formatName == "wav") {
} }
return nullptr;}