summaryrefslogtreecommitdiff
path: root/src/demuxers/demux_ts.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers/demux_ts.c')
-rw-r--r--src/demuxers/demux_ts.c92
1 files changed, 39 insertions, 53 deletions
diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c
index 999862347..c37a6c488 100644
--- a/src/demuxers/demux_ts.c
+++ b/src/demuxers/demux_ts.c
@@ -300,7 +300,6 @@ typedef struct {
unsigned int counter;
uint16_t descriptor_tag; /* +0x100 for PES stream IDs (no available TS descriptor tag?) */
int corrupted_pes;
- uint32_t buffered_bytes;
int input_normpos;
int input_time;
@@ -311,16 +310,16 @@ typedef struct {
typedef struct {
spu_dvb_descriptor_t desc;
- int pid;
- int media_index;
+ unsigned int pid;
+ unsigned int media_index;
} demux_ts_spu_lang;
/* Audio Channels */
#define MAX_AUDIO_TRACKS 32
typedef struct {
- int pid;
- int media_index;
+ unsigned int pid;
+ unsigned int media_index;
char lang[4];
} demux_ts_audio_track;
@@ -361,7 +360,7 @@ typedef struct {
int blockSize;
int rate;
- int media_num;
+ unsigned int media_num;
demux_ts_media media[MAX_PIDS];
/* PAT */
@@ -429,7 +428,7 @@ static void demux_ts_tbre_reset (demux_ts_t *this) {
}
}
-static void demux_ts_tbre_update (demux_ts_t *this, int mode, int64_t now) {
+static void demux_ts_tbre_update (demux_ts_t *this, unsigned int mode, int64_t now) {
/* select best available timesource on the fly */
if ((mode < this->tbre_mode) || (now <= 0))
return;
@@ -586,27 +585,37 @@ static void demux_ts_update_spu_channel(demux_ts_t *this)
if ((this->media[this->spu_media].type & BUF_MAJOR_MASK) == BUF_SPU_HDMV) {
buf->type = BUF_SPU_HDMV;
+ buf->type |= this->current_spu_channel;
}
this->video_fifo->put(this->video_fifo, buf);
}
-static void demux_ts_flush_media(demux_ts_media *m)
+static void demux_ts_send_buffer(demux_ts_media *m, int flags)
{
if (m->buf) {
m->buf->content = m->buf->mem;
- m->buf->size = m->buffered_bytes;
m->buf->type = m->type;
- m->buf->decoder_flags |= BUF_FLAG_FRAME_END;
+ m->buf->decoder_flags |= flags;
m->buf->pts = m->pts;
+ m->buf->decoder_info[0] = 1;
m->buf->extra_info->input_normpos = m->input_normpos;
m->buf->extra_info->input_time = m->input_time;
+
m->fifo->put(m->fifo, m->buf);
- m->buffered_bytes = 0;
m->buf = NULL;
+
+#ifdef TS_LOG
+ printf ("demux_ts: produced buffer, pts=%lld\n", m->pts);
+#endif
}
}
+static void demux_ts_flush_media(demux_ts_media *m)
+{
+ demux_ts_send_buffer(m, BUF_FLAG_FRAME_END);
+}
+
static void demux_ts_flush(demux_ts_t *this)
{
unsigned int i;
@@ -1089,25 +1098,11 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts,
m->counter++;
if (pus) { /* new PES packet */
- if (m->buffered_bytes) {
-
- m->buf->content = m->buf->mem;
- m->buf->size = m->buffered_bytes;
- m->buf->type = m->type;
- m->buf->decoder_flags |= BUF_FLAG_FRAME_END;
- m->buf->pts = m->pts;
- m->buf->decoder_info[0] = 1;
- m->buf->extra_info->input_normpos = m->input_normpos;
- m->buf->extra_info->input_time = m->input_time;
- m->fifo->put(m->fifo, m->buf);
- m->buffered_bytes = 0;
- m->buf = NULL; /* forget about buf -- not our responsibility anymore */
-#ifdef TS_LOG
- printf ("demux_ts: produced buffer, pts=%lld\n", m->pts);
-#endif
- }
+
+ demux_ts_flush_media(m);
+
/* allocate the buffer here, as pes_header needs a valid buf for dvbsubs */
- m->buf = m->fifo->buffer_pool_alloc(m->fifo);
+ m->buf = m->fifo->buffer_pool_alloc(m->fifo);
if (!demux_ts_parse_pes_header(this->stream->xine, m, ts, len)) {
m->buf->free_buffer(m->buf);
@@ -1120,7 +1115,7 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts,
m->corrupted_pes = 0;
memcpy(m->buf->mem, ts+len-m->size, m->size);
- m->buffered_bytes = m->size;
+ m->buf->size = m->size;
/* cache frame position */
off_t length = this->input->get_length (this->input);
@@ -1140,25 +1135,12 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts,
} else if (!m->corrupted_pes) { /* no pus -- PES packet continuation */
- if ((m->buffered_bytes + len) > MAX_PES_BUF_SIZE) {
- m->buf->content = m->buf->mem;
- m->buf->size = m->buffered_bytes;
- m->buf->type = m->type;
- m->buf->pts = m->pts;
- m->buf->decoder_info[0] = 1;
- m->buf->extra_info->input_normpos = m->input_normpos;
- m->buf->extra_info->input_time = m->input_time;
- m->fifo->put(m->fifo, m->buf);
- m->buffered_bytes = 0;
+ if ((m->buf->size + len) > MAX_PES_BUF_SIZE) {
+ demux_ts_send_buffer(m, 0);
m->buf = m->fifo->buffer_pool_alloc(m->fifo);
-
-#ifdef TS_LOG
- printf ("demux_ts: produced buffer, pts=%lld\n", m->pts);
-#endif
-
}
- memcpy(m->buf->mem + m->buffered_bytes, ts, len);
- m->buffered_bytes += len;
+ memcpy(m->buf->mem + m->buf->size, ts, len);
+ m->buf->size += len;
}
}
@@ -1182,7 +1164,6 @@ static void demux_ts_pes_new(demux_ts_t*this,
m->counter = INVALID_CC;
m->descriptor_tag = descriptor;
m->corrupted_pes = 1;
- m->buffered_bytes = 0;
}
@@ -2282,17 +2263,23 @@ static int demux_ts_seek (demux_plugin_t *this_gen,
demux_ts_t *this = (demux_ts_t *) this_gen;
int i;
- start_time /= 1000;
start_pos = (off_t) ( (double) start_pos / 65535 *
this->input->get_length (this->input) );
if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
if ((!start_pos) && (start_time)) {
- start_pos = (int64_t)start_time * this->rate / 1000;
- }
- this->input->seek (this->input, start_pos, SEEK_SET);
+ if (this->input->seek_time) {
+ this->input->seek_time(this->input, start_time, SEEK_SET);
+ } else {
+ start_pos = (int64_t)start_time * this->rate / 1000;
+ this->input->seek (this->input, start_pos, SEEK_SET);
+ }
+
+ } else {
+ this->input->seek (this->input, start_pos, SEEK_SET);
+ }
}
this->send_newpts = 1;
@@ -2305,7 +2292,6 @@ static int demux_ts_seek (demux_plugin_t *this_gen,
m->buf = NULL;
m->counter = INVALID_CC;
m->corrupted_pes = 1;
- m->buffered_bytes = 0;
}
if( !playing ) {