Write meta-seek information (seek heads).
Original commit message from CVS: Write meta-seek information (seek heads).
This commit is contained in:
parent
56a8d7c680
commit
814b3d25be
@ -1,8 +1,10 @@
|
|||||||
2004-09-09 Arwed v. Merkatz <v.merkatz@gmx.net>
|
2004-09-09 Arwed v. Merkatz <v.merkatz@gmx.net>
|
||||||
* gst/matroska/matroska-mux.h:
|
* gst/matroska/matroska-mux.h:
|
||||||
* gst/matroska/matroska-mux.c: (gst_matroska_mux_reset),
|
* gst/matroska/matroska-mux.c: (gst_matroska_mux_reset),
|
||||||
(gst_matroska_mux_finish), (gst_matroska_mux_write_data):
|
(gst_matroska_mux_start), (gst_matroska_mux_finish),
|
||||||
|
(gst_matroska_mux_write_data):
|
||||||
Write multiple blocks/frames per cluster.
|
Write multiple blocks/frames per cluster.
|
||||||
|
Write meta-seek information (seek heads).
|
||||||
|
|
||||||
2004-09-09 Scott Wheeler <wheeler@kde.org>
|
2004-09-09 Scott Wheeler <wheeler@kde.org>
|
||||||
|
|
||||||
|
@ -328,6 +328,11 @@ gst_matroska_mux_reset (GstElement * element)
|
|||||||
mux->cluster = 0;
|
mux->cluster = 0;
|
||||||
mux->cluster_time = 0;
|
mux->cluster_time = 0;
|
||||||
mux->cluster_pos = 0;
|
mux->cluster_pos = 0;
|
||||||
|
|
||||||
|
/* reset meta-seek index */
|
||||||
|
mux->num_meta_indexes = 0;
|
||||||
|
g_free (mux->meta_index);
|
||||||
|
mux->meta_index = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstPadLinkReturn
|
static GstPadLinkReturn
|
||||||
@ -734,6 +739,7 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
|
|||||||
guint32 seekhead_id[] = { GST_MATROSKA_ID_INFO,
|
guint32 seekhead_id[] = { GST_MATROSKA_ID_INFO,
|
||||||
GST_MATROSKA_ID_TRACKS,
|
GST_MATROSKA_ID_TRACKS,
|
||||||
GST_MATROSKA_ID_CUES,
|
GST_MATROSKA_ID_CUES,
|
||||||
|
GST_MATROSKA_ID_SEEKHEAD,
|
||||||
#if 0
|
#if 0
|
||||||
GST_MATROSKA_ID_TAGS,
|
GST_MATROSKA_ID_TAGS,
|
||||||
#endif
|
#endif
|
||||||
@ -870,6 +876,28 @@ gst_matroska_mux_finish (GstMatroskaMux * mux)
|
|||||||
gst_ebml_write_flush_cache (ebml);
|
gst_ebml_write_flush_cache (ebml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mux->meta_index != NULL) {
|
||||||
|
guint n;
|
||||||
|
guint64 master, seekentry_master;
|
||||||
|
|
||||||
|
mux->meta_pos = ebml->pos;
|
||||||
|
gst_ebml_write_set_cache (ebml, 12 + 28 * mux->num_meta_indexes);
|
||||||
|
master = gst_ebml_write_master_start (ebml, GST_MATROSKA_ID_SEEKHEAD);
|
||||||
|
|
||||||
|
for (n = 0; n < mux->num_meta_indexes; n++) {
|
||||||
|
GstMatroskaMetaSeekIndex *idx = &mux->meta_index[n];
|
||||||
|
|
||||||
|
seekentry_master = gst_ebml_write_master_start (ebml,
|
||||||
|
GST_MATROSKA_ID_SEEKENTRY);
|
||||||
|
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_SEEKID, idx->id);
|
||||||
|
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_SEEKPOSITION,
|
||||||
|
idx->pos - mux->segment_master);
|
||||||
|
gst_ebml_write_master_finish (ebml, seekentry_master);
|
||||||
|
}
|
||||||
|
gst_ebml_write_master_finish (ebml, master);
|
||||||
|
}
|
||||||
|
gst_ebml_write_flush_cache (ebml);
|
||||||
|
|
||||||
/* FIXME: tags */
|
/* FIXME: tags */
|
||||||
|
|
||||||
/* update seekhead. We know that:
|
/* update seekhead. We know that:
|
||||||
@ -897,6 +925,17 @@ gst_matroska_mux_finish (GstMatroskaMux * mux)
|
|||||||
gst_ebml_write_buffer_header (ebml, GST_EBML_ID_VOID, 26);
|
gst_ebml_write_buffer_header (ebml, GST_EBML_ID_VOID, 26);
|
||||||
gst_ebml_write_seek (ebml, my_pos);
|
gst_ebml_write_seek (ebml, my_pos);
|
||||||
}
|
}
|
||||||
|
if (mux->meta_index != NULL) {
|
||||||
|
gst_ebml_replace_uint (ebml, mux->seekhead_pos + 116,
|
||||||
|
mux->meta_pos - mux->segment_master);
|
||||||
|
} else {
|
||||||
|
/* void'ify */
|
||||||
|
guint64 my_pos = ebml->pos;
|
||||||
|
|
||||||
|
gst_ebml_write_seek (ebml, mux->seekhead_pos + 96);
|
||||||
|
gst_ebml_write_buffer_header (ebml, GST_EBML_ID_VOID, 26);
|
||||||
|
gst_ebml_write_seek (ebml, my_pos);
|
||||||
|
}
|
||||||
#if 0
|
#if 0
|
||||||
gst_ebml_replace_uint (ebml, mux->seekhead_pos + 116,
|
gst_ebml_replace_uint (ebml, mux->seekhead_pos + 116,
|
||||||
mux->tags_pos - mux->segment_master);
|
mux->tags_pos - mux->segment_master);
|
||||||
@ -977,6 +1016,8 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux)
|
|||||||
if (mux->cluster) {
|
if (mux->cluster) {
|
||||||
/* start a new cluster every two seconds */
|
/* start a new cluster every two seconds */
|
||||||
if (mux->cluster_time + GST_SECOND * 2 < GST_BUFFER_TIMESTAMP (buf)) {
|
if (mux->cluster_time + GST_SECOND * 2 < GST_BUFFER_TIMESTAMP (buf)) {
|
||||||
|
GstMatroskaMetaSeekIndex *idx;
|
||||||
|
|
||||||
gst_ebml_write_master_finish (ebml, mux->cluster);
|
gst_ebml_write_master_finish (ebml, mux->cluster);
|
||||||
mux->cluster_pos = ebml->pos;
|
mux->cluster_pos = ebml->pos;
|
||||||
mux->cluster =
|
mux->cluster =
|
||||||
@ -984,14 +1025,32 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux)
|
|||||||
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_CLUSTERTIMECODE,
|
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_CLUSTERTIMECODE,
|
||||||
GST_BUFFER_TIMESTAMP (buf) / mux->time_scale);
|
GST_BUFFER_TIMESTAMP (buf) / mux->time_scale);
|
||||||
mux->cluster_time = GST_BUFFER_TIMESTAMP (buf);
|
mux->cluster_time = GST_BUFFER_TIMESTAMP (buf);
|
||||||
|
|
||||||
|
if (mux->num_meta_indexes % 32 == 0) {
|
||||||
|
mux->meta_index = g_renew (GstMatroskaMetaSeekIndex, mux->meta_index,
|
||||||
|
mux->num_meta_indexes + 32);
|
||||||
|
}
|
||||||
|
idx = &mux->meta_index[mux->num_meta_indexes++];
|
||||||
|
idx->id = GST_MATROSKA_ID_CLUSTER;
|
||||||
|
idx->pos = mux->cluster_pos;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* first cluster */
|
/* first cluster */
|
||||||
|
GstMatroskaMetaSeekIndex *idx;
|
||||||
|
|
||||||
mux->cluster_pos = ebml->pos;
|
mux->cluster_pos = ebml->pos;
|
||||||
mux->cluster = gst_ebml_write_master_start (ebml, GST_MATROSKA_ID_CLUSTER);
|
mux->cluster = gst_ebml_write_master_start (ebml, GST_MATROSKA_ID_CLUSTER);
|
||||||
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_CLUSTERTIMECODE,
|
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_CLUSTERTIMECODE,
|
||||||
GST_BUFFER_TIMESTAMP (buf) / mux->time_scale);
|
GST_BUFFER_TIMESTAMP (buf) / mux->time_scale);
|
||||||
mux->cluster_time = GST_BUFFER_TIMESTAMP (buf);
|
mux->cluster_time = GST_BUFFER_TIMESTAMP (buf);
|
||||||
|
|
||||||
|
if (mux->num_meta_indexes % 32 == 0) {
|
||||||
|
mux->meta_index = g_renew (GstMatroskaMetaSeekIndex, mux->meta_index,
|
||||||
|
mux->num_meta_indexes + 32);
|
||||||
|
}
|
||||||
|
idx = &mux->meta_index[mux->num_meta_indexes++];
|
||||||
|
idx->id = GST_MATROSKA_ID_CLUSTER;
|
||||||
|
idx->pos = mux->cluster_pos;
|
||||||
}
|
}
|
||||||
cluster = mux->cluster;
|
cluster = mux->cluster;
|
||||||
|
|
||||||
|
@ -62,6 +62,11 @@ typedef enum {
|
|||||||
GST_MATROSKA_MUX_STATE_DATA,
|
GST_MATROSKA_MUX_STATE_DATA,
|
||||||
} GstMatroskaMuxState;
|
} GstMatroskaMuxState;
|
||||||
|
|
||||||
|
typedef struct _GstMatroskaMetaSeekIndex {
|
||||||
|
guint32 id;
|
||||||
|
guint64 pos;
|
||||||
|
} GstMatroskaMetaSeekIndex;
|
||||||
|
|
||||||
typedef struct _GstMatroskaMux {
|
typedef struct _GstMatroskaMux {
|
||||||
GstEbmlWrite parent;
|
GstEbmlWrite parent;
|
||||||
|
|
||||||
@ -101,13 +106,18 @@ typedef struct _GstMatroskaMux {
|
|||||||
#endif
|
#endif
|
||||||
info_pos,
|
info_pos,
|
||||||
tracks_pos,
|
tracks_pos,
|
||||||
duration_pos;
|
duration_pos,
|
||||||
|
meta_pos;
|
||||||
guint64 segment_master;
|
guint64 segment_master;
|
||||||
|
|
||||||
/* current cluster */
|
/* current cluster */
|
||||||
guint64 cluster,
|
guint64 cluster,
|
||||||
cluster_time,
|
cluster_time,
|
||||||
cluster_pos;
|
cluster_pos;
|
||||||
|
|
||||||
|
/* meta-seek info */
|
||||||
|
GstMatroskaMetaSeekIndex *meta_index;
|
||||||
|
guint num_meta_indexes;
|
||||||
} GstMatroskaMux;
|
} GstMatroskaMux;
|
||||||
|
|
||||||
typedef struct _GstMatroskaMuxClass {
|
typedef struct _GstMatroskaMuxClass {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user