qtmux: Add new prefill recording mode

This sets up a moov with the correct sample positions beforehand and
only works with constant framerate, I-frame only streams.

Currently only support for ProRes and raw audio is implemented but
adding new codecs is just a matter of defining appropriate maximum frame
sizes.

https://bugzilla.gnome.org/show_bug.cgi?id=781447
This commit is contained in:
Sebastian Dröge 2017-03-09 10:15:34 +02:00
parent f0163a016c
commit 55f949676e
4 changed files with 934 additions and 20 deletions

View file

@ -2923,7 +2923,7 @@ atom_wave_copy_data (AtomWAVE * wave, guint8 ** buffer,
/* add samples to tables */
static void
void
atom_stsc_add_new_entry (AtomSTSC * stsc, guint32 first_chunk, guint32 nsamples)
{
gint len;
@ -3869,7 +3869,7 @@ atom_trak_add_subtitle_entry (AtomTRAK * trak, AtomsContext * context,
}
static void
void
atom_trak_set_constant_size_samples (AtomTRAK * trak, guint32 sample_size)
{
trak->mdia.minf.stbl.stsz.sample_size = sample_size;

View file

@ -923,10 +923,13 @@ void atom_trak_set_elst_entry (AtomTRAK * trak, gint index, guint32 dur
void atom_trak_edts_clear (AtomTRAK * trak);
guint32 atom_trak_get_timescale (AtomTRAK *trak);
guint32 atom_trak_get_id (AtomTRAK * trak);
void atom_trak_set_constant_size_samples (AtomTRAK * trak, guint32 sample_size);
void atom_stbl_add_samples (AtomSTBL * stbl, guint32 nsamples,
guint32 delta, guint32 size,
guint64 chunk_offset, gboolean sync,
gint64 pts_offset);
void atom_stsc_add_new_entry (AtomSTSC * stsc,
guint32 first_chunk, guint32 nsamples);
AtomMOOV* atom_moov_new (AtomsContext *context);
void atom_moov_free (AtomMOOV *moov);

File diff suppressed because it is too large Load diff

View file

@ -100,6 +100,9 @@ struct _GstQTPad
gboolean sparse;
/* bitrates */
guint32 avg_bitrate, max_bitrate;
/* expected sample duration */
guint expected_sample_duration_n;
guint expected_sample_duration_d;
/* for avg bitrate calculation */
guint64 total_bytes;
@ -147,6 +150,13 @@ struct _GstQTPad
GstVideoTimeCode *first_tc;
GstClockTime first_pts;
guint64 tc_pos;
/* for keeping track in pre-fill mode */
GArray *samples;
/* current sample */
GstAdapter *raw_audio_adapter;
guint64 raw_audio_adapter_offset;
GstClockTime raw_audio_adapter_pts;
};
typedef enum _GstQTMuxState
@ -162,7 +172,8 @@ typedef enum _GstQtMuxMode {
GST_QT_MUX_MODE_FRAGMENTED,
GST_QT_MUX_MODE_FRAGMENTED_STREAMABLE,
GST_QT_MUX_MODE_FAST_START,
GST_QT_MUX_MODE_ROBUST_RECORDING
GST_QT_MUX_MODE_ROBUST_RECORDING,
GST_QT_MUX_MODE_ROBUST_RECORDING_PREFILL,
} GstQtMuxMode;
struct _GstQTMux
@ -274,6 +285,8 @@ struct _GstQTMux
GstClockTime reserved_moov_update_period;
GstClockTime muxed_since_last_update;
gboolean reserved_prefill;
/* for request pad naming */
guint video_pads, audio_pads, subtitle_pads;
};