sbMediacoreManager.h
Go to the documentation of this file.
1 /* vim: set sw=2 :miv */
2 /*
3 //
4 // BEGIN SONGBIRD GPL
5 //
6 // This file is part of the Songbird web player.
7 //
8 // Copyright(c) 2005-2008 POTI, Inc.
9 // http://songbirdnest.com
10 //
11 // This file may be licensed under the terms of of the
12 // GNU General Public License Version 2 (the "GPL").
13 //
14 // Software distributed under the License is distributed
15 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
16 // express or implied. See the GPL for the specific language
17 // governing rights and limitations.
18 //
19 // You should have received a copy of the GPL along with this
20 // program. If not, go to http://www.gnu.org/licenses/gpl.html
21 // or write to the Free Software Foundation, Inc.,
22 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 //
24 // END SONGBIRD GPL
25 //
26 */
27 
28 #include <sbIMediacoreManager.h>
29 
30 #include <nsAutoPtr.h>
31 #include <nsIClassInfo.h>
32 #include <nsIDOMEvent.h>
33 #include <nsIDOMEventListener.h>
34 #include <nsIDOMXULElement.h>
35 #include <nsInterfaceHashtable.h>
36 #include <nsIObserver.h>
37 
38 #include <nsHashKeys.h>
39 #include <prmon.h>
40 
41 // Interfaces
42 #include <sbIDataRemote.h>
43 #include <sbIMediacoreEventTarget.h>
44 #include <sbIMediacoreFactoryRegistrar.h>
45 #include <sbIMediacoreVideoWindow.h>
46 #include <sbIMediacoreVoting.h>
47 
50 
51 #include <sbWeakReference.h>
52 
53 // Forward declared classes
55 
58  public sbIMediacoreManager,
59  public sbPIMediacoreManager,
63  public sbIMediacoreVoting,
64  public nsIClassInfo,
65  public nsIObserver,
67 {
68 public:
70  NS_DECL_SBIMEDIACOREMANAGER
71  NS_DECL_SBPIMEDIACOREMANAGER
72  NS_DECL_SBIMEDIACOREEVENTTARGET
73  NS_DECL_SBIMEDIACOREFACTORYREGISTRAR
74  NS_DECL_SBIMEDIACOREVIDEOWINDOW
75  NS_DECL_SBIMEDIACOREVOTING
76  NS_DECL_NSICLASSINFO
77  NS_DECL_NSIOBSERVER
78 
79  NS_FORWARD_SBIMEDIACOREVOLUMECONTROL(sbBaseMediacoreVolumeControl::)
80 
82 
83  nsresult Init();
84  nsresult PreShutdown();
85  nsresult Shutdown();
86 
87  // sbBaseMediacoreMultibandEqualizer overrides
88  virtual nsresult OnInitBaseMediacoreMultibandEqualizer();
89  virtual nsresult OnSetEqEnabled(PRBool aEqEnabled);
90  virtual nsresult OnGetBandCount(PRUint32 *aBandCount);
91  virtual nsresult OnGetBand(PRUint32 aBandIndex, sbIMediacoreEqualizerBand *aBand);
92  virtual nsresult OnSetBand(sbIMediacoreEqualizerBand *aBand);
93 
94  // sbBaseMediacoreVolumeControl overrides
95  virtual nsresult OnInitBaseMediacoreVolumeControl();
96  virtual nsresult OnSetMute(PRBool aMute);
97  virtual nsresult OnSetVolume(PRFloat64 aVolume);
98 
99  nsresult SetVolumeDataRemote(PRFloat64 aVolume);
100 
101  nsresult GetAndEnsureEQBandHasDataRemote(PRUint32 aBandIndex,
102  sbIDataRemote **aRemote);
104 
105  nsresult CreateDataRemoteForEqualizerBand(PRUint32 aBandIndex,
106  sbIDataRemote **aRemote);
107 
108  nsresult InitVideoDataRemotes();
109  nsresult VideoWindowUnloaded();
110 
111 protected:
112  virtual ~sbMediacoreManager();
113 
114  // copies the given hash table into the given mutable array
115  template<class T>
116  static NS_HIDDEN_(PLDHashOperator)
117  EnumerateIntoArrayStringKey(const nsAString& aKey,
118  T* aData,
119  void* aArray);
120  template<class T>
121  static NS_HIDDEN_(PLDHashOperator)
122  EnumerateIntoArrayISupportsKey(nsISupports *aKey,
123  T* aData,
124  void* aArray);
125  template<class T>
126  static NS_HIDDEN_(PLDHashOperator)
127  EnumerateIntoArrayUint32Key(const PRUint32 &aKey,
128  T* aData,
129  void* aArray);
130 
131  nsresult GenerateInstanceName(nsAString &aInstanceName);
132 
133  nsresult VoteWithURIOrChannel(nsIURI *aURI,
134  nsIChannel *aChannel,
135  sbIMediacoreVotingChain **_retval);
136 
137  PRMonitor* mMonitor;
138  PRUint32 mLastCore;
139 
140  nsInterfaceHashtableMT<nsStringHashKey, sbIMediacore> mCores;
141  nsInterfaceHashtableMT<nsISupportsHashKey, sbIMediacoreFactory> mFactories;
142 
146 
148  nsInterfaceHashtableMT<nsUint32HashKey, sbIDataRemote> mDataRemoteEqualizerBands;
149 
153 
154  PRPackedBool mFullscreen;
155 
157  nsCOMPtr<nsIDOMXULElement> mVideoWindow;
159 };
160 
162 {
163 public:
165  NS_DECL_NSIDOMEVENTLISTENER
166 
168  virtual ~sbMediacoreVideoWindowListener();
169 
170  nsresult Init(sbMediacoreManager *aManager, nsIDOMEventTarget *aTarget);
171  PRBool IsWindowReady();
172 
173 protected:
174  PRPackedBool mWindowReady;
175  nsRefPtr<sbMediacoreManager> mManager;
176  nsCOMPtr<nsIDOMEventTarget> mTarget;
177 };
nsCOMPtr< sbIDataRemote > mDataRemoteFaceplateVolume
Songbird Mediacore Base Multiband Equalizer Definition.
nsInterfaceHashtableMT< nsUint32HashKey, sbIDataRemote > mDataRemoteEqualizerBands
virtual nsresult OnInitBaseMediacoreVolumeControl()
virtual nsresult OnGetBandCount(PRUint32 *aBandCount)
nsCOMPtr< nsIDOMEventTarget > mTarget
static NS_HIDDEN_(PLDHashOperator) EnumerateIntoArrayStringKey(const nsAString &aKey
virtual nsresult OnSetEqEnabled(PRBool aEqEnabled)
virtual nsresult OnSetBand(sbIMediacoreEqualizerBand *aBand)
nsresult SetAndEnsureEQBandHasDataRemote(sbIMediacoreEqualizerBand *aBand)
nsCOMPtr< sbIDataRemote > mDataRemoteFaceplateMute
nsresult GetAndEnsureEQBandHasDataRemote(PRUint32 aBandIndex, sbIDataRemote **aRemote)
An interface for accessing, and binding to, stored data.
PRMonitor * mVideoWindowMonitor
Songbird Mediacore Event Definition.
nsresult VoteWithURIOrChannel(nsIURI *aURI, nsIChannel *aChannel, sbIMediacoreVotingChain **_retval)
static T void * aArray
nsCOMPtr< sbIDataRemote > mDataRemoteEqualizerEnabled
nsInterfaceHashtableMT< nsISupportsHashKey, sbIMediacoreFactory > mFactories
const nsIChannel
virtual nsresult OnSetMute(PRBool aMute)
nsCOMPtr< sbIMediacore > mPrimaryCore
nsCOMPtr< nsIDOMXULElement > mVideoWindow
nsInterfaceHashtableMT< nsStringHashKey, sbIMediacore > mCores
nsresult CreateDataRemoteForEqualizerBand(PRUint32 aBandIndex, sbIDataRemote **aRemote)
nsresult GenerateInstanceName(nsAString &aInstanceName)
virtual nsresult OnInitBaseMediacoreMultibandEqualizer()
nsRefPtr< sbMediacoreManager > mManager
nsresult SetVolumeDataRemote(PRFloat64 aVolume)
virtual nsresult OnGetBand(PRUint32 aBandIndex, sbIMediacoreEqualizerBand *aBand)
NS_DECL_ISUPPORTS NS_DECL_SBIMEDIACOREMANAGER NS_DECL_SBPIMEDIACOREMANAGER NS_DECL_SBIMEDIACOREEVENTTARGET NS_DECL_SBIMEDIACOREFACTORYREGISTRAR NS_DECL_SBIMEDIACOREVIDEOWINDOW NS_DECL_SBIMEDIACOREVOTING NS_DECL_NSICLASSINFO NS_DECL_NSIOBSERVER sbMediacoreManager()
nsIDOMEventListener
nsAutoPtr< sbBaseMediacoreEventTarget > mBaseEventTarget
nsCOMPtr< sbIDataRemote > mDataRemoteVideoFullscreen
virtual nsresult OnSetVolume(PRFloat64 aVolume)
nsCOMPtr< sbIMediacoreSequencer > mSequencer