• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.tv.tuner.exoplayer.audio;
18 
19 import com.google.android.exoplayer.ExoPlaybackException;
20 import com.google.android.exoplayer.MediaFormat;
21 import com.google.android.exoplayer.SampleHolder;
22 
23 import java.nio.ByteBuffer;
24 
25 /** A base class for audio decoders. */
26 public abstract class AudioDecoder {
27 
28     /**
29      * Decodes an audio sample.
30      *
31      * @param sampleHolder a holder that contains the sample data and corresponding metadata
32      */
decode(SampleHolder sampleHolder)33     public abstract void decode(SampleHolder sampleHolder);
34 
35     /** Returns a decoded sample from decoder. */
getDecodedSample()36     public abstract ByteBuffer getDecodedSample();
37 
38     /** Returns the presentation time for the decoded sample. */
getDecodedTimeUs()39     public abstract long getDecodedTimeUs();
40 
41     /**
42      * Clear previous decode state if any. Prepares to decode samples of the specified encoding.
43      * This method should be called before using decode.
44      *
45      * @param mime audio encoding
46      */
resetDecoderState(String mimeType)47     public abstract void resetDecoderState(String mimeType);
48 
49     /** Releases all the resource. */
release()50     public abstract void release();
51 
52     /**
53      * Init decoder if needed.
54      *
55      * @param format the format used to initialize decoder
56      */
maybeInitDecoder(MediaFormat format)57     public void maybeInitDecoder(MediaFormat format) throws ExoPlaybackException {
58         // Do nothing.
59     }
60 
61     /** Returns input buffer that will be used in decoder. */
getInputBuffer()62     public ByteBuffer getInputBuffer() {
63         return null;
64     }
65 
66     /** Returns the output format. */
getOutputFormat()67     public android.media.MediaFormat getOutputFormat() {
68         return null;
69     }
70 }
71