diff options
author | Claudio Ciccani <klan@users.sourceforge.net> | 2007-01-03 15:09:42 +0000 |
---|---|---|
committer | Claudio Ciccani <klan@users.sourceforge.net> | 2007-01-03 15:09:42 +0000 |
commit | 35374893f50c163e0cae77dc4801c0d1b7af4d08 (patch) | |
tree | 31b67990eeb94596d8c34a7f067994730553b381 | |
parent | f520a8933ac659d52b66049b2bb2402a9d50c48b (diff) | |
download | xine-lib-35374893f50c163e0cae77dc4801c0d1b7af4d08.tar.gz xine-lib-35374893f50c163e0cae77dc4801c0d1b7af4d08.tar.bz2 |
Added support for setting the playback start time (same as the RTSP plugin).
Actually this is only implemented for the MMST protocol.
CVS patchset: 8484
CVS date: 2007/01/03 15:09:42
-rw-r--r-- | src/input/input_mms.c | 26 | ||||
-rw-r--r-- | src/input/mms.c | 61 | ||||
-rw-r--r-- | src/input/mms.h | 4 |
3 files changed, 87 insertions, 4 deletions
diff --git a/src/input/input_mms.c b/src/input/input_mms.c index d4f6cb940..6ef256ea3 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.64 2006/10/23 21:18:18 hadess Exp $ + * $Id: input_mms.c,v 1.65 2007/01/03 15:09:42 klan Exp $ * * mms input plugin based on work from major mms */ @@ -201,6 +201,26 @@ static off_t mms_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin return curpos; } +static off_t mms_plugin_seek_time (input_plugin_t *this_gen, int time_offset, int origin) { + mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen; + off_t curpos = 0; + + lprintf ("seek_time %d msec, origin %d\n", time_offset, origin); + + switch (this->protocol) { + case PROTOCOL_MMST: + if (origin == SEEK_SET) + mms_set_start_time (this->mms, time_offset); + curpos = mms_get_current_pos (this->mms); + break; + case PROTOCOL_MMSH: + curpos = mmsh_get_current_pos (this->mmsh); + break; + } + + return curpos; +} + static off_t mms_plugin_get_length (input_plugin_t *this_gen) { mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen; off_t length = 0; @@ -356,6 +376,10 @@ 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; } diff --git a/src/input/mms.c b/src/input/mms.c index 86317a1ee..370b20759 100644 --- a/src/input/mms.c +++ b/src/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: mms.c,v 1.63 2006/09/16 08:13:51 tmattern Exp $ + * $Id: mms.c,v 1.64 2007/01/03 15:09:42 klan Exp $ * * MMS over TCP protocol * based on work from major mms @@ -144,9 +144,19 @@ struct mms_s { int eos; uint8_t live_flag; + + uint8_t playing; + double start_time; }; +#define D2Q(d) ({\ + union { double db; long long qw; } _tmp;\ + _tmp.db = d;\ + _tmp.qw;\ +})\ + + static void mms_buffer_init (mms_buffer_t *mms_buffer, char *buffer) { mms_buffer->buffer = (uint8_t*)buffer; mms_buffer->pos = 0; @@ -179,6 +189,20 @@ static void mms_buffer_put_32 (mms_buffer_t *mms_buffer, uint32_t value) { mms_buffer->pos += 4; } +static void mms_buffer_put_64 (mms_buffer_t *mms_buffer, uint64_t value) { + + mms_buffer->buffer[mms_buffer->pos] = value & 0xff; + mms_buffer->buffer[mms_buffer->pos + 1] = (value >> 8) & 0xff; + mms_buffer->buffer[mms_buffer->pos + 2] = (value >> 16) & 0xff; + mms_buffer->buffer[mms_buffer->pos + 3] = (value >> 24) & 0xff; + mms_buffer->buffer[mms_buffer->pos + 4] = (value >> 32) & 0xff; + mms_buffer->buffer[mms_buffer->pos + 5] = (value >> 40) & 0xff; + mms_buffer->buffer[mms_buffer->pos + 6] = (value >> 48) & 0xff; + mms_buffer->buffer[mms_buffer->pos + 7] = (value >> 56) & 0xff; + + mms_buffer->pos += 8; +} + static void print_command (char *data, int len) { @@ -839,11 +863,13 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) { report_progress (stream, 80); /* command 0x07 */ + /* moved to mms_read() */ +#if 0 { mms_buffer_t command_buffer; mms_buffer_init(&command_buffer, this->scmd_body); mms_buffer_put_32 (&command_buffer, 0x00000000); /* 64 byte float timestamp */ - mms_buffer_put_32 (&command_buffer, 0x00000000); + mms_buffer_put_32 (&command_buffer, 0x00000000); mms_buffer_put_32 (&command_buffer, 0xFFFFFFFF); /* ?? */ mms_buffer_put_32 (&command_buffer, 0xFFFFFFFF); /* first packet sequence */ mms_buffer_put_8 (&command_buffer, 0xFF); /* max stream time limit (3 bytes) */ @@ -857,6 +883,7 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) { goto fail; } } +#endif report_progress (stream, 100); @@ -1052,9 +1079,33 @@ int mms_read (mms_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) { + /* send command 0x07 with initial timestamp */ + mms_buffer_t command_buffer; + mms_buffer_init(&command_buffer, this->scmd_body); + mms_buffer_put_64 (&command_buffer, D2Q(this->start_time)); /* 64 byte float timestamp */ + mms_buffer_put_32 (&command_buffer, 0xFFFFFFFF); /* ?? */ + mms_buffer_put_32 (&command_buffer, 0xFFFFFFFF); /* first packet sequence */ + mms_buffer_put_8 (&command_buffer, 0xFF); /* max stream time limit (3 bytes) */ + mms_buffer_put_8 (&command_buffer, 0xFF); + mms_buffer_put_8 (&command_buffer, 0xFF); + mms_buffer_put_8 (&command_buffer, 0x00); /* stream time limit flag */ + mms_buffer_put_32 (&command_buffer, ASF_MEDIA_PACKET_ID_TYPE); /* asf media packet id type */ + if (!send_command (this, 0x07, 1, 0x0001FFFF, command_buffer.pos)) { + xprintf (this->stream->xine, XINE_VERBOSITY_LOG, + "libmms: failed to send command 0x07\n"); + this->eos = 1; + break; + } + this->playing = 1; + } bytes_left = this->buf_size - this->buf_read; if (bytes_left == 0) { @@ -1111,3 +1162,9 @@ uint32_t mms_get_length (mms_t *this) { off_t mms_get_current_pos (mms_t *this) { return this->current_pos; } + +void mms_set_start_time (mms_t *this, int time_offset) { + if (time_offset >= 0) + this->start_time = (double) time_offset / 1000.0; +} + diff --git a/src/input/mms.h b/src/input/mms.h index f4b2928cd..310a6d0cc 100644 --- a/src/input/mms.h +++ b/src/input/mms.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: mms.h,v 1.12 2006/06/20 01:46:41 dgp85 Exp $ + * $Id: mms.h,v 1.13 2007/01/03 15:09:42 klan Exp $ * * libmms public header */ @@ -41,5 +41,7 @@ size_t mms_peek_header (mms_t *this, char *data, size_t maxsize); off_t mms_get_current_pos (mms_t *this); +void mms_set_start_time (mms_t *this, int time_offset); + #endif |