Chromium Code Reviews| Index: Source/modules/mediastream/MediaRecorder.h |
| diff --git a/Source/modules/mediastream/MediaRecorder.h b/Source/modules/mediastream/MediaRecorder.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4ee18239bd67df81ea8b60cd1c96938013bf1736 |
| --- /dev/null |
| +++ b/Source/modules/mediastream/MediaRecorder.h |
| @@ -0,0 +1,106 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MediaRecorder_h |
| +#define MediaRecorder_h |
| + |
| +#include "core/dom/ActiveDOMObject.h" |
| +#include "core/events/EventTarget.h" |
| +#include "modules/EventTargetModules.h" |
| +#include "modules/mediastream/MediaStream.h" |
| +#include "modules/ModulesExport.h" |
| +#include "platform/AsyncMethodRunner.h" |
| +#include "public/platform/WebMediaRecorderHandler.h" |
| +#include "public/platform/WebMediaRecorderHandlerClient.h" |
| + |
| +namespace blink { |
| + |
| +class BlobData; |
| +class ExceptionState; |
| + |
| +class MODULES_EXPORT MediaRecorder final |
| + : public RefCountedGarbageCollectedEventTargetWithInlineData<MediaRecorder> |
| + , public WebMediaRecorderHandlerClient |
| + , public ActiveDOMObject { |
| + REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(MediaRecorder); |
| + WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MediaRecorder); |
| + DEFINE_WRAPPERTYPEINFO(); |
| +public: |
| + enum class MediaRecorderState { |
|
esprehn
2015/08/12 22:27:34
rename to just State, no reason to add the class n
mcasas
2015/08/13 09:31:51
Done.
|
| + Inactive = 0, |
| + Recording, |
| + Paused |
| + }; |
| + |
| + static MediaRecorder* create(ExecutionContext*, MediaStream*, ExceptionState&); |
| + static MediaRecorder* create(ExecutionContext*, MediaStream*, const String& mimeType, ExceptionState&); |
| + |
| + virtual ~MediaRecorder() {} |
| + |
| + MediaStream* stream() const { return m_stream.get(); } |
| + const String& mimeType() const { return m_mimeType; } |
| + String state() const; |
| + |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(start); |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(stop); |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(dataavailable); |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(pause); |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(resume); |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| + |
| + bool ignoreMutedMedia() const { return m_ignoreMutedMedia; } |
| + void setIgnoreMutedMedia(bool ignoreMutedMedia) { m_ignoreMutedMedia = ignoreMutedMedia; } |
| + |
| + void start(ExceptionState&); |
| + void start(int& timeSlice, ExceptionState&); |
|
esprehn
2015/08/12 22:27:34
This shouldn't be a reference to an int.
mcasas
2015/08/13 09:31:51
Done.
|
| + void stop(ExceptionState&); |
| + void pause(ExceptionState&); |
| + void resume(ExceptionState&); |
| + void requestData(ExceptionState&); |
| + |
| + static String canRecordMimeType(const String& mimeType); |
| + |
| + // EventTarget |
| + virtual const AtomicString& interfaceName() const override; |
| + virtual ExecutionContext* executionContext() const override; |
| + |
| + // ActiveDOMObject |
| + virtual void suspend() override { m_dispatchScheduledEventRunner.suspend(); } |
| + virtual void resume() override { m_dispatchScheduledEventRunner.resume(); } |
| + virtual void stop() override; |
| + virtual bool hasPendingActivity() const override { return !m_stopped; } |
| + |
| + // WebMediaRecorderHandlerClient |
| + virtual void writeData(const char* data, size_t length, bool lastInSlice) override; |
| + virtual void failOutOfMemory(const WebString& message) override; |
| + virtual void failIllegalStreamModification(const WebString& message) override; |
| + virtual void failOtherRecordingError(const WebString& message) override; |
| + |
| + DECLARE_VIRTUAL_TRACE(); |
| + |
| +private: |
| + MediaRecorder(ExecutionContext*, MediaStream*, const String&, ExceptionState&); |
|
esprehn
2015/08/12 22:27:34
add argument name for the string.
mcasas
2015/08/13 09:31:50
Done.
|
| + |
| + void createBlobEvent(PassOwnPtr<BlobData> blobData); |
| + |
| + void doStop(); |
| + void scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event>); |
| + void dispatchScheduledEvent(); |
|
esprehn
2015/08/12 22:27:34
I think you want an EventSender instead of this.
mcasas
2015/08/13 09:31:50
I'm not sure I understand how that class would be
|
| + |
| + Member<MediaStream> m_stream; |
| + bool m_stopped; |
| + String m_mimeType; |
| + bool m_ignoreMutedMedia; |
|
esprehn
2015/08/12 22:27:34
combine bools so this packs better.
mcasas
2015/08/13 09:31:50
Done.
|
| + |
| + MediaRecorderState m_state; |
| + |
| + OwnPtr<WebMediaRecorderHandler> m_recorderHandler; |
| + |
| + AsyncMethodRunner<MediaRecorder> m_dispatchScheduledEventRunner; |
| + WillBeHeapVector<RefPtrWillBeMember<Event>> m_scheduledEvents; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // MediaRecorder_h |