1 /*****************************************************************************
2 * media.cpp: Represent a media
3 *****************************************************************************
4 * Copyright (C) 2010 the VideoLAN team
7 * Authors: RĂ©mi Duraffort <ivoire@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
25 #include "exception.hpp"
27 using namespace libvlc;
29 Media::Media( libVLC &libvlcInstance, const char *psz_mrl )
31 m_media = libvlc_media_new( libvlcInstance.m_instance, psz_mrl );
33 throw libvlc_errmsg();
36 Media::Media( const Media& original )
38 m_media = libvlc_media_duplicate( original.m_media );
43 libvlc_media_release( m_media );
46 void Media::addOption( const char *ppsz_options )
48 libvlc_media_add_option( m_media, ppsz_options );
51 void Media::addOption( const char *ppsz_options, libvlc_media_option_t flag )
53 libvlc_media_add_option_flag( m_media, ppsz_options, flag );
56 int64_t Media::duration()
58 return libvlc_media_get_duration( m_media );
61 int Media::isPreparsed()
63 return libvlc_media_is_preparsed( m_media );
68 return libvlc_media_get_mrl( m_media );
71 char *Media::meta( libvlc_meta_t e_meta )
73 return libvlc_media_get_meta( m_media, e_meta );
76 void Media::setMeta( libvlc_meta_t e_meta, const char *psz_value )
78 libvlc_media_set_meta( m_media, e_meta, psz_value );
83 return libvlc_media_save_meta( m_media );
86 libvlc_state_t Media::state()
88 return libvlc_media_get_state( m_media );
91 void Media::setUserData( void *p_user_data )
93 libvlc_media_set_user_data( m_media, p_user_data );
96 void *Media::userData()
98 return libvlc_media_get_user_data( m_media );