Home | History | Annotate | Download | only in timedtext
      1 /*
      2  * Copyright (C) 2012 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 #ifndef TIMED_TEXT_SOURCE_H_
     18 #define TIMED_TEXT_SOURCE_H_
     19 
     20 #include <media/stagefright/foundation/ABase.h>  // for DISALLOW_XXX macro.
     21 #include <media/stagefright/MediaErrors.h>
     22 #include <media/stagefright/MediaSource.h>  // for MediaSource::ReadOptions
     23 #include <utils/RefBase.h>
     24 
     25 namespace android {
     26 
     27 class DataSource;
     28 class MetaData;
     29 class Parcel;
     30 
     31 class TimedTextSource : public RefBase {
     32  public:
     33   enum FileType {
     34       OUT_OF_BAND_FILE_SRT = 1,
     35       OUT_OF_BAND_FILE_SMI = 2,
     36   };
     37   static sp<TimedTextSource> CreateTimedTextSource(
     38       const sp<MediaSource>& source);
     39   static sp<TimedTextSource> CreateTimedTextSource(
     40       const sp<DataSource>& source, FileType filetype);
     41   TimedTextSource() {}
     42   virtual status_t start() = 0;
     43   virtual status_t stop() = 0;
     44   // Returns subtitle parcel and its start time.
     45   virtual status_t read(
     46           int64_t *startTimeUs,
     47           int64_t *endTimeUs,
     48           Parcel *parcel,
     49           const MediaSource::ReadOptions *options = NULL) = 0;
     50   virtual status_t extractGlobalDescriptions(Parcel *parcel) {
     51       return INVALID_OPERATION;
     52   }
     53   virtual sp<MetaData> getFormat();
     54 
     55  protected:
     56   virtual ~TimedTextSource() { }
     57 
     58  private:
     59   DISALLOW_EVIL_CONSTRUCTORS(TimedTextSource);
     60 };
     61 
     62 }  // namespace android
     63 
     64 #endif  // TIMED_TEXT_SOURCE_H_
     65