diff options
author | Andreas Huber <andih@google.com> | 2010-08-04 10:14:30 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-08-04 11:49:24 -0700 |
commit | 39ddf8e0f18766f7ba1e3246b774aa6ebd93eea8 (patch) | |
tree | 87f5d0d68c1779f113843e939c41440ff6b00389 /media/libstagefright/rtsp/MyHandler.h | |
parent | 610959a52fe22a88e50d158f5f5f492fee4f1921 (diff) | |
download | frameworks_av-39ddf8e0f18766f7ba1e3246b774aa6ebd93eea8.zip frameworks_av-39ddf8e0f18766f7ba1e3246b774aa6ebd93eea8.tar.gz frameworks_av-39ddf8e0f18766f7ba1e3246b774aa6ebd93eea8.tar.bz2 |
Support for Gtalk video, includes AMR/H.263 assembler and packetization support, extensions to MediaRecorder to stream via RTP over a pair of UDP sockets as well as various fixes to the RTP implementation.
Change-Id: I95b8dd487061add9bade15749e563b01cd99d9a6
Diffstat (limited to 'media/libstagefright/rtsp/MyHandler.h')
-rw-r--r-- | media/libstagefright/rtsp/MyHandler.h | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h index 044393f..f21c8dc 100644 --- a/media/libstagefright/rtsp/MyHandler.h +++ b/media/libstagefright/rtsp/MyHandler.h @@ -38,9 +38,7 @@ struct MyHandler : public AHandler { mConn(new ARTSPConnection), mRTPConn(new ARTPConnection), mSessionURL(url), - mSetupTracksSuccessful(false), - mFirstAccessUnit(true), - mFirstAccessUnitNTP(-1) { + mSetupTracksSuccessful(false) { mNetLooper->start(false /* runOnCallingThread */, false /* canCallJava */, @@ -161,8 +159,11 @@ struct MyHandler : public AHandler { size_t index; CHECK(msg->findSize("index", &index)); + TrackInfo *track = NULL; size_t trackIndex; - CHECK(msg->findSize("track-index", &trackIndex)); + if (msg->findSize("track-index", &trackIndex)) { + track = &mTracks.editItemAt(trackIndex); + } int32_t result; CHECK(msg->findInt32("result", &result)); @@ -170,9 +171,16 @@ struct MyHandler : public AHandler { LOG(INFO) << "SETUP(" << index << ") completed with result " << result << " (" << strerror(-result) << ")"; - TrackInfo *track = &mTracks.editItemAt(trackIndex); + if (result != OK) { + if (track) { + close(track->mRTPSocket); + close(track->mRTCPSocket); + + mTracks.removeItemsAt(trackIndex); + } + } else { + CHECK(track != NULL); - if (result == OK) { sp<RefBase> obj; CHECK(msg->findObject("response", &obj)); sp<ARTSPResponse> response = @@ -200,24 +208,13 @@ struct MyHandler : public AHandler { mSessionDesc, index, notify); - track->mPacketSource = - new APacketSource(mSessionDesc, index); - mSetupTracksSuccessful = true; - - ++index; - if (index < mSessionDesc->countTracks()) { - setupTrack(index); - break; - } - } else { - close(track->mRTPSocket); - close(track->mRTCPSocket); - - mTracks.removeItemsAt(mTracks.size() - 1); } - if (mSetupTracksSuccessful) { + ++index; + if (index < mSessionDesc->countTracks()) { + setupTrack(index); + } else if (mSetupTracksSuccessful) { AString request = "PLAY "; request.append(mSessionURL); request.append(" RTSP/1.0\r\n"); @@ -321,16 +318,6 @@ struct MyHandler : public AHandler { CHECK(accessUnit->meta()->findInt64( "ntp-time", (int64_t *)&ntpTime)); - if (mFirstAccessUnit) { - mFirstAccessUnit = false; - mFirstAccessUnitNTP = ntpTime; - } - if (ntpTime > mFirstAccessUnitNTP) { - ntpTime -= mFirstAccessUnitNTP; - } else { - ntpTime = 0; - } - accessUnit->meta()->setInt64("ntp-time", ntpTime); #if 0 @@ -374,8 +361,6 @@ private: AString mBaseURL; AString mSessionID; bool mSetupTracksSuccessful; - bool mFirstAccessUnit; - uint64_t mFirstAccessUnitNTP; struct TrackInfo { int mRTPSocket; @@ -386,6 +371,19 @@ private: Vector<TrackInfo> mTracks; void setupTrack(size_t index) { + sp<APacketSource> source = + new APacketSource(mSessionDesc, index); + if (source->initCheck() != OK) { + LOG(WARNING) << "Unsupported format. Ignoring track #" + << index << "."; + + sp<AMessage> reply = new AMessage('setu', id()); + reply->setSize("index", index); + reply->setInt32("result", ERROR_UNSUPPORTED); + reply->post(); + return; + } + AString url; CHECK(mSessionDesc->findAttribute(index, "a=control", &url)); @@ -394,6 +392,7 @@ private: mTracks.push(TrackInfo()); TrackInfo *info = &mTracks.editItemAt(mTracks.size() - 1); + info->mPacketSource = source; unsigned rtpPort; ARTPConnection::MakePortPair( |