Commit 5874c2b7 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

make a formatted version of the duration field, added the bitrate

parent 4724dc5f
......@@ -150,6 +150,21 @@ add_metadata (GFileInfo *info,
if (raw == NULL)
return;
if (strcmp (key, "audio-video::general::duration") == 0) {
int secs;
g_free (formatted);
sscanf (raw, "%i", &secs);
formatted = _g_format_duration_for_display (secs * 1000);
}
else if (strcmp (key, "audio-video::general::bitrate") == 0) {
int bps;
g_free (formatted);
sscanf (raw, "%i", &bps);
formatted = g_strdup_printf ("%d kbps", bps / 1000);
}
metadata = gth_metadata_new ();
g_object_set (metadata,
"id", key,
......@@ -284,6 +299,9 @@ tag_iterate (const GstTagList *list,
if (strcmp (tag, "container-format") == 0) {
tag_key = "audio-video::general::container-format";
}
else if (strcmp (tag, "bitrate") == 0) {
tag_key = "audio-video::general::bitrate";
}
else if (strcmp (tag, "encoder") == 0) {
tag_key = "audio-video::general::encoder";
}
......
......@@ -41,20 +41,19 @@ GthMetadataInfo gstreamer_metadata_info[] = {
{ "audio-video::general::artist", N_("Artist"), "audio-video::general", 2, GTH_METADATA_ALLOW_EVERYWHERE },
{ "audio-video::general::album", N_("Album"), "audio-video::general", 3, GTH_METADATA_ALLOW_EVERYWHERE },
{ "audio-video::general::duration", N_("Duration"), "audio-video::general", 4, GTH_METADATA_ALLOW_EVERYWHERE },
{ "audio-video::general::container-format", N_("Container Format"), "audio-video::general", 5, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::general::encoder", N_("Encoder"), "audio-video::general", 6, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::general::bitrate", N_("Bitrate"), "audio-video::general", 5, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::general::container-format", N_("Container Format"), "audio-video::general", 6, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::general::encoder", N_("Encoder"), "audio-video::general", 7, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::video::size", N_("Dimensions"), "audio-video::video", 1, GTH_METADATA_ALLOW_EVERYWHERE },
{ "audio-video::video::codec", N_("Codec"), "audio-video::video", 2, GTH_METADATA_ALLOW_EVERYWHERE },
{ "audio-video::video::framerate", N_("Framerate"), "audio-video::video", 3, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::video::bitrate", N_("Bitrate"), "audio-video::video", 4, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::video::width", N_("Width"), "audio-video::video", 0, GTH_METADATA_ALLOW_NOWHERE },
{ "audio-video::video::height", N_("Height"), "audio-video::video", 0, GTH_METADATA_ALLOW_NOWHERE },
{ "audio-video::audio::codec", N_("Codec"), "audio-video::audio", 1, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::audio::channels", N_("Channels"), "audio-video::audio", 2, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::audio::samplerate", N_("Sample rate"), "audio-video::audio", 3, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::audio::bitrate", N_("Bitrate"), "audio-video::audio", 4, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ NULL, NULL, NULL, 0, 0 }
};
......
......@@ -25,6 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gprintf.h>
#include <gio/gio.h>
#include "glib-utils.h"
......@@ -2246,3 +2247,37 @@ _g_mime_type_is_audio (const char *mime_type)
return g_content_type_is_a (mime_type, "audio/*");
}
/* this is totem_time_to_string renamed, thanks to the authors :) */
char *
_g_format_duration_for_display (gint64 msecs)
{
int sec, min, hour, _time;
_time = (int) (msecs / 1000);
sec = _time % 60;
_time = _time - sec;
min = (_time % (60*60)) / 60;
_time = _time - (min * 60);
hour = _time / (60*60);
if (hour > 0)
{
/* hour:minutes:seconds */
/* Translators: This is a time format, like "9:05:02" for 9
* hours, 5 minutes, and 2 seconds. You may change ":" to
* the separator that your locale uses or use "%Id" instead
* of "%d" if your locale uses localized digits.
*/
return g_strdup_printf (C_("long time format", "%d:%02d:%02d"), hour, min, sec);
}
/* minutes:seconds */
/* Translators: This is a time format, like "5:02" for 5
* minutes and 2 seconds. You may change ":" to the
* separator that your locale uses or use "%Id" instead of
* "%d" if your locale uses localized digits.
*/
return g_strdup_printf (C_("short time format", "%d:%02d"), min, sec);
}
......@@ -253,6 +253,10 @@ gboolean _g_mime_type_is_image (const char *mime_type);
gboolean _g_mime_type_is_video (const char *mime_type);
gboolean _g_mime_type_is_audio (const char *mime_type);
/* Other */
char * _g_format_duration_for_display (gint64 msecs);
G_END_DECLS
#endif /* _GLIB_UTILS_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment