diff options
author | Andreas Huber <andih@google.com> | 2010-08-05 11:46:04 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-08-05 11:46:04 -0700 |
commit | 982a93173bc84f005172152d823cbb59dfcbeb12 (patch) | |
tree | 2ef94049c4daadc6b4da5a3d6c93c04d99d08d05 /media/libstagefright/rtsp/MyHandler.h | |
parent | aa68b49a53a874a1813e65752663f19d18149e2c (diff) | |
parent | 347d3c1dabd7ae9c998a024c685de2001e0ff369 (diff) | |
download | frameworks_av-982a93173bc84f005172152d823cbb59dfcbeb12.zip frameworks_av-982a93173bc84f005172152d823cbb59dfcbeb12.tar.gz frameworks_av-982a93173bc84f005172152d823cbb59dfcbeb12.tar.bz2 |
am 1f513d88: am c17f35dd: Merge "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." into gingerbread
Merge commit '1f513d8821670a33d6361ea521b6756163a3f9bf'
* commit '1f513d8821670a33d6361ea521b6756163a3f9bf':
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.
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 15901cd..8be8914 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( |