ext/speex/gstspeexenc.c: Fix handling of GST_TAG_DATE, which is now of GST_TYPE_DATE; use GST_READ_UINT32_LE() and fr...
Original commit message from CVS: * ext/speex/gstspeexenc.c: (gst_speexenc_get_tag_value), (comment_init), (comment_add): Fix handling of GST_TAG_DATE, which is now of GST_TYPE_DATE; use GST_READ_UINT32_LE() and friends rather than the private implementation of those same macros.
This commit is contained in:
parent
1eb3b76e8b
commit
fb495736bc
@ -1,3 +1,11 @@
|
|||||||
|
2005-10-13 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
* ext/speex/gstspeexenc.c: (gst_speexenc_get_tag_value),
|
||||||
|
(comment_init), (comment_add):
|
||||||
|
Fix handling of GST_TAG_DATE, which is now of GST_TYPE_DATE;
|
||||||
|
use GST_READ_UINT32_LE() and friends rather than the private
|
||||||
|
implementation of those same macros.
|
||||||
|
|
||||||
2005-10-13 Stefan Kost <ensonic@users.sf.net>
|
2005-10-13 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
* examples/stats/mp2ogg.c:
|
* examples/stats/mp2ogg.c:
|
||||||
|
@ -514,15 +514,20 @@ gst_speexenc_init (GstSpeexEnc * speexenc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* FIXME: why are we not using the from/to vorbiscomment
|
||||||
|
* functions that are in -lgsttagedit-0.9 here? */
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
gst_speexenc_get_tag_value (const GstTagList * list, const gchar * tag,
|
gst_speexenc_get_tag_value (const GstTagList * list, const gchar * tag,
|
||||||
int index)
|
int index)
|
||||||
{
|
{
|
||||||
|
GType tag_type;
|
||||||
gchar *speexvalue = NULL;
|
gchar *speexvalue = NULL;
|
||||||
|
|
||||||
if (tag == NULL) {
|
if (tag == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
tag_type = gst_tag_get_type (tag);
|
||||||
|
|
||||||
/* get tag name right */
|
/* get tag name right */
|
||||||
if ((strcmp (tag, GST_TAG_TRACK_NUMBER) == 0)
|
if ((strcmp (tag, GST_TAG_TRACK_NUMBER) == 0)
|
||||||
@ -531,24 +536,26 @@ gst_speexenc_get_tag_value (const GstTagList * list, const gchar * tag,
|
|||||||
|| (strcmp (tag, GST_TAG_ALBUM_VOLUME_COUNT) == 0)) {
|
|| (strcmp (tag, GST_TAG_ALBUM_VOLUME_COUNT) == 0)) {
|
||||||
guint track_no;
|
guint track_no;
|
||||||
|
|
||||||
if (!gst_tag_list_get_uint_index (list, tag, index, &track_no))
|
if (gst_tag_list_get_uint_index (list, tag, index, &track_no)) {
|
||||||
g_assert_not_reached ();
|
|
||||||
speexvalue = g_strdup_printf ("%u", track_no);
|
speexvalue = g_strdup_printf ("%u", track_no);
|
||||||
} else if (strcmp (tag, GST_TAG_DATE) == 0) {
|
} else {
|
||||||
|
GST_WARNING ("Failed to extract int tag %d for '%s'", index, tag);
|
||||||
|
}
|
||||||
|
} else if (tag_type == GST_TYPE_DATE) {
|
||||||
/* FIXME: how are dates represented in speex files? */
|
/* FIXME: how are dates represented in speex files? */
|
||||||
GDate *date;
|
GDate *date;
|
||||||
guint u;
|
|
||||||
|
|
||||||
if (!gst_tag_list_get_uint_index (list, tag, index, &u))
|
if (gst_tag_list_get_date_index (list, tag, index, &date)) {
|
||||||
g_assert_not_reached ();
|
|
||||||
date = g_date_new_julian (u);
|
|
||||||
speexvalue =
|
speexvalue =
|
||||||
g_strdup_printf ("%04d-%02d-%02d", (gint) g_date_get_year (date),
|
g_strdup_printf ("%04d-%02d-%02d", (gint) g_date_get_year (date),
|
||||||
(gint) g_date_get_month (date), (gint) g_date_get_day (date));
|
(gint) g_date_get_month (date), (gint) g_date_get_day (date));
|
||||||
g_date_free (date);
|
g_date_free (date);
|
||||||
} else if (gst_tag_get_type (tag) == G_TYPE_STRING) {
|
} else {
|
||||||
|
GST_WARNING ("Failed to extract date tag %d for '%s'", index, tag);
|
||||||
|
}
|
||||||
|
} else if (tag_type == G_TYPE_STRING) {
|
||||||
if (!gst_tag_list_get_string_index (list, tag, index, &speexvalue))
|
if (!gst_tag_list_get_string_index (list, tag, index, &speexvalue))
|
||||||
g_assert_not_reached ();
|
GST_WARNING ("Failed to extract string tag %d for '%s'", index, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return speexvalue;
|
return speexvalue;
|
||||||
@ -573,16 +580,6 @@ gst_speexenc_get_tag_value (const GstTagList * list, const gchar * tag,
|
|||||||
*
|
*
|
||||||
* If you have troubles, please write to ymnk@jcraft.com.
|
* If you have troubles, please write to ymnk@jcraft.com.
|
||||||
*/
|
*/
|
||||||
#define readint(buf, base) (((buf[base+3]<<24) & 0xff000000)| \
|
|
||||||
((buf[base+2]<<16) & 0xff0000)| \
|
|
||||||
((buf[base+1]<< 8) & 0xff00)| \
|
|
||||||
(buf[base ] & 0xff))
|
|
||||||
#define writeint(buf, base, val) do{ buf[base+3] = ((val)>>24) & 0xff; \
|
|
||||||
buf[base+2] = ((val)>>16) & 0xff; \
|
|
||||||
buf[base+1] = ((val)>> 8) & 0xff; \
|
|
||||||
buf[base ] = (val) & 0xff; \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
comment_init (guint8 ** comments, int *length, char *vendor_string)
|
comment_init (guint8 ** comments, int *length, char *vendor_string)
|
||||||
{
|
{
|
||||||
@ -591,9 +588,9 @@ comment_init (guint8 ** comments, int *length, char *vendor_string)
|
|||||||
int len = 4 + vendor_length + 4;
|
int len = 4 + vendor_length + 4;
|
||||||
guint8 *p = g_malloc (len);
|
guint8 *p = g_malloc (len);
|
||||||
|
|
||||||
writeint (p, 0, vendor_length);
|
GST_WRITE_UINT32_LE (p, vendor_length);
|
||||||
memcpy (p + 4, (guint8 *) vendor_string, vendor_length);
|
memcpy (p + 4, vendor_string, vendor_length);
|
||||||
writeint (p, 4 + vendor_length, user_comment_list_length);
|
GST_WRITE_UINT32_LE (p + 4 + vendor_length, user_comment_list_length);
|
||||||
*length = len;
|
*length = len;
|
||||||
*comments = p;
|
*comments = p;
|
||||||
}
|
}
|
||||||
@ -601,27 +598,24 @@ static void
|
|||||||
comment_add (guint8 ** comments, int *length, const char *tag, char *val)
|
comment_add (guint8 ** comments, int *length, const char *tag, char *val)
|
||||||
{
|
{
|
||||||
guint8 *p = *comments;
|
guint8 *p = *comments;
|
||||||
int vendor_length = readint (p, 0);
|
int vendor_length = GST_READ_UINT32_LE (p);
|
||||||
int user_comment_list_length = readint (p, 4 + vendor_length);
|
int user_comment_list_length = GST_READ_UINT32_LE (p + 4 + vendor_length);
|
||||||
int tag_len = (tag ? strlen (tag) : 0);
|
int tag_len = (tag ? strlen (tag) : 0);
|
||||||
int val_len = strlen (val);
|
int val_len = strlen (val);
|
||||||
int len = (*length) + 4 + tag_len + val_len;
|
int len = (*length) + 4 + tag_len + val_len;
|
||||||
|
|
||||||
p = g_realloc (p, len);
|
p = g_realloc (p, len);
|
||||||
|
|
||||||
writeint (p, *length, tag_len + val_len); /* length of comment */
|
GST_WRITE_UINT32_LE (p + *length, tag_len + val_len); /* length of comment */
|
||||||
if (tag)
|
if (tag)
|
||||||
memcpy (p + *length + 4, (guint8 *) tag, tag_len); /* comment */
|
memcpy (p + *length + 4, (guint8 *) tag, tag_len); /* comment */
|
||||||
memcpy (p + *length + 4 + tag_len, val, val_len); /* comment */
|
memcpy (p + *length + 4 + tag_len, val, val_len); /* comment */
|
||||||
writeint (p, 4 + vendor_length, user_comment_list_length + 1);
|
GST_WRITE_UINT32_LE (p + 4 + vendor_length, user_comment_list_length + 1);
|
||||||
|
|
||||||
*comments = p;
|
*comments = p;
|
||||||
*length = len;
|
*length = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef readint
|
|
||||||
#undef writeint
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_speexenc_metadata_set1 (const GstTagList * list, const gchar * tag,
|
gst_speexenc_metadata_set1 (const GstTagList * list, const gchar * tag,
|
||||||
gpointer speexenc)
|
gpointer speexenc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user