hythmbox-2.98/metadata/rb-metadata-gst-common.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found rb-metadata-gst-common.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found rb-metadata-gst-common.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
  1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  2  *
  3  *  Copyright (C) 2003,2004 Colin Walters <walters@verbum.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  *  The Rhythmbox authors hereby grant permission for non-GPL compatible
 11  *  GStreamer plugins to be used and distributed together with GStreamer
 12  *  and Rhythmbox. This permission is above and beyond the permissions granted
 13  *  by the GPL license by which Rhythmbox is covered. If you modify this code
 14  *  you may extend this exception to your version of the code, but you are not
 15  *  obligated to do so. If you do not wish to do so, delete this exception
 16  *  statement from your version.
 17  *
 18  *  This program is distributed in the hope that it will be useful,
 19  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 20  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 21  *  GNU General Public License for more details.
 22  *
 23  *  You should have received a copy of the GNU General Public License
 24  *  along with this program; if not, write to the Free Software
 25  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
 26  *
 27  */
 28 
 29 #include <config.h>
 30 
 31 #include <string.h>
 32 
 33 #include <glib/gi18n.h>
 34 #include <gst/gst.h>
 35 #include <gst/tag/tag.h>
 36 
 37 #include "rb-metadata-gst-common.h"
 38 #include "rb-debug.h"
 39 
 40 static void
 41 gst_date_gulong_transform (const GValue *src, GValue *dest)
 42 {
 43 	const GDate *date = gst_value_get_date (src);
 44 
 45 	g_value_set_ulong (dest, (date) ? g_date_get_julian (date) : 0);
 46 }
 47 
 48 static void
 49 gulong_gst_date_transform (const GValue *src, GValue *dest)
 50 {
 51 	gulong day = g_value_get_ulong (src);
 52 	GDate *date = g_date_new_julian (day);
 53 
 54 	gst_value_set_date (dest, date);
 55 	g_date_free (date);
 56 }
 57 
 58 void
 59 rb_metadata_gst_register_transforms ()
 60 {
 61 	g_value_register_transform_func (GST_TYPE_DATE, G_TYPE_ULONG, gst_date_gulong_transform);
 62 	g_value_register_transform_func (G_TYPE_ULONG, GST_TYPE_DATE, gulong_gst_date_transform);
 63 }
 64 
 65 RBMetaDataField
 66 rb_metadata_gst_tag_to_field (const char *tag)
 67 {
 68 	if (!strcmp (tag, GST_TAG_TITLE))
 69 		return RB_METADATA_FIELD_TITLE;
 70 	else if (!strcmp (tag, GST_TAG_ARTIST))
 71 		return RB_METADATA_FIELD_ARTIST;
 72 	else if (!strcmp (tag, GST_TAG_ALBUM))
 73 		return RB_METADATA_FIELD_ALBUM;
 74 	else if (!strcmp (tag, GST_TAG_DATE))
 75 		return RB_METADATA_FIELD_DATE;
 76 	else if (!strcmp (tag, GST_TAG_GENRE))
 77 		return RB_METADATA_FIELD_GENRE;
 78 	else if (!strcmp (tag, GST_TAG_COMMENT))
 79 		return RB_METADATA_FIELD_COMMENT;
 80 	else if (!strcmp (tag, GST_TAG_TRACK_NUMBER))
 81 		return RB_METADATA_FIELD_TRACK_NUMBER;
 82 	else if (!strcmp (tag, GST_TAG_TRACK_COUNT))
 83 		return RB_METADATA_FIELD_MAX_TRACK_NUMBER;
 84 	else if (!strcmp (tag, GST_TAG_ALBUM_VOLUME_NUMBER))
 85 		return RB_METADATA_FIELD_DISC_NUMBER;
 86 	else if (!strcmp (tag, GST_TAG_ALBUM_VOLUME_COUNT))
 87 		return RB_METADATA_FIELD_MAX_TRACK_NUMBER;
 88 	else if (!strcmp (tag, GST_TAG_DESCRIPTION))
 89 		return RB_METADATA_FIELD_DESCRIPTION;
 90 	else if (!strcmp (tag, GST_TAG_VERSION))
 91 		return RB_METADATA_FIELD_VERSION;
 92 	else if (!strcmp (tag, GST_TAG_ISRC))
 93 		return RB_METADATA_FIELD_ISRC;
 94 	else if (!strcmp (tag, GST_TAG_ORGANIZATION))
 95 		return RB_METADATA_FIELD_ORGANIZATION;
 96 	else if (!strcmp (tag, GST_TAG_COPYRIGHT))
 97 		return RB_METADATA_FIELD_COPYRIGHT;
 98 	else if (!strcmp (tag, GST_TAG_CONTACT))
 99 		return RB_METADATA_FIELD_CONTACT;
100 	else if (!strcmp (tag, GST_TAG_LICENSE))
101 		return RB_METADATA_FIELD_LICENSE;
102 	else if (!strcmp (tag, GST_TAG_PERFORMER))
103 		return RB_METADATA_FIELD_PERFORMER;
104 	else if (!strcmp (tag, GST_TAG_DURATION))
105 		return RB_METADATA_FIELD_DURATION;
106 	else if (!strcmp (tag, GST_TAG_CODEC))
107 		return RB_METADATA_FIELD_CODEC;
108 	else if (!strcmp (tag, GST_TAG_BITRATE))
109 		return RB_METADATA_FIELD_BITRATE;
110 	else if (!strcmp (tag, GST_TAG_TRACK_GAIN))
111 		return RB_METADATA_FIELD_TRACK_GAIN;
112 	else if (!strcmp (tag, GST_TAG_TRACK_PEAK))
113 		return RB_METADATA_FIELD_TRACK_PEAK;
114 	else if (!strcmp (tag, GST_TAG_ALBUM_GAIN))
115 		return RB_METADATA_FIELD_ALBUM_GAIN;
116 	else if (!strcmp (tag, GST_TAG_ALBUM_PEAK))
117 		return RB_METADATA_FIELD_ALBUM_PEAK;
118 	else if (!strcmp (tag, GST_TAG_BEATS_PER_MINUTE))
119 		return RB_METADATA_FIELD_BPM;
120 	else if (!strcmp (tag, GST_TAG_MUSICBRAINZ_TRACKID))
121 		return RB_METADATA_FIELD_MUSICBRAINZ_TRACKID;
122 	else if (!strcmp (tag, GST_TAG_MUSICBRAINZ_ARTISTID))
123 		return RB_METADATA_FIELD_MUSICBRAINZ_ARTISTID;
124 	else if (!strcmp (tag, GST_TAG_MUSICBRAINZ_ALBUMID))
125 		return RB_METADATA_FIELD_MUSICBRAINZ_ALBUMID;
126 	else if (!strcmp (tag, GST_TAG_MUSICBRAINZ_ALBUMARTISTID))
127 		return RB_METADATA_FIELD_MUSICBRAINZ_ALBUMARTISTID;
128 	else if (!strcmp (tag, GST_TAG_ARTIST_SORTNAME))
129 		return RB_METADATA_FIELD_ARTIST_SORTNAME;
130 	else if (!strcmp (tag, GST_TAG_ALBUM_SORTNAME))
131 		return RB_METADATA_FIELD_ALBUM_SORTNAME;
132 	else if (!strcmp (tag, GST_TAG_ALBUM_ARTIST))
133 		return RB_METADATA_FIELD_ALBUM_ARTIST;
134 	else if (!strcmp (tag, GST_TAG_ALBUM_ARTIST_SORTNAME))
135 		return RB_METADATA_FIELD_ALBUM_ARTIST_SORTNAME;
136 	else
137 		return -1;
138 }
139 
140 const char *
141 rb_metadata_gst_field_to_gst_tag (RBMetaDataField field)
142 {
143 	switch (field)
144 	{
145 	case RB_METADATA_FIELD_TITLE:
146 		return GST_TAG_TITLE;
147 	case RB_METADATA_FIELD_ARTIST:
148 		return GST_TAG_ARTIST;
149 	case RB_METADATA_FIELD_ALBUM:
150 		return GST_TAG_ALBUM;
151 	case RB_METADATA_FIELD_DATE:
152 		return GST_TAG_DATE;
153 	case RB_METADATA_FIELD_GENRE:
154 		return GST_TAG_GENRE;
155 	case RB_METADATA_FIELD_COMMENT:
156 		return GST_TAG_COMMENT;
157 	case RB_METADATA_FIELD_TRACK_NUMBER:
158 		return GST_TAG_TRACK_NUMBER;
159 	case RB_METADATA_FIELD_MAX_TRACK_NUMBER:
160 		return GST_TAG_TRACK_COUNT;
161 	case RB_METADATA_FIELD_DISC_NUMBER:
162 		return GST_TAG_ALBUM_VOLUME_NUMBER;
163 	case RB_METADATA_FIELD_MAX_DISC_NUMBER:
164 		return GST_TAG_ALBUM_VOLUME_COUNT;
165 	case RB_METADATA_FIELD_DESCRIPTION:
166 		return GST_TAG_DESCRIPTION;
167 	case RB_METADATA_FIELD_VERSION:
168 		return GST_TAG_VERSION;
169 	case RB_METADATA_FIELD_ISRC:
170 		return GST_TAG_ISRC;
171 	case RB_METADATA_FIELD_ORGANIZATION:
172 		return GST_TAG_ORGANIZATION;
173 	case RB_METADATA_FIELD_COPYRIGHT:
174 		return GST_TAG_COPYRIGHT;
175 	case RB_METADATA_FIELD_CONTACT:
176 		return GST_TAG_CONTACT;
177 	case RB_METADATA_FIELD_LICENSE:
178 		return GST_TAG_LICENSE;
179 	case RB_METADATA_FIELD_PERFORMER:
180 		return GST_TAG_PERFORMER;
181 	case RB_METADATA_FIELD_DURATION:
182 		return GST_TAG_DURATION;
183 	case RB_METADATA_FIELD_CODEC:
184 		return GST_TAG_CODEC;
185 	case RB_METADATA_FIELD_BITRATE:
186 		return GST_TAG_BITRATE;
187 	case RB_METADATA_FIELD_TRACK_GAIN:
188 		return GST_TAG_TRACK_GAIN;
189 	case RB_METADATA_FIELD_TRACK_PEAK:
190 		return GST_TAG_TRACK_PEAK;
191 	case RB_METADATA_FIELD_ALBUM_GAIN:
192 		return GST_TAG_ALBUM_GAIN;
193 	case RB_METADATA_FIELD_ALBUM_PEAK:
194 		return GST_TAG_ALBUM_PEAK;
195 	case RB_METADATA_FIELD_BPM:
196 		return GST_TAG_BEATS_PER_MINUTE;
197 	case RB_METADATA_FIELD_MUSICBRAINZ_TRACKID:
198 		return GST_TAG_MUSICBRAINZ_TRACKID;
199 	case RB_METADATA_FIELD_MUSICBRAINZ_ARTISTID:
200 		return GST_TAG_MUSICBRAINZ_ARTISTID;
201 	case RB_METADATA_FIELD_MUSICBRAINZ_ALBUMID:
202 		return GST_TAG_MUSICBRAINZ_ALBUMID;
203 	case RB_METADATA_FIELD_MUSICBRAINZ_ALBUMARTISTID:
204 		return GST_TAG_MUSICBRAINZ_ALBUMARTISTID;
205 	case RB_METADATA_FIELD_ARTIST_SORTNAME:
206 		return GST_TAG_ARTIST_SORTNAME;
207 	case RB_METADATA_FIELD_ALBUM_SORTNAME:
208 		return GST_TAG_ALBUM_SORTNAME;
209 	case RB_METADATA_FIELD_ALBUM_ARTIST:
210 		return GST_TAG_ALBUM_ARTIST;
211 	case RB_METADATA_FIELD_ALBUM_ARTIST_SORTNAME:
212 		return GST_TAG_ALBUM_ARTIST_SORTNAME;
213 	default:
214 		return NULL;
215 	}
216 }