13#ifndef STREAMS_HLS_PLAYER_H
14#define STREAMS_HLS_PLAYER_H
19#include <QGraphicsPixmapItem>
20#include <QGraphicsScene>
21#include <QGraphicsView>
52 explicit HlsPlayer(QWidget *parent =
nullptr);
71 void play(
const QString name,
const QString url);
112 bool eventFilter(QObject *obj, QEvent *event)
override;
122 void playAudio(
const QByteArray &pcm,
int sample_rate,
int channels);
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).
int m_audio_rate
Sample rate of the open audio output in Hz.
Definition hls_player.h:159
void play(const QString name, const QString url)
Open the playlist in the background and start playing.
Definition hls_player.cpp:121
QAudioSink * m_audio_sink
The audio output, created when the first audio arrives.
Definition hls_player.h:155
void receiveLoop(const std::string &url)
Receive the stream until stop is requested, runs on the worker thread.
Definition hls_player.cpp:142
void workerState(const QString &state)
The worker thread changed state (delivered queued to the GUI thread).
HlsPlayer(QWidget *parent=nullptr)
Construct a new HLS player and show the window.
Definition hls_player.cpp:58
void noFrame()
Blank the display when no frames are arriving.
Definition hls_player.cpp:291
void showFrame(const QImage &image)
Show a received frame.
Definition hls_player.cpp:215
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.
Definition hls_player.cpp:234
QGraphicsPixmapItem * m_pixmap_item
The pixmap item, kept to avoid flicker.
Definition hls_player.h:137
void sessionState(const QString &state)
Update the status bar and report the new state.
Definition hls_player.cpp:279
bool eventFilter(QObject *obj, QEvent *event) override
Event filter to keep the image fitted to the dialog on resize.
Definition hls_player.cpp:302
QLabel * m_frame_label
Frame counter label.
Definition hls_player.h:145
QGraphicsView * m_view
The view.
Definition hls_player.h:135
void frameReceived(const QImage &image)
A frame was decoded on the worker thread (delivered queued to the GUI thread).
QLabel * m_stream_label
Stream address label (without credentials or query).
Definition hls_player.h:141
QLabel * m_format_label
Resolution label.
Definition hls_player.h:143
~HlsPlayer() final
Stop the stream and close the window.
Definition hls_player.cpp:108
void stop()
Stop the stream, close the window and destroy this object.
Definition hls_player.cpp:134
std::thread m_thread
The receive thread.
Definition hls_player.h:149
QString m_audio_info
Audio description shown in the status bar, empty without audio.
Definition hls_player.h:163
QString m_video_info
Video resolution description shown in the status bar.
Definition hls_player.h:165
QPixmap m_pixmap
The displayed image.
Definition hls_player.h:139
QPointer< QDialog > m_dialog
The player dialog.
Definition hls_player.h:131
quint64 m_frame_count
Frames received.
Definition hls_player.h:153
std::atomic< bool > m_stop
Set to ask the receive thread to finish.
Definition hls_player.h:151
QIODevice * m_audio_io
The audio output device, owned by the sink. Null if audio cannot be played.
Definition hls_player.h:157
int m_audio_channels
Channel count of the open audio output.
Definition hls_player.h:161
void setLabelColour(const QString &colour)
Set the colour of the stream label.
Definition hls_player.cpp:297
QGraphicsScene * m_scene
The scene.
Definition hls_player.h:133
void stateChanged(const QString &state)
The state of the stream changed.
QTimer m_blank_timer
No-frame blanking timer.
Definition hls_player.h:147