static off_t align_to_next_packet(hb_stream_t *stream);
static int64_t pes_timestamp( const uint8_t *pes );
-static void hb_ts_stream_init(hb_stream_t *stream);
+static int hb_ts_stream_init(hb_stream_t *stream);
static hb_buffer_t * hb_ts_stream_decode(hb_stream_t *stream);
static void hb_init_audio_list(hb_stream_t *stream, hb_title_t *title);
-static void hb_ts_stream_find_pids(hb_stream_t *stream);
+static int hb_ts_stream_find_pids(hb_stream_t *stream);
static void hb_ps_stream_init(hb_stream_t *stream);
static hb_buffer_t * hb_ps_stream_decode(hb_stream_t *stream);
" offset %d bytes", psize, offset);
stream->packetsize = psize;
stream->hb_stream_type = transport;
- hb_ts_stream_init(stream);
- return 1;
+ if (hb_ts_stream_init(stream) == 0)
+ return 1;
}
- if ( hb_stream_check_for_ps(stream) != 0 )
+ else if ( hb_stream_check_for_ps(stream) != 0 )
{
hb_log("file is MPEG Program Stream");
stream->hb_stream_type = program;
*
**********************************************************************/
-static void hb_ts_stream_init(hb_stream_t *stream)
+static int hb_ts_stream_init(hb_stream_t *stream)
{
int i;
stream->ts.packet = malloc( stream->packetsize );
// Find the audio and video pids in the stream
- hb_ts_stream_find_pids(stream);
+ if (hb_ts_stream_find_pids(stream) < 0)
+ {
+ return -1;
+ }
// hb_ts_resolve_pid_types reads some data, so the TS buffers
// are needed here.
hb_stream_delete_ts_entry(stream, i);
}
}
+ return 0;
}
static void hb_ps_stream_init(hb_stream_t *stream)
}
hb_stream_seek( stream, 0.2 );
}
-done:
hb_buffer_close( &buf );
}
}
-static void hb_ts_stream_find_pids(hb_stream_t *stream)
+static int hb_ts_stream_find_pids(hb_stream_t *stream)
{
// To be different from every other broadcaster in the world, New Zealand TV
// changes PMTs (and thus video & audio PIDs) when 'programs' change. Since
if ((pid == 0x0000) && (stream->ts_number_pat_entries == 0))
{
- decode_PAT(buf, stream);
- continue;
+ decode_PAT(buf, stream);
+ continue;
}
int pat_index = 0;
if (stream->pat_info[pat_index].program_number != 0 &&
pid == stream->pat_info[pat_index].program_map_PID)
{
- if (build_program_map(buf, stream) > 0)
- break;
+ if (build_program_map(buf, stream) > 0)
+ {
+ break;
+ }
}
}
// Keep going until we have a complete set of PIDs
if ( ts_index_of_video( stream ) >= 0 )
break;
}
+ if ( ts_index_of_video( stream ) < 0 )
+ return -1;
update_ts_streams( stream, stream->pmt_info.PCR_PID, 0, -1, P, NULL );
- }
+ return 0;
+}
// convert a PES PTS or DTS to an int64