summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Ciccani <klan@users.sourceforge.net>2007-01-09 20:50:59 +0000
committerClaudio Ciccani <klan@users.sourceforge.net>2007-01-09 20:50:59 +0000
commitfbabd49f7b8a90c111833fa2627473146d60de2e (patch)
treec5b6133ca38f113a3d597cbb3bf8d6729d8a9371
parent639fe2bde8fa8dda1571b91adba193c6a52dce18 (diff)
downloadxine-lib-fbabd49f7b8a90c111833fa2627473146d60de2e.tar.gz
xine-lib-fbabd49f7b8a90c111833fa2627473146d60de2e.tar.bz2
Support setting the start time over MMSH protocol.
CVS patchset: 8494 CVS date: 2007/01/09 20:50:59
-rw-r--r--src/input/input_mms.c9
-rw-r--r--src/input/mmsh.c118
-rw-r--r--src/input/mmsh.h6
3 files changed, 84 insertions, 49 deletions
diff --git a/src/input/input_mms.c b/src/input/input_mms.c
index 6ef256ea3..5704e78b6 100644
--- a/src/input/input_mms.c
+++ b/src/input/input_mms.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: input_mms.c,v 1.65 2007/01/03 15:09:42 klan Exp $
+ * $Id: input_mms.c,v 1.66 2007/01/09 20:50:59 klan Exp $
*
* mms input plugin based on work from major mms
*/
@@ -214,6 +214,8 @@ static off_t mms_plugin_seek_time (input_plugin_t *this_gen, int time_offset, in
curpos = mms_get_current_pos (this->mms);
break;
case PROTOCOL_MMSH:
+ if (origin == SEEK_SET)
+ mmsh_set_start_time (this->mmsh, time_offset);
curpos = mmsh_get_current_pos (this->mmsh);
break;
}
@@ -376,10 +378,6 @@ static int mms_plugin_open (input_plugin_t *this_gen) {
this->mms = mms;
this->mmsh = mmsh;
- if (this->protocol == PROTOCOL_MMST) {
- this->input_plugin.seek_time = mms_plugin_seek_time;
- }
-
return 1;
}
@@ -424,6 +422,7 @@ static input_plugin_t *mms_class_get_instance (input_class_t *cls_gen, xine_stre
this->input_plugin.read = mms_plugin_read;
this->input_plugin.read_block = mms_plugin_read_block;
this->input_plugin.seek = mms_plugin_seek;
+ this->input_plugin.seek_time = mms_plugin_seek_time;
this->input_plugin.get_current_pos = mms_plugin_get_current_pos;
this->input_plugin.get_length = mms_plugin_get_length;
this->input_plugin.get_blocksize = mms_plugin_get_blocksize;
diff --git a/src/input/mmsh.c b/src/input/mmsh.c
index 889596cf7..cf8ab8a6b 100644
--- a/src/input/mmsh.c
+++ b/src/input/mmsh.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: mmsh.c,v 1.40 2006/11/11 00:05:22 dgp85 Exp $
+ * $Id: mmsh.c,v 1.41 2007/01/09 20:50:59 klan Exp $
*
* MMS over HTTP protocol
* written by Thibaut Mattern
@@ -99,7 +99,7 @@
"Pragma: no-cache,rate=1.000000,stream-time=%u,stream-offset=%u:%u,request-context=%u,max-duration=%u\r\n" \
CLIENTGUID \
"Pragma: xPlayStrm=1\r\n" \
- "Pragma: stream-switch-coun t=%d\r\n" \
+ "Pragma: stream-switch-count=%d\r\n" \
"Pragma: stream-switch-entry=%s\r\n" /* ffff:1:0 ffff:2:0 */ \
"Connection: Close\r\n\r\n"
@@ -180,9 +180,15 @@ struct mmsh_s {
uint32_t asf_header_len;
uint32_t asf_header_read;
int seq_num;
+
+ int video_stream;
+ int audio_stream;
off_t current_pos;
- int user_bandwitdh;
+ int user_bandwidth;
+
+ int playing;
+ unsigned int start_time;
};
static int send_command (mmsh_t *this, char *cmd) {
@@ -382,7 +388,6 @@ static int get_header (mmsh_t *this) {
lprintf("get_header\n");
this->asf_header_len = 0;
- this->asf_header_read = 0;
/* read chunk */
while (1) {
@@ -514,13 +519,10 @@ static int mmsh_tcp_connect(mmsh_t *this) {
return 0;
}
-
+/*
+ * firts http request
+ */
static int mmsh_connect_int(mmsh_t *this, int bandwidth) {
- int i;
- char stream_selection[10 * ASF_MAX_NUM_STREAMS]; /* 10 chars per stream */
- int offset;
- int audio_stream, video_stream;
-
/*
* let the negotiations begin...
*/
@@ -532,29 +534,44 @@ static int mmsh_connect_int(mmsh_t *this, int bandwidth) {
this->host, this->port, 1);
if (!send_command (this, this->str))
- goto fail;
+ return 0;
if (!get_answer (this))
- goto fail;
+ return 0;
- get_header(this); /* FIXME: it returns 0 */
+ get_header (this); /* FIXME: it returns 0 */
- if (!interp_header(this))
- goto fail;
+ if (!interp_header (this))
+ return 0;
- close(this->s);
+ close (this->s);
report_progress (this->stream, 20);
- asf_header_choose_streams (this->asf_header, bandwidth, &video_stream, &audio_stream);
+ asf_header_choose_streams (this->asf_header, bandwidth,
+ &this->video_stream, &this->audio_stream);
- lprintf("audio stream %d, video stream %d\n", audio_stream, video_stream);
+ lprintf("audio stream %d, video stream %d\n",
+ this->audio_stream, this->video_stream);
+
+ asf_header_disable_streams (this->asf_header,
+ this->video_stream, this->audio_stream);
+
+ return 1;
+}
+
+/*
+ * second http request
+ */
+static int mmsh_connect_int2(mmsh_t *this, int bandwidth) {
+ int i;
+ char stream_selection[10 * ASF_MAX_NUM_STREAMS]; /* 10 chars per stream */
+ int offset;
/* second request */
lprintf("second http request\n");
-
- if (mmsh_tcp_connect(this)) {
- goto fail;
- }
+
+ if (mmsh_tcp_connect(this))
+ return 0;
/* stream selection string */
/* The same selection is done with mmst */
@@ -563,8 +580,8 @@ static int mmsh_connect_int(mmsh_t *this, int bandwidth) {
offset = 0;
for (i = 0; i < this->asf_header->stream_count; i++) {
int size;
- if ((i == audio_stream) ||
- (i == video_stream)) {
+ if ((i == this->audio_stream) ||
+ (i == this->video_stream)) {
size = snprintf(stream_selection + offset, sizeof(stream_selection) - offset,
"ffff:%d:0 ", this->asf_header->streams[i]->stream_number);
} else {
@@ -573,14 +590,15 @@ static int mmsh_connect_int(mmsh_t *this, int bandwidth) {
size = snprintf(stream_selection + offset, sizeof(stream_selection) - offset,
"ffff:%d:2 ", this->asf_header->streams[i]->stream_number);
}
- if (size < 0) goto fail;
+ if (size < 0)
+ return 0;
offset += size;
}
switch (this->stream_type) {
case MMSH_SEEKABLE:
snprintf (this->str, SCRATCH_SIZE, mmsh_SeekableRequest, this->uri,
- this->host, this->port, 0, 0, 0, 2, 0,
+ this->host, this->port, this->start_time, 0, 0, 2, 0,
this->asf_header->stream_count, stream_selection);
break;
case MMSH_LIVE:
@@ -591,25 +609,25 @@ static int mmsh_connect_int(mmsh_t *this, int bandwidth) {
}
if (!send_command (this, this->str))
- goto fail;
+ return 0;
lprintf("before read \n");
if (!get_answer (this))
- goto fail;
-
- if (!get_header(this))
- goto fail;
-
- if (!interp_header(this))
- goto fail;
+ return 0;
- asf_header_disable_streams (this->asf_header, video_stream, audio_stream);
+ if (!get_header (this))
+ return 0;
+
+#if 0
+ if (!interp_header (this))
+ return 0;
+
+ asf_header_disable_streams (this->asf_header,
+ this->video_stream, this->audio_stream);
+#endif
return 1;
-
-fail:
- return 0;
}
mmsh_t *mmsh_connect (xine_stream_t *stream, const char *url, int bandwidth) {
@@ -630,7 +648,7 @@ mmsh_t *mmsh_connect (xine_stream_t *stream, const char *url, int bandwidth) {
this->buf_size = 0;
this->buf_read = 0;
this->current_pos = 0;
- this->user_bandwitdh = bandwidth;
+ this->user_bandwidth = bandwidth;
report_progress (stream, 0);
@@ -650,7 +668,7 @@ mmsh_t *mmsh_connect (xine_stream_t *stream, const char *url, int bandwidth) {
report_progress (stream, 30);
- if (!mmsh_connect_int(this, this->user_bandwitdh))
+ if (!mmsh_connect_int(this, this->user_bandwidth))
goto fail;
report_progress (stream, 100);
@@ -709,8 +727,10 @@ static int get_media_packet (mmsh_t *this) {
if (mmsh_tcp_connect(this))
return 0;
- if (!mmsh_connect_int(this, this->user_bandwitdh))
+ if (!mmsh_connect_int(this, this->user_bandwidth))
return 0;
+
+ this->playing = 0;
/* mmsh_connect_int reads the first data packet */
/* this->buf_size is set by mmsh_connect_int */
@@ -784,7 +804,7 @@ int mmsh_read (mmsh_t *this, char *data, int len) {
if (this->asf_header_read < this->asf_header_len) {
int n, bytes_left ;
- bytes_left = this->asf_header_len - this->asf_header_read ;
+ bytes_left = this->asf_header_len - this->asf_header_read;
if ((len-total) < bytes_left)
n = len-total;
@@ -796,9 +816,18 @@ int mmsh_read (mmsh_t *this, char *data, int len) {
this->asf_header_read += n;
total += n;
this->current_pos += n;
+
+ if (this->asf_header_read == this->asf_header_len)
+ break;
} else {
int n, bytes_left ;
+
+ if (!this->playing) {
+ if (!mmsh_connect_int2 (this, this->user_bandwidth))
+ break;
+ this->playing = 1;
+ }
bytes_left = this->buf_size - this->buf_read;
@@ -867,3 +896,8 @@ uint32_t mmsh_get_length (mmsh_t *this) {
off_t mmsh_get_current_pos (mmsh_t *this) {
return this->current_pos;
}
+
+void mmsh_set_start_time (mmsh_t *this, int time_offset) {
+ if (time_offset >= 0)
+ this->start_time = time_offset;
+}
diff --git a/src/input/mmsh.h b/src/input/mmsh.h
index 8aee808f0..1ded6295a 100644
--- a/src/input/mmsh.h
+++ b/src/input/mmsh.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: mmsh.h,v 1.5 2006/06/20 01:46:41 dgp85 Exp $
+ * $Id: mmsh.h,v 1.6 2007/01/09 20:51:00 klan Exp $
*
* libmmsh public header
*/
@@ -31,7 +31,7 @@
typedef struct mmsh_s mmsh_t;
char* mmsh_connect_common(int *s ,int *port, char *url, char **host, char **path, char **file);
-mmsh_t* mmsh_connect (xine_stream_t *stream, const char *url_, int bandwidth);
+mmsh_t* mmsh_connect (xine_stream_t *stream, const char *url_, int bandwidth);
int mmsh_read (mmsh_t *this, char *data, int len);
uint32_t mmsh_get_length (mmsh_t *this);
@@ -41,4 +41,6 @@ size_t mmsh_peek_header (mmsh_t *this, char *data, size_t maxsize);
off_t mmsh_get_current_pos (mmsh_t *this);
+void mmsh_set_start_time (mmsh_t *this, int time_offset);
+
#endif