summaryrefslogtreecommitdiffstats
path: root/stream/librtsp
diff options
context:
space:
mode:
authorUoti Urpala <uau@symbol.nonexistent.invalid>2008-07-01 16:18:21 +0300
committerUoti Urpala <uau@symbol.nonexistent.invalid>2008-07-01 16:18:21 +0300
commit7de350c673e1c0ae52d655e322a072f2f6b624b0 (patch)
tree346005084450b679f57c77daad2263fcdcf9e1de /stream/librtsp
parent28fbfd2cdea5ffa860a251de274a74b0e85c88f0 (diff)
parent3ff9a6e7d82ff9a5231e561bd2686fab7df97f68 (diff)
downloadmpv-7de350c673e1c0ae52d655e322a072f2f6b624b0.tar.bz2
mpv-7de350c673e1c0ae52d655e322a072f2f6b624b0.tar.xz
Merge svn changes up to r27184
Diffstat (limited to 'stream/librtsp')
-rw-r--r--stream/librtsp/rtsp.c104
-rw-r--r--stream/librtsp/rtsp.h54
-rw-r--r--stream/librtsp/rtsp_session.c26
3 files changed, 92 insertions, 92 deletions
diff --git a/stream/librtsp/rtsp.c b/stream/librtsp/rtsp.c
index 16a77f77d5..932114a762 100644
--- a/stream/librtsp/rtsp.c
+++ b/stream/librtsp/rtsp.c
@@ -33,14 +33,6 @@
#include <stdio.h>
#include <assert.h>
#include "config.h"
-#ifndef HAVE_WINSOCK2
-#define closesocket close
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#else
-#include <winsock2.h>
-#endif
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -50,7 +42,9 @@
#include <sys/time.h>
#include <sys/types.h>
#include <inttypes.h>
-
+#ifdef HAVE_WINSOCK2
+#include <winsock2.h>
+#endif
#include "mp_msg.h"
#include "rtsp.h"
#include "rtsp_session.h"
@@ -60,56 +54,6 @@
#define LOG
*/
-#define BUF_SIZE 4096
-#define HEADER_SIZE 1024
-#define MAX_FIELDS 256
-
-struct rtsp_s {
-
- int s;
-
- char *host;
- int port;
- char *path;
- char *param;
- char *mrl;
- char *user_agent;
-
- char *server;
- unsigned int server_state;
- uint32_t server_caps;
-
- unsigned int cseq;
- char *session;
-
- char *answers[MAX_FIELDS]; /* data of last message */
- char *scheduled[MAX_FIELDS]; /* will be sent with next message */
-};
-
-/*
- * constants
- */
-
-#define RTSP_PROTOCOL_VERSION "RTSP/1.0"
-
-/* server states */
-#define RTSP_CONNECTED 1
-#define RTSP_INIT 2
-#define RTSP_READY 4
-#define RTSP_PLAYING 8
-#define RTSP_RECORDING 16
-
-/* server capabilities */
-#define RTSP_OPTIONS 0x001
-#define RTSP_DESCRIBE 0x002
-#define RTSP_ANNOUNCE 0x004
-#define RTSP_SETUP 0x008
-#define RTSP_GET_PARAMETER 0x010
-#define RTSP_SET_PARAMETER 0x020
-#define RTSP_TEARDOWN 0x040
-#define RTSP_PLAY 0x080
-#define RTSP_RECORD 0x100
-
/*
* network utilities
*/
@@ -575,14 +519,22 @@ int rtsp_read_data(rtsp_t *s, char *buffer, unsigned int size) {
//rtsp_t *rtsp_connect(const char *mrl, const char *user_agent) {
rtsp_t *rtsp_connect(int fd, char* mrl, char *path, char *host, int port, char *user_agent) {
- rtsp_t *s=malloc(sizeof(rtsp_t));
+ rtsp_t *s;
int i;
-
+
+ if (fd < 0) {
+ mp_msg(MSGT_OPEN, MSGL_ERR, "rtsp: failed to connect to '%s'\n", host);
+ return NULL;
+ }
+
+ s = malloc(sizeof(rtsp_t));
+
for (i=0; i<MAX_FIELDS; i++) {
s->answers[i]=NULL;
s->scheduled[i]=NULL;
}
+ s->s = fd;
s->server=NULL;
s->server_state=0;
s->server_caps=0;
@@ -605,13 +557,6 @@ rtsp_t *rtsp_connect(int fd, char* mrl, char *path, char *host, int port, char *
s->param++;
//mp_msg(MSGT_OPEN, MSGL_INFO, "path=%s\n", s->path);
//mp_msg(MSGT_OPEN, MSGL_INFO, "param=%s\n", s->param ? s->param : "NULL");
- s->s = fd;
-
- if (s->s < 0) {
- mp_msg(MSGT_OPEN, MSGL_ERR, "rtsp: failed to connect to '%s'\n", s->host);
- rtsp_close(s);
- return NULL;
- }
s->server_state=RTSP_CONNECTED;
@@ -632,29 +577,6 @@ rtsp_t *rtsp_connect(int fd, char* mrl, char *path, char *host, int port, char *
/*
- * closes an rtsp connection
- */
-
-void rtsp_close(rtsp_t *s) {
-
- if (s->server_state)
- {
- if (s->server_state == RTSP_PLAYING)
- rtsp_request_teardown (s, NULL);
- closesocket (s->s);
- }
-
- if (s->path) free(s->path);
- if (s->host) free(s->host);
- if (s->mrl) free(s->mrl);
- if (s->session) free(s->session);
- if (s->user_agent) free(s->user_agent);
- rtsp_free_answers(s);
- rtsp_unschedule_all(s);
- free(s);
-}
-
-/*
* search in answers for tags. returns a pointer to the content
* after the first matched tag. returns NULL if no match found.
*/
diff --git a/stream/librtsp/rtsp.h b/stream/librtsp/rtsp.h
index 528dacaa42..efca1f7779 100644
--- a/stream/librtsp/rtsp.h
+++ b/stream/librtsp/rtsp.h
@@ -32,6 +32,7 @@
#ifndef MPLAYER_RTSP_H
#define MPLAYER_RTSP_H
+#include <inttypes.h>
/* some codes returned by rtsp_request_* functions */
@@ -45,6 +46,58 @@
#define RTSP_METHOD_TEARDOWN "TEARDOWN"
#define RTSP_METHOD_SET_PARAMETER "SET_PARAMETER"
+#define BUF_SIZE 4096
+#define HEADER_SIZE 1024
+#define MAX_FIELDS 256
+
+
+struct rtsp_s {
+
+ int s;
+
+ char *host;
+ int port;
+ char *path;
+ char *param;
+ char *mrl;
+ char *user_agent;
+
+ char *server;
+ unsigned int server_state;
+ uint32_t server_caps;
+
+ unsigned int cseq;
+ char *session;
+
+ char *answers[MAX_FIELDS]; /* data of last message */
+ char *scheduled[MAX_FIELDS]; /* will be sent with next message */
+};
+
+/*
+ * constants
+ */
+
+#define RTSP_PROTOCOL_VERSION "RTSP/1.0"
+
+/* server states */
+#define RTSP_CONNECTED 1
+#define RTSP_INIT 2
+#define RTSP_READY 4
+#define RTSP_PLAYING 8
+#define RTSP_RECORDING 16
+
+/* server capabilities */
+#define RTSP_OPTIONS 0x001
+#define RTSP_DESCRIBE 0x002
+#define RTSP_ANNOUNCE 0x004
+#define RTSP_SETUP 0x008
+#define RTSP_GET_PARAMETER 0x010
+#define RTSP_SET_PARAMETER 0x020
+#define RTSP_TEARDOWN 0x040
+#define RTSP_PLAY 0x080
+#define RTSP_RECORD 0x100
+
+
typedef struct rtsp_s rtsp_t;
rtsp_t* rtsp_connect (int fd, char *mrl, char *path, char *host, int port, char *user_agent);
@@ -66,7 +119,6 @@ void rtsp_add_to_payload(char **payload, const char *string);
void rtsp_free_answers(rtsp_t *this);
int rtsp_read (rtsp_t *this, char *data, int len);
-void rtsp_close (rtsp_t *this);
void rtsp_set_session(rtsp_t *s, const char *id);
char *rtsp_get_session(rtsp_t *s);
diff --git a/stream/librtsp/rtsp_session.c b/stream/librtsp/rtsp_session.c
index a3559212b2..d999323fcd 100644
--- a/stream/librtsp/rtsp_session.c
+++ b/stream/librtsp/rtsp_session.c
@@ -31,12 +31,15 @@
#include <sys/types.h>
#include "config.h"
#ifndef HAVE_WINSOCK2
+#define closesocket close
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#else
#include <winsock2.h>
#endif
+
+
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
@@ -73,6 +76,29 @@ struct rtsp_session_s {
struct rtp_rtsp_session_t* rtp_session;
};
+/*
+ * closes an rtsp connection
+ */
+
+static void rtsp_close(rtsp_t *s) {
+
+ if (s->server_state)
+ {
+ if (s->server_state == RTSP_PLAYING)
+ rtsp_request_teardown (s, NULL);
+ closesocket (s->s);
+ }
+
+ if (s->path) free(s->path);
+ if (s->host) free(s->host);
+ if (s->mrl) free(s->mrl);
+ if (s->session) free(s->session);
+ if (s->user_agent) free(s->user_agent);
+ rtsp_free_answers(s);
+ rtsp_unschedule_all(s);
+ free(s);
+}
+
//rtsp_session_t *rtsp_session_start(char *mrl) {
rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host,
int port, int *redir, uint32_t bandwidth, char *user, char *pass) {