blob: 92b7426d11ae3e02bfe74ae415f0d6d6eed8a89e [file] [log] [blame]
Pawin Vongmasa36653902018-11-15 00:10:25 -08001/*
2 * Copyright (C) 2018 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#ifndef ANDROID_C2_SOFT_OPUS_DEC_H_
18#define ANDROID_C2_SOFT_OPUS_DEC_H_
19
20#include <SimpleC2Component.h>
21
22
23struct OpusMSDecoder;
24
25namespace android {
26
27struct OpusHeader {
28 int channels;
29 int skip_samples;
30 int channel_mapping;
31 int num_streams;
32 int num_coupled;
33 int16_t gain_db;
34 uint8_t stream_map[8];
35};
36
37struct C2SoftOpusDec : public SimpleC2Component {
38 class IntfImpl;
39
40 C2SoftOpusDec(const char *name, c2_node_id_t id,
41 const std::shared_ptr<IntfImpl> &intfImpl);
42 virtual ~C2SoftOpusDec();
43
44 // From SimpleC2Component
45 c2_status_t onInit() override;
46 c2_status_t onStop() override;
47 void onReset() override;
48 void onRelease() override;
49 c2_status_t onFlush_sm() override;
50 void process(
51 const std::unique_ptr<C2Work> &work,
52 const std::shared_ptr<C2BlockPool> &pool) override;
53 c2_status_t drain(
54 uint32_t drainMode,
55 const std::shared_ptr<C2BlockPool> &pool) override;
56private:
57 enum {
58 kMaxNumSamplesPerBuffer = 960 * 6
59 };
60
61 std::shared_ptr<IntfImpl> mIntf;
62 OpusMSDecoder *mDecoder;
63 OpusHeader mHeader;
64
65 int64_t mCodecDelay;
66 int64_t mSeekPreRoll;
67 int64_t mSamplesToDiscard;
68 size_t mInputBufferCount;
69 bool mSignalledError;
70 bool mSignalledOutputEos;
71
72 status_t initDecoder();
73
74 C2_DO_NOT_COPY(C2SoftOpusDec);
75};
76
77} // namespace android
78
79#endif // ANDROID_C2_SOFT_OPUS_DEC_H_