All these fixes are interlinked but to explain them further: Event selection would only partially work, the code to re-use an existing liveStream was never hit and so didn't work. It would also break going live because broadcast_id would never be set. Additionally it called StartBroadcast for no reason if autostart was enabled. API usage was unoptimal. Instead of only fetching the events we need (active, ready) it would fetch *every single livestream* on the youtube channel, 7 at a time, and then throw away every single result in the majority of use cases. This commit changes it to only fetch "active" and "ready" broadcasts and then only filters out active ones that cannot be resumed (because they're stil live). Resuming existing streams also didn't work because they were just thrown out by the selection. Now they get included if the attached liveStream is not receiving data. The're distinguished in the UI and are listed first. Simply selecting them and starting the stream will work. These's still some stuff left, like redundant API calls. But thankfully those fail silently and we can simply ignore it for now.
70 lines
1.5 KiB
C++
70 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <QDialog>
|
|
#include <QString>
|
|
#include <QThread>
|
|
|
|
#include "ui_OBSYoutubeActions.h"
|
|
#include "youtube-api-wrappers.hpp"
|
|
|
|
class WorkerThread : public QThread {
|
|
Q_OBJECT
|
|
public:
|
|
WorkerThread(YoutubeApiWrappers *api) : QThread(), apiYouTube(api) {}
|
|
|
|
void stop() { pending = false; }
|
|
|
|
protected:
|
|
YoutubeApiWrappers *apiYouTube;
|
|
bool pending = true;
|
|
|
|
public slots:
|
|
void run() override;
|
|
signals:
|
|
void ready();
|
|
void new_item(const QString &title, const QString &dateTimeString,
|
|
const QString &broadcast, const QString &status,
|
|
bool astart, bool astop);
|
|
void failed();
|
|
};
|
|
|
|
class OBSYoutubeActions : public QDialog {
|
|
Q_OBJECT
|
|
|
|
std::unique_ptr<Ui::OBSYoutubeActions> ui;
|
|
|
|
signals:
|
|
void ok(const QString &id, const QString &key, bool autostart,
|
|
bool autostop);
|
|
|
|
protected:
|
|
void UpdateOkButtonStatus();
|
|
|
|
bool StreamNowAction(YoutubeApiWrappers *api,
|
|
StreamDescription &stream);
|
|
bool StreamLaterAction(YoutubeApiWrappers *api);
|
|
bool ChooseAnEventAction(YoutubeApiWrappers *api,
|
|
StreamDescription &stream);
|
|
|
|
void ShowErrorDialog(QWidget *parent, QString text);
|
|
|
|
public:
|
|
explicit OBSYoutubeActions(QWidget *parent, Auth *auth);
|
|
virtual ~OBSYoutubeActions() override;
|
|
|
|
bool Valid() { return valid; };
|
|
|
|
private:
|
|
void InitBroadcast();
|
|
void UiToBroadcast(BroadcastDescription &broadcast);
|
|
void OpenYouTubeDashboard();
|
|
void Cancel();
|
|
void Accept();
|
|
|
|
QString selectedBroadcast;
|
|
bool autostart, autostop;
|
|
bool valid = false;
|
|
YoutubeApiWrappers *apiYouTube;
|
|
WorkerThread *workerThread;
|
|
};
|