status_t TimedTextSRTSource::read( int64_t *startTimeUs, int64_t *endTimeUs, Parcel *parcel, const MediaSource::ReadOptions *options) { #ifdef MTK_SUBTITLE_SUPPORT MagicString text("", mFileEncodeType); status_t err = getText(options, &text, startTimeUs, endTimeUs); if (err != OK) { return err; } // CHECK_GE(*startTimeUs, 0); extractAndAppendLocalDescriptions(*startTimeUs, text, parcel); return OK; #else AString text; status_t err = getText(options, &text, startTimeUs, endTimeUs); if (err != OK) { return err; } CHECK_GE(*startTimeUs, 0); extractAndAppendLocalDescriptions(*startTimeUs, text, parcel); return OK; #endif }
status_t TimedTextVOBSUBSource::read( int64_t *startTimeUs, int64_t *endTimeUs, Parcel *parcel, const MediaSource::ReadOptions *options) { MediaBuffer *textBuffer = NULL; uint32_t type; const int *paletteData; size_t paletteDataSize = 0; status_t err = mSource->read(&textBuffer, options); if (err != OK) { ALOGE("mSource->read() failed, error code %d\n", err); return err; } CHECK(textBuffer != NULL); textBuffer->meta_data()->findInt64(kKeyTime, startTimeUs); char * content = (char *)textBuffer->data(); size_t size = textBuffer->size(); CHECK_GE(*startTimeUs, 0); mSubParser->stInit(content, size); do { err = mSubParser->stParseControlPacket(); if (err != OK) break; if (mSubParser->m_iDataPacketSize <= 4) break; if (err != OK) break; err = mSubParser->stParseDataPacket(NULL, 0); if (err != OK) break; //*startTimeUs = (int64_t)(mSubParser->m_iBeginTime); ALOGE("Call extractAndAppendLocalDescriptions, send data to \n"); extractAndAppendLocalDescriptions(*startTimeUs, textBuffer, parcel); } while (false); textBuffer->release(); *endTimeUs = -1; mSubParser->incTmpFileIdx(); ALOGE("read() finished\n"); return OK; }
status_t TimedTextSRTSource::read( int64_t *startTimeUs, int64_t *endTimeUs, Parcel *parcel, const MediaSource::ReadOptions *options) { AString text; status_t err = getText(options, &text, startTimeUs, endTimeUs); if (err != OK) { return err; } CHECK_GE(*startTimeUs, 0); extractAndAppendLocalDescriptions(*startTimeUs, text, parcel); return OK; }
status_t TimedTextVOBSUBSource::parse( uint8_t* text, size_t size, int64_t startTimeUs, int64_t endTimeUs, Parcel *parcel) { MediaBuffer *textBuffer = new MediaBuffer(text,size); uint32_t type; status_t err; const int *paletteData; size_t paletteDataSize = 0; CHECK(textBuffer != NULL); mSubParser->stInit(text, size); do { err = mSubParser->stParseControlPacket(); if (err != OK) break; if (mSubParser->m_iDataPacketSize <= 4) break; if (err != OK) break; err = mSubParser->stParseDataPacket(NULL, 0); if (err != OK) break; //*startTimeUs = (int64_t)(mSubParser->m_iBeginTime); ALOGE("Call extractAndAppendLocalDescriptions, send data to \n"); extractAndAppendLocalDescriptions(startTimeUs, textBuffer, parcel); } while (false); textBuffer->release(); mSubParser->incTmpFileIdx(); ALOGE("read() finished\n"); return OK; }
status_t TimedTextSSASource::parse( uint8_t* text, size_t size, int64_t startTimeUs, int64_t endTimeUs, Parcel *parcel) { ALOGE("[--dbg--] ass parse satart"); MediaBuffer *textBuffer = new MediaBuffer(text,size); CHECK(textBuffer != NULL); ALOGE("[--dbg--] ass parse sTime=%lld, eTime=%lld", startTimeUs, endTimeUs); extractAndAppendLocalDescriptions(startTimeUs, textBuffer, parcel); textBuffer->release(); return OK; }
status_t TimedTextASSSource::in_read( int64_t *startTimeUs, int64_t *endTimeUs, Parcel *parcel, const MediaSource::ReadOptions *options) { MediaBuffer *textBuffer = NULL; status_t err = mInSource->read(&textBuffer, options); if (err != OK) { return err; } CHECK(textBuffer != NULL); textBuffer->meta_data()->findInt64(kKeyTime, startTimeUs); textBuffer->meta_data()->findInt64(kKeyDriftTime, endTimeUs); //CHECK_GE(*startTimeUs, 0); ALOGE("[--dbg--] ass internal subtitle in_read sTime=%lld, eTime=%lld", *startTimeUs, *endTimeUs); extractAndAppendLocalDescriptions(*startTimeUs, textBuffer, parcel); textBuffer->release(); return OK; }
status_t TimedText3GPPSource::read( int64_t *startTimeUs, int64_t *endTimeUs, Parcel *parcel, const MediaSource::ReadOptions *options) { MediaBuffer *textBuffer = NULL; status_t err = mSource->read(&textBuffer, options); if (err != OK) { return err; } CHECK(textBuffer != NULL); textBuffer->meta_data()->findInt64(kKeyTime, startTimeUs); CHECK_GE(*startTimeUs, 0); #ifndef ANDROID_DEFAULT_CODE if (options != NULL) { ALOGI("seek done, startTimeUs:%lld", *startTimeUs); } #endif extractAndAppendLocalDescriptions(*startTimeUs, textBuffer, parcel); textBuffer->release(); // endTimeUs is a dummy parameter for 3gpp timed text format. // Set a negative value to it to mark it is unavailable. *endTimeUs = -1; return OK; }
/** * *bugfix for BUG00161497.android original does not support unicode encoded subtitle ,so we need values convert before display subtitle * ************************************ * *ActionsCode(author:sunchengzhi, change_code) */ status_t TimedTextSRTSource::read( int64_t *startTimeUs, int64_t *endTimeUs, Parcel *parcel, const MediaSource::ReadOptions *options) { AString text; status_t err = getText(options, &text, startTimeUs, endTimeUs); if (err != OK) { return err; } //ActionsCode(author:sunchengzhi, bugfix BUG00161497) int encoding; char mLocaleEncoding[MAX_SUB_LINE_LEN]; char textbuf[MAX_SUB_LINE_LEN]; encoding= subEncodingDetect(text.c_str()); encodingEnumToString(encoding,mLocaleEncoding); if (convertValues(text.c_str(),mLocaleEncoding,textbuf) < 0) { return ERROR_MALFORMED; } text = textbuf; CHECK_GE(*startTimeUs, 0); extractAndAppendLocalDescriptions(*startTimeUs, text, parcel); return OK; }
status_t TimedTextMatroskaSource::read( int64_t *startTimeUs, int64_t *endTimeUs, Parcel *parcel, const MediaSource::ReadOptions *options) { MediaBuffer *textBuffer = NULL; status_t err = mSource->read(&textBuffer, options); if (err != OK) { return err; } if (textBuffer == NULL) { /* let TextPlayer do read after post some time. */ return WOULD_BLOCK; } if (textBuffer->range_length() ==0) { /* let TextPlayer do read after post some time. */ textBuffer->release(); return WOULD_BLOCK; } int64_t curSysTimeUs = GetSysTimeUs(); if ((mPreGetFrmTimeUs >0) && abs(curSysTimeUs - mPreGetFrmTimeUs) <SEND_MKV_TIMED_TEXT_MIN_DELTA_US) { /* skip this frame */ textBuffer->release(); return WOULD_BLOCK; } if (mPreGetFrmTimeUs == -1) { mPreGetFrmTimeUs = curSysTimeUs; } int32_t durMs = 0; *startTimeUs = 0; *endTimeUs = 0; textBuffer->meta_data()->findInt64(kKeyTime, startTimeUs); textBuffer->meta_data()->findInt32(kKeySubtitleDuration, &durMs); *endTimeUs = *startTimeUs + durMs*1000; CHECK_GE(*startTimeUs, 0); if ((mTimedMkvSource.srcMimeType == MKV_TIMED_SRC_MIME_VOBSUB) && mObserver) { mObserver->notifyObserver(MKV_TIMED_MSG_VOBSUB_GET, textBuffer); } else { extractAndAppendLocalDescriptions(*startTimeUs, textBuffer, parcel); } ALOGV("read one mkv text frame, size: %d, timeUs: %lld, durMs: %d", textBuffer->range_length(), *startTimeUs, durMs); mPreGetFrmTimeUs = curSysTimeUs; textBuffer->release(); // endTimeUs is a dummy parameter for Matroska timed text format. // Set a negative value to it to mark it is unavailable. return OK; }