|
1 /* |
|
2 * Copyright (c) 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: Audio stream test component |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "StreamerBase.h" |
|
20 |
|
21 const TInt CStreamerBase::KBitRate8=8; |
|
22 const TInt CStreamerBase::KSampleRate8000Hz = 8000; |
|
23 const TInt CStreamerBase::KSampleRate11025Hz = 11025; |
|
24 const TInt CStreamerBase::KSampleRate12000Hz = 12000; |
|
25 const TInt CStreamerBase::KSampleRate16000Hz = 16000; |
|
26 const TInt CStreamerBase::KSampleRate22050Hz = 22050; |
|
27 const TInt CStreamerBase::KSampleRate24000Hz = 24000; |
|
28 const TInt CStreamerBase::KSampleRate32000Hz = 32000; |
|
29 const TInt CStreamerBase::KSampleRate44100Hz = 44100; |
|
30 const TInt CStreamerBase::KSampleRate48000Hz = 48000; |
|
31 const TInt CStreamerBase::KSampleRate64000Hz = 64000; |
|
32 const TInt CStreamerBase::KSampleRate96000Hz = 96000; |
|
33 |
|
34 const TInt CStreamerBase::KChannelsMono = 1; |
|
35 const TInt CStreamerBase::KChannelsStereo = 2; |
|
36 |
|
37 CStreamerBase::CStreamerBase(CStifLogger *aLogger) |
|
38 : iFinalError(KErrNone), iId(0), iLogger(aLogger) , iCurrentBuffer(-1) //, iBuffers(16) |
|
39 { |
|
40 iExitAfterOpen = EFalse; |
|
41 } |
|
42 |
|
43 CStreamerBase::~CStreamerBase() |
|
44 { |
|
45 iBuffers.ResetAndDestroy(); |
|
46 } |
|
47 |
|
48 void CStreamerBase::SetId(TInt aId) { iId = aId; } |
|
49 |
|
50 TInt CStreamerBase::GetId() { return iId; } |
|
51 |
|
52 TInt CStreamerBase::GetFinalError() { return iFinalError; } |
|
53 |
|
54 TTimeIntervalMicroSeconds CStreamerBase::GetExecDuration() { return iLastStopTime.MicroSecondsFrom(iLastStartTime); } |
|
55 |
|
56 TTime CStreamerBase::GetStartTime() { return iLastStartTime; } |
|
57 |
|
58 TTime CStreamerBase::GetStopTime() { return iLastStopTime; } |
|
59 |
|
60 TInt CStreamerBase::AppendBuffer(TDes8 *aBuffer) |
|
61 { |
|
62 return iBuffers.Append(aBuffer); |
|
63 } |
|
64 |
|
65 TMdaAudioDataSettings::TAudioCaps CStreamerBase::TranslateRate(TInt aSampleRate, TMdaAudioDataSettings::TAudioCaps aDefaultSampleRate) |
|
66 { |
|
67 TMdaAudioDataSettings::TAudioCaps retVal=aDefaultSampleRate; |
|
68 |
|
69 switch(aSampleRate) |
|
70 { |
|
71 case KSampleRate8000Hz: |
|
72 iLogger->Log(_L("Setting sample rate to 8000")); |
|
73 retVal=TMdaAudioDataSettings::ESampleRate8000Hz; |
|
74 break; |
|
75 case KSampleRate11025Hz: |
|
76 iLogger->Log(_L("Setting sample rate to 11025")); |
|
77 retVal=TMdaAudioDataSettings::ESampleRate11025Hz; |
|
78 break; |
|
79 case KSampleRate12000Hz: |
|
80 iLogger->Log(_L("Setting sample rate to 12000")); |
|
81 retVal=TMdaAudioDataSettings::ESampleRate12000Hz; |
|
82 break; |
|
83 case KSampleRate16000Hz: |
|
84 iLogger->Log(_L("Setting sample rate to 16000")); |
|
85 retVal=TMdaAudioDataSettings::ESampleRate16000Hz; |
|
86 break; |
|
87 case KSampleRate22050Hz: |
|
88 iLogger->Log(_L("Setting sample rate to 22050")); |
|
89 retVal=TMdaAudioDataSettings::ESampleRate22050Hz; |
|
90 break; |
|
91 case KSampleRate24000Hz: |
|
92 iLogger->Log(_L("Setting sample rate to 24000")); |
|
93 retVal=TMdaAudioDataSettings::ESampleRate24000Hz; |
|
94 break; |
|
95 case KSampleRate32000Hz: |
|
96 iLogger->Log(_L("Setting sample rate to 32000")); |
|
97 retVal=TMdaAudioDataSettings::ESampleRate32000Hz; |
|
98 break; |
|
99 case KSampleRate44100Hz: |
|
100 iLogger->Log(_L("Setting sample rate to 44100")); |
|
101 retVal=TMdaAudioDataSettings::ESampleRate44100Hz; |
|
102 break; |
|
103 case KSampleRate48000Hz: |
|
104 iLogger->Log(_L("Setting sample rate to 48000")); |
|
105 retVal=TMdaAudioDataSettings::ESampleRate48000Hz; |
|
106 break; |
|
107 case KSampleRate64000Hz: |
|
108 iLogger->Log(_L("Setting sample rate to 64000")); |
|
109 retVal=TMdaAudioDataSettings::ESampleRate64000Hz; |
|
110 break; |
|
111 case KSampleRate96000Hz: |
|
112 iLogger->Log(_L("Setting sample rate to 96000")); |
|
113 retVal=TMdaAudioDataSettings::ESampleRate96000Hz; |
|
114 break; |
|
115 default: |
|
116 break; |
|
117 iLogger->Log(_L("Setting sample rate to default")); |
|
118 } |
|
119 return retVal; |
|
120 } |
|
121 |
|
122 void CStreamerBase::Exit(TInt aExitCode) |
|
123 { |
|
124 iLogger->Log(_L("%d) CStreamerBase::Exit(%d)"), iId, aExitCode); |
|
125 iFinalError = aExitCode; |
|
126 CActiveScheduler::Stop(); |
|
127 } |
|
128 |
|
129 void CStreamerBase::SetExitAfterOpen(TBool aFlag) |
|
130 { |
|
131 iExitAfterOpen = aFlag; |
|
132 } |
|
133 |