1 /* |
|
2 * Copyright (c) 2002-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: Streams data from Java to controller |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CMMASTREAMHANDLER_H |
|
19 #define CMMASTREAMHANDLER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include "cmmastreamrequest.h" |
|
23 #include "mmmastreamrequestlistener.h" |
|
24 #include "mmmastreamhandlerlistener.h" |
|
25 #include <MDUChunkDataObserver.h> |
|
26 #include <MetaDataUtility.h> |
|
27 |
|
28 //EMC |
|
29 #include "StreamControl.h" |
|
30 #include "MMControlFactory.h" |
|
31 #include "DataBufferSource.h" |
|
32 #include "DataBuffer.h" |
|
33 #include "SinkControl.h" |
|
34 #include "StreamControlObserver.h" |
|
35 #include "SourceControlObserver.h" |
|
36 |
|
37 |
|
38 using namespace multimedia; |
|
39 using multimedia ::MStreamControl; |
|
40 using multimedia ::MDataBufferSource; |
|
41 using multimedia ::MDataBuffer; |
|
42 using multimedia ::CMultimediaFactory; |
|
43 using multimedia ::MSinkControl; |
|
44 using multimedia::MSourceControlObserver; |
|
45 using multimedia::MStreamControlObserver; |
|
46 using multimedia::MBufferProcessedEvent; |
|
47 |
|
48 //End EMC |
|
49 |
|
50 |
|
51 // CONSTANTS |
|
52 const TInt KMMAStreamHandlerBufferCount = 2; |
|
53 |
|
54 class CMMADataSourceStream; |
|
55 |
|
56 // CLASS DECLARATION |
|
57 /** |
|
58 * This class read data from CMMADataSourceStream and writes it to |
|
59 * controller. |
|
60 */ |
|
61 NONSHARABLE_CLASS(CMMAStreamHandler): public CBase, public MControlObserver, |
|
62 public MMMAStreamRequestListener, public MMDUChunkDataObserver |
|
63 { |
|
64 private: |
|
65 // Streams internal state |
|
66 enum TMMAStreamState |
|
67 { |
|
68 EMMAStreamPrepare = 0, |
|
69 EMMAStreamPaused, |
|
70 EMMAStreamStart, |
|
71 EMMAStreamStarted, |
|
72 EMMAStreamEof |
|
73 }; |
|
74 |
|
75 // chunk data processed state |
|
76 enum TMMAProcessedState |
|
77 { |
|
78 EMMANoneProcessed = 0, |
|
79 EMMAMetaDataProcessed, |
|
80 EMMABufferProcessed, |
|
81 EMMABothProcessed |
|
82 }; |
|
83 |
|
84 public: // Construction |
|
85 /** |
|
86 * Creates new player. |
|
87 */ |
|
88 static CMMAStreamHandler* NewL( |
|
89 MMMAStreamHandlerListener& aListener, |
|
90 MStreamControl& aMStreamControl, |
|
91 MDataBufferSource& aMDataBufferSource, |
|
92 CMultimediaFactory& aFactory, |
|
93 CMetaDataUtility& aMetaDataUtility); |
|
94 |
|
95 // Destructor |
|
96 ~CMMAStreamHandler(); |
|
97 |
|
98 protected: |
|
99 // C++ constructor |
|
100 CMMAStreamHandler(MMMAStreamHandlerListener& aResolver, |
|
101 MStreamControl& aMStreamControl, |
|
102 MDataBufferSource& aMDataBufferSource, |
|
103 CMultimediaFactory& aFactory, |
|
104 CMetaDataUtility& aMetaDataUtility); |
|
105 void ConstructL(); |
|
106 |
|
107 protected: // New methods |
|
108 |
|
109 public: // New methods |
|
110 /** |
|
111 * Prepares stream to play. |
|
112 */ |
|
113 void Prepare(const TDesC8& aMimeType); |
|
114 |
|
115 /** |
|
116 * Stops handling requests. After this call data received from source |
|
117 * stream will be buffered until StartL is called. |
|
118 */ |
|
119 void Pause(); |
|
120 |
|
121 /** |
|
122 * Stops handling requests and frees already read data |
|
123 * without playing it. |
|
124 */ |
|
125 void Stop(); |
|
126 |
|
127 /** |
|
128 * Starts handling requests |
|
129 */ |
|
130 void Start(); |
|
131 |
|
132 /** |
|
133 * Sets source stream to read |
|
134 */ |
|
135 void SetSourceStream(CMMADataSourceStream* aSourceStream); |
|
136 |
|
137 public: // From MMMAStreamRequestListener |
|
138 void WriteComplete(CMMAStreamRequest* aRequest); |
|
139 void ReadComplete(CMMAStreamRequest* aRequest); |
|
140 void HandleError(CMMAStreamRequest* aRequest, |
|
141 TInt aError); |
|
142 |
|
143 public: // from MControlObserver |
|
144 void Event(MControl* aControl, |
|
145 TUint aEventType, |
|
146 TAny* aEventObject); |
|
147 TBool LastBufferWritten(); |
|
148 |
|
149 public: // from MMDUChunkDataObserver |
|
150 void HandleChunkDataProcessed(TInt aError); |
|
151 void HandleChunkDataReadyToBeParsed(); |
|
152 void HandleChunkDataComplete(TInt aError); |
|
153 |
|
154 private: |
|
155 /** |
|
156 * Writes request to controller |
|
157 */ |
|
158 void WriteRequest(CMMAStreamRequest* aRequest); |
|
159 |
|
160 private: // data |
|
161 // Owned write requests |
|
162 RPointerArray< CMMAStreamRequest > iRequests; |
|
163 |
|
164 CMMAStreamRequest* iCurrentRequest; |
|
165 |
|
166 // not owned source stream |
|
167 CMMADataSourceStream* iSourceStream; |
|
168 |
|
169 // EMC |
|
170 // not owned |
|
171 MStreamControl& iMStreamControl; |
|
172 MDataBufferSource& iMDataBufferSource; |
|
173 CMultimediaFactory& iFactory; |
|
174 |
|
175 // owned |
|
176 MDataBuffer *iBuffer; |
|
177 TBool iLastBufferWritten; |
|
178 // |
|
179 |
|
180 // not owned listener |
|
181 MMMAStreamHandlerListener& iListener; |
|
182 |
|
183 // not owned |
|
184 CMetaDataUtility& iMetaDataUtility; |
|
185 |
|
186 // Stream's state |
|
187 TMMAStreamState iState; |
|
188 |
|
189 // Processed state of current chunk data |
|
190 TMMAProcessedState iProcessedState; |
|
191 |
|
192 // tells if metadata parsing can be started |
|
193 TBool iMetaDataReadyToBeParsed; |
|
194 |
|
195 // to be removed once MDU supports all the reqd formats |
|
196 TBool iMimeTypeSupportedByMDU; |
|
197 }; |
|
198 |
|
199 #endif // CMMASTREAMHANDLER_H |
|