本文整理汇总了C++中KeyedVector::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyedVector::isEmpty方法的具体用法?C++ KeyedVector::isEmpty怎么用?C++ KeyedVector::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyedVector
的用法示例。
在下文中一共展示了KeyedVector::isEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decode
static int decode(
const android::sp<android::ALooper> &looper,
const char *path,
bool useAudio,
bool useVideo,
const android::sp<android::Surface> &surface) {
using namespace android;
static int64_t kTimeout = 500ll;
sp<NuMediaExtractor> extractor = new NuMediaExtractor;
if (extractor->setDataSource(path) != OK) {
fprintf(stderr, "unable to instantiate extractor.\n");
return 1;
}
KeyedVector<size_t, CodecState> stateByTrack;
bool haveAudio = false;
bool haveVideo = false;
for (size_t i = 0; i < extractor->countTracks(); ++i) {
sp<AMessage> format;
status_t err = extractor->getTrackFormat(i, &format);
CHECK_EQ(err, (status_t)OK);
AString mime;
CHECK(format->findString("mime", &mime));
bool isAudio = !strncasecmp(mime.c_str(), "audio/", 6);
bool isVideo = !strncasecmp(mime.c_str(), "video/", 6);
if (useAudio && !haveAudio && isAudio) {
haveAudio = true;
} else if (useVideo && !haveVideo && isVideo) {
haveVideo = true;
} else {
continue;
}
ALOGV("selecting track %d", i);
err = extractor->selectTrack(i);
CHECK_EQ(err, (status_t)OK);
CodecState *state =
&stateByTrack.editValueAt(stateByTrack.add(i, CodecState()));
state->mNumBytesDecoded = 0;
state->mNumBuffersDecoded = 0;
state->mIsAudio = isAudio;
state->mCodec = MediaCodec::CreateByType(
looper, mime.c_str(), false /* encoder */);
CHECK(state->mCodec != NULL);
err = state->mCodec->configure(
format, isVideo ? surface : NULL,
NULL /* crypto */,
0 /* flags */);
CHECK_EQ(err, (status_t)OK);
state->mSignalledInputEOS = false;
state->mSawOutputEOS = false;
}
CHECK(!stateByTrack.isEmpty());
int64_t startTimeUs = ALooper::GetNowUs();
for (size_t i = 0; i < stateByTrack.size(); ++i) {
CodecState *state = &stateByTrack.editValueAt(i);
sp<MediaCodec> codec = state->mCodec;
CHECK_EQ((status_t)OK, codec->start());
CHECK_EQ((status_t)OK, codec->getInputBuffers(&state->mInBuffers));
CHECK_EQ((status_t)OK, codec->getOutputBuffers(&state->mOutBuffers));
ALOGV("got %d input and %d output buffers",
state->mInBuffers.size(), state->mOutBuffers.size());
}
bool sawInputEOS = false;
for (;;) {
if (!sawInputEOS) {
size_t trackIndex;
status_t err = extractor->getSampleTrackIndex(&trackIndex);
if (err != OK) {
ALOGV("saw input eos");
sawInputEOS = true;
} else {
CodecState *state = &stateByTrack.editValueFor(trackIndex);
size_t index;
err = state->mCodec->dequeueInputBuffer(&index, kTimeout);
//.........这里部分代码省略.........