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 */
16package com.android.tv.tuner.exoplayer;
17
18import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
19import com.google.android.exoplayer2.extractor.Extractor;
20import com.google.android.exoplayer2.extractor.ExtractorsFactory;
21import com.google.android.exoplayer2.extractor.TimestampAdjuster;
22import com.google.android.exoplayer2.extractor.ts.DefaultTsPayloadReaderFactory;
23import com.google.android.exoplayer2.extractor.ts.TsExtractor;
24
25import java.util.ArrayList;
26import java.util.List;
27
28/**
29 * Extractor factory, mainly aim at create TsExtractor with FLAG_ALLOW_NON_IDR_KEYFRAMES flags for
30 * H.264 stream
31 */
32public final class ExoPlayerExtractorsFactory implements ExtractorsFactory {
33    @Override
34    public Extractor[] createExtractors() {
35        // Only create TsExtractor since we only target MPEG2TS stream.
36        Extractor[] extractors = {
37                new TsExtractor(new TimestampAdjuster(0), new DefaultTsPayloadReaderFactory(
38                        DefaultTsPayloadReaderFactory.FLAG_ALLOW_NON_IDR_KEYFRAMES), false) };
39        return extractors;
40    }
41}
42