Skip to content

Commit

Permalink
obsproject#18 1.1.13版本 01 增加版本检查菜单响应事件:不需更新时,提示信息 02 解决崩溃问题:A:系统退出时、B…
Browse files Browse the repository at this point in the history
…:移除视频监控时 03 优化:刚启动就结束工作时,需要等待较长时间的问题
  • Loading branch information
5455945 committed Apr 14, 2017
1 parent aaff9ec commit b85788f
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 30 deletions.
2 changes: 1 addition & 1 deletion libobs/obs-config.h
Expand Up @@ -44,7 +44,7 @@
* Reset to zero each major or minor version
*/
//#define LIBOBS_API_PATCH_VER 5
#define LIBOBS_API_PATCH_VER 12
#define LIBOBS_API_PATCH_VER 13

#define MAKE_SEMANTIC_VERSION(major, minor, patch) \
((major << 24) | \
Expand Down
1 change: 1 addition & 0 deletions obs/data/locale/en-US.ini
Expand Up @@ -153,6 +153,7 @@ Remux.ExitUnfinished="Remuxing is not finished, stopping now may render the targ
# update dialog
UpdateAvailable="New Update Available"
UpdateAvailable.Text="Version %1.%2.%3 is now available. <a href='%4'>Click here to download</a>"
UpdateNewVersion.Text="Server version%1.%2.%3, the local is a new version. "

# audio device names
Basic.DesktopDevice1="Desktop Audio"
Expand Down
1 change: 1 addition & 0 deletions obs/data/locale/zh-CN.ini
Expand Up @@ -132,6 +132,7 @@ Remux.ExitUnfinished="转封装没有完成, 现在停止可能使目标文件

UpdateAvailable="版本升级"
UpdateAvailable.Text="新的版本 %1.%2.%3 已可用。<a href='%4'> 点击这里下载</a>"
UpdateNewVersion.Text="服务端版本 %1.%2.%3 ,本地是新版本。"

Basic.DesktopDevice1="台式音响"
Basic.DesktopDevice2="台式音响 2"
Expand Down
44 changes: 22 additions & 22 deletions obs/face-add.cpp
Expand Up @@ -40,20 +40,6 @@ bool FaceAddThread::OpenCVFaceAdd(bool force)
return bRet;
}

HMODULE hModule = GetModuleHandleA("win-dshow.dll");
if (!hModule) {
bRet = false;
return bRet;
}

typedef bool(__stdcall *PFUN_SaveCapturePicture)(bool isSave, wchar_t* filename);

PFUN_SaveCapturePicture pfuncSaveCapturePicture = (PFUN_SaveCapturePicture)GetProcAddress(hModule, "SaveCapturePicture");
if (!pfuncSaveCapturePicture) {
bRet = false;
return bRet;
}

stringstream dst;
dst << "vhome/obs-studio/imgs" << "/" << "user_face.jpg";
string loginFile = string(GetConfigPathPtr(dst.str().c_str()));
Expand All @@ -65,18 +51,24 @@ bool FaceAddThread::OpenCVFaceAdd(bool force)
return bRet;
}

// 尝试刷脸登陆
typedef int(__stdcall *PFUNC_ImageFaceDetect)(const char* filename);
PFUNC_ImageFaceDetect pfuncImageFaceDetect = nullptr;
hModule = GetModuleHandleA("face-detect.dll");
if (!hModule) {
bRet = false;
return bRet;
}
for (int i = 0; i < 50; i++) {
if (os_file_exists(loginFile.c_str())) {
os_unlink(loginFile.c_str());
}

HMODULE hModule = GetModuleHandleA("win-dshow.dll");
if (!hModule) {
bRet = false;
return bRet;
}

typedef bool(__stdcall *PFUN_SaveCapturePicture)(bool isSave, wchar_t* filename);

PFUN_SaveCapturePicture pfuncSaveCapturePicture = (PFUN_SaveCapturePicture)GetProcAddress(hModule, "SaveCapturePicture");
if (!pfuncSaveCapturePicture) {
bRet = false;
return bRet;
}
pfuncSaveCapturePicture(true, filename);
// 最多等3次 0.6秒,待文件生成
for (int j = 0; j < 3; j++) {
Expand All @@ -87,6 +79,14 @@ bool FaceAddThread::OpenCVFaceAdd(bool force)
}

if (os_file_exists(loginFile.c_str())) {
// 尝试刷脸登陆
typedef int(__stdcall *PFUNC_ImageFaceDetect)(const char* filename);
PFUNC_ImageFaceDetect pfuncImageFaceDetect = nullptr;
HMODULE hModule = GetModuleHandleA("face-detect.dll");
if (!hModule) {
bRet = false;
return bRet;
}
pfuncImageFaceDetect = (PFUNC_ImageFaceDetect)GetProcAddress(hModule, "ImageFaceDetect");
if (!pfuncImageFaceDetect) {
bRet = false;
Expand Down
8 changes: 4 additions & 4 deletions obs/obs.rc
Expand Up @@ -5,10 +5,10 @@ IDI_ICON1 ICON "../cmake/winrc/obs-studio.ico"
#include <winver.h>
#endif

#define VER_FILEVERSION 1,1,12,0
#define VER_FILEVERSION_STR "1.1.12.0\0"
#define VER_PRODUCTVERSION 1,1,12,0
#define VER_PRODUCTVERSION_STR "1.1.12.0\0"
#define VER_FILEVERSION 1,1,13,0
#define VER_FILEVERSION_STR "1.1.13.0\0"
#define VER_PRODUCTVERSION 1,1,13,0
#define VER_PRODUCTVERSION_STR "1.1.13.0\0"

VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
Expand Down
43 changes: 40 additions & 3 deletions obs/window-basic-main.cpp
Expand Up @@ -135,6 +135,7 @@ OBSBasic::OBSBasic(QWidget *parent)
// 2016-12-05 zhangfj add 暂时不现实更新和日志菜单
//ui->menuBasic_MainMenu_Help->removeAction(ui->actionCheckForUpdates);
ui->menuBasic_MainMenu_Help->removeAction(ui->menuLogFiles->menuAction());
m_bMenuActionUpdate = false;

ui->sources->setItemDelegate(new VisibilityItemDelegate(ui->sources));

Expand Down Expand Up @@ -2024,9 +2025,9 @@ void OBSBasic::CheckForUpdates()
void OBSBasic::updateFileFinished(const QString &text, const QString &error)
{
ui->actionCheckForUpdates->setEnabled(true);

if (text.isEmpty()) {
blog(LOG_WARNING, "Update check failed: %s", QT_TO_UTF8(error));
m_bMenuActionUpdate = false;
return;
}

Expand Down Expand Up @@ -2066,12 +2067,29 @@ void OBSBasic::updateFileFinished(const QString &text, const QString &error)
"LastUpdateCheck", t);
config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
}
else {
if (m_bMenuActionUpdate) {
QString str = QTStr("UpdateNewVersion.Text");
QMessageBox messageBox(this);

str = str.arg(QString::number(major),
QString::number(minor),
QString::number(patch));

messageBox.setWindowTitle(QTStr("UpdateAvailable"));
messageBox.setTextFormat(Qt::RichText);
messageBox.setText(str);
messageBox.setInformativeText(QT_UTF8(description));
messageBox.exec();
}
}
} else {
blog(LOG_WARNING, "Bad JSON file received from server");
}

obs_data_release(versionData);
obs_data_release(returnData);
m_bMenuActionUpdate = false;
}

void OBSBasic::DuplicateSelectedScene()
Expand Down Expand Up @@ -2673,6 +2691,17 @@ void OBSBasic::closeEvent(QCloseEvent *event)
{
blog(LOG_INFO, SHUTDOWN_SEPARATOR);

if (loginAddFaceThread) {
loginAddFaceThread->terminate();
delete loginAddFaceThread;
loginAddFaceThread = nullptr;
}
if (checkRecordFileUploadThread) {
checkRecordFileUploadThread->terminate();
delete checkRecordFileUploadThread;
checkRecordFileUploadThread = nullptr;
}

if (outputHandler && outputHandler->Active()) {
QMessageBox::StandardButton button = QMessageBox::question(
this, QTStr("ConfirmExit.Title"),
Expand Down Expand Up @@ -3309,6 +3338,13 @@ void OBSBasic::on_actionRemoveSource_triggered()
return Yes == remove_items.clickedButton();
};

// 删除视像头前,需要停止AddFace线程
if (loginAddFaceThread) {
loginAddFaceThread->terminate();
delete loginAddFaceThread;
loginAddFaceThread = nullptr;
}

if (items.size() == 1) {
OBSSceneItem &item = items[0];
obs_source_t *source = obs_sceneitem_get_source(item);
Expand Down Expand Up @@ -3491,6 +3527,7 @@ void OBSBasic::on_actionViewCurrentLog_triggered()

void OBSBasic::on_actionCheckForUpdates_triggered()
{
m_bMenuActionUpdate = true;
CheckForUpdates();
}

Expand Down Expand Up @@ -4708,11 +4745,11 @@ void OBSBasic::WebLogout()
ui->actionLogout->setEnabled(false);

if (logoutThread) {
logoutThread->wait();
logoutThread->wait(); // 如果日志过多未上传,可能等待时间略长
delete logoutThread;
}
if (loginAddFaceThread) {
loginAddFaceThread->wait();
loginAddFaceThread->terminate();
delete loginAddFaceThread;
}

Expand Down
1 change: 1 addition & 0 deletions obs/window-basic-main.hpp
Expand Up @@ -573,6 +573,7 @@ private slots:
QPointer<QThread> logoutThread;
QPointer<WinMonitor> winMonitor;
bool m_bPushStreamSisconnected;
bool m_bMenuActionUpdate;

protected:
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);
Expand Down

0 comments on commit b85788f

Please sign in to comment.