annotate Input/mpg123/id3_frame_url.c @ 34:ffddef61dd83 trunk

[svn] Rebuild configure.
author nenolod
date Wed, 26 Oct 2005 00:42:55 -0700
parents cb178e5ad177
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /*********************************************************************
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 * Copyright (C) 1999, 2001, 2002,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Department of Computer Science, University of Tromsų
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 * Filename: id3_frame_url.c
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * Description: Code for handling ID3 URL frames.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * Author: Espen Skoglund <espensk@stud.cs.uit.no>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 * Created at: Tue Feb 9 21:10:45 1999
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 * $Id: id3_frame_url.c,v 1.6 2004/07/20 21:47:22 descender Exp $
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * This program is free software; you can redistribute it and/or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * modify it under the terms of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 * as published by the Free Software Foundation; either version 2
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 * of the License, or (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 * along with this program; if not, write to the Free Software
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 ********************************************************************/
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include "config.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 #include "xmms-id3.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #include "id3_header.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 * Function id3_get_url (frame)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38 * Return URL of frame.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 char *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 id3_get_url(struct id3_frame *frame)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 /* Type check */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 if (frame->fr_desc->fd_idstr[0] != 'W')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 /* Check if frame is compressed */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 if (id3_decompress_frame(frame) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 if (frame->fr_desc->fd_id == ID3_WXXX) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 * This is a user defined link frame. Skip the description.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 switch (*(guint8 *) frame->fr_data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 case ID3_ENCODING_ISO_8859_1:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 char *text = (char *) frame->fr_data + 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 while (*text != 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 text++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 return g_strdup(++text);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 case ID3_ENCODING_UTF16:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 gint16 *text16 = (gint16 *) ((glong) frame->fr_data + 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 while (*text16 != 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 text16++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 return g_strdup((char *) (++text16));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 default:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 return g_strdup((char *) frame->fr_data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 * Function id3_get_url_desc (frame)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 * Get description of a URL.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 char *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 id3_get_url_desc(struct id3_frame *frame)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 /* Type check */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 if (frame->fr_desc->fd_idstr[0] != 'W')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 /* If predefined link frame, return description. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 if (frame->fr_desc->fd_id != ID3_WXXX)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 return frame->fr_desc->fd_description;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 /* Check if frame is compressed */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 if (id3_decompress_frame(frame) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 if (*(guint8 *) frame->fr_data == ID3_ENCODING_ISO_8859_1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 return g_strdup((char *) frame->fr_data + 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 return id3_utf16_to_ascii((gint16 *) ((glong) frame->fr_data + 1));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 }