MPD  0.20.6
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 
32  FLAC__Metadata_Chain *chain;
33 
34 public:
35  FlacMetadataChain():chain(::FLAC__metadata_chain_new()) {}
36 
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 
87  FLAC__Metadata_Iterator *iterator;
88 
89 public:
90  FLACMetadataIterator():iterator(::FLAC__metadata_iterator_new()) {}
91 
93  :iterator(::FLAC__metadata_iterator_new()) {
94  ::FLAC__metadata_iterator_init(iterator,
95  (FLAC__Metadata_Chain *)chain);
96  }
97 
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
117  const FLAC__StreamMetadata_VorbisComment &vc);
118 
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
bool Read(InputStream &is)
static FLAC__IOHandle ToFlacIOHandle(InputStream &is)
FLACMetadataIterator(FlacMetadataChain &chain)
gcc_pure FLAC__StreamMetadata * GetBlock()
The meta information about a song file.
Definition: Tag.hxx:34
bool Read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks)
A callback table for receiving metadata of a song.
Definition: TagHandler.hxx:32
MixRampInfo flac_parse_mixramp(const FLAC__StreamMetadata_VorbisComment &vc)
bool ReadOgg(const char *path)
bool Read(const char *path)
Tag flac_vorbis_comments_to_tag(const FLAC__StreamMetadata_VorbisComment *comment)
bool flac_parse_replay_gain(ReplayGainInfo &rgi, const FLAC__StreamMetadata_VorbisComment &vc)
gcc_pure FLAC__Metadata_ChainStatus GetStatus() const
void flac_scan_metadata(const FLAC__StreamMetadata *block, const TagHandler &handler, void *handler_ctx)
bool ReadOgg(InputStream &is)
gcc_pure const char * GetStatusString() const
static const FLAC__IOCallbacks & GetFlacIOCallbacks(const InputStream &is)
#define gcc_pure
Definition: Compiler.h:116
bool ReadOgg(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks)
void Scan(const TagHandler &handler, void *handler_ctx)