|
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 <logger.h> |
|
21 #include "CMMAAudioStreamPlayerFactory.h" |
|
22 #include "CMMAAudioStreamPlayer.h" |
|
23 #include "CMMAAudioVolumeControl.h" |
|
24 #include "CMMAStopTimeControl.h" |
|
25 #include "CMMAMMFResolver.h" |
|
26 #include "CMMAAudioMetaDataControl.h" |
|
27 #include "CMMAAudioStreamRateControl.h" |
|
28 |
|
29 // CONSTANTS |
|
30 _LIT(KMMAAMRMimetype, "audio/amr"); |
|
31 _LIT(KMMAAMRWBMimetype, "audio/amr-wb"); |
|
32 |
|
33 CMMAAudioStreamPlayerFactory* CMMAAudioStreamPlayerFactory::NewLC() |
|
34 { |
|
35 CMMAAudioStreamPlayerFactory* pFactory = |
|
36 new(ELeave) CMMAAudioStreamPlayerFactory(); |
|
37 CleanupStack::PushL(pFactory); |
|
38 return pFactory; |
|
39 } |
|
40 |
|
41 CMMAAudioStreamPlayerFactory::CMMAAudioStreamPlayerFactory() |
|
42 { |
|
43 } |
|
44 |
|
45 |
|
46 CMMAAudioStreamPlayerFactory::~CMMAAudioStreamPlayerFactory() |
|
47 { |
|
48 } |
|
49 |
|
50 CMMAPlayer* CMMAAudioStreamPlayerFactory::CreatePlayerL( |
|
51 const TDesC& /*aContentType*/) |
|
52 { |
|
53 // only http protocol is supported |
|
54 return NULL; |
|
55 } |
|
56 |
|
57 CMMAPlayer* CMMAAudioStreamPlayerFactory::CreatePlayerL( |
|
58 const TDesC& aProtocol, |
|
59 const TDesC& aMiddlePart, |
|
60 const TDesC& aParameters) |
|
61 { |
|
62 // only http protocol is supported |
|
63 if (aProtocol != KMMAHttpProtocol) |
|
64 { |
|
65 return NULL; |
|
66 } |
|
67 |
|
68 return CMMAMMFPlayerFactory::CreatePlayerL(aProtocol, |
|
69 aMiddlePart, |
|
70 aParameters); |
|
71 } |
|
72 |
|
73 CMMAPlayer* CMMAAudioStreamPlayerFactory::CreatePlayerL( |
|
74 const TDesC8& /*aHeaderData*/) |
|
75 { |
|
76 // only http protocol is supported |
|
77 return NULL; |
|
78 } |
|
79 |
|
80 CMMAPlayer* CMMAAudioStreamPlayerFactory::CreatePlayerL( |
|
81 CMMAMMFResolver* aResolver) |
|
82 { |
|
83 // only amr streaming is supported |
|
84 HBufC* contentType = aResolver->ContentType(); |
|
85 if (!contentType || |
|
86 ((contentType->Des() != KMMAAMRMimetype) && |
|
87 (contentType->Des() != KMMAAMRWBMimetype))) |
|
88 { |
|
89 return NULL; |
|
90 } |
|
91 |
|
92 CMMAAudioStreamPlayer* player = CMMAAudioStreamPlayer::NewLC(aResolver); |
|
93 |
|
94 CMMAAudioVolumeControl* volumeControl = CMMAAudioVolumeControl::NewL(player); |
|
95 CleanupStack::PushL(volumeControl); |
|
96 player->AddControlL(volumeControl); |
|
97 CleanupStack::Pop(volumeControl); |
|
98 |
|
99 // Amr stream player should support METADATACONTROL so adding this control to the player |
|
100 CMMAAudioMetaDataControl* metaDataControl = |
|
101 new(ELeave) CMMAAudioMetaDataControl(player->Controller()); |
|
102 CleanupStack::PushL(metaDataControl); |
|
103 player->AddControlL(metaDataControl); |
|
104 CleanupStack::Pop(metaDataControl); |
|
105 |
|
106 CMMAStopTimeControl* stopTimeControl = CMMAStopTimeControl::NewL(player); |
|
107 CleanupStack::PushL(stopTimeControl); |
|
108 player->AddControlL(stopTimeControl); |
|
109 CleanupStack::Pop(stopTimeControl); |
|
110 |
|
111 CMMAAudioStreamRateControl* rateControl = CMMAAudioStreamRateControl::NewL(player); |
|
112 CleanupStack::PushL(rateControl); |
|
113 player->AddControlL(rateControl); |
|
114 CleanupStack::Pop(rateControl); |
|
115 |
|
116 CleanupStack::Pop(player); |
|
117 |
|
118 return player; |
|
119 } |
|
120 |
|
121 void CMMAAudioStreamPlayerFactory::GetSupportedContentTypesL(const TDesC& /*aProtocol*/, |
|
122 CDesC16Array& /*aMimeTypeArray*/) |
|
123 { |
|
124 // streaming player does not add new content types |
|
125 } |
|
126 |
|
127 void CMMAAudioStreamPlayerFactory::MediaIdsL(RArray<TUid>& aMediaIds) |
|
128 { |
|
129 User::LeaveIfError(aMediaIds.Append(KUidMediaTypeAudio)); |
|
130 } |
|
131 |
|
132 // END OF FILE |