Пример #1
0
void RemoteMediaStream::AddTrack(FB::JSAPIPtr pTrack)
{
    if("video" == pTrack->GetProperty("kind").convert_cast<std::string>())
    {
        m_videoTracks.push_back(FB::variant(pTrack));
    }
    else if("audio" == pTrack->GetProperty("kind").convert_cast<std::string>())
    {
        m_audioTracks.push_back(FB::variant(pTrack));
    }
}
Пример #2
0
// Methods to manage properties on the API
FB::variant IDispatchAPI::GetProperty(const std::string& propertyName)
{
    if (!host->isMainThread()) {
        return host->CallOnMainThread(boost::bind((FB::GetPropertyType)&IDispatchAPI::GetProperty, this, propertyName));
    }
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            return tmp->GetProperty(propertyName);
        else 
            return false;
    }

    DISPPARAMS params;
    params.cArgs = 0;
    params.cNamedArgs = 0;

    VARIANT res;
    EXCEPINFO eInfo;

    HRESULT hr = E_NOTIMPL;
    CComQIPtr<IDispatchEx> dispex(m_obj);
    if (dispex) {
        hr = dispex->InvokeEx(getIDForName(FB::utf8_to_wstring(propertyName)), LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &params,
            &res, &eInfo, NULL);
    } else {
        hr = m_obj->Invoke(getIDForName(FB::utf8_to_wstring(propertyName)), IID_NULL, LOCALE_USER_DEFAULT,
            DISPATCH_PROPERTYGET, &params, &res, NULL, NULL);
    }
    if (SUCCEEDED(hr)) {
        return m_browser->getVariant(&res);
    } else {
        throw FB::script_error("Could not get property");
    }
}
Пример #3
0
// Methods to manage properties on the API
FB::variant NPObjectAPI::GetProperty(const std::string& propertyName)
{
    if (m_browser.expired())
        return FB::FBVoid();

    NpapiBrowserHostPtr browser(getHost());
    if (!browser->isMainThread()) {
        return browser->CallOnMainThread(boost::bind((FB::GetPropertyType)&JSAPI::GetProperty, this, propertyName));
    }
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            return tmp->GetProperty(propertyName);
        else 
            return false;
    }
    NPVariant retVal;
    if (!browser->GetProperty(obj, browser->GetStringIdentifier(propertyName.c_str()), &retVal)) {
        browser->ReleaseVariantValue(&retVal);
        throw script_error(propertyName.c_str());
    } else {
        FB::variant ret = browser->getVariant(&retVal);
        browser->ReleaseVariantValue(&retVal);
        return ret;
    }
}
Пример #4
0
// Methods to manage properties on the API
FB::variant IDispatchAPI::GetProperty(const std::string& propertyName)
{
    if (m_browser.expired() || m_obj.expired())
        return FB::FBVoid();

    ActiveXBrowserHostPtr browser(getHost());
    if (!browser->isMainThread()) {
        return browser->CallOnMainThread(boost::bind((FB::GetPropertyType)&IDispatchAPI::GetProperty, this, propertyName));
    }
    
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (!tmp) {
            return false;
        }
        return tmp->GetProperty(propertyName);
    }

    DISPID dispId = getIDForName(FB::utf8_to_wstring(propertyName));
    if (dispId == DISPID_UNKNOWN && propertyName != "toString") {
        throw FB::script_error("Could not get property");
    }

    // TODO: how can toString == DISPID_UNKNOWN work?

    DISPPARAMS params;
    params.cArgs = 0;
    params.cNamedArgs = 0;

    HRESULT hr;
    CComVariant result;
    CComExcepInfo exceptionInfo;
    try {
        CComQIPtr<IDispatchEx> dispatchEx(getIDispatch());
        if (dispatchEx) {
            hr = dispatchEx->InvokeEx(dispId, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &params,
                &result, &exceptionInfo, NULL);
        } else {
            hr = getIDispatch()->Invoke(dispId, IID_NULL, LOCALE_USER_DEFAULT,
                DISPATCH_PROPERTYGET, &params, &result, &exceptionInfo, NULL);
        }

        if (FAILED(hr)) {
            throw FB::script_error("Could not get property");
        }

        return browser->getVariant(&result);
    } catch (...) {
        throw FB::script_error("Could not get property");
    }
}
Пример #5
0
FB::variant NPObjectAPI::GetProperty(int idx)
{
    if (m_browser.expired())
        return FB::FBVoid();

    NpapiBrowserHostPtr browser(getHost());
    std::string strIdx(boost::lexical_cast<std::string>(idx));
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            return tmp->GetProperty(idx);
    }
    return GetProperty(strIdx);
}
Пример #6
0
FB::variant GCPAPI::RemoveStream(const FB::JSAPIPtr& stream)
{
    GoCast::RtcCenter* pCtr = GoCast::RtcCenter::Instance();
    
    if(false == pCtr->Inited())
    {
        std::string msg = m_htmlId.convert_cast<std::string>();
        msg += ": Failed to init RtcCenter singleton";
        FBLOG_ERROR_CUSTOM("GCPAPI::RemoveStream", msg);
        return false;
    }
    
    return pCtr->RemoveStream(m_htmlId.convert_cast<std::string>(),
                              stream->GetProperty("label").convert_cast<std::string>());
}