libvlc.c 18 KB
Newer Older
1
/*****************************************************************************
Clément Stenac's avatar
Clément Stenac committed
2
 * libvlc.c: Implementation of the old libvlc API
3
 *****************************************************************************
4
 * Copyright (C) 1998-2007 the VideoLAN team
5
 * $Id$
6 7 8
 *
 * Authors: Vincent Seguin <seguin@via.ecp.fr>
 *          Samuel Hocevar <sam@zoy.org>
9
 *          Gildas Bazin <gbazin@videolan.org>
10
 *          Derk-Jan Hartman <hartman at videolan dot org>
11
 *          Rémi Denis-Courmont <rem # videolan : org>
12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
Antoine Cellerier's avatar
Antoine Cellerier committed
25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 27 28 29 30 31
 *****************************************************************************/

/*****************************************************************************
 * Pretend we are a builtin module
 *****************************************************************************/
#define MODULE_NAME main
32
#define MODULE_PATH main
33 34 35 36 37
#define __BUILTIN__

/*****************************************************************************
 * Preamble
 *****************************************************************************/
38 39 40 41
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

42 43
#include <vlc/vlc.h>

Clément Stenac's avatar
Clément Stenac committed
44
#include "control/libvlc_internal.h"
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
45
#include "libvlc.h"
46

47
#include <vlc_playlist.h>
48

Clément Stenac's avatar
Clément Stenac committed
49 50
#include <vlc_aout.h>
#include <vlc_vout.h>
51

52 53 54 55 56 57 58
#define LIBVLC_FUNC \
    libvlc_int_t * p_libvlc = vlc_current_object( i_object ); \
    if( !p_libvlc ) return VLC_ENOOBJ;
#define LIBVLC_FUNC_END \
    if( i_object ) vlc_object_release( p_libvlc );


59
/*****************************************************************************
60
 * VLC_VariableSet: set a "safe" vlc variable
61
 *****************************************************************************/
62
int VLC_VariableSet( int i_object, char const *psz_var, vlc_value_t value )
63
{
Gildas Bazin's avatar
 
Gildas Bazin committed
64
    int i_ret;
65
    LIBVLC_FUNC;
66

Sam Hocevar's avatar
Sam Hocevar committed
67 68 69
    /* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then
     * we handle it as a configuration variable. Don't tell Gildas :) -- sam */
    if( !strncmp( psz_var, "conf::", 6 ) )
70
    {
Sam Hocevar's avatar
Sam Hocevar committed
71
        module_config_t *p_item;
72
        char const *psz_newvar = psz_var + 6;
73

74
        p_item = config_FindConfig( VLC_OBJECT(p_libvlc), psz_newvar );
75

Sam Hocevar's avatar
Sam Hocevar committed
76
        if( p_item )
77
        {
78 79 80 81 82
            /* VLC_VariableSet is only used from the browser plugins, so we
             *  can pretty much assume that the input is _not_ trusted. */
            if( !p_item->b_safe )
                return VLC_EGENERIC;

Sam Hocevar's avatar
Sam Hocevar committed
83
            switch( p_item->i_type )
84
            {
Sam Hocevar's avatar
Sam Hocevar committed
85
                case CONFIG_ITEM_BOOL:
86
                    config_PutInt( p_libvlc, psz_newvar, value.b_bool );
Sam Hocevar's avatar
Sam Hocevar committed
87 88
                    break;
                case CONFIG_ITEM_INTEGER:
89
                    config_PutInt( p_libvlc, psz_newvar, value.i_int );
Sam Hocevar's avatar
Sam Hocevar committed
90 91
                    break;
                case CONFIG_ITEM_FLOAT:
92
                    config_PutFloat( p_libvlc, psz_newvar, value.f_float );
Sam Hocevar's avatar
Sam Hocevar committed
93 94
                    break;
                default:
95
                    config_PutPsz( p_libvlc, psz_newvar, value.psz_string );
Sam Hocevar's avatar
Sam Hocevar committed
96
                    break;
97
            }
98
            if( i_object ) vlc_object_release( p_libvlc );
Sam Hocevar's avatar
Sam Hocevar committed
99
            return VLC_SUCCESS;
100 101
        }
    }
102 103 104 105 106 107 108 109 110
    /* EXPLICIT HACK (this is the legacy API anyway):
     * VLC_VariableSet is only used from the browser plugins, so we
     *  can pretty much assume that the input is _not_ trusted. */
    module_config_t *p_item;
    p_item = config_FindConfig( VLC_OBJECT(p_libvlc), psz_var );
    if( !p_item )
        return VLC_ENOVAR;
    if( !p_item->b_safe )
        return VLC_EGENERIC;
111

112
    i_ret = var_Set( p_libvlc, psz_var, value );
Gildas Bazin's avatar
 
Gildas Bazin committed
113

114
    LIBVLC_FUNC_END;
Gildas Bazin's avatar
 
Gildas Bazin committed
115
    return i_ret;
Sam Hocevar's avatar
Sam Hocevar committed
116 117 118
}

/*****************************************************************************
119
 * VLC_VariableGet: get a vlc variable
Sam Hocevar's avatar
Sam Hocevar committed
120
 *****************************************************************************/
121
int VLC_VariableGet( int i_object, char const *psz_var, vlc_value_t *p_value )
Sam Hocevar's avatar
Sam Hocevar committed
122
{
Gildas Bazin's avatar
 
Gildas Bazin committed
123
    int i_ret;
124
    LIBVLC_FUNC;
125
    i_ret = var_Get( p_libvlc , psz_var, p_value );
126
    LIBVLC_FUNC_END;
Gildas Bazin's avatar
 
Gildas Bazin committed
127
    return i_ret;
128 129
}

130 131 132 133 134 135
/*****************************************************************************
 * VLC_VariableType: get a vlc variable type
 *****************************************************************************/
int VLC_VariableType( int i_object, char const *psz_var, int *pi_type )
{
    int i_type;
136
    LIBVLC_FUNC;
137 138 139 140 141 142 143
    /* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then
     * we handle it as a configuration variable. Don't tell Gildas :) -- sam */
    if( !strncmp( psz_var, "conf::", 6 ) )
    {
        module_config_t *p_item;
        char const *psz_newvar = psz_var + 6;

144
        p_item = config_FindConfig( VLC_OBJECT(p_libvlc), psz_newvar );
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167

        if( p_item )
        {
            switch( p_item->i_type )
            {
                case CONFIG_ITEM_BOOL:
                    i_type = VLC_VAR_BOOL;
                    break;
                case CONFIG_ITEM_INTEGER:
                    i_type = VLC_VAR_INTEGER;
                    break;
                case CONFIG_ITEM_FLOAT:
                    i_type = VLC_VAR_FLOAT;
                    break;
                default:
                    i_type = VLC_VAR_STRING;
                    break;
            }
        }
        else
            i_type = 0;
    }
    else
168
        i_type = VLC_VAR_TYPE & var_Type( p_libvlc , psz_var );
169

170
    LIBVLC_FUNC_END;
171 172 173 174 175 176 177 178 179

    if( i_type > 0 )
    {
        *pi_type = i_type;
        return VLC_SUCCESS;
    }
    return VLC_ENOVAR;
}

180 181
#define LIBVLC_PLAYLIST_FUNC \
    libvlc_int_t *p_libvlc = vlc_current_object( i_object );\
182 183 184
    if( !p_libvlc ) return VLC_ENOOBJ; \
    playlist_t *p_playlist = pl_Yield( p_libvlc ); \
    if( !p_playlist ) return VLC_ENOOBJ
185 186

#define LIBVLC_PLAYLIST_FUNC_END \
187
    pl_Release( p_libvlc ); \
188 189
    if( i_object ) vlc_object_release( p_libvlc );

190
/*****************************************************************************
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
191 192
 * VLC_AddTarget: adds a target for playing.
 *****************************************************************************
193
 * This function adds psz_target to the playlist
194
 *****************************************************************************/
195

Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
196 197 198
int VLC_AddTarget( int i_object, char const *psz_target,
                   char const **ppsz_options, int i_options,
                   int i_mode, int i_pos )
199
{
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
200
    int i_err;
201
    LIBVLC_PLAYLIST_FUNC;
202
    i_err = playlist_AddExt( p_playlist, psz_target,
203
                             NULL,  i_mode, i_pos, -1,
204
                             ppsz_options, i_options, true, false );
205
    LIBVLC_PLAYLIST_FUNC_END;
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
206
    return i_err;
207 208 209
}

/*****************************************************************************
210
 * VLC_Play: play the playlist
211
 *****************************************************************************/
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
212
int VLC_Play( int i_object )
213
{
214
    LIBVLC_PLAYLIST_FUNC;
215
    playlist_Play( p_playlist );
216
    LIBVLC_PLAYLIST_FUNC_END;
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
217
    return VLC_SUCCESS;
218 219
}

220
/*****************************************************************************
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
221
 * VLC_Pause: toggle pause
222
 *****************************************************************************/
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
223
int VLC_Pause( int i_object )
224
{
225
    LIBVLC_PLAYLIST_FUNC;
226
    playlist_Pause( p_playlist );
227
    LIBVLC_PLAYLIST_FUNC_END;
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
228
    return VLC_SUCCESS;
229 230 231
}

/*****************************************************************************
232
 * VLC_Stop: stop playback
233
 *****************************************************************************/
Sam Hocevar's avatar
Sam Hocevar committed
234
int VLC_Stop( int i_object )
235
{
236
    LIBVLC_PLAYLIST_FUNC;
237
    playlist_Stop( p_playlist );
238
    LIBVLC_PLAYLIST_FUNC_END;
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
239
    return VLC_SUCCESS;
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
240
}
Clément Stenac's avatar
Clément Stenac committed
241

Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
242 243 244
/*****************************************************************************
 * VLC_IsPlaying: Query for Playlist Status
 *****************************************************************************/
245
bool VLC_IsPlaying( int i_object )
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
246
{
247
    bool   b_playing;
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
248

249
    LIBVLC_PLAYLIST_FUNC;
250
    if( p_playlist->p_input )
251
    {
252
        vlc_value_t  val;
253
        var_Get( p_playlist->p_input, "state", &val );
254 255 256 257
        b_playing = ( val.i_int == PLAYING_S );
    }
    else
    {
258
        b_playing = playlist_IsPlaying( p_playlist );
259
    }
260
    LIBVLC_PLAYLIST_FUNC_END;
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
    return b_playing;
}

/**
 * Get the current position in a input
 *
 * Return the current position as a float
 * \note For some inputs, this will be unknown.
 *
 * \param i_object a vlc object id
 * \return a float in the range of 0.0 - 1.0
 */
float VLC_PositionGet( int i_object )
{
    input_thread_t *p_input;
    vlc_value_t val;
Clément Stenac's avatar
Clément Stenac committed
277
    LIBVLC_FUNC;
278

279
    p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
280 281 282

    if( !p_input )
    {
283
        if( i_object ) vlc_object_release( p_libvlc );
284 285 286 287 288 289
        return VLC_ENOOBJ;
    }

    var_Get( p_input, "position", &val );
    vlc_object_release( p_input );

Clément Stenac's avatar
Clément Stenac committed
290
    LIBVLC_FUNC_END;
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
    return val.f_float;
}

/**
 * Set the current position in a input
 *
 * Set the current position in a input and then return
 * the current position as a float.
 * \note For some inputs, this will be unknown.
 *
 * \param i_object a vlc object id
 * \param i_position a float in the range of 0.0 - 1.0
 * \return a float in the range of 0.0 - 1.0
 */
float VLC_PositionSet( int i_object, float i_position )
{
    input_thread_t *p_input;
    vlc_value_t val;
309
    libvlc_int_t *p_libvlc = vlc_current_object( i_object );
310 311

    /* Check that the handle is valid */
312
    if( !p_libvlc )
313 314 315 316
    {
        return VLC_ENOOBJ;
    }

317
    p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
318

319 320
    if( !p_input )
    {
321
        if( i_object ) vlc_object_release( p_libvlc );
322 323 324 325 326 327 328 329
        return VLC_ENOOBJ;
    }

    val.f_float = i_position;
    var_Set( p_input, "position", val );
    var_Get( p_input, "position", &val );
    vlc_object_release( p_input );

330
    if( i_object ) vlc_object_release( p_libvlc );
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
    return val.f_float;
}

/**
 * Get the current position in a input
 *
 * Return the current position in seconds from the start.
 * \note For some inputs, this will be unknown.
 *
 * \param i_object a vlc object id
 * \return the offset from 0:00 in seconds
 */
int VLC_TimeGet( int i_object )
{
    input_thread_t *p_input;
    vlc_value_t val;
347
    libvlc_int_t *p_libvlc = vlc_current_object( i_object );
348 349

    /* Check that the handle is valid */
350
    if( !p_libvlc )
351 352 353 354
    {
        return VLC_ENOOBJ;
    }

355
    p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
356 357 358

    if( !p_input )
    {
359
        if( i_object ) vlc_object_release( p_libvlc );
360 361 362 363 364 365
        return VLC_ENOOBJ;
    }

    var_Get( p_input, "time", &val );
    vlc_object_release( p_input );

366
    if( i_object ) vlc_object_release( p_libvlc );
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
    return val.i_time  / 1000000;
}

/**
 * Seek to a position in the current input
 *
 * Seek i_seconds in the current input. If b_relative is set,
 * then the seek will be relative to the current position, otherwise
 * it will seek to i_seconds from the beginning of the input.
 * \note For some inputs, this will be unknown.
 *
 * \param i_object a vlc object id
 * \param i_seconds seconds from current position or from beginning of input
 * \param b_relative seek relative from current position
 * \return VLC_SUCCESS on success
 */
383
int VLC_TimeSet( int i_object, int i_seconds, bool b_relative )
384 385 386
{
    input_thread_t *p_input;
    vlc_value_t val;
387
    libvlc_int_t *p_libvlc = vlc_current_object( i_object );
388 389

    /* Check that the handle is valid */
390
    if( !p_libvlc )
391 392 393 394
    {
        return VLC_ENOOBJ;
    }

395
    p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
396 397 398

    if( !p_input )
    {
399
        if( i_object ) vlc_object_release( p_libvlc );
400 401 402 403 404
        return VLC_ENOOBJ;
    }

    if( b_relative )
    {
405 406
        val.i_time = i_seconds;
        val.i_time = val.i_time * 1000000L;
407 408 409 410
        var_Set( p_input, "time-offset", val );
    }
    else
    {
411 412
        val.i_time = i_seconds;
        val.i_time = val.i_time * 1000000L;
413 414 415 416
        var_Set( p_input, "time", val );
    }
    vlc_object_release( p_input );

417
    if( i_object ) vlc_object_release( p_libvlc );
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
    return VLC_SUCCESS;
}

/**
 * Get the total length of a input
 *
 * Return the total length in seconds from the current input.
 * \note For some inputs, this will be unknown.
 *
 * \param i_object a vlc object id
 * \return the length in seconds
 */
int VLC_LengthGet( int i_object )
{
    input_thread_t *p_input;
    vlc_value_t val;
434
    libvlc_int_t *p_libvlc = vlc_current_object( i_object );
435 436

    /* Check that the handle is valid */
437
    if( !p_libvlc )
438 439 440 441
    {
        return VLC_ENOOBJ;
    }

442
    p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
443 444 445

    if( !p_input )
    {
446
        if( i_object ) vlc_object_release( p_libvlc );
447 448 449 450 451 452
        return VLC_ENOOBJ;
    }

    var_Get( p_input, "length", &val );
    vlc_object_release( p_input );

453
    if( i_object ) vlc_object_release( p_libvlc );
454
    return val.i_time  / 1000000L;
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
}

/**
 * Play the input faster than realtime
 *
 * 2x, 4x, 8x faster than realtime
 * \note For some inputs, this will be impossible.
 *
 * \param i_object a vlc object id
 * \return the current speedrate
 */
float VLC_SpeedFaster( int i_object )
{
    input_thread_t *p_input;
    vlc_value_t val;
470
    libvlc_int_t *p_libvlc = vlc_current_object( i_object );
471 472

    /* Check that the handle is valid */
473
    if( !p_libvlc )
474 475 476 477
    {
        return VLC_ENOOBJ;
    }

478
    p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
479 480 481

    if( !p_input )
    {
482
        if( i_object ) vlc_object_release( p_libvlc );
483 484 485
        return VLC_ENOOBJ;
    }

486
    val.b_bool = true;
487 488 489 490
    var_Set( p_input, "rate-faster", val );
    var_Get( p_input, "rate", &val );
    vlc_object_release( p_input );

491
    if( i_object ) vlc_object_release( p_libvlc );
492
    return val.f_float / INPUT_RATE_DEFAULT;
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
}

/**
 * Play the input slower than realtime
 *
 * 1/2x, 1/4x, 1/8x slower than realtime
 * \note For some inputs, this will be impossible.
 *
 * \param i_object a vlc object id
 * \return the current speedrate
 */
float VLC_SpeedSlower( int i_object )
{
    input_thread_t *p_input;
    vlc_value_t val;
508
    libvlc_int_t *p_libvlc = vlc_current_object( i_object );
509 510

    /* Check that the handle is valid */
511
    if( !p_libvlc )
512 513 514 515
    {
        return VLC_ENOOBJ;
    }

516
    p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
517 518 519

    if( !p_input )
    {
520
        if( i_object ) vlc_object_release( p_libvlc );
521 522 523
        return VLC_ENOOBJ;
    }

524
    val.b_bool = true;
525 526 527 528
    var_Set( p_input, "rate-slower", val );
    var_Get( p_input, "rate", &val );
    vlc_object_release( p_input );

529
    if( i_object ) vlc_object_release( p_libvlc );
530
    return val.f_float / INPUT_RATE_DEFAULT;
531 532 533 534 535 536 537 538 539 540 541 542 543
}

/**
 * Return the current playlist item
 *
 * Returns the index of the playlistitem that is currently selected for play.
 * This is valid even if nothing is currently playing.
 *
 * \param i_object a vlc object id
 * \return the current index
 */
int VLC_PlaylistIndex( int i_object )
{
544
    (void)i_object;
545 546
    printf( "This function is deprecated and should not be used anymore" );
    return -1;
547
}
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
548

549
/**
Clément Stenac's avatar
Clément Stenac committed
550
 * Total number of items in the playlist
551 552 553 554 555 556 557
 *
 * \param i_object a vlc object id
 * \return amount of playlist items
 */
int VLC_PlaylistNumberOfItems( int i_object )
{
    int i_size;
Clément Stenac's avatar
Clément Stenac committed
558
    LIBVLC_PLAYLIST_FUNC;
559
    i_size = p_playlist->items.i_size;
Clément Stenac's avatar
Clément Stenac committed
560
    LIBVLC_PLAYLIST_FUNC_END;
561 562 563 564
    return i_size;
}

/**
Clément Stenac's avatar
Clément Stenac committed
565
 * Go to next playlist item
566 567 568 569 570
 * \param i_object a vlc object id
 * \return VLC_SUCCESS on success
 */
int VLC_PlaylistNext( int i_object )
{
Clément Stenac's avatar
Clément Stenac committed
571
    LIBVLC_PLAYLIST_FUNC;
572
    playlist_Next( p_playlist );
Clément Stenac's avatar
Clément Stenac committed
573
    LIBVLC_PLAYLIST_FUNC_END;
574 575 576 577
    return VLC_SUCCESS;
}

/**
Clément Stenac's avatar
Clément Stenac committed
578
 * Go to previous playlist item
579 580 581 582 583
 * \param i_object a vlc object id
 * \return VLC_SUCCESS on success
 */
int VLC_PlaylistPrev( int i_object )
{
Clément Stenac's avatar
Clément Stenac committed
584
    LIBVLC_PLAYLIST_FUNC;
585
    playlist_Prev( p_playlist );
Clément Stenac's avatar
Clément Stenac committed
586
    LIBVLC_PLAYLIST_FUNC_END;
587
    return VLC_SUCCESS;
588 589
}

Clément Stenac's avatar
Clément Stenac committed
590 591 592
/**
 * Empty the playlist
 */
593
int VLC_PlaylistClear( int i_object )
594
{
Clément Stenac's avatar
Clément Stenac committed
595
    LIBVLC_PLAYLIST_FUNC;
596
    playlist_Clear( p_playlist, true );
Clément Stenac's avatar
Clément Stenac committed
597
    LIBVLC_PLAYLIST_FUNC_END;
598
    return VLC_SUCCESS;
599 600
}

601 602 603 604 605 606 607 608 609
/**
 * Change the volume
 *
 * \param i_object a vlc object id
 * \param i_volume something in a range from 0-200
 * \return the new volume (range 0-200 %)
 */
int VLC_VolumeSet( int i_object, int i_volume )
{
610
    audio_volume_t i_vol = 0;
Clément Stenac's avatar
Clément Stenac committed
611
    LIBVLC_FUNC;
612

613
    if( i_volume >= 0 && i_volume <= 200 )
614 615
    {
        i_vol = i_volume * AOUT_VOLUME_MAX / 200;
616
        aout_VolumeSet( p_libvlc, i_vol );
617
    }
Clément Stenac's avatar
Clément Stenac committed
618
    LIBVLC_FUNC_END;
619 620 621 622 623 624 625 626 627 628 629 630 631 632
    return i_vol * 200 / AOUT_VOLUME_MAX;
}

/**
 * Get the current volume
 *
 * Retrieve the current volume.
 *
 * \param i_object a vlc object id
 * \return the current volume (range 0-200 %)
 */
int VLC_VolumeGet( int i_object )
{
    audio_volume_t i_volume;
Clément Stenac's avatar
Clément Stenac committed
633
    LIBVLC_FUNC;
634
    aout_VolumeGet( p_libvlc, &i_volume );
Clément Stenac's avatar
Clément Stenac committed
635
    LIBVLC_FUNC_END;
636 637 638 639 640 641 642 643 644 645 646
    return i_volume*200/AOUT_VOLUME_MAX;
}

/**
 * Mute/Unmute the volume
 *
 * \param i_object a vlc object id
 * \return VLC_SUCCESS on success
 */
int VLC_VolumeMute( int i_object )
{
Clément Stenac's avatar
Clément Stenac committed
647
    LIBVLC_FUNC;
648
    aout_VolumeMute( p_libvlc, NULL );
Clément Stenac's avatar
Clément Stenac committed
649
    LIBVLC_FUNC_END;
650 651 652
    return VLC_SUCCESS;
}

653
/*****************************************************************************
Sam Hocevar's avatar
Sam Hocevar committed
654
 * VLC_FullScreen: toggle fullscreen mode
655
 *****************************************************************************/
Sam Hocevar's avatar
Sam Hocevar committed
656
int VLC_FullScreen( int i_object )
657 658
{
    vout_thread_t *p_vout;
Clément Stenac's avatar
Clément Stenac committed
659
    LIBVLC_FUNC;
660
    p_vout = vlc_object_find( p_libvlc, VLC_OBJECT_VOUT, FIND_CHILD );
661 662 663

    if( !p_vout )
    {
664
        if( i_object ) vlc_object_release( p_libvlc );
665
        return VLC_ENOOBJ;
666 667 668 669
    }

    p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
    vlc_object_release( p_vout );
Clément Stenac's avatar
Clément Stenac committed
670
    LIBVLC_FUNC_END;
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
671 672
    return VLC_SUCCESS;
}