UserMediaRequest* UserMediaRequest::create(ExecutionContext* context, UserMediaController* controller, const Dictionary& options, PassOwnPtr<NavigatorUserMediaSuccessCallback> successCallback, PassOwnPtr<NavigatorUserMediaErrorCallback> errorCallback, ExceptionState& exceptionState)
{
    WebMediaConstraints audio = parseOptions(options, "audio", exceptionState);
    if (exceptionState.hadException())
        return nullptr;

    WebMediaConstraints video = parseOptions(options, "video", exceptionState);
    if (exceptionState.hadException())
        return nullptr;

    if (audio.isNull() && video.isNull()) {
        exceptionState.throwDOMException(SyntaxError, "At least one of audio and video must be requested");
        return nullptr;
    }

    return new UserMediaRequest(context, controller, audio, video, successCallback, errorCallback);
}
Exemplo n.º 2
0
UserMediaRequest* UserMediaRequest::create(ExecutionContext* context, UserMediaController* controller, const MediaStreamConstraints& options, NavigatorUserMediaSuccessCallback* successCallback, NavigatorUserMediaErrorCallback* errorCallback, MediaErrorState& errorState)
{
    WebMediaConstraints audio = parseOptions(context, options.audio(), errorState);
    if (errorState.hadException())
        return nullptr;

    WebMediaConstraints video = parseOptions(context, options.video(), errorState);
    if (errorState.hadException())
        return nullptr;

    if (audio.isNull() && video.isNull()) {
        errorState.throwDOMException(SyntaxError, "At least one of audio and video must be requested");
        return nullptr;
    }

    return new UserMediaRequest(context, controller, audio, video, successCallback, errorCallback);
}