diff options
| author | Anton <anton@picapica.im> | 2026-11-29 23:38:25 +0400 |
|---|---|---|
| committer | Anton <anton@picapica.im> | 2026-11-29 23:38:25 +0400 |
| commit | 56863d74399c8d7354a00bc8ddc87b924ef870ab (patch) | |
| tree | bd9e44c438f974f80aa6cfef59fe842d3e128ee7 /pica-client/videodevice.h | |
| parent | d6ce3a2226bda81cce96c61f0a73fb1516adbd0b (diff) | |
| download | pica-pica-call_quality_presets.tar.gz pica-pica-call_quality_presets.zip | |
pica-client: new presets tab, call quality presetscall_quality_presets
Diffstat (limited to 'pica-client/videodevice.h')
| -rw-r--r-- | pica-client/videodevice.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/pica-client/videodevice.h b/pica-client/videodevice.h index 14a906a..2724d63 100644 --- a/pica-client/videodevice.h +++ b/pica-client/videodevice.h @@ -19,6 +19,7 @@ #include "mediadevice.h" #include "callsettings.h" +#include "callquality.h" #include "vaapi.h" #include <QObject> #include <QString> @@ -29,6 +30,7 @@ #include <QWaitCondition> #include <QSize> #include <QAtomicInt> +#include <QList> // Reassembles the fragments of one encoded video frame, as carried by 0x77 // protocol messages - see the fragmentation description in @@ -193,6 +195,27 @@ public: // captureSizeWithin(). Queued after configureCapture(), which clears it. Q_INVOKABLE void limitCaptureSize(int width, int height); + // A CallQualityPreset. For any but CallQualityCustom, Capture() puts the + // preset's plan in place of the codec, bitrate, size, frame rate and + // acceleration given to configureCapture() - worked out from what the + // camera offers, the limit above and the hardware encoders that work, see + // callPlanVideo() - and never forwards the camera's own stream, which + // would leave nothing to plan. Queued after configureCapture(), which + // resets it to CallQualityCustom. + Q_INVOKABLE void setQualityPreset(int preset); + + // One 0x79 report from the peer of the call, for CallQualityAdaptive to + // follow - see CallRateController. Ignored with any other preset. Safe to + // call from any thread, and called directly rather than queued for the + // same reason enqueueFrame() is. + void reportReception(const CallReceptionReport &report); + + // Runs ProbeHardwareEncoders() on this device's thread and emits + // hardwareEncodersProbed() when it is done. For a caller on a thread that + // must not block, or that Media Foundation will not work on - a Windows + // GUI thread is in COM's single-threaded apartment. + Q_INVOKABLE void probeHardwareEncoders(); + // Allows Capture()/Play() to run for the call this pair of ids names, // until Close() - the same arrangement as AudioDevice::openSession(). To // be called directly, before the calls that configure and start the @@ -327,6 +350,13 @@ signals: // encoding altogether - neither should have to be guessed at. void accelerationInUse(QString description); + // What is being sent changed in the middle of a capture: CallQualityAdaptive + // moved to another picture size. For a new 0x75; the codec stays the same. + void streamChanged(QString codec, int width, int height); + + // See probeHardwareEncoders(). + void hardwareEncodersProbed(); + public: virtual QList<MediaDeviceInfo> Enumerate(enum MediaDeviceStreamDirection dir); @@ -356,6 +386,21 @@ public: // what the settings dialog needs to know before offering it. static bool AccelerationBuiltIn(VideoAcceleration acceleration, bool encoding); + // The hardware encoders that work on this machine: each one FFmpeg has + // for a call codec, through each acceleration this build offers, that + // opens on this machine's GPU and encodes a frame. In the order Capture() + // tries them. Found out once per run - opening an encoder takes up to a + // fraction of a second - and blocks until then, so call it from a thread + // that may wait. Thread-safe. + static QList<CallHardwareEncoder> ProbeHardwareEncoders(); + + // The same, without waiting: false while the probe has not run yet. + static bool HardwareEncodersProbed(QList<CallHardwareEncoder> *encoders); + + // The sizes and rates of CaptureFormats() as the call quality planning + // takes them. + static QList<CallCameraSize> CallCameraSizes(const QList<VideoCaptureFormat> &formats); + private: QString m_deviceName; QString m_codec; @@ -367,6 +412,19 @@ private: int m_frameRate; int m_bitrate; bool m_preferCompressed; + // see setQualityPreset() + int m_preset; + // What Capture() made of a preset; m_planned is false for + // CallQualityCustom, which encodes at m_width x m_height. + CallVideoPlan m_plan; + bool m_planned; + + // see reportReception() + QMutex m_reportMutex; + QList<CallReceptionReport> m_reports; + QList<CallReceptionReport> takeReports(); + // Fragments emitted since the last report was taken. Capture thread only. + int m_fragmentsSent; // VideoAcceleration flags; which of them apply depends on the direction // this instance was configured for. int m_acceleration; |
