MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

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) {
46 return ::FLAC__metadata_chain_read(chain, path);
47 }
48
49 bool Read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks) {
50 return ::FLAC__metadata_chain_read_with_callbacks(chain,
51 handle,
52 callbacks);
53 }
54
55 bool Read(InputStream &is) {
56 return Read(::ToFlacIOHandle(is), ::GetFlacIOCallbacks(is));
57 }
58
59 bool ReadOgg(const char *path) {
60 return ::FLAC__metadata_chain_read_ogg(chain, path);
61 }
62
63 bool ReadOgg(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks) {
64 return ::FLAC__metadata_chain_read_ogg_with_callbacks(chain,
65 handle,
66 callbacks);
67 }
68
69 bool ReadOgg(InputStream &is) {
70 return ReadOgg(::ToFlacIOHandle(is), ::GetFlacIOCallbacks(is));
71 }
72
73 gcc_pure
74 FLAC__Metadata_ChainStatus GetStatus() const {
75 return ::FLAC__metadata_chain_status(chain);
76 }
77
78 gcc_pure
79 const char *GetStatusString() const {
80 return FLAC__Metadata_ChainStatusString[GetStatus()];
81 }
82
83 void Scan(const TagHandler &handler, void *handler_ctx);
84 };
85
86 class FLACMetadataIterator {
87 FLAC__Metadata_Iterator *iterator;
88
89 public:
90 FLACMetadataIterator():iterator(::FLAC__metadata_iterator_new()) {}
91
92 FLACMetadataIterator(FlacMetadataChain &chain)
93 :iterator(::FLAC__metadata_iterator_new()) {
94 ::FLAC__metadata_iterator_init(iterator,
95 (FLAC__Metadata_Chain *)chain);
96 }
97
98 ~FLACMetadataIterator() {
99 ::FLAC__metadata_iterator_delete(iterator);
100 }
101
102 bool Next() {
103 return ::FLAC__metadata_iterator_next(iterator);
104 }
105
106 gcc_pure
107 FLAC__StreamMetadata *GetBlock() {
108 return ::FLAC__metadata_iterator_get_block(iterator);
109 }
110 };
111
112 struct Tag;
113 struct ReplayGainInfo;
114
115 bool
116 flac_parse_replay_gain(ReplayGainInfo &rgi,
117 const FLAC__StreamMetadata_VorbisComment &vc);
118
119 MixRampInfo
120 flac_parse_mixramp(const FLAC__StreamMetadata_VorbisComment &vc);
121
122 Tag
123 flac_vorbis_comments_to_tag(const FLAC__StreamMetadata_VorbisComment *comment);
124
125 void
126 flac_scan_metadata(const FLAC__StreamMetadata *block,
127 const TagHandler &handler, void *handler_ctx);
128
129 #endif
FlacMetadataChain::Read
bool Read(InputStream &is)
Definition: FlacMetadata.hxx:55
ToFlacIOHandle
static FLAC__IOHandle ToFlacIOHandle(InputStream &is)
Definition: FlacIOHandle.hxx:32
FLACMetadataIterator::FLACMetadataIterator
FLACMetadataIterator(FlacMetadataChain &chain)
Definition: FlacMetadata.hxx:92
FLACMetadataIterator::GetBlock
gcc_pure FLAC__StreamMetadata * GetBlock()
Definition: FlacMetadata.hxx:107
Tag
The meta information about a song file.
Definition: Tag.hxx:34
FLACMetadataIterator::~FLACMetadataIterator
~FLACMetadataIterator()
Definition: FlacMetadata.hxx:98
FlacMetadataChain::Read
bool Read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks)
Definition: FlacMetadata.hxx:49
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)
FlacMetadataChain::ReadOgg
bool ReadOgg(const char *path)
Definition: FlacMetadata.hxx:59
FlacMetadataChain::Read
bool Read(const char *path)
Definition: FlacMetadata.hxx:45
InputStream
Definition: InputStream.hxx:36
flac_vorbis_comments_to_tag
Tag flac_vorbis_comments_to_tag(const FLAC__StreamMetadata_VorbisComment *comment)
FLACMetadataIterator::Next
bool Next()
Definition: FlacMetadata.hxx:102
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:90
FlacMetadataChain
Definition: FlacMetadata.hxx:31
FlacMetadataChain::GetStatus
gcc_pure FLAC__Metadata_ChainStatus GetStatus() const
Definition: FlacMetadata.hxx:74
flac_scan_metadata
void flac_scan_metadata(const FLAC__StreamMetadata *block, const TagHandler &handler, void *handler_ctx)
FlacMetadataChain::ReadOgg
bool ReadOgg(InputStream &is)
Definition: FlacMetadata.hxx:69
Compiler.h
ReplayGainInfo
Definition: ReplayGainInfo.hxx:46
FLACMetadataIterator
Definition: FlacMetadata.hxx:86
FlacMetadataChain::FlacMetadataChain
FlacMetadataChain()
Definition: FlacMetadata.hxx:35
FlacMetadataChain::~FlacMetadataChain
~FlacMetadataChain()
Definition: FlacMetadata.hxx:37
FlacMetadataChain::GetStatusString
gcc_pure const char * GetStatusString() const
Definition: FlacMetadata.hxx:79
GetFlacIOCallbacks
static const FLAC__IOCallbacks & GetFlacIOCallbacks(const InputStream &is)
Definition: FlacIOHandle.hxx:38
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
FlacMetadataChain::ReadOgg
bool ReadOgg(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks)
Definition: FlacMetadata.hxx:63
FlacMetadataChain::Scan
void Scan(const TagHandler &handler, void *handler_ctx)
FlacIOHandle.hxx