From 3b17ce66a7f42a8145d97f691a984374d542a121 Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Sun, 7 Oct 2001 15:13:09 +0000 Subject: if a pes header indicates that the stream is encrypted that doesn't necessarily mean xine cannot play back that stream, so let's at least try it. besides that, vcd seeking bugfixes (linux/sun) CVS patchset: 756 CVS date: 2001/10/07 15:13:09 --- src/demuxers/demux_mpeg_block.c | 40 +++++++++++++++++++------- src/input/input_vcd.c | 63 ++++++++++++++++++++++++----------------- src/xine-engine/xine.c | 7 ++--- 3 files changed, 69 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index c59f5723e..cfada768c 100644 --- a/src/demuxers/demux_mpeg_block.c +++ b/src/demuxers/demux_mpeg_block.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_mpeg_block.c,v 1.51 2001/10/06 13:48:17 jkeil Exp $ + * $Id: demux_mpeg_block.c,v 1.52 2001/10/07 15:13:09 guenter Exp $ * * demultiplexer for mpeg 1/2 program streams * @@ -59,6 +59,7 @@ typedef struct demux_mpeg_block_s { int rate; int send_end_buffers; + int warned; /* encryption warning */ gui_get_next_mrl_cb_t next_mrl_cb; gui_branched_cb_t branched_cb; @@ -222,6 +223,13 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m printf ("demux_mpeg_block: error! %02x %02x %02x (should be 0x000001) \n", p[0], p[1], p[2]); buf->free_buffer (buf); + + this->warned++; + if (this->warned > 5) { + printf ("demux_mpeg_block: too many errors, stopping playback. Maybe this stream is scrambled?\n"); + this->status = DEMUX_FINISHED; + } + return ; } @@ -282,13 +290,10 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m } else { /* mpeg 2 */ /* check PES scrambling_control */ - if ((p[6] & 0x30) != 0) { - printf("demux_mpeg_block: Encrypted PES MPEG2 stream.\n"); - printf("\n\tSorry, Xine doesn't play encrypted MPEG2 streams. The legal status of\n" - "\tCSS decryption is unclear and we will not provide such code.\n\n"); - buf->free_buffer(buf); - this->status = DEMUX_FINISHED; - return; + if (((p[6] & 0x30) != 0) && !this->warned) { + printf("demux_mpeg_block: warning: pes header indicates that this stream may be encrypted (encryption mode %d)\n", (p[6] & 0x30) >> 4); + + this->warned = 1; } if (p[7] & 0x80) { /* PTS avail */ @@ -501,20 +506,21 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { uint32_t PTS, last_PTS; int rate; int count; + int stream_id; if (!(this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE)) return 0; - pos = 0; last_pos = 0; last_PTS = 0; rate = 0; step = this->input->get_length (this->input) / 10; step = (step / this->blocksize) * this->blocksize; if (step <= 0) step = this->blocksize; /* avoid endless loop for tiny files */ + pos = step; count = 0; - this->input->seek (this->input, 0, SEEK_SET); + this->input->seek (this->input, pos, SEEK_SET); while ((buf = this->input->read_block (this->input, this->video_fifo, this->blocksize)) ) { @@ -541,8 +547,15 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { return rate; } + stream_id = p[3]; PTS = 0; + if ((stream_id < 0xbc) || ((stream_id & 0xf0) != 0xe0)) { + pos += (off_t) this->blocksize; + continue; /* only use video packets */ + } + + if (is_mpeg1) { if (p[3] != 0xBF) { /* stream_id */ @@ -582,6 +595,7 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { if (PTS) { + if ( (pos>last_pos) && (PTS>last_PTS) ) { int cur_rate; @@ -591,7 +605,10 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { count ++; - /* printf ("demux_mpeg_block: cur_rate = %d, overall rate : %d\n", cur_rate, rate); */ + /* + printf ("demux_mpeg_block: stream_id %02x, pos: %lld, PTS: %d, cur_rate = %d, overall rate : %d\n", + stream_id, pos, PTS, cur_rate, rate); + */ } last_pos = pos; @@ -604,6 +621,7 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { if (this->input->seek (this->input, pos, SEEK_SET) == (off_t)-1) break; + } return rate; diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c index 4d648257a..616449d8c 100644 --- a/src/input/input_vcd.c +++ b/src/input/input_vcd.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_vcd.c,v 1.24 2001/10/03 15:09:04 jkeil Exp $ + * $Id: input_vcd.c,v 1.25 2001/10/07 15:13:09 guenter Exp $ */ #ifdef HAVE_CONFIG_H @@ -660,11 +660,20 @@ static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, } #endif -// +static off_t vcd_time_to_offset (int min, int sec, int frame) { + return min * 60 * 75 + sec * 75 + frame; +} + +static void vcd_offset_to_time (off_t offset, int *min, int *sec, + int *frame) { + + *min = offset / (60*75); + offset %= (60*75); + *sec = offset / 75; + *frame = offset % 75; + +} -/* - * - */ #if defined (__linux__) || defined(__sun) static off_t vcd_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) { @@ -678,34 +687,36 @@ static off_t vcd_plugin_seek (input_plugin_t *this_gen, switch (origin) { case SEEK_SET: - dist = offset / VCDSECTORSIZE; - - this->cur_min = dist / (60*75) + start_msf->minute; - dist %= 60; - this->cur_sec = dist / 75 + start_msf->second; - dist %= 75; - this->cur_frame = dist + start_msf->frame; + sector_pos = (offset / VCDSECTORSIZE) + + vcd_time_to_offset (start_msf->minute, + start_msf->second, + start_msf->frame); + - xprintf (VERBOSE|INPUT, "%Ld => %02d:%02d:%02d\n", offset, - this->cur_min, this->cur_sec, this->cur_frame); + vcd_offset_to_time (sector_pos, &this->cur_min, + &this->cur_sec, &this->cur_frame); + /* + printf ("input_vcd: seek to %lld => %02d:%02d:%02d (start is %02d:%02d:%02d)\n", offset, + this->cur_min, this->cur_sec, this->cur_frame, + start_msf->minute, start_msf->second, start_msf->frame); + */ break; case SEEK_CUR: if (offset) fprintf (stderr, "input_vcd: SEEK_CUR not implemented for offset != 0\n"); - sector_pos = 75 - start_msf->frame; - - if (start_msf->second<60) - sector_pos += (59 - start_msf->second) * 75; - - if ( this->cur_min > start_msf->minute) { - sector_pos += (this->cur_min - start_msf->minute-1) * 60 * 75; - - sector_pos += this->cur_sec * 60; - - sector_pos += this->cur_frame ; - } + /* + printf ("input_vcd: current pos: %02d:%02d:%02d\n", + this->cur_min, this->cur_sec, this->cur_frame); + */ + + sector_pos = vcd_time_to_offset (this->cur_min, + this->cur_sec, + this->cur_frame) + - vcd_time_to_offset (start_msf->minute, + start_msf->second, + start_msf->frame); return sector_pos * VCDSECTORSIZE; diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index eeccd704a..40c6911a8 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.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: xine.c,v 1.63 2001/10/05 01:56:57 miguelfreitas Exp $ + * $Id: xine.c,v 1.64 2001/10/07 15:13:09 guenter Exp $ * * top-level xine functions * @@ -185,12 +185,11 @@ void xine_play (xine_t *this, char *mrl, off_t pos, len; int i; - xprintf (VERBOSE|LOOP, "xine open %s, start pos = %d\n", mrl, start_pos); + printf ("xine_play: xine open %s, start pos = %d, start time = %d (sec)\n", + mrl, start_pos, start_time); pthread_mutex_lock (&this->xine_lock); - printf ("xine_play: open %s, start pos = %d\n", mrl, start_pos); - /* * stop engine? */ -- cgit v1.2.3