本文整理汇总了C++中mediasource::ReadOptions::clearSeekTo方法的典型用法代码示例。如果您正苦于以下问题:C++ ReadOptions::clearSeekTo方法的具体用法?C++ ReadOptions::clearSeekTo怎么用?C++ ReadOptions::clearSeekTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mediasource::ReadOptions
的用法示例。
在下文中一共展示了ReadOptions::clearSeekTo方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: performSeekTest
static void performSeekTest(const sp<MediaSource> &source) {
CHECK_EQ((status_t)OK, source->start());
int64_t durationUs;
CHECK(source->getFormat()->findInt64(kKeyDuration, &durationUs));
for (int64_t seekTimeUs = 0; seekTimeUs <= durationUs;
seekTimeUs += 60000ll) {
MediaSource::ReadOptions options;
options.setSeekTo(
seekTimeUs, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
MediaBuffer *buffer;
status_t err;
for (;;) {
err = source->read(&buffer, &options);
options.clearSeekTo();
if (err == INFO_FORMAT_CHANGED) {
CHECK(buffer == NULL);
continue;
}
if (err != OK) {
CHECK(buffer == NULL);
break;
}
if (buffer->range_length() > 0) {
break;
}
CHECK(buffer != NULL);
buffer->release();
buffer = NULL;
}
if (err == OK) {
int64_t timeUs;
CHECK(buffer->meta_data()->findInt64(kKeyTime, &timeUs));
printf("%lld\t%lld\t%lld\n", seekTimeUs, timeUs, seekTimeUs - timeUs);
buffer->release();
buffer = NULL;
} else {
printf("ERROR\n");
break;
}
}
CHECK_EQ((status_t)OK, source->stop());
}
示例2: converter
static VideoFrame *extractVideoFrameWithCodecFlags(
OMXClient *client,
const sp<MetaData> &trackMeta,
const sp<MediaSource> &source,
uint32_t flags,
int64_t frameTimeUs,
int seekMode) {
sp<MetaData> format = source->getFormat();
#ifndef MTK_HARDWARE
// XXX:
// Once all vendors support OMX_COLOR_FormatYUV420Planar, we can
// remove this check and always set the decoder output color format
// skip this check for software decoders
#ifndef QCOM_HARDWARE
if (isYUV420PlanarSupported(client, trackMeta)) {
format->setInt32(kKeyColorFormat, OMX_COLOR_FormatYUV420Planar);
#else
if (!(flags & OMXCodec::kSoftwareCodecsOnly)) {
if (isYUV420PlanarSupported(client, trackMeta)) {
format->setInt32(kKeyColorFormat, OMX_COLOR_FormatYUV420Planar);
}
#endif
}
#endif
sp<MediaSource> decoder =
OMXCodec::Create(
client->interface(), format, false, source,
NULL, flags | OMXCodec::kClientNeedsFramebuffer);
if (decoder.get() == NULL) {
ALOGV("unable to instantiate video decoder.");
return NULL;
}
status_t err = decoder->start();
if (err != OK) {
ALOGW("OMXCodec::start returned error %d (0x%08x)\n", err, err);
return NULL;
}
// Read one output buffer, ignore format change notifications
// and spurious empty buffers.
MediaSource::ReadOptions options;
if (seekMode < MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC ||
seekMode > MediaSource::ReadOptions::SEEK_CLOSEST) {
ALOGE("Unknown seek mode: %d", seekMode);
return NULL;
}
MediaSource::ReadOptions::SeekMode mode =
static_cast<MediaSource::ReadOptions::SeekMode>(seekMode);
int64_t thumbNailTime;
if (frameTimeUs < 0) {
if (!trackMeta->findInt64(kKeyThumbnailTime, &thumbNailTime)
|| thumbNailTime < 0) {
thumbNailTime = 0;
}
options.setSeekTo(thumbNailTime, mode);
} else {
thumbNailTime = -1;
options.setSeekTo(frameTimeUs, mode);
}
MediaBuffer *buffer = NULL;
do {
if (buffer != NULL) {
buffer->release();
buffer = NULL;
}
err = decoder->read(&buffer, &options);
options.clearSeekTo();
} while (err == INFO_FORMAT_CHANGED
|| (buffer != NULL && buffer->range_length() == 0));
if (err != OK) {
CHECK(buffer == NULL);
ALOGV("decoding frame failed.");
decoder->stop();
return NULL;
}
ALOGV("successfully decoded video frame.");
int32_t unreadable;
if (buffer->meta_data()->findInt32(kKeyIsUnreadable, &unreadable)
&& unreadable != 0) {
ALOGV("video frame is unreadable, decoder does not give us access "
"to the video data.");
buffer->release();
buffer = NULL;
//.........这里部分代码省略.........
示例3: videoEntry
/*!
* \brief The decode thread function.
* The main Loop is used to read data from decoder, and put them to render.
*/
void UMMediaPlayer::videoEntry(void)
{
bool eof = false;
MediaBuffer *lastBuffer = NULL;
MediaBuffer *buffer;
MediaSource::ReadOptions options;
mVideoStartTime = 0;
dcount =0;
UMLOG_ERR("videoEntry() ---- mVideoDecoder->start() begin");
status_t err = mVideoDecoder->start();
if(err != OK)
{
UMLOG_ERR("videoEntry() ---- mVideoDecoder->start() end failed err=%d", err);
mHasDspError = 1;
mPlaying = false;
if(mVideoSource->HasAnyDataSource())
{
mVideoSource->read(&buffer, &options);
releaseBufferIfNonNULL(&buffer);
}
}
while(mPlaying && !mVideoSource->HasAnyDataSource())
{
usleep(50 * 1000);
}
while(mPlaying)
{
status_t err = mVideoDecoder->read(&buffer, &options);
options.clearSeekTo();
if(err == INFO_FORMAT_CHANGED)
{
UMLOG_ERR("VideoSource signalled format change.");
if(mVideoRenderer != NULL)
{
initRenderer();
}
continue;
}
if(err != OK && buffer == NULL)
{
mHasDspError = 1;
mPlaying = false;
continue;
}
dcount++;
printPDecodeDateToFile((char*)buffer->data());
if(dcount == 10){
if(fd != NULL){
fclose(fd);
}
}
if(buffer == NULL)
{
usleep(3000);
eof = true;
continue;
}
CHECK((err == OK && buffer != NULL) || (err != OK && buffer == NULL));
if(err != OK)
{
eof = true;
mPlaying = false;
continue;
}
if(buffer->range_length() == 0)
{
buffer->release();
buffer = NULL;
continue;
}
int64_t timeUs;
CHECK(buffer->meta_data()->findInt64(kKeyTime, &timeUs));
if(0 == timeUs)
{
unsigned int currTS = mVideoSource->um_util_getCurrentTick();
if(currTS <= lastRenderTS + UM_RENDER_MAX_INTERVAL)
{
//There is a frame has been pushed into render in last UM_RENDER_MAX_INTERVAL ms
//skip the compensate frame then
buffer->release();
buffer = NULL;
continue;
//.........这里部分代码省略.........
示例4: converter
static VideoFrame *extractVideoFrameWithCodecFlags(
OMXClient *client,
const sp<MetaData> &trackMeta,
const sp<MediaSource> &source,
uint32_t flags,
int64_t frameTimeUs,
int seekMode) {
sp<MetaData> format = source->getFormat();
// XXX:
// Once all vendors support OMX_COLOR_FormatYUV420Planar, we can
// remove this check and always set the decoder output color format
if (isYUV420PlanarSupported(client, trackMeta)) {
format->setInt32(kKeyColorFormat, OMX_COLOR_FormatYUV420Planar);
}
sp<MediaSource> decoder =
OMXCodec::Create(
client->interface(), format, false, source,
NULL, flags | OMXCodec::kClientNeedsFramebuffer);
if (decoder.get() == NULL) {
ALOGV("unable to instantiate video decoder.");
return NULL;
}
status_t err = decoder->start();
if (err != OK) {
ALOGW("OMXCodec::start returned error %d (0x%08x)\n", err, err);
return NULL;
}
// Read one output buffer, ignore format change notifications
// and spurious empty buffers.
MediaSource::ReadOptions options;
if (seekMode < MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC ||
seekMode > MediaSource::ReadOptions::SEEK_CLOSEST) {
ALOGE("Unknown seek mode: %d", seekMode);
return NULL;
}
MediaSource::ReadOptions::SeekMode mode =
static_cast<MediaSource::ReadOptions::SeekMode>(seekMode);
int64_t thumbNailTime;
if (frameTimeUs < 0) {
if (!trackMeta->findInt64(kKeyThumbnailTime, &thumbNailTime)
|| thumbNailTime < 0) {
thumbNailTime = 0;
}
options.setSeekTo(thumbNailTime, mode);
} else {
thumbNailTime = -1;
options.setSeekTo(frameTimeUs, mode);
}
MediaBuffer *buffer = NULL;
do {
if (buffer != NULL) {
buffer->release();
buffer = NULL;
}
err = decoder->read(&buffer, &options);
options.clearSeekTo();
} while (err == INFO_FORMAT_CHANGED
|| (buffer != NULL && buffer->range_length() == 0));
if (err != OK) {
CHECK(buffer == NULL);
ALOGV("decoding frame failed.");
decoder->stop();
return NULL;
}
ALOGV("successfully decoded video frame.");
int32_t unreadable;
if (buffer->meta_data()->findInt32(kKeyIsUnreadable, &unreadable)
&& unreadable != 0) {
ALOGV("video frame is unreadable, decoder does not give us access "
"to the video data.");
buffer->release();
buffer = NULL;
decoder->stop();
return NULL;
}
int64_t timeUs;
CHECK(buffer->meta_data()->findInt64(kKeyTime, &timeUs));
if (thumbNailTime >= 0) {
if (timeUs != thumbNailTime) {
//.........这里部分代码省略.........
示例5: converter
static VideoFrame *extractVideoFrameWithCodecFlags(
OMXClient *client,
const sp<MetaData> &trackMeta,
const sp<MediaSource> &source, uint32_t flags) {
sp<MediaSource> decoder =
OMXCodec::Create(
client->interface(), source->getFormat(), false, source,
NULL, flags | OMXCodec::kClientNeedsFramebuffer);
if (decoder.get() == NULL) {
LOGV("unable to instantiate video decoder.");
return NULL;
}
status_t err = decoder->start();
if (err != OK) {
LOGW("OMXCodec::start returned error %d (0x%08x)\n", err, err);
return NULL;
}
// Read one output buffer, ignore format change notifications
// and spurious empty buffers.
MediaSource::ReadOptions options;
int64_t thumbNailTime;
if (trackMeta->findInt64(kKeyThumbnailTime, &thumbNailTime)) {
options.setSeekTo(thumbNailTime);
} else {
thumbNailTime = -1;
}
MediaBuffer *buffer = NULL;
do {
if (buffer != NULL) {
buffer->release();
buffer = NULL;
}
err = decoder->read(&buffer, &options);
options.clearSeekTo();
} while (err == INFO_FORMAT_CHANGED
|| (buffer != NULL && buffer->range_length() == 0));
if (err != OK) {
CHECK_EQ(buffer, NULL);
LOGV("decoding frame failed.");
decoder->stop();
return NULL;
}
LOGV("successfully decoded video frame.");
int32_t unreadable;
if (buffer->meta_data()->findInt32(kKeyIsUnreadable, &unreadable)
&& unreadable != 0) {
LOGV("video frame is unreadable, decoder does not give us access "
"to the video data.");
buffer->release();
buffer = NULL;
decoder->stop();
return NULL;
}
int64_t timeUs;
CHECK(buffer->meta_data()->findInt64(kKeyTime, &timeUs));
if (thumbNailTime >= 0) {
if (timeUs != thumbNailTime) {
const char *mime;
CHECK(trackMeta->findCString(kKeyMIMEType, &mime));
LOGV("thumbNailTime = %lld us, timeUs = %lld us, mime = %s",
thumbNailTime, timeUs, mime);
}
}
sp<MetaData> meta = decoder->getFormat();
int32_t width, height;
CHECK(meta->findInt32(kKeyWidth, &width));
CHECK(meta->findInt32(kKeyHeight, &height));
int32_t rotationAngle;
if (!trackMeta->findInt32(kKeyRotation, &rotationAngle)) {
rotationAngle = 0; // By default, no rotation
}
VideoFrame *frame = new VideoFrame;
frame->mWidth = width;
frame->mHeight = height;
frame->mDisplayWidth = width;
frame->mDisplayHeight = height;
frame->mSize = width * height * 2;
frame->mData = new uint8_t[frame->mSize];
frame->mRotationAngle = rotationAngle;
//.........这里部分代码省略.........
示例6: testSeek
//.........这里部分代码省略.........
LOGI("requesting seek beyond EOF");
} else {
requestedSeekTimeUs =
(int64_t)(uniform_rand() * durationUs);
LOGI("requesting seek to %lld us (%.2f secs)",
requestedSeekTimeUs, requestedSeekTimeUs / 1E6);
}
MediaBuffer *buffer = NULL;
options.setSeekTo(
requestedSeekTimeUs, MediaSource::ReadOptions::SEEK_NEXT_SYNC);
if (seekSource->read(&buffer, &options) != OK) {
CHECK_EQ(buffer, NULL);
actualSeekTimeUs = -1;
} else {
CHECK(buffer != NULL);
CHECK(buffer->meta_data()->findInt64(kKeyTime, &actualSeekTimeUs));
CHECK(actualSeekTimeUs >= 0);
buffer->release();
buffer = NULL;
}
LOGI("nearest keyframe is at %lld us (%.2f secs)",
actualSeekTimeUs, actualSeekTimeUs / 1E6);
}
status_t err;
MediaBuffer *buffer;
for (;;) {
err = codec->read(&buffer, &options);
options.clearSeekTo();
if (err == INFO_FORMAT_CHANGED) {
CHECK_EQ(buffer, NULL);
continue;
}
if (err == OK) {
CHECK(buffer != NULL);
if (buffer->range_length() == 0) {
buffer->release();
buffer = NULL;
continue;
}
} else {
CHECK_EQ(buffer, NULL);
}
break;
}
if (requestedSeekTimeUs < 0) {
// Linear read.
if (err != OK) {
CHECK_EQ(buffer, NULL);
} else {
CHECK(buffer != NULL);
buffer->release();
buffer = NULL;
}
} else if (actualSeekTimeUs < 0) {
EXPECT(err != OK,
"We attempted to seek beyond EOS and expected "
"ERROR_END_OF_STREAM to be returned, but instead "
"we got a valid buffer.");
示例7: converter
static VideoFrame *extractVideoFrameWithCodecFlags(
OMXClient *client,
const sp<MetaData> &trackMeta,
const sp<MediaSource> &source,
uint32_t flags,
int64_t frameTimeUs,
int seekMode) {
#ifdef OMAP_ENHANCEMENT
flags |= OMXCodec::kPreferThumbnailMode;
#ifdef TARGET_OMAP4
int32_t isInterlaced = false;
//Call config parser to update profile,level,interlaced,reference frame data
updateMetaData(trackMeta);
trackMeta->findInt32(kKeyVideoInterlaced, &isInterlaced);
if(isInterlaced)
{
flags |= OMXCodec::kPreferInterlacedOutputContent;
}
#endif
#endif
sp<MediaSource> decoder =
OMXCodec::Create(
client->interface(), source->getFormat(), false, source,
NULL, flags | OMXCodec::kClientNeedsFramebuffer);
if (decoder.get() == NULL) {
LOGV("unable to instantiate video decoder.");
return NULL;
}
status_t err = decoder->start();
if (err != OK) {
LOGW("OMXCodec::start returned error %d (0x%08x)\n", err, err);
return NULL;
}
// Read one output buffer, ignore format change notifications
// and spurious empty buffers.
MediaSource::ReadOptions options;
if (seekMode < MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC ||
seekMode > MediaSource::ReadOptions::SEEK_CLOSEST) {
LOGE("Unknown seek mode: %d", seekMode);
return NULL;
}
MediaSource::ReadOptions::SeekMode mode =
static_cast<MediaSource::ReadOptions::SeekMode>(seekMode);
int64_t thumbNailTime;
if (frameTimeUs < 0 && trackMeta->findInt64(kKeyThumbnailTime, &thumbNailTime)) {
options.setSeekTo(thumbNailTime, mode);
} else {
thumbNailTime = -1;
options.setSeekTo(frameTimeUs < 0 ? 0 : frameTimeUs, mode);
}
MediaBuffer *buffer = NULL;
do {
if (buffer != NULL) {
buffer->release();
buffer = NULL;
}
err = decoder->read(&buffer, &options);
#ifdef OMAP_ENHANCEMENT
if(err == INFO_FORMAT_CHANGED)
{
int32_t w1,h1;
decoder->getFormat()->findInt32(kKeyWidth, &w1);
decoder->getFormat()->findInt32(kKeyHeight, &h1);
LOGD("Got portreconfig event. New WxH %dx%d. wait 5mS for port to be enabled",w1,h1);
usleep(5000); //sleep 5mS for port disable-enable to complete
}
#endif
options.clearSeekTo();
} while (err == INFO_FORMAT_CHANGED
|| (buffer != NULL && buffer->range_length() == 0));
if (err != OK) {
CHECK_EQ(buffer, NULL);
LOGV("decoding frame failed.");
decoder->stop();
return NULL;
}
LOGV("successfully decoded video frame.");
int32_t unreadable;
if (buffer->meta_data()->findInt32(kKeyIsUnreadable, &unreadable)
&& unreadable != 0) {
//.........这里部分代码省略.........
示例8: playSource
static void playSource(OMXClient *client, sp<MediaSource> &source) {
sp<MetaData> meta = source->getFormat();
const char *mime;
CHECK(meta->findCString(kKeyMIMEType, &mime));
sp<MediaSource> rawSource;
if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_RAW, mime)) {
rawSource = source;
} else {
int flags = 0;
if (gPreferSoftwareCodec) {
flags |= OMXCodec::kPreferSoftwareCodecs;
}
if (gForceToUseHardwareCodec) {
CHECK(!gPreferSoftwareCodec);
flags |= OMXCodec::kHardwareCodecsOnly;
}
rawSource = OMXCodec::Create(
client->interface(), meta, false /* createEncoder */, source,
NULL /* matchComponentName */,
flags,
gSurface);
if (rawSource == NULL) {
fprintf(stderr, "Failed to instantiate decoder for '%s'.\n", mime);
return;
}
displayAVCProfileLevelIfPossible(meta);
}
source.clear();
status_t err = rawSource->start();
if (err != OK) {
fprintf(stderr, "rawSource returned error %d (0x%08x)\n", err, err);
return;
}
if (gPlaybackAudio) {
AudioPlayer *player = new AudioPlayer(NULL);
player->setSource(rawSource);
rawSource.clear();
player->start(true /* sourceAlreadyStarted */);
status_t finalStatus;
while (!player->reachedEOS(&finalStatus)) {
usleep(100000ll);
}
delete player;
player = NULL;
return;
} else if (gReproduceBug >= 3 && gReproduceBug <= 5) {
int64_t durationUs;
CHECK(meta->findInt64(kKeyDuration, &durationUs));
status_t err;
MediaBuffer *buffer;
MediaSource::ReadOptions options;
int64_t seekTimeUs = -1;
for (;;) {
err = rawSource->read(&buffer, &options);
options.clearSeekTo();
bool shouldSeek = false;
if (err == INFO_FORMAT_CHANGED) {
CHECK(buffer == NULL);
printf("format changed.\n");
continue;
} else if (err != OK) {
printf("reached EOF.\n");
shouldSeek = true;
} else {
int64_t timestampUs;
CHECK(buffer->meta_data()->findInt64(kKeyTime, ×tampUs));
bool failed = false;
if (seekTimeUs >= 0) {
int64_t diff = timestampUs - seekTimeUs;
if (diff < 0) {
diff = -diff;
}
if ((gReproduceBug == 4 && diff > 500000)
|| (gReproduceBug == 5 && timestampUs < 0)) {
printf("wanted: %.2f secs, got: %.2f secs\n",
seekTimeUs / 1E6, timestampUs / 1E6);
printf("ERROR: ");
failed = true;
}
}
//.........这里部分代码省略.........
示例9: ALOGV
/**
*******************************************************************************
* @brief Gets an access unit (AU) from the stream handler source.
* @note AU is the smallest possible amount of data to be decoded by decoder
*
* @param context: (IN) Context of the reader
* @param pStreamHandler (IN) The stream handler of the stream to make jump
* @param pAccessUnit (I/O)Pointer to an access unit to fill with read data
* @return M4NO_ERROR there is no error
* @return M4ERR_PARAMETER at least one parameter is not properly set
* @returns M4ERR_ALLOC memory allocation failed
* @returns M4WAR_NO_MORE_AU there are no more access unit in the stream
*******************************************************************************
*/
M4OSA_ERR VideoEditorMp3Reader_getNextAu(M4OSA_Context context,
M4_StreamHandler *pStreamHandler, M4_AccessUnit *pAccessUnit) {
VideoEditorMp3Reader_Context *pReaderContext =
(VideoEditorMp3Reader_Context*)context;
M4OSA_ERR err = M4NO_ERROR;
M4SYS_AccessUnit* pAu;
MediaBuffer *mAudioBuffer;
MediaSource::ReadOptions options;
ALOGV("VideoEditorMp3Reader_getNextAu start");
M4OSA_DEBUG_IF1((pReaderContext == 0), M4ERR_PARAMETER,
"VideoEditorMp3Reader_getNextAu: invalid context");
M4OSA_DEBUG_IF1((pStreamHandler == 0), M4ERR_PARAMETER,
"VideoEditorMp3Reader_getNextAu: invalid pointer to M4_StreamHandler");
M4OSA_DEBUG_IF1((pAccessUnit == 0), M4ERR_PARAMETER,
"VideoEditorMp3Reader_getNextAu: invalid pointer to M4_AccessUnit");
if (pStreamHandler == (M4_StreamHandler*)pReaderContext->\
mAudioStreamHandler) {
pAu = &pReaderContext->mAudioAu;
} else {
ALOGV("VideoEditorMp3Reader_getNextAu: StreamHandler is not known\n");
return M4ERR_PARAMETER;
}
if (pReaderContext->mSeeking) {
options.setSeekTo(pReaderContext->mSeekTime);
}
pReaderContext->mMediaSource->read(&mAudioBuffer, &options);
if (mAudioBuffer != NULL) {
if ((pAu->dataAddress == NULL) ||
(pAu->size < mAudioBuffer->range_length())) {
if (pAu->dataAddress != NULL) {
free((M4OSA_Int32*)pAu->dataAddress);
pAu->dataAddress = NULL;
}
pAu->dataAddress = (M4OSA_Int32*)M4OSA_32bitAlignedMalloc(
(mAudioBuffer->range_length() + 3) & ~0x3,
M4READER_MP3, (M4OSA_Char*)"pAccessUnit->m_dataAddress" );
if (pAu->dataAddress == NULL) {
ALOGV("VideoEditorMp3Reader_getNextAu malloc failed");
pReaderContext->mMediaSource->stop();
pReaderContext->mMediaSource.clear();
pReaderContext->mDataSource.clear();
return M4ERR_ALLOC;
}
}
pAu->size = mAudioBuffer->range_length();
memcpy((M4OSA_MemAddr8)pAu->dataAddress,
(const char *)mAudioBuffer->data() + mAudioBuffer->range_offset(),
mAudioBuffer->range_length());
mAudioBuffer->meta_data()->findInt64(kKeyTime, (int64_t*)&pAu->CTS);
pAu->CTS = pAu->CTS / 1000; /*converting the microsec to millisec */
pAu->DTS = pAu->CTS;
pAu->attribute = M4SYS_kFragAttrOk;
mAudioBuffer->release();
ALOGV("VideoEditorMp3Reader_getNextAu AU CTS = %ld",pAu->CTS);
pAccessUnit->m_dataAddress = (M4OSA_Int8*) pAu->dataAddress;
pAccessUnit->m_size = pAu->size;
pAccessUnit->m_CTS = pAu->CTS;
pAccessUnit->m_DTS = pAu->DTS;
pAccessUnit->m_attribute = pAu->attribute;
} else {
ALOGV("VideoEditorMp3Reader_getNextAu EOS reached.");
pAccessUnit->m_size=0;
err = M4WAR_NO_MORE_AU;
}
pAu->nbFrag = 0;
options.clearSeekTo();
pReaderContext->mSeeking = M4OSA_FALSE;
mAudioBuffer = NULL;
ALOGV("VideoEditorMp3Reader_getNextAu end");
return err;
}
示例10: Process
void Process()
{
Frame* frame;
int32_t w, h;
int decode_done = 0;
MediaSource::ReadOptions readopt;
// GLuint texid;
//SetPriority(THREAD_PRIORITY_ABOVE_NORMAL);
do
{
#if defined(DEBUG_VERBOSE)
unsigned int time = XbmcThreads::SystemClockMillis();
CLog::Log(LOGDEBUG, "%s: >>> Handling frame\n", CLASSNAME);
#endif
p->cur_frame = NULL;
frame = (Frame*)malloc(sizeof(Frame));
if (!frame)
{
decode_done = 1;
continue;
}
frame->eglimg = EGL_NO_IMAGE_KHR;
frame->medbuf = NULL;
if (p->resetting)
{
readopt.setSeekTo(0);
p->resetting = false;
}
frame->status = p->decoder->read(&frame->medbuf, &readopt);
readopt.clearSeekTo();
if (frame->status == OK)
{
if (!frame->medbuf->graphicBuffer().get()) // hw buffers
{
if (frame->medbuf->range_length() == 0)
{
CLog::Log(LOGERROR, "%s - Invalid buffer\n", CLASSNAME);
frame->status = VC_ERROR;
decode_done = 1;
frame->medbuf->release();
frame->medbuf = NULL;
}
else
frame->format = RENDER_FMT_YUV420P;
}
else
frame->format = RENDER_FMT_EGLIMG;
}
if (frame->status == OK)
{
sp<MetaData> outFormat = p->decoder->getFormat();
outFormat->findInt32(kKeyWidth , &w);
outFormat->findInt32(kKeyHeight, &h);
frame->pts = 0;
frame->width = w;
frame->height = h;
frame->medbuf->meta_data()->findInt64(kKeyTime, &(frame->pts));
}
else if (frame->status == INFO_FORMAT_CHANGED)
{
int32_t cropLeft, cropTop, cropRight, cropBottom;
sp<MetaData> outFormat = p->decoder->getFormat();
outFormat->findInt32(kKeyWidth , &p->width);
outFormat->findInt32(kKeyHeight, &p->height);
cropLeft = cropTop = cropRight = cropBottom = 0;
if (!outFormat->findRect(kKeyCropRect, &cropLeft, &cropTop, &cropRight, &cropBottom))
{
p->x = 0;
p->y = 0;
}
else
{
p->x = cropLeft;
p->y = cropTop;
p->width = cropRight - cropLeft + 1;
p->height = cropBottom - cropTop + 1;
}
outFormat->findInt32(kKeyColorFormat, &p->videoColorFormat);
if (!outFormat->findInt32(kKeyStride, &p->videoStride))
p->videoStride = p->width;
if (!outFormat->findInt32(kKeySliceHeight, &p->videoSliceHeight))
p->videoSliceHeight = p->height;
#if defined(DEBUG_VERBOSE)
CLog::Log(LOGDEBUG, ">>> new format col:%d, w:%d, h:%d, sw:%d, sh:%d, ctl:%d,%d; cbr:%d,%d\n", p->videoColorFormat, p->width, p->height, p->videoStride, p->videoSliceHeight, cropTop, cropLeft, cropBottom, cropRight);
#endif
if (frame->medbuf)
frame->medbuf->release();
frame->medbuf = NULL;
free(frame);
continue;
}
//.........这里部分代码省略.........
示例11: CHECK
void NuPlayer::GenericSource::readBuffer(
bool audio, int64_t seekTimeUs, int64_t *actualTimeUs) {
Track *track = audio ? &mAudioTrack : &mVideoTrack;
CHECK(track->mSource != NULL);
if (actualTimeUs) {
*actualTimeUs = seekTimeUs;
}
MediaSource::ReadOptions options;
bool seeking = false;
if (seekTimeUs >= 0) {
options.setSeekTo(seekTimeUs);
seeking = true;
}
for (;;) {
MediaBuffer *mbuf;
status_t err = track->mSource->read(&mbuf, &options);
options.clearSeekTo();
if (err == OK) {
size_t outLength = mbuf->range_length();
if (audio && mAudioIsVorbis) {
outLength += sizeof(int32_t);
}
sp<ABuffer> buffer = new ABuffer(outLength);
memcpy(buffer->data(),
(const uint8_t *)mbuf->data() + mbuf->range_offset(),
mbuf->range_length());
if (audio && mAudioIsVorbis) {
int32_t numPageSamples;
if (!mbuf->meta_data()->findInt32(
kKeyValidSamples, &numPageSamples)) {
numPageSamples = -1;
}
memcpy(buffer->data() + mbuf->range_length(),
&numPageSamples,
sizeof(numPageSamples));
}
int64_t timeUs;
CHECK(mbuf->meta_data()->findInt64(kKeyTime, &timeUs));
buffer->meta()->setInt64("timeUs", timeUs);
if (actualTimeUs) {
*actualTimeUs = timeUs;
}
mbuf->release();
mbuf = NULL;
if (seeking) {
track->mPackets->queueDiscontinuity(
ATSParser::DISCONTINUITY_SEEK, NULL);
}
track->mPackets->queueAccessUnit(buffer);
break;
} else if (err == INFO_FORMAT_CHANGED) {
#if 0
track->mPackets->queueDiscontinuity(
ATSParser::DISCONTINUITY_FORMATCHANGE, NULL);
#endif
} else {
track->mPackets->signalEOS(err);
break;
}
}
}