blob: 4ddb16ad0808c516ba532f9e2ca7839554739389 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
* Copyright 2023 jacqueline <me@jacqueline.id.au>
*
* SPDX-License-Identifier: GPL-3.0-only
*/
#include "codec.hpp"
#include <memory>
#include <optional>
#include "dr_flac.hpp"
#include "mad.hpp"
#include "native.hpp"
#include "opus.hpp"
#include "types.hpp"
#include "vorbis.hpp"
#include "wav.hpp"
#include "wavpack.hpp"
namespace codecs {
auto StreamTypeToString(StreamType t) -> std::string {
switch (t) {
case StreamType::kMp3:
return "Mp3";
case StreamType::kWav:
return "Wav";
case StreamType::kVorbis:
return "Vorbis";
case StreamType::kFlac:
return "Flac";
case StreamType::kOpus:
return "Opus";
case StreamType::kNative:
return "Native";
case StreamType::kWavPack:
return "WavPack";
default:
return "";
}
}
auto CreateCodecForType(StreamType type) -> std::optional<ICodec*> {
switch (type) {
case StreamType::kMp3:
return new MadMp3Decoder();
case StreamType::kVorbis:
return new TremorVorbisDecoder();
case StreamType::kFlac:
return new DrFlacDecoder();
case StreamType::kOpus:
return new XiphOpusDecoder();
case StreamType::kWav:
return new WavDecoder();
case StreamType::kNative:
return new NativeDecoder();
case StreamType::kWavPack:
return new WavPackDecoder();
default:
return {};
}
}
} // namespace codecs
|