Chromium Code Reviews| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "core/html/HTMLMediaElement.h" | 42 #include "core/html/HTMLMediaElement.h" |
| 43 #include "core/html/MediaError.h" | 43 #include "core/html/MediaError.h" |
| 44 #include "core/html/TimeRanges.h" | 44 #include "core/html/TimeRanges.h" |
| 45 #include "core/html/track/AudioTrack.h" | 45 #include "core/html/track/AudioTrack.h" |
| 46 #include "core/html/track/AudioTrackList.h" | 46 #include "core/html/track/AudioTrackList.h" |
| 47 #include "core/html/track/TextTrack.h" | 47 #include "core/html/track/TextTrack.h" |
| 48 #include "core/html/track/VideoTrack.h" | 48 #include "core/html/track/VideoTrack.h" |
| 49 #include "core/html/track/VideoTrackList.h" | 49 #include "core/html/track/VideoTrackList.h" |
| 50 #include "core/streams/Stream.h" | 50 #include "core/streams/Stream.h" |
| 51 #include "modules/mediasource/MediaSource.h" | 51 #include "modules/mediasource/MediaSource.h" |
| 52 #include "modules/mediasource/SourceBufferTrackBaseSupplement.h" | |
| 52 #include "platform/Logging.h" | 53 #include "platform/Logging.h" |
| 53 #include "platform/TraceEvent.h" | 54 #include "platform/TraceEvent.h" |
| 54 #include "public/platform/WebSourceBuffer.h" | 55 #include "public/platform/WebSourceBuffer.h" |
| 55 #include "wtf/MathExtras.h" | 56 #include "wtf/MathExtras.h" |
| 56 | 57 |
| 57 #include <limits> | 58 #include <limits> |
| 58 #include <sstream> | 59 #include <sstream> |
| 59 | 60 |
| 60 using blink::WebSourceBuffer; | 61 using blink::WebSourceBuffer; |
| 61 | 62 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 // 6. If the mode attribute equals "sequence", then set the group start time stamp to new timestamp offset. | 226 // 6. If the mode attribute equals "sequence", then set the group start time stamp to new timestamp offset. |
| 226 if (!m_webSourceBuffer->setTimestampOffset(offset)) { | 227 if (!m_webSourceBuffer->setTimestampOffset(offset)) { |
| 227 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "The timestamp offset may not be set while the SourceBuffer's append state is 'P ARSING_MEDIA_SEGMENT'."); | 228 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "The timestamp offset may not be set while the SourceBuffer's append state is 'P ARSING_MEDIA_SEGMENT'."); |
| 228 return; | 229 return; |
| 229 } | 230 } |
| 230 | 231 |
| 231 // 7. Update the attribute to new timestamp offset. | 232 // 7. Update the attribute to new timestamp offset. |
| 232 m_timestampOffset = offset; | 233 m_timestampOffset = offset; |
| 233 } | 234 } |
| 234 | 235 |
| 236 AudioTrackList& SourceBuffer::audioTracks() | |
| 237 { | |
| 238 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
| 239 return *m_audioTracks; | |
|
wolenetz
2016/03/23 20:18:52
Prior to attachment of MediaSource to a MediaEleme
servolk
2016/03/31 00:03:40
Yes, I've changed this already in the previous CL.
wolenetz
2016/03/31 18:57:59
Acknowledged.
| |
| 240 } | |
| 241 | |
| 242 VideoTrackList& SourceBuffer::videoTracks() | |
| 243 { | |
| 244 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
| 245 return *m_videoTracks; | |
| 246 } | |
| 247 | |
| 235 double SourceBuffer::appendWindowStart() const | 248 double SourceBuffer::appendWindowStart() const |
| 236 { | 249 { |
| 237 return m_appendWindowStart; | 250 return m_appendWindowStart; |
| 238 } | 251 } |
| 239 | 252 |
| 240 void SourceBuffer::setAppendWindowStart(double start, ExceptionState& exceptionS tate) | 253 void SourceBuffer::setAppendWindowStart(double start, ExceptionState& exceptionS tate) |
| 241 { | 254 { |
| 242 WTF_LOG(Media, "SourceBuffer::setAppendWindowStart %p start=%f", this, start ); | 255 WTF_LOG(Media, "SourceBuffer::setAppendWindowStart %p start=%f", this, start ); |
| 243 // Section 3.1 appendWindowStart attribute setter steps. | 256 // Section 3.1 appendWindowStart attribute setter steps. |
| 244 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-SourceBuffer-appendWindowStart | 257 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-SourceBuffer-appendWindowStart |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 499 // 6. Set first initialization segment received flag to true. | 512 // 6. Set first initialization segment received flag to true. |
| 500 m_firstInitializationSegmentReceived = true; | 513 m_firstInitializationSegmentReceived = true; |
| 501 } | 514 } |
| 502 | 515 |
| 503 // TODO(servolk): Implement proper MSE init segment received algorithm. | 516 // TODO(servolk): Implement proper MSE init segment received algorithm. |
| 504 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) { | 517 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) { |
| 505 m_pendingTracks.clear(); | 518 m_pendingTracks.clear(); |
| 506 return; | 519 return; |
| 507 } | 520 } |
| 508 | 521 |
| 522 if (!m_audioTracks) | |
| 523 m_audioTracks = AudioTrackList::create(*m_source->mediaElement()); | |
| 524 if (!m_videoTracks) | |
| 525 m_videoTracks = VideoTrackList::create(*m_source->mediaElement()); | |
| 526 | |
| 509 for (const auto& trackId : m_audioTrackIds) { | 527 for (const auto& trackId : m_audioTrackIds) { |
| 510 m_source->mediaElement()->audioTracks().remove(trackId); | 528 m_source->mediaElement()->audioTracks().remove(trackId); |
| 529 audioTracks().remove(trackId); | |
| 511 } | 530 } |
| 512 for (const auto& trackId : m_videoTrackIds) { | 531 for (const auto& trackId : m_videoTrackIds) { |
| 513 m_source->mediaElement()->videoTracks().remove(trackId); | 532 m_source->mediaElement()->videoTracks().remove(trackId); |
| 533 videoTracks().remove(trackId); | |
| 514 } | 534 } |
| 515 m_audioTrackIds.clear(); | 535 m_audioTrackIds.clear(); |
| 516 m_videoTrackIds.clear(); | 536 m_videoTrackIds.clear(); |
| 517 | 537 |
| 518 for (const auto& trackId : newTracks) { | 538 for (const auto& trackId : newTracks) { |
| 519 for (const auto& track : m_pendingTracks) { | 539 for (const auto& track : m_pendingTracks) { |
| 520 if (track->trackId() == trackId) { | 540 if (track->trackId() == trackId) { |
| 521 if (track->type() == WebMediaPlayer::AudioTrack) { | 541 if (track->type() == WebMediaPlayer::AudioTrack) { |
| 522 AudioTrack* audioTrack = static_cast<AudioTrack*>(track.get( )); | 542 AudioTrack* audioTrack = static_cast<AudioTrack*>(track.get( )); |
| 523 WTF_LOG(Media, "Tracks (sb=%p): adding audioTrack %p trackId =%d id=%s label=%s lang=%s", this, audioTrack, audioTrack->trackId(), audioTrack ->id().utf8().data(), audioTrack->label().utf8().data(), audioTrack->language(). utf8().data()); | 543 WTF_LOG(Media, "Tracks (sb=%p): adding audioTrack %p trackId =%d id=%s label=%s lang=%s", this, audioTrack, audioTrack->trackId(), audioTrack ->id().utf8().data(), audioTrack->label().utf8().data(), audioTrack->language(). utf8().data()); |
| 544 audioTracks().add(audioTrack); | |
| 524 m_source->mediaElement()->audioTracks().add(audioTrack); | 545 m_source->mediaElement()->audioTracks().add(audioTrack); |
| 525 m_audioTrackIds.append(trackId); | 546 m_audioTrackIds.append(trackId); |
| 526 } else if (track->type() == WebMediaPlayer::VideoTrack) { | 547 } else if (track->type() == WebMediaPlayer::VideoTrack) { |
| 527 VideoTrack* videoTrack = static_cast<VideoTrack*>(track.get( )); | 548 VideoTrack* videoTrack = static_cast<VideoTrack*>(track.get( )); |
| 528 WTF_LOG(Media, "Tracks (sb=%p): adding videoTrack %p trackId =%d id=%s label=%s lang=%s", this, videoTrack, videoTrack->trackId(), videoTrack ->id().utf8().data(), videoTrack->label().utf8().data(), videoTrack->language(). utf8().data()); | 549 WTF_LOG(Media, "Tracks (sb=%p): adding videoTrack %p trackId =%d id=%s label=%s lang=%s", this, videoTrack, videoTrack->trackId(), videoTrack ->id().utf8().data(), videoTrack->label().utf8().data(), videoTrack->language(). utf8().data()); |
| 550 videoTracks().add(videoTrack); | |
| 529 m_source->mediaElement()->videoTracks().add(videoTrack); | 551 m_source->mediaElement()->videoTracks().add(videoTrack); |
| 530 m_videoTrackIds.append(trackId); | 552 m_videoTrackIds.append(trackId); |
| 531 } | 553 } |
| 532 break; | 554 break; |
| 533 } | 555 } |
| 534 } | 556 } |
| 535 } | 557 } |
| 536 m_pendingTracks.clear(); | 558 m_pendingTracks.clear(); |
| 537 } | 559 } |
| 538 | 560 |
| 539 WebMediaPlayer::TrackId SourceBuffer::createMediaTrack(WebMediaPlayer::TrackType type, WebString id, WebString kind, WebString label, WebString language) | 561 WebMediaPlayer::TrackId SourceBuffer::createMediaTrack(WebMediaPlayer::TrackType type, WebString id, WebString kind, WebString label, WebString language) |
| 540 { | 562 { |
| 541 TrackBase* result = nullptr; | 563 TrackBase* result = nullptr; |
| 564 const char* typeStr = ""; | |
| 542 switch (type) { | 565 switch (type) { |
| 543 case WebMediaPlayer::AudioTrack: | 566 case WebMediaPlayer::AudioTrack: |
| 544 result = AudioTrack::create(id, kind, label, language, false); | 567 result = AudioTrack::create(id, kind, label, language, false); |
| 568 new SourceBufferTrackBaseSupplement(*result, this); | |
| 569 typeStr = "audio"; | |
| 545 break; | 570 break; |
| 546 case WebMediaPlayer::TextTrack: | 571 case WebMediaPlayer::TextTrack: |
| 547 result = TextTrack::create(kind, label, language); | 572 result = TextTrack::create(kind, label, language); |
| 573 typeStr = "text"; | |
| 548 break; | 574 break; |
| 549 case WebMediaPlayer::VideoTrack: | 575 case WebMediaPlayer::VideoTrack: |
| 550 result = VideoTrack::create(id, kind, label, language, false); | 576 result = VideoTrack::create(id, kind, label, language, false); |
| 577 new SourceBufferTrackBaseSupplement(*result, this); | |
| 578 typeStr = "video"; | |
| 551 break; | 579 break; |
| 552 } | 580 } |
| 581 ASSERT_UNUSED(typeStr, typeStr); | |
| 582 WTF_LOG(Media, "SourceBuffer(%p)::createMediaTrack: %s track %p trackId=%d i d=%s label=%s lang=%s", this, typeStr, result, result->trackId(), result->id().u tf8().data(), result->label().utf8().data(), result->language().utf8().data()); | |
| 553 | 583 |
| 554 ASSERT(result); | 584 ASSERT(result); |
| 555 m_pendingTracks.append(result); | 585 m_pendingTracks.append(result); |
| 556 return result->trackId(); | 586 return result->trackId(); |
| 557 } | 587 } |
| 558 | 588 |
| 559 bool SourceBuffer::hasPendingActivity() const | 589 bool SourceBuffer::hasPendingActivity() const |
| 560 { | 590 { |
| 561 return m_source; | 591 return m_source; |
| 562 } | 592 } |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 930 visitor->trace(m_source); | 960 visitor->trace(m_source); |
| 931 visitor->trace(m_trackDefaults); | 961 visitor->trace(m_trackDefaults); |
| 932 visitor->trace(m_asyncEventQueue); | 962 visitor->trace(m_asyncEventQueue); |
| 933 visitor->trace(m_appendBufferAsyncPartRunner); | 963 visitor->trace(m_appendBufferAsyncPartRunner); |
| 934 visitor->trace(m_removeAsyncPartRunner); | 964 visitor->trace(m_removeAsyncPartRunner); |
| 935 visitor->trace(m_appendStreamAsyncPartRunner); | 965 visitor->trace(m_appendStreamAsyncPartRunner); |
| 936 visitor->trace(m_stream); | 966 visitor->trace(m_stream); |
| 937 visitor->trace(m_pendingTracks); | 967 visitor->trace(m_pendingTracks); |
| 938 visitor->trace(m_audioTrackIds); | 968 visitor->trace(m_audioTrackIds); |
| 939 visitor->trace(m_videoTrackIds); | 969 visitor->trace(m_videoTrackIds); |
| 970 visitor->trace(m_audioTracks); | |
| 971 visitor->trace(m_videoTracks); | |
| 940 RefCountedGarbageCollectedEventTargetWithInlineData<SourceBuffer>::trace(vis itor); | 972 RefCountedGarbageCollectedEventTargetWithInlineData<SourceBuffer>::trace(vis itor); |
| 941 ActiveDOMObject::trace(visitor); | 973 ActiveDOMObject::trace(visitor); |
| 942 } | 974 } |
| 943 | 975 |
| 944 } // namespace blink | 976 } // namespace blink |
| OLD | NEW |