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