Skip to content

Commit 9cabfa2

Browse files
authored
Merge pull request #46 from OPENSPHERE-Inc/patch-0.7.2
0.7.2
2 parents 1efd5b3 + 5a4dad9 commit 9cabfa2

13 files changed

+293
-16
lines changed

buildspec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"name": "osi-src-link",
4040
"displayName": "SRC-Link Plugin",
41-
"version": "0.7.1",
41+
"version": "0.7.2",
4242
"author": "OPENSPHERE Inc.",
4343
"website": "https://opensphere.co.jp/",
4444
"email": "[email protected]",

data/locale/en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,5 @@ Linked="Linked"
140140
Unlinked="Unlinked"
141141
Retrying="Retrying"
142142
Activating="Activating"
143+
%1.kbps[drops.%2(%3%)]="%1 kbps, Drops: %2 (%3%)"
144+
Statistics="Statistics"

data/locale/ja-JP.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,5 @@ Linked="リンク済"
140140
Unlinked="未リンク"
141141
Retrying="再試行中"
142142
Activating="アクティベート中"
143+
%1.kbps[drops.%2(%3%)]="%1 kbps, ドロップ: %2 (%3%)"
144+
Statistics="統計"

src-link_usage_image.jpg

-459 Bytes
Loading

src/UI/egress-link-connection-widget.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ EgressLinkConnectionWidget::EgressLinkConnectionWidget(
6666
output, SIGNAL(recordingStatusChanged(RecordingOutputStatus)), this,
6767
SLOT(onRecordingStatusChanged(RecordingOutputStatus))
6868
);
69+
connect(
70+
output, SIGNAL(statisticsUpdated(double, int, int, uint64_t)), this,
71+
SLOT(onStatisticsUpdated(double, int, int, uint64_t))
72+
);
6973
connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsButtonClick()));
7074
connect(ui->visibilityCheckBox, SIGNAL(clicked(bool)), this, SLOT(onVisibilityChanged(bool)));
7175
connect(ui->videoSourceComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onVideoSourceChanged(int)));
@@ -78,6 +82,8 @@ EgressLinkConnectionWidget::EgressLinkConnectionWidget(
7882
// Translations
7983
ui->videoSourceLabel->setText(QTStr("LocalSource"));
8084
ui->statusLabel->setText(QTStr("Status"));
85+
ui->statsLabel->setText(QTStr("Statistics"));
86+
ui->statsValueLabel->setText("");
8187

8288
obs_log(LOG_DEBUG, "EgressLinkConnectionWidget created");
8389
}
@@ -130,38 +136,45 @@ void EgressLinkConnectionWidget::onOutputStatusChanged(EgressLinkOutputStatus st
130136
case EGRESS_LINK_OUTPUT_STATUS_ACTIVATING:
131137
ui->statusValueLabel->setText(QTStr("Activating"));
132138
ui->statusIconLabel->setVisible(true);
139+
ui->statsWidget->setVisible(false);
133140
setThemeID(ui->statusValueLabel, "good", "text-success");
134141
break;
135142
case EGRESS_LINK_OUTPUT_STATUS_ACTIVE:
136143
ui->statusValueLabel->setText(QTStr("Active"));
137144
ui->statusIconLabel->setVisible(true);
145+
ui->statsWidget->setVisible(true);
138146
setThemeID(ui->statusValueLabel, "good", "text-success");
139147
break;
140148
case EGRESS_LINK_OUTPUT_STATUS_STAND_BY:
141149
ui->statusValueLabel->setText(QTStr("StandBy"));
142150
ui->statusIconLabel->setVisible(false);
151+
ui->statsWidget->setVisible(false);
143152
setThemeID(ui->statusValueLabel, "good", "text-success");
144153
break;
145154
case EGRESS_LINK_OUTPUT_STATUS_ERROR:
146155
ui->statusValueLabel->setText(QTStr("Error"));
147156
ui->statusIconLabel->setVisible(false);
157+
ui->statsWidget->setVisible(false);
148158
setThemeID(ui->statusValueLabel, "error", "text-danger");
149159
// Try to remove error sources from combo
150160
updateSourceList();
151161
break;
152162
case EGRESS_LINK_OUTPUT_STATUS_INACTIVE:
153163
ui->statusValueLabel->setText(QTStr("Inactive"));
154164
ui->statusIconLabel->setVisible(false);
165+
ui->statsWidget->setVisible(false);
155166
setThemeID(ui->statusValueLabel, "", "");
156167
break;
157168
case EGRESS_LINK_OUTPUT_STATUS_DISABLED:
158169
ui->statusValueLabel->setText(QTStr("Disabled"));
159170
ui->statusIconLabel->setVisible(false);
171+
ui->statsWidget->setVisible(false);
160172
setThemeID(ui->statusValueLabel, "", "");
161173
break;
162174
case EGRESS_LINK_OUTPUT_STATUS_RECONNECTING:
163175
ui->statusValueLabel->setText(QTStr("Reconnecting"));
164176
ui->statusIconLabel->setVisible(false);
177+
ui->statsWidget->setVisible(false);
165178
setThemeID(ui->statusValueLabel, "error", "text-danger");
166179
break;
167180
}
@@ -247,3 +260,13 @@ void EgressLinkConnectionWidget::onVisibilityChanged(bool value)
247260
{
248261
output->setVisible(value);
249262
}
263+
264+
void EgressLinkConnectionWidget::onStatisticsUpdated(double bitrate, int totalFrames, int droppedFrames, uint64_t)
265+
{
266+
ui->statsValueLabel->setText(
267+
QTStr("%1.kbps[drops.%2(%3%)]")
268+
.arg(bitrate, 0, 'f', 0)
269+
.arg(droppedFrames)
270+
.arg(totalFrames ? 100.0 * (double)droppedFrames / (double)totalFrames : 0.0, 0, 'f', 1)
271+
);
272+
}

src/UI/egress-link-connection-widget.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ private slots:
5353
void onRecordingStatusChanged(RecordingOutputStatus status);
5454
void updateSourceList();
5555
void onVisibilityChanged(bool value);
56+
void onStatisticsUpdated(double bitrate, int totalFrames, int droppedFrames, uint64_t bytesSent);
5657

5758
public:
5859
explicit EgressLinkConnectionWidget(

src/UI/egress-link-connection-widget.ui

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,17 @@
173173
<item>
174174
<widget class="QLabel" name="statusValueLabel">
175175
<property name="sizePolicy">
176-
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
176+
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
177177
<horstretch>0</horstretch>
178178
<verstretch>0</verstretch>
179179
</sizepolicy>
180180
</property>
181+
<property name="minimumSize">
182+
<size>
183+
<width>0</width>
184+
<height>30</height>
185+
</size>
186+
</property>
181187
<property name="text">
182188
<string>Inactive</string>
183189
</property>
@@ -210,6 +216,62 @@
210216
</item>
211217
</layout>
212218
</item>
219+
<item>
220+
<widget class="QWidget" name="statsWidget" native="true">
221+
<layout class="QHBoxLayout" name="horizontalLayout">
222+
<property name="leftMargin">
223+
<number>0</number>
224+
</property>
225+
<property name="topMargin">
226+
<number>0</number>
227+
</property>
228+
<property name="rightMargin">
229+
<number>0</number>
230+
</property>
231+
<property name="bottomMargin">
232+
<number>0</number>
233+
</property>
234+
<item>
235+
<widget class="QLabel" name="statsLabel">
236+
<property name="sizePolicy">
237+
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
238+
<horstretch>0</horstretch>
239+
<verstretch>0</verstretch>
240+
</sizepolicy>
241+
</property>
242+
<property name="minimumSize">
243+
<size>
244+
<width>120</width>
245+
<height>0</height>
246+
</size>
247+
</property>
248+
<property name="text">
249+
<string>Statistics</string>
250+
</property>
251+
</widget>
252+
</item>
253+
<item>
254+
<widget class="QLabel" name="statsValueLabel">
255+
<property name="sizePolicy">
256+
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
257+
<horstretch>0</horstretch>
258+
<verstretch>0</verstretch>
259+
</sizepolicy>
260+
</property>
261+
<property name="minimumSize">
262+
<size>
263+
<width>0</width>
264+
<height>30</height>
265+
</size>
266+
</property>
267+
<property name="text">
268+
<string>No Data</string>
269+
</property>
270+
</widget>
271+
</item>
272+
</layout>
273+
</widget>
274+
</item>
213275
</layout>
214276
</widget>
215277
<resources>

src/UI/images/unknownstage.png

-41.6 KB
Loading

src/api-client.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ const RequestInvoker *SRCLinkApiClient::putUplink(const bool force)
711711
body["participant_id"] = participantId != PARTICIPANT_SEELCTION_NONE ? participantId : "";
712712
body["force"] = force ? "1" : "0";
713713
body["uplink_status"] = uplinkStatus;
714+
body["protocols"] = QJsonArray({"srt", "rtmp"});
714715

715716
API_LOG(
716717
"Putting uplink of %s (participant=%s, force=%s)", qUtf8Printable(uuid),
@@ -822,6 +823,29 @@ const RequestInvoker *SRCLinkApiClient::deleteUplink(const bool parallel)
822823
return invoker;
823824
}
824825

826+
// Upload statistics via wewbsocket
827+
void SRCLinkApiClient::putStatistics(
828+
const QString &sourceName, const QString &status, bool recording, const OutputMetric &metric
829+
)
830+
{
831+
CHECK_CLIENT_TOKEN();
832+
833+
json payload;
834+
835+
payload["uuid"] = qUtf8Printable(uuid);
836+
payload["source_name"] = qUtf8Printable(sourceName);
837+
payload["status"] = qUtf8Printable(status);
838+
payload["recording"] = recording;
839+
payload["metric"] = {
840+
{"bitrate", metric.getBitrate()},
841+
{"total_frames", metric.getTotalFrames()},
842+
{"dropped_frames", metric.getDroppedFrames()},
843+
{"total_size", metric.getTotalSize()}
844+
};
845+
846+
websocket->invokeBin("statistics.put", payload);
847+
}
848+
825849
// Upload screenshot via websocket
826850
void SRCLinkApiClient::putScreenshot(const QString &sourceName, const QImage &image)
827851
{

src/api-client.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ with this program. If not, see <https://www.gnu.org/licenses/>
3838
#define PARTICIPANT_SEELCTION_NONE "none"
3939
#define WS_PORTAL_SELECTION_NONE "none"
4040

41+
#define OUTPUT_STATUS_INACTIVE "inactive"
42+
#define OUTPUT_STATUS_ACTIVE "active"
43+
#define OUTPUT_STATUS_RECONNECTING "reconnecting"
44+
#define OUTPUT_STATUS_STAND_BY "standby"
45+
4146
class SRCLinkApiClient : public QObject {
4247
Q_OBJECT
4348

@@ -164,6 +169,7 @@ public slots:
164169
const RequestInvoker *putUplink(const bool force = false);
165170
const RequestInvoker *putUplinkStatus();
166171
const RequestInvoker *deleteUplink(const bool parallel = false);
172+
void putStatistics(const QString &sourceName, const QString &status, bool recording, const OutputMetric &metric);
167173
void putScreenshot(const QString &sourceName, const QImage &image);
168174
void getPicture(const QString &pitureId);
169175
void refreshIngress() { emit ingressRefreshNeeded(); }

0 commit comments

Comments
 (0)