Chromium Code Reviews| 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 "core/dom/DOMError.h" | 8 #include "core/dom/DOMError.h" |
| 9 #include "core/fileapi/Blob.h" | 9 #include "core/fileapi/Blob.h" |
| 10 #include "modules/EventModules.h" | 10 #include "modules/EventModules.h" |
| 11 #include "modules/EventTargetModules.h" | 11 #include "modules/EventTargetModules.h" |
| 12 #include "modules/mediarecorder/MediaRecorderErrorEvent.h" | 12 #include "modules/mediarecorder/MediaRecorderErrorEvent.h" |
| 13 #include "platform/Logging.h" | |
| 13 #include "platform/blob/BlobData.h" | 14 #include "platform/blob/BlobData.h" |
| 14 #include "public/platform/Platform.h" | 15 #include "public/platform/Platform.h" |
| 15 #include "public/platform/WebMediaStream.h" | 16 #include "public/platform/WebMediaStream.h" |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 String stateToString(MediaRecorder::State state) | 22 String stateToString(MediaRecorder::State state) |
| 22 { | 23 { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 | 198 |
| 198 m_stopped = true; | 199 m_stopped = true; |
| 199 m_stream.clear(); | 200 m_stream.clear(); |
| 200 m_recorderHandler.clear(); | 201 m_recorderHandler.clear(); |
| 201 | 202 |
| 202 scheduleDispatchEvent(Event::create(EventTypeNames::stop)); | 203 scheduleDispatchEvent(Event::create(EventTypeNames::stop)); |
| 203 } | 204 } |
| 204 | 205 |
| 205 void MediaRecorder::writeData(const char* data, size_t length, bool lastInSlice) | 206 void MediaRecorder::writeData(const char* data, size_t length, bool lastInSlice) |
| 206 { | 207 { |
| 207 ASSERT(m_state == State::Recording); | 208 if (!lastInSlice && m_stopped) { |
| 208 | |
| 209 if (m_stopped) { | |
| 210 m_stopped = false; | 209 m_stopped = false; |
| 211 scheduleDispatchEvent(Event::create(EventTypeNames::start)); | 210 scheduleDispatchEvent(Event::create(EventTypeNames::start)); |
| 212 } | 211 } |
| 213 | 212 |
| 214 // TODO(mcasas): Act as |m_ignoredMutedMedia| instructs if |m_stream| track( s) is in muted() state. | 213 // TODO(mcasas): Act as |m_ignoredMutedMedia| instructs if |m_stream| track( s) is in muted() state. |
| 215 // TODO(mcasas): Use |lastInSlice| to indicate to JS that recording is done. | 214 // TODO(mcasas): Use |lastInSlice| to indicate to JS that recording is done. |
| 216 | 215 |
| 217 OwnPtr<BlobData> blobData = BlobData::create(); | 216 OwnPtr<BlobData> blobData = BlobData::create(); |
| 218 blobData->appendBytes(data, length); | 217 blobData->appendBytes(data, length); |
| 219 createBlobEvent(blobData.release()); | 218 createBlobEvent(blobData.release()); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 242 scheduleDispatchEvent(MediaRecorderErrorEvent::create( | 241 scheduleDispatchEvent(MediaRecorderErrorEvent::create( |
| 243 EventTypeNames::error, false, false, "OtherRecordingError", message)); | 242 EventTypeNames::error, false, false, "OtherRecordingError", message)); |
| 244 | 243 |
| 245 if (m_state == State::Recording) | 244 if (m_state == State::Recording) |
| 246 stopRecording(); | 245 stopRecording(); |
| 247 } | 246 } |
| 248 | 247 |
| 249 void MediaRecorder::createBlobEvent(PassOwnPtr<BlobData> blobData) | 248 void MediaRecorder::createBlobEvent(PassOwnPtr<BlobData> blobData) |
| 250 { | 249 { |
| 251 // TODO(mcasas): Launch a BlobEvent when that class is landed, but also see https://github.com/w3c/mediacapture-record/issues/17. | 250 // TODO(mcasas): Launch a BlobEvent when that class is landed, but also see https://github.com/w3c/mediacapture-record/issues/17. |
| 252 ASSERT_NOT_REACHED(); | 251 WTF_LOG(Media, "createBlobEvent() not implemented."); |
|
Peter Beverloo
2015/09/16 15:09:01
You could use notImplemented() from Source/platfor
mcasas
2015/09/16 18:04:15
Done, thanks!
| |
| 253 } | 252 } |
| 254 | 253 |
| 255 void MediaRecorder::stopRecording() | 254 void MediaRecorder::stopRecording() |
| 256 { | 255 { |
| 257 ASSERT(m_state != State::Inactive); | 256 ASSERT(m_state != State::Inactive); |
| 258 m_state = State::Inactive; | 257 m_state = State::Inactive; |
| 259 | 258 |
| 260 m_recorderHandler->stop(); | 259 m_recorderHandler->stop(); |
| 261 | 260 |
| 262 createBlobEvent(BlobData::create()); | 261 createBlobEvent(BlobData::create()); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 282 | 281 |
| 283 DEFINE_TRACE(MediaRecorder) | 282 DEFINE_TRACE(MediaRecorder) |
| 284 { | 283 { |
| 285 visitor->trace(m_stream); | 284 visitor->trace(m_stream); |
| 286 visitor->trace(m_scheduledEvents); | 285 visitor->trace(m_scheduledEvents); |
| 287 RefCountedGarbageCollectedEventTargetWithInlineData<MediaRecorder>::trace(vi sitor); | 286 RefCountedGarbageCollectedEventTargetWithInlineData<MediaRecorder>::trace(vi sitor); |
| 288 ActiveDOMObject::trace(visitor); | 287 ActiveDOMObject::trace(visitor); |
| 289 } | 288 } |
| 290 | 289 |
| 291 } // namespace blink | 290 } // namespace blink |
| OLD | NEW |