static AString codecResultsToXml(const KeyedVector<AString, CodecSettings> &results) { AString ret; for (size_t i = 0; i < results.size(); ++i) { AString name; AString mime; if (!splitString(results.keyAt(i), " ", &name, &mime)) { continue; } AString codec = AStringPrintf(" <MediaCodec name=\"%s\" type=\"%s\" update=\"true\" >\n", name.c_str(), mime.c_str()); ret.append(codec); const CodecSettings &settings = results.valueAt(i); for (size_t i = 0; i < settings.size(); ++i) { // WARNING: we assume all the settings are "Limit". Currently we have only one type // of setting in this case, which is "max-supported-instances". AString setting = AStringPrintf( " <Limit name=\"%s\" value=\"%s\" />\n", settings.keyAt(i).c_str(), settings.valueAt(i).c_str()); ret.append(setting); } ret.append(" </MediaCodec>\n"); } return ret; }
static jobject KeyedVectorToHashMap (JNIEnv *env, KeyedVector<String8, String8> const &map) { jclass clazz = gFields.hashmapClassId; jobject hashMap = env->NewObject(clazz, gFields.hashmap.init); for (size_t i = 0; i < map.size(); ++i) { jstring jkey = env->NewStringUTF(map.keyAt(i).string()); jstring jvalue = env->NewStringUTF(map.valueAt(i).string()); env->CallObjectMethod(hashMap, gFields.hashmap.put, jkey, jvalue); env->DeleteLocalRef(jkey); env->DeleteLocalRef(jvalue); } return hashMap; }
void HeapCache::dump_heaps() { Mutex::Autolock _l(mHeapCacheLock); int c = mHeapCache.size(); for (int i=0 ; i<c ; i++) { const heap_info_t& info = mHeapCache.valueAt(i); BpMemoryHeap const* h(static_cast<BpMemoryHeap const *>(info.heap.get())); ALOGD("hey=%p, heap=%p, count=%d, (fd=%d, base=%p, size=%d)", mHeapCache.keyAt(i).unsafe_get(), info.heap.get(), info.count, h->mHeapId, h->mBase, h->mSize); } }
status_t MPEG2TSExtractor::feedMore() { Mutex::Autolock autoLock(mLock); uint8_t packet[kTSPacketSize]; ssize_t n = mDataSource->readAt(mOffset, packet, kTSPacketSize); if (n < (ssize_t)kTSPacketSize) { if (n >= 0) { mParser->signalEOS(ERROR_END_OF_STREAM); } return (n < 0) ? (status_t)n : ERROR_END_OF_STREAM; } ATSParser::SyncEvent event(mOffset); mOffset += n; status_t err = mParser->feedTSPacket(packet, kTSPacketSize, &event); if (event.isInit()) { for (size_t i = 0; i < mSourceImpls.size(); ++i) { if (mSourceImpls[i].get() == event.getMediaSource().get()) { KeyedVector<int64_t, off64_t> *syncPoints = &mSyncPoints.editItemAt(i); syncPoints->add(event.getTimeUs(), event.getOffset()); // We're keeping the size of the sync points at most 5mb per a track. size_t size = syncPoints->size(); if (size >= 327680) { int64_t firstTimeUs = syncPoints->keyAt(0); int64_t lastTimeUs = syncPoints->keyAt(size - 1); if (event.getTimeUs() - firstTimeUs > lastTimeUs - event.getTimeUs()) { syncPoints->removeItemsAt(0, 4096); } else { syncPoints->removeItemsAt(size - 4096, 4096); } } break; } } } return err; }
void generate(const KeyedVector<String8, Vector<SplitDescription> >& splits, const String8& base) { Vector<SplitDescription> allSplits; const size_t apkSplitCount = splits.size(); for (size_t i = 0; i < apkSplitCount; i++) { allSplits.appendVector(splits[i]); } const SplitSelector selector(allSplits); KeyedVector<SplitDescription, sp<Rule> > rules(selector.getRules()); bool first = true; fprintf(stdout, "[\n"); for (size_t i = 0; i < apkSplitCount; i++) { if (splits.keyAt(i) == base) { // Skip the base. continue; } if (!first) { fprintf(stdout, ",\n"); } first = false; sp<Rule> masterRule = new Rule(); masterRule->op = Rule::OR_SUBRULES; const Vector<SplitDescription>& splitDescriptions = splits[i]; const size_t splitDescriptionCount = splitDescriptions.size(); for (size_t j = 0; j < splitDescriptionCount; j++) { masterRule->subrules.add(rules.valueFor(splitDescriptions[j])); } masterRule = Rule::simplify(masterRule); fprintf(stdout, " {\n \"path\": \"%s\",\n \"rules\": %s\n }", splits.keyAt(i).string(), masterRule->toJson(2).string()); } fprintf(stdout, "\n]\n"); }
// cast-operator to (EGLint const*) operator EGLint const* () const { return &mList.keyAt(0).v; }
status_t TiffWriter::write(Output* out, StripSource** sources, size_t sourcesCount, Endianness end) { status_t ret = OK; EndianOutput endOut(out, end); if (mIfd == NULL) { ALOGE("%s: Tiff header is empty.", __FUNCTION__); return BAD_VALUE; } uint32_t totalSize = getTotalSize(); KeyedVector<uint32_t, uint32_t> offsetVector; for (size_t i = 0; i < mNamedIfds.size(); ++i) { if (mNamedIfds[i]->uninitializedOffsets()) { uint32_t stripSize = mNamedIfds[i]->getStripSize(); if (mNamedIfds[i]->setStripOffset(totalSize) != OK) { ALOGE("%s: Could not set strip offsets.", __FUNCTION__); return BAD_VALUE; } totalSize += stripSize; WORD_ALIGN(totalSize); offsetVector.add(mNamedIfds.keyAt(i), totalSize); } } size_t offVecSize = offsetVector.size(); if (offVecSize != sourcesCount) { ALOGE("%s: Mismatch between number of IFDs with uninitialized strips (%zu) and" " sources (%zu).", __FUNCTION__, offVecSize, sourcesCount); return BAD_VALUE; } BAIL_ON_FAIL(writeFileHeader(endOut), ret); uint32_t offset = FILE_HEADER_SIZE; sp<TiffIfd> ifd = mIfd; while(ifd != NULL) { BAIL_ON_FAIL(ifd->writeData(offset, &endOut), ret); offset += ifd->getSize(); ifd = ifd->getNextIfd(); } if (LOG_NDEBUG == 0) { log(); } for (size_t i = 0; i < offVecSize; ++i) { uint32_t ifdKey = offsetVector.keyAt(i); uint32_t sizeToWrite = mNamedIfds[ifdKey]->getStripSize(); bool found = false; for (size_t j = 0; j < sourcesCount; ++j) { if (sources[j]->getIfd() == ifdKey) { if ((ret = sources[i]->writeToStream(endOut, sizeToWrite)) != OK) { ALOGE("%s: Could not write to stream, received %d.", __FUNCTION__, ret); return ret; } ZERO_TILL_WORD(&endOut, sizeToWrite, ret); found = true; break; } } if (!found) { ALOGE("%s: No stream for byte strips for IFD %u", __FUNCTION__, ifdKey); return BAD_VALUE; } assert(offsetVector[i] == endOut.getCurrentOffset()); } return ret; }