MythTV master
decoderhandler.h
Go to the documentation of this file.
1#ifndef DECODERHANDLER_H_
2#define DECODERHANDLER_H_
3
4// c++
5#include <iostream>
6
7// qt
8#include <QFile>
9#include <QIODevice>
10#include <QMutex>
11#include <QObject>
12#include <QUrl>
13
14// MythTV
17
18// mythmusic
19#include "pls.h"
20
21class Decoder;
22
26{
27 public:
29 : MythEvent(type) {}
30
31 DecoderHandlerEvent(Type type, QString *e)
32 : MythEvent(type), m_msg(e) {}
33
34 DecoderHandlerEvent(Type type, int available, int maxSize)
35 : MythEvent(type), m_available(available), m_maxSize(maxSize) {}
36
38 ~DecoderHandlerEvent() override;
39
40 QString *getMessage(void) const { return m_msg; }
41 MusicMetadata *getMetadata(void) const { return m_meta; }
42 void getBufferStatus(int *available, int *maxSize) const;
43
44 MythEvent *clone(void) const override; // MythEvent
45
46 static const Type kReady;
47 static const Type kMeta;
48 static const Type kBufferStatus;
49 static const Type kOperationStart;
50 static const Type kOperationStop;
51 static const Type kError;
52
53 // No implicit copying.
54 protected:
57 public:
60
61 private:
62 QString *m_msg {nullptr};
64 int m_available {0};
65 int m_maxSize {0};
66};
67
77class DecoderHandler : public QObject, public MythObservable
78{
79 Q_OBJECT
80
81 public:
82 enum State : std::uint8_t
83 {
87 };
88
89 DecoderHandler(void) = default;
90 ~DecoderHandler(void) override;
91
92 Decoder *getDecoder(void) { return m_decoder; }
93
94 void start(MusicMetadata *mdata);
95
96 void stop(void);
97 void customEvent(QEvent *e) override; // QObject
98 bool done(void);
99 bool next(void);
100 void error(const QString &e);
101
103
104 QUrl& getUrl() { return m_url; }
105 void setUrl (const QUrl &url) { m_url = url; }
106
107 protected:
108 void doOperationStart(const QString &name);
109 void doOperationStop(void);
110 void doConnectDecoder(const QUrl &url, const QString &format);
111 void doFailed(const QUrl &url, const QString &message);
112 void doStart(bool result);
113
114 private:
115 void createPlaylist(const QUrl &url);
116 void createPlaylistForSingleFile(const QUrl &url);
117 void createPlaylistFromFile(const QUrl &url);
118 void createPlaylistFromRemoteUrl(const QUrl &url);
119
123 Decoder *m_decoder {nullptr};
125 QUrl m_url;
126 bool m_op {false};
128};
129
130#endif /* DECODERHANDLER_H_ */
Events sent by the DecoderHandler and it's helper classes.
MusicMetadata * m_meta
QString * getMessage(void) const
DecoderHandlerEvent & operator=(const DecoderHandlerEvent &other)=default
DecoderHandlerEvent(Type type)
~DecoderHandlerEvent() override
DecoderHandlerEvent(DecoderHandlerEvent &&)=delete
static const Type kBufferStatus
DecoderHandlerEvent(const DecoderHandlerEvent &other)=default
static const Type kError
static const Type kOperationStart
void getBufferStatus(int *available, int *maxSize) const
DecoderHandlerEvent(Type type, int available, int maxSize)
static const Type kReady
DecoderHandlerEvent & operator=(DecoderHandlerEvent &&)=delete
static const Type kOperationStop
MusicMetadata * getMetadata(void) const
static const Type kMeta
MythEvent * clone(void) const override
DecoderHandlerEvent(Type type, QString *e)
Class for starting stream decoding.
void doOperationStop(void)
MusicMetadata m_meta
void createPlaylist(const QUrl &url)
~DecoderHandler(void) override
void doConnectDecoder(const QUrl &url, const QString &format)
void doFailed(const QUrl &url, const QString &message)
MusicMetadata & getMetadata()
void customEvent(QEvent *e) override
PlayListFile m_playlist
void start(MusicMetadata *mdata)
Decoder * getDecoder(void)
void error(const QString &e)
void doOperationStart(const QString &name)
void setUrl(const QUrl &url)
void doStart(bool result)
DecoderHandler(void)=default
void createPlaylistFromRemoteUrl(const QUrl &url)
void createPlaylistFromFile(const QUrl &url)
void createPlaylistForSingleFile(const QUrl &url)
Decoder * m_decoder
This class is used as a container for messages.
Definition: mythevent.h:17
Superclass for making an object have a set of listeners.
Class for containing the info of a pls or m3u file.
Definition: pls.h:42
unsigned int uint
Definition: compat.h:68