this repo has no description
at fixPythonPipStalling 94 lines 2.1 kB view raw
1/* 2This file is part of Darling. 3 4Copyright (C) 2020 Lubos Dolezel 5 6Darling is free software: you can redistribute it and/or modify 7it under the terms of the GNU General Public License as published by 8the Free Software Foundation, either version 3 of the License, or 9(at your option) any later version. 10 11Darling is distributed in the hope that it will be useful, 12but WITHOUT ANY WARRANTY; without even the implied warranty of 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14GNU General Public License for more details. 15 16You should have received a copy of the GNU General Public License 17along with Darling. If not, see <http://www.gnu.org/licenses/>. 18*/ 19#include "AVFormatFileObject.h" 20#include <sstream> 21#include "AudioFileFormatMP3.h" 22 23extern "C" { 24#include <libavformat/avformat.h> 25} 26 27#pragma GCC visibility push(default) 28AUDIOCOMPONENT_ENTRY(AudioFileComponentFactory, AVFormatFileObject); 29#pragma GCC visibility pop 30 31AVFormatFileObject::AVFormatFileObject(AudioComponentInstance inInstance) 32: AudioFileObjectComponentBase(inInstance) 33{ 34 35} 36 37// Analyze mAudioFileObject and return an AudioFileFormat based on that 38AudioFileFormat* AVFormatFileObject::GetAudioFormat() const 39{ 40 uint8_t buffer[1024 + AVPROBE_PADDING_SIZE]; 41 AVProbeData probeData; 42 43 probeData.filename = ""; 44 probeData.buf = buffer; 45 probeData.buf_size = 1024; 46 47 if (mAudioFileObject->ReadBytes(false, 0, (UInt32*)&probeData.buf_size, probeData.buf) != noErr) 48 return nullptr; 49 50 AVInputFormat* fmt = av_probe_input_format(&probeData, true); 51 if (!fmt) 52 return nullptr; 53 54 std::istringstream ss(fmt->name); 55 std::string formatName; 56 57 while (std::getline(ss, formatName, ',')) 58 { 59 if (formatName == "aac") // Raw AAC 60 { 61 62 } 63 else if (formatName == "ac3") 64 { 65 66 } 67 else if (formatName == "aiff") 68 { 69 70 } 71 else if (formatName == "caff") 72 { 73 74 } 75 else if (formatName == "mp3") 76 { 77 return AudioFileFormatMP3::instance(); 78 } 79 else if (formatName == "mov" || formatName == "mp4") 80 { 81 82 } 83 else if (formatName == "au") 84 { 85 86 } 87 else if (formatName == "wav") 88 { 89 90 } 91 } 92 93 return nullptr; 94}