Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit edb948b8 authored by James Dong's avatar James Dong Committed by Android (Google) Code Review
Browse files

Merge "Changed TimedTextInBandSource to TimedText3GPPSource."

parents 5d5b3783 0de4783a
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES:=                 \
        TextDescriptions.cpp      \
        TimedTextDriver.cpp       \
        TimedTextInBandSource.cpp \
        TimedText3GPPSource.cpp \
        TimedTextSource.cpp       \
        TimedTextSRTSource.cpp    \
        TimedTextPlayer.cpp
@@ -12,8 +12,7 @@ LOCAL_SRC_FILES:= \
LOCAL_CFLAGS += -Wno-multichar
LOCAL_C_INCLUDES:= \
        $(JNI_H_INCLUDE) \
        $(TOP)/frameworks/base/media/libstagefright \
        $(TOP)/frameworks/base/include/media/stagefright/openmax
        $(TOP)/frameworks/base/media/libstagefright

LOCAL_MODULE:= libstagefright_timedtext

+31 −36
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 */

//#define LOG_NDEBUG 0
#define LOG_TAG "TimedTextInBandSource"
#define LOG_TAG "TimedText3GPPSource"
#include <utils/Log.h>

#include <binder/Parcel.h>
@@ -26,19 +26,19 @@
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MetaData.h>

#include "TimedTextInBandSource.h"
#include "TimedText3GPPSource.h"
#include "TextDescriptions.h"

namespace android {

TimedTextInBandSource::TimedTextInBandSource(const sp<MediaSource>& mediaSource)
TimedText3GPPSource::TimedText3GPPSource(const sp<MediaSource>& mediaSource)
    : mSource(mediaSource) {
}

TimedTextInBandSource::~TimedTextInBandSource() {
TimedText3GPPSource::~TimedText3GPPSource() {
}

status_t TimedTextInBandSource::read(
status_t TimedText3GPPSource::read(
        int64_t *timeUs, Parcel *parcel, const MediaSource::ReadOptions *options) {
    MediaBuffer *textBuffer = NULL;
    status_t err = mSource->read(&textBuffer, options);
@@ -60,7 +60,7 @@ status_t TimedTextInBandSource::read(
// text style for the string of text. These descriptions are present only
// if they are needed. This method is used to extract the modifier
// description and append it at the end of the text.
status_t TimedTextInBandSource::extractAndAppendLocalDescriptions(
status_t TimedText3GPPSource::extractAndAppendLocalDescriptions(
        int64_t timeUs, const MediaBuffer *textBuffer, Parcel *parcel) {
    const void *data;
    size_t size = 0;
@@ -68,8 +68,8 @@ status_t TimedTextInBandSource::extractAndAppendLocalDescriptions(

    const char *mime;
    CHECK(mSource->getFormat()->findCString(kKeyMIMEType, &mime));
    CHECK(strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) == 0);

    if (strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) == 0) {
    data = textBuffer->data();
    size = textBuffer->size();

@@ -81,22 +81,19 @@ status_t TimedTextInBandSource::extractAndAppendLocalDescriptions(
    }
    return OK;
}
    return ERROR_UNSUPPORTED;
}

// To extract and send the global text descriptions for all the text samples
// in the text track or text file.
// TODO: send error message to application via notifyListener()...?
status_t TimedTextInBandSource::extractGlobalDescriptions(Parcel *parcel) {
status_t TimedText3GPPSource::extractGlobalDescriptions(Parcel *parcel) {
    const void *data;
    size_t size = 0;
    int32_t flag = TextDescriptions::GLOBAL_DESCRIPTIONS;

    const char *mime;
    CHECK(mSource->getFormat()->findCString(kKeyMIMEType, &mime));
    CHECK(strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) == 0);

    // support 3GPP only for now
    if (strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) == 0) {
    uint32_t type;
    // get the 'tx3g' box content. This box contains the text descriptions
    // used to render the text track
@@ -112,7 +109,5 @@ status_t TimedTextInBandSource::extractGlobalDescriptions(Parcel *parcel) {
    }
    return OK;
}
    return ERROR_UNSUPPORTED;
}

}  // namespace android
+7 −7
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@
 * limitations under the License.
 */

#ifndef TIMED_TEXT_IN_BAND_SOURCE_H_
#define TIMED_TEXT_IN_BAND_SOURCE_H_
#ifndef TIMED_TEXT_3GPP_SOURCE_H_
#define TIMED_TEXT_3GPP_SOURCE_H_

#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MediaSource.h>
@@ -27,9 +27,9 @@ namespace android {
class MediaBuffer;
class Parcel;

class TimedTextInBandSource : public TimedTextSource {
class TimedText3GPPSource : public TimedTextSource {
 public:
  TimedTextInBandSource(const sp<MediaSource>& mediaSource);
  TimedText3GPPSource(const sp<MediaSource>& mediaSource);
  virtual status_t start() { return mSource->start(); }
  virtual status_t stop() { return mSource->stop(); }
  virtual status_t read(
@@ -39,7 +39,7 @@ class TimedTextInBandSource : public TimedTextSource {
  virtual status_t extractGlobalDescriptions(Parcel *parcel);

 protected:
  virtual ~TimedTextInBandSource();
  virtual ~TimedText3GPPSource();

 private:
  sp<MediaSource> mSource;
@@ -47,9 +47,9 @@ class TimedTextInBandSource : public TimedTextSource {
  status_t extractAndAppendLocalDescriptions(
        int64_t timeUs, const MediaBuffer *textBuffer, Parcel *parcel);

  DISALLOW_EVIL_CONSTRUCTORS(TimedTextInBandSource);
  DISALLOW_EVIL_CONSTRUCTORS(TimedText3GPPSource);
};

}  // namespace android

#endif  // TIMED_TEXT_IN_BAND_SOURCE_H_
#endif  // TIMED_TEXT_3GPP_SOURCE_H_
+11 −2
Original line number Diff line number Diff line
@@ -18,12 +18,15 @@
#define LOG_TAG "TimedTextSource"
#include <utils/Log.h>

#include <media/stagefright/foundation/ADebug.h>  // CHECK_XX macro
#include <media/stagefright/DataSource.h>
#include <media/stagefright/MediaDefs.h>  // for MEDIA_MIMETYPE_xxx
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MetaData.h>

#include "TimedTextSource.h"

#include "TimedTextInBandSource.h"
#include "TimedText3GPPSource.h"
#include "TimedTextSRTSource.h"

namespace android {
@@ -31,7 +34,13 @@ namespace android {
// static
sp<TimedTextSource> TimedTextSource::CreateTimedTextSource(
        const sp<MediaSource>& mediaSource) {
    return new TimedTextInBandSource(mediaSource);
    const char *mime;
    CHECK(mediaSource->getFormat()->findCString(kKeyMIMEType, &mime));
    if (strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) == 0) {
        return new TimedText3GPPSource(mediaSource);
    }
    ALOGE("Unsupported mime type for subtitle. : %s", mime);
    return NULL;
}

// static