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 
21 class Decoder;
22 
26 {
27  public:
28  explicit DecoderHandlerEvent(Type type)
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 
37  DecoderHandlerEvent(Type type, const MusicMetadata &m);
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:
55  DecoderHandlerEvent(const DecoderHandlerEvent &other) = default;
56  DecoderHandlerEvent &operator=(const DecoderHandlerEvent &other) = default;
57  public:
60 
61  private:
62  QString *m_msg {nullptr};
63  MusicMetadata *m_meta {nullptr};
64  int m_available {0};
65  int m_maxSize {0};
66 };
67 
77 class DecoderHandler : public QObject, public MythObservable
78 {
79  Q_OBJECT
80 
81  public:
82  enum State
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 
121  int m_playlistPos {0};
123  Decoder *m_decoder {nullptr};
125  QUrl m_url;
126  bool m_op {false};
128 };
129 
130 #endif /* DECODERHANDLER_H_ */
DecoderHandler::m_url
QUrl m_url
Definition: decoderhandler.h:125
DecoderHandler::State
State
Definition: decoderhandler.h:82
DecoderHandler::LOADING
@ LOADING
Definition: decoderhandler.h:85
DecoderHandler::doConnectDecoder
void doConnectDecoder(const QUrl &url, const QString &format)
Definition: decoderhandler.cpp:332
DecoderHandlerEvent::m_available
int m_available
Definition: decoderhandler.h:64
DecoderHandlerEvent::clone
MythEvent * clone(void) const override
Definition: decoderhandler.cpp:45
MythObservable
Superclass for making an object have a set of listeners.
Definition: mythobservable.h:11
DecoderHandler::getUrl
QUrl & getUrl()
Definition: decoderhandler.h:104
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:34
MusicMetadata
Definition: musicmetadata.h:80
DecoderHandlerEvent::~DecoderHandlerEvent
~DecoderHandlerEvent() override
Definition: decoderhandler.cpp:39
DecoderHandler::m_playlistPos
int m_playlistPos
Definition: decoderhandler.h:121
DecoderHandler::next
bool next(void)
Definition: decoderhandler.cpp:137
DecoderHandlerEvent::m_meta
MusicMetadata * m_meta
Definition: decoderhandler.h:63
DecoderHandler::DecoderHandler
DecoderHandler(void)=default
DecoderHandlerEvent::m_msg
QString * m_msg
Definition: decoderhandler.h:62
DecoderHandler::error
void error(const QString &e)
Definition: decoderhandler.cpp:116
DecoderHandler
Class for starting stream decoding.
Definition: decoderhandler.h:77
DecoderHandlerEvent
Events sent by the DecoderHandler and it's helper classes.
Definition: decoderhandler.h:25
Decoder
Definition: decoder.h:70
DecoderHandlerEvent::getBufferStatus
void getBufferStatus(int *available, int *maxSize) const
Definition: decoderhandler.cpp:61
DecoderHandlerEvent::kOperationStart
static const Type kOperationStart
Definition: decoderhandler.h:49
DecoderHandler::m_meta
MusicMetadata m_meta
Definition: decoderhandler.h:124
DecoderHandler::createPlaylistForSingleFile
void createPlaylistForSingleFile(const QUrl &url)
Definition: decoderhandler.cpp:279
DecoderHandlerEvent::getMessage
QString * getMessage(void) const
Definition: decoderhandler.h:40
DecoderHandler::createPlaylist
void createPlaylist(const QUrl &url)
Definition: decoderhandler.cpp:259
DecoderHandler::m_decoder
Decoder * m_decoder
Definition: decoderhandler.h:123
DecoderHandlerEvent::operator=
DecoderHandlerEvent & operator=(const DecoderHandlerEvent &other)=default
DecoderHandler::getDecoder
Decoder * getDecoder(void)
Definition: decoderhandler.h:92
PlayListFile
Class for containing the info of a pls or m3u file.
Definition: pls.h:41
uint
unsigned int uint
Definition: compat.h:81
DecoderHandler::customEvent
void customEvent(QEvent *e) override
Definition: decoderhandler.cpp:205
DecoderHandlerEvent::kOperationStop
static const Type kOperationStop
Definition: decoderhandler.h:50
DecoderHandlerEvent::kMeta
static const Type kMeta
Definition: decoderhandler.h:47
DecoderHandler::m_state
int m_state
Definition: decoderhandler.h:120
DecoderHandlerEvent::DecoderHandlerEvent
DecoderHandlerEvent(Type type)
Definition: decoderhandler.h:28
DecoderHandler::start
void start(MusicMetadata *mdata)
Definition: decoderhandler.cpp:74
DecoderHandler::doOperationStop
void doOperationStop(void)
Definition: decoderhandler.cpp:371
DecoderHandler::done
bool done(void)
Definition: decoderhandler.cpp:123
DecoderHandler::m_op
bool m_op
Definition: decoderhandler.h:126
DecoderHandler::STOPPED
@ STOPPED
Definition: decoderhandler.h:86
DecoderHandler::~DecoderHandler
~DecoderHandler(void) override
Definition: decoderhandler.cpp:69
DecoderHandler::doStart
void doStart(bool result)
Definition: decoderhandler.cpp:91
DecoderHandler::doFailed
void doFailed(const QUrl &url, const QString &message)
Definition: decoderhandler.cpp:356
DecoderHandlerEvent::kError
static const Type kError
Definition: decoderhandler.h:51
DecoderHandler::m_redirects
uint m_redirects
Definition: decoderhandler.h:127
DecoderHandler::getMetadata
MusicMetadata & getMetadata()
Definition: decoderhandler.h:102
DecoderHandlerEvent::kBufferStatus
static const Type kBufferStatus
Definition: decoderhandler.h:48
DecoderHandlerEvent::kReady
static const Type kReady
Definition: decoderhandler.h:46
DecoderHandler::setUrl
void setUrl(const QUrl &url)
Definition: decoderhandler.h:105
DecoderHandlerEvent::getMetadata
MusicMetadata * getMetadata(void) const
Definition: decoderhandler.h:41
DecoderHandlerEvent::DecoderHandlerEvent
DecoderHandlerEvent(Type type, QString *e)
Definition: decoderhandler.h:31
DecoderHandler::createPlaylistFromRemoteUrl
void createPlaylistFromRemoteUrl(const QUrl &url)
Definition: decoderhandler.cpp:302
DecoderHandlerEvent::m_maxSize
int m_maxSize
Definition: decoderhandler.h:65
DecoderHandler::ACTIVE
@ ACTIVE
Definition: decoderhandler.h:84
DecoderHandler::stop
void stop(void)
Definition: decoderhandler.cpp:175
DecoderHandler::m_playlist
PlayListFile m_playlist
Definition: decoderhandler.h:122
DecoderHandler::doOperationStart
void doOperationStart(const QString &name)
Definition: decoderhandler.cpp:364
DecoderHandler::createPlaylistFromFile
void createPlaylistFromFile(const QUrl &url)
Definition: decoderhandler.cpp:293
musicmetadata.h
mythobservable.h