~ft/aacdec

aacdec/plugins/xmms/src/mp4_utils.c -rw-r--r-- 18.7 KiB
3ba08819Sigrid Solveig Haflínudóttir forbid extra arguments 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
/*
 * some functions for MP4 files
*/

#include "mp4ff.h"
#include "faad.h"

#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <xmms/plugin.h>
#include <xmms/titlestring.h>
#include <xmms/util.h>

const char *mp4AudioNames[]=
  {
    "MPEG-1 Audio Layers 1,2 or 3",
    "MPEG-2 low biterate (MPEG-1 extension) - MP3",
    "MPEG-2 AAC Main Profile",
    "MPEG-2 AAC Low Complexity profile",
    "MPEG-2 AAC SSR profile",
    "MPEG-4 audio (MPEG-4 AAC)",
    0
  };

/* MPEG-4 Audio types from 14496-3 Table 1.5.1 (from mp4.h)*/
const char *mpeg4AudioNames[]=
  {
    "!!!!MPEG-4 Audio track Invalid !!!!!!!",
    "MPEG-4 AAC Main profile",
    "MPEG-4 AAC Low Complexity profile",
    "MPEG-4 AAC SSR profile",
    "MPEG-4 AAC Long Term Prediction profile",
    "MPEG-4 AAC Scalable",
    "MPEG-4 CELP",
    "MPEG-4 HVXC",
    "MPEG-4 Text To Speech",
    "MPEG-4 Main Synthetic profile",
    "MPEG-4 Wavetable Synthesis profile",
    "MPEG-4 MIDI Profile",
    "MPEG-4 Algorithmic Synthesis and Audio FX profile"
  };

static GtkWidget *mp4_info_dialog = NULL;

/*
 * find AAC track
*/

int getAACTrack(mp4ff_t *infile)
{
  int i, rc;
  int numTracks = mp4ff_total_tracks(infile);

  printf("total-tracks: %d\n", numTracks);
  for(i=0; i<numTracks; i++){
    unsigned char*	buff = 0;
    int			buff_size = 0;
    mp4AudioSpecificConfig mp4ASC;

    printf("testing-track: %d\n", i);
    mp4ff_get_decoder_config(infile, i, &buff, &buff_size);
    if(buff){
      rc = NeAACDecAudioSpecificConfig(buff, buff_size, &mp4ASC);
      g_free(buff);
      if(rc < 0)
	continue;
      return(i);
    }
  }
  return(-1);
}

uint32_t read_callback(void *user_data, void *buffer, uint32_t length)
{
  return fread(buffer, 1, length, (FILE*)user_data);
}

uint32_t seek_callback(void *user_data, uint64_t position)
{
  return fseek((FILE*)user_data, position, SEEK_SET);
}

mp4ff_callback_t *getMP4FF_cb(FILE *mp4file)
{
  mp4ff_callback_t* mp4cb = malloc(sizeof(mp4ff_callback_t));
  mp4cb->read = read_callback;
  mp4cb->seek = seek_callback;
  mp4cb->user_data = mp4file;
  return mp4cb;
}

/*
 * Function to display an info box for an mp4 file.
 * This code is based heavily on fileinfo.c from the xmms mpg123
 * plugin, and the info box layout mimics that plugin.
*/
void create_mp4_info_dialog (char *filename, FILE *mp4file, mp4ff_t *infile, gint mp4track)
{
  char *window_title, *value, *value2;
  static GtkWidget *filename_entry, *title_entry, *artist_entry, *album_entry;
  static GtkWidget *genre_entry, *year_entry, *track_entry, *comment_entry;
  static GtkWidget *mp4_info_label;

  if (!mp4_info_dialog)
  {
    GtkWidget *dialog_vbox1, *vbox1, *hbox2, *hbox3, *hbox4;
    GtkWidget *frame2, *frame3, *table1, *dialog_action_area1;
    GtkWidget *filename_label, *title_label, *artist_label, *album_label;
    GtkWidget *genre_label, *year_label, *track_label, *comment_label;
    GtkWidget *close_button;

    mp4_info_dialog = gtk_dialog_new ();
    gtk_object_set_data (GTK_OBJECT (mp4_info_dialog), "mp4_info_dialog", mp4_info_dialog);
    gtk_window_set_policy (GTK_WINDOW (mp4_info_dialog), TRUE, TRUE, FALSE);
    gtk_signal_connect(GTK_OBJECT (mp4_info_dialog), "destroy",
                                   gtk_widget_destroyed, &mp4_info_dialog);

    dialog_vbox1 = GTK_DIALOG (mp4_info_dialog)->vbox;
    gtk_object_set_data (GTK_OBJECT (mp4_info_dialog), "dialog_vbox1", dialog_vbox1);
    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox1), 3);

    hbox2 = gtk_hbox_new (FALSE, 0);
    gtk_widget_ref (hbox2);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "hbox2", hbox2,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_box_pack_start (GTK_BOX (dialog_vbox1), hbox2, FALSE, TRUE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (hbox2), 3);

    filename_label = gtk_label_new ("Filename: ");
    gtk_widget_ref (filename_label);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "filename_label", filename_label,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_box_pack_start (GTK_BOX (hbox2), filename_label, FALSE, FALSE, 0);

    filename_entry = gtk_entry_new ();
    gtk_widget_ref (filename_entry);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "filename_entry", filename_entry,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_box_pack_start (GTK_BOX (hbox2), filename_entry, TRUE, TRUE, 0);
    gtk_entry_set_editable (GTK_ENTRY (filename_entry), FALSE);

    hbox3 = gtk_hbox_new (FALSE, 0);
    gtk_widget_ref (hbox3);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "hbox3", hbox3,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_box_pack_start (GTK_BOX (dialog_vbox1), hbox3, TRUE, TRUE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (hbox3), 3);

    frame2 = gtk_frame_new ("Tag Info: ");
    gtk_widget_ref (frame2);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "frame2", frame2,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_box_pack_start (GTK_BOX (hbox3), frame2, TRUE, TRUE, 0);

    table1 = gtk_table_new (6, 2, FALSE);
    gtk_widget_ref (table1);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "table1", table1,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_container_add (GTK_CONTAINER (frame2), table1);
    gtk_container_set_border_width (GTK_CONTAINER (table1), 5);

    comment_label = gtk_label_new ("Comment: ");
    gtk_widget_ref (comment_label);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "comment_label", comment_label,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_table_attach (GTK_TABLE (table1), comment_label, 0, 1, 5, 6,
                      (GtkAttachOptions) (GTK_FILL),
                      (GtkAttachOptions) (GTK_EXPAND), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (comment_label), 1, 0.5);

    genre_label = gtk_label_new ("Genre: ");
    gtk_widget_ref (genre_label);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "genre_label", genre_label,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_table_attach (GTK_TABLE (table1), genre_label, 0, 1, 4, 5,
                      (GtkAttachOptions) (GTK_FILL),
                      (GtkAttachOptions) (GTK_EXPAND), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (genre_label), 1, 0.5);

    album_label = gtk_label_new ("Album: ");
    gtk_widget_ref (album_label);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "album_label", album_label,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_table_attach (GTK_TABLE (table1), album_label, 0, 1, 2, 3,
                      (GtkAttachOptions) (GTK_FILL),
                      (GtkAttachOptions) (GTK_EXPAND), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (album_label), 1, 0.5);

    title_label = gtk_label_new ("Title: ");
    gtk_widget_ref (title_label);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "title_label", title_label,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_table_attach (GTK_TABLE (table1), title_label, 0, 1, 0, 1,
                      (GtkAttachOptions) (GTK_FILL),
                      (GtkAttachOptions) (GTK_EXPAND), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (title_label), 1, 0.5);

    artist_label = gtk_label_new ("Artist: ");
    gtk_widget_ref (artist_label);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "artist_label", artist_label,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_table_attach (GTK_TABLE (table1), artist_label, 0, 1, 1, 2,
                      (GtkAttachOptions) (GTK_FILL),
                      (GtkAttachOptions) (GTK_EXPAND), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (artist_label), 1, 0.5);

    year_label = gtk_label_new ("Year: ");
    gtk_widget_ref (year_label);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "year_label", year_label,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_table_attach (GTK_TABLE (table1), year_label, 0, 1, 3, 4,
                      (GtkAttachOptions) (GTK_FILL),
                      (GtkAttachOptions) (GTK_EXPAND), 0, 0);
    gtk_misc_set_alignment (GTK_MISC (year_label), 1, 0.5);

    hbox4 = gtk_hbox_new (FALSE, 0);
    gtk_widget_ref (hbox4);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "hbox4", hbox4,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_table_attach (GTK_TABLE (table1), hbox4, 1, 2, 3, 4,
                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                      (GtkAttachOptions) (GTK_FILL), 0, 0);

    year_entry = gtk_entry_new ();
    gtk_widget_ref (year_entry);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "year_entry", year_entry,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_box_pack_start (GTK_BOX (hbox4), year_entry, FALSE, FALSE, 0);
    gtk_widget_set_usize (year_entry, 60, -2);
    gtk_entry_set_editable (GTK_ENTRY (year_entry), FALSE);

    track_label = gtk_label_new ("     Track: ");
    gtk_widget_ref (track_label);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "track_label", track_label,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_box_pack_start (GTK_BOX (hbox4), track_label, FALSE, FALSE, 0);
    gtk_misc_set_alignment (GTK_MISC (track_label), 1, 0.5);

    track_entry = gtk_entry_new ();
    gtk_widget_ref (track_entry);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "track_entry", track_entry,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_box_pack_start (GTK_BOX (hbox4), track_entry, FALSE, FALSE, 0);
    gtk_widget_set_usize (track_entry, 60, -2);
    gtk_entry_set_editable (GTK_ENTRY (track_entry), FALSE);

    title_entry = gtk_entry_new ();
    gtk_widget_ref (title_entry);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "title_entry", title_entry,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_table_attach (GTK_TABLE (table1), title_entry, 1, 2, 0, 1,
                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                      (GtkAttachOptions) (0), 0, 0);
    gtk_entry_set_editable (GTK_ENTRY (title_entry), FALSE);

    artist_entry = gtk_entry_new ();
    gtk_widget_ref (artist_entry);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "artist_entry", artist_entry,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_table_attach (GTK_TABLE (table1), artist_entry, 1, 2, 1, 2,
                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                      (GtkAttachOptions) (0), 0, 0);
    gtk_entry_set_editable (GTK_ENTRY (artist_entry), FALSE);

    album_entry = gtk_entry_new ();
    gtk_widget_ref (album_entry);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "album_entry", album_entry,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_table_attach (GTK_TABLE (table1), album_entry, 1, 2, 2, 3,
                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                      (GtkAttachOptions) (0), 0, 0);
    gtk_entry_set_editable (GTK_ENTRY (album_entry), FALSE);

    genre_entry = gtk_entry_new ();
    gtk_widget_ref (genre_entry);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "genre_entry", genre_entry,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_table_attach (GTK_TABLE (table1), genre_entry, 1, 2, 4, 5,
                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                      (GtkAttachOptions) (0), 0, 0);
    gtk_entry_set_editable (GTK_ENTRY (genre_entry), FALSE);

    comment_entry = gtk_entry_new ();
    gtk_widget_ref (comment_entry);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "comment_entry", comment_entry,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_table_attach (GTK_TABLE (table1), comment_entry, 1, 2, 5, 6,
                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                      (GtkAttachOptions) (0), 0, 0);
    gtk_entry_set_editable (GTK_ENTRY (comment_entry), FALSE);

    frame3 = gtk_frame_new ("MP4 Info: ");
    gtk_widget_ref (frame3);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "frame3", frame3,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_box_pack_start (GTK_BOX (hbox3), frame3, FALSE, TRUE, 0);

    vbox1 = gtk_vbox_new (FALSE, 0);
    gtk_widget_ref (vbox1);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "vbox1", vbox1,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_container_add (GTK_CONTAINER (frame3), vbox1);
    gtk_container_set_border_width (GTK_CONTAINER (vbox1), 5);

    mp4_info_label = gtk_label_new ("");
    gtk_widget_ref (mp4_info_label);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "mp4_info_label", mp4_info_label,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_box_pack_start (GTK_BOX (vbox1), mp4_info_label, TRUE, TRUE, 0);
    gtk_label_set_justify (GTK_LABEL (mp4_info_label), GTK_JUSTIFY_LEFT);
    gtk_misc_set_alignment (GTK_MISC (mp4_info_label), 0, 0);

    dialog_action_area1 = GTK_DIALOG (mp4_info_dialog)->action_area;
    gtk_object_set_data (GTK_OBJECT (mp4_info_dialog), "dialog_action_area1", dialog_action_area1);
    gtk_container_set_border_width (GTK_CONTAINER (dialog_action_area1), 4);

    close_button = gtk_button_new_with_label ("Close");
    gtk_widget_ref (close_button);
    gtk_object_set_data_full (GTK_OBJECT (mp4_info_dialog), "close_button", close_button,
                              (GtkDestroyNotify) gtk_widget_unref);
    gtk_box_pack_start (GTK_BOX (dialog_action_area1), close_button, FALSE, FALSE, 0);

    gtk_signal_connect_object (GTK_OBJECT (close_button), "clicked",
                               GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (mp4_info_dialog));

  }

  window_title = g_strdup_printf("File Info - %s", g_basename(filename));
  gtk_window_set_title (GTK_WINDOW (mp4_info_dialog), window_title);
  g_free(window_title);

  gtk_entry_set_text (GTK_ENTRY (filename_entry), filename);

  gtk_entry_set_text (GTK_ENTRY (title_entry), "");
  gtk_entry_set_text (GTK_ENTRY (artist_entry), "");
  gtk_entry_set_text (GTK_ENTRY (album_entry), "");
  gtk_entry_set_text (GTK_ENTRY (year_entry), "");
  gtk_entry_set_text (GTK_ENTRY (track_entry), "");
  gtk_entry_set_text (GTK_ENTRY (genre_entry), "");
  gtk_entry_set_text (GTK_ENTRY (comment_entry), "");

  if ((mp4ff_meta_get_title(infile, &value)) && value != NULL) {
    gtk_entry_set_text (GTK_ENTRY(title_entry), value);
    g_free(value);
  }
  if ((mp4ff_meta_get_artist(infile, &value)) && value != NULL) {
    gtk_entry_set_text (GTK_ENTRY(artist_entry), value);
    g_free(value);
  }
  if ((mp4ff_meta_get_album(infile, &value)) && value != NULL) {
    gtk_entry_set_text (GTK_ENTRY(album_entry), value);
    g_free(value);
  }
  if ((mp4ff_meta_get_date(infile, &value)) && value != NULL) {
    gtk_entry_set_text (GTK_ENTRY(year_entry), value);
    g_free(value);
  }
  if ((mp4ff_meta_get_track(infile, &value)) && value != NULL) {
    if ((mp4ff_meta_get_totaltracks(infile, &value2)) && value2 != NULL) {
      char *tmp = g_strdup_printf("%s of %s", value, value2);
      g_free(value2);
      g_free(value);
      value = tmp;
    }
    gtk_entry_set_text (GTK_ENTRY(track_entry), value);
    g_free(value);
  }
  if ((mp4ff_meta_get_genre(infile, &value)) && value != NULL) {
    gtk_entry_set_text (GTK_ENTRY(genre_entry), value);
    g_free(value);
  }
  if ((mp4ff_meta_get_comment(infile, &value)) && value != NULL) {
    gtk_entry_set_text (GTK_ENTRY(comment_entry), value);
    g_free(value);
  }

  // Get the length of the track.
  double track_duration = mp4ff_get_track_duration(infile, mp4track);
  unsigned long time_scale = mp4ff_time_scale(infile, mp4track);
  unsigned long length = (track_duration / time_scale);
  int min = length / 60;
  int sec = length % 60;

  // Get other info about the track.
  unsigned long bitrate = mp4ff_get_avg_bitrate(infile, mp4track) / 1000;
  unsigned long samplerate = mp4ff_get_sample_rate(infile, mp4track);
  unsigned long channels = mp4ff_get_channel_count(infile, mp4track);
  unsigned long audio_type = mp4ff_get_audio_type(infile, mp4track);
  fseek(mp4file, 0, SEEK_END);
  int filesize = ftell(mp4file) / 1024;

  value = g_strdup_printf("Length: %d:%d\nAvg. Bitrate: %ld kbps\nSample Rate: %ld Hz\nChannels: %ld\nAudio Type: %ld\nFile Size: %d KB", min, sec, bitrate, samplerate, channels, audio_type, filesize);
  gtk_label_set_text (GTK_LABEL(mp4_info_label), value);
  g_free(value);

  gtk_widget_show_all(mp4_info_dialog);
}


void getMP4info(char* filename, FILE* mp4file)
{
  mp4ff_callback_t*	mp4cb;
  mp4ff_t*		infile;
  gint			mp4track;

  mp4cb = getMP4FF_cb(mp4file);
  if ((infile = mp4ff_open_read_metaonly(mp4cb)) &&
      ((mp4track = getAACTrack(infile)) >= 0)){
    create_mp4_info_dialog (filename, mp4file, infile, mp4track);
  }
  if(infile) mp4ff_close(infile);
  if(mp4cb) g_free(mp4cb);
}

/* Get the xmms titlestring for the file based on metadata.
The following code was adapted from the gtkpod project, specifically
mp4file.c (C) Jorg Schuler, but written to use the mp4ff library.  The
mpg123 input plugin for xmms was used as a guide for this function.
	--Jason Arroyo, 2004 */
char *getMP4title(mp4ff_t *infile, char *filename) {
	char *ret=NULL;
	gchar *value, *path, *temp;

	TitleInput *input;
	XMMS_NEW_TITLEINPUT(input);

	// Fill in the TitleInput with the relevant data
	// from the mp4 file that can be used to display the title.
	mp4ff_meta_get_title(infile, &input->track_name);
        mp4ff_meta_get_artist(infile, &input->performer);
	mp4ff_meta_get_album(infile, &input->album_name);
	if (mp4ff_meta_get_track(infile, &value) && value != NULL) {
		input->track_number = atoi(value);
		g_free(value);
	}
	if (mp4ff_meta_get_date(infile, &value) && value != NULL) {
		input->year = atoi(value);
		g_free(value);
	}
	mp4ff_meta_get_genre(infile, &input->genre);
	mp4ff_meta_get_comment(infile, &input->comment);
	input->file_name = g_strdup(g_basename(filename));
	path = g_strdup(filename);
	temp = strrchr(path, '.');
	if (temp != NULL) {++temp;}
	input->file_ext = g_strdup_printf("%s", temp);
	temp = strrchr(path, '/');
	if (temp) {*temp = '\0';}
	input->file_path = g_strdup_printf("%s/", path);

	// Use the default xmms title format to format the
	// title from the above info.
	ret = xmms_get_titlestring(xmms_get_gentitle_format(), input);

        g_free(input->track_name);
        g_free(input->performer);
        g_free(input->album_name);
        g_free(input->genre);
        g_free(input->comment);
        g_free(input->file_name);
        g_free(input->file_ext);
        g_free(input->file_path);
	g_free(input);
	g_free(path);

	return ret;
}