mEncoder->release();
mEncoder.clear();
}
+
+ AString mime;
+ CHECK(mInputFormat->findString("mime", &mime));
+ ALOGI("encoder (%s) shut down.", mime.c_str());
}
status_t Converter::initCheck() const {
const sp<MediaSource> &source, const sp<AMessage> ¬ify)
: mSource(source),
mNotify(notify),
- mPullGeneration(0) {
+ mPullGeneration(0),
+ mIsAudio(false) {
+ sp<MetaData> meta = source->getFormat();
+ const char *mime;
+ CHECK(meta->findCString(kKeyMIMEType, &mime));
+
+ mIsAudio = !strncasecmp(mime, "audio/", 6);
}
MediaPuller::~MediaPuller() {
schedulePull();
}
} else {
+ sp<MetaData> meta = mSource->getFormat();
+ const char *tmp;
+ CHECK(meta->findCString(kKeyMIMEType, &tmp));
+ AString mime = tmp;
+
+ ALOGI("MediaPuller(%s) stopping.", mime.c_str());
err = mSource->stop();
+ ALOGI("MediaPuller(%s) stopped.", mime.c_str());
++mPullGeneration;
}
mbuf->range_length());
accessUnit->meta()->setInt64("timeUs", timeUs);
- accessUnit->meta()->setPointer("mediaBuffer", mbuf);
+
+ if (mIsAudio) {
+ mbuf->release();
+ mbuf = NULL;
+ } else {
+ // video encoder will release MediaBuffer when done
+ // with underlying data.
+ accessUnit->meta()->setPointer("mediaBuffer", mbuf);
+ }
sp<AMessage> notify = mNotify->dup();
sp<MediaSource> mSource;
sp<AMessage> mNotify;
int32_t mPullGeneration;
+ bool mIsAudio;
status_t postSynchronouslyAndReturnError(const sp<AMessage> &msg);
void schedulePull();
err = mMediaPuller->stop();
}
+ mConverter.clear();
+
mStarted = false;
return err;
mLogFile = NULL;
}
#endif
-
- mTracks.clear();
-
- mPacketizer.clear();
-
- if (mSerializer != NULL) {
- mSerializer->stop();
-
- looper()->unregisterHandler(mSerializer->id());
- mSerializer.clear();
- }
-
- mTracks.clear();
-
- if (mSerializerLooper != NULL) {
- mSerializerLooper->stop();
- mSerializerLooper.clear();
- }
-
- if (mLegacyMode) {
- sp<IServiceManager> sm = defaultServiceManager();
- sp<IBinder> binder = sm->getService(String16("SurfaceFlinger"));
- sp<ISurfaceComposer> service = interface_cast<ISurfaceComposer>(binder);
- CHECK(service != NULL);
-
- service->connectDisplay(NULL);
- }
-
- if (mRTCPSessionID != 0) {
- mNetSession->destroySession(mRTCPSessionID);
- }
-
- if (mRTPSessionID != 0) {
- mNetSession->destroySession(mRTPSessionID);
- }
}
int32_t WifiDisplaySource::PlaybackSession::getRTPPort() const {
return OK;
}
+status_t WifiDisplaySource::PlaybackSession::destroy() {
+ mTracks.clear();
+
+ mPacketizer.clear();
+
+ if (mSerializer != NULL) {
+ mSerializer->stop();
+
+ looper()->unregisterHandler(mSerializer->id());
+ mSerializer.clear();
+ }
+
+ mTracks.clear();
+
+ if (mSerializerLooper != NULL) {
+ mSerializerLooper->stop();
+ mSerializerLooper.clear();
+ }
+
+ if (mLegacyMode) {
+ sp<IServiceManager> sm = defaultServiceManager();
+ sp<IBinder> binder = sm->getService(String16("SurfaceFlinger"));
+ sp<ISurfaceComposer> service = interface_cast<ISurfaceComposer>(binder);
+ CHECK(service != NULL);
+
+ service->connectDisplay(NULL);
+ }
+
+ if (mRTCPSessionID != 0) {
+ mNetSession->destroySession(mRTCPSessionID);
+ }
+
+ if (mRTPSessionID != 0) {
+ mNetSession->destroySession(mRTPSessionID);
+ }
+
+ return OK;
+}
+
void WifiDisplaySource::PlaybackSession::onMessageReceived(
const sp<AMessage> &msg) {
switch (msg->what()) {
const char *clientIP, int32_t clientRtp, int32_t clientRtcp,
bool useInterleavedTCP);
+ status_t destroy();
+
int32_t getRTPPort() const;
int64_t getLastLifesignUs() const;
CHECK(msg->senderAwaitsResponse(&replyID));
for (size_t i = mPlaybackSessions.size(); i-- > 0;) {
- const sp<PlaybackSession> &playbackSession =
+ sp<PlaybackSession> playbackSession =
mPlaybackSessions.valueAt(i);
- looper()->unregisterHandler(playbackSession->id());
mPlaybackSessions.removeItemsAt(i);
+
+ playbackSession->destroy();
+ looper()->unregisterHandler(playbackSession->id());
+ playbackSession.clear();
}
if (mClient != NULL) {
const ClientInfo &info = mClientInfos.valueFor(sessionID);
request.append(StringPrintf("Session: %d\r\n", info.mPlaybackSessionID));
-
- request.append("Content-Length: 0\r\n");
- request.append("\r\n");
+ request.append("\r\n"); // Empty body
status_t err =
mNetSession->sendRequest(sessionID, request.c_str(), request.size());
return;
}
#if 1
- // The LG dongle doesn't specify client_port=xxx apparently.
+ // The older LG dongles doesn't specify client_port=xxx apparently.
} else if (transport == "RTP/AVP/UDP;unicast") {
clientRtp = 19000;
clientRtcp = clientRtp + 1;
int32_t cseq,
const sp<ParsedMessage> &data) {
int32_t playbackSessionID;
-#if 0
- // XXX the dongle does not include a "Session:" header in this request.
sp<PlaybackSession> playbackSession =
findPlaybackSession(data, &playbackSessionID);
+#if 1
+ // XXX the older dongles do not include a "Session:" header in this request.
+ if (playbackSession == NULL) {
+ CHECK_EQ(mPlaybackSessions.size(), 1u);
+ playbackSessionID = mPlaybackSessions.keyAt(0);
+ playbackSession = mPlaybackSessions.valueAt(0);
+ }
+#else
if (playbackSession == NULL) {
sendErrorResponse(sessionID, "454 Session Not Found", cseq);
return;
}
-#else
- CHECK_EQ(mPlaybackSessions.size(), 1u);
- playbackSessionID = mPlaybackSessions.keyAt(0);
- sp<PlaybackSession> playbackSession = mPlaybackSessions.valueAt(0);
#endif
playbackSession->updateLiveness();