本文整理汇总了C++中KeyedVector::add方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyedVector::add方法的具体用法?C++ KeyedVector::add怎么用?C++ KeyedVector::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyedVector
的用法示例。
在下文中一共展示了KeyedVector::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendMotionEvent
status_t NativeInputEventSender::sendMotionEvent(uint32_t seq, const MotionEvent* event) {
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Sending motion event, seq=%u.", getInputChannelName(), seq);
}
uint32_t publishedSeq;
for (size_t i = 0; i <= event->getHistorySize(); i++) {
publishedSeq = mNextPublishedSeq++;
status_t status = mInputPublisher.publishMotionEvent(publishedSeq,
event->getDeviceId(), event->getSource(),
event->getAction(), event->getActionButton(), event->getFlags(),
event->getEdgeFlags(), event->getMetaState(), event->getButtonState(),
event->getXOffset(), event->getYOffset(),
event->getXPrecision(), event->getYPrecision(),
event->getDownTime(), event->getHistoricalEventTime(i),
event->getPointerCount(), event->getPointerProperties(),
event->getHistoricalRawPointerCoords(0, i));
if (status) {
ALOGW("Failed to send motion event sample on channel '%s'. status=%d",
getInputChannelName(), status);
return status;
}
}
mPublishedSeqMap.add(publishedSeq, seq);
return OK;
}
示例2: connect
status_t MediaHTTP::connect(
const char *uri,
const KeyedVector<String8, String8> *headers,
off64_t /* offset */) {
if (mInitCheck != OK) {
return mInitCheck;
}
KeyedVector<String8, String8> extHeaders;
if (headers != NULL) {
extHeaders = *headers;
}
if (extHeaders.indexOfKey(String8("User-Agent")) < 0) {
extHeaders.add(String8("User-Agent"), String8(MakeUserAgent().c_str()));
}
bool success = mHTTPConnection->connect(uri, &extHeaders);
mLastHeaders = extHeaders;
mLastURI = uri;
mCachedSizeValid = false;
return success ? OK : UNKNOWN_ERROR;
}
示例3: allocateNode
status_t MuxOMX::allocateNode(
const char *name, const sp<IOMXObserver> &observer,
node_id *node) {
Mutex::Autolock autoLock(mLock);
sp<IOMX> omx;
if (IsSoftwareComponent(name)) {
if (mLocalOMX == NULL) {
mLocalOMX = new OMX;
}
omx = mLocalOMX;
} else {
omx = mRemoteOMX;
}
status_t err = omx->allocateNode(name, observer, node);
if (err != OK) {
return err;
}
if (omx == mLocalOMX) {
mIsLocalNode.add(*node, true);
}
return OK;
}
示例4:
KeyedVector<uint16_t, const TagDefinition_t*> TiffWriter::buildTagMap(
const TagDefinition_t* definitions, size_t length) {
KeyedVector<uint16_t, const TagDefinition_t*> map;
for(size_t i = 0; i < length; ++i) {
map.add(definitions[i].tagId, definitions + i);
}
return map;
}
示例5: HashMapToKeyedVector
static KeyedVector<String8, String8> HashMapToKeyedVector(
JNIEnv *env, jobject &hashMap, bool* pIsOK) {
jclass clazz = gFields.stringClassId;
KeyedVector<String8, String8> keyedVector;
*pIsOK = true;
jobject entrySet = env->CallObjectMethod(hashMap, gFields.hashmap.entrySet);
if (entrySet) {
jobject iterator = env->CallObjectMethod(entrySet, gFields.set.iterator);
if (iterator) {
jboolean hasNext = env->CallBooleanMethod(iterator, gFields.iterator.hasNext);
while (hasNext) {
jobject entry = env->CallObjectMethod(iterator, gFields.iterator.next);
if (entry) {
jobject obj = env->CallObjectMethod(entry, gFields.entry.getKey);
if (obj == NULL || !env->IsInstanceOf(obj, clazz)) {
jniThrowException(env, "java/lang/IllegalArgumentException",
"HashMap key is not a String");
env->DeleteLocalRef(entry);
*pIsOK = false;
break;
}
jstring jkey = static_cast<jstring>(obj);
obj = env->CallObjectMethod(entry, gFields.entry.getValue);
if (obj == NULL || !env->IsInstanceOf(obj, clazz)) {
jniThrowException(env, "java/lang/IllegalArgumentException",
"HashMap value is not a String");
env->DeleteLocalRef(entry);
*pIsOK = false;
break;
}
jstring jvalue = static_cast<jstring>(obj);
String8 key = JStringToString8(env, jkey);
String8 value = JStringToString8(env, jvalue);
keyedVector.add(key, value);
env->DeleteLocalRef(jkey);
env->DeleteLocalRef(jvalue);
hasNext = env->CallBooleanMethod(iterator, gFields.iterator.hasNext);
}
env->DeleteLocalRef(entry);
}
env->DeleteLocalRef(iterator);
}
env->DeleteLocalRef(entrySet);
}
return keyedVector;
}
示例6: AMediaDrm_getKeyRequest
EXPORT
media_status_t AMediaDrm_getKeyRequest(AMediaDrm *mObj, const AMediaDrmScope *scope,
const uint8_t *init, size_t initSize, const char *mimeType, AMediaDrmKeyType keyType,
const AMediaDrmKeyValue *optionalParameters, size_t numOptionalParameters,
const uint8_t **keyRequest, size_t *keyRequestSize) {
if (!mObj || mObj->mDrm == NULL) {
return AMEDIA_ERROR_INVALID_OBJECT;
}
if (!mimeType || !scope || !keyRequest || !keyRequestSize) {
return AMEDIA_ERROR_INVALID_PARAMETER;
}
List<idvec_t>::iterator iter;
if (!findId(mObj, *scope, iter)) {
return AMEDIA_DRM_SESSION_NOT_OPENED;
}
Vector<uint8_t> mdInit;
mdInit.appendArray(init, initSize);
DrmPlugin::KeyType mdKeyType;
switch (keyType) {
case KEY_TYPE_STREAMING:
mdKeyType = DrmPlugin::kKeyType_Streaming;
break;
case KEY_TYPE_OFFLINE:
mdKeyType = DrmPlugin::kKeyType_Offline;
break;
case KEY_TYPE_RELEASE:
mdKeyType = DrmPlugin::kKeyType_Release;
break;
default:
return AMEDIA_ERROR_INVALID_PARAMETER;
}
KeyedVector<String8, String8> mdOptionalParameters;
for (size_t i = 0; i < numOptionalParameters; i++) {
mdOptionalParameters.add(String8(optionalParameters[i].mKey),
String8(optionalParameters[i].mValue));
}
String8 defaultUrl;
status_t status = mObj->mDrm->getKeyRequest(*iter, mdInit, String8(mimeType),
mdKeyType, mdOptionalParameters, mObj->mKeyRequest, defaultUrl);
if (status != OK) {
return translateStatus(status);
} else {
*keyRequest = mObj->mKeyRequest.array();
*keyRequestSize = mObj->mKeyRequest.size();
}
return AMEDIA_OK;
}
示例7: client
GPUHardware::Client& GPUHardware::getClientLocked(pid_t pid)
{
ssize_t index = mClients.indexOfKey(pid);
if (index < 0) {
Client client;
client.pid = pid;
client.smi.heap = mSMIHeap;
client.ebi.heap = mEBIHeap;
client.reg.heap = mREGHeap;
index = mClients.add(pid, client);
}
Client& client(mClients.editValueAt(index));
client.createClientHeaps();
return client;
}
示例8:
KeyedVector<SplitDescription, sp<Rule> > SplitSelector::getRules() const {
KeyedVector<SplitDescription, sp<Rule> > rules;
const size_t groupCount = mGroups.size();
for (size_t i = 0; i < groupCount; i++) {
const SortedVector<SplitDescription>& splits = mGroups[i];
const size_t splitCount = splits.size();
for (size_t j = 0; j < splitCount; j++) {
sp<Rule> rule = Rule::simplify(RuleGenerator::generate(splits, j));
if (rule != NULL) {
rules.add(splits[j], rule);
}
}
}
return rules;
}
示例9: sendKeyEvent
status_t NativeInputEventSender::sendKeyEvent(uint32_t seq, const KeyEvent* event) {
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Sending key event, seq=%u.", getInputChannelName(), seq);
}
uint32_t publishedSeq = mNextPublishedSeq++;
status_t status = mInputPublisher.publishKeyEvent(publishedSeq,
event->getDeviceId(), event->getSource(), event->getAction(), event->getFlags(),
event->getKeyCode(), event->getScanCode(), event->getMetaState(),
event->getRepeatCount(), event->getDownTime(), event->getEventTime());
if (status) {
ALOGW("Failed to send key event on channel '%s'. status=%d",
getInputChannelName(), status);
return status;
}
mPublishedSeqMap.add(publishedSeq, seq);
return OK;
}
示例10: autoLock
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;
}
示例11: onDeviceAvailable
void JTvInputHal::onDeviceAvailable(const tv_input_device_info_t& info) {
{
Mutex::Autolock autoLock(&mLock);
mConnections.add(info.device_id, KeyedVector<int, Connection>());
}
JNIEnv* env = AndroidRuntime::getJNIEnv();
jobject builder = env->NewObject(
gTvInputHardwareInfoBuilderClassInfo.clazz,
gTvInputHardwareInfoBuilderClassInfo.constructor);
env->CallObjectMethod(
builder, gTvInputHardwareInfoBuilderClassInfo.deviceId, info.device_id);
env->CallObjectMethod(
builder, gTvInputHardwareInfoBuilderClassInfo.type, info.type);
if (info.type == TV_INPUT_TYPE_HDMI) {
env->CallObjectMethod(
builder, gTvInputHardwareInfoBuilderClassInfo.hdmiPortId, info.hdmi.port_id);
}
env->CallObjectMethod(
builder, gTvInputHardwareInfoBuilderClassInfo.audioType, info.audio_type);
if (info.audio_type != AUDIO_DEVICE_NONE) {
jstring audioAddress = env->NewStringUTF(info.audio_address);
env->CallObjectMethod(
builder, gTvInputHardwareInfoBuilderClassInfo.audioAddress, audioAddress);
env->DeleteLocalRef(audioAddress);
}
jobject infoObject = env->CallObjectMethod(builder, gTvInputHardwareInfoBuilderClassInfo.build);
env->CallVoidMethod(
mThiz,
gTvInputHalClassInfo.deviceAvailable,
infoObject);
env->DeleteLocalRef(builder);
env->DeleteLocalRef(infoObject);
}
示例12: _l
sp<IMemoryHeap> HeapCache::find_heap(const sp<IBinder>& binder)
{
Mutex::Autolock _l(mHeapCacheLock);
ssize_t i = mHeapCache.indexOfKey(binder);
if (i>=0) {
heap_info_t& info = mHeapCache.editValueAt(i);
ALOGD_IF(VERBOSE,
"found binder=%p, heap=%p, size=%d, fd=%d, count=%d",
binder.get(), info.heap.get(),
static_cast<BpMemoryHeap*>(info.heap.get())->mSize,
static_cast<BpMemoryHeap*>(info.heap.get())->mHeapId,
info.count);
android_atomic_inc(&info.count);
return info.heap;
} else {
heap_info_t info;
info.heap = interface_cast<IMemoryHeap>(binder);
info.count = 1;
//ALOGD("adding binder=%p, heap=%p, count=%d",
// binder.get(), info.heap.get(), info.count);
mHeapCache.add(binder, info);
return info.heap;
}
}
示例13: 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);
//.........这里部分代码省略.........
示例14: onTransact
status_t BnMediaPlayerService::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch(code) {
case CREATE_URL: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pid_t pid = data.readInt32();
sp<IMediaPlayerClient> client =
interface_cast<IMediaPlayerClient>(data.readStrongBinder());
const char* url = data.readCString();
KeyedVector<String8, String8> headers;
int32_t numHeaders = data.readInt32();
for (int i = 0; i < numHeaders; ++i) {
String8 key = data.readString8();
String8 value = data.readString8();
headers.add(key, value);
}
sp<IMediaPlayer> player = create(
pid, client, url, numHeaders > 0 ? &headers : NULL);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case CREATE_FD: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pid_t pid = data.readInt32();
sp<IMediaPlayerClient> client = interface_cast<IMediaPlayerClient>(data.readStrongBinder());
int fd = dup(data.readFileDescriptor());
int64_t offset = data.readInt64();
int64_t length = data.readInt64();
sp<IMediaPlayer> player = create(pid, client, fd, offset, length);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case DECODE_URL: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
const char* url = data.readCString();
uint32_t sampleRate;
int numChannels;
int format;
sp<IMemory> player = decode(url, &sampleRate, &numChannels, &format);
reply->writeInt32(sampleRate);
reply->writeInt32(numChannels);
reply->writeInt32(format);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case DECODE_FD: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
int fd = dup(data.readFileDescriptor());
int64_t offset = data.readInt64();
int64_t length = data.readInt64();
uint32_t sampleRate;
int numChannels;
int format;
sp<IMemory> player = decode(fd, offset, length, &sampleRate, &numChannels, &format);
reply->writeInt32(sampleRate);
reply->writeInt32(numChannels);
reply->writeInt32(format);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case SNOOP: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
sp<IMemory> snooped_audio = snoop();
reply->writeStrongBinder(snooped_audio->asBinder());
return NO_ERROR;
} break;
case CREATE_MEDIA_RECORDER: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pid_t pid = data.readInt32();
sp<IMediaRecorder> recorder = createMediaRecorder(pid);
reply->writeStrongBinder(recorder->asBinder());
return NO_ERROR;
} break;
case CREATE_METADATA_RETRIEVER: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pid_t pid = data.readInt32();
sp<IMediaMetadataRetriever> retriever = createMetadataRetriever(pid);
reply->writeStrongBinder(retriever->asBinder());
return NO_ERROR;
} break;
case GET_OMX: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
sp<IOMX> omx = getOMX();
reply->writeStrongBinder(omx->asBinder());
return NO_ERROR;
} break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
示例15: muxing
static int muxing(
const char *path,
bool useAudio,
bool useVideo,
const char *outputFileName,
bool enableTrim,
int trimStartTimeMs,
int trimEndTimeMs,
int rotationDegrees,
MediaMuxer::OutputFormat container = MediaMuxer::OUTPUT_FORMAT_MPEG_4) {
sp<NuMediaExtractor> extractor = new NuMediaExtractor;
if (extractor->setDataSource(NULL /* httpService */, path) != OK) {
fprintf(stderr, "unable to instantiate extractor. %s\n", path);
return 1;
}
if (outputFileName == NULL) {
outputFileName = "/sdcard/muxeroutput.mp4";
}
ALOGV("input file %s, output file %s", path, outputFileName);
ALOGV("useAudio %d, useVideo %d", useAudio, useVideo);
int fd = open(outputFileName, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
if (fd < 0) {
ALOGE("couldn't open file");
return fd;
}
sp<MediaMuxer> muxer = new MediaMuxer(fd, container);
close(fd);
size_t trackCount = extractor->countTracks();
// Map the extractor's track index to the muxer's track index.
KeyedVector<size_t, ssize_t> trackIndexMap;
size_t bufferSize = 1 * 1024 * 1024; // default buffer size is 1MB.
bool haveAudio = false;
bool haveVideo = false;
int64_t trimStartTimeUs = trimStartTimeMs * 1000;
int64_t trimEndTimeUs = trimEndTimeMs * 1000;
bool trimStarted = false;
int64_t trimOffsetTimeUs = 0;
for (size_t i = 0; i < trackCount; ++i) {
sp<AMessage> format;
status_t err = extractor->getTrackFormat(i, &format);
CHECK_EQ(err, (status_t)OK);
ALOGV("extractor getTrackFormat: %s", format->debugString().c_str());
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;
}
if (isVideo) {
int width , height;
CHECK(format->findInt32("width", &width));
CHECK(format->findInt32("height", &height));
bufferSize = width * height * 4; // Assuming it is maximally 4BPP
}
int64_t duration;
CHECK(format->findInt64("durationUs", &duration));
// Since we got the duration now, correct the start time.
if (enableTrim) {
if (trimStartTimeUs > duration) {
fprintf(stderr, "Warning: trimStartTimeUs > duration,"
" reset to 0\n");
trimStartTimeUs = 0;
}
}
ALOGV("selecting track %zu", i);
err = extractor->selectTrack(i);
CHECK_EQ(err, (status_t)OK);
ssize_t newTrackIndex = muxer->addTrack(format);
if (newTrackIndex < 0) {
fprintf(stderr, "%s track (%zu) unsupported by muxer\n",
isAudio ? "audio" : "video",
i);
} else {
trackIndexMap.add(i, newTrackIndex);
}
}
int64_t muxerStartTimeUs = ALooper::GetNowUs();
//.........这里部分代码省略.........