Downloads an HLS stream and displays the video in a window, playing any audio.
More...
#include <hls_player.h>
|
| void | play (const QString name, const QString url) |
| | Open the playlist in the background and start playing.
|
|
void | stop () |
| | Stop the stream, close the window and destroy this object.
|
|
| void | stateChanged (const QString &state) |
| | The state of the stream changed.
|
| void | frameReceived (const QImage &image) |
| | A frame was decoded on the worker thread (delivered queued to the GUI thread).
|
| void | workerState (const QString &state) |
| | The worker thread changed state (delivered queued to the GUI thread).
|
| void | audioReceived (const QByteArray &pcm, int sample_rate, int channels) |
| | A block of decoded audio arrived on the worker thread (delivered queued to the GUI thread).
|
|
|
bool | eventFilter (QObject *obj, QEvent *event) override |
| | Event filter to keep the image fitted to the dialog on resize.
|
|
|
void | showFrame (const QImage &image) |
| | Show a received frame.
|
|
void | sessionState (const QString &state) |
| | Update the status bar and report the new state.
|
|
void | noFrame () |
| | Blank the display when no frames are arriving.
|
|
void | playAudio (const QByteArray &pcm, int sample_rate, int channels) |
| | Play a block of decoded audio, (re)opening the audio output when the format changes.
|
|
|
void | receiveLoop (const std::string &url) |
| | Receive the stream until stop is requested, runs on the worker thread.
|
|
void | setLabelColour (const QString &colour) |
| | Set the colour of the stream label.
|
|
|
QPointer< QDialog > | m_dialog |
| | The player dialog.
|
|
QGraphicsScene * | m_scene = nullptr |
| | The scene.
|
|
QGraphicsView * | m_view = nullptr |
| | The view.
|
|
QGraphicsPixmapItem * | m_pixmap_item = nullptr |
| | The pixmap item, kept to avoid flicker.
|
|
QPixmap | m_pixmap |
| | The displayed image.
|
|
QLabel * | m_stream_label = nullptr |
| | Stream address label (without credentials or query).
|
|
QLabel * | m_format_label = nullptr |
| | Resolution label.
|
|
QLabel * | m_frame_label = nullptr |
| | Frame counter label.
|
|
QTimer | m_blank_timer |
| | No-frame blanking timer.
|
|
std::thread | m_thread |
| | The receive thread.
|
|
std::atomic< bool > | m_stop { false } |
| | Set to ask the receive thread to finish.
|
|
quint64 | m_frame_count = 0 |
| | Frames received.
|
|
QAudioSink * | m_audio_sink = nullptr |
| | The audio output, created when the first audio arrives.
|
|
QIODevice * | m_audio_io = nullptr |
| | The audio output device, owned by the sink. Null if audio cannot be played.
|
|
int | m_audio_rate = 0 |
| | Sample rate of the open audio output in Hz.
|
|
int | m_audio_channels = 0 |
| | Channel count of the open audio output.
|
|
QString | m_audio_info |
| | Audio description shown in the status bar, empty without audio.
|
|
QString | m_video_info |
| | Video resolution description shown in the status bar.
|
Downloads an HLS stream and displays the video in a window, playing any audio.
The stream is received on a worker thread using mediax::hls::HlsDepayloader. Audio is decoded to PCM by MediaX and played on the default audio output. The stream stops and the object is destroyed when the window is closed or stop() is called.
◆ HlsPlayer()
| HlsPlayer::HlsPlayer |
( |
QWidget * | parent = nullptr | ) |
|
|
explicit |
Construct a new HLS player and show the window.
- Parameters
-
| parent | the parent widget (the player closes when the parent closes) |
◆ audioReceived
| void HlsPlayer::audioReceived |
( |
const QByteArray & | pcm, |
|
|
int | sample_rate, |
|
|
int | channels ) |
|
signal |
A block of decoded audio arrived on the worker thread (delivered queued to the GUI thread).
- Parameters
-
| pcm | interleaved signed 16 bit samples in host byte order |
| sample_rate | sample rate in Hz |
| channels | number of interleaved channels |
◆ frameReceived
| void HlsPlayer::frameReceived |
( |
const QImage & | image | ) |
|
|
signal |
A frame was decoded on the worker thread (delivered queued to the GUI thread).
- Parameters
-
◆ play
| void HlsPlayer::play |
( |
const QString | name, |
|
|
const QString | url ) |
|
slot |
Open the playlist in the background and start playing.
- Parameters
-
| name | the stream name shown in the window title |
| url | the playlist URL, http(s)://host/path/stream.m3u8 |
◆ stateChanged
| void HlsPlayer::stateChanged |
( |
const QString & | state | ) |
|
|
signal |
The state of the stream changed.
- Parameters
-
| state | a short description, e.g. "Playing" or "Failed: HTTP error" |
◆ workerState
| void HlsPlayer::workerState |
( |
const QString & | state | ) |
|
|
signal |
The worker thread changed state (delivered queued to the GUI thread).
- Parameters
-
| state | a short description, e.g. "Playing" or "Failed: HTTP error" |
The documentation for this class was generated from the following files: