Skip to content

Commit

Permalink
GUI: Display incoming video & audio formats
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiatka committed Sep 25, 2024
1 parent fa4798f commit 74da163
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 14 deletions.
58 changes: 44 additions & 14 deletions gui/QT/ui/ultragrid_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,50 @@
<layout class="QHBoxLayout" name="remotePreviewBar"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remote</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
<layout class="QHBoxLayout" name="remoteLabelFormatLayout">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remote</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="recvAudioFmtLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="recvVideoFmtLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down
33 changes: 33 additions & 0 deletions gui/QT/window/ultragrid_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <CoreFoundation/CoreFoundation.h>
#endif

#include "utils/string_view_utils.hpp"

namespace {
QString argListToString(const QStringList& argList){
return argList.join(" ");
Expand Down Expand Up @@ -120,6 +122,34 @@ UltragridWindow::UltragridWindow(QWidget *parent): QMainWindow(parent){

using namespace std::placeholders;
controlPort.addLineCallback(std::bind(&BandwidthWidget::parseLine, ui.send_bandwidth, _1));

controlPort.addLineCallback(std::bind(&UltragridWindow::recvFmtCallback, this, _1));
}

void UltragridWindow::clearFmtLabels(){
ui.recvVideoFmtLabel->setText("");
ui.recvAudioFmtLabel->setText("");
};

void UltragridWindow::recvFmtCallback(std::string_view line){
static constexpr std::string_view prefix = "stats ";
if(!sv_is_prefix(line, prefix))
return;

line.remove_prefix(prefix.size());

static constexpr std::string_view videoFmt = "new incoming video fmt: ";
static constexpr std::string_view audioFmt = "new incoming audio fmt: ";

if(sv_is_prefix(line, videoFmt)){
line.remove_prefix(videoFmt.size());
std::string fmt(sv_trim_whitespace_back(line));
ui.recvVideoFmtLabel->setText(fmt.c_str());
} else if(sv_is_prefix(line, audioFmt)){
line.remove_prefix(audioFmt.size());
std::string fmt(sv_trim_whitespace_back(line));
ui.recvAudioFmtLabel->setText(fmt.c_str());
}
}

void UltragridWindow::launchQuery(){
Expand Down Expand Up @@ -314,6 +344,8 @@ void UltragridWindow::start(){
ctx->args = launchArgs;
ctx->type = LaunchContext::Type::Run;

clearFmtLabels();

connect(&ctx->process, &QProcess::started,
[=]()
{
Expand All @@ -330,6 +362,7 @@ void UltragridWindow::start(){
ui.startButton->setEnabled(true);
ui.actionRefresh->setEnabled(true);
receiverLoss.reset();
clearFmtLabels();
rtcpRr.reset();
ui.send_bandwidth->reset();

Expand Down
3 changes: 3 additions & 0 deletions gui/QT/window/ultragrid_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class UltragridWindow : public QMainWindow{

void launchQuery();

void clearFmtLabels();
void recvFmtCallback(std::string_view line);

Ui::UltragridWindow ui;

QString ultragridExecutable;
Expand Down

0 comments on commit 74da163

Please sign in to comment.