1
1
/*
2
- * Copyright (C) 2011-2014 GUIGUI Simon, [email protected]
2
+ * Copyright (C) 2011-2015 GUIGUI Simon, [email protected]
3
3
*
4
4
* This file is part of Spydroid (http://code.google.com/p/spydroid-ipcamera/)
5
5
*
@@ -186,9 +186,9 @@ public void setServerAddress(String host, int port) {
186
186
}
187
187
188
188
/**
189
- * If authentication is enabled on the server, you need to call this with a valid username /password pair.
189
+ * If authentication is enabled on the server, you need to call this with a valid login /password pair.
190
190
* Only implements Digest Access Authentication according to RFC 2069.
191
- * @param username The username
191
+ * @param username The login
192
192
* @param password The password
193
193
*/
194
194
public void setCredentials (String username , String password ) {
@@ -219,7 +219,7 @@ public boolean isStreaming() {
219
219
220
220
/**
221
221
* Connects to the RTSP server to publish the stream, and the effectively starts streaming.
222
- * You need to call {@link #setServerAddress(String, int)} and optionnally {@link #setSession(Session)}
222
+ * You need to call {@link #setServerAddress(String, int)} and optionally {@link #setSession(Session)}
223
223
* and {@link #setCredentials(String, String)} before calling this.
224
224
* Should be called of the main thread !
225
225
*/
@@ -323,7 +323,7 @@ private void sendRequestAnnounce() throws IllegalStateException, SocketException
323
323
String request = "ANNOUNCE rtsp://" +mParameters .host +":" +mParameters .port +mParameters .path +" RTSP/1.0\r \n " +
324
324
"CSeq: " + (++mCSeq ) + "\r \n " +
325
325
"Content-Length: " + body .length () + "\r \n " +
326
- "Content-Type: application/sdp \r \n \r \n " +
326
+ "Content-Type: application/sdp\r \n \r \n " +
327
327
body ;
328
328
Log .i (TAG ,request .substring (0 , request .indexOf ("\r \n " )));
329
329
@@ -337,12 +337,14 @@ private void sendRequestAnnounce() throws IllegalStateException, SocketException
337
337
Log .v (TAG ,"RTSP server name unknown" );
338
338
}
339
339
340
- try {
341
- Matcher m = Response .rexegSession .matcher (response .headers .get ("session" ));
342
- m .find ();
343
- mSessionID = m .group (1 );
344
- } catch (Exception e ) {
345
- throw new IOException ("Invalid response from server. Session id: " +mSessionID );
340
+ if (response .headers .containsKey ("session" )) {
341
+ try {
342
+ Matcher m = Response .rexegSession .matcher (response .headers .get ("session" ));
343
+ m .find ();
344
+ mSessionID = m .group (1 );
345
+ } catch (Exception e ) {
346
+ throw new IOException ("Invalid response from server. Session id: " +mSessionID );
347
+ }
346
348
}
347
349
348
350
if (response .status == 401 ) {
@@ -371,7 +373,7 @@ private void sendRequestAnnounce() throws IllegalStateException, SocketException
371
373
"Content-Length: " + body .length () + "\r \n " +
372
374
"Authorization: " + mAuthorization + "\r \n " +
373
375
"Session: " + mSessionID + "\r \n " +
374
- "Content-Type: application/sdp \r \n \r \n " +
376
+ "Content-Type: application/sdp\r \n \r \n " +
375
377
body ;
376
378
377
379
Log .i (TAG ,request .substring (0 , request .indexOf ("\r \n " )));
@@ -407,6 +409,17 @@ private void sendRequestSetup() throws IllegalStateException, SocketException, I
407
409
mOutputStream .flush ();
408
410
Response response = Response .parseResponse (mBufferedReader );
409
411
Matcher m ;
412
+
413
+ if (response .headers .containsKey ("session" )) {
414
+ try {
415
+ m = Response .rexegSession .matcher (response .headers .get ("session" ));
416
+ m .find ();
417
+ mSessionID = m .group (1 );
418
+ } catch (Exception e ) {
419
+ throw new IOException ("Invalid response from server. Session id: " +mSessionID );
420
+ }
421
+ }
422
+
410
423
if (mParameters .transport == TRANSPORT_UDP ) {
411
424
try {
412
425
m = Response .rexegTransport .matcher (response .headers .get ("transport" )); m .find ();
0 commit comments