1/*
2 Copyright (C) 2011 Harald Sitter <sitter@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef PHONON_VLC_MEDIA_H
19#define PHONON_VLC_MEDIA_H
20
21#include <QtCore/QObject>
22#include <QtCore/QStringBuilder>
23#include <QtCore/QVariant>
24
25#include <vlc/libvlc.h>
26#include <vlc/libvlc_version.h>
27#if (LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0))
28// Bit of a work around. media.h requires picture
29#include <vlc/libvlc_picture.h>
30#endif
31#include <vlc/libvlc_media.h>
32
33#define INTPTR_PTR(x) reinterpret_cast<intptr_t>(x)
34#define INTPTR_FUNC(x) reinterpret_cast<intptr_t>(&x)
35
36namespace Phonon {
37namespace VLC {
38
39class Media : public QObject
40{
41 Q_OBJECT
42public:
43 explicit Media(const QByteArray &mrl, QObject *parent = nullptr);
44 ~Media();
45
46 inline libvlc_media_t *libvlc_media() const { return m_media; }
47 inline operator libvlc_media_t *() const { return m_media; }
48
49 inline void addOption(const QString &option, const QVariant &argument)
50 {
51 addOption(option: option % argument.toString());
52 }
53
54 inline void addOption(const QString &option, intptr_t functionPtr)
55 {
56 QString optionWithPtr = option;
57 optionWithPtr.append(s: QString::number(static_cast<qint64>(functionPtr)));
58 addOption(option: optionWithPtr);
59 }
60
61 void addOption(const QString &option);
62
63 QString meta(libvlc_meta_t meta);
64
65 void setCdTrack(int track);
66
67Q_SIGNALS:
68 void durationChanged(qint64 duration);
69 void metaDataChanged();
70
71private:
72 static void event_cb(const libvlc_event_t *event, void *opaque);
73
74 libvlc_media_t *m_media;
75 libvlc_state_t m_state;
76 QByteArray m_mrl;
77};
78
79} // namespace VLC
80} // namespace Phonon
81
82#endif // PHONON_VLC_MEDIA_H
83

source code of phonon-vlc/src/media.h