UI: Remove Mixer integration

master
derrod 2020-06-22 22:02:37 +02:00
parent 1fed223195
commit db37cc34d5
10 changed files with 15 additions and 431 deletions

View File

@ -29,16 +29,6 @@ else()
set(TWITCH_ENABLED TRUE)
endif()
if(NOT DEFINED MIXER_CLIENTID OR "${MIXER_CLIENTID}" STREQUAL "" OR
NOT DEFINED MIXER_HASH OR "${MIXER_HASH}" STREQUAL "" OR
NOT BROWSER_AVAILABLE_INTERNAL)
set(MIXER_ENABLED FALSE)
set(MIXER_CLIENTID "")
set(MIXER_HASH "0")
else()
set(MIXER_ENABLED TRUE)
endif()
if(NOT DEFINED RESTREAM_CLIENTID OR "${RESTREAM_CLIENTID}" STREQUAL "" OR
NOT DEFINED RESTREAM_HASH OR "${RESTREAM_HASH}" STREQUAL "" OR
NOT BROWSER_AVAILABLE_INTERNAL)
@ -166,15 +156,6 @@ if(BROWSER_AVAILABLE_INTERNAL)
)
endif()
if(MIXER_ENABLED)
list(APPEND obs_PLATFORM_SOURCES
auth-mixer.cpp
)
list(APPEND obs_PLATFORM_HEADERS
auth-mixer.hpp
)
endif()
if(RESTREAM_ENABLED)
list(APPEND obs_PLATFORM_SOURCES
auth-restream.cpp

View File

@ -1,313 +0,0 @@
#include "auth-mixer.hpp"
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <qt-wrappers.hpp>
#include <obs-app.hpp>
#include "window-dock-browser.hpp"
#include "window-basic-main.hpp"
#include "remote-text.hpp"
#include <json11.hpp>
#include <ctime>
#include "ui-config.h"
#include "obf.h"
using namespace json11;
/* ------------------------------------------------------------------------- */
#define MIXER_AUTH_URL "https://obsproject.com/app-auth/mixer?action=redirect"
#define MIXER_TOKEN_URL "https://obsproject.com/app-auth/mixer-token"
#define MIXER_SCOPE_VERSION 1
static Auth::Def mixerDef = {"Mixer", Auth::Type::OAuth_StreamKey};
/* ------------------------------------------------------------------------- */
MixerAuth::MixerAuth(const Def &d) : OAuthStreamKey(d) {}
bool MixerAuth::GetChannelInfo(bool allow_retry)
try {
std::string client_id = MIXER_CLIENTID;
deobfuscate_str(&client_id[0], MIXER_HASH);
if (!GetToken(MIXER_TOKEN_URL, client_id, MIXER_SCOPE_VERSION))
return false;
if (token.empty())
return false;
if (!key_.empty())
return true;
std::string auth;
auth += "Authorization: Bearer ";
auth += token;
std::vector<std::string> headers;
headers.push_back(std::string("Client-ID: ") + client_id);
headers.push_back(std::move(auth));
std::string output;
std::string error;
Json json;
bool success;
if (id.empty()) {
auto func = [&]() {
success = GetRemoteFile(
"https://mixer.com/api/v1/users/current",
output, error, nullptr, "application/json",
nullptr, headers, nullptr, 5);
};
ExecThreadedWithoutBlocking(
func, QTStr("Auth.LoadingChannel.Title"),
QTStr("Auth.LoadingChannel.Text").arg(service()));
if (!success || output.empty())
throw ErrorInfo("Failed to get user info from remote",
error);
Json json = Json::parse(output, error);
if (!error.empty())
throw ErrorInfo("Failed to parse json", error);
error = json["error"].string_value();
if (!error.empty())
throw ErrorInfo(
error,
json["error_description"].string_value());
id = std::to_string(json["channel"]["id"].int_value());
name = json["channel"]["token"].string_value();
}
/* ------------------ */
std::string url;
url += "https://mixer.com/api/v1/channels/";
url += id;
url += "/details";
output.clear();
auto func = [&]() {
success = GetRemoteFile(url.c_str(), output, error, nullptr,
"application/json", nullptr, headers,
nullptr, 5);
};
ExecThreadedWithoutBlocking(
func, QTStr("Auth.LoadingChannel.Title"),
QTStr("Auth.LoadingChannel.Text").arg(service()));
if (!success || output.empty())
throw ErrorInfo("Failed to get stream key from remote", error);
json = Json::parse(output, error);
if (!error.empty())
throw ErrorInfo("Failed to parse json", error);
error = json["error"].string_value();
if (!error.empty())
throw ErrorInfo(error,
json["error_description"].string_value());
std::string key_suffix = json["streamKey"].string_value();
/* Mixer does not throw an error; instead it gives you the channel data
* json without the data you normally have privileges for, which means
* it'll be an empty stream key usually. So treat empty stream key as
* an error. */
if (key_suffix.empty()) {
if (allow_retry && RetryLogin()) {
return GetChannelInfo(false);
}
throw ErrorInfo("Auth Failure", "Could not get channel data");
}
key_ = id + "-" + key_suffix;
return true;
} catch (ErrorInfo info) {
QString title = QTStr("Auth.ChannelFailure.Title");
QString text = QTStr("Auth.ChannelFailure.Text")
.arg(service(), info.message.c_str(),
info.error.c_str());
QMessageBox::warning(OBSBasic::Get(), title, text);
blog(LOG_WARNING, "%s: %s: %s", __FUNCTION__, info.message.c_str(),
info.error.c_str());
return false;
}
void MixerAuth::SaveInternal()
{
OBSBasic *main = OBSBasic::Get();
config_set_string(main->Config(), service(), "Name", name.c_str());
config_set_string(main->Config(), service(), "Id", id.c_str());
if (uiLoaded) {
config_set_string(main->Config(), service(), "DockState",
main->saveState().toBase64().constData());
}
OAuthStreamKey::SaveInternal();
}
static inline std::string get_config_str(OBSBasic *main, const char *section,
const char *name)
{
const char *val = config_get_string(main->Config(), section, name);
return val ? val : "";
}
bool MixerAuth::LoadInternal()
{
if (!cef)
return false;
OBSBasic *main = OBSBasic::Get();
name = get_config_str(main, service(), "Name");
id = get_config_str(main, service(), "Id");
firstLoad = false;
return OAuthStreamKey::LoadInternal();
}
static const char *elixr_script = "\
var elixr = document.createElement('script');\
elixr.setAttribute('src','https://api.mixrelixr.com/scripts/elixr-emotes-embedded-chat.bundle.js');\
document.head.appendChild(elixr);";
void MixerAuth::LoadUI()
{
if (!cef)
return;
if (uiLoaded)
return;
if (!GetChannelInfo())
return;
OBSBasic::InitBrowserPanelSafeBlock();
OBSBasic *main = OBSBasic::Get();
std::string script = "";
std::string url;
url += "https://mixer.com/embed/chat/";
url += id;
QSize size = main->frameSize();
QPoint pos = main->pos();
chat.reset(new BrowserDock());
chat->setObjectName("mixerChat");
chat->resize(300, 600);
chat->setMinimumSize(200, 300);
chat->setWindowTitle(QTStr("Auth.Chat"));
chat->setAllowedAreas(Qt::AllDockWidgetAreas);
QCefWidget *browser = cef->create_widget(nullptr, url, panel_cookies);
chat->SetWidget(browser);
const int mxAddonChoice =
config_get_int(main->Config(), service(), "AddonChoice");
if (mxAddonChoice) {
if (mxAddonChoice & 0x1)
script += elixr_script;
}
browser->setStartupScript(script);
main->addDockWidget(Qt::RightDockWidgetArea, chat.data());
chatMenu.reset(main->AddDockWidget(chat.data()));
/* ----------------------------------- */
chat->setFloating(true);
chat->move(pos.x() + size.width() - chat->width() - 50, pos.y() + 50);
if (firstLoad) {
chat->setVisible(true);
} else {
const char *dockStateStr = config_get_string(
main->Config(), service(), "DockState");
QByteArray dockState =
QByteArray::fromBase64(QByteArray(dockStateStr));
main->restoreState(dockState);
}
uiLoaded = true;
}
bool MixerAuth::RetryLogin()
{
if (!cef)
return false;
OAuthLogin login(OBSBasic::Get(), MIXER_AUTH_URL, false);
cef->add_popup_whitelist_url("about:blank", &login);
if (login.exec() == QDialog::Rejected) {
return false;
}
std::shared_ptr<MixerAuth> auth = std::make_shared<MixerAuth>(mixerDef);
std::string client_id = MIXER_CLIENTID;
deobfuscate_str(&client_id[0], MIXER_HASH);
return GetToken(MIXER_TOKEN_URL, client_id, MIXER_SCOPE_VERSION,
QT_TO_UTF8(login.GetCode()), true);
}
std::shared_ptr<Auth> MixerAuth::Login(QWidget *parent)
{
if (!cef) {
return nullptr;
}
OAuthLogin login(parent, MIXER_AUTH_URL, false);
cef->add_popup_whitelist_url("about:blank", &login);
if (login.exec() == QDialog::Rejected) {
return nullptr;
}
std::shared_ptr<MixerAuth> auth = std::make_shared<MixerAuth>(mixerDef);
std::string client_id = MIXER_CLIENTID;
deobfuscate_str(&client_id[0], MIXER_HASH);
if (!auth->GetToken(MIXER_TOKEN_URL, client_id, MIXER_SCOPE_VERSION,
QT_TO_UTF8(login.GetCode()))) {
return nullptr;
}
std::string error;
if (auth->GetChannelInfo(false)) {
return auth;
}
return nullptr;
}
static std::shared_ptr<Auth> CreateMixerAuth()
{
return std::make_shared<MixerAuth>(mixerDef);
}
static void DeleteCookies()
{
if (panel_cookies) {
panel_cookies->DeleteCookies("mixer.com", std::string());
panel_cookies->DeleteCookies("microsoft.com", std::string());
}
}
void RegisterMixerAuth()
{
OAuth::RegisterOAuth(mixerDef, CreateMixerAuth, MixerAuth::Login,
DeleteCookies);
}

View File

@ -1,30 +0,0 @@
#pragma once
#include "auth-oauth.hpp"
class BrowserDock;
class MixerAuth : public OAuthStreamKey {
Q_OBJECT
QSharedPointer<BrowserDock> chat;
QSharedPointer<QAction> chatMenu;
bool uiLoaded = false;
std::string name;
std::string id;
virtual bool RetryLogin() override;
virtual void SaveInternal() override;
virtual bool LoadInternal() override;
bool GetChannelInfo(bool allow_retry = true);
virtual void LoadUI() override;
public:
MixerAuth(const Def &d);
static std::shared_ptr<Auth> Login(QWidget *parent);
};

View File

@ -689,9 +689,6 @@ Basic.Settings.Stream.TTVAddon.None="None"
Basic.Settings.Stream.TTVAddon.BTTV="BetterTTV"
Basic.Settings.Stream.TTVAddon.FFZ="FrankerFaceZ"
Basic.Settings.Stream.TTVAddon.Both="BetterTTV and FrankerFaceZ"
Basic.Settings.Stream.MixerAddon="Mixer Chat Add-Ons"
Basic.Settings.Stream.MixerAddon.None="None"
Basic.Settings.Stream.MixerAddon.MEE="MixrElixr Emotes"
Basic.Settings.Stream.MissingSettingAlert="Missing Stream Setup"
Basic.Settings.Stream.StreamSettingsWarning="Open Settings"
Basic.Settings.Stream.MissingUrlAndApiKey="URL and Stream Key are missing.\n\nOpen settings to enter the URL and Stream Key in the 'stream' tab."
@ -833,7 +830,7 @@ Basic.Settings.Audio.PeakMeterType="Peak Meter Type"
Basic.Settings.Audio.PeakMeterType.SamplePeak="Sample Peak"
Basic.Settings.Audio.PeakMeterType.TruePeak="True Peak (Higher CPU usage)"
Basic.Settings.Audio.MultiChannelWarning.Enabled="WARNING: Surround sound audio is enabled."
Basic.Settings.Audio.MultichannelWarning="If streaming, check to see if your streaming service supports both surround sound ingest and surround sound playback. Facebook 360 Live, Mixer RTMP, Smashcast are examples where surround sound is fully supported. Although Facebook Live and YouTube Live both accept surround ingest, Facebook Live downmixes to stereo, and YouTube Live plays only two channels.\n\nOBS audio filters are compatible with surround sound, though VST plugin support isn't guaranteed."
Basic.Settings.Audio.MultichannelWarning="If streaming, check to see if your streaming service supports both surround sound ingest and surround sound playback. Facebook 360 Live is one example where surround sound is fully supported. Although Facebook Live and YouTube Live both accept surround ingest, Facebook Live downmixes to stereo, and YouTube Live plays only two channels.\n\nOBS audio filters are compatible with surround sound, though VST plugin support isn't guaranteed."
Basic.Settings.Audio.MultichannelWarning.Title="Enable surround sound audio?"
Basic.Settings.Audio.MultichannelWarning.Confirm="Are you sure you want to enable surround sound audio?"
Basic.Settings.Audio.Devices="Global Audio Devices"

View File

@ -151,8 +151,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<height>1026</height>
<width>806</width>
<height>1254</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_19">
@ -1146,7 +1146,7 @@
</property>
</widget>
</item>
<item row="9" column="0">
<item row="8" column="0">
<widget class="QLabel" name="authUsernameLabel">
<property name="text">
<string>Basic.Settings.Stream.Custom.Username</string>
@ -1156,10 +1156,10 @@
</property>
</widget>
</item>
<item row="9" column="1">
<item row="8" column="1">
<widget class="QLineEdit" name="authUsername"/>
</item>
<item row="10" column="0">
<item row="9" column="0">
<widget class="QLabel" name="authPwLabel">
<property name="text">
<string>Basic.Settings.Stream.Custom.Password</string>
@ -1169,7 +1169,7 @@
</property>
</widget>
</item>
<item row="10" column="1">
<item row="9" column="1">
<widget class="QWidget" name="authPwWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_25">
<property name="leftMargin">
@ -1214,19 +1214,6 @@
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="mixerAddonLabel">
<property name="text">
<string>Basic.Settings.Stream.MixerAddon</string>
</property>
<property name="buddy">
<cstring>mixerAddonDropdown</cstring>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QComboBox" name="mixerAddonDropdown"/>
</item>
</layout>
</widget>
</widget>
@ -1263,8 +1250,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>603</width>
<height>631</height>
<width>813</width>
<height>761</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
@ -3758,8 +3745,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>555</width>
<height>469</height>
<width>767</width>
<height>582</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_50">
@ -4614,8 +4601,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>596</width>
<height>781</height>
<width>791</width>
<height>970</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_23">

View File

@ -20,10 +20,6 @@
#define TWITCH_CLIENTID "@TWITCH_CLIENTID@"
#define TWITCH_HASH 0x@TWITCH_HASH@
#define MIXER_ENABLED @MIXER_ENABLED@
#define MIXER_CLIENTID "@MIXER_CLIENTID@"
#define MIXER_HASH 0x@MIXER_HASH@
#define RESTREAM_ENABLED @RESTREAM_ENABLED@
#define RESTREAM_CLIENTID "@RESTREAM_CLIENTID@"
#define RESTREAM_HASH 0x@RESTREAM_HASH@

View File

@ -250,8 +250,8 @@ void AutoConfigTestPage::TestBandwidthThread()
GetServers(servers);
/* just use the first server if it only has one alternate server,
* or if using Mixer or Restream due to their "auto" servers */
if (servers.size() < 3 || wiz->serviceName == "Mixer.com - FTL" ||
* or if using Restream due to their "auto" servers */
if (servers.size() < 3 ||
wiz->serviceName.substr(0, 11) == "Restream.io") {
servers.resize(1);

View File

@ -185,7 +185,6 @@ void assignDockToggle(QDockWidget *dock, QAction *action)
}
extern void RegisterTwitchAuth();
extern void RegisterMixerAuth();
extern void RegisterRestreamAuth();
OBSBasic::OBSBasic(QWidget *parent)
@ -199,9 +198,6 @@ OBSBasic::OBSBasic(QWidget *parent)
#if TWITCH_ENABLED
RegisterTwitchAuth();
#endif
#if MIXER_ENABLED
RegisterMixerAuth();
#endif
#if RESTREAM_ENABLED
RegisterRestreamAuth();
#endif

View File

@ -41,8 +41,6 @@ void OBSBasicSettings::InitStreamPage()
ui->bandwidthTestEnable->setVisible(false);
ui->twitchAddonDropdown->setVisible(false);
ui->twitchAddonLabel->setVisible(false);
ui->mixerAddonDropdown->setVisible(false);
ui->mixerAddonLabel->setVisible(false);
int vertSpacing = ui->topStreamLayout->verticalSpacing();
@ -69,11 +67,6 @@ void OBSBasicSettings::InitStreamPage()
ui->twitchAddonDropdown->addItem(
QTStr("Basic.Settings.Stream.TTVAddon.Both"));
ui->mixerAddonDropdown->addItem(
QTStr("Basic.Settings.Stream.MixerAddon.None"));
ui->mixerAddonDropdown->addItem(
QTStr("Basic.Settings.Stream.MixerAddon.MEE"));
connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
SLOT(UpdateServerList()));
connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
@ -119,9 +112,6 @@ void OBSBasicSettings::LoadStream1Settings()
idx = config_get_int(main->Config(), "Twitch", "AddonChoice");
ui->twitchAddonDropdown->setCurrentIndex(idx);
idx = config_get_int(main->Config(), "Mixer", "AddonChoice");
ui->mixerAddonDropdown->setCurrentIndex(idx);
}
UpdateServerList();
@ -199,19 +189,6 @@ void OBSBasicSettings::SaveStream1Settings()
if (choiceExists && currentChoice != newChoice)
forceAuthReload = true;
}
if (!!auth && strcmp(auth->service(), "Mixer") == 0) {
bool choiceExists = config_has_user_value(
main->Config(), "Mixer", "AddonChoice");
int currentChoice =
config_get_int(main->Config(), "Mixer", "AddonChoice");
int newChoice = ui->mixerAddonDropdown->currentIndex();
config_set_int(main->Config(), "Mixer", "AddonChoice",
newChoice);
if (choiceExists && currentChoice != newChoice)
forceAuthReload = true;
}
obs_data_set_string(settings, "key", QT_TO_UTF8(ui->key->text()));
@ -335,8 +312,6 @@ void OBSBasicSettings::on_service_currentIndexChanged(int)
ui->bandwidthTestEnable->setVisible(false);
ui->twitchAddonDropdown->setVisible(false);
ui->twitchAddonLabel->setVisible(false);
ui->mixerAddonDropdown->setVisible(false);
ui->mixerAddonLabel->setVisible(false);
#ifdef BROWSER_AVAILABLE
if (cef) {
@ -495,10 +470,6 @@ void OBSBasicSettings::OnOAuthStreamKeyConnected()
ui->twitchAddonLabel->setVisible(true);
ui->twitchAddonDropdown->setVisible(true);
}
if (strcmp(a->service(), "Mixer") == 0) {
ui->mixerAddonLabel->setVisible(true);
ui->mixerAddonDropdown->setVisible(true);
}
}
ui->streamStackWidget->setCurrentIndex((int)Section::StreamKey);

View File

@ -423,7 +423,6 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
HookWidget(ui->key, EDIT_CHANGED, STREAM1_CHANGED);
HookWidget(ui->bandwidthTestEnable, CHECK_CHANGED, STREAM1_CHANGED);
HookWidget(ui->twitchAddonDropdown, COMBO_CHANGED, STREAM1_CHANGED);
HookWidget(ui->mixerAddonDropdown, COMBO_CHANGED, STREAM1_CHANGED);
HookWidget(ui->useAuth, CHECK_CHANGED, STREAM1_CHANGED);
HookWidget(ui->authUsername, EDIT_CHANGED, STREAM1_CHANGED);
HookWidget(ui->authPw, EDIT_CHANGED, STREAM1_CHANGED);