| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Ericsson AB. All rights reserved. | 3 * Copyright (C) 2011 Ericsson AB. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #ifndef MediaStream_h | 26 #ifndef MediaStream_h |
| 27 #define MediaStream_h | 27 #define MediaStream_h |
| 28 | 28 |
| 29 #include "bindings/v8/ScriptWrappable.h" | 29 #include "bindings/v8/ScriptWrappable.h" |
| 30 #include "core/dom/ContextDestructionObserver.h" | 30 #include "core/dom/ContextDestructionObserver.h" |
| 31 #include "core/dom/EventTarget.h" | 31 #include "core/dom/EventTarget.h" |
| 32 #include "core/dom/ExceptionBase.h" | 32 #include "core/dom/ExceptionBase.h" |
| 33 #include "core/html/URLRegistry.h" | 33 #include "core/html/URLRegistry.h" |
| 34 #include "core/platform/Timer.h" | 34 #include "core/platform/Timer.h" |
| 35 #include "core/platform/chromium/support/WebMediaStreamClient.h" | 35 #include "core/platform/mediastream/MediaStreamDescriptor.h" |
| 36 #include "modules/mediastream/MediaStreamTrack.h" | 36 #include "modules/mediastream/MediaStreamTrack.h" |
| 37 #include "public/platform/WebMediaStream.h" | |
| 38 #include "wtf/RefCounted.h" | 37 #include "wtf/RefCounted.h" |
| 39 #include "wtf/RefPtr.h" | 38 #include "wtf/RefPtr.h" |
| 40 | 39 |
| 41 namespace WebCore { | 40 namespace WebCore { |
| 42 | 41 |
| 43 class MediaStream : public RefCounted<MediaStream>, public ScriptWrappable, publ
ic URLRegistrable, public WebKit::WebMediaStreamClient, public EventTarget, publ
ic ContextDestructionObserver { | 42 class MediaStream : public RefCounted<MediaStream>, public ScriptWrappable, publ
ic URLRegistrable, public MediaStreamDescriptorClient, public EventTarget, publi
c ContextDestructionObserver { |
| 44 public: | 43 public: |
| 45 static PassRefPtr<MediaStream> create(ScriptExecutionContext*); | 44 static PassRefPtr<MediaStream> create(ScriptExecutionContext*); |
| 46 static PassRefPtr<MediaStream> create(ScriptExecutionContext*, PassRefPtr<Me
diaStream>); | 45 static PassRefPtr<MediaStream> create(ScriptExecutionContext*, PassRefPtr<Me
diaStream>); |
| 47 static PassRefPtr<MediaStream> create(ScriptExecutionContext*, const MediaSt
reamTrackVector&); | 46 static PassRefPtr<MediaStream> create(ScriptExecutionContext*, const MediaSt
reamTrackVector&); |
| 48 static PassRefPtr<MediaStream> create(ScriptExecutionContext*, WebKit::WebMe
diaStream); | 47 static PassRefPtr<MediaStream> create(ScriptExecutionContext*, PassRefPtr<Me
diaStreamDescriptor>); |
| 49 virtual ~MediaStream(); | 48 virtual ~MediaStream(); |
| 50 | 49 |
| 51 // DEPRECATED | 50 // DEPRECATED |
| 52 String label() const { return m_webStream.id(); } | 51 String label() const { return m_descriptor->id(); } |
| 53 | 52 |
| 54 String id() const { return m_webStream.id(); } | 53 String id() const { return m_descriptor->id(); } |
| 55 | 54 |
| 56 void addTrack(PassRefPtr<MediaStreamTrack>, ExceptionCode&); | 55 void addTrack(PassRefPtr<MediaStreamTrack>, ExceptionCode&); |
| 57 void removeTrack(PassRefPtr<MediaStreamTrack>, ExceptionCode&); | 56 void removeTrack(PassRefPtr<MediaStreamTrack>, ExceptionCode&); |
| 58 MediaStreamTrack* getTrackById(String); | 57 MediaStreamTrack* getTrackById(String); |
| 59 | 58 |
| 60 MediaStreamTrackVector getAudioTracks() const { return m_audioTracks; } | 59 MediaStreamTrackVector getAudioTracks() const { return m_audioTracks; } |
| 61 MediaStreamTrackVector getVideoTracks() const { return m_videoTracks; } | 60 MediaStreamTrackVector getVideoTracks() const { return m_videoTracks; } |
| 62 | 61 |
| 63 bool ended() const; | 62 bool ended() const; |
| 64 void stop(); | 63 void stop(); |
| 65 | 64 |
| 66 DEFINE_ATTRIBUTE_EVENT_LISTENER(ended); | 65 DEFINE_ATTRIBUTE_EVENT_LISTENER(ended); |
| 67 DEFINE_ATTRIBUTE_EVENT_LISTENER(addtrack); | 66 DEFINE_ATTRIBUTE_EVENT_LISTENER(addtrack); |
| 68 DEFINE_ATTRIBUTE_EVENT_LISTENER(removetrack); | 67 DEFINE_ATTRIBUTE_EVENT_LISTENER(removetrack); |
| 69 | 68 |
| 70 // WebMediaStreamClient | 69 // MediaStreamDescriptorClient |
| 71 virtual void trackEnded() OVERRIDE; | 70 virtual void trackEnded() OVERRIDE; |
| 72 virtual void streamEnded() OVERRIDE; | 71 virtual void streamEnded() OVERRIDE; |
| 73 | 72 |
| 74 WebKit::WebMediaStream webStream() const { return m_webStream; } | 73 MediaStreamDescriptor* descriptor() const { return m_descriptor.get(); } |
| 75 | 74 |
| 76 // EventTarget | 75 // EventTarget |
| 77 virtual const AtomicString& interfaceName() const OVERRIDE; | 76 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 78 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; | 77 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; |
| 79 | 78 |
| 80 using RefCounted<MediaStream>::ref; | 79 using RefCounted<MediaStream>::ref; |
| 81 using RefCounted<MediaStream>::deref; | 80 using RefCounted<MediaStream>::deref; |
| 82 | 81 |
| 83 // URLRegistrable | 82 // URLRegistrable |
| 84 virtual URLRegistry& registry() const OVERRIDE; | 83 virtual URLRegistry& registry() const OVERRIDE; |
| 85 | 84 |
| 86 protected: | 85 protected: |
| 87 MediaStream(ScriptExecutionContext*, WebKit::WebMediaStream); | 86 MediaStream(ScriptExecutionContext*, PassRefPtr<MediaStreamDescriptor>); |
| 88 | 87 |
| 89 // EventTarget | 88 // EventTarget |
| 90 virtual EventTargetData* eventTargetData() OVERRIDE; | 89 virtual EventTargetData* eventTargetData() OVERRIDE; |
| 91 virtual EventTargetData* ensureEventTargetData() OVERRIDE; | 90 virtual EventTargetData* ensureEventTargetData() OVERRIDE; |
| 92 | 91 |
| 93 // ContextDestructionObserver | 92 // ContextDestructionObserver |
| 94 virtual void contextDestroyed(); | 93 virtual void contextDestroyed(); |
| 95 | 94 |
| 96 private: | 95 private: |
| 97 // EventTarget | 96 // EventTarget |
| 98 virtual void refEventTarget() OVERRIDE { ref(); } | 97 virtual void refEventTarget() OVERRIDE { ref(); } |
| 99 virtual void derefEventTarget() OVERRIDE { deref(); } | 98 virtual void derefEventTarget() OVERRIDE { deref(); } |
| 100 | 99 |
| 101 // WebMediaStreamClient | 100 // MediaStreamDescriptorClient |
| 102 virtual void addRemoteTrack(MediaStreamComponent*) OVERRIDE; | 101 virtual void addRemoteTrack(MediaStreamComponent*) OVERRIDE; |
| 103 virtual void removeRemoteTrack(MediaStreamComponent*) OVERRIDE; | 102 virtual void removeRemoteTrack(MediaStreamComponent*) OVERRIDE; |
| 104 | 103 |
| 105 void scheduleDispatchEvent(PassRefPtr<Event>); | 104 void scheduleDispatchEvent(PassRefPtr<Event>); |
| 106 void scheduledEventTimerFired(Timer<MediaStream>*); | 105 void scheduledEventTimerFired(Timer<MediaStream>*); |
| 107 | 106 |
| 108 bool m_stopped; | 107 bool m_stopped; |
| 109 | 108 |
| 110 EventTargetData m_eventTargetData; | 109 EventTargetData m_eventTargetData; |
| 111 | 110 |
| 112 MediaStreamTrackVector m_audioTracks; | 111 MediaStreamTrackVector m_audioTracks; |
| 113 MediaStreamTrackVector m_videoTracks; | 112 MediaStreamTrackVector m_videoTracks; |
| 114 WebKit::WebMediaStream m_webStream; | 113 RefPtr<MediaStreamDescriptor> m_descriptor; |
| 115 | 114 |
| 116 Timer<MediaStream> m_scheduledEventTimer; | 115 Timer<MediaStream> m_scheduledEventTimer; |
| 117 Vector<RefPtr<Event> > m_scheduledEvents; | 116 Vector<RefPtr<Event> > m_scheduledEvents; |
| 118 }; | 117 }; |
| 119 | 118 |
| 120 typedef Vector<RefPtr<MediaStream> > MediaStreamVector; | 119 typedef Vector<RefPtr<MediaStream> > MediaStreamVector; |
| 121 | 120 |
| 122 } // namespace WebCore | 121 } // namespace WebCore |
| 123 | 122 |
| 124 #endif // MediaStream_h | 123 #endif // MediaStream_h |
| OLD | NEW |