|
1 /* |
|
2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This class is a container for MAMMSControlGroup objects. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CAMMSMODULE_H |
|
20 #define CAMMSMODULE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 #include <cmmaplayer.h> |
|
26 |
|
27 #include "mammscontrollable.h" |
|
28 |
|
29 // CONSTANTS |
|
30 const TInt KAMMSPlayerAlreadyInModuleError = -123; |
|
31 |
|
32 #ifdef __WINS__ |
|
33 const TInt KAMMSMixingNotSupported = -1234; |
|
34 #endif // __WINS__ |
|
35 |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class CAMMSControlGroup; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 /** |
|
43 * |
|
44 * This class is a container for MAMMSControlGroup objects. |
|
45 * |
|
46 * |
|
47 * @since 3.0 |
|
48 */ |
|
49 NONSHARABLE_CLASS(CAMMSModule): public CBase, public MAMMSControllable |
|
50 { |
|
51 public: |
|
52 /** |
|
53 * Two-phased constructor. |
|
54 */ |
|
55 static CAMMSModule* NewL(); |
|
56 |
|
57 /** |
|
58 * Two-phased constructor. |
|
59 */ |
|
60 static CAMMSModule* NewLC(); |
|
61 |
|
62 /** |
|
63 * Destructor. |
|
64 */ |
|
65 ~CAMMSModule(); |
|
66 |
|
67 public: // New functions |
|
68 /** |
|
69 * Adds new control group to module. Ownership is transferred to |
|
70 * the module and aGroup is removed from the cleanupstack |
|
71 * if this method does not leave. |
|
72 * @since 3.0 |
|
73 * @param aGroup New control group. Must be the previous item in the |
|
74 * cleanupstack. |
|
75 */ |
|
76 void AddControlGroupAndPopL(CAMMSControlGroup* aGroup); |
|
77 |
|
78 /** |
|
79 * Adds new player to this module. |
|
80 * @param aPlayer New player to add |
|
81 */ |
|
82 virtual void AddPlayerL(CMMAPlayer* aPlayer); |
|
83 |
|
84 /** |
|
85 * Removes player from module. |
|
86 * @param aPlayer player to remove |
|
87 * @return KErrNotFound if player was not in the module. |
|
88 */ |
|
89 virtual TInt RemovePlayer(CMMAPlayer* aPlayer); |
|
90 |
|
91 /** |
|
92 * Adds new player to this module without checking player states. |
|
93 * @param aPlayer New player to add |
|
94 */ |
|
95 virtual void AddPlayerNoStateCheckL(CMMAPlayer* aPlayer); |
|
96 |
|
97 /** |
|
98 * Removes player from module without checking player states. |
|
99 * @param aPlayer player to remove |
|
100 * @return KErrNotFound if player was not in the module. |
|
101 */ |
|
102 virtual TInt RemovePlayerNoStateCheck(CMMAPlayer* aPlayer); |
|
103 |
|
104 /** |
|
105 * Checks whether the given player is in this module. |
|
106 * @param aPlayer Player to be checked. |
|
107 * @return ETrue if the specified player exists in this |
|
108 * module; EFalse otherwise. |
|
109 */ |
|
110 TBool HasPlayer(CMMAPlayer* aPlayer); |
|
111 |
|
112 #ifdef __WINS__ |
|
113 |
|
114 /** |
|
115 * Returns the count of players whose state is between the given |
|
116 * limits. |
|
117 * @param aMinState Minimum player state to be searched. |
|
118 * @param aMaxState Maximum player state to be searched. |
|
119 * @return The count of players having state between the given |
|
120 * limits. |
|
121 */ |
|
122 TInt PlayerCount(TInt aMinState, TInt aMaxState); |
|
123 |
|
124 #endif // __WINS__ |
|
125 |
|
126 |
|
127 private: // Private new functions |
|
128 /** |
|
129 * Checks that none of the players in this module is not in PREFETCHED |
|
130 * or STARTED state. |
|
131 * @return KErrNotReady if some player is in PREFETCHED or STARTED |
|
132 * state, otherwise KErrNone. |
|
133 */ |
|
134 TInt CheckAllPlayersState(); |
|
135 |
|
136 /** |
|
137 * Checks that player state is not in PREFETCHED or STARTED state. |
|
138 * @param aPlayer player to check |
|
139 * @return KErrNotReady if player is in PREFETCHED or STARTED state, |
|
140 * otherwise KErrNone. |
|
141 */ |
|
142 TInt CheckPlayerState(CMMAPlayer* aPlayer); |
|
143 |
|
144 /** |
|
145 * Static function to be used with TCleanupItem in |
|
146 * AddPlayerNoStateCheckL method. This method removes last added |
|
147 * player from module and control groups. |
|
148 * @param aModule Module to clean. |
|
149 */ |
|
150 static void CleanupAddPlayer(TAny* aModule); |
|
151 |
|
152 public: // Functions from base classes |
|
153 MAMMSControlGroup* Find(const TDesC& aClassName); |
|
154 MAMMSControlGroup* At(TInt aIndex); |
|
155 TInt Count(); |
|
156 |
|
157 protected: |
|
158 /** |
|
159 * C++ default constructor. |
|
160 */ |
|
161 CAMMSModule(); |
|
162 |
|
163 protected: |
|
164 /** |
|
165 * Protected because derived classes must call ConstructL. |
|
166 */ |
|
167 void ConstructL(); |
|
168 |
|
169 private: // Data |
|
170 // Owned array containing control groups, which are owned. |
|
171 // Elements are added using AddControlGroupL method and deleted |
|
172 // in the destructor. |
|
173 CArrayPtrSeg< CAMMSControlGroup >* iControlGroups; |
|
174 |
|
175 // Array containing players. |
|
176 // Elements are added using AddPlayerL method and removes |
|
177 // with RemovePlayer |
|
178 RPointerArray< CMMAPlayer > iPlayers; |
|
179 }; |
|
180 |
|
181 #endif // CAMMSMODULE_H |
|
182 |
|
183 |