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