OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "modules/mediarecorder/MediaRecorder.h" | 6 #include "modules/mediarecorder/MediaRecorder.h" |
7 | 7 |
8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
9 #include "core/dom/DOMError.h" | 9 #include "core/dom/DOMError.h" |
10 #include "core/fileapi/Blob.h" | 10 #include "core/fileapi/Blob.h" |
11 #include "core/frame/ConsoleTypes.h" | 11 #include "core/frame/ConsoleTypes.h" |
12 #include "core/inspector/ConsoleMessage.h" | 12 #include "core/inspector/ConsoleMessage.h" |
13 #include "modules/EventModules.h" | 13 #include "modules/EventModules.h" |
14 #include "modules/EventTargetModules.h" | 14 #include "modules/EventTargetModules.h" |
15 #include "modules/mediarecorder/BlobEvent.h" | 15 #include "modules/mediarecorder/BlobEvent.h" |
16 #include "modules/mediarecorder/MediaRecorderErrorEvent.h" | 16 #include "modules/mediarecorder/MediaRecorderErrorEvent.h" |
| 17 #include "platform/ContentType.h" |
17 #include "platform/NotImplemented.h" | 18 #include "platform/NotImplemented.h" |
18 #include "platform/blob/BlobData.h" | 19 #include "platform/blob/BlobData.h" |
19 #include "public/platform/Platform.h" | 20 #include "public/platform/Platform.h" |
20 #include "public/platform/WebMediaStream.h" | 21 #include "public/platform/WebMediaStream.h" |
21 | 22 |
22 namespace blink { | 23 namespace blink { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 String stateToString(MediaRecorder::State state) | 27 String stateToString(MediaRecorder::State state) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 74 } |
74 | 75 |
75 m_recorderHandler = adoptPtr(Platform::current()->createMediaRecorderHandler
()); | 76 m_recorderHandler = adoptPtr(Platform::current()->createMediaRecorderHandler
()); |
76 ASSERT(m_recorderHandler); | 77 ASSERT(m_recorderHandler); |
77 | 78 |
78 // We deviate from the spec by not returning |UnsupportedOption|, see https:
//github.com/w3c/mediacapture-record/issues/18 | 79 // We deviate from the spec by not returning |UnsupportedOption|, see https:
//github.com/w3c/mediacapture-record/issues/18 |
79 if (!m_recorderHandler) { | 80 if (!m_recorderHandler) { |
80 exceptionState.throwDOMException(NotSupportedError, "No MediaRecorder ha
ndler can be created."); | 81 exceptionState.throwDOMException(NotSupportedError, "No MediaRecorder ha
ndler can be created."); |
81 return; | 82 return; |
82 } | 83 } |
83 if (!m_recorderHandler->initialize(this, stream->descriptor(), m_mimeType))
{ | 84 ContentType contentType(m_mimeType); |
| 85 if (!m_recorderHandler->initialize(this, stream->descriptor(), contentType.t
ype(), contentType.parameter("codecs"))) { |
84 exceptionState.throwDOMException(NotSupportedError, "Failed to initializ
e native MediaRecorder, the type provided " + m_mimeType + "is unsupported." ); | 86 exceptionState.throwDOMException(NotSupportedError, "Failed to initializ
e native MediaRecorder, the type provided " + m_mimeType + "is unsupported." ); |
85 return; | 87 return; |
86 } | 88 } |
87 m_stopped = false; | 89 m_stopped = false; |
88 } | 90 } |
89 | 91 |
90 String MediaRecorder::state() const | 92 String MediaRecorder::state() const |
91 { | 93 { |
92 return stateToString(m_state); | 94 return stateToString(m_state); |
93 } | 95 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 { | 168 { |
167 RawPtr<WebMediaRecorderHandler> handler = Platform::current()->createMediaRe
corderHandler(); | 169 RawPtr<WebMediaRecorderHandler> handler = Platform::current()->createMediaRe
corderHandler(); |
168 if (!handler) | 170 if (!handler) |
169 return false; | 171 return false; |
170 | 172 |
171 // If true is returned from this method, it only indicates that the | 173 // If true is returned from this method, it only indicates that the |
172 // MediaRecorder implementation is capable of recording Blob objects for the | 174 // MediaRecorder implementation is capable of recording Blob objects for the |
173 // specified MIME type. Recording may still fail if sufficient resources are | 175 // specified MIME type. Recording may still fail if sufficient resources are |
174 // not available to support the concrete media encoding. | 176 // not available to support the concrete media encoding. |
175 // [1] https://w3c.github.io/mediacapture-record/MediaRecorder.html#methods | 177 // [1] https://w3c.github.io/mediacapture-record/MediaRecorder.html#methods |
176 return handler->canSupportMimeType(type); | 178 ContentType contentType(type); |
| 179 return handler->canSupportMimeType(contentType.type(), contentType.parameter
("codecs")); |
177 } | 180 } |
178 | 181 |
179 const AtomicString& MediaRecorder::interfaceName() const | 182 const AtomicString& MediaRecorder::interfaceName() const |
180 { | 183 { |
181 return EventTargetNames::MediaRecorder; | 184 return EventTargetNames::MediaRecorder; |
182 } | 185 } |
183 | 186 |
184 ExecutionContext* MediaRecorder::executionContext() const | 187 ExecutionContext* MediaRecorder::executionContext() const |
185 { | 188 { |
186 return ActiveDOMObject::executionContext(); | 189 return ActiveDOMObject::executionContext(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 293 |
291 DEFINE_TRACE(MediaRecorder) | 294 DEFINE_TRACE(MediaRecorder) |
292 { | 295 { |
293 visitor->trace(m_stream); | 296 visitor->trace(m_stream); |
294 visitor->trace(m_scheduledEvents); | 297 visitor->trace(m_scheduledEvents); |
295 RefCountedGarbageCollectedEventTargetWithInlineData<MediaRecorder>::trace(vi
sitor); | 298 RefCountedGarbageCollectedEventTargetWithInlineData<MediaRecorder>::trace(vi
sitor); |
296 ActiveDOMObject::trace(visitor); | 299 ActiveDOMObject::trace(visitor); |
297 } | 300 } |
298 | 301 |
299 } // namespace blink | 302 } // namespace blink |
OLD | NEW |