json_t* OBSAPIMessageHandler::HandleGetSceneList(OBSAPIMessageHandler* handler, json_t* message)
{
    OBSEnterSceneMutex();
    json_t* ret = GetOkResponse();
    XElement* xscenes = OBSGetSceneListElement();

    XElement* currentScene = OBSGetSceneElement();
    json_object_set_new(ret, "current-scene", json_string_wchar(currentScene->GetName()));

    json_t* scenes = json_array();
    if(scenes != NULL)
    {
        int numScenes = xscenes->NumElements();
        for(int i = 0; i < numScenes; i++)
        {
            XElement* scene = xscenes->GetElementByID(i);
            json_array_append_new(scenes, getSceneJson(scene));
        }
    }
    
    json_object_set_new(ret,"scenes", scenes);
    OBSLeaveSceneMutex();

    return ret;
}
Beispiel #2
0
void OnSceneSwitch(CTSTR scene)
{
    XElement *sceneElement;
    float desktopVolumeLevel, micVolumeLevel;
    int dMFV, mMFV;
    bool desktopMuted, micMuted;

    if(!bPSVEnabled)
        return;

    sceneElement = OBSGetSceneElement();

    if(sceneElement)
    {
        desktopVolumeLevel = sceneElement->GetFloat(TEXT("psvDesktopVolume"), 1.0f);
        micVolumeLevel = sceneElement->GetFloat(TEXT("psvMicVolume"), 1.0f);

        dMFV = sceneElement->GetInt(TEXT("psvDesktopMFV"));
        mMFV = sceneElement->GetInt(TEXT("psvMicMFV"));

        desktopMuted = (dMFV & PSV_VOL_MUTED) == PSV_VOL_MUTED;

        micMuted = (mMFV & PSV_VOL_MUTED) == PSV_VOL_MUTED;

        OBSSetDesktopVolume(desktopVolumeLevel, true);

        if(desktopMuted)
            OBSToggleDesktopMute();

        OBSSetMicVolume(micVolumeLevel, true);

        if(micMuted)
            OBSToggleMicMute();
    }
}
void WebSocketOBSTriggerHandler::SourceChanged(CTSTR sourceName, XElement* source)
{
    json_t* update = json_object();
    json_object_set_new(update, "update-type", json_string("SourceChanged"));

    XElement* xsources = OBSGetSceneElement()->GetElement(TEXT("sources"));
    
    json_object_set_new(update, "source-name", json_string_wchar(sourceName));
    
    json_object_set_new(update, "source", getSourceJson(source));

    OSEnterMutex(this->updateQueueMutex);
    this->updates.Add(update);
    OSLeaveMutex(this->updateQueueMutex);
}
Beispiel #4
0
void OnDesktopVolumeChanged(float level, bool muted, bool finalValue)
{
    XElement *sceneElement;

    if(!bPSVEnabled)
        return;

    sceneElement = OBSGetSceneElement();

    if(sceneElement)
    {
        if(!muted)
            sceneElement->SetFloat(TEXT("psvDesktopVolume"), level);

        sceneElement->SetInt(TEXT("psvDesktopMFV"), muted ? PSV_VOL_MUTED : 0);
    }
}
void WebSocketOBSTriggerHandler::SourcesAddedOrRemoved()
{
    json_t* update = json_object();
    json_object_set_new(update, "update-type", json_string("RepopulateSources"));

    XElement* xsources = OBSGetSceneElement()->GetElement(TEXT("sources"));
    
    json_t* sources = json_array();
    for(UINT i = 0; i < xsources->NumElements(); i++)
    {
        XElement* source = xsources->GetElementByID(i);

        json_array_append_new(sources, getSourceJson(source));
    }

    json_object_set_new(update, "sources", sources);

    OSEnterMutex(this->updateQueueMutex);
    this->updates.Add(update);
    OSLeaveMutex(this->updateQueueMutex);
}
void WebSocketOBSTriggerHandler::SourceOrderChanged()
{
    json_t* update = json_object();
    json_object_set_new(update, "update-type", json_string("SourceOrderChanged"));

    XElement* xsources = OBSGetSceneElement()->GetElement(TEXT("sources"));
    
    json_t* sources = json_array();
    for(UINT i = 0; i < xsources->NumElements(); i++)
    {
        XElement* source = xsources->GetElementByID(i);

        json_array_append_new(sources, json_string_wchar(source->GetName()));
    }

    json_object_set_new(update, "sources", sources);

    OSEnterMutex(this->updateQueueMutex);
    this->updates.Add(update);
    OSLeaveMutex(this->updateQueueMutex);
}
json_t* OBSAPIMessageHandler::HandleGetCurrentScene(OBSAPIMessageHandler* handler, json_t* message)
{
    OBSEnterSceneMutex();
    
    json_t* ret = GetOkResponse();

    XElement* scene = OBSGetSceneElement();
    json_object_set_new(ret, "name", json_string_wchar(scene->GetName()));

    XElement* sources = scene->GetElement(TEXT("sources"));
    json_t* scene_items = json_array();
    if(sources != NULL)
    {
        for(UINT i = 0; i < sources->NumElements(); i++)
        {
            XElement* source = sources->GetElementByID(i);
            json_array_append_new(scene_items, getSourceJson(source));
        }
    }

    json_object_set_new(ret, "sources", scene_items);
    OBSLeaveSceneMutex();
    return ret;
}