MPD: decoder/plugins/FlacMetadata.hxx Source File

MPD 0.20.18

FlacMetadata.hxx
Go to the documentation of this file.
1 /*
2 * Copyright 2003-2017 The Music Player Daemon Project
3 * http://www.musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MPD_FLAC_METADATA_H
21 #define MPD_FLAC_METADATA_H
22
23 #include "Compiler.h"
24 #include "FlacIOHandle.hxx"
25
26 #include <FLAC/metadata.h>
27
28 struct TagHandler;
29 class MixRampInfo;
30
31 class FlacMetadataChain {
32 FLAC__Metadata_Chain *chain;
33
34 public:
35 FlacMetadataChain():chain(::FLAC__metadata_chain_new()) {}
36
37 ~FlacMetadataChain() {
38 ::FLAC__metadata_chain_delete(chain);
39 }
40
41 explicit operator FLAC__Metadata_Chain *() {
42 return chain;
43 }
44
45 bool Read(const char *path) noexcept {
46 return ::FLAC__metadata_chain_read(chain, path);
47 }
48
49 bool Read(FLAC__IOHandle handle,
50 FLAC__IOCallbacks callbacks) noexcept {
51 return ::FLAC__metadata_chain_read_with_callbacks(chain,
52 handle,
53 callbacks);
54 }
55
56 bool Read(InputStream &is) noexcept {
57 return Read(::ToFlacIOHandle(is), ::GetFlacIOCallbacks(is));
58 }
59
60 bool ReadOgg(const char *path) noexcept {
61 return ::FLAC__metadata_chain_read_ogg(chain, path);
62 }
63
64 bool ReadOgg(FLAC__IOHandle handle,
65 FLAC__IOCallbacks callbacks) noexcept {
66 return ::FLAC__metadata_chain_read_ogg_with_callbacks(chain,
67 handle,
68 callbacks);
69 }
70
71 bool ReadOgg(InputStream &is) {
72 return ReadOgg(::ToFlacIOHandle(is), ::GetFlacIOCallbacks(is));
73 }
74
75 gcc_pure
76 FLAC__Metadata_ChainStatus GetStatus() const noexcept {
77 return ::FLAC__metadata_chain_status(chain);
78 }
79
80 gcc_pure
81 const char *GetStatusString() const noexcept {
82 return FLAC__Metadata_ChainStatusString[GetStatus()];
83 }
84
85 void Scan(const TagHandler &handler, void *handler_ctx);
86 };
87
88 class FLACMetadataIterator {
89 FLAC__Metadata_Iterator *iterator;
90
91 public:
92 FLACMetadataIterator():iterator(::FLAC__metadata_iterator_new()) {}
93
94 FLACMetadataIterator(FlacMetadataChain &chain)
95 :iterator(::FLAC__metadata_iterator_new()) {
96 ::FLAC__metadata_iterator_init(iterator,
97 (FLAC__Metadata_Chain *)chain);
98 }
99
100 ~FLACMetadataIterator() {
101 ::FLAC__metadata_iterator_delete(iterator);
102 }
103
104 bool Next() noexcept {
105 return ::FLAC__metadata_iterator_next(iterator);
106 }
107
108 gcc_pure
109 FLAC__StreamMetadata *GetBlock() noexcept {
110 return ::FLAC__metadata_iterator_get_block(iterator);
111 }
112 };
113
114 struct Tag;
115 struct ReplayGainInfo;
116
117 bool
118 flac_parse_replay_gain(ReplayGainInfo &rgi,
119 const FLAC__StreamMetadata_VorbisComment &vc);
120
121 MixRampInfo
122 flac_parse_mixramp(const FLAC__StreamMetadata_VorbisComment &vc);
123
124 Tag
125 flac_vorbis_comments_to_tag(const FLAC__StreamMetadata_VorbisComment *comment);
126
127 void
128 flac_scan_metadata(const FLAC__StreamMetadata *block,
129 const TagHandler &handler, void *handler_ctx);
130
131 #endif
FlacMetadataChain::Read
bool Read(InputStream &is) noexcept
Definition: FlacMetadata.hxx:56
FlacMetadataChain::GetStatus
gcc_pure FLAC__Metadata_ChainStatus GetStatus() const noexcept
Definition: FlacMetadata.hxx:76
ToFlacIOHandle
static FLAC__IOHandle ToFlacIOHandle(InputStream &is)
Definition: FlacIOHandle.hxx:32
FLACMetadataIterator::FLACMetadataIterator
FLACMetadataIterator(FlacMetadataChain &chain)
Definition: FlacMetadata.hxx:94
Tag
The meta information about a song file.
Definition: Tag.hxx:34
FLACMetadataIterator::~FLACMetadataIterator
~FLACMetadataIterator()
Definition: FlacMetadata.hxx:100
TagHandler
A callback table for receiving metadata of a song.
Definition: TagHandler.hxx:32
flac_parse_mixramp
MixRampInfo flac_parse_mixramp(const FLAC__StreamMetadata_VorbisComment &vc)
InputStream
Definition: InputStream.hxx:36
flac_vorbis_comments_to_tag
Tag flac_vorbis_comments_to_tag(const FLAC__StreamMetadata_VorbisComment *comment)
MixRampInfo
Definition: MixRampInfo.hxx:28
flac_parse_replay_gain
bool flac_parse_replay_gain(ReplayGainInfo &rgi, const FLAC__StreamMetadata_VorbisComment &vc)
FLACMetadataIterator::FLACMetadataIterator
FLACMetadataIterator()
Definition: FlacMetadata.hxx:92
FlacMetadataChain
Definition: FlacMetadata.hxx:31
FLACMetadataIterator::Next
bool Next() noexcept
Definition: FlacMetadata.hxx:104
FlacMetadataChain::GetStatusString
gcc_pure const char * GetStatusString() const noexcept
Definition: FlacMetadata.hxx:81
FlacMetadataChain::ReadOgg
bool ReadOgg(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks) noexcept
Definition: FlacMetadata.hxx:64
flac_scan_metadata
void flac_scan_metadata(const FLAC__StreamMetadata *block, const TagHandler &handler, void *handler_ctx)
FlacMetadataChain::Read
bool Read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks) noexcept
Definition: FlacMetadata.hxx:49
FlacMetadataChain::ReadOgg
bool ReadOgg(InputStream &is)
Definition: FlacMetadata.hxx:71
Compiler.h
FlacMetadataChain::ReadOgg
bool ReadOgg(const char *path) noexcept
Definition: FlacMetadata.hxx:60
ReplayGainInfo
Definition: ReplayGainInfo.hxx:46
FLACMetadataIterator
Definition: FlacMetadata.hxx:88
FlacMetadataChain::FlacMetadataChain
FlacMetadataChain()
Definition: FlacMetadata.hxx:35
FlacMetadataChain::~FlacMetadataChain
~FlacMetadataChain()
Definition: FlacMetadata.hxx:37
FLACMetadataIterator::GetBlock
gcc_pure FLAC__StreamMetadata * GetBlock() noexcept
Definition: FlacMetadata.hxx:109
GetFlacIOCallbacks
static const FLAC__IOCallbacks & GetFlacIOCallbacks(const InputStream &is)
Definition: FlacIOHandle.hxx:38
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
FlacMetadataChain::Read
bool Read(const char *path) noexcept
Definition: FlacMetadata.hxx:45
FlacMetadataChain::Scan
void Scan(const TagHandler &handler, void *handler_ctx)
FlacIOHandle.hxx