diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/demuxers/asfheader.h | 122 | ||||
-rw-r--r-- | src/demuxers/demux_asf.c | 52 | ||||
-rw-r--r-- | src/input/mms.c | 18 | ||||
-rw-r--r-- | src/input/mmsh.c | 29 |
4 files changed, 141 insertions, 80 deletions
diff --git a/src/demuxers/asfheader.h b/src/demuxers/asfheader.h index d2975078e..0a73a2570 100644 --- a/src/demuxers/asfheader.h +++ b/src/demuxers/asfheader.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: asfheader.h,v 1.3 2003/10/06 15:46:20 mroi Exp $ + * $Id: asfheader.h,v 1.4 2005/01/12 00:05:36 tmattern Exp $ * * demultiplexer for asf streams * @@ -41,60 +41,71 @@ #define GUID_ASF_HEADER 1 #define GUID_ASF_DATA 2 #define GUID_ASF_SIMPLE_INDEX 3 +#define GUID_INDEX 4 +#define GUID_MEDIA_OBJECT_INDEX 5 +#define GUID_TIMECODE_INDEX 6 /* header ASF objects */ -#define GUID_ASF_FILE_PROPERTIES 4 -#define GUID_ASF_STREAM_PROPERTIES 5 -#define GUID_ASF_STREAM_BITRATE_PROPERTIES 6 -#define GUID_ASF_CONTENT_DESCRIPTION 7 -#define GUID_ASF_EXTENDED_CONTENT_ENCRYPTION 8 -#define GUID_ASF_SCRIPT_COMMAND 9 -#define GUID_ASF_MARKER 10 -#define GUID_ASF_HEADER_EXTENSION 11 -#define GUID_ASF_BITRATE_MUTUAL_EXCLUSION 12 -#define GUID_ASF_CODEC_LIST 13 -#define GUID_ASF_EXTENDED_CONTENT_DESCRIPTION 14 -#define GUID_ASF_ERROR_CORRECTION 15 -#define GUID_ASF_PADDING 16 +#define GUID_ASF_FILE_PROPERTIES 7 +#define GUID_ASF_STREAM_PROPERTIES 8 +#define GUID_ASF_HEADER_EXTENSION 9 +#define GUID_ASF_CODEC_LIST 10 +#define GUID_ASF_SCRIPT_COMMAND 11 +#define GUID_ASF_MARKER 12 +#define GUID_ASF_BITRATE_MUTUAL_EXCLUSION 13 +#define GUID_ASF_ERROR_CORRECTION 14 +#define GUID_ASF_CONTENT_DESCRIPTION 15 +#define GUID_ASF_EXTENDED_CONTENT_DESCRIPTION 16 +#define GUID_ASF_STREAM_BITRATE_PROPERTIES 17 +#define GUID_ASF_EXTENDED_CONTENT_ENCRYPTION 18 +#define GUID_ASF_PADDING 19 /* stream properties object stream type */ -#define GUID_ASF_AUDIO_MEDIA 17 -#define GUID_ASF_VIDEO_MEDIA 18 -#define GUID_ASF_COMMAND_MEDIA 19 +#define GUID_ASF_AUDIO_MEDIA 20 +#define GUID_ASF_VIDEO_MEDIA 21 +#define GUID_ASF_COMMAND_MEDIA 22 +#define GUID_ASF_JFIF_MEDIA 23 +#define GUID_ASF_DEGRADABLE_JPEG_MEDIA 24 +#define GUID_ASF_FILE_TRANSFER_MEDIA 25 +#define GUID_ASF_BINARY_MEDIA 26 /* stream properties object error correction type */ -#define GUID_ASF_NO_ERROR_CORRECTION 20 -#define GUID_ASF_AUDIO_SPREAD 21 +#define GUID_ASF_NO_ERROR_CORRECTION 27 +#define GUID_ASF_AUDIO_SPREAD 28 /* mutual exclusion object exlusion type */ -#define GUID_ASF_MUTEX_BITRATE 22 -#define GUID_ASF_MUTEX_UKNOWN 23 +#define GUID_ASF_MUTEX_BITRATE 29 +#define GUID_ASF_MUTEX_UKNOWN 30 /* header extension */ -#define GUID_ASF_RESERVED_1 24 +#define GUID_ASF_RESERVED_1 31 /* script command */ -#define GUID_ASF_RESERVED_SCRIPT_COMMNAND 25 +#define GUID_ASF_RESERVED_SCRIPT_COMMNAND 32 /* marker object */ -#define GUID_ASF_RESERVED_MARKER 26 +#define GUID_ASF_RESERVED_MARKER 33 /* various */ /* #define GUID_ASF_HEAD2 27 */ -#define GUID_ASF_AUDIO_CONCEAL_NONE 27 -#define GUID_ASF_CODEC_COMMENT1_HEADER 28 -#define GUID_ASF_2_0_HEADER 29 +#define GUID_ASF_AUDIO_CONCEAL_NONE 34 +#define GUID_ASF_CODEC_COMMENT1_HEADER 35 +#define GUID_ASF_2_0_HEADER 36 -#define GUID_END 30 +#define GUID_END 37 /* asf stream types */ -#define ASF_STREAM_TYPE_UNKNOWN 0 -#define ASF_STREAM_TYPE_AUDIO 1 -#define ASF_STREAM_TYPE_VIDEO 2 -#define ASF_STREAM_TYPE_CONTROL 3 +#define ASF_STREAM_TYPE_UNKNOWN 0 +#define ASF_STREAM_TYPE_AUDIO 1 +#define ASF_STREAM_TYPE_VIDEO 2 +#define ASF_STREAM_TYPE_CONTROL 3 +#define ASF_STREAM_TYPE_JFIF 4 +#define ASF_STREAM_TYPE_DEGRADABLE_JPEG 5 +#define ASF_STREAM_TYPE_FILE_TRANSFER 6 +#define ASF_STREAM_TYPE_BINARY 7 #define ASF_MAX_NUM_STREAMS 23 @@ -130,6 +141,14 @@ static const struct { "simple index", { 0x33000890, 0xe5b1, 0x11cf, { 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb }} }, + { "index", + { 0xd6e229d3, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} }, + + { "media object index", + { 0xfeb103f8, 0x12ad, 0x4c64, { 0x84, 0x0f, 0x2a, 0x1d, 0x2f, 0x7a, 0xd4, 0x8c }} }, + + { "timecode index", + { 0x3cb73fd0, 0x0c4a, 0x4803, { 0x95, 0x3d, 0xed, 0xf7, 0xb6, 0x22, 0x8f, 0x0c }} }, /* header ASF objects */ { "file properties", @@ -138,14 +157,11 @@ static const struct { "stream header", { 0xb7dc0791, 0xa9b7, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} }, - { "stream bitrate properties", /* (http://get.to/sdp) */ - { 0x7bf875ce, 0x468d, 0x11d1, { 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2 }} }, - - { "content description", - { 0x75b22633, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }} }, + { "header extension", + { 0x5fbf03b5, 0xa92e, 0x11cf, { 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} }, - { "extended content encryption", - { 0x298ae614, 0x2622, 0x4c17, { 0xb9, 0x35, 0xda, 0xe0, 0x7e, 0xe9, 0x28, 0x9c }} }, + { "codec list", + { 0x86d15240, 0x311d, 0x11d0, { 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} }, { "script command", { 0x1efb1a30, 0x0b62, 0x11d0, { 0xa3, 0x9b, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} }, @@ -153,20 +169,23 @@ static const struct { "marker", { 0xf487cd01, 0xa951, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} }, - { "header extension", - { 0x5fbf03b5, 0xa92e, 0x11cf, { 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} }, - { "bitrate mutual exclusion", { 0xd6e229dc, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} }, - { "codec list", - { 0x86d15240, 0x311d, 0x11d0, { 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} }, + { "error correction", + { 0x75b22635, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }} }, + + { "content description", + { 0x75b22633, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }} }, { "extended content description", { 0xd2d0a440, 0xe307, 0x11d2, { 0x97, 0xf0, 0x00, 0xa0, 0xc9, 0x5e, 0xa8, 0x50 }} }, - { "error correction", - { 0x75b22635, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }} }, + { "stream bitrate properties", /* (http://get.to/sdp) */ + { 0x7bf875ce, 0x468d, 0x11d1, { 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2 }} }, + + { "extended content encryption", + { 0x298ae614, 0x2622, 0x4c17, { 0xb9, 0x35, 0xda, 0xe0, 0x7e, 0xe9, 0x28, 0x9c }} }, { "padding", { 0x1806d474, 0xcadf, 0x4509, { 0xa4, 0xba, 0x9a, 0xab, 0xcb, 0x96, 0xaa, 0xe8 }} }, @@ -182,6 +201,17 @@ static const struct { "command media", { 0x59dacfc0, 0x59e6, 0x11d0, { 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} }, + { "JFIF media (JPEG)", + { 0xb61be100, 0x5b4e, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b }} }, + + { "Degradable JPEG media", + { 0x35907de0, 0xe415, 0x11cf, { 0xa9, 0x17, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b }} }, + + { "File Transfer media", + { 0x91bd222c, 0xf21c, 0x497a, { 0x8b, 0x6d, 0x5a, 0xa8, 0x6b, 0xfc, 0x01, 0x85 }} }, + + { "Binary media", + { 0x3afb65e2, 0x47ef, 0x40f2, { 0xac, 0x2c, 0x70, 0xa9, 0x0d, 0x71, 0xd3, 0x43 }} }, /* stream properties object error correction */ { "no error correction", diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c index d94a394d8..f9913e749 100644 --- a/src/demuxers/demux_asf.c +++ b/src/demuxers/demux_asf.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: demux_asf.c,v 1.167 2004/12/24 17:43:38 hadess Exp $ + * $Id: demux_asf.c,v 1.168 2005/01/12 00:05:36 tmattern Exp $ * * demultiplexer for asf streams * @@ -44,7 +44,6 @@ /* #define LOG */ - #include "xine_internal.h" #include "demux.h" #include "xineutils.h" @@ -246,11 +245,11 @@ static uint64_t get_le64 (demux_asf_t *this) { return LE_64(buf); } -static int get_guid_id (demux_asf_t *this, GUID g) { +static int get_guid_id (demux_asf_t *this, GUID *g) { int i; for (i = 1; i < GUID_END; i++) { - if (!memcmp(&g, &guids[i].guid, sizeof(GUID))) { + if (!memcmp(g, &guids[i].guid, sizeof(GUID))) { lprintf ("GUID: %s\n", guids[i].name); return i; } @@ -259,8 +258,8 @@ static int get_guid_id (demux_asf_t *this, GUID g) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_asf: unknown GUID: 0x%" PRIx32 ", 0x%" PRIx16 ", 0x%" PRIx16 ", " "{ 0x%" PRIx8 ", 0x%" PRIx8 ", 0x%" PRIx8 ", 0x%" PRIx8 ", 0x%" PRIx8 ", 0x%" PRIx8 ", 0x%" PRIx8 ", 0x%" PRIx8 " }\n", - g.Data1, g.Data2, g.Data3, - g.Data4[0], g.Data4[1], g.Data4[2], g.Data4[3], g.Data4[4], g.Data4[5], g.Data4[6], g.Data4[7]); + g->Data1, g->Data2, g->Data3, + g->Data4[0], g->Data4[1], g->Data4[2], g->Data4[3], g->Data4[4], g->Data4[5], g->Data4[6], g->Data4[7]); return GUID_ERROR; } @@ -277,7 +276,7 @@ static int get_guid (demux_asf_t *this) { g.Data4[i] = get_byte(this); } - return get_guid_id(this, g); + return get_guid_id(this, &g); } static void get_str16_nolen(demux_asf_t *this, int len, @@ -396,7 +395,7 @@ static int asf_read_header (demux_asf_t *this) { guid = get_guid(this); file_size = get_le64(this); /* file size */ - + get_le64(this); /* creation time */ this->packet_count = get_le64(this); /* nb packets */ @@ -450,7 +449,10 @@ static int asf_read_header (demux_asf_t *this) { break; default: - goto fail; + lprintf("unexpected GUID\n"); + pos2 = this->input->get_current_pos (this->input); + this->input->seek (this->input, gsize - (pos2 - pos1 + 24), SEEK_CUR); + continue; } guid = get_guid(this); @@ -978,6 +980,7 @@ static int asf_parse_packet_align(demux_asf_t *this) { mod = (current_pos - this->first_packet_pos) % this->packet_size; this->packet_size_left = mod ? this->packet_size - mod : 0; packet_pos = current_pos + this->packet_size_left; + if (this->packet_size_left) { lprintf("last packet is not finished, %d bytes\n", this->packet_size_left); current_pos = this->input->seek (this->input, packet_pos, SEEK_SET); @@ -988,9 +991,9 @@ static int asf_parse_packet_align(demux_asf_t *this) { this->packet_size_left = 0; /* check packet_count */ - packet_num = (current_pos - this->first_packet_pos) / this->packet_size; + packet_num = (packet_pos - this->first_packet_pos) / this->packet_size; lprintf("packet_num=%lld, packet_count=%lld\n", packet_num, this->packet_count); - if (packet_num == this->packet_count) { + if (packet_num >= this->packet_count) { /* end of payload data */ current_pos = this->input->get_current_pos (this->input); lprintf("end of payload data, current_pos=%lld\n", current_pos); @@ -1046,10 +1049,29 @@ static int asf_parse_packet_ecd(demux_asf_t *this, uint32_t *p_hdr_size) { *p_hdr_size += read_size; } else { - - /* skip invalid packet */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_asf: skip invalid packet: %2X\n", ecd_flags); - this->input->seek (this->input, this->packet_size - *p_hdr_size, SEEK_CUR); + GUID *guid = (GUID *)buf; + + /* check if it's a new stream */ + buf[0] = ecd_flags; + if (this->input->read (this->input, buf + 1, 15) != 15) { + this->status = DEMUX_FINISHED; + return 1; + } + *p_hdr_size += 15; + guid->Data1 = LE_32(buf); + guid->Data2 = LE_16(buf + 4); + guid->Data3 = LE_16(buf + 6); + if (get_guid_id(this, guid) == GUID_ASF_HEADER) { + lprintf("new asf header detected\n"); + _x_demux_control_end(this->stream, 0); + if (demux_asf_send_headers_common(this)) + return 1; + } else { + + /* skip invalid packet */ + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_asf: skip invalid packet: %2X\n", ecd_flags); + this->input->seek (this->input, this->packet_size - *p_hdr_size, SEEK_CUR); + } invalid_packet = 1; } } diff --git a/src/input/mms.c b/src/input/mms.c index e00cd286e..9476c527a 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.52 2004/12/14 23:13:09 tmattern Exp $ + * $Id: mms.c,v 1.53 2005/01/12 00:05:37 tmattern Exp $ * * MMS over TCP protocol * based on work from major mms @@ -58,7 +58,6 @@ /* #define LOG */ - #include "xine_internal.h" #include "xineutils.h" @@ -140,7 +139,7 @@ struct mms_s { int stream_ids[ASF_MAX_NUM_STREAMS]; int stream_types[ASF_MAX_NUM_STREAMS]; int asf_packet_len; - uint32_t file_len; + uint64_t file_len; char guid[37]; uint32_t bitrates[ASF_MAX_NUM_STREAMS]; uint32_t bitrates_pos[ASF_MAX_NUM_STREAMS]; @@ -540,9 +539,9 @@ static void interp_asf_header (mms_t *this) { case GUID_ASF_FILE_PROPERTIES: this->asf_packet_len = LE_32(this->asf_header + i + 92 - 24); - this->file_len = LE_32(this->asf_header + i + 40 - 24); - lprintf ("file object, packet length = %d (%d)\n", - this->asf_packet_len, LE_32(this->asf_header + i + 96 - 24)); + this->file_len = LE_64(this->asf_header + i + 40 - 24); + lprintf ("file object, file_length = %lld, packet length = %d", + this->file_len, this->asf_packet_len); break; case GUID_ASF_STREAM_PROPERTIES: @@ -560,6 +559,8 @@ static void interp_asf_header (mms_t *this) { break; case GUID_ASF_VIDEO_MEDIA: + case GUID_ASF_JFIF_MEDIA: + case GUID_ASF_DEGRADABLE_JPEG_MEDIA: type = ASF_STREAM_TYPE_VIDEO; this->has_video = 1; break; @@ -1170,10 +1171,7 @@ static int get_media_packet (mms_t *this) { "libmms: invalid asf packet len: %d bytes\n", header.packet_len); return 0; } - - /* simulate a seek */ - this->current_pos = (off_t)this->asf_header_len + (off_t)header.packet_seq * (off_t)this->asf_packet_len; - + len = _x_io_tcp_read (this->stream, this->s, this->buf, header.packet_len); if (len != header.packet_len) { xprintf (this->stream->xine, XINE_VERBOSITY_LOG, diff --git a/src/input/mmsh.c b/src/input/mmsh.c index fc5bc61a7..62aff01a5 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.33 2004/12/14 23:13:09 tmattern Exp $ + * $Id: mmsh.c,v 1.34 2005/01/12 00:05:38 tmattern Exp $ * * MMS over HTTP protocol * written by Thibaut Mattern @@ -183,7 +183,7 @@ struct mmsh_s { int stream_ids[ASF_MAX_NUM_STREAMS]; int stream_types[ASF_MAX_NUM_STREAMS]; int packet_length; - uint32_t file_length; + int64_t file_length; char guid[37]; uint32_t bitrates[ASF_MAX_NUM_STREAMS]; uint32_t bitrates_pos[ASF_MAX_NUM_STREAMS]; @@ -452,7 +452,6 @@ static int get_header (mmsh_t *this) { if (len != this->chunk_length) { return 0; } else { - this->buf_size = this->packet_length; return 1; } } else { @@ -492,9 +491,9 @@ static void interp_header (mmsh_t *this) { case GUID_ASF_FILE_PROPERTIES: this->packet_length = LE_32(this->asf_header + i + 92 - 24); - this->file_length = LE_32(this->asf_header + i + 40 - 24); - lprintf ("file object, packet length = %d (%d)\n", - this->packet_length, LE_32(this->asf_header + i + 96 - 24)); + this->file_length = LE_64(this->asf_header + i + 40 - 24); + lprintf ("file object, file_length = %lld, packet length = %d", + this->file_length, this->packet_count); break; case GUID_ASF_STREAM_PROPERTIES: @@ -510,16 +509,18 @@ static void interp_header (mmsh_t *this) { type = ASF_STREAM_TYPE_AUDIO; this->has_audio = 1; break; - + case GUID_ASF_VIDEO_MEDIA: + case GUID_ASF_JFIF_MEDIA: + case GUID_ASF_DEGRADABLE_JPEG_MEDIA: type = ASF_STREAM_TYPE_VIDEO; this->has_video = 1; break; - + case GUID_ASF_COMMAND_MEDIA: type = ASF_STREAM_TYPE_CONTROL; break; - + default: type = ASF_STREAM_TYPE_UNKNOWN; } @@ -793,6 +794,7 @@ static int mmsh_connect_int(mmsh_t *this, int bandwidth) { if (!get_header(this)) goto fail; interp_header(this); + this->buf_size = this->packet_length; for (i = 0; i < this->num_stream_ids; i++) { if ((this->stream_ids[i] != audio_stream) && @@ -928,12 +930,15 @@ static int get_media_packet (mmsh_t *this) { case CHUNK_TYPE_RESET: /* next chunk is an ASF header */ + if (this->chunk_length != 0) { /* that's strange, don't know what to do */ return 0; } if (!get_header(this)) return 0; + interp_header(this); + this->buf_size = this->packet_length; return 2; default: @@ -946,6 +951,12 @@ static int get_media_packet (mmsh_t *this) { if (len == this->chunk_length) { /* explicit padding with 0 */ + if (this->chunk_length > this->packet_length) { + xprintf (this->stream->xine, XINE_VERBOSITY_LOG, + "libmmsh: chunk_length(%d) > packet_length(%d)\n", + this->chunk_length, this->packet_length); + return 0; + } memset(this->buf + this->chunk_length, 0, this->packet_length - this->chunk_length); this->buf_size = this->packet_length; |