2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
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.
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.
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.
21 #include "decoder_list.h"
22 #include "decoder_api.h"
23 #include "input_init.h"
24 #include "input_stream.h"
25 #include "audio_format.h"
26 #include "pcm_volume.h"
44 idle_add(G_GNUC_UNUSED
unsigned flags
)
52 pcm_volume(G_GNUC_UNUSED
void *buffer
, G_GNUC_UNUSED
int length
,
53 G_GNUC_UNUSED
const struct audio_format
*format
,
54 G_GNUC_UNUSED
int volume
)
60 decoder_initialized(G_GNUC_UNUSED
struct decoder
*decoder
,
61 G_GNUC_UNUSED
const struct audio_format
*audio_format
,
62 G_GNUC_UNUSED
bool seekable
,
63 G_GNUC_UNUSED
float total_time
)
67 char *decoder_get_uri(G_GNUC_UNUSED
struct decoder
*decoder
)
73 decoder_get_command(G_GNUC_UNUSED
struct decoder
*decoder
)
75 return DECODE_COMMAND_NONE
;
78 void decoder_command_finished(G_GNUC_UNUSED
struct decoder
*decoder
)
82 double decoder_seek_where(G_GNUC_UNUSED
struct decoder
*decoder
)
87 void decoder_seek_error(G_GNUC_UNUSED
struct decoder
*decoder
)
92 decoder_read(G_GNUC_UNUSED
struct decoder
*decoder
,
93 struct input_stream
*is
,
94 void *buffer
, size_t length
)
96 return input_stream_read(is
, buffer
, length
, NULL
);
100 decoder_timestamp(G_GNUC_UNUSED
struct decoder
*decoder
,
101 G_GNUC_UNUSED
double t
)
106 decoder_data(G_GNUC_UNUSED
struct decoder
*decoder
,
107 G_GNUC_UNUSED
struct input_stream
*is
,
108 const void *data
, size_t datalen
,
109 G_GNUC_UNUSED
uint16_t bit_rate
,
110 G_GNUC_UNUSED
struct replay_gain_info
*replay_gain_info
)
112 write(1, data
, datalen
);
113 return DECODE_COMMAND_NONE
;
117 decoder_tag(G_GNUC_UNUSED
struct decoder
*decoder
,
118 G_GNUC_UNUSED
struct input_stream
*is
,
119 G_GNUC_UNUSED
const struct tag
*tag
)
121 return DECODE_COMMAND_NONE
;
125 print_tag(const struct tag
*tag
)
128 g_print("time=%d\n", tag
->time
);
130 for (unsigned i
= 0; i
< tag
->num_items
; ++i
)
132 tag_item_names
[tag
->items
[i
]->type
],
133 tag
->items
[i
]->value
);
136 int main(int argc
, char **argv
)
138 GError
*error
= NULL
;
139 const char *decoder_name
, *path
;
140 const struct decoder_plugin
*plugin
;
145 /* initialize locale */
146 setlocale(LC_CTYPE
,"");
150 g_printerr("Usage: read_tags DECODER FILE\n");
154 decoder_name
= argv
[1];
157 if (!input_stream_global_init(&error
)) {
158 g_warning("%s", error
->message
);
163 decoder_plugin_init_all();
165 plugin
= decoder_plugin_from_name(decoder_name
);
166 if (plugin
== NULL
) {
167 g_printerr("No such decoder: %s\n", decoder_name
);
171 tag
= decoder_plugin_tag_dup(plugin
, path
);
172 if (tag
== NULL
&& plugin
->stream_tag
!= NULL
) {
173 struct input_stream is
;
175 if (!input_stream_open(&is
, path
, &error
)) {
176 g_printerr("Failed to open %s: %s\n",
177 path
, error
->message
);
182 tag
= decoder_plugin_stream_tag(plugin
, &is
);
183 input_stream_close(&is
);
186 decoder_plugin_deinit_all();
187 input_stream_global_finish();
189 g_printerr("Failed to read tags\n");
195 empty
= tag_is_empty(tag
);
199 tag
= tag_ape_load(path
);
201 tag
= tag_id3_load(path
);