/ src / CoreAudio / AFAVFormatComponent / AudioFileMP3.cpp
AudioFileMP3.cpp
 1  /*
 2  This file is part of Darling.
 3  
 4  Copyright (C) 2020 Lubos Dolezel
 5  
 6  Darling is free software: you can redistribute it and/or modify
 7  it under the terms of the GNU General Public License as published by
 8  the Free Software Foundation, either version 3 of the License, or
 9  (at your option) any later version.
10  
11  Darling is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15  
16  You should have received a copy of the GNU General Public License
17  along with Darling.  If not, see <http://www.gnu.org/licenses/>.
18  */
19  #include "AudioFileMP3.h"
20  #include "AVFormatFileObject.h"
21  #include "AudioFileFormatGeneric.h"
22  
23  class AudioFileFormatMP3 : public AudioFileFormatGeneric
24  {
25  public:
26  	AudioFileFormatMP3() : AudioFileFormatGeneric('.mp3', "mp3") {}
27  protected:
28  	const Description& description() const override
29  	{
30  		static const Description d = {
31  			.name = "MPEG Layer 3",
32  			.extensions = { "mp3" },
33  			.utis = { "public.mp3", "public.audio", "public.data" },
34  			.mimeTypes = { "audio/mpeg" },
35  			.formats = { '.mp3' },
36  		};
37  		return d;
38  	}
39  };
40  
41  class MP3Component : public AVFormatFileObject<AudioFileFormatMP3, AudioFileMP3, '.mp3'>
42  {
43  public:
44  	MP3Component(AudioComponentInstance inInstance) : AVFormatFileObject(inInstance) {}
45  };
46  
47  #pragma GCC visibility push(default)
48  AUDIOCOMPONENT_ENTRY(AudioFileComponentFactory, MP3Component);
49  #pragma GCC visibility pop
50  
51  AudioFileMP3::AudioFileMP3()
52  : AudioFileObject('.mp3')
53  {
54  
55  }
56  
57  Boolean AudioFileMP3::IsDataFormatSupported(const AudioStreamBasicDescription	*inFormat)
58  {
59  	return true;
60  }