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

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: Prefix public Blink API AppendMode enum values with AppendMode 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 // 7. If the new mode equals "sequence", then set the group start timestamp to the highest presentation end timestamp.
131 // FIXME: Remove default no-op implementation once these steps are landed in Chromium. See http://crbug.com/249422.
132 WebSourceBuffer::AppendMode appendMode = WebSourceBuffer::AppendModeSegments ;
133 if (newMode == sequenceKeyword())
134 appendMode = WebSourceBuffer::AppendModeSequence;
135 if (!m_webSourceBuffer->setMode(appendMode)) {
136 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
137 return;
138 }
139
140 // 8. Update the attribute to new mode.
141 m_mode = newMode;
142 }
143
92 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& exceptionState) co nst 144 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& exceptionState) co nst
93 { 145 {
94 // Section 3.1 buffered attribute steps. 146 // 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 147 // 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. 148 // InvalidStateError exception and abort these steps.
97 if (isRemoved()) { 149 if (isRemoved()) {
98 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); 150 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
99 return 0; 151 return 0;
100 } 152 }
101 153
(...skipping 19 matching lines...) Expand all
121 } 173 }
122 174
123 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: 175 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps:
124 // 4.1 Set the readyState attribute of the parent media source to "open" 176 // 4.1 Set the readyState attribute of the parent media source to "open"
125 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me dia source. 177 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me dia source.
126 m_source->openIfInEndedState(); 178 m_source->openIfInEndedState();
127 179
128 // 5. If this object is waiting for the end of a media segment to be appende d, then throw an InvalidStateError 180 // 5. If this object is waiting for the end of a media segment to be appende d, then throw an InvalidStateError
129 // and abort these steps. 181 // and abort these steps.
130 // 182 //
131 // FIXME: Add step 6 text when mode attribute is implemented. 183 // FIXME: Add step 6 text when mode attribute is implemented. See http://crb ug.com/249422.
132 if (!m_webSourceBuffer->setTimestampOffset(offset)) { 184 if (!m_webSourceBuffer->setTimestampOffset(offset)) {
133 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); 185 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
134 return; 186 return;
135 } 187 }
136 188
137 // 7. Update the attribute to new timestamp offset. 189 // 7. Update the attribute to new timestamp offset.
138 m_timestampOffset = offset; 190 m_timestampOffset = offset;
139 } 191 }
140 192
141 double SourceBuffer::appendWindowStart() const 193 double SourceBuffer::appendWindowStart() const
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 appendStreamDone(true); 685 appendStreamDone(true);
634 } 686 }
635 687
636 void SourceBuffer::didFail(FileError::ErrorCode errorCode) 688 void SourceBuffer::didFail(FileError::ErrorCode errorCode)
637 { 689 {
638 WTF_LOG(Media, "SourceBuffer::didFail(%d) %p", errorCode, this); 690 WTF_LOG(Media, "SourceBuffer::didFail(%d) %p", errorCode, this);
639 appendStreamDone(false); 691 appendStreamDone(false);
640 } 692 }
641 693
642 } // namespace WebCore 694 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698