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 <QObject>
9 #include <QIODevice>
10 #include <QFile>
11 #include <QUrl>
12 #include <QMutex>
13 
14 // mythtv
15 #include <mythobservable.h>
16 #include <musicmetadata.h>
17 
18 // mythmusic
19 
20 #include "pls.h"
21 
22 class Decoder;
23 
27 {
28  public:
29  explicit DecoderHandlerEvent(Type type)
30  : MythEvent(type) {}
31 
32  DecoderHandlerEvent(Type type, QString *e)
33  : MythEvent(type), m_msg(e) {}
34 
35  DecoderHandlerEvent(Type type, int available, int maxSize)
36  : MythEvent(type), m_available(available), m_maxSize(maxSize) {}
37 
38  DecoderHandlerEvent(Type type, const MusicMetadata &m);
39  ~DecoderHandlerEvent() override;
40 
41  QString *getMessage(void) const { return m_msg; }
42  MusicMetadata *getMetadata(void) const { return m_meta; }
43  void getBufferStatus(int *available, int *maxSize) const;
44 
45  MythEvent *clone(void) const override; // MythEvent
46 
47  static Type Ready;
48  static Type Meta;
49  static Type BufferStatus;
50  static Type OperationStart;
51  static Type OperationStop;
52  static Type Error;
53 
54  private:
55  QString *m_msg {nullptr};
56  MusicMetadata *m_meta {nullptr};
57  int m_available {0};
58  int m_maxSize {0};
59 };
60 
70 class DecoderHandler : public QObject, public MythObservable
71 {
72  Q_OBJECT
73 
74  public:
75  enum State
76  {
79  STOPPED
80  };
81 
82  DecoderHandler(void) = default;
83  ~DecoderHandler(void) override;
84 
85  Decoder *getDecoder(void) { return m_decoder; }
86 
87  void start(MusicMetadata *mdata);
88 
89  void stop(void);
90  void customEvent(QEvent *e) override; // QObject
91  bool done(void);
92  bool next(void);
93  void error(const QString &e);
94 
96 
97  QUrl& getUrl() { return m_url; }
98  void setUrl (const QUrl &url) { m_url = url; }
99 
100  protected:
101  void doOperationStart(const QString &name);
102  void doOperationStop(void);
103  void doConnectDecoder(const QUrl &url, const QString &format);
104  void doFailed(const QUrl &url, const QString &message);
105  void doStart(bool result);
106 
107  private:
108  void createPlaylist(const QUrl &url);
109  void createPlaylistForSingleFile(const QUrl &url);
110  void createPlaylistFromFile(const QUrl &url);
111  void createPlaylistFromRemoteUrl(const QUrl &url);
112 
114  int m_playlistPos {0};
116  Decoder *m_decoder {nullptr};
118  QUrl m_url;
119  bool m_op {false};
121 };
122 
123 #endif /* DECODERHANDLER_H_ */
DecoderHandlerEvent::Ready
static Type Ready
Definition: decoderhandler.h:47
DecoderHandlerEvent::BufferStatus
static Type BufferStatus
Definition: decoderhandler.h:49
e
QDomElement e
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1417
DecoderHandler::m_url
QUrl m_url
Definition: decoderhandler.h:118
DecoderHandler::State
State
Definition: decoderhandler.h:76
DecoderHandlerEvent::OperationStart
static Type OperationStart
Definition: decoderhandler.h:50
DecoderHandler::LOADING
@ LOADING
Definition: decoderhandler.h:78
DecoderHandler::doConnectDecoder
void doConnectDecoder(const QUrl &url, const QString &format)
Definition: decoderhandler.cpp:336
DecoderHandlerEvent::m_available
int m_available
Definition: decoderhandler.h:57
DecoderHandlerEvent::clone
MythEvent * clone(void) const override
Definition: decoderhandler.cpp:46
MythObservable
Superclass for making an object have a set of listeners.
Definition: mythobservable.h:12
DecoderHandler::getUrl
QUrl & getUrl()
Definition: decoderhandler.h:97
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:17
pls.h
DecoderHandlerEvent::DecoderHandlerEvent
DecoderHandlerEvent(Type type, int available, int maxSize)
Definition: decoderhandler.h:35
MusicMetadata
Definition: musicmetadata.h:81
DecoderHandlerEvent::Meta
static Type Meta
Definition: decoderhandler.h:48
DecoderHandlerEvent::~DecoderHandlerEvent
~DecoderHandlerEvent() override
Definition: decoderhandler.cpp:40
DecoderHandler::m_playlistPos
int m_playlistPos
Definition: decoderhandler.h:114
DecoderHandler::next
bool next(void)
Definition: decoderhandler.cpp:138
DecoderHandlerEvent::m_meta
MusicMetadata * m_meta
Definition: decoderhandler.h:56
DecoderHandler::DecoderHandler
DecoderHandler(void)=default
DecoderHandlerEvent::m_msg
QString * m_msg
Definition: decoderhandler.h:55
DecoderHandler::error
void error(const QString &e)
Definition: decoderhandler.cpp:117
DecoderHandler
Class for starting stream decoding.
Definition: decoderhandler.h:71
DecoderHandlerEvent
Events sent by the DecoderHandler and it's helper classes.
Definition: decoderhandler.h:27
Decoder
Definition: decoder.h:66
DecoderHandlerEvent::getBufferStatus
void getBufferStatus(int *available, int *maxSize) const
Definition: decoderhandler.cpp:62
DecoderHandler::m_meta
MusicMetadata m_meta
Definition: decoderhandler.h:117
DecoderHandler::createPlaylistForSingleFile
void createPlaylistForSingleFile(const QUrl &url)
Definition: decoderhandler.cpp:283
DecoderHandlerEvent::getMessage
QString * getMessage(void) const
Definition: decoderhandler.h:41
DecoderHandler::createPlaylist
void createPlaylist(const QUrl &url)
Definition: decoderhandler.cpp:263
DecoderHandler::m_decoder
Decoder * m_decoder
Definition: decoderhandler.h:116
DecoderHandler::getDecoder
Decoder * getDecoder(void)
Definition: decoderhandler.h:85
PlayListFile
Class for containing the info of a pls or m3u file.
Definition: pls.h:42
uint
unsigned int uint
Definition: compat.h:140
DecoderHandler::customEvent
void customEvent(QEvent *e) override
Definition: decoderhandler.cpp:206
DecoderHandler::m_state
int m_state
Definition: decoderhandler.h:113
DecoderHandlerEvent::DecoderHandlerEvent
DecoderHandlerEvent(Type type)
Definition: decoderhandler.h:29
DecoderHandler::start
void start(MusicMetadata *mdata)
Definition: decoderhandler.cpp:75
DecoderHandlerEvent::Error
static Type Error
Definition: decoderhandler.h:52
DecoderHandler::doOperationStop
void doOperationStop(void)
Definition: decoderhandler.cpp:374
DecoderHandler::done
bool done(void)
Definition: decoderhandler.cpp:124
DecoderHandler::m_op
bool m_op
Definition: decoderhandler.h:119
DecoderHandler::STOPPED
@ STOPPED
Definition: decoderhandler.h:79
DecoderHandler::~DecoderHandler
~DecoderHandler(void) override
Definition: decoderhandler.cpp:70
DecoderHandlerEvent::OperationStop
static Type OperationStop
Definition: decoderhandler.h:51
DecoderHandler::doStart
void doStart(bool result)
Definition: decoderhandler.cpp:92
DecoderHandler::doFailed
void doFailed(const QUrl &url, const QString &message)
Definition: decoderhandler.cpp:359
DecoderHandler::m_redirects
uint m_redirects
Definition: decoderhandler.h:120
DecoderHandler::getMetadata
MusicMetadata & getMetadata()
Definition: decoderhandler.h:95
DecoderHandler::setUrl
void setUrl(const QUrl &url)
Definition: decoderhandler.h:98
DecoderHandlerEvent::getMetadata
MusicMetadata * getMetadata(void) const
Definition: decoderhandler.h:42
DecoderHandlerEvent::DecoderHandlerEvent
DecoderHandlerEvent(Type type, QString *e)
Definition: decoderhandler.h:32
DecoderHandler::createPlaylistFromRemoteUrl
void createPlaylistFromRemoteUrl(const QUrl &url)
Definition: decoderhandler.cpp:306
DecoderHandlerEvent::m_maxSize
int m_maxSize
Definition: decoderhandler.h:58
DecoderHandler::ACTIVE
@ ACTIVE
Definition: decoderhandler.h:77
DecoderHandler::stop
void stop(void)
Definition: decoderhandler.cpp:176
DecoderHandler::m_playlist
PlayListFile m_playlist
Definition: decoderhandler.h:115
DecoderHandler::doOperationStart
void doOperationStart(const QString &name)
Definition: decoderhandler.cpp:367
DecoderHandler::createPlaylistFromFile
void createPlaylistFromFile(const QUrl &url)
Definition: decoderhandler.cpp:297
musicmetadata.h
mythobservable.h