Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Side by Side Diff: Source/modules/mediasource/SourceBuffer.cpp

Issue 130523002: Preliminary work for unprefixed MSE SourceBuffer.mode manipulation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 RefPtr<SourceBuffer> sourceBuffer(adoptRef(new SourceBuffer(webSourceBuffer, source, asyncEventQueue))); 58 RefPtr<SourceBuffer> sourceBuffer(adoptRef(new SourceBuffer(webSourceBuffer, source, asyncEventQueue)));
59 sourceBuffer->suspendIfNeeded(); 59 sourceBuffer->suspendIfNeeded();
60 return sourceBuffer.release(); 60 return sourceBuffer.release();
61 } 61 }
62 62
63 SourceBuffer::SourceBuffer(PassOwnPtr<WebSourceBuffer> webSourceBuffer, MediaSou rce* source, GenericEventQueue* asyncEventQueue) 63 SourceBuffer::SourceBuffer(PassOwnPtr<WebSourceBuffer> webSourceBuffer, MediaSou rce* source, GenericEventQueue* asyncEventQueue)
64 : ActiveDOMObject(source->executionContext()) 64 : ActiveDOMObject(source->executionContext())
65 , m_webSourceBuffer(webSourceBuffer) 65 , m_webSourceBuffer(webSourceBuffer)
66 , m_source(source) 66 , m_source(source)
67 , m_asyncEventQueue(asyncEventQueue) 67 , m_asyncEventQueue(asyncEventQueue)
68 , m_mode(segmentsKeyword())
68 , m_updating(false) 69 , m_updating(false)
69 , m_timestampOffset(0) 70 , m_timestampOffset(0)
70 , m_appendWindowStart(0) 71 , m_appendWindowStart(0)
71 , m_appendWindowEnd(std::numeric_limits<double>::infinity()) 72 , m_appendWindowEnd(std::numeric_limits<double>::infinity())
72 , m_appendBufferAsyncPartRunner(this, &SourceBuffer::appendBufferAsyncPart) 73 , m_appendBufferAsyncPartRunner(this, &SourceBuffer::appendBufferAsyncPart)
73 , m_pendingRemoveStart(-1) 74 , m_pendingRemoveStart(-1)
74 , m_pendingRemoveEnd(-1) 75 , m_pendingRemoveEnd(-1)
75 , m_removeAsyncPartRunner(this, &SourceBuffer::removeAsyncPart) 76 , m_removeAsyncPartRunner(this, &SourceBuffer::removeAsyncPart)
76 , m_streamMaxSizeValid(false) 77 , m_streamMaxSizeValid(false)
77 , m_streamMaxSize(0) 78 , m_streamMaxSize(0)
78 , m_appendStreamAsyncPartRunner(this, &SourceBuffer::appendStreamAsyncPart) 79 , m_appendStreamAsyncPartRunner(this, &SourceBuffer::appendStreamAsyncPart)
79 { 80 {
80 ASSERT(m_webSourceBuffer); 81 ASSERT(m_webSourceBuffer);
81 ASSERT(m_source); 82 ASSERT(m_source);
82 ScriptWrappable::init(this); 83 ScriptWrappable::init(this);
83 } 84 }
84 85
85 SourceBuffer::~SourceBuffer() 86 SourceBuffer::~SourceBuffer()
86 { 87 {
87 ASSERT(isRemoved()); 88 ASSERT(isRemoved());
88 ASSERT(!m_loader); 89 ASSERT(!m_loader);
89 ASSERT(!m_stream); 90 ASSERT(!m_stream);
90 } 91 }
91 92
93 const AtomicString& SourceBuffer::segmentsKeyword()
94 {
95 DEFINE_STATIC_LOCAL(const AtomicString, segments, ("segments", AtomicString: :ConstructFromLiteral));
96 return segments;
97 }
98
99 const AtomicString& SourceBuffer::sequenceKeyword()
100 {
101 DEFINE_STATIC_LOCAL(const AtomicString, sequence, ("sequence", AtomicString: :ConstructFromLiteral));
102 return sequence;
103 }
104
105 void SourceBuffer::setMode(const AtomicString& newMode, ExceptionState& exceptio nState)
106 {
107 // Section 3.1 On setting mode attribute steps.
108 // 1. Let new mode equal the new value being assigned to this attribute.
109 // 2. If new mode does not equal "segments" or "sequence", then throw an INV ALID_ACCESS_ERR exception and abort
110 // these steps.
111 if (newMode != segmentsKeyword() && newMode != sequenceKeyword()) {
112 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
113 return;
114 }
115
116 // 3. If this object has been removed from the sourceBuffers attribute of th e parent media source, then throw
117 // an INVALID_STATE_ERR exception and abort these steps.
118 // 4. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps.
119 if (isRemoved() || m_updating) {
120 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
121 return;
122 }
123
124 // 5. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps:
125 // 5.1 Set the readyState attribute of the parent media source to "open"
126 // 5.2 Queue a task to fire a simple event named sourceopen at the parent me dia source.
127 m_source->openIfInEndedState();
128
129 // 6. If the append state equals PARSING_MEDIA_SEGMENT, then throw an INVALI D_STATE_ERR and abort these steps.
130 // TODO(wolenetz): Figure out how to enforce this step. See http://crbug.com /249422.
acolwell GONE FROM CHROMIUM 2014/01/09 02:53:58 I'd recommmend you just have your m_source->setMod
wolenetz 2014/01/09 21:43:11 Done.
131
132 // 7. If the new mode equals "sequence", then set the group start timestamp to the highest presentation end
133 // timestamp.
134 // TODO(wolenetz): Figure out how to enforce this step. See http://crbug.com /249422.
135
136 // 8. Update the attribute to new mode.
137 m_mode = newMode;
138 }
139
92 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& exceptionState) co nst 140 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& exceptionState) co nst
93 { 141 {
94 // Section 3.1 buffered attribute steps. 142 // Section 3.1 buffered attribute steps.
95 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an 143 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
96 // InvalidStateError exception and abort these steps. 144 // InvalidStateError exception and abort these steps.
97 if (isRemoved()) { 145 if (isRemoved()) {
98 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); 146 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
99 return 0; 147 return 0;
100 } 148 }
101 149
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 appendStreamDone(true); 681 appendStreamDone(true);
634 } 682 }
635 683
636 void SourceBuffer::didFail(FileError::ErrorCode errorCode) 684 void SourceBuffer::didFail(FileError::ErrorCode errorCode)
637 { 685 {
638 WTF_LOG(Media, "SourceBuffer::didFail(%d) %p", errorCode, this); 686 WTF_LOG(Media, "SourceBuffer::didFail(%d) %p", errorCode, this);
639 appendStreamDone(false); 687 appendStreamDone(false);
640 } 688 }
641 689
642 } // namespace WebCore 690 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698