void SourceBuffer::setTimestampOffset(double offset, ExceptionState& es)
{
    // Section 3.1 timestampOffset attribute setter steps.
    // 1. Let new timestamp offset equal the new value being assigned to this attribute.
    // 2. If this object has been removed from the sourceBuffers attribute of the parent media source, then throw an
    //    InvalidStateError exception and abort these steps.
    // 3. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
    if (isRemoved() || m_updating) {
        es.throwDOMException(InvalidStateError);
        return;
    }

    // 4. If the readyState attribute of the parent media source is in the "ended" state then run the following steps:
    // 4.1 Set the readyState attribute of the parent media source to "open"
    // 4.2 Queue a task to fire a simple event named sourceopen at the parent media source.
    m_source->openIfInEndedState();

    // 5. If this object is waiting for the end of a media segment to be appended, then throw an InvalidStateError
    // and abort these steps.
    //
    // FIXME: Add step 6 text when mode attribute is implemented.
    if (!m_private->setTimestampOffset(offset)) {
        es.throwDOMException(InvalidStateError);
        return;
    }

    // 7. Update the attribute to new timestamp offset.
    m_timestampOffset = offset;
}
void SourceBuffer::setAppendWindowStart(double start, ExceptionState& es)
{
    // Enforce throwing an exception on restricted double values.
    if (std::isnan(start)
        || start == std::numeric_limits<double>::infinity()
        || start == -std::numeric_limits<double>::infinity()) {
        es.throwDOMException(TypeMismatchError);
        return;
    }

    // Section 3.1 appendWindowStart attribute setter steps.
    // 1. If this object has been removed from the sourceBuffers attribute of the parent media source then throw an
    //    InvalidStateError exception and abort these steps.
    // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
    if (isRemoved() || m_updating) {
        es.throwDOMException(InvalidStateError);
        return;
    }

    // 3. If the new value is less than 0 or greater than or equal to appendWindowEnd then throw an InvalidAccessError
    //    exception and abort these steps.
    if (start < 0 || start >= m_appendWindowEnd) {
        es.throwDOMException(InvalidAccessError);
        return;
    }

    m_private->setAppendWindowStart(start);

    // 4. Update the attribute to the new value.
    m_appendWindowStart = start;
}
Beispiel #3
0
void WebKitSourceBuffer::append(PassRefPtr<Uint8Array> data, ExceptionCode& ec)
{
    // SourceBuffer.append() steps from October 1st version of the Media Source Extensions spec.
    // https://dvcs.w3.org/hg/html-media/raw-file/7bab66368f2c/media-source/media-source.html#dom-append

    // 2. If data is null then throw an INVALID_ACCESS_ERR exception and abort these steps.
    if (!data) {
        ec = INVALID_ACCESS_ERR;
        return;
    }

    // 3. If this object has been removed from the sourceBuffers attribute of media source then throw
    //    an INVALID_STATE_ERR exception and abort these steps.
    if (isRemoved()) {
        ec = INVALID_STATE_ERR;
        return;
    }

    // 5. If the readyState attribute of media source is in the "ended" state then run the following steps:
    // 5.1. Set the readyState attribute of media source to "open"
    // 5.2. Queue a task to fire a simple event named sourceopen at media source.
    openIfInEndedState();

    // Steps 6 & beyond are handled by the private implementation.
    m_private->append(data->data(), data->length());
}
void SourceBuffer::remove(double start, double end, ExceptionState& es)
{
    // Section 3.2 remove() method steps.
    // 1. If start is negative or greater than duration, then throw an InvalidAccessError exception and abort these steps.
    // 2. If end is less than or equal to start, then throw an InvalidAccessError exception and abort these steps.
    if (start < 0 || (m_source && (std::isnan(m_source->duration()) || start > m_source->duration())) || end <= start) {
        es.throwDOMException(InvalidAccessError);
        return;
    }

    // 3. If this object has been removed from the sourceBuffers attribute of the parent media source then throw an
    //    InvalidStateError exception and abort these steps.
    // 4. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
    if (isRemoved() || m_updating) {
        es.throwDOMException(InvalidStateError);
        return;
    }

    // 5. If the readyState attribute of the parent media source is in the "ended" state then run the following steps:
    // 5.1. Set the readyState attribute of the parent media source to "open"
    // 5.2. Queue a task to fire a simple event named sourceopen at the parent media source .
    m_source->openIfInEndedState();

    // 6. Set the updating attribute to true.
    m_updating = true;

    // 7. Queue a task to fire a simple event named updatestart at this SourceBuffer object.
    scheduleEvent(eventNames().updatestartEvent);

    // 8. Return control to the caller and run the rest of the steps asynchronously.
    m_pendingRemoveStart = start;
    m_pendingRemoveEnd = end;
    m_removeTimer.startOneShot(0);
}
void SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size, ExceptionState& es)
{
    // Section 3.2 appendBuffer()
    // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data

    // Step 1 is enforced by the caller.
    // 2. If this object has been removed from the sourceBuffers attribute of the parent media source then throw an InvalidStateError exception and abort these steps.
    // 3. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
    if (isRemoved() || m_updating) {
        es.throwDOMException(InvalidStateError);
        return;
    }

    // 4. If the readyState attribute of the parent media source is in the "ended" state then run the following steps: ...
    m_source->openIfInEndedState();

    // Steps 5-6

    // 7. Add data to the end of the input buffer.
    m_pendingAppendData.append(data, size);

    // 8. Set the updating attribute to true.
    m_updating = true;

    // 9. Queue a task to fire a simple event named updatestart at this SourceBuffer object.
    scheduleEvent(eventNames().updatestartEvent);

    // 10. Asynchronously run the buffer append algorithm.
    m_appendBufferTimer.startOneShot(0);
}
void WebKitSourceBuffer::append(PassRefPtr<Uint8Array> data, ExceptionState& es)
{
    TRACE_EVENT0("media", "SourceBuffer::append");

    // SourceBuffer.append() steps from October 1st version of the Media Source Extensions spec.
    // https://dvcs.w3.org/hg/html-media/raw-file/7bab66368f2c/media-source/media-source.html#dom-append

    // 2. If data is null then throw an InvalidAccessError exception and abort these steps.
    if (!data) {
        es.throwUninformativeAndGenericDOMException(InvalidAccessError);
        return;
    }

    // 3. If this object has been removed from the sourceBuffers attribute of media source then throw
    //    an InvalidStateError exception and abort these steps.
    if (isRemoved()) {
        es.throwUninformativeAndGenericDOMException(InvalidStateError);
        return;
    }

    // 5. If the readyState attribute of media source is in the "ended" state then run the following steps:
    // 5.1. Set the readyState attribute of media source to "open"
    // 5.2. Queue a task to fire a simple event named sourceopen at media source.
    m_source->openIfInEndedState();

    // Steps 6 & beyond are handled by the private implementation.
    m_private->append(data->data(), data->length());
}
Beispiel #7
0
void WebKitSourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec)
{
    // Section 3.1 timestampOffset attribute setter steps.
    // 1. If this object has been removed from the sourceBuffers attribute of the parent media source then throw an
    //    INVALID_STATE_ERR exception and abort these steps.
    if (isRemoved()) {
        ec = INVALID_STATE_ERR;
        return;
    }

    // 4. If the readyState attribute of the parent media source is in the "ended" state then run the following steps:
    // 4.1 Set the readyState attribute of the parent media source to "open"
    // 4.2 Queue a task to fire a simple event named sourceopen at the parent media source.
    openIfInEndedState();

    // 5. If this object is waiting for the end of a media segment to be appended, then throw an INVALID_STATE_ERR
    // and abort these steps.
    if (!m_private->setTimestampOffset(offset)) {
        ec = INVALID_STATE_ERR;
        return;
    }

    // 6. Update the attribute to the new value.
    m_timestampOffset = offset;
}
Beispiel #8
0
bool Item::canDecay()
{
	if(isRemoved())
		return false;

	return items[id].canDecay;
}
void WebKitSourceBuffer::setTimestampOffset(double offset, ExceptionState& es)
{
    // Section 3.1 timestampOffset attribute setter steps.
    // 1. If this object has been removed from the sourceBuffers attribute of the parent media source then throw an
    //    InvalidStateError exception and abort these steps.
    if (isRemoved()) {
        es.throwUninformativeAndGenericDOMException(InvalidStateError);
        return;
    }

    // 4. If the readyState attribute of the parent media source is in the "ended" state then run the following steps:
    // 4.1 Set the readyState attribute of the parent media source to "open"
    // 4.2 Queue a task to fire a simple event named sourceopen at the parent media source.
    m_source->openIfInEndedState();

    // 5. If this object is waiting for the end of a media segment to be appended, then throw an InvalidStateError
    // and abort these steps.
    if (!m_private->setTimestampOffset(offset)) {
        es.throwUninformativeAndGenericDOMException(InvalidStateError);
        return;
    }

    // 6. Update the attribute to the new value.
    m_timestampOffset = offset;
}
void SourceBuffer::abort(ExceptionState& es)
{
    // Section 3.2 abort() method steps.
    // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-SourceBuffer-abort-void
    // 1. If this object has been removed from the sourceBuffers attribute of the parent media source
    //    then throw an InvalidStateError exception and abort these steps.
    // 2. If the readyState attribute of the parent media source is not in the "open" state
    //    then throw an InvalidStateError exception and abort these steps.
    if (isRemoved() || !m_source->isOpen()) {
        es.throwDOMException(InvalidStateError);
        return;
    }

    // 3. If the sourceBuffer.updating attribute equals true, then run the following steps: ...
    abortIfUpdating();

    // 4. Run the reset parser state algorithm.
    m_private->abort();

    // 5. Set appendWindowStart to 0.
    setAppendWindowStart(0, es);

    // 6. Set appendWindowEnd to positive Infinity.
    setAppendWindowEnd(std::numeric_limits<double>::infinity(), es);
}
Beispiel #11
0
void QgsComposerLegend::updateFilterByMap()
{
  if ( isRemoved() )
    return;

  if ( mComposerMap )
    mLegendModel2->setLayerStyleOverrides( mComposerMap->layerStyleOverrides() );
  else
    mLegendModel2->setLayerStyleOverrides( QMap<QString, QString>() );


  if ( mComposerMap && mLegendFilterByMap )
  {
    int dpi = mComposition->printResolution();

    QgsRectangle requestRectangle;
    mComposerMap->requestedExtent( requestRectangle );

    QSizeF theSize( requestRectangle.width(), requestRectangle.height() );
    theSize *= mComposerMap->mapUnitsToMM() * dpi / 25.4;

    QgsMapSettings ms = mComposerMap->mapSettings( requestRectangle, theSize, dpi );

    mLegendModel2->setLegendFilterByMap( &ms );
  }
  else
    mLegendModel2->setLegendFilterByMap( 0 );

  adjustBoxSize();
  update();
}
void WebKitSourceBuffer::removedFromMediaSource()
{
    if (isRemoved())
        return;

    m_private->removedFromMediaSource();
    m_source.clear();
}
Beispiel #13
0
void QgsComposerLegend::updateFilterByMap()
{
  if ( isRemoved() )
    return;
  // ask for update
  // the actual update will take place before the redraw.
  // This is to avoid multiple calls to the filter
  mFilterAskedForUpdate = true;
}
Beispiel #14
0
/*
 * You can check if you got a valid slot in return via isValid(slotID)
 */
uint16_t SlottedPage::getFirstUnusedSlot() {
    uint16_t i = (uint16_t)0;
    for(; i < header.slotCount; ++i){
        if(isRemoved(i)){
            return i;
        }
    }
    return i;
}
Beispiel #15
0
void SlottedPage::remove(uint16_t slotID) {
    if(!isRemoved(slotID)){
        if(!isIndirection(slotID)) {
            header.fragmentedSpace += slots[slotID].length;
        }
        setControlbitsToRemoved(slotID);
        header.numUnusedSlots++;
    }
}
void SourceBuffer::removedFromMediaSource()
{
    if (isRemoved())
        return;

    abortIfUpdating();

    m_private->removedFromMediaSource();
    m_source = 0;
    m_asyncEventQueue = 0;
}
Beispiel #17
0
bool Item::canDecay()
{
	if(isRemoved())
		return false;

	if(loadedFromMap && (getUniqueId() || (getActionId() && getContainer())))
		return false;

	const ItemType& it = Item::items[id];
	return it.decayTo >= 0 && it.decayTime;
}
Beispiel #18
0
int ClientPlayer::aliveCount(bool includeRemoved) const{
    int n = ClientInstance->alivePlayerCount();
    if (!includeRemoved) {
        if (isRemoved())
            n--;
        foreach (const Player *p, getAliveSiblings())
            if (p->isRemoved())
                n--;
    }
    return n;
}
Beispiel #19
0
void Npc::setIdle(bool idle)
{
	if (isRemoved() || getHealth() <= 0) {
		return;
	}

	isIdle = idle;

	if (isIdle) {
		onIdleStatus();
	}
}
PassRefPtr<TimeRanges> WebKitSourceBuffer::buffered(ExceptionState& es) const
{
    // Section 3.1 buffered attribute steps.
    // 1. If this object has been removed from the sourceBuffers attribute of the parent media source then throw an
    //    InvalidStateError exception and abort these steps.
    if (isRemoved()) {
        es.throwUninformativeAndGenericDOMException(InvalidStateError);
        return 0;
    }

    // 2. Return a new static normalized TimeRanges object for the media segments buffered.
    return m_private->buffered();
}
Beispiel #21
0
PassRefPtr<TimeRanges> WebKitSourceBuffer::buffered(ExceptionCode& ec) const
{
    // Section 3.1 buffered attribute steps.
    // 1. If this object has been removed from the sourceBuffers attribute of the parent media source then throw an
    //    INVALID_STATE_ERR exception and abort these steps.
    if (isRemoved()) {
        ec = INVALID_STATE_ERR;
        return 0;
    }

    // 2. Return a new static normalized TimeRanges object for the media segments buffered.
    return m_private->buffered();
}
void WebKitSourceBuffer::abort(ExceptionState& es)
{
    // Section 3.2 abort() method steps.
    // 1. If this object has been removed from the sourceBuffers attribute of the parent media source
    //    then throw an InvalidStateError exception and abort these steps.
    // 2. If the readyState attribute of the parent media source is not in the "open" state
    //    then throw an InvalidStateError exception and abort these steps.
    if (isRemoved() || !m_source->isOpen()) {
        es.throwUninformativeAndGenericDOMException(InvalidStateError);
        return;
    }

    // 4. Run the reset parser state algorithm.
    m_private->abort();
}
Beispiel #23
0
void WebKitSourceBuffer::abort(ExceptionCode& ec)
{
    // Section 3.2 abort() method steps.
    // 1. If this object has been removed from the sourceBuffers attribute of the parent media source
    //    then throw an INVALID_STATE_ERR exception and abort these steps.
    // 2. If the readyState attribute of the parent media source is not in the "open" state
    //    then throw an INVALID_STATE_ERR exception and abort these steps.
    if (isRemoved() || !isOpen()) {
        ec = INVALID_STATE_ERR;
        return;
    }

    // 4. Run the reset parser state algorithm.
    m_private->abort();
}
Beispiel #24
0
void BasicBlock::setStatements(const QVector<Stmt *> &newStatements)
{
    Q_ASSERT(!isRemoved());
    Q_ASSERT(newStatements.size() >= _statements.size());
    for (Stmt *s : qAsConst(_statements)) {
        if (Phi *p = s->asPhi()) {
            if (!newStatements.contains(p)) {
                // phi-node was not copied over, so:
                p->destroyData();
            }
        } else {
            break;
        }
    }
    _statements = newStatements;
}
Beispiel #25
0
void Monster::setIdle(bool _idle)
{
	if(isRemoved() || getHealth() <= 0)
		return;

	isIdle = _idle;
	if(isIdle)
	{
		onIdleStatus();
		clearTargetList();
		clearFriendList();
		g_game.removeCreatureCheck(this);
	}
	else
		g_game.addCreatureCheck(this);
}
Beispiel #26
0
void Monster::setIdle(bool idle)
{
	if (isRemoved() || getHealth() <= 0) {
		return;
	}

	isIdle = idle;

	if (!isIdle) {
		g_game.addCreatureCheck(this);
	} else {
		onIdleStatus();
		clearTargetList();
		clearFriendList();
		Game::removeCreatureCheck(this);
	}
}
int32_t Creature::getStepDuration() const
{
	if (isRemoved()) {
		return 0;
	}

	uint32_t calculatedStepSpeed;
	uint32_t groundSpeed;

	int32_t stepSpeed = getStepSpeed();

	if (stepSpeed > -Creature::speedB) {
		calculatedStepSpeed = floor((Creature::speedA * log((stepSpeed / 2) + Creature::speedB) + Creature::speedC) + 0.5);

		if (calculatedStepSpeed <= 0) {
			calculatedStepSpeed = 1;
		}
	} else {
		calculatedStepSpeed = 1;
	}

	const Tile* tile = getTile();

	if (tile && tile->ground) {
		uint32_t groundId = tile->ground->getID();
		groundSpeed = Item::items[groundId].speed;

		if (groundSpeed == 0) {
			groundSpeed = 150;
		}
	} else {
		groundSpeed = 150;
	}

	double duration = std::floor(1000 * groundSpeed / calculatedStepSpeed);

	int32_t stepDuration = std::ceil(duration / 50) * 50;

	const Monster* monster = getMonster();

	if (monster && monster->isTargetNearby() && !monster->isFleeing() && !monster->getMaster()) {
		stepDuration <<= 1;
	}

	return stepDuration;
}
Beispiel #28
0
bool Item::canDecay()
{
	if (isRemoved()) {
		return false;
	}

	if (getUniqueId() != 0) {
		return false;
	}

	const ItemType& it = Item::items[id];
	if (it.decayTo == -1 || it.decayTime == 0) {
		return false;
	}

	return true;
}
void ProtocolSpectator::login(const std::string& liveCastName, const std::string& password)
{
	//dispatcher thread
	auto _player = g_game.getPlayerByName(liveCastName);
	if (!_player || _player->isRemoved()) {
		disconnectSpectator("Live cast no longer exists. Please relogin to refresh the list.");
		return;
	}

	const auto liveCasterProtocol = ProtocolCaster::getLiveCast(_player);

	if (!liveCasterProtocol) {
		disconnectSpectator("Live cast no longer exists. Please relogin to refresh the list.");
		return;
	}

	const auto& liveCastPassword = liveCasterProtocol->getLiveCastPassword();
	if (liveCasterProtocol->isLiveCaster()) {
		if (!liveCastPassword.empty() && password != liveCastPassword) {
			disconnectSpectator("Wrong live cast password.");
			return;
		}

		if (liveCasterProtocol->isIpBan(getIP())) {
			disconnectSpectator("You have been banned from this cast.");
			return;
		}

		player = _player;
		eventConnect = 0;
		client = liveCasterProtocol;
		m_acceptPackets = true;

		sendAddCreature(player, player->getPosition(), 0, false);

		syncKnownCreatureSets();
		syncChatChannels();
		syncOpenContainers();

		liveCasterProtocol->addSpectator(this);
	} else {
		disconnectSpectator("Live cast no longer exists. Please relogin to refresh the list.");
	}
}
Beispiel #30
0
int32_t Creature::getStepDuration() const
{
	if(isRemoved()){
		return 0;
	}

	int32_t duration = 0;
	const Tile* tile = getParentTile();
	if(tile && tile->ground){
		uint32_t groundId = tile->ground->getID();
		uint16_t groundSpeed = Item::items[groundId].speed;
		uint32_t stepSpeed = getStepSpeed();
		if(stepSpeed != 0){
			duration = (1000 * groundSpeed) / stepSpeed;
		}
	}

	return duration * lastStepCost;
}