summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/rtsp
diff options
context:
space:
mode:
authorRoger Jönsson <roger1.jonsson@sonymobile.com>2013-01-17 13:22:31 +0100
committerAndreas Huber <andih@google.com>2013-02-05 10:50:06 -0800
commitec29a2bfb5364a5968b77559fd13821b827d173a (patch)
treedd4c1ae2ccc29d1895921178e6621d4a2c9ee40d /media/libstagefright/rtsp
parent80c1ae8f63cbbd243756caf1533ddbb97244b8b5 (diff)
downloadframeworks_av-ec29a2bfb5364a5968b77559fd13821b827d173a.zip
frameworks_av-ec29a2bfb5364a5968b77559fd13821b827d173a.tar.gz
frameworks_av-ec29a2bfb5364a5968b77559fd13821b827d173a.tar.bz2
Detect live streams
The information is used to decide on visibility of pause button and to handle the duration clock correctly. Change-Id: I286ac992fd171c7fc313e429326d38b6fc80e3fb
Diffstat (limited to 'media/libstagefright/rtsp')
-rw-r--r--media/libstagefright/rtsp/MyHandler.h44
1 files changed, 39 insertions, 5 deletions
diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h
index b7183b1..cdd00e4 100644
--- a/media/libstagefright/rtsp/MyHandler.h
+++ b/media/libstagefright/rtsp/MyHandler.h
@@ -133,7 +133,7 @@ struct MyHandler : public AHandler {
mTryFakeRTCP(false),
mReceivedFirstRTCPPacket(false),
mReceivedFirstRTPPacket(false),
- mSeekable(false),
+ mSeekable(true),
mKeepAliveTimeoutUs(kDefaultKeepAliveTimeoutUs),
mKeepAliveGeneration(0) {
mNetLooper->setName("rtsp net");
@@ -360,6 +360,39 @@ struct MyHandler : public AHandler {
return true;
}
+ static bool isLiveStream(const sp<ASessionDescription> &desc) {
+ AString attrLiveStream;
+ if (desc->findAttribute(0, "a=LiveStream", &attrLiveStream)) {
+ ssize_t semicolonPos = attrLiveStream.find(";", 2);
+
+ const char* liveStreamValue;
+ if (semicolonPos < 0) {
+ liveStreamValue = attrLiveStream.c_str();
+ } else {
+ AString valString;
+ valString.setTo(attrLiveStream,
+ semicolonPos + 1,
+ attrLiveStream.size() - semicolonPos - 1);
+ liveStreamValue = valString.c_str();
+ }
+
+ uint32_t value = strtoul(liveStreamValue, NULL, 10);
+ if (value == 1) {
+ ALOGV("found live stream");
+ return true;
+ }
+ } else {
+ // It is a live stream if no duration is returned
+ int64_t durationUs;
+ if (!desc->getDurationUs(&durationUs)) {
+ ALOGV("No duration found, assume live stream");
+ return true;
+ }
+ }
+
+ return false;
+ }
+
virtual void onMessageReceived(const sp<AMessage> &msg) {
switch (msg->what()) {
case 'conn':
@@ -457,6 +490,8 @@ struct MyHandler : public AHandler {
}
}
+ mSeekable = !isLiveStream(mSessionDesc);
+
if (!mBaseURL.startsWith("rtsp://")) {
// Some misbehaving servers specify a relative
// URL in one of the locations above, combine
@@ -518,6 +553,8 @@ struct MyHandler : public AHandler {
} else {
mBaseURL = mSessionURL;
+ mSeekable = !isLiveStream(mSessionDesc);
+
if (mSessionDesc->countTracks() < 2) {
// There's no actual tracks in this session.
// The first "track" is merely session meta
@@ -783,7 +820,7 @@ struct MyHandler : public AHandler {
mNumAccessUnitsReceived = 0;
mReceivedFirstRTCPPacket = false;
mReceivedFirstRTPPacket = false;
- mSeekable = false;
+ mSeekable = true;
sp<AMessage> reply = new AMessage('tear', id());
@@ -1143,7 +1180,6 @@ struct MyHandler : public AHandler {
}
void parsePlayResponse(const sp<ARTSPResponse> &response) {
- mSeekable = false;
if (mTracks.size() == 0) {
ALOGV("parsePlayResponse: late packets ignored.");
return;
@@ -1218,8 +1254,6 @@ struct MyHandler : public AHandler {
++n;
}
-
- mSeekable = true;
}
sp<MetaData> getTrackFormat(size_t index, int32_t *timeScale) {