~ubuntu-branches/ubuntu/maverick/vlc/maverick

« back to all changes in this revision

Viewing changes to modules/misc/playlist/m3u.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-09-17 21:56:14 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20080917215614-tj0vx8xzd57e52t8
Tags: 0.9.2-1ubuntu1
* New Upstream Release, exception granted by
    - dktrkranz, norsetto, Hobbsee (via irc). LP: #270404

Changes done in ubuntu:

* add libxul-dev to build-depends
* make sure that vlc is build against libxul in configure. This doesn't
  change anything in the package, but makes it more robust if building
  in an 'unclean' chroot or when modifying the package.
* debian/control: make Vcs-* fields point to the motumedia branch
* add libx264-dev and libass-dev to build-depends
  LP: #210354, #199870
* actually enable libass support by passing --enable-libass to configure
* enable libdca: add libdca-dev to build depends and --enable-libdca
* install the x264 plugin.

Changes already in the pkg-multimedia branch in debian:

* don't install usr/share/vlc/mozilla in debian/mozilla-plugin-vlc.install  
* new upstream .desktop file now registers flash video mimetype LP: #261567
* add Xb-Npp-Applications to mozilla-plugin-vlc
* remove duplicate entries in debian/vlc-nox.install

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * m3u.c :  M3U playlist export module
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2004 the VideoLAN team
5
 
 * $Id: bcf37e8d1950896e5e7a13c8b269b140c10645b2 $
 
5
 * $Id$
6
6
 *
7
7
 * Authors: Clément Stenac <zorglub@videolan.org>
8
8
 *
24
24
/*****************************************************************************
25
25
 * Preamble
26
26
 *****************************************************************************/
27
 
#include <stdlib.h>                                      /* malloc(), free() */
28
 
 
29
 
#include <vlc/vlc.h>
30
 
#include <vlc/intf.h>
 
27
 
 
28
#ifdef HAVE_CONFIG_H
 
29
# include "config.h"
 
30
#endif
 
31
 
 
32
#include <vlc_common.h>
 
33
#include <vlc_interface.h>
 
34
#include <vlc_playlist.h>
 
35
#include <vlc_input.h>
31
36
#include <vlc_meta.h>
32
37
 
33
38
#include <errno.h>                                                 /* ENOMEM */
34
39
 
 
40
#include <assert.h>
 
41
 
35
42
/*****************************************************************************
36
43
 * Local prototypes
37
44
 *****************************************************************************/
40
47
/*****************************************************************************
41
48
 * Export_M3U: main export function
42
49
 *****************************************************************************/
43
 
int Export_M3U( vlc_object_t *p_this )
 
50
static void DoChildren( playlist_t *p_playlist, playlist_export_t *p_export,
 
51
                        playlist_item_t *p_root )
44
52
{
45
 
    playlist_t *p_playlist = (playlist_t*)p_this;
46
 
    playlist_export_t *p_export = (playlist_export_t *)p_playlist->p_private;
47
53
    int i, j;
48
54
 
49
 
    msg_Dbg(p_playlist, "saving using M3U format");
50
 
 
51
 
    /* Write header */
52
 
    fprintf( p_export->p_file, "#EXTM3U\n" );
53
 
 
54
55
    /* Go through the playlist and add items */
55
 
    for( i = 0; i< p_playlist->i_size ; i++)
 
56
    for( i = 0; i< p_root->i_children ; i++)
56
57
    {
57
 
        if( (p_playlist->pp_items[i]->i_flags & PLAYLIST_SAVE_FLAG) == 0 )
 
58
        playlist_item_t *p_current = p_root->pp_children[i];
 
59
        assert( p_current );
 
60
 
 
61
        if( p_current->i_flags & PLAYLIST_SAVE_FLAG )
 
62
            continue;
 
63
 
 
64
        if( p_current->i_children >= 0 )
58
65
        {
 
66
            DoChildren( p_playlist, p_export, p_current );
59
67
            continue;
60
68
        }
61
69
 
62
70
        /* General info */
63
 
        if( p_playlist->pp_items[i]->input.psz_name &&
64
 
             strcmp( p_playlist->pp_items[i]->input.psz_name,
65
 
                    p_playlist->pp_items[i]->input.psz_uri ) )
 
71
 
 
72
        char *psz_uri = input_item_GetURI( p_current->p_input );
 
73
 
 
74
        assert( psz_uri );
 
75
 
 
76
        char *psz_name = input_item_GetName( p_current->p_input );
 
77
        if( psz_name && strcmp( psz_uri, psz_name ) )
66
78
        {
67
 
            char *psz_artist =
68
 
                vlc_input_item_GetInfo( &p_playlist->pp_items[i]->input,
69
 
                                        _(VLC_META_INFO_CAT), _(VLC_META_ARTIST) );
 
79
            char *psz_artist = input_item_GetArtist( p_current->p_input );
 
80
            if( psz_artist == NULL ) psz_artist = strdup( "" );
 
81
            mtime_t i_duration = input_item_GetDuration( p_current->p_input );
70
82
            if( psz_artist && *psz_artist )
71
83
            {
72
84
                /* write EXTINF with artist */
73
85
                fprintf( p_export->p_file, "#EXTINF:%i,%s - %s\n",
74
 
                         (int)(p_playlist->pp_items[i]->input.i_duration/1000000),
75
 
                         psz_artist,
76
 
                         p_playlist->pp_items[i]->input.psz_name );
 
86
                          (int)( i_duration / 1000000 ), psz_artist, psz_name);
77
87
            }
78
88
            else
79
89
            {
80
90
                /* write EXTINF without artist */
81
91
                fprintf( p_export->p_file, "#EXTINF:%i,%s\n",
82
 
                       (int)(p_playlist->pp_items[i]->input.i_duration/1000000),
83
 
                         p_playlist->pp_items[i]->input.psz_name );
 
92
                         (int)( i_duration / 1000000 ), psz_name);
84
93
            }
85
 
            if( psz_artist )
86
 
                free( psz_artist );
 
94
            free( psz_artist );
87
95
        }
 
96
        free( psz_name );
88
97
 
89
98
        /* VLC specific options */
90
 
        for( j = 0; j < p_playlist->pp_items[i]->input.i_options; j++ )
 
99
        vlc_mutex_lock( &p_current->p_input->lock );
 
100
        for( j = 0; j < p_current->p_input->i_options; j++ )
91
101
        {
92
102
            fprintf( p_export->p_file, "#EXTVLCOPT:%s\n",
93
 
                     p_playlist->pp_items[i]->input.ppsz_options[j][0] == ':' ?
94
 
                     p_playlist->pp_items[i]->input.ppsz_options[j] + 1 :
95
 
                     p_playlist->pp_items[i]->input.ppsz_options[j] );
 
103
                     p_current->p_input->ppsz_options[j][0] == ':' ?
 
104
                     p_current->p_input->ppsz_options[j] + 1 :
 
105
                     p_current->p_input->ppsz_options[j] );
96
106
        }
 
107
        vlc_mutex_unlock( &p_current->p_input->lock );
97
108
 
98
 
        fprintf( p_export->p_file, "%s\n",
99
 
                 p_playlist->pp_items[i]->input.psz_uri );
 
109
        fprintf( p_export->p_file, "%s\n", psz_uri );
 
110
        free( psz_uri );
100
111
    }
 
112
}
 
113
 
 
114
int Export_M3U( vlc_object_t *p_this )
 
115
{
 
116
    playlist_t *p_playlist = (playlist_t*)p_this;
 
117
    playlist_export_t *p_export = (playlist_export_t *)p_playlist->p_private;
 
118
 
 
119
    msg_Dbg(p_playlist, "saving using M3U format");
 
120
 
 
121
    /* Write header */
 
122
    fprintf( p_export->p_file, "#EXTM3U\n" );
 
123
 
 
124
    DoChildren( p_playlist, p_export, p_export->p_root );
101
125
    return VLC_SUCCESS;
102
126
}