|
1 | | -/******************************************************************************* |
2 | | - * COPYRIGHT(c) 2015 STMicroelectronics |
3 | | - * |
4 | | - * Redistribution and use in source and binary forms, with or without modification, |
5 | | - * are permitted provided that the following conditions are met: |
6 | | - * 1. Redistributions of source code must retain the above copyright notice, |
7 | | - * this list of conditions and the following disclaimer. |
8 | | - * 2. Redistributions in binary form must reproduce the above copyright notice, |
9 | | - * this list of conditions and the following disclaimer in the documentation |
10 | | - * and/or other materials provided with the distribution. |
11 | | - * 3. Neither the name of STMicroelectronics nor the names of its contributors |
12 | | - * may be used to endorse or promote products derived from this software |
13 | | - * without specific prior written permission. |
14 | | - * |
15 | | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
16 | | - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | | - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
18 | | - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
19 | | - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
20 | | - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
21 | | - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
22 | | - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
23 | | - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 | | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 | | - * |
26 | | - ******************************************************************************/ |
27 | | -package com.st.BlueSTSDK.Utils; |
28 | | - |
29 | | -import com.st.BlueSTSDK.Feature; |
30 | | -import com.st.BlueSTSDK.Features.FeatureAudioADPCMSync; |
31 | | - |
32 | | -/** |
33 | | - * Class containing the sync data needed in a ADPCM stream decoding |
34 | | - * |
35 | | - * @author STMicroelectronics - Central Labs. |
36 | | - * @version 1.0 |
37 | | - */ |
38 | | -public class BVAudioSyncManager { |
39 | | - |
40 | | - private boolean intra_flag=false; |
41 | | - private short adpcm_index_in=0; |
42 | | - private int adpcm_predsample_in=0; |
43 | | - |
44 | | - public boolean isIntra() { |
45 | | - return intra_flag; |
46 | | - } |
47 | | - |
48 | | - public short getAdpcm_index_in() { |
49 | | - return adpcm_index_in; |
50 | | - } |
51 | | - |
52 | | - public int getAdpcm_predsample_in() { |
53 | | - return adpcm_predsample_in; |
54 | | - } |
55 | | - |
56 | | - public void reinitResetFlag(){ |
57 | | - intra_flag = false; |
58 | | - } |
59 | | - |
60 | | - public void setSyncParams(Feature.Sample sample){ |
61 | | - synchronized (this) { |
62 | | - adpcm_index_in = FeatureAudioADPCMSync.getIndex(sample); |
63 | | - adpcm_predsample_in = FeatureAudioADPCMSync.getPredictedSample(sample); |
64 | | - intra_flag = true; |
65 | | - } |
66 | | - } |
67 | | -} |
| 1 | +/******************************************************************************* |
| 2 | + * COPYRIGHT(c) 2015 STMicroelectronics |
| 3 | + * |
| 4 | + * Redistribution and use in source and binary forms, with or without modification, |
| 5 | + * are permitted provided that the following conditions are met: |
| 6 | + * 1. Redistributions of source code must retain the above copyright notice, |
| 7 | + * this list of conditions and the following disclaimer. |
| 8 | + * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 9 | + * this list of conditions and the following disclaimer in the documentation |
| 10 | + * and/or other materials provided with the distribution. |
| 11 | + * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| 12 | + * may be used to endorse or promote products derived from this software |
| 13 | + * without specific prior written permission. |
| 14 | + * |
| 15 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 16 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 18 | + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 19 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 20 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 21 | + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 22 | + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 23 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | + * |
| 26 | + ******************************************************************************/ |
| 27 | +package com.st.BlueSTSDK.Features.Audio.ADPCM; |
| 28 | + |
| 29 | +import com.st.BlueSTSDK.Feature; |
| 30 | +import com.st.BlueSTSDK.Features.Audio.AudioCodecManager; |
| 31 | + |
| 32 | +/** |
| 33 | + * Class containing the sync data needed in a ADPCM stream decoding |
| 34 | + * |
| 35 | + * @author STMicroelectronics - Central Labs. |
| 36 | + * @version 1.0 |
| 37 | + */ |
| 38 | +public class ADPCMManager implements AudioCodecManager { |
| 39 | + |
| 40 | + private static final String CODEC_NAME = "ADPCM"; |
| 41 | + private static final int SAMPLING_FREQ = 8000; |
| 42 | + private static final short CHANNELS = 1; |
| 43 | + |
| 44 | + /** index where you can find adpcm index value/description */ |
| 45 | + public static final int ADPCM_INDEX_INDEX = 0; |
| 46 | + /** index where you can find adpcm predsample value/description*/ |
| 47 | + public static final int ADPCM_PREDSAMPLE_INDEX = 1; |
| 48 | + |
| 49 | + private boolean intra_flag=false; |
| 50 | + private short adpcm_index_in=0; |
| 51 | + private int adpcm_predsample_in=0; |
| 52 | + |
| 53 | + public boolean isIntra() { |
| 54 | + return intra_flag; |
| 55 | + } |
| 56 | + |
| 57 | + public short getAdpcm_index_in() { |
| 58 | + return adpcm_index_in; |
| 59 | + } |
| 60 | + |
| 61 | + public int getAdpcm_predsample_in() { |
| 62 | + return adpcm_predsample_in; |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public void reinit(){ |
| 67 | + intra_flag = false; |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public String getCodecName() { |
| 72 | + return CODEC_NAME; |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + public int getSamplingFreq() { |
| 77 | + return SAMPLING_FREQ; |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public short getChannels() { |
| 82 | + return CHANNELS; |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + public boolean isAudioEnabled() { |
| 87 | + return true; |
| 88 | + } |
| 89 | + |
| 90 | + @Override |
| 91 | + public void updateParams(Feature.Sample sample){ |
| 92 | + synchronized (this) { |
| 93 | + adpcm_index_in = FeatureAudioADPCMSync.getIndex(sample); |
| 94 | + adpcm_predsample_in = FeatureAudioADPCMSync.getPredictedSample(sample); |
| 95 | + intra_flag = true; |
| 96 | + } |
| 97 | + } |
| 98 | +} |
0 commit comments