live-starttime.patch 6.74 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
diff -ruN live.orig/liveMedia/MediaSession.cpp live/liveMedia/MediaSession.cpp
--- live.orig/liveMedia/MediaSession.cpp	2007-01-17 21:44:26.000000000 +0100
+++ live/liveMedia/MediaSession.cpp	2007-01-22 22:17:54.000000000 +0100
@@ -61,7 +61,7 @@
 MediaSession::MediaSession(UsageEnvironment& env)
   : Medium(env),
     fSubsessionsHead(NULL), fSubsessionsTail(NULL),
-    fConnectionEndpointName(NULL), fMaxPlayEndTime(0.0f),
+    fConnectionEndpointName(NULL), fMaxPlayStartTime(0.0f), fMaxPlayEndTime(0.0f),
     fScale(1.0f), fMediaSessionType(NULL), fSessionName(NULL), fSessionDescription(NULL) {
 #ifdef SUPPORT_REAL_RTSP
   RealInitSDPAttributes(this);
@@ -348,8 +348,8 @@
   return parseSuccess;
 }
 
-static Boolean parseRangeAttribute(char const* sdpLine, float& endTime) {
-  return sscanf(sdpLine, "a=range: npt = %*g - %g", &endTime) == 1;
+static Boolean parseRangeAttribute(char const* sdpLine, float& startTime, float& endTime) {
+  return sscanf(sdpLine, "a=range: npt = %g - %g", &startTime, &endTime) == 2;
 }
 
 Boolean MediaSession::parseSDPAttribute_range(char const* sdpLine) {
@@ -357,9 +357,13 @@
   // (Later handle other kinds of "a=range" attributes also???#####)
   Boolean parseSuccess = False;
 
+  float playStartTime;
   float playEndTime;
-  if (parseRangeAttribute(sdpLine, playEndTime)) {
+  if (parseRangeAttribute(sdpLine, playStartTime, playEndTime)) {
     parseSuccess = True;
+    if (playStartTime != fMaxPlayStartTime && playStartTime >= 0.0f) {
+      fMaxPlayStartTime = playStartTime;
+    }
     if (playEndTime > fMaxPlayEndTime) {
       fMaxPlayEndTime = playEndTime;
     }
@@ -526,7 +530,7 @@
     fSizelength(0), fStreamstateindication(0), fStreamtype(0),
     fCpresent(False), fRandomaccessindication(False),
     fConfig(NULL), fMode(NULL), fSpropParameterSets(NULL),
-    fPlayEndTime(0.0),
+    fPlayStartTime(0.0), fPlayEndTime(0.0),
     fVideoWidth(0), fVideoHeight(0), fVideoFPS(0), fNumChannels(1), fScale(1.0f),
     fRTPSocket(NULL), fRTCPSocket(NULL),
     fRTPSource(NULL), fRTCPInstance(NULL), fReadSource(NULL) {
@@ -548,6 +552,12 @@
 #endif
 }
 
+float MediaSubsession::playStartTime() const {
+  if (fPlayStartTime > 0) return fPlayStartTime;
+
+  return fParent.playStartTime();
+}
+
 float MediaSubsession::playEndTime() const {
   if (fPlayEndTime > 0) return fPlayEndTime;
 
@@ -967,9 +977,16 @@
   // (Later handle other kinds of "a=range" attributes also???#####)
   Boolean parseSuccess = False;
 
+  float playStartTime;
   float playEndTime;
-  if (parseRangeAttribute(sdpLine, playEndTime)) {
+  if (parseRangeAttribute(sdpLine, playStartTime, playEndTime)) {
     parseSuccess = True;
+    if (playStartTime != fPlayStartTime && playStartTime >= 0.0f ) {
+      fPlayStartTime = playStartTime;
+      if (playStartTime != fParent.playStartTime()) {
+	fParent.playStartTime() = playStartTime;
+      }
+    }
     if (playEndTime > fPlayEndTime) {
       fPlayEndTime = playEndTime;
       if (playEndTime > fParent.playEndTime()) {
diff -ruN live.orig/liveMedia/RTSPClient.cpp live/liveMedia/RTSPClient.cpp
--- live.orig/liveMedia/RTSPClient.cpp	2007-01-22 22:17:46.000000000 +0100
+++ live/liveMedia/RTSPClient.cpp	2007-01-22 22:21:12.000000000 +0100
@@ -1128,7 +1128,8 @@
 
       nextLineStart = getLine(lineStart);
 
-      if (parseScaleHeader(lineStart, session.scale())) break;
+      if( parseScaleHeader(lineStart, session.scale())) continue;
+      if( parseRangeHeader(lineStart, session.playStartTime(), session.playEndTime()) ) continue;
     }
 
     if (fTCPStreamIdCount == 0) { // we're not receiving RTP-over-TCP
@@ -1229,6 +1230,7 @@
 	continue;
       }
       if (parseScaleHeader(lineStart, subsession.scale())) continue;
+      //if (parseRangeHeader(lineStart, subsession.playStartTime(), subsession.playEndTime())) continue;
     }
 
     delete[] cmd;
@@ -2287,6 +2289,14 @@
   return radix_safe_sscanf(line, "%f", &scale) == 1;
 }
 
+Boolean RTSPClient::parseRangeHeader(char const* line, float& start, float& end) {
+  if (_strncasecmp(line, "Range: ", 7) != 0) return False;
+  line += 7;
+
+  /* "npt=start-" is also valid */
+  return radix_safe_sscanf(line, "npt = %f - %f", &start, &end) >= 1;
+}
+
 Boolean RTSPClient::parseGetParameterHeader(char const* line, 
                                             const char* param,
                                             char*& value) {
diff -ruN live.orig/liveMedia/include/MediaSession.hh live/liveMedia/include/MediaSession.hh
--- live.orig/liveMedia/include/MediaSession.hh	2007-01-17 21:44:26.000000000 +0100
+++ live/liveMedia/include/MediaSession.hh	2007-01-22 22:20:30.000000000 +0100
@@ -39,6 +39,7 @@
 			      MediaSession*& resultSession);
 
   Boolean hasSubsessions() const { return fSubsessionsHead != NULL; }
+  float& playStartTime() { return fMaxPlayStartTime; }
   float& playEndTime() { return fMaxPlayEndTime; }
   char* connectionEndpointName() const { return fConnectionEndpointName; }
   char const* CNAME() const { return fCNAME; }
@@ -97,6 +98,7 @@
 
   // Fields set from a SDP description:
   char* fConnectionEndpointName;
+  float fMaxPlayStartTime;
   float fMaxPlayEndTime;
   struct in_addr fSourceFilterAddr; // used for SSM
   float fScale; // set from a RTSP "Scale:" header
@@ -147,6 +149,7 @@
     // This is the source that client sinks read from.  It is usually
     // (but not necessarily) the same as "rtpSource()"
 
+  float playStartTime() const;
   float playEndTime() const;
 
   Boolean initiate(int useSpecialRTPoffset = -1);
@@ -268,6 +271,7 @@
   Boolean fCpresent, fRandomaccessindication;
   char *fConfig, *fMode, *fSpropParameterSets;
 
+  float fPlayStartTime;
   float fPlayEndTime;
   unsigned short fVideoWidth, fVideoHeight;
      // screen dimensions (set by an optional a=x-dimensions: <w>,<h> line)
diff -ruN live.orig/liveMedia/include/RTSPClient.hh live/liveMedia/include/RTSPClient.hh
--- live.orig/liveMedia/include/RTSPClient.hh	2007-01-17 21:44:26.000000000 +0100
+++ live/liveMedia/include/RTSPClient.hh	2007-01-22 22:17:54.000000000 +0100
@@ -185,6 +185,7 @@
   Boolean parseRTPInfoHeader(char const* line, unsigned& trackId,
 			     u_int16_t& seqNum, u_int32_t& timestamp);
   Boolean parseScaleHeader(char const* line, float& scale);
+  Boolean parseRangeHeader(char const* line, float& start, float& end);
   Boolean parseGetParameterHeader(char const* line, 
                                   const char* param,
                                   char*& value);
161
162
--- live/liveMedia/include/liveMedia_version.hh.orig	2007-07-25 10:40:46.000000000 +0200
+++ live/liveMedia/include/liveMedia_version.hh	2007-07-27 12:43:32.000000000 +0200
163
@@ -5,6 +5,6 @@
164
165
 #define _LIVEMEDIA_VERSION_HH
 
166
167
 #define LIVEMEDIA_LIBRARY_VERSION_STRING	"2007.07.25"
-#define LIVEMEDIA_LIBRARY_VERSION_INT		1185321600
168
+#define LIVEMEDIA_LIBRARY_VERSION_INT		9999999999
169
170
 
 #endif
171