• 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 import java.nio.ByteBuffer;
23 
24 /** A base class for audio decoders. */
25 public abstract class AudioDecoder {
26 
27     /**
28      * Decodes an audio sample.
29      *
30      * @param sampleHolder a holder that contains the sample data and corresponding metadata
31      */
decode(SampleHolder sampleHolder)32     public abstract void decode(SampleHolder sampleHolder);
33 
34     /** Returns a decoded sample from decoder. */
getDecodedSample()35     public abstract ByteBuffer getDecodedSample();
36 
37     /** Returns the presentation time for the decoded sample. */
getDecodedTimeUs()38     public abstract long getDecodedTimeUs();
39 
40     /**
41      * Clear previous decode state if any. Prepares to decode samples of the specified encoding.
42      * This method should be called before using decode.
43      *
44      * @param mimeType audio encoding
45      */
resetDecoderState(String mimeType)46     public abstract void resetDecoderState(String mimeType);
47 
48     /** Releases all the resource. */
release()49     public abstract void release();
50 
51     /**
52      * Init decoder if needed.
53      *
54      * @param format the format used to initialize decoder
55      */
maybeInitDecoder(MediaFormat format)56     public void maybeInitDecoder(MediaFormat format) throws ExoPlaybackException {
57         // Do nothing.
58     }
59 
60     /** Returns input buffer that will be used in decoder. */
getInputBuffer()61     public ByteBuffer getInputBuffer() {
62         return null;
63     }
64 
65     /** Returns the output format. */
getOutputFormat()66     public android.media.MediaFormat getOutputFormat() {
67         return null;
68     }
69 }
70