kopia lustrzana https://github.com/kierank/libmpegts
Add low latency mode
rodzic
d3d4983161
commit
0e03d83428
1
common.h
1
common.h
|
@ -295,6 +295,7 @@ struct ts_writer_t
|
||||||
|
|
||||||
int cbr;
|
int cbr;
|
||||||
int ts_muxrate;
|
int ts_muxrate;
|
||||||
|
int lowlatency;
|
||||||
|
|
||||||
int pat_cc;
|
int pat_cc;
|
||||||
|
|
||||||
|
|
18
libmpegts.c
18
libmpegts.c
|
@ -1693,7 +1693,7 @@ int ts_write_frames( ts_writer_t *w, ts_frame_t *frames, int num_frames, uint8_t
|
||||||
new_pes[i]->header_size = write_pes( w, program, &frames[i], new_pes[i] );
|
new_pes[i]->header_size = write_pes( w, program, &frames[i], new_pes[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !initial_queued_pes )
|
if( !w->lowlatency && !initial_queued_pes )
|
||||||
{
|
{
|
||||||
out = NULL;
|
out = NULL;
|
||||||
*len = 0;
|
*len = 0;
|
||||||
|
@ -1711,12 +1711,25 @@ int ts_write_frames( ts_writer_t *w, ts_frame_t *frames, int num_frames, uint8_t
|
||||||
w->first_input = 1;
|
w->first_input = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* loop through and find the time when the second video packet in the queue can arrive */
|
|
||||||
int video_found = 0;
|
int video_found = 0;
|
||||||
int64_t pcr_stop = 0;
|
int64_t pcr_stop = 0;
|
||||||
|
|
||||||
cur_pcr = get_pcr_int( w, 0 );
|
cur_pcr = get_pcr_int( w, 0 );
|
||||||
|
|
||||||
|
if( w->lowlatency )
|
||||||
|
{
|
||||||
|
/* Find the latest arrival time in the batch of packets delivered */
|
||||||
|
for( int i = 0; i < w->num_buffered_frames; i++ )
|
||||||
|
{
|
||||||
|
stream = queued_pes[i]->stream;
|
||||||
|
if( queued_pes[i]->final_arrival_time > pcr_stop )
|
||||||
|
pcr_stop = queued_pes[i]->final_arrival_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* loop through and find the time when the second video packet in the queue can arrive */
|
||||||
for( int i = 0; i < w->num_buffered_frames; i++ )
|
for( int i = 0; i < w->num_buffered_frames; i++ )
|
||||||
{
|
{
|
||||||
stream = queued_pes[i]->stream;
|
stream = queued_pes[i]->stream;
|
||||||
|
@ -1731,6 +1744,7 @@ int ts_write_frames( ts_writer_t *w, ts_frame_t *frames, int num_frames, uint8_t
|
||||||
pcr_stop = queued_pes[i]->initial_arrival_time; /* earliest that a frame can arrive */
|
pcr_stop = queued_pes[i]->initial_arrival_time; /* earliest that a frame can arrive */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while( cur_pcr < pcr_stop )
|
while( cur_pcr < pcr_stop )
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue