1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <rtl/ustring.h>
12 #include "SymbolLoader.hxx"
13 #include "Instance.hxx"
17 struct libvlc_instance_t
;
27 libvlc_media_t
* ( *libvlc_media_new_path
) ( libvlc_instance_t
*p_instance
, const char *path
);
28 libvlc_media_t
* ( *libvlc_media_new_location
) (libvlc_instance_t
*p_instance
, const char *psz_mrl
);
29 void ( *libvlc_media_release
) ( libvlc_media_t
*p_md
);
30 void ( *libvlc_media_retain
) ( libvlc_media_t
*p_md
);
31 libvlc_time_t ( *libvlc_media_get_duration
) ( libvlc_media_t
*p_md
);
32 void ( *libvlc_media_parse
) ( libvlc_media_t
*p_md
);
33 int ( *libvlc_media_is_parsed
) ( libvlc_media_t
*p_md
);
34 char* ( *libvlc_media_get_mrl
)(libvlc_media_t
*p_md
);
37 libvlc_media_t
* InitMedia( const rtl::OUString
& url
, Instance
& instance
)
40 url
.convertToString(&dest
, RTL_TEXTENCODING_UTF8
, 0);
42 return libvlc_media_new_location(instance
, dest
.getStr());
46 bool Media::LoadSymbols()
48 ApiMap VLC_MEDIA_API
[] =
50 SYM_MAP( libvlc_media_new_path
),
51 SYM_MAP( libvlc_media_release
),
52 SYM_MAP( libvlc_media_retain
),
53 SYM_MAP( libvlc_media_get_duration
),
54 SYM_MAP( libvlc_media_parse
),
55 SYM_MAP( libvlc_media_is_parsed
),
56 SYM_MAP( libvlc_media_get_mrl
),
57 SYM_MAP( libvlc_media_new_location
)
60 return InitApiMap( VLC_MEDIA_API
);
63 Media::Media( const rtl::OUString
& url
, Instance
& instance
)
64 : mMedia( InitMedia( url
, instance
) )
72 Media::Media( const Media
& other
)
77 Media
& Media::operator=( const Media
& other
)
79 libvlc_media_release( mMedia
);
80 mMedia
= other
.mMedia
;
82 libvlc_media_retain( mMedia
);
86 int Media::getDuration() const
88 if ( !libvlc_media_is_parsed( mMedia
) )
89 libvlc_media_parse( mMedia
);
91 const int duration
= libvlc_media_get_duration( mMedia
);
94 SAL_WARN("avmedia", Common::LastErrorMessage());
97 else if (duration
== 0)
99 // A duration must be greater than 0
108 libvlc_media_release( mMedia
);
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */