Skip to content

Commit f3d272b

Browse files
Merge pull request #26 from elgatosf/bugfixes/pre-1.0.0-fixes
Bugfixes/pre 1.0.0 fixes
2 parents 8ca132f + 3398182 commit f3d272b

File tree

10 files changed

+229
-11
lines changed

10 files changed

+229
-11
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": 0,
45-
"releaseType": "rc9",
45+
"releaseType": "rc11",
4646
"author": "Elgato",
4747
"website": "https://elgato.com",
4848
"email": "support@elgato.com",

data/locale/en-US.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ MarketplaceWindow.LoginNeeded.Subtitle="First off, let's connect your Marketplac
1515
MarketplaceWindow.LoginError.Title="Sign in"
1616
MarketplaceWindow.LoginError.Subtitle="There was an issue signing you in. Please try signing in again to continue."
1717
MarketplaceWindow.LoggingIn.Title="Signing you in"
18-
MarketplaceWindow.LoggingIn.Subtitle="Please sign in using the browser window that should have appeared. If no browser window appeared, or you accidentally closed it, click below to try again."
18+
MarketplaceWindow.LoggingIn.Subtitle="Use the new browser window to sign into your account, or select Try again to reopen"
1919
MarketplaceWindow.LoggingIn.TryAgain="Try again"
2020
MarketplaceWindow.ConnectionError.Title="Connection error"
2121
MarketplaceWindow.ConnectionError.Subtitle="Could not connect to the server. (please check your network connection)"

data/plugins.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"name": "obs-shaderfilter",
2626
"url": "https://obsproject.com/forum/resources/obs-shaderfilter.1736/",
2727
"files" :[
28-
"obs-shaderfilter"
28+
"obs-shaderfilter.dll"
2929
]
3030
},
3131
{

src/elgato-cloud-config.cpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,16 @@ void SimpleVolumeMeter::paintEvent(QPaintEvent *event)
459459

460460
ElgatoCloudConfig::ElgatoCloudConfig(QWidget *parent) : QDialog(parent)
461461
{
462+
463+
// Disable all video capture sources so that single-thread
464+
// capture sources, such as the Elgato Facecam, can be properly
465+
// selected in the wizard. Will re-enable any disabled sources
466+
// in the wizard destructor.
467+
obs_enum_sources(
468+
&ElgatoCloudConfig::
469+
DisableVideoCaptureSources,
470+
this);
471+
462472
configWindow = this;
463473
std::string imageBaseDir = GetDataPath();
464474
imageBaseDir += "/images/";
@@ -603,6 +613,50 @@ ElgatoCloudConfig::ElgatoCloudConfig(QWidget *parent) : QDialog(parent)
603613
obs_data_release(config);
604614
}
605615

616+
bool ElgatoCloudConfig::DisableVideoCaptureSources(void* data,
617+
obs_source_t* source)
618+
{
619+
auto config = static_cast<ElgatoCloudConfig*>(data);
620+
std::string sourceType = obs_source_get_id(source);
621+
if (sourceType == "dshow_input") {
622+
auto settings = obs_source_get_settings(source);
623+
bool active = obs_data_get_bool(settings, "active");
624+
obs_data_release(settings);
625+
if (active) {
626+
calldata_t cd = {};
627+
calldata_set_bool(&cd, "active", false);
628+
proc_handler_t* ph =
629+
obs_source_get_proc_handler(source);
630+
proc_handler_call(ph, "activate", &cd);
631+
calldata_free(&cd);
632+
std::string id = obs_source_get_uuid(source);
633+
config->_toEnable.push_back(id);
634+
}
635+
}
636+
return true;
637+
}
638+
639+
bool ElgatoCloudConfig::EnableVideoCaptureSources(void* data,
640+
obs_source_t* source)
641+
{
642+
auto config = static_cast<ElgatoCloudConfig*>(data);
643+
std::string sourceType = obs_source_get_id(source);
644+
if (sourceType == "dshow_input") {
645+
auto settings = obs_source_get_settings(source);
646+
std::string id = obs_source_get_uuid(source);
647+
obs_data_release(settings);
648+
if (std::find(config->_toEnable.begin(), config->_toEnable.end(), id) != config->_toEnable.end()) {
649+
calldata_t cd = {};
650+
calldata_set_bool(&cd, "active", true);
651+
proc_handler_t* ph =
652+
obs_source_get_proc_handler(source);
653+
proc_handler_call(ph, "activate", &cd);
654+
calldata_free(&cd);
655+
}
656+
}
657+
return true;
658+
}
659+
606660
void ElgatoCloudConfig::OpenConfigVideoSource()
607661
{
608662
if (!_videoCaptureSource) {
@@ -700,6 +754,19 @@ void ElgatoCloudConfig::_save()
700754

701755
ElgatoCloudConfig::~ElgatoCloudConfig()
702756
{
757+
if (!_videoCaptureSource) {
758+
calldata_t cd = {};
759+
calldata_set_bool(&cd, "active", false);
760+
proc_handler_t* ph =
761+
obs_source_get_proc_handler(_videoCaptureSource);
762+
proc_handler_call(ph, "activate", &cd);
763+
calldata_free(&cd);
764+
}
765+
766+
obs_enum_sources(
767+
&ElgatoCloudConfig::
768+
EnableVideoCaptureSources,
769+
this);
703770
configWindow = nullptr;
704771
}
705772

src/elgato-cloud-config.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ class ElgatoCloudConfig : public QDialog {
123123
const float peak[MAX_AUDIO_CHANNELS],
124124
const float inputPeak[MAX_AUDIO_CHANNELS]);
125125

126+
static bool DisableVideoCaptureSources(void* data,
127+
obs_source_t* source);
128+
static bool EnableVideoCaptureSources(void* data,
129+
obs_source_t* source);
130+
126131
private:
127132
void _save();
128133
DefaultAVWidget *_avWidget;
@@ -134,6 +139,7 @@ class ElgatoCloudConfig : public QDialog {
134139
OBSQTDisplay *_videoPreview = nullptr;
135140
QCheckBox *_makerCheckbox = nullptr;
136141
QLabel* _makerRestartMsg = nullptr;
142+
std::vector<std::string> _toEnable;
137143
std::string _installDirectory;
138144

139145
signals:

src/elgato-cloud-data.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,17 @@ void ElgatoCloud::_LoadUserData(bool loadData)
498498

499499
void ElgatoCloud::_SaveState()
500500
{
501-
obs_data_set_string(_config, "AccessToken", _accessToken.c_str());
502-
obs_data_set_string(_config, "RefreshToken", _refreshToken.c_str());
501+
std::string accessTokenEncrypted = "";
502+
std::string refreshTokenEncrypted = "";
503+
if (_accessToken != "") {
504+
accessTokenEncrypted = encryptString(_accessToken);
505+
}
506+
if (_refreshToken != "") {
507+
refreshTokenEncrypted = encryptString(_refreshToken);
508+
}
509+
510+
obs_data_set_string(_config, "AccessToken", accessTokenEncrypted.c_str());
511+
obs_data_set_string(_config, "RefreshToken", refreshTokenEncrypted.c_str());
503512
obs_data_set_int(_config, "AccessTokenExpiration",
504513
_accessTokenExpiration);
505514
obs_data_set_int(_config, "RefreshTokenExpiration",
@@ -510,14 +519,25 @@ void ElgatoCloud::_SaveState()
510519

511520
void ElgatoCloud::_GetSavedState()
512521
{
513-
_accessToken = obs_data_get_string(_config, "AccessToken");
514-
_refreshToken = obs_data_get_string(_config, "RefreshToken");
522+
std::string accessTokenEncrypted = obs_data_get_string(_config, "AccessToken");
523+
std::string refreshTokenEncrypted = obs_data_get_string(_config, "RefreshToken");
524+
if (accessTokenEncrypted.size() > 25) {
525+
_accessToken = decryptString(accessTokenEncrypted);
526+
} else {
527+
_accessToken = "";
528+
}
529+
530+
if (refreshTokenEncrypted.size() > 25) {
531+
_refreshToken = decryptString(refreshTokenEncrypted);
532+
} else {
533+
_refreshToken = "";
534+
}
535+
515536
_accessTokenExpiration =
516537
obs_data_get_int(_config, "AccessTokenExpiration");
517538
_refreshTokenExpiration =
518539
obs_data_get_int(_config, "RefreshTokenExpiration");
519540
_skipUpdate = obs_data_get_string(_config, "SkipUpdate");
520-
_skipUpdate = "";
521541
}
522542

523543
} // namespace elgatocloud

src/elgato-cloud-window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ DownloadButton::DownloadButton(QWidget *parent) : QWidget(parent)
176176
std::string downloadIconPath = imageBaseDir + "download.svg";
177177
std::string downloadIconHoverPath = imageBaseDir + "download_hover.svg";
178178
std::string downloadIconDisabledPath =
179-
imageBaseDir + "download_hover.svg";
179+
imageBaseDir + "download_disabled.svg";
180180
QString buttonStyle = EIconHoverDisabledButtonStyle;
181181
buttonStyle.replace("${img}", downloadIconPath.c_str());
182182
buttonStyle.replace("${hover-img}", downloadIconHoverPath.c_str());

src/scene-bundle.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ bool SceneBundle::FromCollection(std::string collection_name)
8686
for (auto &source : _collection["sources"]) {
8787
_ProcessJsonObj(source);
8888
}
89+
if (_collection.contains("groups")) {
90+
for (auto& group : _collection["groups"]) {
91+
_ProcessJsonObj(group);
92+
}
93+
}
8994
for (auto &transition : _collection["transitions"]) {
9095
_ProcessJsonObj(transition);
9196
}

src/util.cpp

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ with this program. If not, see <https://www.gnu.org/licenses/>
3939
#include "platform.h"
4040
#include "util.h"
4141

42+
#pragma comment(lib, "crypt32.lib")
43+
#include <Windows.h>
44+
#include <Wincrypt.h>
45+
#define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
46+
4247
obs_data_t *get_module_config()
4348
{
4449
const auto confPath = obs_module_config_path("config.json");
@@ -516,4 +521,116 @@ std::string releaseType()
516521
c = tolower(c);
517522
}
518523
return rt == "release" ? "" : " " + rt;
519-
}
524+
}
525+
526+
std::string binaryToString(const BYTE* binaryData, DWORD dataLen, DWORD flags = CRYPT_STRING_BASE64) {
527+
DWORD stringLen = 0;
528+
// Get the required string length, not including the null terminator.
529+
if (!CryptBinaryToStringA(binaryData, dataLen, flags, nullptr, &stringLen)) {
530+
obs_log(LOG_ERROR, "Could not convert binary data to string.");
531+
return "";
532+
}
533+
534+
// Allocate memory for the string, including the null terminator.
535+
std::string encodedString;
536+
encodedString.resize(stringLen);
537+
538+
// Perform the actual conversion.
539+
if (!CryptBinaryToStringA(binaryData, dataLen, flags, encodedString.data(), &stringLen)) {
540+
obs_log(LOG_ERROR, "Could not convert binary data to string.");
541+
return "";
542+
}
543+
return encodedString;
544+
}
545+
546+
DATA_BLOB stringToBinary(const std::string& input, DWORD flags = CRYPT_STRING_BASE64) {
547+
DWORD binarySize = 0;
548+
DATA_BLOB output;
549+
output.pbData = nullptr;
550+
output.cbData = 0;
551+
// Get the required size for the binary data
552+
if (!CryptStringToBinaryA(input.c_str(), (DWORD)input.length(), flags, nullptr, &binarySize, nullptr, nullptr)) {
553+
obs_log(LOG_INFO, "Could not string to binary. Could not determine needed binary data size.");
554+
return output;
555+
}
556+
557+
// Allocate memory for the binary data
558+
output.pbData = (BYTE*)LocalAlloc(LMEM_FIXED, binarySize);
559+
if (output.pbData == nullptr) {
560+
obs_log(LOG_INFO, "Could not convert string to binary. Memory allocation error.");
561+
return output;
562+
}
563+
output.cbData = binarySize;
564+
// Perform the actual conversion
565+
if (!CryptStringToBinaryA(input.c_str(), (DWORD)input.length(), flags, output.pbData, &binarySize, nullptr, nullptr)) {
566+
obs_log(LOG_INFO, "Could not string to binary. Invalid conversion.");
567+
return output;
568+
}
569+
return output;
570+
}
571+
572+
// Encrypts a string, and returns string of encrypted binary data
573+
// as a formatted BASE 64 encoded string.
574+
std::string encryptString(std::string input)
575+
{
576+
DATA_BLOB DataIn;
577+
DATA_BLOB DataOut;
578+
BYTE* pbDataInput = (BYTE*)input.c_str();
579+
DWORD cbDataInput = DWORD(strlen((char*)pbDataInput) + 1);
580+
DataIn.pbData = pbDataInput;
581+
DataIn.cbData = cbDataInput;
582+
std::string encrypted = "";
583+
if (CryptProtectData(
584+
&DataIn,
585+
L"",
586+
NULL,
587+
NULL,
588+
NULL,
589+
0,
590+
&DataOut))
591+
{
592+
//convert binary to formatted base 64 encoded string.
593+
encrypted = binaryToString(DataOut.pbData, DataOut.cbData);
594+
LocalFree(DataOut.pbData);
595+
} else {
596+
obs_log(LOG_ERROR, "Could not encrypt string.");
597+
}
598+
return encrypted;
599+
}
600+
601+
// Decrypts a formatted base64 encoded string. First
602+
// converts string to binary blob, then uses windows
603+
// cryto API to decrypt the binary blob into a usable
604+
// string
605+
std::string decryptString(std::string input)
606+
{
607+
DATA_BLOB ToDecrypt = stringToBinary(input);
608+
if (ToDecrypt.pbData == nullptr) {
609+
return "";
610+
}
611+
DATA_BLOB DataVerify;
612+
LPWSTR pDescrOut = NULL;
613+
614+
std::string decrypted = "";
615+
616+
if (CryptUnprotectData(
617+
&ToDecrypt,
618+
&pDescrOut,
619+
NULL,
620+
NULL,
621+
NULL,
622+
0,
623+
&DataVerify))
624+
{
625+
decrypted = std::string(reinterpret_cast<char*>(DataVerify.pbData), DataVerify.cbData);
626+
LocalFree(DataVerify.pbData);
627+
LocalFree(pDescrOut);
628+
if (ToDecrypt.pbData != nullptr) {
629+
LocalFree(ToDecrypt.pbData);
630+
}
631+
} else {
632+
obs_log(LOG_ERROR, "Could not decrypt string.");
633+
}
634+
return decrypted;
635+
}
636+

src/util.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,7 @@ template<class T, class U> auto_closer<T, U> auto_close(T *self, U closer)
8484
bool generate_safe_path(std::string unsafe, std::string &safe);
8585
std::string versionNoBuild();
8686
std::string buildNumber();
87-
std::string releaseType();
87+
std::string releaseType();
88+
89+
std::string encryptString(std::string input);
90+
std::string decryptString(std::string input);

0 commit comments

Comments
 (0)