2013-10-17 13:48:30 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "MediaEngine.h"
|
|
|
|
#include "ImageContainer.h"
|
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "mozilla/Monitor.h"
|
2014-03-18 12:05:46 -07:00
|
|
|
#include "nsITabSource.h"
|
2013-10-17 13:48:30 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventListener, nsITimerCallback {
|
|
|
|
public:
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
|
|
|
NS_DECL_NSITIMERCALLBACK
|
|
|
|
MediaEngineTabVideoSource();
|
2014-03-18 12:05:46 -07:00
|
|
|
|
2013-10-17 13:48:30 -07:00
|
|
|
virtual void GetName(nsAString_internal&);
|
|
|
|
virtual void GetUUID(nsAString_internal&);
|
2014-04-18 12:15:10 -07:00
|
|
|
virtual nsresult Allocate(const VideoTrackConstraintsN &,
|
|
|
|
const mozilla::MediaEnginePrefs&);
|
2013-10-17 13:48:30 -07:00
|
|
|
virtual nsresult Deallocate();
|
|
|
|
virtual nsresult Start(mozilla::SourceMediaStream*, mozilla::TrackID);
|
|
|
|
virtual nsresult Snapshot(uint32_t, nsIDOMFile**);
|
|
|
|
virtual void NotifyPull(mozilla::MediaStreamGraph*, mozilla::SourceMediaStream*, mozilla::TrackID, mozilla::StreamTime, mozilla::TrackTicks&);
|
|
|
|
virtual nsresult Stop(mozilla::SourceMediaStream*, mozilla::TrackID);
|
2014-04-02 10:58:19 -07:00
|
|
|
virtual nsresult Config(bool, uint32_t, bool, uint32_t, bool, uint32_t, int32_t);
|
2013-10-17 13:48:30 -07:00
|
|
|
virtual bool IsFake();
|
|
|
|
void Draw();
|
|
|
|
|
|
|
|
class StartRunnable : public nsRunnable {
|
|
|
|
public:
|
|
|
|
StartRunnable(MediaEngineTabVideoSource *videoSource) : mVideoSource(videoSource) {}
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
nsRefPtr<MediaEngineTabVideoSource> mVideoSource;
|
|
|
|
};
|
|
|
|
|
|
|
|
class StopRunnable : public nsRunnable {
|
|
|
|
public:
|
|
|
|
StopRunnable(MediaEngineTabVideoSource *videoSource) : mVideoSource(videoSource) {}
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
nsRefPtr<MediaEngineTabVideoSource> mVideoSource;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InitRunnable : public nsRunnable {
|
|
|
|
public:
|
|
|
|
InitRunnable(MediaEngineTabVideoSource *videoSource) : mVideoSource(videoSource) {}
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
nsRefPtr<MediaEngineTabVideoSource> mVideoSource;
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
int mBufW;
|
|
|
|
int mBufH;
|
|
|
|
int mTimePerFrame;
|
2014-03-25 21:59:01 -07:00
|
|
|
ScopedFreePtr<unsigned char> mData;
|
2013-10-17 13:48:30 -07:00
|
|
|
nsCOMPtr<nsIDOMWindow> mWindow;
|
|
|
|
nsRefPtr<layers::CairoImage> mImage;
|
|
|
|
nsCOMPtr<nsITimer> mTimer;
|
|
|
|
Monitor mMonitor;
|
2014-03-18 12:05:46 -07:00
|
|
|
nsCOMPtr<nsITabSource> mTabSource;
|
2013-10-17 13:48:30 -07:00
|
|
|
};
|
|
|
|
}
|