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 "core/dom/DOMError.h" | 9 #include "core/dom/DOMError.h" |
9 #include "core/fileapi/Blob.h" | 10 #include "core/fileapi/Blob.h" |
10 #include "core/frame/ConsoleTypes.h" | 11 #include "core/frame/ConsoleTypes.h" |
11 #include "core/inspector/ConsoleMessage.h" | 12 #include "core/inspector/ConsoleMessage.h" |
12 #include "modules/EventModules.h" | 13 #include "modules/EventModules.h" |
13 #include "modules/EventTargetModules.h" | 14 #include "modules/EventTargetModules.h" |
14 #include "modules/mediarecorder/BlobEvent.h" | 15 #include "modules/mediarecorder/BlobEvent.h" |
15 #include "modules/mediarecorder/MediaRecorderErrorEvent.h" | 16 #include "modules/mediarecorder/MediaRecorderErrorEvent.h" |
16 #include "platform/NotImplemented.h" | 17 #include "platform/NotImplemented.h" |
17 #include "platform/blob/BlobData.h" | 18 #include "platform/blob/BlobData.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
34 } | 35 } |
35 | 36 |
36 ASSERT_NOT_REACHED(); | 37 ASSERT_NOT_REACHED(); |
37 return String(); | 38 return String(); |
38 } | 39 } |
39 | 40 |
40 } // namespace | 41 } // namespace |
41 | 42 |
42 MediaRecorder* MediaRecorder::create(ExecutionContext* context, MediaStream* str eam, ExceptionState& exceptionState) | 43 MediaRecorder* MediaRecorder::create(ExecutionContext* context, MediaStream* str eam, ExceptionState& exceptionState) |
43 { | 44 { |
44 MediaRecorder* recorder = new MediaRecorder(context, stream, String(), excep tionState); | 45 MediaRecorder* recorder = new MediaRecorder(context, stream, MediaRecorderOp tions(), exceptionState); |
45 recorder->suspendIfNeeded(); | 46 recorder->suspendIfNeeded(); |
46 | 47 |
47 return recorder; | 48 return recorder; |
48 } | 49 } |
49 | 50 |
50 MediaRecorder* MediaRecorder::create(ExecutionContext* context, MediaStream* str eam, const String& mimeType, ExceptionState& exceptionState) | 51 MediaRecorder* MediaRecorder::create(ExecutionContext* context, MediaStream* str eam, const MediaRecorderOptions& options, ExceptionState& exceptionState) |
51 { | 52 { |
52 MediaRecorder* recorder = new MediaRecorder(context, stream, mimeType, excep tionState); | 53 MediaRecorder* recorder = new MediaRecorder(context, stream, options, except ionState); |
53 recorder->suspendIfNeeded(); | 54 recorder->suspendIfNeeded(); |
54 | 55 |
55 return recorder; | 56 return recorder; |
56 } | 57 } |
57 | 58 |
58 MediaRecorder::MediaRecorder(ExecutionContext* context, MediaStream* stream, con st String& mimeType, ExceptionState& exceptionState) | 59 MediaRecorder::MediaRecorder(ExecutionContext* context, MediaStream* stream, con st MediaRecorderOptions& options, ExceptionState& exceptionState) |
59 : ActiveDOMObject(context) | 60 : ActiveDOMObject(context) |
60 , m_stream(stream) | 61 , m_stream(stream) |
61 , m_mimeType(mimeType) | 62 , m_mimeType(options.mimeType()) |
62 , m_stopped(true) | 63 , m_stopped(true) |
63 , m_ignoreMutedMedia(true) | 64 , m_ignoreMutedMedia(true) |
64 , m_state(State::Inactive) | 65 , m_state(State::Inactive) |
65 , m_dispatchScheduledEventRunner(this, &MediaRecorder::dispatchScheduledEven t) | 66 , m_dispatchScheduledEventRunner(this, &MediaRecorder::dispatchScheduledEven t) |
66 { | 67 { |
67 ASSERT(m_stream->getTracks().size()); | 68 ASSERT(m_stream->getTracks().size()); |
68 | 69 |
69 // Recording remote Audio streams is not supported: http://crbug.com/121673. | 70 // Recording remote Audio streams is not supported: http://crbug.com/121673. |
70 if (!stream->getAudioTracks().isEmpty() && stream->getAudioTracks()[0]->remo te()) { | 71 if (!stream->getAudioTracks().isEmpty() && stream->getAudioTracks()[0]->remo te()) { |
71 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni ngMessageLevel, "Recording remote audio tracks is not supported, ignoring them." )); | 72 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni ngMessageLevel, "Recording remote audio tracks is not supported, ignoring them." )); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 | 152 |
152 void MediaRecorder::requestData(ExceptionState& exceptionState) | 153 void MediaRecorder::requestData(ExceptionState& exceptionState) |
153 { | 154 { |
154 if (m_state != State::Recording) { | 155 if (m_state != State::Recording) { |
155 exceptionState.throwDOMException(InvalidStateError, "The MediaRecorder's state is '" + stateToString(m_state) + "'."); | 156 exceptionState.throwDOMException(InvalidStateError, "The MediaRecorder's state is '" + stateToString(m_state) + "'."); |
156 return; | 157 return; |
157 } | 158 } |
158 writeData(nullptr /* data */, 0 /* length */, true /* lastInSlice */); | 159 writeData(nullptr /* data */, 0 /* length */, true /* lastInSlice */); |
159 } | 160 } |
160 | 161 |
161 String MediaRecorder::canRecordMimeType(const String& mimeType) | 162 bool MediaRecorder::isTypeSupported(const String& type) |
philipj_slow
2015/12/11 08:29:03
Can you use this in the constructor, where the "th
philipj_slow
2015/12/18 20:18:10
I've filed https://code.google.com/p/chromium/issu
| |
162 { | 163 { |
163 RawPtr<WebMediaRecorderHandler> handler = Platform::current()->createMediaRe corderHandler(); | 164 RawPtr<WebMediaRecorderHandler> handler = Platform::current()->createMediaRe corderHandler(); |
164 if (!handler) | 165 if (!handler) |
165 return emptyString(); | 166 return false; |
166 | 167 |
167 // MediaRecorder canRecordMimeType() MUST return 'probably' "if the UA is | 168 // If true is returned from this method, it only indicates that the |
168 // confident that mimeType represents a type that it can record" [1], but a | 169 // MediaRecorder implementation is capable of recording Blob objects for the |
169 // number of reasons could prevent the recording from happening as expected, | 170 // specified MIME type. Recording may still fail if sufficient resources are |
170 // so 'maybe' is a better option: "Implementors are encouraged to return | 171 // not available to support the concrete media encoding. |
171 // "maybe" unless the type can be confidently established as being supported | 172 // [1] https://w3c.github.io/mediacapture-record/MediaRecorder.html#methods |
172 // or not.". Hence this method returns '' or 'maybe', never 'probably'. | 173 return handler->canSupportMimeType(type); |
173 // [1] http://w3c.github.io/mediacapture-record/MediaRecorder.html#methods | |
174 return handler->canSupportMimeType(mimeType) ? "maybe" : emptyString(); | |
175 } | 174 } |
176 | 175 |
177 const AtomicString& MediaRecorder::interfaceName() const | 176 const AtomicString& MediaRecorder::interfaceName() const |
178 { | 177 { |
179 return EventTargetNames::MediaRecorder; | 178 return EventTargetNames::MediaRecorder; |
180 } | 179 } |
181 | 180 |
182 ExecutionContext* MediaRecorder::executionContext() const | 181 ExecutionContext* MediaRecorder::executionContext() const |
183 { | 182 { |
184 return ActiveDOMObject::executionContext(); | 183 return ActiveDOMObject::executionContext(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 | 287 |
289 DEFINE_TRACE(MediaRecorder) | 288 DEFINE_TRACE(MediaRecorder) |
290 { | 289 { |
291 visitor->trace(m_stream); | 290 visitor->trace(m_stream); |
292 visitor->trace(m_scheduledEvents); | 291 visitor->trace(m_scheduledEvents); |
293 RefCountedGarbageCollectedEventTargetWithInlineData<MediaRecorder>::trace(vi sitor); | 292 RefCountedGarbageCollectedEventTargetWithInlineData<MediaRecorder>::trace(vi sitor); |
294 ActiveDOMObject::trace(visitor); | 293 ActiveDOMObject::trace(visitor); |
295 } | 294 } |
296 | 295 |
297 } // namespace blink | 296 } // namespace blink |
OLD | NEW |