Skip to content

Commit

Permalink
UI: Add "YouTube Control Panel" dock panel
Browse files Browse the repository at this point in the history
New dock panel with integrated youtube studio live control room.
This commit also modifies CI files.
  • Loading branch information
yuriy-chumak authored and Lain-B committed Aug 3, 2023
1 parent 807c8a9 commit 81b5881
Show file tree
Hide file tree
Showing 14 changed files with 712 additions and 20 deletions.
12 changes: 10 additions & 2 deletions UI/cmake/feature-youtube.cmake
Expand Up @@ -2,8 +2,16 @@ if(YOUTUBE_CLIENTID
AND YOUTUBE_SECRET
AND YOUTUBE_CLIENTID_HASH MATCHES "(0|[a-fA-F0-9]+)"
AND YOUTUBE_SECRET_HASH MATCHES "(0|[a-fA-F0-9]+)")
target_sources(obs-studio PRIVATE auth-youtube.cpp auth-youtube.hpp window-youtube-actions.cpp
window-youtube-actions.hpp youtube-api-wrappers.cpp youtube-api-wrappers.hpp)
target_sources(
obs-studio
PRIVATE auth-youtube.cpp
auth-youtube.hpp
window-dock-youtube-app.cpp
window-dock-youtube-app.hpp
window-youtube-actions.cpp
window-youtube-actions.hpp
youtube-api-wrappers.cpp
youtube-api-wrappers.hpp)

target_enable_feature(obs-studio "YouTube API connection" YOUTUBE_ENABLED)
else()
Expand Down
12 changes: 10 additions & 2 deletions UI/cmake/legacy.cmake
Expand Up @@ -330,8 +330,16 @@ endif()

if(YOUTUBE_ENABLED)
target_compile_definitions(obs PRIVATE YOUTUBE_ENABLED)
target_sources(obs PRIVATE auth-youtube.cpp auth-youtube.hpp youtube-api-wrappers.cpp youtube-api-wrappers.hpp
window-youtube-actions.cpp window-youtube-actions.hpp)
target_sources(
obs
PRIVATE auth-youtube.cpp
auth-youtube.hpp
window-dock-youtube-app.cpp
window-dock-youtube-app.hpp
window-youtube-actions.cpp
window-youtube-actions.hpp
youtube-api-wrappers.cpp
youtube-api-wrappers.hpp)
endif()

if(OS_WINDOWS)
Expand Down
3 changes: 3 additions & 0 deletions UI/data/locale/en-US.ini
Expand Up @@ -1526,3 +1526,6 @@ YouTube.Errors.liveChatDisabled="Live chat is disabled on this stream."
YouTube.Errors.liveChatEnded="Live stream has ended."
YouTube.Errors.messageTextInvalid="The message text is not valid."
YouTube.Errors.rateLimitExceeded="You are sending messages too quickly."
# Browser Dock
YouTube.DocksRemoval.Title="Clear Legacy YouTube Browser Docks"
YouTube.DocksRemoval.Text="These browser docks will be removed as deprecated:\n\n%1\nUse \"Docks/YouTube Live Control Room\" instead."
7 changes: 7 additions & 0 deletions UI/window-basic-auto-config.cpp
Expand Up @@ -1050,6 +1050,13 @@ void AutoConfig::done(int result)
if (type == Type::Streaming)
SaveStreamSettings();
SaveSettings();

#ifdef YOUTUBE_ENABLED
if (YouTubeAppDock::IsYTServiceSelected()) {
OBSBasic *main = OBSBasic::Get();
main->NewYouTubeAppDock();
}
#endif
}
}

Expand Down
54 changes: 49 additions & 5 deletions UI/window-basic-main.cpp
Expand Up @@ -2170,6 +2170,9 @@ void OBSBasic::OBSInit()

/* ----------------------------- */
/* add custom browser docks */
#if defined(BROWSER_AVAILABLE) && defined(YOUTUBE_ENABLED)
YouTubeAppDock::CleanupYouTubeUrls();
#endif

#ifdef BROWSER_AVAILABLE
if (cef) {
Expand Down Expand Up @@ -2331,6 +2334,12 @@ void OBSBasic::OBSInit()
UpdatePreviewProgramIndicators();
OnFirstLoad();

#ifdef YOUTUBE_ENABLED
/* setup YouTube app dock */
if (YouTubeAppDock::IsYTServiceSelected())
youtubeAppDock = new YouTubeAppDock();
#endif

if (!hideWindowOnStart)
activateWindow();

Expand Down Expand Up @@ -6823,9 +6832,10 @@ void OBSBasic::DisplayStreamStartError()
}

#ifdef YOUTUBE_ENABLED
void OBSBasic::YouTubeActionDialogOk(const QString &id, const QString &key,
bool autostart, bool autostop,
bool start_now)
void OBSBasic::YouTubeActionDialogOk(const QString &broadcast_id,
const QString &stream_id,
const QString &key, bool autostart,
bool autostop, bool start_now)
{
//blog(LOG_DEBUG, "Stream key: %s", QT_TO_UTF8(key));
obs_service_t *service_obj = GetService();
Expand All @@ -6834,8 +6844,11 @@ void OBSBasic::YouTubeActionDialogOk(const QString &id, const QString &key,
const std::string a_key = QT_TO_UTF8(key);
obs_data_set_string(settings, "key", a_key.c_str());

const std::string an_id = QT_TO_UTF8(id);
obs_data_set_string(settings, "stream_id", an_id.c_str());
const std::string b_id = QT_TO_UTF8(broadcast_id);
obs_data_set_string(settings, "broadcast_id", b_id.c_str());

const std::string s_id = QT_TO_UTF8(stream_id);
obs_data_set_string(settings, "stream_id", s_id.c_str());

obs_service_update(service_obj, settings);
autoStartBroadcast = autostart;
Expand Down Expand Up @@ -7419,6 +7432,11 @@ void OBSBasic::StreamingStart()

OnActivate();

#ifdef YOUTUBE_ENABLED
if (YouTubeAppDock::IsYTServiceSelected())
youtubeAppDock->IngestionStarted();
#endif

blog(LOG_INFO, STREAMING_START);
}

Expand Down Expand Up @@ -7499,6 +7517,11 @@ void OBSBasic::StreamingStop(int code, QString last_error)

OnDeactivate();

#ifdef YOUTUBE_ENABLED
if (YouTubeAppDock::IsYTServiceSelected())
youtubeAppDock->IngestionStopped();
#endif

blog(LOG_INFO, STREAMING_STOP);

if (encode_error) {
Expand Down Expand Up @@ -8462,6 +8485,27 @@ config_t *OBSBasic::Config() const
return basicConfig;
}

#ifdef YOUTUBE_ENABLED
YouTubeAppDock *OBSBasic::GetYouTubeAppDock()
{
return youtubeAppDock;
}

void OBSBasic::NewYouTubeAppDock()
{
if (youtubeAppDock)
delete youtubeAppDock;
youtubeAppDock = new YouTubeAppDock();
}

void OBSBasic::DeleteYouTubeAppDock()
{
if (youtubeAppDock)
delete youtubeAppDock;
youtubeAppDock = nullptr;
}
#endif

void OBSBasic::UpdateEditMenu()
{
QModelIndexList items = GetAllSelectedSourceItems();
Expand Down
14 changes: 13 additions & 1 deletion UI/window-basic-main.hpp
Expand Up @@ -36,6 +36,9 @@
#include "window-missing-files.hpp"
#include "window-projector.hpp"
#include "window-basic-about.hpp"
#ifdef YOUTUBE_ENABLED
#include "window-dock-youtube-app.hpp"
#endif
#include "auth-base.hpp"
#include "log-viewer.hpp"
#include "undo-stack-obs.hpp"
Expand Down Expand Up @@ -262,6 +265,9 @@ class OBSBasic : public OBSMainWindow {
QPointer<OBSBasicAdvAudio> advAudioWindow;
QPointer<OBSBasicFilters> filters;
QPointer<QDockWidget> statsDock;
#ifdef YOUTUBE_ENABLED
QPointer<YouTubeAppDock> youtubeAppDock;
#endif
QPointer<OBSAbout> about;
QPointer<OBSMissingFiles> missDialog;
QPointer<OBSLogViewer> logView;
Expand Down Expand Up @@ -631,7 +637,8 @@ class OBSBasic : public OBSMainWindow {
#ifdef YOUTUBE_ENABLED
void YoutubeStreamCheck(const std::string &key);
void ShowYouTubeAutoStartWarning();
void YouTubeActionDialogOk(const QString &id, const QString &key,
void YouTubeActionDialogOk(const QString &broadcast_id,
const QString &stream_id, const QString &key,
bool autostart, bool autostop,
bool start_now);
#endif
Expand Down Expand Up @@ -1253,6 +1260,11 @@ public slots:
const char *file) const override;

static void InitBrowserPanelSafeBlock();
#ifdef YOUTUBE_ENABLED
void NewYouTubeAppDock();
void DeleteYouTubeAppDock();
YouTubeAppDock *GetYouTubeAppDock();
#endif
};

class SceneRenameDelegate : public QStyledItemDelegate {
Expand Down
18 changes: 18 additions & 0 deletions UI/window-basic-settings-stream.cpp
Expand Up @@ -770,6 +770,14 @@ void OBSBasicSettings::on_connectAccount_clicked()
auth = OAuthStreamKey::Login(this, service);
if (!!auth) {
OnAuthConnected();
#ifdef YOUTUBE_ENABLED
if (IsYouTubeService(service)) {
if (!main->GetYouTubeAppDock()) {
main->NewYouTubeAppDock();
}
main->GetYouTubeAppDock()->AccountConnected();
}
#endif

ui->useStreamKeyAdv->setVisible(false);
}
Expand Down Expand Up @@ -812,6 +820,16 @@ void OBSBasicSettings::on_disconnectAccount_clicked()

ui->connectedAccountLabel->setVisible(false);
ui->connectedAccountText->setVisible(false);

#ifdef YOUTUBE_ENABLED
if (IsYouTubeService(service)) {
if (!main->GetYouTubeAppDock()) {
main->NewYouTubeAppDock();
}
main->GetYouTubeAppDock()->AccountDisconnected();
main->GetYouTubeAppDock()->Update();
}
#endif
}

void OBSBasicSettings::on_useStreamKey_clicked()
Expand Down
20 changes: 20 additions & 0 deletions UI/window-basic-settings.cpp
Expand Up @@ -48,6 +48,10 @@
#include "window-basic-main-outputs.hpp"
#include "window-projector.hpp"

#ifdef YOUTUBE_ENABLED
#include "youtube-api-wrappers.hpp"
#endif

#include <util/platform.h>
#include <util/dstr.hpp>
#include "ui-config.h"
Expand Down Expand Up @@ -4251,6 +4255,22 @@ void OBSBasicSettings::on_buttonBox_clicked(QAbstractButton *button)
return;

SaveSettings();

#ifdef YOUTUBE_ENABLED
std::string service = ui->service->currentText().toStdString();
if (IsYouTubeService(service)) {
if (!main->GetYouTubeAppDock()) {
main->NewYouTubeAppDock();
}
main->GetYouTubeAppDock()->SettingsUpdated(
!IsYouTubeService(service) || stream1Changed);
} else {
if (main->GetYouTubeAppDock()) {
main->GetYouTubeAppDock()->AccountDisconnected();
}
main->DeleteYouTubeAppDock();
}
#endif
ClearChanged();
}

Expand Down

0 comments on commit 81b5881

Please sign in to comment.