| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 // 4.3 For each AudioTrack object in the SourceBuffer audioTracks list, run
the following steps: | 516 // 4.3 For each AudioTrack object in the SourceBuffer audioTracks list, run
the following steps: |
| 517 while (audioTracks().length() > 0) { | 517 while (audioTracks().length() > 0) { |
| 518 AudioTrack* audioTrack = audioTracks().anonymousIndexedGetter(0); | 518 AudioTrack* audioTrack = audioTracks().anonymousIndexedGetter(0); |
| 519 // 4.3.1 Set the sourceBuffer attribute on the AudioTrack object to null
. | 519 // 4.3.1 Set the sourceBuffer attribute on the AudioTrack object to null
. |
| 520 SourceBufferTrackBaseSupplement::setSourceBuffer(*audioTrack, nullptr); | 520 SourceBufferTrackBaseSupplement::setSourceBuffer(*audioTrack, nullptr); |
| 521 // 4.3.2 If the enabled attribute on the AudioTrack object is true, then
set the removed enabled audio track flag to true. | 521 // 4.3.2 If the enabled attribute on the AudioTrack object is true, then
set the removed enabled audio track flag to true. |
| 522 if (audioTrack->enabled()) | 522 if (audioTrack->enabled()) |
| 523 removedEnabledAudioTrack = true; | 523 removedEnabledAudioTrack = true; |
| 524 // 4.3.3 Remove the AudioTrack object from the HTMLMediaElement audioTra
cks list. | 524 // 4.3.3 Remove the AudioTrack object from the HTMLMediaElement audioTra
cks list. |
| 525 // 4.3.4 Queue a task to fire a trusted event named removetrack, that do
es not bubble and is not cancelable, and that uses the TrackEvent interface, at
the HTMLMediaElement audioTracks list. | 525 // 4.3.4 Queue a task to fire a trusted event named removetrack, that do
es not bubble and is not cancelable, and that uses the TrackEvent interface, at
the HTMLMediaElement audioTracks list. |
| 526 mediaElement->audioTracks().remove(audioTrack->trackId()); | 526 mediaElement->audioTracks().remove(audioTrack->id()); |
| 527 // 4.3.5 Remove the AudioTrack object from the SourceBuffer audioTracks
list. | 527 // 4.3.5 Remove the AudioTrack object from the SourceBuffer audioTracks
list. |
| 528 // 4.3.6 Queue a task to fire a trusted event named removetrack, that do
es not bubble and is not cancelable, and that uses the TrackEvent interface, at
the SourceBuffer audioTracks list. | 528 // 4.3.6 Queue a task to fire a trusted event named removetrack, that do
es not bubble and is not cancelable, and that uses the TrackEvent interface, at
the SourceBuffer audioTracks list. |
| 529 audioTracks().remove(audioTrack->trackId()); | 529 audioTracks().remove(audioTrack->id()); |
| 530 } | 530 } |
| 531 // 4.4 If the removed enabled audio track flag equals true, then queue a tas
k to fire a simple event named change at the HTMLMediaElement audioTracks list. | 531 // 4.4 If the removed enabled audio track flag equals true, then queue a tas
k to fire a simple event named change at the HTMLMediaElement audioTracks list. |
| 532 if (removedEnabledAudioTrack) { | 532 if (removedEnabledAudioTrack) { |
| 533 Event* event = Event::create(EventTypeNames::change); | 533 Event* event = Event::create(EventTypeNames::change); |
| 534 event->setTarget(&mediaElement->audioTracks()); | 534 event->setTarget(&mediaElement->audioTracks()); |
| 535 mediaElement->scheduleEvent(event); | 535 mediaElement->scheduleEvent(event); |
| 536 } | 536 } |
| 537 | 537 |
| 538 // 5. Let SourceBuffer videoTracks list equal the VideoTrackList object retu
rned by sourceBuffer.videoTracks. | 538 // 5. Let SourceBuffer videoTracks list equal the VideoTrackList object retu
rned by sourceBuffer.videoTracks. |
| 539 // 6. If the SourceBuffer videoTracks list is not empty, then run the follow
ing steps: | 539 // 6. If the SourceBuffer videoTracks list is not empty, then run the follow
ing steps: |
| 540 // 6.1 Let HTMLMediaElement videoTracks list equal the VideoTrackList object
returned by the videoTracks attribute on the HTMLMediaElement. | 540 // 6.1 Let HTMLMediaElement videoTracks list equal the VideoTrackList object
returned by the videoTracks attribute on the HTMLMediaElement. |
| 541 // 6.2 Let the removed selected video track flag equal false. | 541 // 6.2 Let the removed selected video track flag equal false. |
| 542 bool removedSelectedVideoTrack = false; | 542 bool removedSelectedVideoTrack = false; |
| 543 // 6.3 For each VideoTrack object in the SourceBuffer videoTracks list, run
the following steps: | 543 // 6.3 For each VideoTrack object in the SourceBuffer videoTracks list, run
the following steps: |
| 544 while (videoTracks().length() > 0) { | 544 while (videoTracks().length() > 0) { |
| 545 VideoTrack* videoTrack = videoTracks().anonymousIndexedGetter(0); | 545 VideoTrack* videoTrack = videoTracks().anonymousIndexedGetter(0); |
| 546 // 6.3.1 Set the sourceBuffer attribute on the VideoTrack object to null
. | 546 // 6.3.1 Set the sourceBuffer attribute on the VideoTrack object to null
. |
| 547 SourceBufferTrackBaseSupplement::setSourceBuffer(*videoTrack, nullptr); | 547 SourceBufferTrackBaseSupplement::setSourceBuffer(*videoTrack, nullptr); |
| 548 // 6.3.2 If the selected attribute on the VideoTrack object is true, the
n set the removed selected video track flag to true. | 548 // 6.3.2 If the selected attribute on the VideoTrack object is true, the
n set the removed selected video track flag to true. |
| 549 if (videoTrack->selected()) | 549 if (videoTrack->selected()) |
| 550 removedSelectedVideoTrack = true; | 550 removedSelectedVideoTrack = true; |
| 551 // 6.3.3 Remove the VideoTrack object from the HTMLMediaElement videoTra
cks list. | 551 // 6.3.3 Remove the VideoTrack object from the HTMLMediaElement videoTra
cks list. |
| 552 // 6.3.4 Queue a task to fire a trusted event named removetrack, that do
es not bubble and is not cancelable, and that uses the TrackEvent interface, at
the HTMLMediaElement videoTracks list. | 552 // 6.3.4 Queue a task to fire a trusted event named removetrack, that do
es not bubble and is not cancelable, and that uses the TrackEvent interface, at
the HTMLMediaElement videoTracks list. |
| 553 mediaElement->videoTracks().remove(videoTrack->trackId()); | 553 mediaElement->videoTracks().remove(videoTrack->id()); |
| 554 // 6.3.5 Remove the VideoTrack object from the SourceBuffer videoTracks
list. | 554 // 6.3.5 Remove the VideoTrack object from the SourceBuffer videoTracks
list. |
| 555 // 6.3.6 Queue a task to fire a trusted event named removetrack, that do
es not bubble and is not cancelable, and that uses the TrackEvent interface, at
the SourceBuffer videoTracks list. | 555 // 6.3.6 Queue a task to fire a trusted event named removetrack, that do
es not bubble and is not cancelable, and that uses the TrackEvent interface, at
the SourceBuffer videoTracks list. |
| 556 videoTracks().remove(videoTrack->trackId()); | 556 videoTracks().remove(videoTrack->id()); |
| 557 } | 557 } |
| 558 // 6.4 If the removed selected video track flag equals true, then queue a ta
sk to fire a simple event named change at the HTMLMediaElement videoTracks list. | 558 // 6.4 If the removed selected video track flag equals true, then queue a ta
sk to fire a simple event named change at the HTMLMediaElement videoTracks list. |
| 559 if (removedSelectedVideoTrack) { | 559 if (removedSelectedVideoTrack) { |
| 560 Event* event = Event::create(EventTypeNames::change); | 560 Event* event = Event::create(EventTypeNames::change); |
| 561 event->setTarget(&mediaElement->videoTracks()); | 561 event->setTarget(&mediaElement->videoTracks()); |
| 562 mediaElement->scheduleEvent(event); | 562 mediaElement->scheduleEvent(event); |
| 563 } | 563 } |
| 564 | 564 |
| 565 // 7-8. TODO(servolk): Remove text tracks once SourceBuffer has text tracks. | 565 // 7-8. TODO(servolk): Remove text tracks once SourceBuffer has text tracks. |
| 566 } | 566 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 583 DCHECK(m_source); | 583 DCHECK(m_source); |
| 584 DCHECK(m_source->mediaElement()); | 584 DCHECK(m_source->mediaElement()); |
| 585 DCHECK(m_updating); | 585 DCHECK(m_updating); |
| 586 | 586 |
| 587 // TODO(servolk): Implement proper 'initialization segment received' algorit
hm according to MSE spec: | 587 // TODO(servolk): Implement proper 'initialization segment received' algorit
hm according to MSE spec: |
| 588 // https://w3c.github.io/media-source/#sourcebuffer-init-segment-received | 588 // https://w3c.github.io/media-source/#sourcebuffer-init-segment-received |
| 589 WebVector<WebMediaPlayer::TrackId> result(newTracks.size()); | 589 WebVector<WebMediaPlayer::TrackId> result(newTracks.size()); |
| 590 unsigned resultIdx = 0; | 590 unsigned resultIdx = 0; |
| 591 for (const auto& trackInfo : newTracks) { | 591 for (const auto& trackInfo : newTracks) { |
| 592 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) { | 592 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) { |
| 593 static WebMediaPlayer::TrackId nextTrackId = 0; | 593 static unsigned nextTrackId = 0; |
| 594 result[resultIdx++] = ++nextTrackId; | 594 StringBuilder stringBuilder; |
| 595 stringBuilder.appendNumber(++nextTrackId); |
| 596 result[resultIdx++] = stringBuilder.toString(); |
| 595 continue; | 597 continue; |
| 596 } | 598 } |
| 597 | 599 |
| 598 const TrackBase* trackBase = nullptr; | 600 const TrackBase* trackBase = nullptr; |
| 599 if (trackInfo.trackType == WebMediaPlayer::AudioTrack) { | 601 if (trackInfo.trackType == WebMediaPlayer::AudioTrack) { |
| 600 AudioTrack* audioTrack = nullptr; | 602 AudioTrack* audioTrack = nullptr; |
| 601 if (!m_firstInitializationSegmentReceived) { | 603 if (!m_firstInitializationSegmentReceived) { |
| 602 audioTrack = AudioTrack::create(trackInfo.byteStreamTrackId, tra
ckInfo.kind, trackInfo.label, trackInfo.language, false); | 604 audioTrack = AudioTrack::create(trackInfo.id, trackInfo.kind, tr
ackInfo.label, trackInfo.language, false); |
| 603 SourceBufferTrackBaseSupplement::setSourceBuffer(*audioTrack, th
is); | 605 SourceBufferTrackBaseSupplement::setSourceBuffer(*audioTrack, th
is); |
| 604 audioTracks().add(audioTrack); | 606 audioTracks().add(audioTrack); |
| 605 m_source->mediaElement()->audioTracks().add(audioTrack); | 607 m_source->mediaElement()->audioTracks().add(audioTrack); |
| 606 } else { | 608 } else { |
| 607 audioTrack = findExistingTrackById(audioTracks(), trackInfo.byte
StreamTrackId); | 609 audioTrack = findExistingTrackById(audioTracks(), trackInfo.id); |
| 608 DCHECK(audioTrack); | 610 DCHECK(audioTrack); |
| 609 } | 611 } |
| 610 trackBase = audioTrack; | 612 trackBase = audioTrack; |
| 611 result[resultIdx++] = audioTrack->trackId(); | 613 result[resultIdx++] = audioTrack->id(); |
| 612 } else if (trackInfo.trackType == WebMediaPlayer::VideoTrack) { | 614 } else if (trackInfo.trackType == WebMediaPlayer::VideoTrack) { |
| 613 VideoTrack* videoTrack = nullptr; | 615 VideoTrack* videoTrack = nullptr; |
| 614 if (!m_firstInitializationSegmentReceived) { | 616 if (!m_firstInitializationSegmentReceived) { |
| 615 videoTrack = VideoTrack::create(trackInfo.byteStreamTrackId, tra
ckInfo.kind, trackInfo.label, trackInfo.language, false); | 617 videoTrack = VideoTrack::create(trackInfo.id, trackInfo.kind, tr
ackInfo.label, trackInfo.language, false); |
| 616 SourceBufferTrackBaseSupplement::setSourceBuffer(*videoTrack, th
is); | 618 SourceBufferTrackBaseSupplement::setSourceBuffer(*videoTrack, th
is); |
| 617 videoTracks().add(videoTrack); | 619 videoTracks().add(videoTrack); |
| 618 m_source->mediaElement()->videoTracks().add(videoTrack); | 620 m_source->mediaElement()->videoTracks().add(videoTrack); |
| 619 } else { | 621 } else { |
| 620 videoTrack = findExistingTrackById(videoTracks(), trackInfo.byte
StreamTrackId); | 622 videoTrack = findExistingTrackById(videoTracks(), trackInfo.id); |
| 621 DCHECK(videoTrack); | 623 DCHECK(videoTrack); |
| 622 } | 624 } |
| 623 trackBase = videoTrack; | 625 trackBase = videoTrack; |
| 624 result[resultIdx++] = videoTrack->trackId(); | 626 result[resultIdx++] = videoTrack->id(); |
| 625 } else { | 627 } else { |
| 626 NOTREACHED(); | 628 NOTREACHED(); |
| 627 } | 629 } |
| 628 (void)trackBase; | 630 (void)trackBase; |
| 629 #if !LOG_DISABLED | 631 #if !LOG_DISABLED |
| 630 const char* logActionStr = m_firstInitializationSegmentReceived ? "using
existing" : "added"; | 632 const char* logActionStr = m_firstInitializationSegmentReceived ? "using
existing" : "added"; |
| 631 const char* logTrackTypeStr = (trackInfo.trackType == WebMediaPlayer::Au
dioTrack) ? "audio" : "video"; | 633 const char* logTrackTypeStr = (trackInfo.trackType == WebMediaPlayer::Au
dioTrack) ? "audio" : "video"; |
| 632 SBLOG << __FUNCTION__ << "(" << this << ") " << logActionStr << " " | 634 SBLOG << __FUNCTION__ << "(" << this << ") " << logActionStr << " " |
| 633 << logTrackTypeStr << " Track " << trackBase << "trackId=" << trackB
ase->trackId() << " id=" | 635 << logTrackTypeStr << " Track " << trackBase << " id=" << String(tra
ckBase->id()) |
| 634 << trackBase->id() << " label=" << trackBase->label() << " lang=" <<
trackBase->language(); | 636 << " label=" << trackBase->label() << " lang=" << trackBase->languag
e(); |
| 635 #endif | 637 #endif |
| 636 } | 638 } |
| 637 | 639 |
| 638 if (!m_firstInitializationSegmentReceived) { | 640 if (!m_firstInitializationSegmentReceived) { |
| 639 // 5. If active track flag equals true, then run the following steps: | 641 // 5. If active track flag equals true, then run the following steps: |
| 640 // 5.1. Add this SourceBuffer to activeSourceBuffers. | 642 // 5.1. Add this SourceBuffer to activeSourceBuffers. |
| 641 // 5.2. Queue a task to fire a simple event named addsourcebuffer at | 643 // 5.2. Queue a task to fire a simple event named addsourcebuffer at |
| 642 // activesourcebuffers. | 644 // activesourcebuffers. |
| 643 m_source->setSourceBufferActive(this); | 645 m_source->setSourceBufferActive(this); |
| 644 | 646 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 visitor->trace(m_removeAsyncPartRunner); | 1030 visitor->trace(m_removeAsyncPartRunner); |
| 1029 visitor->trace(m_appendStreamAsyncPartRunner); | 1031 visitor->trace(m_appendStreamAsyncPartRunner); |
| 1030 visitor->trace(m_stream); | 1032 visitor->trace(m_stream); |
| 1031 visitor->trace(m_audioTracks); | 1033 visitor->trace(m_audioTracks); |
| 1032 visitor->trace(m_videoTracks); | 1034 visitor->trace(m_videoTracks); |
| 1033 EventTargetWithInlineData::trace(visitor); | 1035 EventTargetWithInlineData::trace(visitor); |
| 1034 ActiveDOMObject::trace(visitor); | 1036 ActiveDOMObject::trace(visitor); |
| 1035 } | 1037 } |
| 1036 | 1038 |
| 1037 } // namespace blink | 1039 } // namespace blink |
| OLD | NEW |