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 <mmf/common/mmfcontroller.h> |
|
23 #include "CMMAStreamRequest.h" |
|
24 #include "MMMAStreamRequestListener.h" |
|
25 #include "MMMAStreamHandlerListener.h" |
|
26 |
|
27 |
|
28 // CONSTANTS |
|
29 const TInt KMMAStreamHandlerBufferCount = 2; |
|
30 |
|
31 class CMMADataSourceStream; |
|
32 |
|
33 // CLASS DECLARATION |
|
34 /** |
|
35 * This class read data from CMMADataSourceStream and writes it to |
|
36 * controller. |
|
37 */ |
|
38 NONSHARABLE_CLASS(CMMAStreamHandler): public CBase, |
|
39 public MMMAStreamRequestListener |
|
40 { |
|
41 private: |
|
42 // Streams internal state |
|
43 enum TMMAStreamState |
|
44 { |
|
45 EMMAStreamPrepare = 0, |
|
46 EMMAStreamPaused, |
|
47 EMMAStreamStart, |
|
48 EMMAStreamStarted, |
|
49 EMMAStreamEof |
|
50 }; |
|
51 |
|
52 public: // Construction |
|
53 /** |
|
54 * Creates new player. |
|
55 */ |
|
56 static CMMAStreamHandler* NewL( |
|
57 MMMAStreamHandlerListener& aListener, |
|
58 RMMFController& aController); |
|
59 |
|
60 // Destructor |
|
61 ~CMMAStreamHandler(); |
|
62 |
|
63 protected: |
|
64 // C++ constructor |
|
65 CMMAStreamHandler(MMMAStreamHandlerListener& aResolver, |
|
66 RMMFController& aController); |
|
67 void ConstructL(); |
|
68 |
|
69 protected: // New methods |
|
70 |
|
71 public: // New methods |
|
72 /** |
|
73 * Prepares stream to play. |
|
74 */ |
|
75 void PrepareL(); |
|
76 |
|
77 /** |
|
78 * Stops handling requests. After this call data received from source |
|
79 * stream will be buffered until StartL is called. |
|
80 */ |
|
81 void Pause(); |
|
82 |
|
83 /** |
|
84 * Starts handling requests |
|
85 */ |
|
86 void StartL(); |
|
87 |
|
88 /** |
|
89 * Data sink destination must be written to this reference |
|
90 * before stream can be started. |
|
91 * @return data sink destination reference |
|
92 */ |
|
93 TMMFMessageDestination& MessageDestination(); |
|
94 |
|
95 /** |
|
96 * Sets source stream to read |
|
97 */ |
|
98 void SetSourceStream(CMMADataSourceStream* aSourceStream); |
|
99 |
|
100 public: // From MMMAStreamRequestListener |
|
101 void WriteComplete(CMMAStreamRequest* aRequest); |
|
102 void ReadComplete(CMMAStreamRequest* aRequest); |
|
103 void HandleError(CMMAStreamRequest* aRequest, |
|
104 TInt aError); |
|
105 private: |
|
106 /** |
|
107 * Writes request to controller |
|
108 */ |
|
109 void WriteRequest(CMMAStreamRequest* aRequest); |
|
110 |
|
111 private: // data |
|
112 // Owned write requests |
|
113 RPointerArray< CMMAStreamRequest > iRequests; |
|
114 |
|
115 // not owned source stream |
|
116 CMMADataSourceStream* iSourceStream; |
|
117 |
|
118 // Controller to write stream |
|
119 RMMFController& iController; |
|
120 |
|
121 // added data source |
|
122 TMMFMessageDestination iDataSourceHandle; |
|
123 |
|
124 // not owned listener |
|
125 MMMAStreamHandlerListener& iListener; |
|
126 |
|
127 // Stream's state |
|
128 TMMAStreamState iState; |
|
129 }; |
|
130 |
|
131 #endif // CMMASTREAMHANDLER_H |
|