Exemplo n.º 1
0
BOOL ConfigFile::GetStringList(CTSTR lpSection, CTSTR lpKey, StringList &StrList)
{
    assert(lpSection);
    assert(lpKey);

    BOOL bFoundKey = 0;

    DWORD i,j,k;

    for(i=0; i<Sections.Num(); i++)
    {
        ConfigSection &section = Sections[i];
        if(scmpi(lpSection, section.name) == 0)
        {
            for(j=0; j<section.Keys.Num(); j++)
            {
                ConfigKey &key = section.Keys[j];
                if(scmpi(lpKey, key.name) == 0)
                {
                    for(k=0; k<key.ValueList.Num(); k++)
                        StrList << key.ValueList[k];

                    bFoundKey = 1;
                }
            }
        }
    }

    return bFoundKey;
}
Exemplo n.º 2
0
XElement* XElement::GetElementByItem(CTSTR lpName, CTSTR lpItemName, CTSTR lpItemValue) const
{
    assert(lpItemName);
    assert(lpItemValue);

    if(lpName)
    {
        for(DWORD i=0; i<SubItems.Num(); i++)
        {
            if(!SubItems[i]->IsElement()) continue;

            XElement *element = static_cast<XElement*>(SubItems[i]);
            if(element->strName.CompareI(lpName))
            {
                if(scmpi(element->GetString(lpItemName), lpItemValue) == 0)
                    return element;
            }
        }
    }
    else
    {
        for(DWORD i=0; i<SubItems.Num(); i++)
        {
            if(!SubItems[i]->IsElement()) continue;

            XElement *element = static_cast<XElement*>(SubItems[i]);
            if(scmpi(element->GetString(lpItemName), lpItemValue) == 0)
                return element;
        }
    }

    return NULL;
}
Exemplo n.º 3
0
CTSTR ConfigFile::GetStringPtr(CTSTR lpSection, CTSTR lpKey, CTSTR def)
{
    assert(lpSection);
    assert(lpKey);

    DWORD i,j;

    for(i=0; i<Sections.Num(); i++)
    {
        ConfigSection &section = Sections[i];
        if(scmpi(lpSection, section.name) == 0)
        {
            for(j=0; j<section.Keys.Num(); j++)
            {
                ConfigKey &key = section.Keys[j];
                if(scmpi(lpKey, key.name) == 0)
                    return key.ValueList[0];
            }
        }
    }

    if(def)
        return def;
    else
        return NULL;
}
Exemplo n.º 4
0
int ConfigFile::GetInt(CTSTR lpSection, CTSTR lpKey, int def)
{
    assert(lpSection);
    assert(lpKey);

    DWORD i,j;

    for(i=0; i<Sections.Num(); i++)
    {
        ConfigSection &section = Sections[i];
        if(scmpi(lpSection, section.name) == 0)
        {
            for(j=0; j<section.Keys.Num(); j++)
            {
                ConfigKey &key = section.Keys[j];
                if(scmpi(lpKey, key.name) == 0)
                {
                    if(scmpi(key.ValueList[0], TEXT("true")) == 0)
                        return 1;
                    else if(scmpi(key.ValueList[0], TEXT("false")) == 0)
                        return 0;
                    else
                    {
                        if(ValidIntString(key.ValueList[0]))
                            return tstring_base_to_int(key.ValueList[0], NULL, 0);
                    }
                }
            }
        }
    }

    return def;
}
Exemplo n.º 5
0
BOOL ConfigFile::GetFloatList(CTSTR lpSection, CTSTR lpKey, List<float> &FloatList)
{
    assert(lpSection);
    assert(lpKey);

    DWORD i,j,k;
    BOOL bFoundKey = 0;

    for(i=0; i<Sections.Num(); i++)
    {
        ConfigSection &section = Sections[i];
        if(scmpi(lpSection, section.name) == 0)
        {
            for(j=0; j<section.Keys.Num(); j++)
            {
                ConfigKey &key = section.Keys[j];
                if(scmpi(lpKey, key.name) == 0)
                {
                    for(k=0; k<key.ValueList.Num(); k++)
                        FloatList << (float)tstof(key.ValueList[k]);

                    bFoundKey = 1;
                }
            }
        }
    }

    return bFoundKey;
}
Exemplo n.º 6
0
void STDCALL ResetXTAllocator(CTSTR lpAllocator)
{
    StringLog.Stop();
    StringLog.Clear();

    delete locale;
    delete MainAllocator;

    if(scmpi(lpAllocator, TEXT("DebugAlloc")) == 0)
        MainAllocator = new DebugAlloc;
    else if (scmpi(lpAllocator, TEXT("DefaultAlloc")) == 0)
        MainAllocator = new DefaultAlloc;
    else if (scmpi(lpAllocator, TEXT("SeriousMemoryDebuggingAlloc")) == 0)
        MainAllocator = new SeriousMemoryDebuggingAlloc;
    else
#if defined(_M_X64) || defined(__amd64__)
        MainAllocator = new DefaultAlloc;
#else
        MainAllocator = new FastAlloc;
#endif

    locale = new LocaleStringLookup;

    StringLog.Reset();
}
Exemplo n.º 7
0
void  XElement::GetIntList(CTSTR lpName, List<int> &IntList) const
{
    assert(lpName);

    IntList.Clear();

    for(DWORD i=0; i<SubItems.Num(); i++)
    {
        if(!SubItems[i]->IsData()) continue;

        XDataItem *item = static_cast<XDataItem*>(SubItems[i]);
        if(item->strName.CompareI(lpName))
        {
            CTSTR lpValue = item->strData;

            if( (*LPWORD(lpValue) == 'x0') ||
                (*LPWORD(lpValue) == 'X0') )
            {
                IntList << tstring_base_to_uint(lpValue+2, NULL, 16);
            }
            else if(scmpi(lpValue, TEXT("true")) == 0)
                IntList << 1;
            else if(scmpi(lpValue, TEXT("false")) == 0)
                IntList << 0;
            else
                IntList << tstring_base_to_uint(lpValue, NULL, 0);
        }
    }
}
void ProcessDateTime::SetString(CTSTR lpName, CTSTR lpVal)
{
	if (scmpi(lpName, TEXT("Font")) == 0)
	{
		strFont = lpVal;
	}
	else if (scmpi(lpName, TEXT("FormatString")) == 0)
		strFormatString = lpVal;

	bUpdateTexture = true;
}
void ProcessDateTime::SetFloat(CTSTR lpName, float fValue)
{
	if (scmpi(lpName, TEXT("outlineSize")) == 0)
		outlineSize = fValue;
	else if (scmpi(lpName, TEXT("cx")) == 0)
	{
		Resolution.x = fValue;
	}
	else if (scmpi(lpName, TEXT("cy")) == 0)
	{
		Resolution.y = fValue;
	}

	bUpdateTexture = true;
}
Exemplo n.º 10
0
Arquivo: XT.cpp Projeto: robessog/OBS
void STDCALL ResetXTAllocator(CTSTR lpAllocator)
{
    delete locale;
    delete MainAllocator;

    if(scmpi(lpAllocator, TEXT("DebugAlloc")) == 0)
        MainAllocator = new DebugAlloc;
    else if (scmpi(lpAllocator, TEXT("DefaultAlloc")) == 0)
        MainAllocator = new DefaultAlloc;
    else if (scmpi(lpAllocator, TEXT("SeriousMemoryDebuggingAlloc")) == 0)
        MainAllocator = new SeriousMemoryDebuggingAlloc;
    else
        MainAllocator = new FastAlloc;

    locale = new LocaleStringLookup;
}
Exemplo n.º 11
0
BOOL  ConfigFile::HasKey(CTSTR lpSection, CTSTR lpKey)
{
    for(unsigned int i=0; i<Sections.Num(); i++)
    {
        ConfigSection &section = Sections[i];
        if(scmpi(section.name, lpSection) == 0)
        {
            for(unsigned int j=0; j<section.Keys.Num(); j++)
            {
                if(scmpi(section.Keys[j].name, lpKey) == 0)
                    return TRUE;
            }
        }
    }

    return FALSE;
}
Exemplo n.º 12
0
    BlankAudioPlayback(CTSTR lpDevice)
    {
        const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
        const IID IID_IMMDeviceEnumerator    = __uuidof(IMMDeviceEnumerator);
        const IID IID_IAudioClient           = __uuidof(IAudioClient);
        const IID IID_IAudioRenderClient     = __uuidof(IAudioRenderClient);

        HRESULT err;
        err = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void**)&mmEnumerator);
        if(FAILED(err))
            CrashError(TEXT("Could not create IMMDeviceEnumerator: 0x%08lx"), err);

        if (scmpi(lpDevice, TEXT("Default")) == 0)
            err = mmEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &mmDevice);
        else
            err = mmEnumerator->GetDevice(lpDevice, &mmDevice);
        if(FAILED(err))
            CrashError(TEXT("Could not create IMMDevice"));

        err = mmDevice->Activate(IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&mmClient);
        if(FAILED(err))
            CrashError(TEXT("Could not create IAudioClient"));

        WAVEFORMATEX *pwfx;
        err = mmClient->GetMixFormat(&pwfx);
        if(FAILED(err))
            CrashError(TEXT("Could not get mix format from audio client"));

        UINT inputBlockSize = pwfx->nBlockAlign;

        err = mmClient->Initialize(AUDCLNT_SHAREMODE_SHARED, 0, ConvertMSTo100NanoSec(1000), 0, pwfx, NULL);
        if(FAILED(err))
            CrashError(TEXT("Could not initialize audio client, error = %08lX"), err);

        err = mmClient->GetService(IID_IAudioRenderClient, (void**)&mmRender);
        if(FAILED(err))
            CrashError(TEXT("Could not get audio render client"));

        //----------------------------------------------------------------

        UINT bufferFrameCount;
        err = mmClient->GetBufferSize(&bufferFrameCount);
        if(FAILED(err))
            CrashError(TEXT("Could not get audio buffer size"));

        BYTE *lpData;
        err = mmRender->GetBuffer(bufferFrameCount, &lpData);
        if(FAILED(err))
            CrashError(TEXT("Could not get audio buffer"));

        zero(lpData, bufferFrameCount*inputBlockSize);

        mmRender->ReleaseBuffer(bufferFrameCount, 0);//AUDCLNT_BUFFERFLAGS_SILENT); //probably better if it doesn't know

        if(FAILED(mmClient->Start()))
            CrashError(TEXT("Could not start audio source"));
    }
Exemplo n.º 13
0
void GraphicsCaptureSource::SetInt(CTSTR lpName, int iVal)
{
    if(scmpi(lpName, TEXT("gamma")) == 0)
    {
        gamma = iVal;
        if(gamma < 50)        gamma = 50;
        else if(gamma > 175)  gamma = 175;
    }
}
Exemplo n.º 14
0
void DeviceSource::SetFloat(CTSTR lpName, float fValue)
{
    if(!bCapturing)
        return;

    if(scmpi(lpName, TEXT("volume")) == 0)
    {
        fNewVol = fValue;
        bRequestVolume = true;
    }
}
Exemplo n.º 15
0
void Scene::RemoveImageSource(CTSTR lpName)
{
    for(UINT i=0; i<sceneItems.Num(); i++)
    {
        if(scmpi(sceneItems[i]->GetName(), lpName) == 0)
        {
            RemoveImageSource(sceneItems[i]);
            return;
        }
    }
}
Exemplo n.º 16
0
void DeviceSource::SetInt(CTSTR lpName, int iVal)
{
    if(bCapturing)
    {
        if(scmpi(lpName, TEXT("timeOffset")) == 0)
        {
            if(audioOut)
                audioOut->SetAudioOffset(iVal);
        }
    }
}
Exemplo n.º 17
0
LocaleNativeName* STDCALL GetLocaleNativeName(CTSTR lpCode)
{
    LocaleNativeName *native = &nativeNames[0];
    while(native->lpCode)
    {
        if(scmpi(native->lpCode, lpCode) == 0)
            return native;
        native++;
    }

    return NULL;
}
Exemplo n.º 18
0
BOOL ConfigFile::GetIntList(CTSTR lpSection, CTSTR lpKey, List<int> &IntList)
{
    assert(lpSection);
    assert(lpKey);

    DWORD i,j,k;
    BOOL bFoundKey = 0;

    for(i=0; i<Sections.Num(); i++)
    {
        ConfigSection &section = Sections[i];
        if(scmpi(lpSection, section.name) == 0)
        {
            for(j=0; j<section.Keys.Num(); j++)
            {
                ConfigKey &key = section.Keys[j];
                if(scmpi(lpKey, key.name) == 0)
                {
                    for(k=0; k<key.ValueList.Num(); k++)
                    {
                        if(scmpi(key.ValueList[k], TEXT("true")) == 0)
                            IntList << 1;
                        else if(scmpi(key.ValueList[k], TEXT("false")) == 0)
                            IntList << 0;
                        else
                        {
                            if(ValidIntString(key.ValueList[k]))
                                IntList << tstring_base_to_int(key.ValueList[k], NULL, 0);
                        }
                    }

                    bFoundKey = 1;
                }
            }
        }
    }

    return bFoundKey;
}
Exemplo n.º 19
0
BOOL String::CompareI(CTSTR str) const
{
    if(lpString)
    {
        if(!str)
            return (lpString[0] == 0);

        return scmpi(lpString, str) == 0;
    }
    else
    {
        return !str || (str[0] == 0);
    }
}
Exemplo n.º 20
0
DWORD ConfigFile::GetHex(CTSTR lpSection, CTSTR lpKey, DWORD def)
{
    assert(lpSection);
    assert(lpKey);

    DWORD i,j;

    for(i=0; i<Sections.Num(); i++)
    {
        ConfigSection &section = Sections[i];
        if(scmpi(lpSection, section.name) == 0)
        {
            for(j=0; j<section.Keys.Num(); j++)
            {
                ConfigKey &key = section.Keys[j];
                if(scmpi(lpKey, key.name) == 0)
                    return tstring_base_to_int(key.ValueList[0], NULL, 0);
            }
        }
    }

    return def;
}
Exemplo n.º 21
0
float ConfigFile::GetFloat(CTSTR lpSection, CTSTR lpKey, float def)
{
    assert(lpSection);
    assert(lpKey);

    DWORD i,j;

    for(i=0; i<Sections.Num(); i++)
    {
        ConfigSection &section = Sections[i];
        if(scmpi(lpSection, section.name) == 0)
        {
            for(j=0; j<section.Keys.Num(); j++)
            {
                ConfigKey &key = section.Keys[j];
                if(scmpi(lpKey, key.name) == 0)
                    return (float)tstof(key.ValueList[0]);
            }
        }
    }

    return def;
}
Exemplo n.º 22
0
int   XElement::GetInt(CTSTR lpName, int def) const
{
    assert(lpName);

    XDataItem *item = GetDataItem(lpName);
    if(item)
    {
        CTSTR lpValue = item->strData;

        if( (*LPWORD(lpValue) == 'x0') ||
            (*LPWORD(lpValue) == 'X0') )
        {
            return tstring_base_to_uint(lpValue+2, NULL, 16);
        }
        else if(scmpi(lpValue, TEXT("true")) == 0)
            return 1;
        else if(scmpi(lpValue, TEXT("false")) == 0)
            return 0;
        else
            return tstring_base_to_uint(lpValue, NULL, 0);
    }

    return def;
}
Exemplo n.º 23
0
void GraphicsCaptureSource::BeginScene()
{
    if(bCapturing)
        return;

    strWindowClass = data->GetString(TEXT("windowClass"));
    strExecutable = data->GetString(TEXT("executable"));
    if (strWindowClass.IsEmpty() && strExecutable.IsEmpty())
    {
        Log(TEXT("GraphicsCaptureSource::BeginScene: No class or executable specified, what's happening?!"));
        return;
    }

    bUseDWMCapture = (scmpi(strWindowClass, TEXT("Dwm")) == 0);

    bStretch = data->GetInt(TEXT("stretchImage")) != 0;
    bAlphaBlend = data->GetInt(TEXT("alphaBlend")) != 0;
    bIgnoreAspect = data->GetInt(TEXT("ignoreAspect")) != 0;
    bCaptureMouse = data->GetInt(TEXT("captureMouse"), 1) != 0;

    bool safeHookVal = data->GetInt(TEXT("safeHook")) != 0;

    if (safeHookVal != useSafeHook && safeHookVal)
        Log(L"Using anti-cheat hooking for game capture");

    useSafeHook = safeHookVal;

    bUseHotkey = data->GetInt(TEXT("useHotkey"), 0) != 0;
    hotkey = data->GetInt(TEXT("hotkey"), VK_F12);

    if(bUseHotkey)
    {
        hotkeyID = OBSCreateHotkey(hotkey, (OBSHOTKEYPROC)GraphicsCaptureSource::CaptureHotkey, (UPARAM)this);
        bUseDWMCapture = false;
    }

    gamma = data->GetInt(TEXT("gamma"), 100);

    if(bCaptureMouse && data->GetInt(TEXT("invertMouse")))
        invertShader = CreatePixelShaderFromFile(TEXT("shaders\\InvertTexture.pShader"));

    drawShader = CreatePixelShaderFromFile(TEXT("shaders\\DrawTexture_ColorAdjust.pShader"));

    if (!bUseHotkey)
        AttemptCapture();
}
Exemplo n.º 24
0
void ApplyRTL(HWND hwnd, bool bRTL)
{
    if (!bRTL)
        return;

    TCHAR controlClassName[128];
    GetClassName(hwnd, controlClassName, 128);
    if (scmpi(controlClassName, L"Static") == 0)
    {
        LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE);
        style ^= SS_RIGHT;
        SetWindowLongPtr(hwnd, GWL_STYLE, style);
    }

    LONG_PTR styles = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
    styles ^= WS_EX_RIGHT;
    styles |= WS_EX_RTLREADING;
    SetWindowLongPtr(hwnd, GWL_EXSTYLE, styles);
}
Exemplo n.º 25
0
void ProcessDateTime::SetInt(CTSTR lpName, int iValue)
{
	if (scmpi(lpName, TEXT("Fontcolor")) == 0)
		color = iValue;
	else if (scmpi(lpName, TEXT("fontSize")) == 0)
		size = iValue;
	else if (scmpi(lpName, TEXT("underline")) == 0)
		bUnderline = iValue != 0;
	else if (scmpi(lpName, TEXT("align")) == 0)
		align = iValue;
	else if (scmpi(lpName, TEXT("useOutline")) == 0)
		bUseOutline = iValue != 0;
	else if (scmpi(lpName, TEXT("outlineColor")) == 0)
		outlineColor = iValue;

	bUpdateTexture = true;
}
Exemplo n.º 26
0
bool LoadPlugin()
{
    pluginLocale = new LocaleStringLookup;

    if(!pluginLocale->LoadStringFile(TEXT("plugins/PSVPlugin/locale/en.txt")))
        AppWarning(TEXT("Could not open locale string file '%s'"), TEXT("plugins/PSVPlugin/locale/en.txt"));

    if(scmpi(API->GetLanguage(), TEXT("en")) != 0)
    {
        String pluginStringFile;
        pluginStringFile << TEXT("plugins/PSVPlugin/locale/") << API->GetLanguage() << TEXT(".txt");
        if(!pluginLocale->LoadStringFile(pluginStringFile))
            AppWarning(TEXT("Could not open locale string file '%s'"), pluginStringFile.Array());
    }

    config.Open(OBSGetPluginDataPath() + CONFIG_FILE, true);

    LoadSettings();

    OnSceneSwitch(OBSGetSceneName());

    return true;
}
Exemplo n.º 27
0
INT_PTR SettingsAdvanced::ProcMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
        case WM_INITDIALOG:
            {
                LocalizeWindow(hwnd);

                //--------------------------------------------

                HWND hwndToolTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL, WS_POPUP|TTS_NOPREFIX|TTS_ALWAYSTIP,
                    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                    hwnd, NULL, hinstMain, NULL);

                TOOLINFO ti;
                zero(&ti, sizeof(ti));
                ti.cbSize = sizeof(ti);
                ti.uFlags = TTF_SUBCLASS|TTF_IDISHWND;
                ti.hwnd = hwnd;

                SendMessage(hwndToolTip, TTM_SETMAXTIPWIDTH, 0, 500);
                SendMessage(hwndToolTip, TTM_SETDELAYTIME, TTDT_AUTOPOP, 14000);

                //------------------------------------

                UINT sceneBufferingTime = GlobalConfig->GetInt(TEXT("General"), TEXT("SceneBufferingTime"), 700);
                SendMessage(GetDlgItem(hwnd, IDC_SCENEBUFFERTIME), UDM_SETRANGE32, 60, 20000);
                SendMessage(GetDlgItem(hwnd, IDC_SCENEBUFFERTIME), UDM_SETPOS32, 0, sceneBufferingTime);

                //------------------------------------

                bool bUseMTOptimizations = AppConfig->GetInt(TEXT("General"), TEXT("UseMultithreadedOptimizations"), TRUE) != 0;
                SendMessage(GetDlgItem(hwnd, IDC_USEMULTITHREADEDOPTIMIZATIONS), BM_SETCHECK, bUseMTOptimizations ? BST_CHECKED : BST_UNCHECKED, 0);

                HWND hwndTemp = GetDlgItem(hwnd, IDC_PRIORITY);
                SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)Str("Settings.Advanced.Priority.High"));
                SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)Str("Settings.Advanced.Priority.AboveNormal"));
                SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)Str("Settings.Advanced.Priority.Normal"));
                SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)Str("Settings.Advanced.Priority.Idle"));

                CTSTR pStr = AppConfig->GetStringPtr(TEXT("General"), TEXT("Priority"), TEXT("Normal"));
                if (scmpi(pStr, TEXT("Idle")) == 0)
                    SendMessage(hwndTemp, CB_SETCURSEL, 3, 0);
                else if (scmpi(pStr, TEXT("Above Normal")) == 0)
                    SendMessage(hwndTemp, CB_SETCURSEL, 1, 0);
                else if (scmpi(pStr, TEXT("High")) == 0)
                    SendMessage(hwndTemp, CB_SETCURSEL, 0, 0);
                else //Normal
                    SendMessage(hwndTemp, CB_SETCURSEL, 2, 0);

                //------------------------------------

                bool bDisablePreviewEncoding = GlobalConfig->GetInt(TEXT("General"), TEXT("DisablePreviewEncoding"), false) != 0;
                SendMessage(GetDlgItem(hwnd, IDC_DISABLEPREVIEWENCODING), BM_SETCHECK, bDisablePreviewEncoding ? BST_CHECKED : BST_UNCHECKED, 0);

                //------------------------------------

                bool bAllowOtherHotkeyModifiers = GlobalConfig->GetInt(TEXT("General"), TEXT("AllowOtherHotkeyModifiers"), true) != 0;
                SendMessage(GetDlgItem(hwnd, IDC_ALLOWOTHERHOTKEYMODIFIERS), BM_SETCHECK, bAllowOtherHotkeyModifiers ? BST_CHECKED : BST_UNCHECKED, 0);

                //--------------------------------------------

                hwndTemp = GetDlgItem(hwnd, IDC_X264PROFILE);
                static const CTSTR profile_names[3] = {TEXT("main"), TEXT("high")};
                for(int i=0; i<2; i++)
                    SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)profile_names[i]);

                LoadSettingComboString(hwndTemp, TEXT("Video Encoding"), TEXT("X264Profile"), TEXT("high"));

                //--------------------------------------------

                hwndTemp = GetDlgItem(hwnd, IDC_PRESET);
                static const CTSTR preset_names[8] = {TEXT("ultrafast"), TEXT("superfast"), TEXT("veryfast"), TEXT("faster"), TEXT("fast"), TEXT("medium"), TEXT("slow"), TEXT("slower")};
                for(int i=0; i<8; i++)
                    SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)preset_names[i]);

                LoadSettingComboString(hwndTemp, TEXT("Video Encoding"), TEXT("Preset"), TEXT("veryfast"));

                ti.lpszText = (LPWSTR)Str("Settings.Advanced.VideoEncoderCPUTradeoffTooltip");
                ti.uId = (UINT_PTR)hwndTemp;
                SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);

                //------------------------------------

                bool bUseCFR = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCFR"), 1) != 0;
                SendMessage(GetDlgItem(hwnd, IDC_USECFR), BM_SETCHECK, bUseCFR ? BST_CHECKED : BST_UNCHECKED, 0);

                //------------------------------------

                bool bUseCustomX264Settings = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCustomSettings")) != 0;
                String strX264Settings = AppConfig->GetString(TEXT("Video Encoding"), TEXT("CustomSettings"));

                SendMessage(GetDlgItem(hwnd, IDC_USEVIDEOENCODERSETTINGS), BM_SETCHECK, bUseCustomX264Settings ? BST_CHECKED : BST_UNCHECKED, 0);
                SetWindowText(GetDlgItem(hwnd, IDC_VIDEOENCODERSETTINGS), strX264Settings);

                ti.lpszText = (LPWSTR)Str("Settings.Advanced.VideoEncoderSettingsTooltip");
                ti.uId = (UINT_PTR)GetDlgItem(hwnd, IDC_VIDEOENCODERSETTINGS);
                SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);

                ti.uId = (UINT_PTR)GetDlgItem(hwnd, IDC_USEVIDEOENCODERSETTINGS);
                SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);

                EnableWindow(GetDlgItem(hwnd, IDC_VIDEOENCODERSETTINGS), bUseCustomX264Settings);

                //--------------------------------------------

                UINT keyframeInt = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("KeyframeInterval"), 0);
                SendMessage(GetDlgItem(hwnd, IDC_KEYFRAMEINTERVAL), UDM_SETRANGE32, 0, 20);
                SendMessage(GetDlgItem(hwnd, IDC_KEYFRAMEINTERVAL), UDM_SETPOS32, 0, keyframeInt);

                //--------------------------------------------

                bool bUnlockFPS = AppConfig->GetInt(TEXT("Video"), TEXT("UnlockFPS")) != 0;
                SendMessage(GetDlgItem(hwnd, IDC_UNLOCKHIGHFPS), BM_SETCHECK, bUnlockFPS ? BST_CHECKED : BST_UNCHECKED, 0);

                //------------------------------------

                bool bHasQSV = CheckQSVHardwareSupport(false);

                bool bUseQSV = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseQSV")) != 0;

                bool bHasNVENC = CheckNVENCHardwareSupport(false);

                bool bUseNVENC = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseNVENC")) != 0;

                EnableWindow(GetDlgItem(hwnd, IDC_USEQSV), (bHasQSV || bUseQSV) && !bUseNVENC);
                SendMessage(GetDlgItem(hwnd, IDC_USEQSV), BM_SETCHECK, bUseQSV ? BST_CHECKED : BST_UNCHECKED, 0);

                bool bQSVUseVideoEncoderSettings = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("QSVUseVideoEncoderSettings")) != 0;
                SendMessage(GetDlgItem(hwnd, IDC_QSVUSEVIDEOENCODERSETTINGS), BM_SETCHECK, bQSVUseVideoEncoderSettings ? BST_CHECKED : BST_UNCHECKED, 0);
                
                ti.lpszText = (LPWSTR)Str("Settings.Advanced.QSVUseVideoEncoderSettingsTooltip");
                ti.uId = (UINT_PTR)GetDlgItem(hwnd, IDC_QSVUSEVIDEOENCODERSETTINGS);
                SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);

                EnableWindow(GetDlgItem(hwnd, IDC_QSVUSEVIDEOENCODERSETTINGS), bUseQSV && !bUseNVENC);

                EnableWindow(GetDlgItem(hwnd, IDC_USENVENC), (bHasNVENC || bUseNVENC) && !bUseQSV);
                SendMessage(GetDlgItem(hwnd, IDC_USENVENC), BM_SETCHECK, bUseNVENC ? BST_CHECKED : BST_UNCHECKED, 0);

                //------------------------------------

                bool bSyncToVideoTime = AppConfig->GetInt(TEXT("Audio"), TEXT("SyncToVideoTime")) != 0;
                SendMessage(GetDlgItem(hwnd, IDC_SYNCTOVIDEOTIME), BM_SETCHECK, bSyncToVideoTime ? BST_CHECKED : BST_UNCHECKED, 0);

                //------------------------------------

                bool bUseMicQPC = GlobalConfig->GetInt(TEXT("Audio"), TEXT("UseMicQPC")) != 0;
                SendMessage(GetDlgItem(hwnd, IDC_USEMICQPC), BM_SETCHECK, bUseMicQPC ? BST_CHECKED : BST_UNCHECKED, 0);
                
                //------------------------------------

                BOOL bMicSyncFixHack = GlobalConfig->GetInt(TEXT("Audio"), TEXT("UseMicSyncFixHack"));
                SendMessage(GetDlgItem(hwnd, IDC_MICSYNCFIX), BM_SETCHECK, bMicSyncFixHack ? BST_CHECKED : BST_UNCHECKED, 0);

                //------------------------------------

                int bufferTime = GlobalConfig->GetInt(TEXT("General"), TEXT("SceneBufferingTime"), 700);

                int globalAudioTimeAdjust = GlobalConfig->GetInt(TEXT("Audio"), TEXT("GlobalAudioTimeAdjust"));
                SendMessage(GetDlgItem(hwnd, IDC_AUDIOTIMEADJUST), UDM_SETRANGE32, -bufferTime, 5000);
                SendMessage(GetDlgItem(hwnd, IDC_AUDIOTIMEADJUST), UDM_SETPOS32, 0, globalAudioTimeAdjust);

                //------------------------------------

                int lowLatencyFactor = AppConfig->GetInt(TEXT("Publish"), TEXT("LatencyFactor"), 20);
                SetDlgItemInt(hwnd, IDC_LATENCYTUNE, lowLatencyFactor, TRUE);

                int bLowLatencyAutoMethod = AppConfig->GetInt(TEXT("Publish"), TEXT("LowLatencyMethod"), 0);
                SendMessage(GetDlgItem(hwnd, IDC_LATENCYMETHOD), BM_SETCHECK, bLowLatencyAutoMethod ? BST_CHECKED : BST_UNCHECKED, 0);

                //------------------------------------

                MIB_IPADDRTABLE tempTable;
                DWORD dwSize = 0;
                if (GetIpAddrTable (&tempTable, &dwSize, TRUE) == ERROR_INSUFFICIENT_BUFFER)
                {
                    PMIB_IPADDRTABLE ipTable;

                    ipTable = (PMIB_IPADDRTABLE)Allocate(dwSize);

                    if (GetIpAddrTable (ipTable, &dwSize, TRUE) == NO_ERROR)
                    {
                        DWORD i;

                        hwndTemp = GetDlgItem(hwnd, IDC_BINDIP);
                        SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("Default"));

                        for (i=0; i < ipTable->dwNumEntries; i++)
                        {
                            String strAddress;
                            DWORD strLength = 32;

                            // don't allow binding to localhost
                            if ((ipTable->table[i].dwAddr & 0xFF) == 127)
                                continue;

                            strAddress.SetLength(strLength);

                            SOCKADDR_IN IP;

                            IP.sin_addr.S_un.S_addr = ipTable->table[i].dwAddr;
                            IP.sin_family = AF_INET;
                            IP.sin_port = 0;
                            zero(&IP.sin_zero, sizeof(IP.sin_zero));

                            WSAAddressToString ((LPSOCKADDR)&IP, sizeof(IP), NULL, strAddress.Array(), &strLength);
                            SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)strAddress.Array());
                        }

                        LoadSettingComboString(hwndTemp, TEXT("Publish"), TEXT("BindToIP"), TEXT("Default"));
                    }

                    Free(ipTable);
                }

                //need this as some of the dialog item sets above trigger the notifications
                ShowWindow(GetDlgItem(hwnd, IDC_INFO), SW_HIDE);
                SetChangedSettings(false);
                return TRUE;
            }

        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case IDC_USEVIDEOENCODERSETTINGS:
                    if(HIWORD(wParam) == BN_CLICKED)
                    {
                        BOOL bUseVideoEncoderSettings = SendMessage((HWND)lParam, BM_GETCHECK, 0, 0) == BST_CHECKED;
                        EnableWindow(GetDlgItem(hwnd, IDC_VIDEOENCODERSETTINGS), bUseVideoEncoderSettings);

                        ShowWindow(GetDlgItem(hwnd, IDC_INFO), SW_SHOW);
                        SetChangedSettings(true);
                    }
                    break;

                case IDC_KEYFRAMEINTERVAL_EDIT:
                case IDC_SCENEBUFFERTIME_EDIT:
                case IDC_AUDIOTIMEADJUST_EDIT:
                case IDC_VIDEOENCODERSETTINGS:
                case IDC_LATENCYTUNE:
                    if(HIWORD(wParam) == EN_CHANGE)
                    {
                        ShowWindow(GetDlgItem(hwnd, IDC_INFO), SW_SHOW);
                        SetChangedSettings(true);
                    }
                    break;

                /*case IDC_TIMER1:
                case IDC_TIMER2:
                case IDC_TIMER3:
                case IDC_DISABLED3DCOMPATIBILITY:
                    if(HIWORD(wParam) == BN_CLICKED)
                    {
                        ShowWindow(GetDlgItem(hwnd, IDC_INFO), SW_SHOW);
                        SetChangedSettings(true);
                    }
                    break;*/

                case IDC_USESENDBUFFER:
                    if(HIWORD(wParam) == BN_CLICKED)
                    {
                        BOOL bUseSendBuffer = SendMessage((HWND)lParam, BM_GETCHECK, 0, 0) == BST_CHECKED;
                        EnableWindow(GetDlgItem(hwnd, IDC_SENDBUFFERSIZE), bUseSendBuffer);

                        ShowWindow(GetDlgItem(hwnd, IDC_INFO), SW_SHOW);
                        SetChangedSettings(true);
                    }
                    break;

                case IDC_PRESET:
                    if(HIWORD(wParam) == CBN_SELCHANGE)
                    {
                        HWND hwndTemp = (HWND)lParam;

                        String strNewPreset = GetCBText(hwndTemp);
                        if (scmp(strNewPreset.Array(), TEXT("veryfast")))
                        {
                            static BOOL bHasWarned = FALSE;
                            if (!bHasWarned && MessageBox(hwnd, Str("Settings.Advanced.PresetWarning"), NULL, MB_ICONEXCLAMATION | MB_YESNO) == IDNO)
                                LoadSettingComboString(hwndTemp, TEXT("Video Encoding"), TEXT("Preset"), TEXT("veryfast"));
                            else
                                bHasWarned = TRUE;
                        }

                        SetChangedSettings(true);
                        ShowWindow(GetDlgItem(hwnd, IDC_INFO), SW_SHOW);
                    }
                    break;

                case IDC_X264PROFILE:
                case IDC_SENDBUFFERSIZE:
                case IDC_PRIORITY:
                case IDC_BINDIP:
                    if(HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE)
                    {
                        ShowWindow(GetDlgItem(hwnd, IDC_INFO), SW_SHOW);
                        SetChangedSettings(true);
                    }
                    break;

                case IDC_USEQSV:
                case IDC_USENVENC:
                    if (HIWORD(wParam) == BN_CLICKED)
                    {
                        bool bHasQSV = CheckQSVHardwareSupport(false);
                        bool bHasNVENC = CheckNVENCHardwareSupport(false);
                        bool bUseQSV = SendMessage(GetDlgItem(hwnd, IDC_USEQSV), BM_GETCHECK, 0, 0) == BST_CHECKED;
                        bool bUseNVENC = SendMessage(GetDlgItem(hwnd, IDC_USENVENC), BM_GETCHECK, 0, 0) == BST_CHECKED;
                        bool bUseQSV_prev = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseQSV")) != 0;
                        bool bUseNVENC_prev = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseNVENC")) != 0;
                        EnableWindow(GetDlgItem(hwnd, IDC_QSVUSEVIDEOENCODERSETTINGS), (bHasQSV || bUseQSV) && !bUseNVENC);
                        EnableWindow(GetDlgItem(hwnd, IDC_USEQSV), !bUseNVENC && (bHasQSV || bUseQSV_prev));
                        EnableWindow(GetDlgItem(hwnd, IDC_USENVENC), !bUseQSV && (bHasNVENC || bUseNVENC_prev));
                    }
                case IDC_DISABLEPREVIEWENCODING:
                case IDC_ALLOWOTHERHOTKEYMODIFIERS:
                case IDC_MICSYNCFIX:
                case IDC_USEMICQPC:
                case IDC_SYNCTOVIDEOTIME:
                case IDC_USECFR:
                case IDC_USEMULTITHREADEDOPTIMIZATIONS:
                case IDC_UNLOCKHIGHFPS:
                case IDC_LATENCYMETHOD:
                case IDC_QSVUSEVIDEOENCODERSETTINGS:
                    if(HIWORD(wParam) == BN_CLICKED)
                    {
                        ShowWindow(GetDlgItem(hwnd, IDC_INFO), SW_SHOW);
                        SetChangedSettings(true);
                    }
                    break;
            }

    }
    return FALSE;
}
Exemplo n.º 28
0
char* OBS::EncMetaData(char *enc, char *pend, bool bFLVFile)
{
    int    maxBitRate    = GetVideoEncoder()->GetBitRate();
    int    fps           = GetFPS();
    int    audioBitRate  = GetAudioEncoder()->GetBitRate();
    CTSTR  lpAudioCodec  = GetAudioEncoder()->GetCodec();

    double audioCodecID;
    const AVal *av_codecFourCC;

#ifdef USE_AAC
    if(scmpi(lpAudioCodec, TEXT("AAC")) == 0)
    {
        av_codecFourCC = &av_mp4a;
        audioCodecID = 10.0;
    }
    else
#endif
    {
        av_codecFourCC = &av_mp3;
        audioCodecID = 2.0;
    }

    if(bFLVFile)
    {
        *enc++ = AMF_ECMA_ARRAY;
        enc = AMF_EncodeInt32(enc, pend, 14);
    }
    else
        *enc++ = AMF_OBJECT;

    enc = AMF_EncodeNamedNumber(enc, pend, &av_duration,        0.0);
    enc = AMF_EncodeNamedNumber(enc, pend, &av_fileSize,        0.0);
    enc = AMF_EncodeNamedNumber(enc, pend, &av_width,           double(outputCX));
    enc = AMF_EncodeNamedNumber(enc, pend, &av_height,          double(outputCY));

    /*if(bFLVFile)
        enc = AMF_EncodeNamedNumber(enc, pend, &av_videocodecid,    7.0);//&av_avc1);//
    else*/
        enc = AMF_EncodeNamedString(enc, pend, &av_videocodecid,    &av_avc1);//7.0);//

    enc = AMF_EncodeNamedNumber(enc, pend, &av_videodatarate,   double(maxBitRate));
    enc = AMF_EncodeNamedNumber(enc, pend, &av_framerate,       double(fps));

    /*if(bFLVFile)
        enc = AMF_EncodeNamedNumber(enc, pend, &av_audiocodecid,    audioCodecID);//av_codecFourCC);//
    else*/
        enc = AMF_EncodeNamedString(enc, pend, &av_audiocodecid,    av_codecFourCC);//audioCodecID);//

    enc = AMF_EncodeNamedNumber(enc, pend, &av_audiodatarate,   double(audioBitRate)); //ex. 128kb\s
    enc = AMF_EncodeNamedNumber(enc, pend, &av_audiosamplerate, 44100.0);
    enc = AMF_EncodeNamedNumber(enc, pend, &av_audiosamplesize, 16.0);
    enc = AMF_EncodeNamedNumber(enc, pend, &av_audiochannels,   2.0);
    enc = AMF_EncodeNamedBoolean(enc, pend, &av_stereo,         true);
    enc = AMF_EncodeNamedString(enc, pend, &av_encoder,         &av_OBSVersion);
    *enc++ = 0;
    *enc++ = 0;
    *enc++ = AMF_OBJECT_END;

    return enc;
}
Exemplo n.º 29
0
void ConfigFile::LoadData()
{
    TSTR lpCurLine = lpFileData, lpNextLine;
    ConfigSection *lpCurSection=NULL;
    DWORD i;

    lpNextLine = schr(lpCurLine, '\r');

    while(*(lpCurLine = (lpNextLine+2)))
    {
        lpNextLine = schr(lpCurLine, '\r');
        if (!lpNextLine)
            CrashError(TEXT("Your %s file is corrupt, please delete it and re-launch OBS."), strFileName.Array());
        *lpNextLine = 0;

        if((*lpCurLine == '[') && (*(lpNextLine-1) == ']'))
        {
            lpCurSection = Sections.CreateNew();

            lpCurSection->name = sfix(sdup(lpCurLine+1));
            lpCurSection->name[lpNextLine-lpCurLine-2] = 0;
        }
        else if(lpCurSection && *lpCurLine && (*(LPWORD)lpCurLine != '//'))
        {
            TSTR lpValuePtr = schr(lpCurLine, '=');
            if (!lpValuePtr)
                CrashError(TEXT("Your %s file is corrupt, please delete it and re-launch OBS."), strFileName.Array());

            if(lpValuePtr[1] != 0)
            {
                ConfigKey *key=NULL;

                *lpValuePtr = 0;

                for(i=0; i<lpCurSection->Keys.Num(); i++)
                {
                    if(scmpi(lpCurLine, lpCurSection->Keys[i].name) == 0)
                    {
                        key = &lpCurSection->Keys[i];
                        break;
                    }
                }

                if(!key)
                {
                    key = lpCurSection->Keys.CreateNew();
                    key->name = sfix(sdup(lpCurLine));
                }

                *lpValuePtr = '=';

                lpCurLine = lpValuePtr+1;

                TSTR value = sfix(sdup(lpCurLine));
                key->ValueList << value;
            }
        }

        *lpNextLine = '\r';
    }
}
Exemplo n.º 30
0
BOOL ConfigFile::GetColorList(CTSTR lpSection, CTSTR lpKey, List<Color4> &ColorList)
{
    assert(lpSection);
    assert(lpKey);

    DWORD i,j,k;
    BOOL bFoundKey = 0;

    for(i=0; i<Sections.Num(); i++)
    {
        ConfigSection &section = Sections[i];
        if(scmpi(lpSection, section.name) == 0)
        {
            for(j=0; j<section.Keys.Num(); j++)
            {
                ConfigKey &key = section.Keys[j];
                if(scmpi(lpKey, key.name) == 0)
                {
                    for(k=0; k<key.ValueList.Num(); k++)
                    {
                        TSTR strValue = key.ValueList[k];
                        if(*strValue == '{')
                        {
                            Color4 ret;

                            ret.x = float(tstof(++strValue));

                            if(!(strValue = schr(strValue, ',')))
                                break;
                            ret.y = float(tstof(++strValue));

                            if(!(strValue = schr(strValue, ',')))
                                break;
                            ret.z = float(tstof(++strValue));

                            if(!(strValue = schr(strValue, ',')))
                                ret.w = 0.0f;
                            else
                                ret.w = float(tstof(++strValue));
                            ColorList << ret;
                        }
                        else if(*strValue == '[')
                        {
                            Color4 ret;

                            ret.x = float(tstoi(++strValue))/255.0f;

                            if(!(strValue = schr(strValue, ',')))
                                break;
                            ret.y = float(tstoi(++strValue))/255.0f;

                            if(!(strValue = schr(strValue, ',')))
                                break;
                            ret.z = float(tstoi(++strValue))/255.0f;

                            if(!(strValue = schr(strValue, ',')))
                                ret.w = 0.0f;
                            else
                                ret.w = float(tstoi(++strValue))/255.0f;

                            ColorList << ret;
                        }
                        else if( (*LPWORD(strValue) == 'x0') ||
                            (*LPWORD(strValue) == 'X0') )
                        {
                            ColorList << RGBA_to_Vect4(tstring_base_to_int(strValue+2, NULL, 16));
                        }
                    }

                    bFoundKey = 1;
                }
            }
        }
    }

    return bFoundKey;
}