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

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

Issue 2207613003: MediaRecorder: add mime type to recorded blobs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/LayoutTests/fast/mediarecorder/MediaRecorder-requestData.html ('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 "core/inspector/ConsoleMessage.h" 10 #include "core/inspector/ConsoleMessage.h"
11 #include "modules/EventTargetModules.h" 11 #include "modules/EventTargetModules.h"
12 #include "modules/mediarecorder/BlobEvent.h" 12 #include "modules/mediarecorder/BlobEvent.h"
13 #include "platform/ContentType.h" 13 #include "platform/ContentType.h"
14 #include "platform/blob/BlobData.h" 14 #include "platform/blob/BlobData.h"
15 #include "public/platform/Platform.h" 15 #include "public/platform/Platform.h"
16 #include "public/platform/WebMediaStream.h" 16 #include "public/platform/WebMediaStream.h"
17 #include "wtf/PtrUtil.h" 17 #include "wtf/PtrUtil.h"
18 #include <algorithm> 18 #include <algorithm>
19 19
20 namespace blink { 20 namespace blink {
21 21
22 namespace { 22 namespace {
23 23
24 const char* kDefaultMimeType = "video/webm";
25
24 // Boundaries of Opus bitrate from https://www.opus-codec.org/. 26 // Boundaries of Opus bitrate from https://www.opus-codec.org/.
25 const int kSmallestPossibleOpusBitRate = 6000; 27 const int kSmallestPossibleOpusBitRate = 6000;
26 const int kLargestAutoAllocatedOpusBitRate = 128000; 28 const int kLargestAutoAllocatedOpusBitRate = 128000;
27 29
28 // Smallest Vpx bitrate that can be requested. 30 // Smallest Vpx bitrate that can be requested.
29 const int kSmallestPossibleVpxBitRate = 100000; 31 const int kSmallestPossibleVpxBitRate = 100000;
30 32
31 String stateToString(MediaRecorder::State state) 33 String stateToString(MediaRecorder::State state)
32 { 34 {
33 switch (state) { 35 switch (state) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 recorder->suspendIfNeeded(); 131 recorder->suspendIfNeeded();
130 132
131 return recorder; 133 return recorder;
132 } 134 }
133 135
134 MediaRecorder::MediaRecorder(ExecutionContext* context, MediaStream* stream, con st MediaRecorderOptions& options, ExceptionState& exceptionState) 136 MediaRecorder::MediaRecorder(ExecutionContext* context, MediaStream* stream, con st MediaRecorderOptions& options, ExceptionState& exceptionState)
135 : ActiveScriptWrappable(this) 137 : ActiveScriptWrappable(this)
136 , ActiveDOMObject(context) 138 , ActiveDOMObject(context)
137 , m_stream(stream) 139 , m_stream(stream)
138 , m_streamAmountOfTracks(stream->getTracks().size()) 140 , m_streamAmountOfTracks(stream->getTracks().size())
139 , m_mimeType(options.mimeType()) 141 , m_mimeType(options.hasMimeType() ? options.mimeType() : kDefaultMimeType)
140 , m_stopped(true) 142 , m_stopped(true)
141 , m_ignoreMutedMedia(true) 143 , m_ignoreMutedMedia(true)
142 , m_audioBitsPerSecond(0) 144 , m_audioBitsPerSecond(0)
143 , m_videoBitsPerSecond(0) 145 , m_videoBitsPerSecond(0)
144 , m_state(State::Inactive) 146 , m_state(State::Inactive)
145 , m_dispatchScheduledEventRunner(AsyncMethodRunner<MediaRecorder>::create(th is, &MediaRecorder::dispatchScheduledEvent)) 147 , m_dispatchScheduledEventRunner(AsyncMethodRunner<MediaRecorder>::create(th is, &MediaRecorder::dispatchScheduledEvent))
146 { 148 {
147 DCHECK(m_stream->getTracks().size()); 149 DCHECK(m_stream->getTracks().size());
148 150
149 m_recorderHandler = wrapUnique(Platform::current()->createMediaRecorderHandl er()); 151 m_recorderHandler = wrapUnique(Platform::current()->createMediaRecorderHandl er());
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 m_stopped = false; 292 m_stopped = false;
291 scheduleDispatchEvent(Event::create(EventTypeNames::start)); 293 scheduleDispatchEvent(Event::create(EventTypeNames::start));
292 } 294 }
293 if (m_stream && m_streamAmountOfTracks != m_stream->getTracks().size()) { 295 if (m_stream && m_streamAmountOfTracks != m_stream->getTracks().size()) {
294 m_streamAmountOfTracks = m_stream->getTracks().size(); 296 m_streamAmountOfTracks = m_stream->getTracks().size();
295 onError("Amount of tracks in MediaStream has changed."); 297 onError("Amount of tracks in MediaStream has changed.");
296 } 298 }
297 299
298 // TODO(mcasas): Act as |m_ignoredMutedMedia| instructs if |m_stream| track( s) is in muted() state. 300 // TODO(mcasas): Act as |m_ignoredMutedMedia| instructs if |m_stream| track( s) is in muted() state.
299 301
300 if (!m_blobData) 302 if (!m_blobData) {
301 m_blobData = BlobData::create(); 303 m_blobData = BlobData::create();
304 m_blobData->setContentType(m_mimeType);
305 }
302 if (data) 306 if (data)
303 m_blobData->appendBytes(data, length); 307 m_blobData->appendBytes(data, length);
304 308
305 if (!lastInSlice) 309 if (!lastInSlice)
306 return; 310 return;
307 311
308 // Cache |m_blobData->length()| before release()ng it. 312 // Cache |m_blobData->length()| before release()ng it.
309 const long long blobDataLength = m_blobData->length(); 313 const long long blobDataLength = m_blobData->length();
310 createBlobEvent(Blob::create(BlobDataHandle::create(std::move(m_blobData), b lobDataLength))); 314 createBlobEvent(Blob::create(BlobDataHandle::create(std::move(m_blobData), b lobDataLength)));
311 } 315 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 DEFINE_TRACE(MediaRecorder) 356 DEFINE_TRACE(MediaRecorder)
353 { 357 {
354 visitor->trace(m_stream); 358 visitor->trace(m_stream);
355 visitor->trace(m_dispatchScheduledEventRunner); 359 visitor->trace(m_dispatchScheduledEventRunner);
356 visitor->trace(m_scheduledEvents); 360 visitor->trace(m_scheduledEvents);
357 EventTargetWithInlineData::trace(visitor); 361 EventTargetWithInlineData::trace(visitor);
358 ActiveDOMObject::trace(visitor); 362 ActiveDOMObject::trace(visitor);
359 } 363 }
360 364
361 } // namespace blink 365 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-requestData.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698