1 /* 2 * Copyright (C) 2015 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 package com.android.usbtuner; 18 19 import com.android.usbtuner.ChannelScanFileParser.ScanChannel; 20 import com.android.usbtuner.data.TunerChannel; 21 22 /** 23 * Interface definition for stream source. Source based on physical tuner or files should implement 24 * this interface. 25 */ 26 public interface InputStreamSource extends AutoCloseable { 27 /** 28 * @return a type of the source. Either {@code TYPE_TUNER} or {@code TYPE_FILE}. 29 */ getType()30 int getType(); 31 32 /** 33 * Get the source ready to provide stream for channel scanning process. 34 * 35 * @param channel {@link ScanChannel} to be scanned 36 * @return {@code true} if the source is ready, otherwise {@code false} 37 */ setScanChannel(ScanChannel channel)38 boolean setScanChannel(ScanChannel channel); 39 40 /** 41 * Tune to a channel to start viewing. 42 * 43 * @param channel {@link TunerChannel} to view 44 * @return {@code true} if tuning was successful, otherwise {@code false} 45 */ tuneToChannel(TunerChannel channel)46 boolean tuneToChannel(TunerChannel channel); 47 48 /** 49 * Start streaming the data. 50 */ startStream()51 void startStream(); 52 53 /** 54 * Stop streaming the data. 55 */ stopStream()56 void stopStream(); 57 58 /** 59 * Returns the limit of a input source in bytes. This return value means the number of bytes 60 * reading from a tuner device. 61 * 62 * @return the limit of a input source 63 */ getLimit()64 long getLimit(); 65 66 /** 67 * Returns the position of a input source in bytes. This return value means the number of bytes 68 * taken by a reader (for example, {@link MediaExtractor}). 69 * 70 * @return the position of a input source 71 */ getPosition()72 long getPosition(); 73 } 74