1 /* 2 * Copyright (C) 2016 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 org.mozilla.thirdparty.com.google.android.exoplayer2.extractor.ts; 17 18 import org.mozilla.thirdparty.com.google.android.exoplayer2.ParserException; 19 import org.mozilla.thirdparty.com.google.android.exoplayer2.extractor.ExtractorOutput; 20 import org.mozilla.thirdparty.com.google.android.exoplayer2.extractor.TrackOutput; 21 import org.mozilla.thirdparty.com.google.android.exoplayer2.util.ParsableByteArray; 22 23 /** 24 * Extracts individual samples from an elementary media stream, preserving original order. 25 */ 26 public interface ElementaryStreamReader { 27 28 /** 29 * Notifies the reader that a seek has occurred. 30 */ seek()31 void seek(); 32 33 /** 34 * Initializes the reader by providing outputs and ids for the tracks. 35 * 36 * @param extractorOutput The {@link ExtractorOutput} that receives the extracted data. 37 * @param idGenerator A {@link PesReader.TrackIdGenerator} that generates unique track ids for the 38 * {@link TrackOutput}s. 39 */ createTracks(ExtractorOutput extractorOutput, PesReader.TrackIdGenerator idGenerator)40 void createTracks(ExtractorOutput extractorOutput, PesReader.TrackIdGenerator idGenerator); 41 42 /** 43 * Called when a packet starts. 44 * 45 * @param pesTimeUs The timestamp associated with the packet. 46 * @param flags See {@link TsPayloadReader.Flags}. 47 */ packetStarted(long pesTimeUs, @TsPayloadReader.Flags int flags)48 void packetStarted(long pesTimeUs, @TsPayloadReader.Flags int flags); 49 50 /** 51 * Consumes (possibly partial) data from the current packet. 52 * 53 * @param data The data to consume. 54 * @throws ParserException If the data could not be parsed. 55 */ consume(ParsableByteArray data)56 void consume(ParsableByteArray data) throws ParserException; 57 58 /** 59 * Called when a packet ends. 60 */ packetFinished()61 void packetFinished(); 62 63 } 64