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.mkv; 17 18 import org.mozilla.thirdparty.com.google.android.exoplayer2.ParserException; 19 import org.mozilla.thirdparty.com.google.android.exoplayer2.extractor.ExtractorInput; 20 import java.io.IOException; 21 22 /** 23 * Event-driven EBML reader that delivers events to an {@link EbmlReaderOutput}. 24 * <p> 25 * EBML can be summarized as a binary XML format somewhat similar to Protocol Buffers. It was 26 * originally designed for the Matroska container format. More information about EBML and 27 * Matroska is available <a href="http://www.matroska.org/technical/specs/index.html">here</a>. 28 */ 29 /* package */ interface EbmlReader { 30 31 /** 32 * Type for unknown elements. 33 */ 34 int TYPE_UNKNOWN = 0; 35 /** 36 * Type for elements that contain child elements. 37 */ 38 int TYPE_MASTER = 1; 39 /** 40 * Type for integer value elements of up to 8 bytes. 41 */ 42 int TYPE_UNSIGNED_INT = 2; 43 /** 44 * Type for string elements. 45 */ 46 int TYPE_STRING = 3; 47 /** 48 * Type for binary elements. 49 */ 50 int TYPE_BINARY = 4; 51 /** 52 * Type for IEEE floating point value elements of either 4 or 8 bytes. 53 */ 54 int TYPE_FLOAT = 5; 55 56 /** 57 * Initializes the extractor with an {@link EbmlReaderOutput}. 58 * 59 * @param output An {@link EbmlReaderOutput} to receive events. 60 */ init(EbmlReaderOutput output)61 void init(EbmlReaderOutput output); 62 63 /** 64 * Resets the state of the reader. 65 * <p> 66 * Subsequent calls to {@link #read(ExtractorInput)} will start reading a new EBML structure 67 * from scratch. 68 */ reset()69 void reset(); 70 71 /** 72 * Reads from an {@link ExtractorInput}, invoking an event callback if possible. 73 * 74 * @param input The {@link ExtractorInput} from which data should be read. 75 * @return True if data can continue to be read. False if the end of the input was encountered. 76 * @throws ParserException If parsing fails. 77 * @throws IOException If an error occurs reading from the input. 78 * @throws InterruptedException If the thread is interrupted. 79 */ read(ExtractorInput input)80 boolean read(ExtractorInput input) throws IOException, InterruptedException; 81 82 } 83