| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 stringBuilder.append(" ["); | 94 stringBuilder.append(" ["); |
| 95 stringBuilder.appendNumber(r.start); | 95 stringBuilder.appendNumber(r.start); |
| 96 stringBuilder.append(';'); | 96 stringBuilder.append(';'); |
| 97 stringBuilder.appendNumber(r.end); | 97 stringBuilder.appendNumber(r.end); |
| 98 stringBuilder.append(']'); | 98 stringBuilder.append(']'); |
| 99 } | 99 } |
| 100 stringBuilder.append(" }"); | 100 stringBuilder.append(" }"); |
| 101 return stringBuilder.toString(); | 101 return stringBuilder.toString(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool hasAudioVideoTracks() { |
| 105 return RuntimeEnabledFeatures::audioVideoTracksEnabled() || |
| 106 RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled(); |
| 107 } |
| 108 |
| 104 } // namespace | 109 } // namespace |
| 105 | 110 |
| 106 SourceBuffer* SourceBuffer::create( | 111 SourceBuffer* SourceBuffer::create( |
| 107 std::unique_ptr<WebSourceBuffer> webSourceBuffer, | 112 std::unique_ptr<WebSourceBuffer> webSourceBuffer, |
| 108 MediaSource* source, | 113 MediaSource* source, |
| 109 GenericEventQueue* asyncEventQueue) { | 114 GenericEventQueue* asyncEventQueue) { |
| 110 SourceBuffer* sourceBuffer = | 115 SourceBuffer* sourceBuffer = |
| 111 new SourceBuffer(std::move(webSourceBuffer), source, asyncEventQueue); | 116 new SourceBuffer(std::move(webSourceBuffer), source, asyncEventQueue); |
| 112 sourceBuffer->suspendIfNeeded(); | 117 sourceBuffer->suspendIfNeeded(); |
| 113 return sourceBuffer; | 118 return sourceBuffer; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 "while the SourceBuffer's append " | 267 "while the SourceBuffer's append " |
| 263 "state is 'PARSING_MEDIA_SEGMENT'."); | 268 "state is 'PARSING_MEDIA_SEGMENT'."); |
| 264 return; | 269 return; |
| 265 } | 270 } |
| 266 | 271 |
| 267 // 7. Update the attribute to new timestamp offset. | 272 // 7. Update the attribute to new timestamp offset. |
| 268 m_timestampOffset = offset; | 273 m_timestampOffset = offset; |
| 269 } | 274 } |
| 270 | 275 |
| 271 AudioTrackList& SourceBuffer::audioTracks() { | 276 AudioTrackList& SourceBuffer::audioTracks() { |
| 272 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 277 DCHECK(hasAudioVideoTracks()); |
| 273 return *m_audioTracks; | 278 return *m_audioTracks; |
| 274 } | 279 } |
| 275 | 280 |
| 276 VideoTrackList& SourceBuffer::videoTracks() { | 281 VideoTrackList& SourceBuffer::videoTracks() { |
| 277 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 282 DCHECK(hasAudioVideoTracks()); |
| 278 return *m_videoTracks; | 283 return *m_videoTracks; |
| 279 } | 284 } |
| 280 | 285 |
| 281 double SourceBuffer::appendWindowStart() const { | 286 double SourceBuffer::appendWindowStart() const { |
| 282 return m_appendWindowStart; | 287 return m_appendWindowStart; |
| 283 } | 288 } |
| 284 | 289 |
| 285 void SourceBuffer::setAppendWindowStart(double start, | 290 void SourceBuffer::setAppendWindowStart(double start, |
| 286 ExceptionState& exceptionState) { | 291 ExceptionState& exceptionState) { |
| 287 BLINK_SBLOG << __func__ << " this=" << this << " start=" << start; | 292 BLINK_SBLOG << __func__ << " this=" << this << " start=" << start; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 if (isRemoved()) | 567 if (isRemoved()) |
| 563 return; | 568 return; |
| 564 | 569 |
| 565 BLINK_SBLOG << __func__ << " this=" << this; | 570 BLINK_SBLOG << __func__ << " this=" << this; |
| 566 if (m_pendingRemoveStart != -1) { | 571 if (m_pendingRemoveStart != -1) { |
| 567 cancelRemove(); | 572 cancelRemove(); |
| 568 } else { | 573 } else { |
| 569 abortIfUpdating(); | 574 abortIfUpdating(); |
| 570 } | 575 } |
| 571 | 576 |
| 572 if (RuntimeEnabledFeatures::audioVideoTracksEnabled()) { | 577 if (hasAudioVideoTracks()) { |
| 573 DCHECK(m_source); | 578 DCHECK(m_source); |
| 574 if (m_source->mediaElement()->audioTracks().length() > 0 || | 579 if (m_source->mediaElement()->audioTracks().length() > 0 || |
| 575 m_source->mediaElement()->videoTracks().length() > 0) { | 580 m_source->mediaElement()->videoTracks().length() > 0) { |
| 576 removeMediaTracks(); | 581 removeMediaTracks(); |
| 577 } | 582 } |
| 578 } | 583 } |
| 579 | 584 |
| 580 m_webSourceBuffer->removedFromMediaSource(); | 585 m_webSourceBuffer->removedFromMediaSource(); |
| 581 m_webSourceBuffer.reset(); | 586 m_webSourceBuffer.reset(); |
| 582 m_source = nullptr; | 587 m_source = nullptr; |
| 583 m_asyncEventQueue = nullptr; | 588 m_asyncEventQueue = nullptr; |
| 584 } | 589 } |
| 585 | 590 |
| 586 double SourceBuffer::highestPresentationTimestamp() { | 591 double SourceBuffer::highestPresentationTimestamp() { |
| 587 DCHECK(!isRemoved()); | 592 DCHECK(!isRemoved()); |
| 588 | 593 |
| 589 double pts = m_webSourceBuffer->highestPresentationTimestamp(); | 594 double pts = m_webSourceBuffer->highestPresentationTimestamp(); |
| 590 BLINK_SBLOG << __func__ << " this=" << this << ", pts=" << pts; | 595 BLINK_SBLOG << __func__ << " this=" << this << ", pts=" << pts; |
| 591 return pts; | 596 return pts; |
| 592 } | 597 } |
| 593 | 598 |
| 594 void SourceBuffer::removeMediaTracks() { | 599 void SourceBuffer::removeMediaTracks() { |
| 595 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 600 DCHECK(hasAudioVideoTracks()); |
| 596 // Spec: | 601 // Spec: |
| 597 // http://w3c.github.io/media-source/#widl-MediaSource-removeSourceBuffer-void
-SourceBuffer-sourceBuffer | 602 // http://w3c.github.io/media-source/#widl-MediaSource-removeSourceBuffer-void
-SourceBuffer-sourceBuffer |
| 598 DCHECK(m_source); | 603 DCHECK(m_source); |
| 599 | 604 |
| 600 HTMLMediaElement* mediaElement = m_source->mediaElement(); | 605 HTMLMediaElement* mediaElement = m_source->mediaElement(); |
| 601 DCHECK(mediaElement); | 606 DCHECK(mediaElement); |
| 602 // 3. Let SourceBuffer audioTracks list equal the AudioTrackList object | 607 // 3. Let SourceBuffer audioTracks list equal the AudioTrackList object |
| 603 // returned by sourceBuffer.audioTracks. | 608 // returned by sourceBuffer.audioTracks. |
| 604 // 4. If the SourceBuffer audioTracks list is not empty, then run the | 609 // 4. If the SourceBuffer audioTracks list is not empty, then run the |
| 605 // following steps: | 610 // following steps: |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 return trackDefault ? AtomicString(trackDefault->language()) : ""; | 754 return trackDefault ? AtomicString(trackDefault->language()) : ""; |
| 750 } | 755 } |
| 751 | 756 |
| 752 bool SourceBuffer::initializationSegmentReceived( | 757 bool SourceBuffer::initializationSegmentReceived( |
| 753 const WebVector<MediaTrackInfo>& newTracks) { | 758 const WebVector<MediaTrackInfo>& newTracks) { |
| 754 BLINK_SBLOG << __func__ << " this=" << this << " tracks=" << newTracks.size(); | 759 BLINK_SBLOG << __func__ << " this=" << this << " tracks=" << newTracks.size(); |
| 755 DCHECK(m_source); | 760 DCHECK(m_source); |
| 756 DCHECK(m_source->mediaElement()); | 761 DCHECK(m_source->mediaElement()); |
| 757 DCHECK(m_updating); | 762 DCHECK(m_updating); |
| 758 | 763 |
| 759 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) { | 764 if (!hasAudioVideoTracks()) { |
| 760 if (!m_firstInitializationSegmentReceived) { | 765 if (!m_firstInitializationSegmentReceived) { |
| 761 m_source->setSourceBufferActive(this, true); | 766 m_source->setSourceBufferActive(this, true); |
| 762 m_firstInitializationSegmentReceived = true; | 767 m_firstInitializationSegmentReceived = true; |
| 763 } | 768 } |
| 764 return true; | 769 return true; |
| 765 } | 770 } |
| 766 | 771 |
| 767 // Implementation of Initialization Segment Received, see | 772 // Implementation of Initialization Segment Received, see |
| 768 // https://w3c.github.io/media-source/#sourcebuffer-init-segment-received | 773 // https://w3c.github.io/media-source/#sourcebuffer-init-segment-received |
| 769 | 774 |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 visitor->trace(m_asyncEventQueue); | 1311 visitor->trace(m_asyncEventQueue); |
| 1307 visitor->trace(m_appendBufferAsyncPartRunner); | 1312 visitor->trace(m_appendBufferAsyncPartRunner); |
| 1308 visitor->trace(m_removeAsyncPartRunner); | 1313 visitor->trace(m_removeAsyncPartRunner); |
| 1309 visitor->trace(m_audioTracks); | 1314 visitor->trace(m_audioTracks); |
| 1310 visitor->trace(m_videoTracks); | 1315 visitor->trace(m_videoTracks); |
| 1311 EventTargetWithInlineData::trace(visitor); | 1316 EventTargetWithInlineData::trace(visitor); |
| 1312 ActiveDOMObject::trace(visitor); | 1317 ActiveDOMObject::trace(visitor); |
| 1313 } | 1318 } |
| 1314 | 1319 |
| 1315 } // namespace blink | 1320 } // namespace blink |
| OLD | NEW |