From 401c4717b973bfd729513f1b1f0db27c78c48367 Mon Sep 17 00:00:00 2001 From: lu_zero Date: Wed, 25 Jun 2008 09:53:45 +0000 Subject: Move rtsp_close away by simplification - avoids symbol clash with libnemesi git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27135 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/librtsp/rtsp.c | 42 ++++++++++-------------------------------- stream/librtsp/rtsp.h | 1 - stream/librtsp/rtsp_session.c | 23 +++++++++++++++++++++++ 3 files changed, 33 insertions(+), 33 deletions(-) (limited to 'stream') diff --git a/stream/librtsp/rtsp.c b/stream/librtsp/rtsp.c index 16a77f77d5..ca5e16d39b 100644 --- a/stream/librtsp/rtsp.c +++ b/stream/librtsp/rtsp.c @@ -575,14 +575,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; ianswers[i]=NULL; s->scheduled[i]=NULL; } + s->s = fd; s->server=NULL; s->server_state=0; s->server_caps=0; @@ -605,13 +613,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; @@ -631,29 +632,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..352ac7ac82 100644 --- a/stream/librtsp/rtsp.h +++ b/stream/librtsp/rtsp.h @@ -66,7 +66,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..e5ee55893d 100644 --- a/stream/librtsp/rtsp_session.c +++ b/stream/librtsp/rtsp_session.c @@ -73,6 +73,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) { -- cgit v1.2.3 From 4989f301f1685c46015776c5a67741e662f30c6b Mon Sep 17 00:00:00 2001 From: lu_zero Date: Wed, 25 Jun 2008 13:03:18 +0000 Subject: Fix the issue instead of reverting git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27136 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/librtsp/rtsp.c | 58 ------------------------------------------- stream/librtsp/rtsp.h | 53 +++++++++++++++++++++++++++++++++++++++ stream/librtsp/rtsp_session.c | 3 +++ 3 files changed, 56 insertions(+), 58 deletions(-) (limited to 'stream') diff --git a/stream/librtsp/rtsp.c b/stream/librtsp/rtsp.c index ca5e16d39b..30a2987e16 100644 --- a/stream/librtsp/rtsp.c +++ b/stream/librtsp/rtsp.c @@ -33,14 +33,6 @@ #include #include #include "config.h" -#ifndef HAVE_WINSOCK2 -#define closesocket close -#include -#include -#include -#else -#include -#endif #include #include #include @@ -60,56 +52,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 */ diff --git a/stream/librtsp/rtsp.h b/stream/librtsp/rtsp.h index 352ac7ac82..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 /* 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); diff --git a/stream/librtsp/rtsp_session.c b/stream/librtsp/rtsp_session.c index e5ee55893d..d999323fcd 100644 --- a/stream/librtsp/rtsp_session.c +++ b/stream/librtsp/rtsp_session.c @@ -31,12 +31,15 @@ #include #include "config.h" #ifndef HAVE_WINSOCK2 +#define closesocket close #include #include #include #else #include #endif + + #include #include #include -- cgit v1.2.3 From 08c1e65e276f0a3377d6b9db80d79f7e74ec6137 Mon Sep 17 00:00:00 2001 From: vayne Date: Sat, 28 Jun 2008 19:32:35 +0000 Subject: mingw uses Windows sockets. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27141 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/librtsp/rtsp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'stream') diff --git a/stream/librtsp/rtsp.c b/stream/librtsp/rtsp.c index 30a2987e16..932114a762 100644 --- a/stream/librtsp/rtsp.c +++ b/stream/librtsp/rtsp.c @@ -42,7 +42,9 @@ #include #include #include - +#ifdef HAVE_WINSOCK2 +#include +#endif #include "mp_msg.h" #include "rtsp.h" #include "rtsp_session.h" -- cgit v1.2.3 From ec8c4471efea42c46cda1dd59d9baf2a6a4c267e Mon Sep 17 00:00:00 2001 From: nicodvb Date: Sun, 29 Jun 2008 13:14:02 +0000 Subject: removed struct dvdnav_event_t that is 1) unused; 2) has an improper name. You can't turn your back for a second... git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27157 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream_dvdnav.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'stream') diff --git a/stream/stream_dvdnav.h b/stream/stream_dvdnav.h index a7e3c90bd6..0f0a93211e 100644 --- a/stream/stream_dvdnav.h +++ b/stream/stream_dvdnav.h @@ -4,12 +4,6 @@ #include #include "stream.h" -typedef struct { - int event; /* event number fromd dvdnav_events.h */ - void * details; /* event details */ - int len; /* bytes in details */ -} dvdnav_event_t; - typedef struct { uint16_t sx, sy; uint16_t ex, ey; -- cgit v1.2.3 From fddbd849924748088d719d0289b768a493d0be9e Mon Sep 17 00:00:00 2001 From: voroshil Date: Mon, 30 Jun 2008 17:42:35 +0000 Subject: Fix division by zero in tvi_v4l2 which occures when capture device driver (such as uvcvideo USB video driver) does not provide VIDIOC_G_STD ioctl. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27170 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/tvi_v4l2.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'stream') diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c index a13d4c203a..c188da92a4 100644 --- a/stream/tvi_v4l2.c +++ b/stream/tvi_v4l2.c @@ -336,13 +336,23 @@ static int amode2v4l(int amode) } +/* +** Get current FPS. +*/ +static double getfps(priv_t *priv) +{ + if (priv->tv_param->fps > 0) + return priv->tv_param->fps; + if (priv->standard.frameperiod.denominator && priv->standard.frameperiod.numerator) + return (double)priv->standard.frameperiod.denominator / priv->standard.frameperiod.numerator; + return 25.0; +} + // sets and sanitizes audio buffer/block sizes static void setup_audio_buffer_sizes(priv_t *priv) { int bytes_per_sample = priv->audio_in.bytes_per_sample; - double fps = (double)priv->standard.frameperiod.denominator / - priv->standard.frameperiod.numerator; - int seconds = priv->video_buffer_size_max/fps; + int seconds = priv->video_buffer_size_max/getfps(priv); if (seconds < 5) seconds = 5; if (seconds > 500) seconds = 500; @@ -701,6 +711,10 @@ static int control(priv_t *priv, int cmd, void *arg) priv->immediate_mode = 1; return TVI_CONTROL_TRUE; case TVI_CONTROL_VID_GET_FPS: + if (!priv->standard.frameperiod.denominator || !priv->standard.frameperiod.numerator) { + mp_msg(MSGT_TV, MSGL_ERR, "%s: Cannot get fps\n", info.short_name); + return TVI_CONTROL_FALSE; + } *(float *)arg = (float)priv->standard.frameperiod.denominator / priv->standard.frameperiod.numerator; mp_msg(MSGT_TV, MSGL_V, "%s: get fps: %f\n", info.short_name, @@ -1089,11 +1103,7 @@ static int uninit(priv_t *priv) struct v4l2_buffer buf; /* get performance */ - frames = 1 + (priv->curr_frame - priv->first_frame + - priv->standard.frameperiod.numerator * 500000 / - priv->standard.frameperiod.denominator) * - priv->standard.frameperiod.denominator / - priv->standard.frameperiod.numerator / 1000000; + frames = 1 + lrintf((double)(priv->curr_frame - priv->first_frame) / (1e6 * getfps(priv))); dropped = frames - priv->frames; /* turn off streaming */ -- cgit v1.2.3 From 6077530ac232800f17de966a9c5e146c9e6dee54 Mon Sep 17 00:00:00 2001 From: voroshil Date: Mon, 30 Jun 2008 17:46:27 +0000 Subject: Try to get frame rate information through VIDIOC_G_PARM if capture device driver (such as uvcvideo USB video driver) does not provide VIDIOC_G_STD ioctl. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27171 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/tvi_v4l2.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'stream') diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c index c188da92a4..97bce47754 100644 --- a/stream/tvi_v4l2.c +++ b/stream/tvi_v4l2.c @@ -448,6 +448,18 @@ static int getstd(priv_t *priv) int i=0; if (ioctl(priv->video_fd, VIDIOC_G_STD, &id) < 0) { + struct v4l2_streamparm parm; + + parm.type=V4L2_BUF_TYPE_VIDEO_CAPTURE; + if(ioctl(priv->video_fd, VIDIOC_G_PARM, &parm) >= 0) { + mp_msg(MSGT_TV, MSGL_WARN, "%s: your device driver does not support VIDIOC_G_STD ioctl," + " VIDIOC_G_PARM was used instead.\n", info.short_name); + priv->standard.index=0; + priv->standard.id=0; + priv->standard.frameperiod=parm.parm.capture.timeperframe; + return 0; + } + mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get standard failed: %s\n", info.short_name, strerror(errno)); return -1; -- cgit v1.2.3