| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 { | 62 { |
| 63 LOG(Media, "MediaSource::~MediaSource %p", this); | 63 LOG(Media, "MediaSource::~MediaSource %p", this); |
| 64 ASSERT(isClosed()); | 64 ASSERT(isClosed()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionCode& ec
) | 67 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionCode& ec
) |
| 68 { | 68 { |
| 69 LOG(Media, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), this)
; | 69 LOG(Media, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), this)
; |
| 70 | 70 |
| 71 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media
-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type | 71 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media
-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type |
| 72 // 1. If type is null or an empty then throw an INVALID_ACCESS_ERR exception
and | 72 // 1. If type is null or an empty then throw an InvalidAccessError exception
and |
| 73 // abort these steps. | 73 // abort these steps. |
| 74 if (type.isNull() || type.isEmpty()) { | 74 if (type.isNull() || type.isEmpty()) { |
| 75 ec = INVALID_ACCESS_ERR; | 75 ec = InvalidAccessError; |
| 76 return 0; | 76 return 0; |
| 77 } | 77 } |
| 78 | 78 |
| 79 // 2. If type contains a MIME type that is not supported ..., then throw a | 79 // 2. If type contains a MIME type that is not supported ..., then throw a |
| 80 // NotSupportedError exception and abort these steps. | 80 // NotSupportedError exception and abort these steps. |
| 81 if (!isTypeSupported(type)) { | 81 if (!isTypeSupported(type)) { |
| 82 ec = NotSupportedError; | 82 ec = NotSupportedError; |
| 83 return 0; | 83 return 0; |
| 84 } | 84 } |
| 85 | 85 |
| 86 // 4. If the readyState attribute is not in the "open" state then throw an | 86 // 4. If the readyState attribute is not in the "open" state then throw an |
| 87 // INVALID_STATE_ERR exception and abort these steps. | 87 // InvalidStateError exception and abort these steps. |
| 88 if (!isOpen()) { | 88 if (!isOpen()) { |
| 89 ec = INVALID_STATE_ERR; | 89 ec = InvalidStateError; |
| 90 return 0; | 90 return 0; |
| 91 } | 91 } |
| 92 | 92 |
| 93 // 5. Create a new SourceBuffer object and associated resources. | 93 // 5. Create a new SourceBuffer object and associated resources. |
| 94 ContentType contentType(type); | 94 ContentType contentType(type); |
| 95 Vector<String> codecs = contentType.codecs(); | 95 Vector<String> codecs = contentType.codecs(); |
| 96 OwnPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(
contentType.type(), codecs, ec); | 96 OwnPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(
contentType.type(), codecs, ec); |
| 97 | 97 |
| 98 if (!sourceBufferPrivate) { | 98 if (!sourceBufferPrivate) { |
| 99 ASSERT(ec == NotSupportedError || ec == QUOTA_EXCEEDED_ERR); | 99 ASSERT(ec == NotSupportedError || ec == QUOTA_EXCEEDED_ERR); |
| 100 // 2. If type contains a MIME type that is not supported ..., then throw
a NotSupportedError exception and abort these steps. | 100 // 2. If type contains a MIME type that is not supported ..., then throw
a NotSupportedError exception and abort these steps. |
| 101 // 3. If the user agent can't handle any more SourceBuffer objects then
throw a QUOTA_EXCEEDED_ERR exception and abort these steps | 101 // 3. If the user agent can't handle any more SourceBuffer objects then
throw a QUOTA_EXCEEDED_ERR exception and abort these steps |
| 102 return 0; | 102 return 0; |
| 103 } | 103 } |
| 104 | 104 |
| 105 RefPtr<SourceBuffer> buffer = SourceBuffer::create(sourceBufferPrivate.relea
se(), this, asyncEventQueue()); | 105 RefPtr<SourceBuffer> buffer = SourceBuffer::create(sourceBufferPrivate.relea
se(), this, asyncEventQueue()); |
| 106 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that
object. | 106 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that
object. |
| 107 m_sourceBuffers->add(buffer); | 107 m_sourceBuffers->add(buffer); |
| 108 m_activeSourceBuffers->add(buffer); | 108 m_activeSourceBuffers->add(buffer); |
| 109 // 7. Return the new object to the caller. | 109 // 7. Return the new object to the caller. |
| 110 return buffer.get(); | 110 return buffer.get(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionCode& ec) | 113 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionCode& ec) |
| 114 { | 114 { |
| 115 LOG(Media, "MediaSource::removeSourceBuffer() %p", this); | 115 LOG(Media, "MediaSource::removeSourceBuffer() %p", this); |
| 116 RefPtr<SourceBuffer> protect(buffer); | 116 RefPtr<SourceBuffer> protect(buffer); |
| 117 | 117 |
| 118 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media
-source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer | 118 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media
-source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer |
| 119 // 1. If sourceBuffer is null then throw an INVALID_ACCESS_ERR exception and | 119 // 1. If sourceBuffer is null then throw an InvalidAccessError exception and |
| 120 // abort these steps. | 120 // abort these steps. |
| 121 if (!buffer) { | 121 if (!buffer) { |
| 122 ec = INVALID_ACCESS_ERR; | 122 ec = InvalidAccessError; |
| 123 return; | 123 return; |
| 124 } | 124 } |
| 125 | 125 |
| 126 // 2. If sourceBuffer specifies an object that is not in sourceBuffers then | 126 // 2. If sourceBuffer specifies an object that is not in sourceBuffers then |
| 127 // throw a NotFoundError exception and abort these steps. | 127 // throw a NotFoundError exception and abort these steps. |
| 128 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) { | 128 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) { |
| 129 ec = NotFoundError; | 129 ec = NotFoundError; |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 | 132 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 void MediaSource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 212 void MediaSource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
| 213 { | 213 { |
| 214 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); | 214 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); |
| 215 ScriptWrappable::reportMemoryUsage(memoryObjectInfo); | 215 ScriptWrappable::reportMemoryUsage(memoryObjectInfo); |
| 216 MediaSourceBase::reportMemoryUsage(memoryObjectInfo); | 216 MediaSourceBase::reportMemoryUsage(memoryObjectInfo); |
| 217 info.addMember(m_sourceBuffers, "sourceBuffers"); | 217 info.addMember(m_sourceBuffers, "sourceBuffers"); |
| 218 info.addMember(m_activeSourceBuffers, "activeSourceBuffers"); | 218 info.addMember(m_activeSourceBuffers, "activeSourceBuffers"); |
| 219 } | 219 } |
| 220 | 220 |
| 221 } // namespace WebCore | 221 } // namespace WebCore |
| OLD | NEW |