Skip to content

Commit 1a90d52

Browse files
Release/1.0.0 rc4 (#15)
* Handle invalid login URL error. * Update auth process to use correct production auth url. * Update import wizard to create/destroy video capture source.
1 parent acc65c5 commit 1a90d52

File tree

8 files changed

+75
-26
lines changed

8 files changed

+75
-26
lines changed

buildspec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"versionMinor": 0,
4343
"versionPatch": 0,
4444
"buildNumber": 123,
45-
"releaseType": "rc3",
45+
"releaseType": "rc4",
4646
"author": "Elgato",
4747
"website": "https://elgato.com",
4848
"email": "support@elgato.com",

src/api.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ std::mutex MarketplaceApi::_mtx;
3434

3535
MarketplaceApi::MarketplaceApi()
3636
: _gatewayUrl(DEFAULT_GATEWAY_URL),
37-
_apiUrl(DEFAULT_API_URL),
38-
_storeUrl(DEFAULT_STORE_URL)
37+
_authUrl(DEFAULT_AUTH_URL),
38+
_storeUrl(DEFAULT_STORE_URL),
39+
_loggedIn(false)
3940
{
4041
std::string dataPath = obs_get_module_data_path(obs_current_module());
4142
dataPath += "/" + std::string(API_URLS_FILE);
@@ -44,7 +45,7 @@ MarketplaceApi::MarketplaceApi()
4445
try {
4546
json data = json::parse(f);
4647
_gatewayUrl = data.at("gateway_url");
47-
_apiUrl = data.at("api_url");
48+
_authUrl = data.at("auth_url");
4849
_storeUrl = data.at("store_url");
4950
obs_log(LOG_INFO, "Url file loaded.");
5051
} catch (...) {
@@ -55,7 +56,7 @@ MarketplaceApi::MarketplaceApi()
5556
obs_log(LOG_INFO, "No url file found.");
5657
}
5758
obs_log(LOG_INFO, "Gateway Url: %s", _gatewayUrl.c_str());
58-
obs_log(LOG_INFO, "API Url: %s", _apiUrl.c_str());
59+
obs_log(LOG_INFO, "Auth Url: %s", _authUrl.c_str());
5960
obs_log(LOG_INFO, "Store Url: %s", _storeUrl.c_str());
6061
}
6162

src/api.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
2222
#include <nlohmann/json.hpp>
2323

2424
#define DEFAULT_GATEWAY_URL "https://mp-gateway.elgato.com"
25-
#define DEFAULT_API_URL "https://mp.elgato.com"
2625
#define DEFAULT_STORE_URL "https://marketplace.elgato.com"
26+
#define DEFAULT_AUTH_URL "https://account.elgato.com"
2727
#define API_URLS_FILE "api-urls.json"
2828

2929
namespace elgatocloud {
@@ -37,8 +37,8 @@ class MarketplaceApi {
3737
public:
3838
static MarketplaceApi *getInstance();
3939
inline std::string gatewayUrl() const { return _gatewayUrl; }
40-
inline std::string apiUrl() const { return _apiUrl; }
4140
inline std::string storeUrl() const { return _storeUrl; }
41+
inline std::string authUrl() const { return _authUrl; }
4242
inline std::string firstName() const { return _firstName; }
4343
inline std::string lastName() const { return _lastName; }
4444
inline std::string avatarColor() const { return _avatarColor; }
@@ -50,8 +50,8 @@ class MarketplaceApi {
5050
MarketplaceApi(const MarketplaceApi &cpy) = delete;
5151

5252
std::string _gatewayUrl;
53-
std::string _apiUrl;
5453
std::string _storeUrl;
54+
std::string _authUrl;
5555
bool _loggedIn;
5656
std::string _firstName;
5757
std::string _lastName;

src/elgato-cloud-config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ DefaultAVWidget::~DefaultAVWidget()
241241
}
242242
if (_videoCaptureSource) {
243243
obs_source_release(_videoCaptureSource);
244-
obs_source_remove(_videoCaptureSource);
244+
//obs_source_remove(_videoCaptureSource);
245245
}
246246
_levelsWidget = nullptr;
247247
}

src/elgato-cloud-data.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,27 @@ void ElgatoCloud::_TokenRefresh(bool loadData, bool loadUserDetails)
114114
encodeddata += "grant_type=refresh_token";
115115
encodeddata += "&refresh_token=" + _refreshToken;
116116
encodeddata += "&client_id=elgatolink";
117-
std::string url = api->gatewayUrl();
117+
std::string url = api->authUrl();
118118
url += "/auth/realms/mp/protocol/openid-connect/token?";
119119
url += encodeddata;
120120
obs_log(LOG_INFO, "Token Refresh Called");
121121
auto response = fetch_string_from_post(url, encodeddata);
122-
auto responseJson = nlohmann::json::parse(response);
123-
_ProcessLogin(responseJson, loadData);
122+
try {
123+
auto responseJson = nlohmann::json::parse(response);
124+
_ProcessLogin(responseJson, loadData);
125+
} catch (...) {
126+
loggedIn = false;
127+
loading = false;
128+
authorizing = false;
129+
loginError = true;
130+
if (mainWindowOpen && window) {
131+
QMetaObject::invokeMethod(
132+
QCoreApplication::instance()->thread(),
133+
[this]() {
134+
window->setLoggedIn();
135+
});
136+
}
137+
}
124138
}
125139

126140
void ElgatoCloud::_Listen()
@@ -174,7 +188,7 @@ void ElgatoCloud::_Listen()
174188
encodeddata += "&client_id=elgatolink";
175189

176190
auto api = MarketplaceApi::getInstance();
177-
std::string url = api->gatewayUrl();
191+
std::string url = api->authUrl();
178192

179193
url += "/auth/realms/mp/protocol/openid-connect/token?";
180194
url += encodeddata;
@@ -247,7 +261,7 @@ void ElgatoCloud::StartLogin()
247261

248262
auto api = MarketplaceApi::getInstance();
249263
std::string url =
250-
api->gatewayUrl() +
264+
api->authUrl() +
251265
"/auth/realms/mp/protocol/openid-connect/auth?response_type=code&client_id=elgatolink&redirect_uri=https%3A%2F%2Foauth2-redirect.elgato.com%2Felgatolink%2Fauth&code_challenge=" +
252266
stringhash + "&code_challenge_method=S256";
253267

src/elgato-widgets.cpp

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ VideoCaptureSourceSelector::VideoCaptureSourceSelector(QWidget *parent,
3939
obs_data_t *videoData)
4040
: QWidget(parent),
4141
_sourceName(sourceName),
42-
_noneSelected(true)
42+
_noneSelected(true),
43+
_deactivated(false)
4344
{
4445
std::string imageBaseDir =
4546
obs_get_module_data_path(obs_current_module());
4647
imageBaseDir += "/images/";
4748

4849
setFixedWidth(258);
50+
_loading = true;
4951

5052
auto layout = new QVBoxLayout(this);
5153
layout->setContentsMargins(0, 0, 0, 16);
@@ -90,22 +92,17 @@ VideoCaptureSourceSelector::VideoCaptureSourceSelector(QWidget *parent,
9092

9193
connect(_videoSources, &QComboBox::currentIndexChanged, this,
9294
[this](int index) {
95+
_loading = true;
9396
if (index > 0) {
9497
auto vSettings = obs_data_create();
9598
std::string id = _videoSourceIds[index];
9699
obs_data_set_string(vSettings,
97-
"video_device_id",
98-
id.c_str());
99-
obs_source_reset_settings(_videoCaptureSource,
100-
vSettings);
100+
"video_device_id",
101+
id.c_str());
102+
_changeSource(vSettings);
101103
obs_data_release(vSettings);
102-
this->_noneSelected = false;
103-
this->_videoPreview->show();
104-
this->_blank->hide();
105104
} else {
106-
this->_noneSelected = true;
107-
this->_videoPreview->hide();
108-
this->_blank->show();
105+
_changeSource(nullptr);
109106
}
110107
});
111108
}
@@ -163,11 +160,44 @@ void VideoCaptureSourceSelector::_setupTempSource(obs_data_t *videoData)
163160
//obs_data_release(videoSettings);
164161
}
165162

163+
void VideoCaptureSourceSelector::_changeSource(obs_data_t *vSettings)
164+
{
165+
if (vSettings != nullptr) {
166+
blog(LOG_INFO, "_changeSource called.");
167+
if (_videoCaptureSource) {
168+
obs_source_t* tmp = _videoCaptureSource;
169+
_videoCaptureSource = nullptr;
170+
obs_source_release(tmp);
171+
}
172+
173+
const char* videoSourceId = "dshow_input";
174+
const char* vId = obs_get_latest_input_type_id(videoSourceId);
175+
_videoCaptureSource = obs_source_create_private(
176+
vId, "elgato-cloud-video-config", vSettings);
177+
178+
this->_noneSelected = false;
179+
this->_videoPreview->show();
180+
this->_blank->hide();
181+
} else {
182+
this->_noneSelected = true;
183+
this->_videoPreview->hide();
184+
this->_blank->show();
185+
if (_videoCaptureSource) {
186+
obs_source_t* tmp = _videoCaptureSource;
187+
_videoCaptureSource = nullptr;
188+
obs_source_release(tmp);
189+
}
190+
}
191+
192+
}
193+
166194
void VideoCaptureSourceSelector::DrawVideoPreview(void *data, uint32_t cx,
167195
uint32_t cy)
168196
{
169197
auto config = static_cast<VideoCaptureSourceSelector *>(data);
170-
198+
if (config->_loading) {
199+
config->_loading = false;
200+
}
171201
if (!config->_videoCaptureSource)
172202
return;
173203

src/elgato-widgets.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ class VideoCaptureSourceSelector : public QWidget {
5252
std::vector<std::string> _videoSourceIds;
5353
std::string _sourceName;
5454
void _setupTempSource(obs_data_t *videoData);
55+
void _changeSource(obs_data_t* vSettings);
5556
bool _noneSelected;
57+
bool _loading;
58+
bool _deactivated;
5659
};
5760

5861
class ProgressSpinner : public QWidget {

src/setup-wizard.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ void StreamPackageSetupWizard::_buildSetupUI(
902902
connect(aSetup, &AudioSetup::proceedPressed, this,
903903
[this](std::string settings) {
904904
_setup.audioSettings = settings;
905+
// Nuke the video preview window
905906
install();
906907
});
907908
connect(aSetup, &AudioSetup::backPressed, this,

0 commit comments

Comments
 (0)