| |
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
| |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| |
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| |
4 |
| |
5 #include "nsIDOMEventListener.h" |
| |
6 #include "MediaEngine.h" |
| |
7 #include "ImageContainer.h" |
| |
8 #include "nsITimer.h" |
| |
9 #include "mozilla/Monitor.h" |
| |
10 #include "nsITabSource.h" |
| |
11 |
| |
12 namespace mozilla { |
| |
13 |
| |
14 class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventListener, nsITimerCallback { |
| |
15 public: |
| |
16 NS_DECL_THREADSAFE_ISUPPORTS |
| |
17 NS_DECL_NSIDOMEVENTLISTENER |
| |
18 NS_DECL_NSITIMERCALLBACK |
| |
19 MediaEngineTabVideoSource(); |
| |
20 |
| |
21 virtual void GetName(nsAString_internal&); |
| |
22 virtual void GetUUID(nsAString_internal&); |
| |
23 virtual nsresult Allocate(const VideoTrackConstraintsN &, |
| |
24 const mozilla::MediaEnginePrefs&); |
| |
25 virtual nsresult Deallocate(); |
| |
26 virtual nsresult Start(mozilla::SourceMediaStream*, mozilla::TrackID); |
| |
27 virtual nsresult Snapshot(uint32_t, nsIDOMFile**); |
| |
28 virtual void NotifyPull(mozilla::MediaStreamGraph*, mozilla::SourceMediaStream*, mozilla::TrackID, mozilla::StreamTime, mozilla::TrackTicks&); |
| |
29 virtual nsresult Stop(mozilla::SourceMediaStream*, mozilla::TrackID); |
| |
30 virtual nsresult Config(bool, uint32_t, bool, uint32_t, bool, uint32_t, int32_t); |
| |
31 virtual bool IsFake(); |
| |
32 void Draw(); |
| |
33 |
| |
34 class StartRunnable : public nsRunnable { |
| |
35 public: |
| |
36 StartRunnable(MediaEngineTabVideoSource *videoSource) : mVideoSource(videoSource) {} |
| |
37 NS_IMETHOD Run(); |
| |
38 nsRefPtr<MediaEngineTabVideoSource> mVideoSource; |
| |
39 }; |
| |
40 |
| |
41 class StopRunnable : public nsRunnable { |
| |
42 public: |
| |
43 StopRunnable(MediaEngineTabVideoSource *videoSource) : mVideoSource(videoSource) {} |
| |
44 NS_IMETHOD Run(); |
| |
45 nsRefPtr<MediaEngineTabVideoSource> mVideoSource; |
| |
46 }; |
| |
47 |
| |
48 class InitRunnable : public nsRunnable { |
| |
49 public: |
| |
50 InitRunnable(MediaEngineTabVideoSource *videoSource) : mVideoSource(videoSource) {} |
| |
51 NS_IMETHOD Run(); |
| |
52 nsRefPtr<MediaEngineTabVideoSource> mVideoSource; |
| |
53 }; |
| |
54 |
| |
55 private: |
| |
56 int mBufW; |
| |
57 int mBufH; |
| |
58 int mTimePerFrame; |
| |
59 ScopedFreePtr<unsigned char> mData; |
| |
60 nsCOMPtr<nsIDOMWindow> mWindow; |
| |
61 nsRefPtr<layers::CairoImage> mImage; |
| |
62 nsCOMPtr<nsITimer> mTimer; |
| |
63 Monitor mMonitor; |
| |
64 nsCOMPtr<nsITabSource> mTabSource; |
| |
65 }; |
| |
66 } |