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

Side by Side Diff: third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.cpp

Issue 1578973002: MediaRecorder: fire onError if the amount of tracks of the MediaStream varies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: peter@ comments Created 4 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
« no previous file with comments | « third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "modules/mediarecorder/MediaRecorder.h" 5 #include "modules/mediarecorder/MediaRecorder.h"
6 6
7 #include "bindings/core/v8/Dictionary.h" 7 #include "bindings/core/v8/Dictionary.h"
8 #include "core/events/Event.h" 8 #include "core/events/Event.h"
9 #include "core/fileapi/Blob.h" 9 #include "core/fileapi/Blob.h"
10 #include "modules/EventTargetModules.h" 10 #include "modules/EventTargetModules.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 { 48 {
49 MediaRecorder* recorder = new MediaRecorder(context, stream, options, except ionState); 49 MediaRecorder* recorder = new MediaRecorder(context, stream, options, except ionState);
50 recorder->suspendIfNeeded(); 50 recorder->suspendIfNeeded();
51 51
52 return recorder; 52 return recorder;
53 } 53 }
54 54
55 MediaRecorder::MediaRecorder(ExecutionContext* context, MediaStream* stream, con st MediaRecorderOptions& options, ExceptionState& exceptionState) 55 MediaRecorder::MediaRecorder(ExecutionContext* context, MediaStream* stream, con st MediaRecorderOptions& options, ExceptionState& exceptionState)
56 : ActiveDOMObject(context) 56 : ActiveDOMObject(context)
57 , m_stream(stream) 57 , m_stream(stream)
58 , m_streamAmountOfTracks(stream->getTracks().size())
58 , m_mimeType(options.mimeType()) 59 , m_mimeType(options.mimeType())
59 , m_stopped(true) 60 , m_stopped(true)
60 , m_ignoreMutedMedia(true) 61 , m_ignoreMutedMedia(true)
61 , m_state(State::Inactive) 62 , m_state(State::Inactive)
62 , m_dispatchScheduledEventRunner(this, &MediaRecorder::dispatchScheduledEven t) 63 , m_dispatchScheduledEventRunner(this, &MediaRecorder::dispatchScheduledEven t)
63 { 64 {
64 ASSERT(m_stream->getTracks().size()); 65 ASSERT(m_stream->getTracks().size());
65 66
66 m_recorderHandler = adoptPtr(Platform::current()->createMediaRecorderHandler ()); 67 m_recorderHandler = adoptPtr(Platform::current()->createMediaRecorderHandler ());
67 ASSERT(m_recorderHandler); 68 ASSERT(m_recorderHandler);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 m_stream.clear(); 199 m_stream.clear();
199 m_recorderHandler.clear(); 200 m_recorderHandler.clear();
200 } 201 }
201 202
202 void MediaRecorder::writeData(const char* data, size_t length, bool lastInSlice) 203 void MediaRecorder::writeData(const char* data, size_t length, bool lastInSlice)
203 { 204 {
204 if (m_stopped && !lastInSlice) { 205 if (m_stopped && !lastInSlice) {
205 m_stopped = false; 206 m_stopped = false;
206 scheduleDispatchEvent(Event::create(EventTypeNames::start)); 207 scheduleDispatchEvent(Event::create(EventTypeNames::start));
207 } 208 }
209 if (m_stream && m_streamAmountOfTracks != m_stream->getTracks().size()) {
210 m_streamAmountOfTracks = m_stream->getTracks().size();
211 onError("Amount of tracks in MediaStream has changed.");
212 }
208 213
209 // TODO(mcasas): Act as |m_ignoredMutedMedia| instructs if |m_stream| track( s) is in muted() state. 214 // TODO(mcasas): Act as |m_ignoredMutedMedia| instructs if |m_stream| track( s) is in muted() state.
210 215
211 if (!m_blobData) 216 if (!m_blobData)
212 m_blobData = BlobData::create(); 217 m_blobData = BlobData::create();
213 if (data) 218 if (data)
214 m_blobData->appendBytes(data, length); 219 m_blobData->appendBytes(data, length);
215 220
216 if (!lastInSlice) 221 if (!lastInSlice)
217 return; 222 return;
218 223
219 // Cache |m_blobData->length()| before release()ng it. 224 // Cache |m_blobData->length()| before release()ng it.
220 const long long blobDataLength = m_blobData->length(); 225 const long long blobDataLength = m_blobData->length();
221 createBlobEvent(Blob::create(BlobDataHandle::create(m_blobData.release(), bl obDataLength))); 226 createBlobEvent(Blob::create(BlobDataHandle::create(m_blobData.release(), bl obDataLength)));
222 } 227 }
223 228
224 void MediaRecorder::onError(const WebString& message) 229 void MediaRecorder::onError(const WebString& message)
225 { 230 {
226 // TODO(mcasas): Beef up the Error Event and add the |message|, see https:// github.com/w3c/mediacapture-record/issues/31 231 // TODO(mcasas): Beef up the Error Event and add the |message|, see https:// github.com/w3c/mediacapture-record/issues/31
227 scheduleDispatchEvent(Event::create(EventTypeNames::error)); 232 scheduleDispatchEvent(Event::create(EventTypeNames::error));
228
229 if (m_state == State::Recording)
230 stopRecording();
231 } 233 }
232 234
233 void MediaRecorder::createBlobEvent(Blob* blob) 235 void MediaRecorder::createBlobEvent(Blob* blob)
234 { 236 {
235 // TODO(mcasas): Consider launching an Event with a TypedArray inside, see h ttps://github.com/w3c/mediacapture-record/issues/17. 237 // TODO(mcasas): Consider launching an Event with a TypedArray inside, see h ttps://github.com/w3c/mediacapture-record/issues/17.
236 scheduleDispatchEvent(BlobEvent::create(EventTypeNames::dataavailable, blob) ); 238 scheduleDispatchEvent(BlobEvent::create(EventTypeNames::dataavailable, blob) );
237 } 239 }
238 240
239 void MediaRecorder::stopRecording() 241 void MediaRecorder::stopRecording()
240 { 242 {
(...skipping 24 matching lines...) Expand all
265 267
266 DEFINE_TRACE(MediaRecorder) 268 DEFINE_TRACE(MediaRecorder)
267 { 269 {
268 visitor->trace(m_stream); 270 visitor->trace(m_stream);
269 visitor->trace(m_scheduledEvents); 271 visitor->trace(m_scheduledEvents);
270 RefCountedGarbageCollectedEventTargetWithInlineData<MediaRecorder>::trace(vi sitor); 272 RefCountedGarbageCollectedEventTargetWithInlineData<MediaRecorder>::trace(vi sitor);
271 ActiveDOMObject::trace(visitor); 273 ActiveDOMObject::trace(visitor);
272 } 274 }
273 275
274 } // namespace blink 276 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698