WEB开发网
开发学院手机开发Android 开发 Android 下的PVPlayer的实现 阅读

Android 下的PVPlayer的实现

 2010-09-10 01:08:00 来源:WEB开发网   
核心提示:close(mSharedFd);mSharedFd = -1;}free(mDataSourcePath);mDataSourcePath = NULL;// Don't let somebody trick us in to reading some random block of memoryif (st

close(mSharedFd);

mSharedFd = -1;

}

free(mDataSourcePath);

mDataSourcePath = NULL;

// Don't let somebody trick us in to reading some random block of memory

if (strncmp("sharedfd://", url, 11) == 0)

return android::UNKNOWN_ERROR;

mDataSourcePath = strdup(url);

return OK;

} //这个函数只是改变了一下mDataSourcePath这个东东,但是我们的opencore里面如何知道的呢?

status_t PVPlayer::setDataSource(int fd, int64_t offset, int64_t length) {

// This is all a big hack to allow PV to play from a file descriptor.

// Eventually we'll fix PV to use a file descriptor directly instead

// of using mmap().

LOGV("setDataSource(%d, %lld, %lld)", fd, offset, length);

if (mSharedFd >= 0) {

close(mSharedFd);

mSharedFd = -1;

}

free(mDataSourcePath);

mDataSourcePath = NULL;

char buf[80];

mSharedFd = dup(fd);

sprintf(buf, "sharedfd://%d:%lld:%lld", mSharedFd, offset, length);

mDataSourcePath = strdup(buf);

return OK;

}

然后是:

status_t PVPlayer::setVideoSurface(const sp& surface)

{

LOGV("setVideoSurface(%p)", surface.get());

mSurface = surface;

return OK;

}

然后是prepare,这个函数如果你在setsource里面没有做什么事情的话,这个里面就开始忙了

status_t PVPlayer::prepare()

{

status_t ret;

// We need to differentiate the two valid use cases for prepare():

// 1. new PVPlayer/reset()->setDataSource()->prepare()

// 2. new PVPlayer/reset()->setDataSource()->prepare()/prepareAsync()

// ->start()->...->stop()->prepare()

// If data source has already been set previously, no need to run

上一页  2 3 4 5 6 7 8 9 10 11 12  下一页

Tags:Android PVPlayer 实现

编辑录入:coldstar [复制链接] [打 印]
赞助商链接