| 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     bool ignoreMutedMedia() const { return m_ignoreMutedMedia; } | 
|  | 45     void setIgnoreMutedMedia(bool ignoreMutedMedia) { m_ignoreMutedMedia = ignor
     eMutedMedia; } | 
|  | 46 | 
|  | 47     DEFINE_ATTRIBUTE_EVENT_LISTENER(start); | 
|  | 48     DEFINE_ATTRIBUTE_EVENT_LISTENER(stop); | 
|  | 49     DEFINE_ATTRIBUTE_EVENT_LISTENER(dataavailable); | 
|  | 50     DEFINE_ATTRIBUTE_EVENT_LISTENER(pause); | 
|  | 51     DEFINE_ATTRIBUTE_EVENT_LISTENER(resume); | 
|  | 52     DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 
|  | 53 | 
|  | 54     void start(ExceptionState&); | 
|  | 55     void start(int timeSlice, ExceptionState&); | 
|  | 56     void stop(ExceptionState&); | 
|  | 57     void pause(ExceptionState&); | 
|  | 58     void resume(ExceptionState&); | 
|  | 59     void requestData(ExceptionState&); | 
|  | 60 | 
|  | 61     static String canRecordMimeType(const String& mimeType); | 
|  | 62 | 
|  | 63     // EventTarget | 
|  | 64     virtual const AtomicString& interfaceName() const override; | 
|  | 65     virtual ExecutionContext* executionContext() const override; | 
|  | 66 | 
|  | 67     // ActiveDOMObject | 
|  | 68     virtual void suspend() override; | 
|  | 69     virtual void resume() override; | 
|  | 70     virtual void stop() override; | 
|  | 71     virtual bool hasPendingActivity() const override { return !m_stopped; } | 
|  | 72 | 
|  | 73     // WebMediaRecorderHandlerClient | 
|  | 74     virtual void writeData(const char* data, size_t length, bool lastInSlice) ov
     erride; | 
|  | 75     virtual void failOutOfMemory(const WebString& message) override; | 
|  | 76     virtual void failIllegalStreamModification(const WebString& message) overrid
     e; | 
|  | 77     virtual void failOtherRecordingError(const WebString& message) override; | 
|  | 78 | 
|  | 79     DECLARE_VIRTUAL_TRACE(); | 
|  | 80 | 
|  | 81 private: | 
|  | 82     MediaRecorder(ExecutionContext*, MediaStream*, const String& mimeType, Excep
     tionState&); | 
|  | 83 | 
|  | 84     void createBlobEvent(PassOwnPtr<BlobData> blobData); | 
|  | 85 | 
|  | 86     void stopRecording(); | 
|  | 87     void scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event>); | 
|  | 88     void dispatchScheduledEvent(); | 
|  | 89 | 
|  | 90     Member<MediaStream> m_stream; | 
|  | 91     String m_mimeType; | 
|  | 92     bool m_stopped; | 
|  | 93     bool m_ignoreMutedMedia; | 
|  | 94 | 
|  | 95     State m_state; | 
|  | 96 | 
|  | 97     OwnPtr<WebMediaRecorderHandler> m_recorderHandler; | 
|  | 98 | 
|  | 99     AsyncMethodRunner<MediaRecorder> m_dispatchScheduledEventRunner; | 
|  | 100     WillBeHeapVector<RefPtrWillBeMember<Event>> m_scheduledEvents; | 
|  | 101 }; | 
|  | 102 | 
|  | 103 } // namespace blink | 
|  | 104 | 
|  | 105 #endif // MediaRecorder_h | 
| OLD | NEW | 
|---|