]> git.sesse.net Git - vlc/blob - bindings/libvlcpp/src/media.cpp
9e166528b6839cb41802d14196da006ecc565608
[vlc] / bindings / libvlcpp / src / media.cpp
1 /*****************************************************************************
2  * media.cpp: Represent a media
3  *****************************************************************************
4  * Copyright (C) 2010 the VideoLAN team
5  * $Id$
6  *
7  * Authors: RĂ©mi Duraffort <ivoire@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #include "media.hpp"
25 #include "exception.hpp"
26
27 using namespace libvlc;
28
29 Media::Media( libVLC &libvlcInstance, const char *psz_mrl )
30 {
31     m_media = libvlc_media_new( libvlcInstance.m_instance, psz_mrl );
32     if( !m_media )
33         throw libvlc_errmsg();
34 }
35
36 Media::Media( const Media& original )
37 {
38     m_media = libvlc_media_duplicate( original.m_media );
39 }
40
41 Media::~Media()
42 {
43     libvlc_media_release( m_media );
44 }
45
46 void Media::addOption( const char *ppsz_options )
47 {
48     libvlc_media_add_option( m_media, ppsz_options );
49 }
50
51 void Media::addOption( const char *ppsz_options, libvlc_media_option_t flag )
52 {
53     libvlc_media_add_option_flag( m_media, ppsz_options, flag );
54 }
55
56 int64_t Media::duration()
57 {
58     return libvlc_media_get_duration( m_media );
59 }
60
61 int Media::isPreparsed()
62 {
63     return libvlc_media_is_preparsed( m_media );
64 }
65
66 char *Media::mrl()
67 {
68     return libvlc_media_get_mrl( m_media );
69 }
70
71 char *Media::meta( libvlc_meta_t e_meta )
72 {
73     return libvlc_media_get_meta( m_media, e_meta );
74 }
75
76 void Media::setMeta( libvlc_meta_t e_meta, const char *psz_value )
77 {
78     libvlc_media_set_meta( m_media, e_meta, psz_value );
79 }
80
81 int Media::saveMeta()
82 {
83     return libvlc_media_save_meta( m_media );
84 }
85
86 libvlc_state_t Media::state()
87 {
88     return libvlc_media_get_state( m_media );
89 }
90
91 void Media::setUserData( void *p_user_data )
92 {
93     libvlc_media_set_user_data( m_media, p_user_data );
94 }
95
96 void *Media::userData()
97 {
98     return libvlc_media_get_user_data( m_media );
99 }
100