summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibaut Mattern <tmattern@users.sourceforge.net>2003-03-02 17:00:31 +0000
committerThibaut Mattern <tmattern@users.sourceforge.net>2003-03-02 17:00:31 +0000
commit81d61dba0b902f7cb0d9d040214f8a13c3ece33b (patch)
treed318b414974a68b2c4fd5a73ddbd755513d7de31
parent0f48ac67ddfec5cefdde8e4e57476be57858295c (diff)
downloadxine-lib-81d61dba0b902f7cb0d9d040214f8a13c3ece33b.tar.gz
xine-lib-81d61dba0b902f7cb0d9d040214f8a13c3ece33b.tar.bz2
Detection by content for non seekable input plugins.
CVS patchset: 4320 CVS date: 2003/03/02 17:00:31
-rw-r--r--src/demuxers/demux_avi.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c
index 5da05b09a..6cbae4ec9 100644
--- a/src/demuxers/demux_avi.c
+++ b/src/demuxers/demux_avi.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_avi.c,v 1.151 2003/03/02 16:01:35 tmattern Exp $
+ * $Id: demux_avi.c,v 1.152 2003/03/02 17:00:31 tmattern Exp $
*
* demultiplexer for avi streams
*
@@ -1674,6 +1674,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input = (input_plugin_t *) input_gen;
demux_avi_t *this;
+ uint8_t buf[MAX_PREVIEW_SIZE];
this = xine_xmalloc (sizeof (demux_avi_t));
this->stream = stream;
@@ -1701,24 +1702,33 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
case METHOD_BY_CONTENT:
- if ((input->get_capabilities(input) & INPUT_CAP_BLOCK) ||
- (this->streaming)) {
+ if (input->get_capabilities(input) & INPUT_CAP_BLOCK) {
printf ("demux_avi: AVI_init failed (AVI_errno: %d)\n",
this->AVI_errno);
free (this);
return NULL;
}
- input->seek(input, 0, SEEK_SET);
-
- this->avi = AVI_init (this);
-
- if (!this->avi) {
+ if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) != 0) {
+ input->seek(input, 0, SEEK_SET);
+ if (input->read(input, buf, 12) != 12) {
+ free (this);
+ return NULL;
+ }
+ input->seek(input, 0, SEEK_SET);
+ } else if ((input->get_capabilities(input) & INPUT_CAP_PREVIEW) != 0) {
+ input->get_optional_data (input, buf, INPUT_OPTIONAL_DATA_PREVIEW);
+ } else {
free (this);
return NULL;
}
- break;
+ if( strncasecmp(buf ,"RIFF",4) !=0 ||
+ strncasecmp(buf+8,"AVI ",4) !=0 ) {
+ free (this);
+ return NULL;
+ }
+ break;
case METHOD_BY_EXTENSION: {
char *ending, *mrl;
@@ -1740,15 +1750,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
/* we want to fall through here */
case METHOD_EXPLICIT: {
-
- this->avi = AVI_init (this);
-
- if (!this->avi) {
- printf ("demux_avi: AVI_init failed (AVI_errno: %d)\n",
- this->AVI_errno);
- free (this);
- return NULL;
- }
}
break;
@@ -1757,6 +1758,13 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
+ this->avi = AVI_init (this);
+ if (!this->avi) {
+ printf ("demux_avi: AVI_init failed (AVI_errno: %d)\n",
+ this->AVI_errno);
+ free (this);
+ return NULL;
+ }
strncpy (this->last_mrl, input->get_mrl (input), 1024);
printf ("demux_avi: %ld frames\n", this->avi->video_idx.video_frames);