|
1 /* |
|
2 * Copyright (c) 2002 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 creating streaming audio player. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <jdebug.h> |
|
21 #include <MetaDataUtility.h> |
|
22 |
|
23 #include "cmmaaudiostreamplayerfactory.h" |
|
24 #include "cmmaaudiostreamplayer.h" |
|
25 #include "cmmaemcaudiovolumecontrol.h" |
|
26 #include "cmmastoptimecontrol.h" |
|
27 #include "cmmaaudiostreammetadatacontrol.h" |
|
28 #include "cmmaemcresolver.h" |
|
29 #include "cmmaaudiostreamratecontrol.h" |
|
30 |
|
31 // CONSTANTS |
|
32 _LIT(KMimetypeAMR,"audio/amr"); |
|
33 _LIT(KMimetypeAMRWB,"audio/amr-wb"); |
|
34 _LIT(KMimetypeAAC, "audio/aac"); |
|
35 _LIT(KMimetype3GPP, "audio/3gpp"); |
|
36 _LIT(KMimetype3GPP2, "audio/3gpp2"); |
|
37 _LIT(KMimetypeMPEG, "audio/mpeg"); |
|
38 _LIT(KMimetypeMP4, "audio/mp4"); |
|
39 _LIT(KMimetypeXMSWMA, "audio/x-ms-wma"); |
|
40 _LIT(KMimetypeRM, "audio/x-pn-realaudio"); |
|
41 |
|
42 CMMAAudioStreamPlayerFactory* CMMAAudioStreamPlayerFactory::NewLC() |
|
43 { |
|
44 CMMAAudioStreamPlayerFactory* pFactory = |
|
45 new(ELeave) CMMAAudioStreamPlayerFactory(); |
|
46 CleanupStack::PushL(pFactory); |
|
47 return pFactory; |
|
48 } |
|
49 |
|
50 CMMAAudioStreamPlayerFactory::CMMAAudioStreamPlayerFactory() |
|
51 { |
|
52 iHeaderData = NULL; |
|
53 } |
|
54 |
|
55 |
|
56 CMMAAudioStreamPlayerFactory::~CMMAAudioStreamPlayerFactory() |
|
57 { |
|
58 } |
|
59 |
|
60 CMMAPlayer* CMMAAudioStreamPlayerFactory::CreatePlayerL( |
|
61 const TDesC& /*aContentType*/) |
|
62 { |
|
63 // only http/https protocol is supported |
|
64 return NULL; |
|
65 } |
|
66 |
|
67 CMMAPlayer* CMMAAudioStreamPlayerFactory::CreatePlayerL( |
|
68 const TDesC& aProtocol, |
|
69 const TDesC& aMiddlePart, |
|
70 const TDesC& aParameters) |
|
71 { |
|
72 // only http and https protocols are supported |
|
73 if ((aProtocol != KMMAHttpProtocol) && (aProtocol != KMMAHttpsProtocol)) |
|
74 { |
|
75 return NULL; |
|
76 } |
|
77 |
|
78 return CMMAEMCPlayerFactory::CreatePlayerL(aProtocol, |
|
79 aMiddlePart, |
|
80 aParameters); |
|
81 } |
|
82 |
|
83 CMMAPlayer* CMMAAudioStreamPlayerFactory::CreatePlayerL( |
|
84 const TDesC8& /*aHeaderData*/) |
|
85 { |
|
86 // only http/https protocol is supported |
|
87 return NULL; |
|
88 } |
|
89 |
|
90 CMMAPlayer* CMMAAudioStreamPlayerFactory::CreatePlayerL( |
|
91 CMMAEMCResolver* aResolver) |
|
92 { |
|
93 aResolver->SetSourceInfoL(iHeaderData); |
|
94 |
|
95 HBufC* contentType = aResolver->ContentType(); |
|
96 if (!contentType || |
|
97 ((contentType->Des() != KMimetypeAMR) && |
|
98 (contentType->Des() != KMimetypeAMRWB) && |
|
99 (contentType->Des() != KMimetypeAAC) && |
|
100 (contentType->Des() != KMimetypeXMSWMA) && |
|
101 (contentType->Des() != KMimetypeRM) && |
|
102 (contentType->Des() != KMimetypeMPEG) && |
|
103 (contentType->Des() != KMimetype3GPP2) && |
|
104 (contentType->Des() != KMimetype3GPP) && |
|
105 (contentType->Des() != KMimetypeMP4))) |
|
106 { |
|
107 return NULL; |
|
108 } |
|
109 |
|
110 CMMAAudioStreamPlayer* player = CMMAAudioStreamPlayer::NewLC(aResolver); |
|
111 |
|
112 CMMAEMCAudioVolumeControl* volumeControl = CMMAEMCAudioVolumeControl::NewL(*player); |
|
113 CleanupStack::PushL(volumeControl); |
|
114 player->AddControlL(volumeControl); |
|
115 CleanupStack::Pop(volumeControl); |
|
116 |
|
117 CMMAStopTimeControl* stopTimeControl = CMMAStopTimeControl::NewL(player); |
|
118 CleanupStack::PushL(stopTimeControl); |
|
119 player->AddControlL(stopTimeControl); |
|
120 CleanupStack::Pop(stopTimeControl); |
|
121 |
|
122 CMMAAudioStreamRateControl* rateControl = CMMAAudioStreamRateControl::NewL(player); |
|
123 CleanupStack::PushL(rateControl); |
|
124 player->AddControlL(rateControl); |
|
125 CleanupStack::Pop(rateControl); |
|
126 |
|
127 CMMAAudioStreamMetaDataControl* metadatacontrol = |
|
128 new(ELeave) CMMAAudioStreamMetaDataControl(player->MetaDataUtilityOwnership()); |
|
129 CleanupStack::PushL(metadatacontrol); |
|
130 player->AddControlL(metadatacontrol); |
|
131 CleanupStack::Pop(metadatacontrol); |
|
132 |
|
133 // delete isourceinfo; |
|
134 // no longer required, can be destroyed here |
|
135 if (iHeaderData) |
|
136 { |
|
137 delete iHeaderData; |
|
138 iHeaderData = NULL; |
|
139 } |
|
140 |
|
141 CleanupStack::Pop(player); |
|
142 |
|
143 return player; |
|
144 } |
|
145 |
|
146 void CMMAAudioStreamPlayerFactory::GetSupportedContentTypesL(const TDesC& /*aProtocol*/, |
|
147 CDesC16Array& /*aMimeTypeArray*/) |
|
148 { |
|
149 // streaming player does not add new content types |
|
150 } |
|
151 |
|
152 void CMMAAudioStreamPlayerFactory::MediaIdsL(RArray<TUid>& aMediaIds) |
|
153 { |
|
154 CleanupClosePushL(aMediaIds); |
|
155 User::LeaveIfError(aMediaIds.Append(KUidMediaTypeAudio)); |
|
156 CleanupStack::Pop(); |
|
157 } |
|
158 |
|
159 void CMMAAudioStreamPlayerFactory::SetSourceInfoL(const TUint8* aHeader, TInt aLength) |
|
160 { |
|
161 iHeaderData = HBufC8::NewL(aLength); |
|
162 iHeaderData->Des().Copy(aHeader, aLength); |
|
163 } |
|
164 |
|
165 // END OF FILE |