michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsIDOMEventListener.h" michael@0: #include "MediaEngine.h" michael@0: #include "ImageContainer.h" michael@0: #include "nsITimer.h" michael@0: #include "mozilla/Monitor.h" michael@0: #include "nsITabSource.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventListener, nsITimerCallback { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIDOMEVENTLISTENER michael@0: NS_DECL_NSITIMERCALLBACK michael@0: MediaEngineTabVideoSource(); michael@0: michael@0: virtual void GetName(nsAString_internal&); michael@0: virtual void GetUUID(nsAString_internal&); michael@0: virtual nsresult Allocate(const VideoTrackConstraintsN &, michael@0: const mozilla::MediaEnginePrefs&); michael@0: virtual nsresult Deallocate(); michael@0: virtual nsresult Start(mozilla::SourceMediaStream*, mozilla::TrackID); michael@0: virtual nsresult Snapshot(uint32_t, nsIDOMFile**); michael@0: virtual void NotifyPull(mozilla::MediaStreamGraph*, mozilla::SourceMediaStream*, mozilla::TrackID, mozilla::StreamTime, mozilla::TrackTicks&); michael@0: virtual nsresult Stop(mozilla::SourceMediaStream*, mozilla::TrackID); michael@0: virtual nsresult Config(bool, uint32_t, bool, uint32_t, bool, uint32_t, int32_t); michael@0: virtual bool IsFake(); michael@0: void Draw(); michael@0: michael@0: class StartRunnable : public nsRunnable { michael@0: public: michael@0: StartRunnable(MediaEngineTabVideoSource *videoSource) : mVideoSource(videoSource) {} michael@0: NS_IMETHOD Run(); michael@0: nsRefPtr mVideoSource; michael@0: }; michael@0: michael@0: class StopRunnable : public nsRunnable { michael@0: public: michael@0: StopRunnable(MediaEngineTabVideoSource *videoSource) : mVideoSource(videoSource) {} michael@0: NS_IMETHOD Run(); michael@0: nsRefPtr mVideoSource; michael@0: }; michael@0: michael@0: class InitRunnable : public nsRunnable { michael@0: public: michael@0: InitRunnable(MediaEngineTabVideoSource *videoSource) : mVideoSource(videoSource) {} michael@0: NS_IMETHOD Run(); michael@0: nsRefPtr mVideoSource; michael@0: }; michael@0: michael@0: private: michael@0: int mBufW; michael@0: int mBufH; michael@0: int mTimePerFrame; michael@0: ScopedFreePtr mData; michael@0: nsCOMPtr mWindow; michael@0: nsRefPtr mImage; michael@0: nsCOMPtr mTimer; michael@0: Monitor mMonitor; michael@0: nsCOMPtr mTabSource; michael@0: }; michael@0: }