Exemplo n.º 1
0
void MediaStream::removeRemoteTrack(MediaStreamComponent* component)
{
    if (ended())
        return;

    MediaStreamTrackVector* tracks = 0;
    switch (component->source()->type()) {
    case MediaStreamSource::TypeAudio:
        tracks = &m_audioTracks;
        break;
    case MediaStreamSource::TypeVideo:
        tracks = &m_videoTracks;
        break;
    }

    size_t index = notFound;
    for (size_t i = 0; i < tracks->size(); ++i) {
        if ((*tracks)[i]->component() == component) {
            index = i;
            break;
        }
    }
    if (index == notFound)
        return;

    RefPtr<MediaStreamTrack> track = (*tracks)[index];
    tracks->remove(index);
    scheduleDispatchEvent(MediaStreamTrackEvent::create(eventNames().removetrackEvent, false, false, track));
}
Exemplo n.º 2
0
void MediaStream::removeRemoteSource(MediaStreamSource* source)
{
    if (ended())
        return;

    MediaStreamTrackVector* tracks = 0;
    switch (source->type()) {
    case MediaStreamSource::Audio:
        tracks = &m_audioTracks;
        break;
    case MediaStreamSource::Video:
        tracks = &m_videoTracks;
        break;
    }

    size_t index = notFound;
    for (size_t i = 0; i < tracks->size(); ++i) {
        if ((*tracks)[i]->source() == source) {
            index = i;
            break;
        }
    }
    if (index == notFound)
        return;

    m_descriptor->removeSource(source);

    RefPtr<MediaStreamTrack> track = (*tracks)[index];
    tracks->remove(index);
    scheduleDispatchEvent(MediaStreamTrackEvent::create(eventNames().removetrackEvent, false, false, track));
}
Exemplo n.º 3
0
void MediaStream::removeRemoteTrack(MediaStreamComponent* component) {
  DCHECK(component);
  if (m_executionContext->isContextDestroyed())
    return;

  MediaStreamTrackVector* tracks = 0;
  switch (component->source()->type()) {
    case MediaStreamSource::TypeAudio:
      tracks = &m_audioTracks;
      break;
    case MediaStreamSource::TypeVideo:
      tracks = &m_videoTracks;
      break;
  }

  size_t index = kNotFound;
  for (size_t i = 0; i < tracks->size(); ++i) {
    if ((*tracks)[i]->component() == component) {
      index = i;
      break;
    }
  }
  if (index == kNotFound)
    return;

  m_descriptor->removeComponent(component);

  MediaStreamTrack* track = (*tracks)[index];
  track->unregisterMediaStream(this);
  tracks->remove(index);
  scheduleDispatchEvent(
      MediaStreamTrackEvent::create(EventTypeNames::removetrack, track));

  if (active() && emptyOrOnlyEndedTracks()) {
    m_descriptor->setActive(false);
    scheduleDispatchEvent(Event::create(EventTypeNames::inactive));
  }
}