Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MediaRecorder_h | |
| 6 #define MediaRecorder_h | |
| 7 | |
| 8 #include "core/dom/ActiveDOMObject.h" | |
| 9 #include "core/events/EventTarget.h" | |
| 10 #include "modules/EventTargetModules.h" | |
| 11 #include "modules/ModulesExport.h" | |
| 12 #include "modules/mediastream/MediaStream.h" | |
| 13 #include "platform/AsyncMethodRunner.h" | |
| 14 #include "public/platform/WebMediaRecorderHandler.h" | |
| 15 #include "public/platform/WebMediaRecorderHandlerClient.h" | |
| 16 | |
| 17 namespace blink { | |
| 18 | |
| 19 class BlobData; | |
| 20 class ExceptionState; | |
| 21 | |
| 22 class MODULES_EXPORT MediaRecorder final | |
| 23 : public RefCountedGarbageCollectedEventTargetWithInlineData<MediaRecorder> | |
| 24 , public WebMediaRecorderHandlerClient | |
| 25 , public ActiveDOMObject { | |
| 26 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(MediaRecorder); | |
| 27 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MediaRecorder); | |
| 28 DEFINE_WRAPPERTYPEINFO(); | |
| 29 public: | |
| 30 enum class State { | |
| 31 Inactive = 0, | |
| 32 Recording, | |
| 33 Paused | |
| 34 }; | |
| 35 | |
| 36 static MediaRecorder* create(ExecutionContext*, MediaStream*, ExceptionState &); | |
| 37 static MediaRecorder* create(ExecutionContext*, MediaStream*, const String& mimeType, ExceptionState&); | |
| 38 | |
| 39 virtual ~MediaRecorder() {} | |
| 40 | |
| 41 MediaStream* stream() const { return m_stream.get(); } | |
| 42 const String& mimeType() const { return m_mimeType; } | |
| 43 String state() const; | |
| 44 | |
| 45 DEFINE_ATTRIBUTE_EVENT_LISTENER(start); | |
| 46 DEFINE_ATTRIBUTE_EVENT_LISTENER(stop); | |
| 47 DEFINE_ATTRIBUTE_EVENT_LISTENER(dataavailable); | |
| 48 DEFINE_ATTRIBUTE_EVENT_LISTENER(pause); | |
| 49 DEFINE_ATTRIBUTE_EVENT_LISTENER(resume); | |
| 50 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | |
| 51 | |
| 52 bool ignoreMutedMedia() const { return m_ignoreMutedMedia; } | |
|
Peter Beverloo
2015/09/01 17:17:12
nit: maybe move these to line 44? That way the hea
mcasas
2015/09/02 03:10:18
Done.
| |
| 53 void setIgnoreMutedMedia(bool ignoreMutedMedia) { m_ignoreMutedMedia = ignor eMutedMedia; } | |
| 54 | |
| 55 void start(ExceptionState&); | |
| 56 void start(int timeSlice, ExceptionState&); | |
| 57 void stop(ExceptionState&); | |
| 58 void pause(ExceptionState&); | |
| 59 void resume(ExceptionState&); | |
| 60 void requestData(ExceptionState&); | |
| 61 | |
| 62 static String canRecordMimeType(const String& mimeType); | |
| 63 | |
| 64 // EventTarget | |
| 65 virtual const AtomicString& interfaceName() const override; | |
| 66 virtual ExecutionContext* executionContext() const override; | |
| 67 | |
| 68 // ActiveDOMObject | |
| 69 virtual void suspend() override; | |
| 70 virtual void resume() override; | |
| 71 virtual void stop() override; | |
| 72 virtual bool hasPendingActivity() const override { return !m_stopped; } | |
| 73 | |
| 74 // WebMediaRecorderHandlerClient | |
| 75 virtual void writeData(const char* data, size_t length, bool lastInSlice) ov erride; | |
| 76 virtual void failOutOfMemory(const WebString& message) override; | |
| 77 virtual void failIllegalStreamModification(const WebString& message) overrid e; | |
| 78 virtual void failOtherRecordingError(const WebString& message) override; | |
| 79 | |
| 80 DECLARE_VIRTUAL_TRACE(); | |
| 81 | |
| 82 private: | |
| 83 MediaRecorder(ExecutionContext*, MediaStream*, const String& mimeType, Excep tionState&); | |
| 84 | |
| 85 void createBlobEvent(PassOwnPtr<BlobData> blobData); | |
| 86 | |
| 87 void stopRecording(); | |
| 88 void scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event>); | |
| 89 void dispatchScheduledEvent(); | |
| 90 | |
| 91 Member<MediaStream> m_stream; | |
| 92 String m_mimeType; | |
| 93 bool m_stopped; | |
| 94 bool m_ignoreMutedMedia; | |
| 95 | |
| 96 State m_state; | |
| 97 | |
| 98 OwnPtr<WebMediaRecorderHandler> m_recorderHandler; | |
| 99 | |
| 100 AsyncMethodRunner<MediaRecorder> m_dispatchScheduledEventRunner; | |
| 101 WillBeHeapVector<RefPtrWillBeMember<Event>> m_scheduledEvents; | |
| 102 }; | |
| 103 | |
| 104 } // namespace blink | |
| 105 | |
| 106 #endif // MediaRecorder_h | |
| OLD | NEW |