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  // No implicit copying.
55  protected:
56  DecoderHandlerEvent(const DecoderHandlerEvent &other) = default;
57  DecoderHandlerEvent &operator=(const DecoderHandlerEvent &other) = default;
58  public:
61 
62  private:
63  QString *m_msg {nullptr};
64  MusicMetadata *m_meta {nullptr};
65  int m_available {0};
66  int m_maxSize {0};
67 };
68 
78 class DecoderHandler : public QObject, public MythObservable
79 {
80  Q_OBJECT
81 
82  public:
83  enum State
84  {
88  };
89 
90  DecoderHandler(void) = default;
91  ~DecoderHandler(void) override;
92 
93  Decoder *getDecoder(void) { return m_decoder; }
94 
95  void start(MusicMetadata *mdata);
96 
97  void stop(void);
98  void customEvent(QEvent *e) override; // QObject
99  bool done(void);
100  bool next(void);
101  void error(const QString &e);
102 
104 
105  QUrl& getUrl() { return m_url; }
106  void setUrl (const QUrl &url) { m_url = url; }
107 
108  protected:
109  void doOperationStart(const QString &name);
110  void doOperationStop(void);
111  void doConnectDecoder(const QUrl &url, const QString &format);
112  void doFailed(const QUrl &url, const QString &message);
113  void doStart(bool result);
114 
115  private:
116  void createPlaylist(const QUrl &url);
117  void createPlaylistForSingleFile(const QUrl &url);
118  void createPlaylistFromFile(const QUrl &url);
119  void createPlaylistFromRemoteUrl(const QUrl &url);
120 
122  int m_playlistPos {0};
124  Decoder *m_decoder {nullptr};
126  QUrl m_url;
127  bool m_op {false};
129 };
130 
131 #endif /* DECODERHANDLER_H_ */
DecoderHandlerEvent::Ready
static Type Ready
Definition: decoderhandler.h:47
DecoderHandlerEvent::BufferStatus
static Type BufferStatus
Definition: decoderhandler.h:49
DecoderHandler::m_url
QUrl m_url
Definition: decoderhandler.h:126
DecoderHandler::State
State
Definition: decoderhandler.h:83
DecoderHandlerEvent::OperationStart
static Type OperationStart
Definition: decoderhandler.h:50
DecoderHandler::LOADING
@ LOADING
Definition: decoderhandler.h:86
DecoderHandler::doConnectDecoder
void doConnectDecoder(const QUrl &url, const QString &format)
Definition: decoderhandler.cpp:337
DecoderHandlerEvent::m_available
int m_available
Definition: decoderhandler.h:65
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:11
DecoderHandler::getUrl
QUrl & getUrl()
Definition: decoderhandler.h:105
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
pls.h
DecoderHandlerEvent::DecoderHandlerEvent
DecoderHandlerEvent(Type type, int available, int maxSize)
Definition: decoderhandler.h:35
MusicMetadata
Definition: musicmetadata.h:80
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:122
DecoderHandler::next
bool next(void)
Definition: decoderhandler.cpp:138
DecoderHandlerEvent::m_meta
MusicMetadata * m_meta
Definition: decoderhandler.h:64
DecoderHandler::DecoderHandler
DecoderHandler(void)=default
DecoderHandlerEvent::m_msg
QString * m_msg
Definition: decoderhandler.h:63
DecoderHandler::error
void error(const QString &e)
Definition: decoderhandler.cpp:117
DecoderHandler
Class for starting stream decoding.
Definition: decoderhandler.h:78
DecoderHandlerEvent
Events sent by the DecoderHandler and it's helper classes.
Definition: decoderhandler.h:26
Decoder
Definition: decoder.h:70
DecoderHandlerEvent::getBufferStatus
void getBufferStatus(int *available, int *maxSize) const
Definition: decoderhandler.cpp:62
DecoderHandler::m_meta
MusicMetadata m_meta
Definition: decoderhandler.h:125
DecoderHandler::createPlaylistForSingleFile
void createPlaylistForSingleFile(const QUrl &url)
Definition: decoderhandler.cpp:284
DecoderHandlerEvent::getMessage
QString * getMessage(void) const
Definition: decoderhandler.h:41
DecoderHandler::createPlaylist
void createPlaylist(const QUrl &url)
Definition: decoderhandler.cpp:264
DecoderHandler::m_decoder
Decoder * m_decoder
Definition: decoderhandler.h:124
DecoderHandlerEvent::operator=
DecoderHandlerEvent & operator=(const DecoderHandlerEvent &other)=default
DecoderHandler::getDecoder
Decoder * getDecoder(void)
Definition: decoderhandler.h:93
PlayListFile
Class for containing the info of a pls or m3u file.
Definition: pls.h:41
uint
unsigned int uint
Definition: compat.h:144
DecoderHandler::customEvent
void customEvent(QEvent *e) override
Definition: decoderhandler.cpp:206
DecoderHandler::m_state
int m_state
Definition: decoderhandler.h:121
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:375
DecoderHandler::done
bool done(void)
Definition: decoderhandler.cpp:124
DecoderHandler::m_op
bool m_op
Definition: decoderhandler.h:127
DecoderHandler::STOPPED
@ STOPPED
Definition: decoderhandler.h:87
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:360
DecoderHandler::m_redirects
uint m_redirects
Definition: decoderhandler.h:128
DecoderHandler::getMetadata
MusicMetadata & getMetadata()
Definition: decoderhandler.h:103
DecoderHandler::setUrl
void setUrl(const QUrl &url)
Definition: decoderhandler.h:106
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:307
DecoderHandlerEvent::m_maxSize
int m_maxSize
Definition: decoderhandler.h:66
DecoderHandler::ACTIVE
@ ACTIVE
Definition: decoderhandler.h:85
DecoderHandler::stop
void stop(void)
Definition: decoderhandler.cpp:176
DecoderHandler::m_playlist
PlayListFile m_playlist
Definition: decoderhandler.h:123
DecoderHandler::doOperationStart
void doOperationStart(const QString &name)
Definition: decoderhandler.cpp:368
DecoderHandler::createPlaylistFromFile
void createPlaylistFromFile(const QUrl &url)
Definition: decoderhandler.cpp:298
musicmetadata.h
mythobservable.h