示例#1
0
void XMLHttpRequestClass::requestTimeout() {
    if (_onTimeout.isFunction()) {
        _onTimeout.call(QScriptValue::NullValue);
    }
    abortRequest();
    _errorCode = QNetworkReply::TimeoutError;
    setReadyState(DONE);
    emit requestComplete();
}
示例#2
0
void XMLHttpRequest::followRedirect(const QUrl &url) {
    Logger::log("XMLHttpRequest::followRedirect(): URL: " + url.toString());
    m_redirects++;
    m_response = QByteArray();
    m_reply = networkAccessManager()->get(QNetworkRequest(url));
    setReadyState(OPENED);
    connect(m_reply, SIGNAL(metaDataChanged()), this, SLOT(onReplyMetaDataChanged()));
    connect(m_reply, SIGNAL(readyRead()), this, SLOT(onReplyReadyRead()));
    connect(m_reply, SIGNAL(finished()), this, SLOT(onReplyFinished()));
}
示例#3
0
void HTMLTrackElement::loadTimerFired(TimerBase*) {
  DVLOG(TRACK_LOG_LEVEL) << "loadTimerFired";

  // 6. [X] Set the text track readiness state to loading.
  setReadyState(kLoading);

  // 7. [X] Let URL be the track URL of the track element.
  KURL url = getNonEmptyURLAttribute(srcAttr);

  // 8. [X] If the track element's parent is a media element then let CORS mode
  // be the state of the parent media element's crossorigin content attribute.
  // Otherwise, let CORS mode be No CORS.
  const AtomicString& corsMode = mediaElementCrossOriginAttribute();

  // 9. End the synchronous section, continuing the remaining steps in parallel.

  // 10. If URL is not the empty string, perform a potentially CORS-enabled
  // fetch of URL, with the mode being CORS mode, the origin being the origin of
  // the track element's node document, and the default origin behaviour set to
  // fail.
  if (!canLoadUrl(url)) {
    didCompleteLoad(Failure);
    return;
  }

  if (url == m_url) {
    DCHECK(m_loader);
    switch (m_loader->loadState()) {
      case TextTrackLoader::Idle:
      case TextTrackLoader::Loading:
        // If loading of the resource from this URL is in progress, return
        // early.
        break;
      case TextTrackLoader::Finished:
        didCompleteLoad(Success);
        break;
      case TextTrackLoader::Failed:
        didCompleteLoad(Failure);
        break;
      default:
        NOTREACHED();
    }
    return;
  }

  m_url = url;

  if (m_loader)
    m_loader->cancelLoad();

  m_loader = TextTrackLoader::create(*this, document());
  if (!m_loader->load(m_url, crossOriginAttributeValue(corsMode)))
    didCompleteLoad(Failure);
}
示例#4
0
void
BuildLayer::setSelectedState(Module* module)
{
  mSelectedModule = module;
  mAngle = 0;
  mPort = 0;
  if(NULL != mSelectedModule) {
    mState = STATE_SELECTED;
    mPrototype = mSelectedModule->getPrototype();
  }
  else {
    setReadyState();
  }
}
示例#5
0
void HTMLTrackElement::didCompleteLoad(LoadStatus status) {
  // 10. ... (continued)

  // If the fetching algorithm fails for any reason (network error, the server
  // returns an error code, a cross-origin check fails, etc), or if URL is the
  // empty string, then queue a task to first change the text track readiness
  // state to failed to load and then fire a simple event named error at the
  // track element. This task must use the DOM manipulation task source.
  //
  // (Note: We don't "queue a task" here because this method will only be called
  // from a timer - m_loadTimer or TextTrackLoader::m_cueLoadTimer - which
  // should be a reasonable, and hopefully non-observable, approximation of the
  // spec text. I.e we could consider this to be run from the "networking task
  // source".)
  //
  // If the fetching algorithm does not fail, but the type of the resource is
  // not a supported text track format, or the file was not successfully
  // processed (e.g. the format in question is an XML format and the file
  // contained a well-formedness error that the XML specification requires be
  // detected and reported to the application), then the task that is queued by
  // the networking task source in which the aforementioned problem is found
  // must change the text track readiness state to failed to load and fire a
  // simple event named error at the track element.
  if (status == Failure) {
    setReadyState(kError);
    dispatchEvent(Event::create(EventTypeNames::error));
    return;
  }

  // If the fetching algorithm does not fail, and the file was successfully
  // processed, then the final task that is queued by the networking task
  // source, after it has finished parsing the data, must change the text track
  // readiness state to loaded, and fire a simple event named load at the track
  // element.
  setReadyState(kLoaded);
  dispatchEvent(Event::create(EventTypeNames::load));
}
void MediaPlayerPrivateAVFoundation::load(const String& url)
{
    LOG(Media, "MediaPlayerPrivateAVFoundation::load(%p)", this);

    setNetworkState(m_preload == MediaPlayer::None ? MediaPlayer::Idle : MediaPlayer::Loading);
    setReadyState(MediaPlayer::HaveNothing);

    m_assetURL = url;

    // Don't do any more work if the url is empty.
    if (!url.length())
        return;

    setPreload(m_preload);
}
示例#7
0
void MediaStreamSource::stop()
{
    for (Vector<Observer*>::iterator i = m_observers.begin(); i != m_observers.end(); ++i) {
        if (!(*i)->stopped())
            return;
    }

    // There are no more consumers of this source's data, shut it down as appropriate.
    setReadyState(Ended);

    // http://www.w3.org/TR/mediacapture-streams/#widl-MediaStreamTrack-stop-void
    // If the data is being generated from a live source (e.g., a microphone or camera), then the user 
    // agent should remove any active "on-air" indicator for that source. If the data is being 
    // generated from a prerecorded source (e.g. a video file), any remaining content in the file is ignored.
}
示例#8
0
bool
BuildLayer::mouseClickEvent(int buttonID, unsigned clickCount, int x, int y)
{
  if(0 == buttonID && 1 == clickCount && NULL != mStation) {
    if(STATE_ADD == mState) {
      if(MOUSEOVER_PORT == mMouseOver && NULL != mPrototype) {
        Module* target = mPrototype->createModule();
        Matrix portAlignTransform = mPrototype->getTransformAgainstPort(mPort, mMouseOverModule->getPrototype(), mMouseOverPortIndex, mAngle);
        Matrix fullTransform = portAlignTransform * mMouseOverModule->getTransform();
        target->setTransform(fullTransform);
        mStation->addModule(target);
        Mission* mission = mStation->getMission();
        if(mission->getAspects()->isCredits()) {
          mission->creditTransaction(-mPrototype->getSimFloat(SIM_COST_HARDWARE));
        }
        mission->useActionPoint();        
        // --------------------------------------------------------------------------------
        // Profile: Update number of modules added
        //         ConfigManager::getPlayer()->mModulesAdded++;
        return true;    

      }
    }
    else if(STATE_SELECTED == mState && MOUSEOVER_PORT == mMouseOver && NULL != mSelectedModule) {
        Matrix portAlignTransform = mPrototype->getTransformAgainstPort(mPort, mMouseOverModule->getPrototype(), mMouseOverPortIndex, mAngle);
        Matrix fullTransform = portAlignTransform * mMouseOverModule->getTransform();
        mStation->disconnectModule(mSelectedModule);
        mSelectedModule->setTransform(fullTransform);
        mStation->connectModule(mSelectedModule);
        mStation->getMission()->useActionPoint();
        return true;      
    }
    if(MOUSEOVER_BACKGROUND == mMouseOver) {
      setReadyState();
    }
    else if(MOUSEOVER_MODULE == mMouseOver) {
      setSelectedState(mMouseOverModule);
    }
  }
  
  return false;
}
示例#9
0
void MediaSource::append(const String& id, PassRefPtr<Uint8Array> data, ExceptionCode& ec)
{
    if (!data.get()) {
        ec = INVALID_ACCESS_ERR;
        return;
    }

    if (!m_player || m_readyState == closedKeyword()) {
        ec = INVALID_STATE_ERR;
        return;
    }

    if (m_readyState == endedKeyword())
        setReadyState(openKeyword());

    if (!m_player->sourceAppend(id, data->data(), data->length())) {
        ec = SYNTAX_ERR;
        return;
    }
}
void HTMLTrackElement::loadTimerFired(Timer<HTMLTrackElement>*)
{
    if (!fastHasAttribute(srcAttr))
        return;

    WTF_LOG(Media, "HTMLTrackElement::loadTimerFired");

    // 6. Set the text track readiness state to loading.
    setReadyState(HTMLTrackElement::LOADING);

    // 7. Let URL be the track URL of the track element.
    KURL url = getNonEmptyURLAttribute(srcAttr);

    // 8. If the track element's parent is a media element then let CORS mode be the state of the parent media
    // element's crossorigin content attribute. Otherwise, let CORS mode be No CORS.
    if (!canLoadUrl(url)) {
        didCompleteLoad(HTMLTrackElement::Failure);
        return;
    }

    ensureTrack()->scheduleLoad(url);
}
示例#11
0
void XMLHttpRequest::open(const QString &method, const QString &url, const QString &username, const QString &password) {
    Logger::log(QString("XMLHttpRequest::open(). Method: %1, URL: %2, Username: %3, Password: %4")
                       .arg(method).arg(url).arg(username).arg(password));
    
    switch (readyState()) {
    case OPENED:
    case HEADERS_RECEIVED:
    case LOADING:
        return;
    default:
        break;
    }
    
    m_method = method.toUtf8();
    m_request.setUrl(QUrl::fromUserInput(url));

    if ((!username.isEmpty()) || (!password.isEmpty())) {
        m_request.setRawHeader("Authorization", "Basic " + QString("%1:%2").arg(username).arg(password).toUtf8()
                                                                           .toBase64());
    }
    
    setReadyState(OPENED);
}
void XMLHttpRequestClass::requestDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
    if (_readyState == OPENED && bytesReceived > 0) {
        setReadyState(HEADERS_RECEIVED);
        setReadyState(LOADING);
    }
}
示例#13
0
void MediaSource::streamEndedWithError(const AtomicString& error, ExceptionCode& ec)
{
    static NeverDestroyed<const AtomicString> network("network", AtomicString::ConstructFromLiteral);
    static NeverDestroyed<const AtomicString> decode("decode", AtomicString::ConstructFromLiteral);

    LOG(MediaSource, "MediaSource::streamEndedWithError(%p) : %s", this, error.string().ascii().data());

    // 2.4.7 https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#end-of-stream-algorithm

    // 1. Change the readyState attribute value to "ended".
    // 2. Queue a task to fire a simple event named sourceended at the MediaSource.
    setReadyState(endedKeyword());

    // 3.
    if (error.isEmpty()) {
        // ↳ If error is not set, is null, or is an empty string
        // 1. Run the duration change algorithm with new duration set to the highest end time reported by
        // the buffered attribute across all SourceBuffer objects in sourceBuffers.
        MediaTime maxEndTime;
        for (auto& sourceBuffer : *m_sourceBuffers) {
            if (auto length = sourceBuffer->buffered()->length())
                maxEndTime = std::max(sourceBuffer->buffered()->ranges().end(length - 1), maxEndTime);
        }
        setDurationInternal(maxEndTime);

        // 2. Notify the media element that it now has all of the media data.
        m_private->markEndOfStream(MediaSourcePrivate::EosNoError);
    }

    if (error == network) {
        // ↳ If error is set to "network"
        ASSERT(m_mediaElement);
        if (m_mediaElement->readyState() == HTMLMediaElement::HAVE_NOTHING) {
            //  ↳ If the HTMLMediaElement.readyState attribute equals HAVE_NOTHING
            //    Run the "If the media data cannot be fetched at all, due to network errors, causing
            //    the user agent to give up trying to fetch the resource" steps of the resource fetch algorithm.
            //    NOTE: This step is handled by HTMLMediaElement::mediaLoadingFailed().
            m_mediaElement->mediaLoadingFailed(MediaPlayer::NetworkError);
        } else {
            //  ↳ If the HTMLMediaElement.readyState attribute is greater than HAVE_NOTHING
            //    Run the "If the connection is interrupted after some media data has been received, causing the
            //    user agent to give up trying to fetch the resource" steps of the resource fetch algorithm.
            //    NOTE: This step is handled by HTMLMediaElement::mediaLoadingFailedFatally().
            m_mediaElement->mediaLoadingFailedFatally(MediaPlayer::NetworkError);
        }
    } else if (error == decode) {
        // ↳ If error is set to "decode"
        ASSERT(m_mediaElement);
        if (m_mediaElement->readyState() == HTMLMediaElement::HAVE_NOTHING) {
            //  ↳ If the HTMLMediaElement.readyState attribute equals HAVE_NOTHING
            //    Run the "If the media data can be fetched but is found by inspection to be in an unsupported
            //    format, or can otherwise not be rendered at all" steps of the resource fetch algorithm.
            //    NOTE: This step is handled by HTMLMediaElement::mediaLoadingFailed().
            m_mediaElement->mediaLoadingFailed(MediaPlayer::FormatError);
        } else {
            //  ↳ If the HTMLMediaElement.readyState attribute is greater than HAVE_NOTHING
            //    Run the media data is corrupted steps of the resource fetch algorithm.
            //    NOTE: This step is handled by HTMLMediaElement::mediaLoadingFailedFatally().
            m_mediaElement->mediaLoadingFailedFatally(MediaPlayer::DecodeError);
        }
    } else if (!error.isEmpty()) {
        // ↳ Otherwise
        //   Throw an INVALID_ACCESS_ERR exception.
        ec = INVALID_ACCESS_ERR;
    }
}
示例#14
0
void LoadableTextTrack::trackLoadCompleted()
{
    setReadyState(TextTrack::LOADED);
}
示例#15
0
void LoadableTextTrack::trackLoadError()
{
    setReadyState(TextTrack::ERROR);
}
void MediaPlayerPrivateAVFoundation::updateStates()
{
    if (m_ignoreLoadStateChanges)
        return;

    MediaPlayer::NetworkState newNetworkState = m_networkState;
    MediaPlayer::ReadyState newReadyState = m_readyState;

    if (m_loadingMetadata)
        newNetworkState = MediaPlayer::Loading;
    else {
        // -loadValuesAsynchronouslyForKeys:completionHandler: has invoked its handler; test status of keys and determine state.
        AssetStatus assetStatus = this->assetStatus();
        ItemStatus itemStatus = playerItemStatus();
        
        m_assetIsPlayable = (assetStatus == MediaPlayerAVAssetStatusPlayable);
        if (m_readyState < MediaPlayer::HaveMetadata && assetStatus > MediaPlayerAVAssetStatusLoading) {
            if (m_assetIsPlayable) {
                if (assetStatus >= MediaPlayerAVAssetStatusLoaded)
                    newReadyState = MediaPlayer::HaveMetadata;
                if (itemStatus <= MediaPlayerAVPlayerItemStatusUnknown) {
                    if (assetStatus == MediaPlayerAVAssetStatusFailed || m_preload > MediaPlayer::MetaData || isLiveStream()) {
                        // The asset is playable but doesn't support inspection prior to playback (eg. streaming files),
                        // or we are supposed to prepare for playback immediately, so create the player item now.
                        newNetworkState = MediaPlayer::Loading;
                        prepareToPlay();
                    } else
                        newNetworkState = MediaPlayer::Idle;
                }
            } else {
                // FIX ME: fetch the error associated with the @"playable" key to distinguish between format 
                // and network errors.
                newNetworkState = MediaPlayer::FormatError;
            }
        }
        
        if (assetStatus >= MediaPlayerAVAssetStatusLoaded && itemStatus > MediaPlayerAVPlayerItemStatusUnknown) {
            switch (itemStatus) {
            case MediaPlayerAVPlayerItemStatusDoesNotExist:
            case MediaPlayerAVPlayerItemStatusUnknown:
            case MediaPlayerAVPlayerItemStatusFailed:
                break;

            case MediaPlayerAVPlayerItemStatusPlaybackLikelyToKeepUp:
            case MediaPlayerAVPlayerItemStatusPlaybackBufferFull:
                // If the status becomes PlaybackBufferFull, loading stops and the status will not
                // progress to LikelyToKeepUp. Set the readyState to  HAVE_ENOUGH_DATA, on the
                // presumption that if the playback buffer is full, playback will probably not stall.
                newReadyState = MediaPlayer::HaveEnoughData;
                break;

            case MediaPlayerAVPlayerItemStatusReadyToPlay:
                if (m_readyState != MediaPlayer::HaveEnoughData && maxTimeLoaded() > currentMediaTime())
                    newReadyState = MediaPlayer::HaveFutureData;
                break;

            case MediaPlayerAVPlayerItemStatusPlaybackBufferEmpty:
                newReadyState = MediaPlayer::HaveCurrentData;
                break;
            }

            if (itemStatus == MediaPlayerAVPlayerItemStatusPlaybackBufferFull)
                newNetworkState = MediaPlayer::Idle;
            else if (itemStatus == MediaPlayerAVPlayerItemStatusFailed)
                newNetworkState = MediaPlayer::DecodeError;
            else if (itemStatus != MediaPlayerAVPlayerItemStatusPlaybackBufferFull && itemStatus >= MediaPlayerAVPlayerItemStatusReadyToPlay)
                newNetworkState = (maxTimeLoaded() == durationMediaTime()) ? MediaPlayer::Loaded : MediaPlayer::Loading;
        }
    }

    if (isReadyForVideoSetup() && currentRenderingMode() != preferredRenderingMode())
        setUpVideoRendering();

    if (!m_haveReportedFirstVideoFrame && m_cachedHasVideo && hasAvailableVideoFrame()) {
        if (m_readyState < MediaPlayer::HaveCurrentData)
            newReadyState = MediaPlayer::HaveCurrentData;
        m_haveReportedFirstVideoFrame = true;
        m_player->firstVideoFrameAvailable();
    }

#if !LOG_DISABLED
    if (m_networkState != newNetworkState || m_readyState != newReadyState) {
        LOG(Media, "MediaPlayerPrivateAVFoundation::updateStates(%p) - entered with networkState = %i, readyState = %i,  exiting with networkState = %i, readyState = %i",
            this, static_cast<int>(m_networkState), static_cast<int>(m_readyState), static_cast<int>(newNetworkState), static_cast<int>(newReadyState));
    }
#endif

    setNetworkState(newNetworkState);
    setReadyState(newReadyState);

    if (m_playWhenFramesAvailable && hasAvailableVideoFrame()) {
        m_playWhenFramesAvailable = false;
        platformPlay();
    }
}
示例#17
0
void LoadableTextTrack::cueLoadingStarted(TextTrackLoader* loader)
{
    ASSERT_UNUSED(loader, m_loader == loader);
    
    setReadyState(TextTrack::Loading);
}
示例#18
0
void MediaSource::close()
{
    setReadyState(closedKeyword());
}
示例#19
0
void LoadableTextTrack::trackLoadStarted()
{
    setReadyState(TextTrack::LOADING);
}