summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Roitzsch <mroi@users.sourceforge.net>2002-12-30 11:51:45 +0000
committerMichael Roitzsch <mroi@users.sourceforge.net>2002-12-30 11:51:45 +0000
commit88fe61c56601390a97242b4d3b370ef4f4933d72 (patch)
treede7bf99e5c6df2d946ad1ecfb6fa829954f38293
parent8cc9b991dd81805b900f6a702d4c45be6debc8de (diff)
downloadxine-lib-88fe61c56601390a97242b4d3b370ef4f4933d72.tar.gz
xine-lib-88fe61c56601390a97242b4d3b370ef4f4933d72.tar.bz2
fill the buffers with text, fix dispose memleak, add FIXMEs
CVS patchset: 3729 CVS date: 2002/12/30 11:51:45
-rw-r--r--src/libsputext/demux_sputext.c58
1 files changed, 52 insertions, 6 deletions
diff --git a/src/libsputext/demux_sputext.c b/src/libsputext/demux_sputext.c
index d316e2bf3..e23477933 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.1 2002/12/29 16:39:38 mroi Exp $
+ * $Id: demux_sputext.c,v 1.2 2002/12/30 11:51:45 mroi Exp $
*
* code based on old libsputext/xine_decoder.c
*
@@ -798,13 +798,54 @@ static void update_osd_dst_encoding(void *this_gen, xine_cfg_entry_t *entry)
printf("demux_sputext: spu_dst_encoding = %s\n", class->dst_encoding );
}
-static int demux_sputext_next (demux_sputext_t *this) {
- /* FIXME: send something out here */
+static int demux_sputext_next (demux_sputext_t *this_gen) {
+ demux_sputext_t *this = (demux_sputext_t *) this_gen;
+ buf_element_t *buf;
+ subtitle_t *sub = &this->subtitles[this->cur];
+ int line;
+
+ if (this->cur >= this->num)
+ return 0;
+
+ buf = this->stream->video_fifo->buffer_pool_alloc(this->stream->video_fifo);
+ buf->decoder_info[1] = sub->lines;
+ for (line = 0; line < sub->lines; line++)
+ strncpy(buf->content + line * SUB_BUFSIZE, sub->text[line], SUB_BUFSIZE);
+
+ /* calculate PTS */
+ if (!this->uses_time) {
+ /* FIXME: framerate hardcoded - get from master stream instead */
+ int64_t frame_pts = 3600;
+
+ buf->pts = sub->start * frame_pts;
+
+ /* duration */
+ buf->decoder_info[0] = (sub->end - sub->start) * frame_pts;
+
+ } else {
+
+ buf->pts = sub->start * 900;
+
+ /* duration */
+ buf->decoder_info[0] = (sub->end - sub->start) * 900;
+ }
+
+ this->stream->video_fifo->put(this->stream->video_fifo, buf);
+ this->cur++;
+
return 1;
}
static void demux_sputext_dispose (demux_plugin_t *this_gen) {
- free (this_gen);
+ demux_sputext_t *this = (demux_sputext_t *) this_gen;
+ int i, l;
+
+ for (i = 0; i < this->num; i++) {
+ for (l = 0; l < this->subtitles[i].lines; l++)
+ free(this->subtitles[i].text[l]);
+ }
+ free(this->subtitles);
+ free(this);
}
static int demux_sputext_get_status (demux_plugin_t *this_gen) {
@@ -813,14 +854,18 @@ static int demux_sputext_get_status (demux_plugin_t *this_gen) {
}
static int demux_sputext_get_stream_length (demux_plugin_t *this_gen) {
- /* FIXME: what to return? */
+ /* FIXME: what to return? Get length from master stream perhaps? */
return 0;
}
static int demux_sputext_send_chunk (demux_plugin_t *this_gen) {
demux_sputext_t *this = (demux_sputext_t *) this_gen;
- if (!demux_sputext_next (this)) {
+ /* send at most 10 buffers to fifo in advance */
+ if (this->stream->video_fifo->size(this->stream->video_fifo) >= 10)
+ xine_usec_sleep(200000);
+ if (this->stream->video_fifo->size(this->stream->video_fifo) < 10 &&
+ !demux_sputext_next (this)) {
this->status = DEMUX_FINISHED;
}
@@ -830,6 +875,7 @@ 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 */
return this->status;
}