ToolX 1.11.1 [e3f477f]
A GUI debug tool chain for diagnosing GVA systems
Loading...
Searching...
No Matches
sap_player.h
Go to the documentation of this file.
1//
2// Copyright (c) 2026, Astute Systems PTY LTD
3//
4// This file is part of the VivoeX project developed by Astute Systems.
5//
6// License. See the LICENSE file in the project root for full license details.
7//
13
14#ifndef STREAMS_SAP_PLAYER_H
15#define STREAMS_SAP_PLAYER_H
16
17#include "../ui_player.h"
18#include <memory>
19#include <mutex>
20#include <QSap>
21#include <QRtp>
22#include <QTimer>
23#include <QElapsedTimer>
24#include <QStatusBar>
25#include <QLabel>
26#include <QGraphicsPixmapItem>
27#include <QGraphicsView>
28#include <QPushButton>
29
30#include "rtp/mkv_recorder.h"
31
32#ifdef VAAPI_SUPPORTED
33# include "qt6/QtRtpVaapiH264Depayloader.h"
34# include "qt6/QtRtpVaapiH265Depayloader.h"
36#endif
37#include "qt6/QtRtpOpenH264Depayloader.h"
38#include "qt6/QtRtpUncompressedDepayloader.h"
39#include "qt6/QtRtpJpegDepayloader.h"
40#ifdef BUILD_RUST
41# include "qt6/QtRtpAv1Depayloader.h"
42#endif
44
45class SapPlayer : public QObject
46{
47 Q_OBJECT
48
49public:
56 explicit SapPlayer(StreamGenerator::EncoderType decoder, QWidget *parent = nullptr);
57
62 ~SapPlayer() final;
63
69 static int activeCount();
70
71public slots:
77 void play(const QString name, const ::mediax::sap::SdpMessage sap);
78
84 void newFrame(Frame frame);
85
90 void noFrame();
91
95 void renderFrame();
96
100 void startRecording();
101
105 void stopRecording();
106
110 void toggleRecording();
111
112protected:
114 bool eventFilter(QObject *obj, QEvent *event) override;
115
116private:
118 Ui::Player *m_player_ui;
122 QGraphicsScene *m_scene;
124 QGraphicsPixmapItem *m_pixmapItem = nullptr;
126 QPixmap m_pixmap;
128 ::mediax::sap::SdpMessage m_sap;
129#ifdef VAAPI_SUPPORTED
131 mediax::qt6::QtRtpVaapiH264Depayloader m_rtpVaapiH264Depayloader;
133 mediax::qt6::QtRtpH265Depayloader m_rtpH265Depayloader;
135 toolx::streams::QtRtpVaapiAv1Depayloader m_rtpVaapiAv1Depayloader;
136#endif
138 mediax::qt6::QtRtpOpenH264Depayloader m_rtpOpenH264Depayloader;
139#if defined(BUILD_RUST) && !defined(VAAPI_SUPPORTED)
141 mediax::qt6::QtRtpAv1Depayloader m_rtpAv1Depayloader;
142#endif
144 mediax::qt6::QtRtpJpegDepayloader m_rtpJpegDepayloader;
146 mediax::qt6::QtRtpUncompressedDepayloader m_rtpUncompressedDepayloader;
148 mediax::qt6::QtRtpDepayloader *m_depayloader;
150 QTimer m_timer;
154 std::mutex m_frameMutex;
158 QByteArray m_convertBuffer;
160 bool m_framePending = false;
162 QGraphicsView *m_graphicsView = nullptr;
164 QStatusBar *m_status_bar;
166 uint32_t m_frame_count = 0;
174 QLabel *label_width;
180 mediax::rtp::MkvRecorder m_mkvRecorder;
182 bool m_recording = false;
184 QLabel *m_recordingLabel = nullptr;
186 QPushButton *m_recordButton = nullptr;
188 uint32_t m_actualWidth = 0;
190 uint32_t m_actualHeight = 0;
191
194};
195
196#endif // STREAMS_SAP_PLAYER_H
QGraphicsView * m_graphicsView
Pointer to the graphics view (cached to avoid findChild per frame).
Definition sap_player.h:162
QDialog * m_player_dialog
The player dialog.
Definition sap_player.h:120
void stopRecording()
Stop/pause recording (finalise MKV file).
Definition sap_player.cpp:439
mediax::qt6::QtRtpUncompressedDepayloader m_rtpUncompressedDepayloader
The RTP depayloader (uncompressed).
Definition sap_player.h:146
mediax::qt6::QtRtpDepayloader * m_depayloader
The RTP depayloader.
Definition sap_player.h:148
StreamGenerator::EncoderType m_decoder
The Decoder type.
Definition sap_player.h:178
void newFrame(Frame frame)
Receive a new video frame.
Definition sap_player.cpp:288
QLabel * m_recordingLabel
The recording status label.
Definition sap_player.h:184
QLabel * label_width
The frame width.
Definition sap_player.h:174
void startRecording()
Start recording to MKV file.
Definition sap_player.cpp:394
mediax::qt6::QtRtpOpenH264Depayloader m_rtpOpenH264Depayloader
The RTP depayloader (compressed H.264).
Definition sap_player.h:138
QTimer m_timer
Timer for blanking video (fires after prolonged silence).
Definition sap_player.h:150
QTimer m_renderTimer
Fixed-rate display timer for smooth rendering.
Definition sap_player.h:152
QLabel * label_framerate
The frame rate.
Definition sap_player.h:176
QGraphicsPixmapItem * m_pixmapItem
The persistent pixmap item (avoids clear/add flicker).
Definition sap_player.h:124
QLabel * m_stream_label
The stream details.
Definition sap_player.h:170
mediax::qt6::QtRtpJpegDepayloader m_rtpJpegDepayloader
The RTP depayloader (compressed JPEG, RFC 2435).
Definition sap_player.h:144
void updateRecordButtonIcon()
Update the record button icon based on recording state.
Definition sap_player.cpp:462
void renderFrame()
Render the latest buffered frame at display rate.
Definition sap_player.cpp:305
QLabel * label_height
The frame height.
Definition sap_player.h:172
QStatusBar * m_status_bar
The status bar.
Definition sap_player.h:164
static int activeCount()
The number of open RTP player windows.
Definition sap_player.cpp:129
uint32_t m_frame_count
The frame count.
Definition sap_player.h:166
uint32_t m_actualHeight
Actual decoded frame height (from latest received frame).
Definition sap_player.h:190
QGraphicsScene * m_scene
The scene for the player.
Definition sap_player.h:122
~SapPlayer() final
Destroy the Sap Player object.
Definition sap_player.cpp:119
void play(const QString name, const ::mediax::sap::SdpMessage sap)
New frame signal.
Definition sap_player.cpp:134
bool m_framePending
Whether a new frame is pending render.
Definition sap_player.h:160
::mediax::sap::SdpMessage m_sap
The SAP message.
Definition sap_player.h:128
Frame m_pendingFrame
The latest raw frame waiting to be rendered (stored cheaply, converted at render time).
Definition sap_player.h:156
Ui::Player * m_player_ui
The UI for the player.
Definition sap_player.h:118
void noFrame()
Timer to blank frame.
Definition sap_player.cpp:385
QPushButton * m_recordButton
The record button.
Definition sap_player.h:186
QPixmap m_pixmap
The pixmap for the player.
Definition sap_player.h:126
QByteArray m_convertBuffer
Reusable buffer for colorspace conversion (avoids per-frame heap allocation).
Definition sap_player.h:158
mediax::rtp::MkvRecorder m_mkvRecorder
The MKV recorder.
Definition sap_player.h:180
QLabel * m_frame_count_label
The frame count label.
Definition sap_player.h:168
bool eventFilter(QObject *obj, QEvent *event) override
Event filter to handle dialog resize events.
Definition sap_player.cpp:109
bool m_recording
Whether recording is active.
Definition sap_player.h:182
SapPlayer(StreamGenerator::EncoderType decoder, QWidget *parent=nullptr)
Construct a new Sap Player object.
Definition sap_player.cpp:38
std::mutex m_frameMutex
Mutex protecting the pending frame buffer.
Definition sap_player.h:154
uint32_t m_actualWidth
Actual decoded frame width (from latest received frame).
Definition sap_player.h:188
void toggleRecording()
Toggle recording on/off.
Definition sap_player.cpp:453
EncoderType
The encoder type.
Definition stream_generator.h:36
Qt wrapper for the MediaX VAAPI AV1 depayloader.
Session Announcement Protocol (SDP) implementation for listening to announcements of stream data....