本文整理汇总了C++中sp::findMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::findMessage方法的具体用法?C++ sp::findMessage怎么用?C++ sp::findMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sp
的用法示例。
在下文中一共展示了sp::findMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onMessageReceived
void ARTSPConnection::onMessageReceived(const sp<AMessage> &msg) {
switch (msg->what()) {
case kWhatConnect:
onConnect(msg);
break;
case kWhatDisconnect:
onDisconnect(msg);
break;
case kWhatCompleteConnection:
onCompleteConnection(msg);
break;
case kWhatSendRequest:
onSendRequest(msg);
break;
case kWhatReceiveResponse:
onReceiveResponse();
break;
case kWhatObserveBinaryData:
{
CHECK(msg->findMessage("reply", &mObserveBinaryMessage));
break;
}
default:
TRESPASS();
break;
}
}
示例2: onReconnect
void ARTSPConnection::onReconnect(const sp<AMessage> &msg) {
ALOGV("onReconnect");
sp<AMessage> reply;
CHECK(msg->findMessage("reply", &reply));
int32_t connectionID;
CHECK(msg->findInt32("connection-id", &connectionID));
if ((connectionID != mConnectionID) || mState != CONNECTING) {
// While we were attempting to connect, the attempt was
// cancelled.
reply->setInt32("result", -ECONNABORTED);
reply->post();
if (mAddrHeader != NULL) {
freeaddrinfo((struct addrinfo *)mAddrHeader);
mAddrHeader = NULL;
}
return;
}
int32_t port;
CHECK(msg->findInt32("port", &port));
if (!createSocketAndConnect(mAddrHeader, port, reply)) {
ALOGV("Failed to reconnect");
reply->setInt32("result", -errno);
mState = DISCONNECTED;
mSocket = -1;
reply->post();
freeaddrinfo((struct addrinfo *)mAddrHeader);
mAddrHeader = NULL;
}
}
示例3: onCompleteConnection
void ARTSPConnection::onCompleteConnection(const sp<AMessage> &msg) {
sp<AMessage> reply;
CHECK(msg->findMessage("reply", &reply));
int32_t connectionID;
CHECK(msg->findInt32("connection-id", &connectionID));
if ((connectionID != mConnectionID) || mState != CONNECTING) {
// While we were attempting to connect, the attempt was
// cancelled.
reply->setInt32("result", -ECONNABORTED);
reply->post();
return;
}
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = kSelectTimeoutUs;
fd_set ws;
FD_ZERO(&ws);
FD_SET(mSocket, &ws);
int res = select(mSocket + 1, NULL, &ws, NULL, &tv);
CHECK_GE(res, 0);
if (res == 0) {
// Timed out. Not yet connected.
msg->post();
return;
}
int err;
socklen_t optionLen = sizeof(err);
CHECK_EQ(getsockopt(mSocket, SOL_SOCKET, SO_ERROR, &err, &optionLen), 0);
CHECK_EQ(optionLen, (socklen_t)sizeof(err));
if (err != 0) {
LOGE("err = %d (%s)", err, strerror(err));
reply->setInt32("result", -err);
mState = DISCONNECTED;
if (mUIDValid) {
HTTPBase::UnRegisterSocketUserTag(mSocket);
}
close(mSocket);
mSocket = -1;
} else {
reply->setInt32("result", OK);
mState = CONNECTED;
mNextCSeq = 1;
postReceiveReponseEvent();
}
reply->post();
}
示例4: onSetFormat
void DirectRenderer::onSetFormat(const sp<AMessage> &msg) {
size_t trackIndex;
CHECK(msg->findSize("trackIndex", &trackIndex));
sp<AMessage> format;
CHECK(msg->findMessage("format", &format));
internalSetFormat(trackIndex, format);
}
示例5: onSendRequest
void ARTSPConnection::onSendRequest(const sp<AMessage> &msg) {
sp<AMessage> reply;
CHECK(msg->findMessage("reply", &reply));
if (mState != CONNECTED) {
reply->setInt32("result", -ENOTCONN);
reply->post();
return;
}
AString request;
CHECK(msg->findString("request", &request));
// Find the boundary between headers and the body.
ssize_t i = request.find("\r\n\r\n");
CHECK_GE(i, 0);
int32_t cseq = mNextCSeq++;
AString cseqHeader = "CSeq: ";
cseqHeader.append(cseq);
cseqHeader.append("\r\n");
request.insert(cseqHeader, i + 2);
LOGV("%s", request.c_str());
size_t numBytesSent = 0;
while (numBytesSent < request.size()) {
ssize_t n =
send(mSocket, request.c_str() + numBytesSent,
request.size() - numBytesSent, 0);
if (n == 0) {
// Server closed the connection.
LOGE("Server unexpectedly closed the connection.");
reply->setInt32("result", ERROR_IO);
reply->post();
return;
} else if (n < 0) {
if (errno == EINTR) {
continue;
}
LOGE("Error sending rtsp request.");
reply->setInt32("result", -errno);
reply->post();
return;
}
numBytesSent += (size_t)n;
}
mPendingRequests.add(cseq, reply);
}
示例6: setParameters
status_t SaturationFilter::setParameters(const sp<AMessage> &msg) {
sp<AMessage> params;
CHECK(msg->findMessage("params", ¶ms));
float saturation;
if (params->findFloat("saturation", &saturation)) {
mSaturation = saturation;
}
return OK;
}
示例7: onDisconnect
void ARTSPConnection::onDisconnect(const sp<AMessage> &msg) {
if (mState == CONNECTED || mState == CONNECTING) {
performDisconnect();
}
sp<AMessage> reply;
CHECK(msg->findMessage("reply", &reply));
reply->setInt32("result", OK);
reply->post();
}
示例8: onDisconnect
void ARTSPConnection::onDisconnect(const sp<AMessage> &msg) {
if (mState == CONNECTED || mState == CONNECTING) {
close(mSocket);
mSocket = -1;
flushPendingRequests();
}
sp<AMessage> reply;
CHECK(msg->findMessage("reply", &reply));
reply->setInt32("result", OK);
mState = DISCONNECTED;
reply->post();
}
示例9: onMessageReceived
void ARTSPConnection::onMessageReceived(const sp<AMessage> &msg) {
switch (msg->what()) {
case kWhatConnect:
onConnect(msg);
break;
case kWhatDisconnect:
onDisconnect(msg);
break;
case kWhatCompleteConnection:
onCompleteConnection(msg);
break;
case kWhatSendRequest:
onSendRequest(msg);
break;
case kWhatReceiveResponse:
onReceiveResponse();
break;
case kWhatObserveBinaryData:
{
CHECK(msg->findMessage("reply", &mObserveBinaryMessage));
break;
}
#ifndef ANDROID_DEFAULT_CODE
case kWhatTimeout:
{
unsigned long cseq;
CHECK(msg->findInt32("cseq", (int32_t*)&cseq));
onTimeout(cseq);
break;
}
case kWhatInjectPacket:
{
onInjectPacket(msg);
break;
}
#endif // #ifndef ANDROID_DEFAULT_CODE
default:
TRESPASS();
break;
}
}
示例10: renderBuffer
void NuPlayer::renderBuffer(bool audio, const sp<AMessage> &msg) {
// LOGV("renderBuffer %s", audio ? "audio" : "video");
sp<AMessage> reply;
CHECK(msg->findMessage("reply", &reply));
if (IsFlushingState(audio ? mFlushingAudio : mFlushingVideo)) {
// We're currently attempting to flush the decoder, in order
// to complete this, the decoder wants all its buffers back,
// so we don't want any output buffers it sent us (from before
// we initiated the flush) to be stuck in the renderer's queue.
LOGV("we're still flushing the %s decoder, sending its output buffer"
" right back.", audio ? "audio" : "video");
reply->post();
return;
}
sp<RefBase> obj;
CHECK(msg->findObject("buffer", &obj));
sp<ABuffer> buffer = static_cast<ABuffer *>(obj.get());
int64_t &skipUntilMediaTimeUs =
audio
? mSkipRenderingAudioUntilMediaTimeUs
: mSkipRenderingVideoUntilMediaTimeUs;
if (skipUntilMediaTimeUs >= 0) {
int64_t mediaTimeUs;
CHECK(buffer->meta()->findInt64("timeUs", &mediaTimeUs));
if (mediaTimeUs < skipUntilMediaTimeUs) {
LOGV("dropping %s buffer at time %lld as requested.",
audio ? "audio" : "video",
mediaTimeUs);
reply->post();
return;
}
skipUntilMediaTimeUs = -1;
}
mRenderer->queueBuffer(audio, buffer, reply);
}
示例11: autoLock
bool NuPlayer::Renderer::dropBufferWhileFlushing(
bool audio, const sp<AMessage> &msg) {
bool flushing = false;
{
Mutex::Autolock autoLock(mFlushLock);
if (audio) {
flushing = mFlushingAudio;
} else {
flushing = mFlushingVideo;
}
}
if (!flushing) {
return false;
}
sp<AMessage> notifyConsumed;
if (msg->findMessage("notifyConsumed", ¬ifyConsumed)) {
notifyConsumed->post();
}
return true;
}
示例12: CHECK
void DashPlayer::Decoder::onFillThisBuffer(const sp<AMessage> &msg) {
sp<AMessage> reply;
CHECK(msg->findMessage("reply", &reply));
#if 0
sp<ABuffer> outBuffer;
CHECK(msg->findBuffer("buffer", &outBuffer));
#else
sp<ABuffer> outBuffer;
#endif
if (mCSDIndex < mCSD.size()) {
outBuffer = mCSD.editItemAt(mCSDIndex++);
outBuffer->meta()->setInt64("timeUs", 0);
reply->setBuffer("buffer", outBuffer);
reply->post();
return;
}
sp<AMessage> notify = mNotify->dup();
notify->setMessage("codec-request", msg);
notify->post();
}
示例13: CHECK
void NuPlayer::Renderer::onQueueBuffer(const sp<AMessage> &msg) {
int32_t audio;
CHECK(msg->findInt32("audio", &audio));
if (audio) {
mHasAudio = true;
} else {
mHasVideo = true;
}
if (dropBufferWhileFlushing(audio, msg)) {
return;
}
sp<RefBase> obj;
CHECK(msg->findObject("buffer", &obj));
sp<ABuffer> buffer = static_cast<ABuffer *>(obj.get());
sp<AMessage> notifyConsumed;
CHECK(msg->findMessage("notifyConsumed", ¬ifyConsumed));
QueueEntry entry;
entry.mBuffer = buffer;
entry.mNotifyConsumed = notifyConsumed;
entry.mOffset = 0;
entry.mFinalResult = OK;
if (audio) {
mAudioQueue.push_back(entry);
postDrainAudioQueue();
} else {
mVideoQueue.push_back(entry);
postDrainVideoQueue();
}
if (!mSyncQueues || mAudioQueue.empty() || mVideoQueue.empty()) {
return;
}
sp<ABuffer> firstAudioBuffer = (*mAudioQueue.begin()).mBuffer;
sp<ABuffer> firstVideoBuffer = (*mVideoQueue.begin()).mBuffer;
if (firstAudioBuffer == NULL || firstVideoBuffer == NULL) {
// EOS signalled on either queue.
syncQueuesDone();
return;
}
int64_t firstAudioTimeUs;
int64_t firstVideoTimeUs;
CHECK(firstAudioBuffer->meta()
->findInt64("timeUs", &firstAudioTimeUs));
CHECK(firstVideoBuffer->meta()
->findInt64("timeUs", &firstVideoTimeUs));
int64_t diff = firstVideoTimeUs - firstAudioTimeUs;
ALOGV("queueDiff = %.2f secs", diff / 1E6);
if (diff > 100000ll) {
// Audio data starts More than 0.1 secs before video.
// Drop some audio.
(*mAudioQueue.begin()).mNotifyConsumed->post();
mAudioQueue.erase(mAudioQueue.begin());
return;
}
syncQueuesDone();
}
示例14: onMessageReceived
void MediaPuller::onMessageReceived(const sp<AMessage> &msg) {
switch (msg->what()) {
case kWhatStart:
{
status_t err;
ALOGI("start mIsAudio=%d",mIsAudio);
if (mIsAudio) {
// This atrocity causes AudioSource to deliver absolute
// systemTime() based timestamps (off by 1 us).
#ifdef MTB_SUPPORT
ATRACE_BEGIN_EXT("AudioPuller, kWhatStart");
#endif
sp<MetaData> params = new MetaData;
params->setInt64(kKeyTime, 1ll);
err = mSource->start(params.get());
} else {
#ifdef MTB_SUPPORT
ATRACE_BEGIN_EXT("VideoPuller, kWhatStart");
#endif
err = mSource->start();
if (err != OK) {
ALOGE("source failed to start w/ err %d", err);
}
}
if (err == OK) {
ALOGI("start done, start to schedulePull data");
schedulePull();
}
sp<AMessage> response = new AMessage;
response->setInt32("err", err);
uint32_t replyID;
CHECK(msg->senderAwaitsResponse(&replyID));
response->postReply(replyID);
#ifdef MTB_SUPPORT
ATRACE_END_EXT("VideoPuller, kWhatStart");
#endif
break;
}
case kWhatStop:
{
sp<MetaData> meta = mSource->getFormat();
const char *tmp;
CHECK(meta->findCString(kKeyMIMEType, &tmp));
AString mime = tmp;
ALOGI("MediaPuller(%s) stopping.", mime.c_str());
mSource->stop();
ALOGI("MediaPuller(%s) stopped.", mime.c_str());
++mPullGeneration;
sp<AMessage> notify;
CHECK(msg->findMessage("notify", ¬ify));
notify->post();
break;
}
case kWhatPull:
{
int32_t generation;
#ifdef MTB_SUPPORT
if (mIsAudio) {
ATRACE_BEGIN_EXT("AudioPuller, kWhatPull");
} else {
ATRACE_BEGIN_EXT("VideoPuller, kWhatPull");
}
#endif
CHECK(msg->findInt32("generation", &generation));
if (generation != mPullGeneration) {
break;
}
MediaBuffer *mbuf;
status_t err = mSource->read(&mbuf);
if (mPaused) {
if (err == OK) {
mbuf->release();
mbuf = NULL;
}
schedulePull();
break;
}
if (err != OK) {
if (err == ERROR_END_OF_STREAM) {
ALOGI("stream ended.");
} else {
ALOGE("error %d reading stream.", err);
}
ALOGI("err=%d.post kWhatEOS",err);
sp<AMessage> notify = mNotify->dup();
notify->setInt32("what", kWhatEOS);
//.........这里部分代码省略.........
示例15: onSendRequest
void ARTSPConnection::onSendRequest(const sp<AMessage> &msg) {
sp<AMessage> reply;
CHECK(msg->findMessage("reply", &reply));
if (mState != CONNECTED) {
reply->setInt32("result", -ENOTCONN);
reply->post();
return;
}
AString request;
CHECK(msg->findString("request", &request));
// Just in case we need to re-issue the request with proper authentication
// later, stash it away.
reply->setString("original-request", request.c_str(), request.size());
addAuthentication(&request);
addUserAgent(&request);
// Find the boundary between headers and the body.
ssize_t i = request.find("\r\n\r\n");
CHECK_GE(i, 0);
int32_t cseq = mNextCSeq++;
AString cseqHeader = "CSeq: ";
cseqHeader.append(cseq);
cseqHeader.append("\r\n");
request.insert(cseqHeader, i + 2);
ALOGV("request: '%s'", request.c_str());
size_t numBytesSent = 0;
while (numBytesSent < request.size()) {
ssize_t n =
send(mSocket, request.c_str() + numBytesSent,
request.size() - numBytesSent, 0);
if (n < 0 && errno == EINTR) {
continue;
}
if (n <= 0) {
performDisconnect();
if (n == 0) {
// Server closed the connection.
ALOGE("Server unexpectedly closed the connection.");
reply->setInt32("result", ERROR_IO);
reply->post();
} else {
ALOGE("Error sending rtsp request. (%s)", strerror(errno));
reply->setInt32("result", -errno);
reply->post();
}
return;
}
numBytesSent += (size_t)n;
}
mPendingRequests.add(cseq, reply);
}