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 //#define LOG_NDEBUG 0
     18 #define LOG_TAG "TimedTextSource"
     19 #include <utils/Log.h>
     20 
     21 #include <media/stagefright/foundation/ADebug.h>  // CHECK_XX macro
     22 #include <media/stagefright/DataSource.h>
     23 #include <media/stagefright/MediaDefs.h>  // for MEDIA_MIMETYPE_xxx
     24 #include <media/stagefright/MediaSource.h>
     25 #include <media/stagefright/MetaData.h>
     26 
     27 #include "TimedTextSource.h"
     28 
     29 #include "TimedText3GPPSource.h"
     30 #include "TimedTextSRTSource.h"
     31 
     32 namespace android {
     33 
     34 // static
     35 sp<TimedTextSource> TimedTextSource::CreateTimedTextSource(
     36         const sp<MediaSource>& mediaSource) {
     37     const char *mime;
     38     CHECK(mediaSource->getFormat()->findCString(kKeyMIMEType, &mime));
     39     if (strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) == 0) {
     40         return new TimedText3GPPSource(mediaSource);
     41     }
     42     ALOGE("Unsupported mime type for subtitle. : %s", mime);
     43     return NULL;
     44 }
     45 
     46 // static
     47 sp<TimedTextSource> TimedTextSource::CreateTimedTextSource(
     48         const sp<DataSource>& dataSource, FileType filetype) {
     49     switch(filetype) {
     50         case OUT_OF_BAND_FILE_SRT:
     51             return new TimedTextSRTSource(dataSource);
     52         case OUT_OF_BAND_FILE_SMI:
     53             // TODO: Implement for SMI.
     54             ALOGE("Supporting SMI is not implemented yet");
     55             break;
     56         default:
     57             ALOGE("Undefined subtitle format. : %d", filetype);
     58     }
     59     return NULL;
     60 }
     61 
     62 sp<MetaData> TimedTextSource::getFormat() {
     63     return NULL;
     64 }
     65 
     66 }  // namespace android
     67