66
|
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: This class is used for playing sounds
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef CMMAEMCPLAYERBASE_H
|
|
19 |
#define CMMAEMCPLAYERBASE_H
|
|
20 |
|
|
21 |
// INCLUDES
|
|
22 |
#include <mmf/common/mmfbase.h>
|
|
23 |
#include "cmmaplayer.h"
|
|
24 |
#include "e32base.h"
|
|
25 |
#include "f32file.h"
|
|
26 |
#include "StreamControl.h"
|
|
27 |
#include "Events.h"
|
|
28 |
#include "MMControlFactory.h"
|
|
29 |
#include "ControlObserver.h"
|
|
30 |
#include "DataBufferSource.h"
|
|
31 |
#include "FileSource.h"
|
|
32 |
#include "DescriptorSource.h"
|
|
33 |
#include "DataBuffer.h"
|
|
34 |
#include "SinkControl.h"
|
|
35 |
#include "badesca.h"
|
|
36 |
#include "MimeTypes.h"
|
|
37 |
#include "StreamControlObserver.h"
|
|
38 |
#include "SourceControlObserver.h"
|
|
39 |
|
|
40 |
|
|
41 |
using multimedia ::MStreamControl;
|
|
42 |
using multimedia ::MControlObserver;
|
|
43 |
using multimedia ::MDataBufferSource;
|
|
44 |
using multimedia ::MDescriptorSource;
|
|
45 |
using multimedia ::MDataBuffer;
|
|
46 |
using multimedia ::MControl;
|
|
47 |
using multimedia ::CMultimediaFactory;
|
|
48 |
using multimedia ::MSinkControl;
|
|
49 |
using multimedia ::MFileSource;
|
|
50 |
using multimedia::MSourceControlObserver;
|
|
51 |
using multimedia::MStreamControlObserver;
|
|
52 |
|
|
53 |
class CMMAEMCResolver;
|
|
54 |
// CLASS DECLARATION
|
|
55 |
/**
|
|
56 |
* This is base class for players those use EMC
|
|
57 |
*
|
|
58 |
*
|
|
59 |
*/
|
|
60 |
|
|
61 |
NONSHARABLE_CLASS(CMMAEMCPlayerBase): public CMMAPlayer,
|
|
62 |
public MControlObserver
|
|
63 |
{
|
|
64 |
protected:
|
|
65 |
// C++ constructor
|
|
66 |
CMMAEMCPlayerBase(CMMAEMCResolver* aResolver);
|
|
67 |
void ConstructL();
|
|
68 |
|
|
69 |
~CMMAEMCPlayerBase();
|
|
70 |
public: // new methods
|
|
71 |
/**
|
|
72 |
* Getter for StreamControl
|
|
73 |
*/
|
|
74 |
IMPORT_C MStreamControl * StreamControl();
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Multimedia Factory getter
|
|
78 |
*/
|
|
79 |
IMPORT_C CMultimediaFactory* MMFactory();
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Check whether this player is playing from a file locator
|
|
83 |
* @return ETrue if is a file player, EFalse otherwise
|
|
84 |
*/
|
|
85 |
TBool IsFilePlayer();
|
|
86 |
|
|
87 |
public: // from CMMAPlayer
|
|
88 |
void StartL(TBool aPostEvent);
|
|
89 |
void StopL(TBool aPostEvent);
|
|
90 |
void DeallocateL();
|
|
91 |
void GetDuration(TInt64* aDuration);
|
|
92 |
void SetMediaTimeL(TInt64* aTime);
|
|
93 |
void GetMediaTime(TInt64* aMediaTime);
|
|
94 |
void CloseL();
|
|
95 |
|
|
96 |
private: //New methods
|
|
97 |
void CreateStreamL();
|
|
98 |
void DetermineMimeTypeL(const TDesC& aFileName, TDes8& aMimeType);
|
|
99 |
void CleanupSource();
|
|
100 |
void AddDataSourceToStreamL();
|
|
101 |
|
|
102 |
public: // from MControlObserver
|
|
103 |
void Event(MControl* aControl,
|
|
104 |
TUint aEventType,
|
|
105 |
TAny* aEventObject);
|
|
106 |
|
|
107 |
protected:
|
|
108 |
|
|
109 |
CActiveSchedulerWait* iActiveSchedulerWait;
|
|
110 |
|
|
111 |
/**
|
|
112 |
* StreamControl infos, owned
|
|
113 |
*/
|
|
114 |
MStreamControl* iMStreamControl;
|
|
115 |
MDataBufferSource* iMDataBufferSource;
|
|
116 |
MDescriptorSource* iMDescriptorSource;
|
|
117 |
MFileSource* iMFileSource;
|
|
118 |
MSinkControl* iMAudioSink;
|
|
119 |
MStreamControl::TStreamState iPrevStreamControlState;
|
|
120 |
enum TSourceType
|
|
121 |
{
|
|
122 |
EFILESOURCE,
|
|
123 |
EDATABUFFERSOURCE,
|
|
124 |
EDESCRIPTORSOURCE
|
|
125 |
};
|
|
126 |
TSourceType iSourceType;
|
|
127 |
RPointerArray<MDataBuffer> iBuffers;
|
|
128 |
RArray<TInt> iAvailable;
|
|
129 |
TBool iIsEOFReached;
|
|
130 |
TBool iAutoWriteBuffer;
|
|
131 |
TInt iBytesReadFromFile;
|
|
132 |
TInt iFileSizeInBytes;
|
|
133 |
CMultimediaFactory* iFactory;
|
|
134 |
|
|
135 |
HBufC8* iMimeType;
|
|
136 |
HBufC8* iDescData;
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Filename used for playing directly from file, owned
|
|
140 |
*/
|
|
141 |
HBufC* iFileName;
|
|
142 |
|
|
143 |
/**
|
|
144 |
* Cached media time
|
|
145 |
*/
|
|
146 |
TInt64 iMediaTime;
|
|
147 |
|
|
148 |
/**
|
|
149 |
* The time that will be sent with CMMAPlayerEvent::EStarted
|
|
150 |
* (may be different from iMediaTime).
|
|
151 |
*/
|
|
152 |
TInt64 iStartedEventTime;
|
|
153 |
};
|
|
154 |
|
|
155 |
#endif // CMMAEMCPLAYERBASE_H
|
|
156 |
|
|
157 |
// End of file
|