summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libsputext/demux_sputext.c34
-rw-r--r--src/libsputext/xine_decoder.c36
2 files changed, 46 insertions, 24 deletions
diff --git a/src/libsputext/demux_sputext.c b/src/libsputext/demux_sputext.c
index afb5f9d11..15de8e100 100644
--- a/src/libsputext/demux_sputext.c
+++ b/src/libsputext/demux_sputext.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_sputext.c,v 1.8 2003/01/11 11:34:15 mroi Exp $
+ * $Id: demux_sputext.c,v 1.9 2003/01/12 15:29:08 miguelfreitas Exp $
*
* code based on old libsputext/xine_decoder.c
*
@@ -48,9 +48,9 @@
#include "xineutils.h"
#include "../demuxers/demux.h"
-/*
+
#define LOG 1
-*/
+
#define ERR (void *)-1
#define SUB_MAX_TEXT 5
@@ -760,8 +760,9 @@ static subtitle_t *sub_read_file (demux_sputext_t *this) {
{ free(first[this->num].text[i]);
first[this->num].text[i]=tmp;
}
- else
- { printf("demux_sputext: Can't convert subtitle text\n"); }
+ else {
+ printf("demux_sputext: Can't convert subtitle text\n");
+ }
}
++this->num; /* Error vs. Valid */
}
@@ -872,19 +873,33 @@ static int demux_sputext_send_chunk (demux_plugin_t *this_gen) {
static int demux_sputext_seek (demux_plugin_t *this_gen,
off_t start_pos, int start_time) {
demux_sputext_t *this = (demux_sputext_t*)this_gen;
- /* FIXME: change this->cur according to seek target and set a discontinuity */
-
- if( this->uses_time && start_time ) {
- }
+#ifdef LOG
+ printf("demux_sputext: seek() called\n");
+#endif
+ /* simple seeking approach: just go back to start.
+ * decoder will discard subtitles until the desired position.
+ */
+ this->cur = 0;
+ this->status = DEMUX_OK;
+
+ xine_demux_flush_engine (this->stream);
+ xine_demux_control_newpts(this->stream, 0, 0);
+
return this->status;
}
static void demux_sputext_send_headers(demux_plugin_t *this_gen) {
demux_sputext_t *this = (demux_sputext_t*)this_gen;
+
+#ifdef LOG
+ printf("demux_sputext: send_headers() called\n");
+#endif
+
xine_demux_control_start(this->stream);
this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 0;
this->stream->stream_info[XINE_STREAM_INFO_HAS_AUDIO] = 0;
+ this->status = DEMUX_OK;
}
static uint32_t demux_sputext_get_capabilities(demux_plugin_t *this_gen) {
@@ -916,7 +931,6 @@ static demux_plugin_t *open_demux_plugin (demux_class_t *class_gen, xine_stream_
this->demux_plugin.get_capabilities = demux_sputext_get_capabilities;
this->demux_plugin.get_optional_data = NULL;
this->demux_plugin.demux_class = class_gen;
- this->status = DEMUX_OK;
this->buflen = 0;
diff --git a/src/libsputext/xine_decoder.c b/src/libsputext/xine_decoder.c
index b1b368941..de539d87d 100644
--- a/src/libsputext/xine_decoder.c
+++ b/src/libsputext/xine_decoder.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_decoder.c,v 1.47 2003/01/11 15:31:45 miguelfreitas Exp $
+ * $Id: xine_decoder.c,v 1.48 2003/01/12 15:29:08 miguelfreitas Exp $
*
*/
@@ -36,9 +36,9 @@
#include "xineutils.h"
#include "osd.h"
-/*
+
#define LOG 1
-*/
+
#define SUB_MAX_TEXT 5
#define SUB_BUFSIZE 1024
@@ -75,7 +75,7 @@ typedef struct sputext_decoder_s {
int height; /* frame height */
int font_size;
int line_height;
-
+ int seek_count;
char *font;
subtitle_size subtitle_size;
@@ -168,11 +168,11 @@ static void draw_subtitle(sputext_decoder_t *this, int64_t sub_start, int64_t su
this->renderer->show (this->osd, sub_start);
this->renderer->hide (this->osd, sub_end);
-//#ifdef LOG
+#ifdef LOG
printf ("sputext: scheduling subtitle >%s< at %lld until %lld, current time is %lld\n",
this->text[0], sub_start, sub_end,
this->stream->xine->clock->get_current_time (this->stream->xine->clock));
-//#endif
+#endif
}
@@ -186,7 +186,6 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) {
uint32_t *val;
char *str;
extra_info_t extra_info;
- int seek_count;
int status;
val = (uint32_t * )buf->content;
@@ -199,20 +198,27 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) {
strcpy( this->text[i], str );
}
+#ifdef LOG
printf("libsputext: decoder data [%s]\n", this->text[0]);
printf("libsputext: mode %d timing %d->%d\n", uses_time, start, end);
+#endif
if( end <= start ) {
+#ifdef LOG
printf("libsputext: discarding subtitle with invalid timing\n");
+#endif
}
if( this->stream->master_stream )
xine_get_current_info (this->stream->master_stream, &extra_info, sizeof(extra_info) );
else
xine_get_current_info (this->stream, &extra_info, sizeof(extra_info) );
- seek_count = extra_info.seek_count;
+
+ if( !this->seek_count ) {
+ this->seek_count = extra_info.seek_count;
+ }
- do {
+ while(this->seek_count == extra_info.seek_count) {
/* initialize decoder if needed */
if( !this->width || !this->height || !this->img_duration ) {
@@ -223,8 +229,6 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) {
if( this->width && this->height && this->img_duration ) {
this->renderer = this->stream->osd_renderer;
- this->osd = NULL;
-
update_font_size (this);
}
}
@@ -284,8 +288,10 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) {
else
status = xine_get_status (this->stream);
- if( status == XINE_STATUS_QUIT || status == XINE_STATUS_STOP )
+ if( status == XINE_STATUS_QUIT || status == XINE_STATUS_STOP ) {
+ this->width = this->height = 0;
return;
+ }
xine_usec_sleep (50000);
@@ -294,13 +300,15 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) {
else
xine_get_current_info (this->stream, &extra_info, sizeof(extra_info) );
- } while(seek_count == extra_info.seek_count);
+ }
}
static void spudec_reset (spu_decoder_t *this_gen) {
sputext_decoder_t *this = (sputext_decoder_t *) this_gen;
-
+
+ this->width = this->height = 0;
+ this->seek_count = 0;
}
static void spudec_discontinuity (spu_decoder_t *this_gen) {