blob: 5e06f4eb7f380eb69d3fc13b6a18950fd4ab606a [file] [log] [blame]
Chong Zhang7137ec72014-11-12 16:41:05 -08001/*
2 * Copyright 2014 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 NUPLAYER_CCDECODER_H_
18
19#define NUPLAYER_CCDECODER_H_
20
21#include "NuPlayer.h"
22
23namespace android {
24
25struct NuPlayer::CCDecoder : public RefBase {
26 enum {
27 kWhatClosedCaptionData,
28 kWhatTrackAdded,
29 };
30
31 CCDecoder(const sp<AMessage> &notify);
32
33 size_t getTrackCount() const;
34 sp<AMessage> getTrackInfo(size_t index) const;
35 status_t selectTrack(size_t index, bool select);
36 bool isSelected() const;
37 void decode(const sp<ABuffer> &accessUnit);
38 void display(int64_t timeUs);
39 void flush();
40
41private:
42 sp<AMessage> mNotify;
43 KeyedVector<int64_t, sp<ABuffer> > mCCMap;
44 size_t mCurrentChannel;
45 int32_t mSelectedTrack;
46 int32_t mTrackIndices[4];
47 Vector<size_t> mFoundChannels;
48
49 bool isTrackValid(size_t index) const;
50 int32_t getTrackIndex(size_t channel) const;
51 bool extractFromSEI(const sp<ABuffer> &accessUnit);
52 sp<ABuffer> filterCCBuf(const sp<ABuffer> &ccBuf, size_t index);
53
54 DISALLOW_EVIL_CONSTRUCTORS(CCDecoder);
55};
56
57} // namespace android
58
59#endif // NUPLAYER_CCDECODER_H_