Skip to content

Commit

Permalink
rtmp-services/UI: Add Bitmovin
Browse files Browse the repository at this point in the history
  • Loading branch information
CMThF committed May 30, 2022
1 parent 0d0b65e commit f115832
Show file tree
Hide file tree
Showing 13 changed files with 480 additions and 10 deletions.
4 changes: 4 additions & 0 deletions UI/data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ Basic.AutoConfig.StreamPage.Server="Server"
Basic.AutoConfig.StreamPage.StreamKey="Stream Key"
Basic.AutoConfig.StreamPage.StreamKey.LinkToSite="(Link)"
Basic.AutoConfig.StreamPage.EncoderKey="Encoder Key"
Basic.AutoConfig.StreamPage.RunningStream="Running Stream"
Basic.AutoConfig.StreamPage.GetApiKey="Get API Key"
Basic.AutoConfig.StreamPage.ApiKey="API Key"
Basic.AutoConfig.StreamPage.None="None"
Basic.AutoConfig.StreamPage.ConnectedAccount="Connected account"
Basic.AutoConfig.StreamPage.PerformBandwidthTest="Estimate bitrate with bandwidth test (may take a few minutes)"
Basic.AutoConfig.StreamPage.PreferHardwareEncoding="Prefer hardware encoding"
Expand Down
59 changes: 59 additions & 0 deletions UI/streaming-helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "obs-app.hpp"

#include "../plugins/rtmp-services/rtmp-format-ver.h"
#include "../plugins/rtmp-services/service-specific/bitmovin-constants.h"

#include <util/platform.h>
#include <util/util.hpp>
Expand Down Expand Up @@ -90,6 +91,40 @@ void StreamSettingsUI::UpdateMoreInfoLink()
}
}

void StreamSettingsUI::UpdateKey(const QString &key)
{
QString serviceName = ui_service->currentText();
if (serviceName == BITMOVIN_SERVICE_NAME) {
obs_service_t *service = obs_frontend_get_streaming_service();
obs_data_t *settings = obs_service_get_settings(service);
obs_data_set_string(settings, "key", QT_TO_UTF8(key));
obs_service_update(service, settings);

BitmovinFillLiveStreamList();
}
}

void StreamSettingsUI::BitmovinFillLiveStreamList()
{
obs_service_t *service = obs_frontend_get_streaming_service();
obs_properties_t *props = obs_service_properties(service);
obs_property_t *bitmovin_prop = obs_properties_get(
props, BITMOVIN_RUNNING_LIVE_STREAMS_LIST_PROPERTY_NAME);

ui_server->clear();
auto count = obs_property_list_item_count(bitmovin_prop);
if (count <= 0) {
ui_server->addItem(QTStr("Basic.AutoConfig.StreamPage.None"));
return;
}

for (size_t i = 0; i < count; i++) {
ui_server->addItem(
obs_property_list_item_name(bitmovin_prop, i),
obs_property_list_item_string(bitmovin_prop, i));
}
}

void StreamSettingsUI::UpdateKeyLink()
{
QString serviceName = ui_service->currentText();
Expand All @@ -107,6 +142,9 @@ void StreamSettingsUI::UpdateKeyLink()
if (serviceName == "Dacast") {
ui_streamKeyLabel->setText(
QTStr("Basic.AutoConfig.StreamPage.EncoderKey"));
} else if (serviceName == BITMOVIN_SERVICE_NAME) {
ui_streamKeyLabel->setText(
QTStr("Basic.AutoConfig.StreamPage.ApiKey"));
} else {
ui_streamKeyLabel->setText(
QTStr("Basic.AutoConfig.StreamPage.StreamKey"));
Expand All @@ -116,6 +154,10 @@ void StreamSettingsUI::UpdateKeyLink()
ui_streamKeyButton->hide();
} else {
ui_streamKeyButton->setTargetUrl(QUrl(streamKeyLink.c_str()));
if (serviceName == BITMOVIN_SERVICE_NAME) {
ui_streamKeyButton->setText(
QTStr("Basic.AutoConfig.StreamPage.GetApiKey"));
}
ui_streamKeyButton->show();
}
}
Expand Down Expand Up @@ -179,6 +221,23 @@ void StreamSettingsUI::UpdateServerList()

ui_server->clear();

if (serviceName == BITMOVIN_SERVICE_NAME) {
ui_serverLabel->setText(
QTStr("Basic.AutoConfig.StreamPage.RunningStream"));

obs_service_t *streaming_service =
obs_frontend_get_streaming_service();
obs_data_t *settings =
obs_service_get_settings(streaming_service);
obs_data_set_string(settings, "service", BITMOVIN_SERVICE_NAME);
obs_service_update(streaming_service, settings);

BitmovinFillLiveStreamList();
return;
}

ui_serverLabel->setText(QTStr("Basic.AutoConfig.StreamPage.Server"));

auto &servers = service["servers"].array_items();
for (const Json &entry : servers) {
ui_server->addItem(entry["name"].string_value().c_str(),
Expand Down
7 changes: 6 additions & 1 deletion UI/streaming-helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class StreamSettingsUI : public QObject {
Q_OBJECT

QLabel *ui_streamKeyLabel;
QLabel *ui_serverLabel;
QComboBox *ui_service;
QComboBox *ui_server;
QLineEdit *ui_customServer;
Expand All @@ -34,9 +35,10 @@ class StreamSettingsUI : public QObject {
inline void Setup(QLabel *streamKeyLabel, QComboBox *service,
QComboBox *server, QLineEdit *customServer,
UrlPushButton *moreInfoButton,
UrlPushButton *streamKeyButton)
UrlPushButton *streamKeyButton, QLabel *serverLabel)
{
ui_streamKeyLabel = streamKeyLabel;
ui_serverLabel = serverLabel;
ui_service = service;
ui_server = server;
ui_customServer = customServer;
Expand All @@ -63,8 +65,11 @@ class StreamSettingsUI : public QObject {

inline const QString &LastService() const { return lastService; }

void BitmovinFillLiveStreamList();

public slots:
void UpdateMoreInfoLink();
void UpdateKey(const QString &key);
void UpdateKeyLink();
void LoadServices(bool showAll);
void UpdateServerList();
Expand Down
2 changes: 1 addition & 1 deletion UI/window-basic-auto-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ AutoConfigStreamPage::AutoConfigStreamPage(QWidget *parent)

streamUi.Setup(ui->streamKeyLabel, ui->service, ui->server,
ui->customServer, ui->moreInfoButton,
ui->streamKeyButton);
ui->streamKeyButton, ui->serverLabel);

ui->connectedAccountLabel->setVisible(false);
ui->connectedAccountText->setVisible(false);
Expand Down
12 changes: 8 additions & 4 deletions UI/window-basic-settings-stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "window-basic-main.hpp"
#include "qt-wrappers.hpp"
#include "url-push-button.hpp"
#include "../plugins/rtmp-services/service-specific/bitmovin-constants.h"

#ifdef BROWSER_AVAILABLE
#include <browser-panel.hpp>
Expand Down Expand Up @@ -61,7 +62,7 @@ void OBSBasicSettings::InitStreamPage()

streamUi.Setup(ui->streamKeyLabel, ui->service, ui->server,
ui->customServer, ui->moreInfoButton,
ui->getStreamKeyButton);
ui->getStreamKeyButton, ui->serverLabel);

streamUi.LoadServices(false);

Expand Down Expand Up @@ -92,6 +93,8 @@ void OBSBasicSettings::InitStreamPage()
SLOT(UpdateResFPSLimits()));
connect(ui->service, SIGNAL(currentIndexChanged(int)), &streamUi,
SLOT(UpdateMoreInfoLink()));
connect(ui->key, SIGNAL(textChanged(QString)), &streamUi,
SLOT(UpdateKey(QString)));
}

void OBSBasicSettings::LoadStream1Settings()
Expand Down Expand Up @@ -139,19 +142,20 @@ void OBSBasicSettings::LoadStream1Settings()
}

streamUi.UpdateServerList();
ui->key->setText(key);

if (strcmp(type, "rtmp_common") == 0) {
int idx = ui->server->findData(server);
if (idx == -1) {
if (server && *server)
if (server && *server &&
strcmp(service, BITMOVIN_SERVICE_NAME) != 0) {
ui->server->insertItem(0, server, server);
}
idx = 0;
}
ui->server->setCurrentIndex(idx);
}

ui->key->setText(key);

streamUi.ClearLastService();
on_service_currentIndexChanged(0);

Expand Down
3 changes: 3 additions & 0 deletions plugins/rtmp-services/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ target_sources(
service-specific/showroom.h
service-specific/dacast.c
service-specific/dacast.h
service-specific/bitmovin.c
service-specific/bitmovin.h
service-specific/bitmovin-constants.h
rtmp-common.c
rtmp-custom.c
rtmp-services-main.c
Expand Down
4 changes: 2 additions & 2 deletions plugins/rtmp-services/data/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "schema/package-schema.json",
"url": "https://obsproject.com/obs2_update/rtmp-services",
"version": 197,
"version": 198,
"files": [
{
"name": "services.json",
"version": 197
"version": 198
}
]
}
14 changes: 14 additions & 0 deletions plugins/rtmp-services/data/services.json
Original file line number Diff line number Diff line change
Expand Up @@ -2622,6 +2622,20 @@
"max video bitrate": 5000,
"max audio bitrate": 160
}
},
{
"name": "Bitmovin",
"more_info_link": "https://bitmovin.com/docs/encoding/tutorials/contribution-encoder-obs-studio-example",
"stream_key_link": "https://bitmovin.com/dashboard/account",
"servers": [
{
"name": "dummy",
"url": "rtmp://"
}
],
"recommended": {
"keyint": 2
}
}
]
}
26 changes: 24 additions & 2 deletions plugins/rtmp-services/rtmp-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "service-specific/nimotv.h"
#include "service-specific/showroom.h"
#include "service-specific/dacast.h"
#include "service-specific/bitmovin.h"

struct rtmp_common {
char *service;
Expand Down Expand Up @@ -51,6 +52,8 @@ static void ensure_valid_url(struct rtmp_common *service, json_t *json,
return;
if (astrstri(service->service, "Facebook") == NULL)
return;
if (astrstri(service->service, BITMOVIN_SERVICE_NAME) == NULL)
return;

json_array_foreach (servers, index, server) {
const char *url = get_string_val(server, "url");
Expand Down Expand Up @@ -150,6 +153,10 @@ static void rtmp_common_update(void *data, obs_data_t *settings)
}
}
json_decref(root);
if (service->service &&
strcmp(service->service, BITMOVIN_SERVICE_NAME) == 0) {
bitmovin_update(service->key);
}

if (!service->output)
service->output = bstrdup("rtmp_output");
Expand Down Expand Up @@ -518,9 +525,9 @@ static bool show_all_services_toggled(obs_properties_t *ppts, obs_property_t *p,
return true;
}

static obs_properties_t *rtmp_common_properties(void *unused)
static obs_properties_t *rtmp_common_properties(void *data)
{
UNUSED_PARAMETER(unused);
struct rtmp_common *service = data;

obs_properties_t *ppts = obs_properties_create();
obs_property_t *p;
Expand All @@ -546,6 +553,11 @@ static obs_properties_t *rtmp_common_properties(void *unused)

obs_properties_add_text(ppts, "key", obs_module_text("StreamKey"),
OBS_TEXT_PASSWORD);

if (strcmp(service->service, BITMOVIN_SERVICE_NAME) == 0) {
bitmovin_get_obs_properties(ppts);
}

return ppts;
}

Expand Down Expand Up @@ -716,6 +728,11 @@ static const char *rtmp_common_url(void *data)
return ingest->url;
}
}

if (service->service &&
strcmp(service->service, BITMOVIN_SERVICE_NAME) == 0) {
return bitmovin_get_ingest(service->key, service->server);
}
return service->server;
}

Expand All @@ -738,6 +755,11 @@ static const char *rtmp_common_key(void *data)
return ingest->streamkey;
}
}

if (service->service &&
strcmp(service->service, BITMOVIN_SERVICE_NAME) == 0) {
return bitmovin_get_stream_key();
}
return service->key;
}

Expand Down
3 changes: 3 additions & 0 deletions plugins/rtmp-services/rtmp-services-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "service-specific/showroom.h"
#include "service-specific/dacast.h"
#include "service-specific/bitmovin.h"

OBS_DECLARE_MODULE()
OBS_MODULE_USE_DEFAULT_LOCALE("rtmp-services", "en-US")
Expand Down Expand Up @@ -75,6 +76,7 @@ bool obs_module_load(void)
{
init_twitch_data();
init_dacast_data();
init_bitmovin_data();

dstr_copy(&module_name, "rtmp-services plugin (libobs ");
dstr_cat(&module_name, obs_get_version_string());
Expand Down Expand Up @@ -115,5 +117,6 @@ void obs_module_unload(void)
unload_twitch_data();
free_showroom_data();
unload_dacast_data();
unload_bitmovin_data();
dstr_free(&module_name);
}
10 changes: 10 additions & 0 deletions plugins/rtmp-services/service-specific/bitmovin-constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#ifndef BITMOVIN_SERVICE_NAME
#define BITMOVIN_SERVICE_NAME "Bitmovin"
#endif

#ifndef BITMOVIN_RUNNING_LIVE_STREAMS_LIST_PROPERTY_NAME
#define BITMOVIN_RUNNING_LIVE_STREAMS_LIST_PROPERTY_NAME \
"bitmovin_running_live_streams_list"
#endif
Loading

0 comments on commit f115832

Please sign in to comment.