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

« back to all changes in this revision

Viewing changes to bindings/java/src/playlist-jni.cc

  • 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:
1
 
/*****************************************************************************
2
 
 * playlist-jni.cc: JNI native playlist functions for VLC Java Bindings
3
 
 *****************************************************************************
4
 
 * Copyright (C) 1998-2006 the VideoLAN team
5
 
 *
6
 
 * Authors: Filippo Carone <filippo@carone.org>
7
 
 *
8
 
 *
9
 
 * $Id $
10
 
 *
11
 
 * This program is free software; you can redistribute it and/or modify
12
 
 * it under the terms of the GNU General Public License as published by
13
 
 * the Free Software Foundation; either version 2 of the License, or
14
 
 * (at your option) any later version.
15
 
 *
16
 
 * This program is distributed in the hope that it will be useful,
17
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 
 * GNU General Public License for more details.
20
 
 *
21
 
 * You should have received a copy of the GNU General Public License
22
 
 * along with this program; if not, write to the Free Software
23
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24
 
 *****************************************************************************/
25
 
 
26
 
/* These are a must*/
27
 
#include <jni.h>
28
 
#include <vlc/libvlc.h>
29
 
#include <unistd.h>
30
 
#include <stdio.h>
31
 
 
32
 
/* JVLC internal imports, generated by gcjh */
33
 
#include "../includes/Playlist.h"
34
 
 
35
 
#include "utils.h"
36
 
 
37
 
 
38
 
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1playlist_1add (JNIEnv *env, jobject _this, jstring uri, jstring name,  jobjectArray options) {
39
 
 
40
 
    INIT_FUNCTION ;
41
 
    
42
 
    int res = 0;
43
 
    int i_options = 0;
44
 
    const char** ppsz_options = NULL;
45
 
    const char* psz_uri  = env->GetStringUTFChars( uri, 0 );
46
 
    const char* psz_name = env->GetStringUTFChars( name, 0 );
47
 
 
48
 
    if ( options != NULL ) {
49
 
        i_options = ( int ) env->GetArrayLength( ( jarray ) options ) + 1;
50
 
        ppsz_options = ( const char ** ) malloc( i_options * sizeof( char* ) );
51
 
        sprintf( ( char * ) ppsz_options[0], "%s", "jvlc" );
52
 
 
53
 
        for (int i = 0; i < i_options - 1; i++) {
54
 
            ppsz_options[ i+1 ] =
55
 
                env->GetStringUTFChars( ( jstring ) env->GetObjectArrayElement( options, i ), 0 );
56
 
        }
57
 
        res = libvlc_playlist_add_extended( ( libvlc_instance_t * ) instance, psz_uri, psz_name, i_options, ppsz_options, exception );
58
 
 
59
 
        CHECK_EXCEPTION_FREE;
60
 
        
61
 
    } else {
62
 
        res = libvlc_playlist_add( ( libvlc_instance_t * ) instance, psz_uri, psz_name, exception );
63
 
        
64
 
        CHECK_EXCEPTION_FREE;
65
 
    }
66
 
    
67
 
    if (psz_uri != NULL) {
68
 
        env->ReleaseStringUTFChars( uri, psz_uri );
69
 
    }
70
 
 
71
 
    if (psz_name != NULL) {
72
 
        env->ReleaseStringUTFChars( name, psz_name );
73
 
    }
74
 
 
75
 
    return res;
76
 
}
77
 
 
78
 
 
79
 
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1play (JNIEnv *env, jobject _this, jint id, jobjectArray options)
80
 
{
81
 
 
82
 
    INIT_FUNCTION;
83
 
    
84
 
    int i_options = 0;
85
 
    const char** ppsz_options = NULL;
86
 
 
87
 
    if ( options != NULL ) {
88
 
       i_options = ( int ) env->GetArrayLength( ( jarray ) options );
89
 
       ppsz_options = ( const char ** ) malloc( i_options * sizeof( char* ) );
90
 
       for ( int i = 0; i < i_options - 1; i++ ) {
91
 
           ppsz_options[ i ] = 
92
 
               env->GetStringUTFChars( ( jstring ) env->GetObjectArrayElement( options, i ), 0 );
93
 
       }
94
 
    }
95
 
 
96
 
    libvlc_playlist_play( ( libvlc_instance_t * ) instance, id, i_options, ( char **  ) ppsz_options, exception );
97
 
 
98
 
    CHECK_EXCEPTION_FREE;
99
 
}
100
 
 
101
 
 
102
 
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1pause (JNIEnv *env, jobject _this)
103
 
{
104
 
    INIT_FUNCTION ;
105
 
 
106
 
    libvlc_playlist_pause( ( libvlc_instance_t* ) instance, exception );
107
 
 
108
 
    CHECK_EXCEPTION_FREE ;
109
 
}
110
 
 
111
 
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1stop (JNIEnv *env, jobject _this)
112
 
{
113
 
    INIT_FUNCTION ;
114
 
 
115
 
    libvlc_playlist_stop( ( libvlc_instance_t* ) instance, exception );
116
 
    
117
 
    while ( libvlc_playlist_isplaying( (libvlc_instance_t*) instance, exception ) )
118
 
    {
119
 
        usleep(100);
120
 
    }
121
 
    
122
 
 
123
 
    CHECK_EXCEPTION_FREE ;
124
 
}
125
 
 
126
 
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1next (JNIEnv *env, jobject _this)
127
 
{
128
 
    INIT_FUNCTION ;
129
 
    
130
 
    libvlc_playlist_next( ( libvlc_instance_t* ) instance, exception );
131
 
 
132
 
    CHECK_EXCEPTION_FREE ;
133
 
}
134
 
 
135
 
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1prev (JNIEnv *env, jobject _this)
136
 
{
137
 
    INIT_FUNCTION ;
138
 
    
139
 
    libvlc_playlist_prev( (libvlc_instance_t*) instance, exception );
140
 
 
141
 
    CHECK_EXCEPTION_FREE ;
142
 
}
143
 
 
144
 
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1clear (JNIEnv *env, jobject _this)
145
 
{
146
 
    INIT_FUNCTION ;
147
 
 
148
 
    libvlc_playlist_clear( (libvlc_instance_t*) instance, exception );
149
 
 
150
 
    CHECK_EXCEPTION_FREE ;
151
 
}
152
 
 
153
 
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1deleteItem (JNIEnv *env, jobject _this, jint itemID)
154
 
{
155
 
    INIT_FUNCTION ;
156
 
 
157
 
    libvlc_playlist_delete_item( ( libvlc_instance_t * ) instance, itemID, exception );
158
 
 
159
 
    CHECK_EXCEPTION_FREE ;
160
 
}
161
 
 
162
 
 
163
 
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1itemsCount (JNIEnv *env, jobject _this)
164
 
{
165
 
    INIT_FUNCTION ;
166
 
    int res = 0;
167
 
 
168
 
    res = libvlc_playlist_items_count( (libvlc_instance_t*) instance, exception );
169
 
 
170
 
    CHECK_EXCEPTION_FREE ;
171
 
 
172
 
    return res;
173
 
 
174
 
}
175
 
 
176
 
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1isRunning (JNIEnv *env, jobject _this)
177
 
{
178
 
    INIT_FUNCTION ;
179
 
    int res = 0;
180
 
 
181
 
    res = libvlc_playlist_isplaying( (libvlc_instance_t*) instance, exception );
182
 
 
183
 
    CHECK_EXCEPTION_FREE ;
184
 
 
185
 
    return res;
186
 
}