1515 */
1616
1717// #define LOG_NDEBUG 0
18- #define LOG_TAG " TimedTextInBandSource "
18+ #define LOG_TAG " TimedText3GPPSource "
1919#include < utils/Log.h>
2020
2121#include < binder/Parcel.h>
2626#include < media/stagefright/MediaSource.h>
2727#include < media/stagefright/MetaData.h>
2828
29- #include " TimedTextInBandSource .h"
29+ #include " TimedText3GPPSource .h"
3030#include " TextDescriptions.h"
3131
3232namespace android {
3333
34- TimedTextInBandSource::TimedTextInBandSource (const sp<MediaSource>& mediaSource)
34+ TimedText3GPPSource::TimedText3GPPSource (const sp<MediaSource>& mediaSource)
3535 : mSource (mediaSource) {
3636}
3737
38- TimedTextInBandSource ::~TimedTextInBandSource () {
38+ TimedText3GPPSource ::~TimedText3GPPSource () {
3939}
4040
41- status_t TimedTextInBandSource ::read (
41+ status_t TimedText3GPPSource ::read (
4242 int64_t *timeUs, Parcel *parcel, const MediaSource::ReadOptions *options) {
4343 MediaBuffer *textBuffer = NULL ;
4444 status_t err = mSource ->read (&textBuffer, options);
@@ -60,59 +60,54 @@ status_t TimedTextInBandSource::read(
6060// text style for the string of text. These descriptions are present only
6161// if they are needed. This method is used to extract the modifier
6262// description and append it at the end of the text.
63- status_t TimedTextInBandSource ::extractAndAppendLocalDescriptions (
63+ status_t TimedText3GPPSource ::extractAndAppendLocalDescriptions (
6464 int64_t timeUs, const MediaBuffer *textBuffer, Parcel *parcel) {
6565 const void *data;
6666 size_t size = 0 ;
6767 int32_t flag = TextDescriptions::LOCAL_DESCRIPTIONS;
6868
6969 const char *mime;
7070 CHECK (mSource ->getFormat ()->findCString (kKeyMIMEType , &mime));
71+ CHECK (strcasecmp (mime, MEDIA_MIMETYPE_TEXT_3GPP) == 0 );
7172
72- if (strcasecmp (mime, MEDIA_MIMETYPE_TEXT_3GPP) == 0 ) {
73- data = textBuffer->data ();
74- size = textBuffer->size ();
75-
76- if (size > 0 ) {
77- parcel->freeData ();
78- flag |= TextDescriptions::IN_BAND_TEXT_3GPP;
79- return TextDescriptions::getParcelOfDescriptions (
80- (const uint8_t *)data, size, flag, timeUs / 1000 , parcel);
81- }
82- return OK;
73+ data = textBuffer->data ();
74+ size = textBuffer->size ();
75+
76+ if (size > 0 ) {
77+ parcel->freeData ();
78+ flag |= TextDescriptions::IN_BAND_TEXT_3GPP;
79+ return TextDescriptions::getParcelOfDescriptions (
80+ (const uint8_t *)data, size, flag, timeUs / 1000 , parcel);
8381 }
84- return ERROR_UNSUPPORTED ;
82+ return OK ;
8583}
8684
8785// To extract and send the global text descriptions for all the text samples
8886// in the text track or text file.
8987// TODO: send error message to application via notifyListener()...?
90- status_t TimedTextInBandSource ::extractGlobalDescriptions (Parcel *parcel) {
88+ status_t TimedText3GPPSource ::extractGlobalDescriptions (Parcel *parcel) {
9189 const void *data;
9290 size_t size = 0 ;
9391 int32_t flag = TextDescriptions::GLOBAL_DESCRIPTIONS;
9492
9593 const char *mime;
9694 CHECK (mSource ->getFormat ()->findCString (kKeyMIMEType , &mime));
95+ CHECK (strcasecmp (mime, MEDIA_MIMETYPE_TEXT_3GPP) == 0 );
96+
97+ uint32_t type;
98+ // get the 'tx3g' box content. This box contains the text descriptions
99+ // used to render the text track
100+ if (!mSource ->getFormat ()->findData (
101+ kKeyTextFormatData , &type, &data, &size)) {
102+ return ERROR_MALFORMED;
103+ }
97104
98- // support 3GPP only for now
99- if (strcasecmp (mime, MEDIA_MIMETYPE_TEXT_3GPP) == 0 ) {
100- uint32_t type;
101- // get the 'tx3g' box content. This box contains the text descriptions
102- // used to render the text track
103- if (!mSource ->getFormat ()->findData (
104- kKeyTextFormatData , &type, &data, &size)) {
105- return ERROR_MALFORMED;
106- }
107-
108- if (size > 0 ) {
109- flag |= TextDescriptions::IN_BAND_TEXT_3GPP;
110- return TextDescriptions::getParcelOfDescriptions (
111- (const uint8_t *)data, size, flag, 0 , parcel);
112- }
113- return OK;
105+ if (size > 0 ) {
106+ flag |= TextDescriptions::IN_BAND_TEXT_3GPP;
107+ return TextDescriptions::getParcelOfDescriptions (
108+ (const uint8_t *)data, size, flag, 0 , parcel);
114109 }
115- return ERROR_UNSUPPORTED ;
110+ return OK ;
116111}
117112
118113} // namespace android
0 commit comments