mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
Port matroska muxer to 0.9 (#318847).
Original commit message from CVS: Reviewed by: Tim-Philipp Müller <tim at centricular dot net> * configure.ac: * gst/matroska/Makefile.am: * gst/matroska/ebml-ids.h: * gst/matroska/ebml-write.c: * gst/matroska/ebml-write.h: * gst/matroska/matroska-ids.h: * gst/matroska/matroska-mux.c: * gst/matroska/matroska-mux.h: * gst/matroska/matroska.c: (plugin_init): Port matroska muxer to 0.9 (#318847).
This commit is contained in:
parent
fb495736bc
commit
22b9a5cd43
10 changed files with 932 additions and 375 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2005-10-14 Michal Benes <michal dot benes at xeris dot cz>
|
||||
|
||||
Reviewed by: Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* configure.ac:
|
||||
* gst/matroska/Makefile.am:
|
||||
* gst/matroska/ebml-ids.h:
|
||||
* gst/matroska/ebml-write.c:
|
||||
* gst/matroska/ebml-write.h:
|
||||
* gst/matroska/matroska-ids.h:
|
||||
* gst/matroska/matroska-mux.c:
|
||||
* gst/matroska/matroska-mux.h:
|
||||
* gst/matroska/matroska.c: (plugin_init):
|
||||
Port matroska muxer to 0.9 (#318847).
|
||||
|
||||
2005-10-13 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* ext/speex/gstspeexenc.c: (gst_speexenc_get_tag_value),
|
||||
|
|
|
@ -275,6 +275,7 @@ GST_PLUGINS_ALL="\
|
|||
goom \
|
||||
law \
|
||||
level \
|
||||
matroska \
|
||||
rtp \
|
||||
rtsp \
|
||||
smpte \
|
||||
|
@ -593,6 +594,7 @@ gst/effectv/Makefile
|
|||
gst/goom/Makefile
|
||||
gst/law/Makefile
|
||||
gst/level/Makefile
|
||||
gst/matroska/Makefile
|
||||
gst/rtp/Makefile
|
||||
gst/rtsp/Makefile
|
||||
gst/smpte/Makefile
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
plugin_LTLIBRARIES = libgstmatroska.la
|
||||
|
||||
libgstmatroska_la_SOURCES = \
|
||||
ebml-read.c \
|
||||
ebml-write.c \
|
||||
matroska.c \
|
||||
matroska-demux.c \
|
||||
matroska-mux.c
|
||||
|
||||
# ebml-read.c
|
||||
# matroska-demux.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
ebml-ids.h \
|
||||
ebml-read.h \
|
||||
|
@ -15,6 +16,14 @@ noinst_HEADERS = \
|
|||
matroska-ids.h \
|
||||
matroska-mux.h
|
||||
|
||||
libgstmatroska_la_CFLAGS = $(GST_CFLAGS)
|
||||
libgstmatroska_la_LIBADD = $(GST_LIBS)
|
||||
libgstmatroska_la_CFLAGS = \
|
||||
$(GST_BASE_CFLAGS) \
|
||||
$(GST_PLUGINS_BASE_CFLAGS) \
|
||||
$(GST_CFLAGS) \
|
||||
-I$(top_srcdir)/gst-libs
|
||||
libgstmatroska_la_LIBADD = \
|
||||
$(GST_BASE_LIBS) \
|
||||
$(GST_PLUGINS_BASE_LIBS) \
|
||||
$(GST_LIBS) \
|
||||
-lgstriff-@GST_MAJORMINOR@
|
||||
libgstmatroska_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||
|
|
|
@ -27,6 +27,9 @@ G_BEGIN_DECLS
|
|||
/* EBML version supported */
|
||||
#define GST_EBML_VERSION 1
|
||||
|
||||
/* Unknown size (all bits set to 1) */
|
||||
#define GST_EBML_SIZE_UNKNOWN G_GINT64_CONSTANT(0x00ffffffffffffff)
|
||||
|
||||
/* top-level master-IDs */
|
||||
#define GST_EBML_ID_HEADER 0x1A45DFA3
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* GStreamer EBML I/O
|
||||
* (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
||||
* (c) 2005 Michal Benes <michal.benes@xeris.cz>
|
||||
*
|
||||
* ebml-write.c: write EBML data to file/stream
|
||||
*
|
||||
|
@ -28,85 +29,116 @@
|
|||
#include "ebml-write.h"
|
||||
#include "ebml-ids.h"
|
||||
|
||||
enum
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_ebml_write_debug);
|
||||
#define GST_CAT_DEFAULT gst_ebml_write_debug
|
||||
|
||||
#define _do_init(thing) \
|
||||
GST_DEBUG_CATEGORY_INIT (gst_ebml_write_debug, "GstEbmlWrite", 0, "Write EBML structured data")
|
||||
GST_BOILERPLATE_FULL (GstEbmlWrite, gst_ebml_write, GstObject, GST_TYPE_OBJECT,
|
||||
_do_init)
|
||||
|
||||
static void gst_ebml_write_finalize (GObject * object);
|
||||
|
||||
|
||||
static void gst_ebml_write_base_init (gpointer g_class)
|
||||
{
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static void gst_ebml_write_class_init (GstEbmlWriteClass * klass);
|
||||
static void gst_ebml_write_init (GstEbmlWrite * ebml);
|
||||
static GstStateChangeReturn gst_ebml_write_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
gst_ebml_write_get_type (void)
|
||||
{
|
||||
static GType gst_ebml_write_type = 0;
|
||||
|
||||
if (!gst_ebml_write_type) {
|
||||
static const GTypeInfo gst_ebml_write_info = {
|
||||
sizeof (GstEbmlWriteClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc) gst_ebml_write_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GstEbmlWrite),
|
||||
0,
|
||||
(GInstanceInitFunc) gst_ebml_write_init,
|
||||
};
|
||||
|
||||
gst_ebml_write_type =
|
||||
g_type_register_static (GST_TYPE_ELEMENT, "GstEbmlWrite",
|
||||
&gst_ebml_write_info, 0);
|
||||
}
|
||||
|
||||
return gst_ebml_write_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_ebml_write_class_init (GstEbmlWriteClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_class = (GstElementClass *) klass;
|
||||
GObjectClass *object = G_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
||||
|
||||
gstelement_class->change_state = gst_ebml_write_change_state;
|
||||
object->finalize = gst_ebml_write_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_ebml_write_init (GstEbmlWrite * ebml)
|
||||
gst_ebml_write_init (GstEbmlWrite * ebml, GstEbmlWriteClass * klass)
|
||||
{
|
||||
ebml->srcpad = NULL;
|
||||
ebml->pos = 0;
|
||||
|
||||
ebml->cache = NULL;
|
||||
ebml->cache_size = 0;
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_ebml_write_change_state (GstElement * element, GstStateChange transition)
|
||||
static void
|
||||
gst_ebml_write_finalize (GObject * object)
|
||||
{
|
||||
GstEbmlWrite *ebml = GST_EBML_WRITE (element);
|
||||
GstEbmlWrite *ebml = GST_EBML_WRITE (object);
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
ebml->pos = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
gst_object_unref (ebml->srcpad);
|
||||
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||
|
||||
return GST_STATE_CHANGE_SUCCESS;
|
||||
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
|
||||
}
|
||||
|
||||
/*
|
||||
* Caching.
|
||||
|
||||
/**
|
||||
* gst_ebml_write_new:
|
||||
* @srcpad: Source pad to which the output will be pushed.
|
||||
*
|
||||
* Creates a new #GstEbmlWrite.
|
||||
*
|
||||
* Returns: a new #GstEbmlWrite
|
||||
*/
|
||||
GstEbmlWrite *
|
||||
gst_ebml_write_new (GstPad * srcpad)
|
||||
{
|
||||
GstEbmlWrite *ebml =
|
||||
GST_EBML_WRITE (g_object_new (GST_TYPE_EBML_WRITE, NULL));
|
||||
|
||||
ebml->srcpad = gst_object_ref (srcpad);
|
||||
|
||||
gst_ebml_write_reset (ebml);
|
||||
|
||||
return ebml;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_ebml_write_reset:
|
||||
* @ebml: a #GstEbmlWrite.
|
||||
*
|
||||
* Reset internal state of #GstEbmlWrite.
|
||||
*/
|
||||
void
|
||||
gst_ebml_write_reset (GstEbmlWrite * ebml)
|
||||
{
|
||||
ebml->pos = 0;
|
||||
|
||||
if (ebml->cache) {
|
||||
gst_buffer_unref (ebml->cache);
|
||||
ebml->cache = NULL;
|
||||
}
|
||||
ebml->cache_size = 0;
|
||||
ebml->last_write_result = GST_FLOW_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_ebml_last_write_result:
|
||||
* @ebml: a #GstEbmlWrite.
|
||||
*
|
||||
* Returns: GST_FLOW_OK if there was not write error since the last call of
|
||||
* gst_ebml_last_write_result or code of the error.
|
||||
*/
|
||||
GstFlowReturn
|
||||
gst_ebml_last_write_result (GstEbmlWrite * ebml)
|
||||
{
|
||||
GstFlowReturn res = ebml->last_write_result;
|
||||
|
||||
ebml->last_write_result = GST_FLOW_OK;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_ebml_write_set_cache:
|
||||
* @ebml: a #GstEbmlWrite.
|
||||
* @size: size of the cache.
|
||||
* Create a cache.
|
||||
*
|
||||
* The idea is that you use this for writing a lot
|
||||
* of small elements. This will just "queue" all of
|
||||
|
@ -114,7 +146,6 @@ gst_ebml_write_change_state (GstElement * element, GstStateChange transition)
|
|||
* at once. This saves memory and time for buffer
|
||||
* allocation and init, and it looks better.
|
||||
*/
|
||||
|
||||
void
|
||||
gst_ebml_write_set_cache (GstEbmlWrite * ebml, guint size)
|
||||
{
|
||||
|
@ -124,11 +155,18 @@ gst_ebml_write_set_cache (GstEbmlWrite * ebml, guint size)
|
|||
g_return_if_fail (ebml->cache == NULL);
|
||||
|
||||
ebml->cache = gst_buffer_new_and_alloc (size);
|
||||
ebml->cache_size = size;
|
||||
GST_BUFFER_SIZE (ebml->cache) = 0;
|
||||
GST_BUFFER_OFFSET (ebml->cache) = ebml->pos;
|
||||
ebml->handled = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_ebml_write_flush_cache:
|
||||
* @ebml: a #GstEbmlWrite.
|
||||
*
|
||||
* Flush the cache.
|
||||
*/
|
||||
void
|
||||
gst_ebml_write_flush_cache (GstEbmlWrite * ebml)
|
||||
{
|
||||
|
@ -141,16 +179,25 @@ gst_ebml_write_flush_cache (GstEbmlWrite * ebml)
|
|||
g_assert (GST_BUFFER_SIZE (ebml->cache) +
|
||||
GST_BUFFER_OFFSET (ebml->cache) == ebml->pos);
|
||||
|
||||
gst_pad_push (ebml->srcpad, GST_DATA (ebml->cache));
|
||||
if (ebml->last_write_result == GST_FLOW_OK)
|
||||
ebml->last_write_result = gst_pad_push (ebml->srcpad, ebml->cache);
|
||||
|
||||
ebml->cache = NULL;
|
||||
ebml->cache_size = 0;
|
||||
ebml->handled = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* One-element buffer, in case of no cache. If there is
|
||||
* a cache, use that instead.
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_ebml_write_element_new:
|
||||
* @ebml: a #GstEbmlWrite.
|
||||
* @size: size of the requested buffer.
|
||||
*
|
||||
* Create a buffer for one element. If there is
|
||||
* a cache, use that instead.
|
||||
*
|
||||
* Returns: A new #GstBuffer.
|
||||
*/
|
||||
static GstBuffer *
|
||||
gst_ebml_write_element_new (GstEbmlWrite * ebml, guint size)
|
||||
{
|
||||
|
@ -162,7 +209,7 @@ gst_ebml_write_element_new (GstEbmlWrite * ebml, guint size)
|
|||
|
||||
/* prefer cache */
|
||||
if (ebml->cache) {
|
||||
if (GST_BUFFER_MAXSIZE (ebml->cache) - GST_BUFFER_SIZE (ebml->cache) < size) {
|
||||
if (ebml->cache_size - GST_BUFFER_SIZE (ebml->cache) < size) {
|
||||
GST_LOG ("Cache available, but too small. Clearing...");
|
||||
gst_ebml_write_flush_cache (ebml);
|
||||
} else {
|
||||
|
@ -177,10 +224,14 @@ gst_ebml_write_element_new (GstEbmlWrite * ebml, guint size)
|
|||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* gst_ebml_write_element_id:
|
||||
* @buf: Buffer to which id should be written.
|
||||
* @id: Element ID that should be written.
|
||||
*
|
||||
* Write element ID into a buffer.
|
||||
*/
|
||||
|
||||
static void
|
||||
gst_ebml_write_element_id (GstBuffer * buf, guint32 id)
|
||||
{
|
||||
|
@ -208,29 +259,38 @@ gst_ebml_write_element_id (GstBuffer * buf, guint32 id)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* gst_ebml_write_element_size:
|
||||
* @buf: #GstBuffer to which size should be written.
|
||||
* @size: Element length.
|
||||
*
|
||||
* Write element length into a buffer.
|
||||
*/
|
||||
|
||||
static void
|
||||
gst_ebml_write_element_size (GstBuffer * buf, guint64 size)
|
||||
{
|
||||
guint8 *data = GST_BUFFER_DATA (buf) + GST_BUFFER_SIZE (buf);
|
||||
guint bytes = 1, mask = 0x80;
|
||||
|
||||
/* how many bytes? */
|
||||
while ((size >> ((bytes - 1) * 8)) >= mask && bytes <= 8) {
|
||||
mask >>= 1;
|
||||
bytes++;
|
||||
}
|
||||
if (size != GST_EBML_SIZE_UNKNOWN) {
|
||||
/* how many bytes? - use mask-1 because an all-1 bitset is not allowed */
|
||||
while ((size >> ((bytes - 1) * 8)) >= (mask - 1) && bytes <= 8) {
|
||||
mask >>= 1;
|
||||
bytes++;
|
||||
}
|
||||
|
||||
/* if invalid size, use max. */
|
||||
if (bytes > 8) {
|
||||
GST_WARNING ("Invalid size, maximizing");
|
||||
/* if invalid size, use max. */
|
||||
if (bytes > 8) {
|
||||
GST_WARNING ("Invalid size, writing size unknown");
|
||||
mask = 0x01;
|
||||
bytes = 8;
|
||||
/* Now here's a real FIXME: we cannot read those yet! */
|
||||
size = GST_EBML_SIZE_UNKNOWN;
|
||||
}
|
||||
} else {
|
||||
mask = 0x01;
|
||||
bytes = 8;
|
||||
/* Now here's a real FIXME: we cannot read those yet! */
|
||||
size = G_GINT64_CONSTANT (0x00ffffffffffffff);
|
||||
}
|
||||
|
||||
/* write out, BE, with length size marker */
|
||||
|
@ -243,10 +303,15 @@ gst_ebml_write_element_size (GstBuffer * buf, guint64 size)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* gst_ebml_write_element_data:
|
||||
* @buf: #GstBuffer to which data should be written.
|
||||
* @write: Data that should be written.
|
||||
* @length: Length of the data.
|
||||
*
|
||||
* Write element data into a buffer.
|
||||
*/
|
||||
|
||||
static void
|
||||
gst_ebml_write_element_data (GstBuffer * buf, guint8 * write, guint64 length)
|
||||
{
|
||||
|
@ -256,10 +321,14 @@ gst_ebml_write_element_data (GstBuffer * buf, guint8 * write, guint64 length)
|
|||
GST_BUFFER_SIZE (buf) += length;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* gst_ebml_write_element_push:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @buf: #GstBuffer to be written.
|
||||
*
|
||||
* Write out buffer by moving it to the next element.
|
||||
*/
|
||||
|
||||
static void
|
||||
gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf)
|
||||
{
|
||||
|
@ -276,25 +345,30 @@ gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf)
|
|||
return;
|
||||
}
|
||||
|
||||
gst_pad_push (ebml->srcpad, GST_DATA (buf));
|
||||
if (ebml->last_write_result == GST_FLOW_OK)
|
||||
ebml->last_write_result = gst_pad_push (ebml->srcpad, buf);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* gst_ebml_write_seek:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @pos: Seek position.
|
||||
*
|
||||
* Seek.
|
||||
*/
|
||||
|
||||
void
|
||||
gst_ebml_write_seek (GstEbmlWrite * ebml, guint64 pos)
|
||||
{
|
||||
GstEvent *seek;
|
||||
GstPad *peer_pad;
|
||||
|
||||
/* Cache seeking. A bit dangerous, we assume the client writer
|
||||
* knows what he's doing... */
|
||||
if (ebml->cache) {
|
||||
/* within bounds? */
|
||||
if (pos >= GST_BUFFER_OFFSET (ebml->cache) &&
|
||||
pos <
|
||||
GST_BUFFER_OFFSET (ebml->cache) + GST_BUFFER_MAXSIZE (ebml->cache)) {
|
||||
pos < GST_BUFFER_OFFSET (ebml->cache) + ebml->cache_size) {
|
||||
GST_BUFFER_SIZE (ebml->cache) = pos - GST_BUFFER_OFFSET (ebml->cache);
|
||||
if (ebml->pos > pos)
|
||||
ebml->handled -= ebml->pos - pos;
|
||||
|
@ -307,15 +381,27 @@ gst_ebml_write_seek (GstEbmlWrite * ebml, guint64 pos)
|
|||
}
|
||||
}
|
||||
|
||||
seek = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, pos);
|
||||
gst_pad_push (ebml->srcpad, GST_DATA (seek));
|
||||
seek = gst_event_new_newsegment (FALSE, 1.0, GST_FORMAT_BYTES,
|
||||
pos, -1, GST_CLOCK_TIME_NONE);
|
||||
peer_pad = GST_PAD_PEER (ebml->srcpad);
|
||||
if (peer_pad) {
|
||||
gst_pad_send_event (peer_pad, seek);
|
||||
} else {
|
||||
GST_WARNING_OBJECT (ebml, "Can not seek: no peer pad");
|
||||
}
|
||||
|
||||
ebml->pos = pos;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get no. bytes needed to write a uint.
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_ebml_write_get_uint_size:
|
||||
* @num: Number to be encoded.
|
||||
*
|
||||
* Get number of bytes needed to write a uint.
|
||||
*
|
||||
* Returns: Encoded uint length.
|
||||
*/
|
||||
static guint
|
||||
gst_ebml_write_get_uint_size (guint64 num)
|
||||
{
|
||||
|
@ -330,10 +416,14 @@ gst_ebml_write_get_uint_size (guint64 num)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* gst_ebml_write_set_uint:
|
||||
* @buf: #GstBuffer to which ithe number should be written.
|
||||
* @num: Number to be written.
|
||||
* @size: Encoded number length.
|
||||
*
|
||||
* Write an uint into a buffer.
|
||||
*/
|
||||
|
||||
static void
|
||||
gst_ebml_write_set_uint (GstBuffer * buf, guint64 num, guint size)
|
||||
{
|
||||
|
@ -347,10 +437,15 @@ gst_ebml_write_set_uint (GstBuffer * buf, guint64 num, guint size)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Data type wrappers.
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_ebml_write_uint:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @id: Element ID.
|
||||
* @num: Number to be written.
|
||||
*
|
||||
* Write uint element.
|
||||
*/
|
||||
void
|
||||
gst_ebml_write_uint (GstEbmlWrite * ebml, guint32 id, guint64 num)
|
||||
{
|
||||
|
@ -364,6 +459,15 @@ gst_ebml_write_uint (GstEbmlWrite * ebml, guint32 id, guint64 num)
|
|||
gst_ebml_write_element_push (ebml, buf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_ebml_write_sint:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @id: Element ID.
|
||||
* @num: Number to be written.
|
||||
*
|
||||
* Write sint element.
|
||||
*/
|
||||
void
|
||||
gst_ebml_write_sint (GstEbmlWrite * ebml, guint32 id, gint64 num)
|
||||
{
|
||||
|
@ -392,6 +496,15 @@ gst_ebml_write_sint (GstEbmlWrite * ebml, guint32 id, gint64 num)
|
|||
gst_ebml_write_element_push (ebml, buf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_ebml_write_float:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @id: Element ID.
|
||||
* @num: Number to be written.
|
||||
*
|
||||
* Write float element.
|
||||
*/
|
||||
void
|
||||
gst_ebml_write_float (GstEbmlWrite * ebml, guint32 id, gdouble num)
|
||||
{
|
||||
|
@ -413,6 +526,15 @@ gst_ebml_write_float (GstEbmlWrite * ebml, guint32 id, gdouble num)
|
|||
gst_ebml_write_element_push (ebml, buf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_ebml_write_ascii:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @id: Element ID.
|
||||
* @str: String to be written.
|
||||
*
|
||||
* Write string element.
|
||||
*/
|
||||
void
|
||||
gst_ebml_write_ascii (GstEbmlWrite * ebml, guint32 id, const gchar * str)
|
||||
{
|
||||
|
@ -425,25 +547,49 @@ gst_ebml_write_ascii (GstEbmlWrite * ebml, guint32 id, const gchar * str)
|
|||
gst_ebml_write_element_push (ebml, buf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_ebml_write_utf8:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @id: Element ID.
|
||||
* @str: String to be written.
|
||||
*
|
||||
* Write utf8 encoded string element.
|
||||
*/
|
||||
void
|
||||
gst_ebml_write_utf8 (GstEbmlWrite * ebml, guint32 id, const gchar * str)
|
||||
{
|
||||
gst_ebml_write_ascii (ebml, id, str);
|
||||
}
|
||||
|
||||
/* date should be in seconds since the unix epoch */
|
||||
|
||||
/**
|
||||
* gst_ebml_write_date:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @id: Element ID.
|
||||
* @date: Date in seconds since the unix epoch.
|
||||
*
|
||||
* Write date element.
|
||||
*/
|
||||
void
|
||||
gst_ebml_write_date (GstEbmlWrite * ebml, guint32 id, gint64 date)
|
||||
{
|
||||
gst_ebml_write_sint (ebml, id, (date - GST_EBML_DATE_OFFSET) * GST_SECOND);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* gst_ebml_write_master_start:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @id: Element ID.
|
||||
*
|
||||
* Start wiriting mater element.
|
||||
*
|
||||
* Master writing is annoying. We use a size marker of
|
||||
* the max. allowed length, so that we can later fill it
|
||||
* in validly.
|
||||
*
|
||||
* Returns: Master starting position.
|
||||
*/
|
||||
|
||||
guint64
|
||||
gst_ebml_write_master_start (GstEbmlWrite * ebml, guint32 id)
|
||||
{
|
||||
|
@ -453,12 +599,20 @@ gst_ebml_write_master_start (GstEbmlWrite * ebml, guint32 id)
|
|||
t = GST_BUFFER_SIZE (buf);
|
||||
gst_ebml_write_element_id (buf, id);
|
||||
pos += GST_BUFFER_SIZE (buf) - t;
|
||||
gst_ebml_write_element_size (buf, -1);
|
||||
gst_ebml_write_element_size (buf, GST_EBML_SIZE_UNKNOWN);
|
||||
gst_ebml_write_element_push (ebml, buf);
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_ebml_write_master_finish:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @startpos: Master starting position.
|
||||
*
|
||||
* Finish writing master element.
|
||||
*/
|
||||
void
|
||||
gst_ebml_write_master_finish (GstEbmlWrite * ebml, guint64 startpos)
|
||||
{
|
||||
|
@ -476,6 +630,16 @@ gst_ebml_write_master_finish (GstEbmlWrite * ebml, guint64 startpos)
|
|||
gst_ebml_write_seek (ebml, pos);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_ebml_write_binary:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @id: Element ID.
|
||||
* @binary: Data to be written.
|
||||
* @length: Length of the data
|
||||
*
|
||||
* Write an element with binary data.
|
||||
*/
|
||||
void
|
||||
gst_ebml_write_binary (GstEbmlWrite * ebml,
|
||||
guint32 id, guint8 * binary, guint64 length)
|
||||
|
@ -488,13 +652,20 @@ gst_ebml_write_binary (GstEbmlWrite * ebml,
|
|||
gst_ebml_write_element_push (ebml, buf);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* gst_ebml_write_buffer_header:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @id: Element ID.
|
||||
* @length: Length of the data
|
||||
*
|
||||
* Write header of the binary element (use with gst_ebml_write_buffer function).
|
||||
*
|
||||
* For things like video frames and audio samples,
|
||||
* you want to use this function, as it doesn't have
|
||||
* the overhead of memcpy() that other functions
|
||||
* such as write_binary() do have.
|
||||
*/
|
||||
|
||||
void
|
||||
gst_ebml_write_buffer_header (GstEbmlWrite * ebml, guint32 id, guint64 length)
|
||||
{
|
||||
|
@ -505,13 +676,29 @@ gst_ebml_write_buffer_header (GstEbmlWrite * ebml, guint32 id, guint64 length)
|
|||
gst_ebml_write_element_push (ebml, buf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_ebml_write_buffer:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @data: #GstBuffer cointaining the data.
|
||||
*
|
||||
* Write binary element (see gst_ebml_write_buffer_header).
|
||||
*/
|
||||
void
|
||||
gst_ebml_write_buffer (GstEbmlWrite * ebml, GstBuffer * data)
|
||||
{
|
||||
gst_ebml_write_element_push (ebml, data);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* gst_ebml_replace_uint:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @pos: Position of the uint that should be replaced.
|
||||
* @num: New value.
|
||||
*
|
||||
* Replace uint with a new value.
|
||||
*
|
||||
* When replacing a uint, we assume that it is *always*
|
||||
* 8-byte, since that's the safest guess we can do. This
|
||||
* is just for simplicity.
|
||||
|
@ -519,7 +706,6 @@ gst_ebml_write_buffer (GstEbmlWrite * ebml, GstBuffer * data)
|
|||
* FIXME: this function needs to be replaced with something
|
||||
* proper. This is a crude hack.
|
||||
*/
|
||||
|
||||
void
|
||||
gst_ebml_replace_uint (GstEbmlWrite * ebml, guint64 pos, guint64 num)
|
||||
{
|
||||
|
@ -533,10 +719,14 @@ gst_ebml_replace_uint (GstEbmlWrite * ebml, guint64 pos, guint64 num)
|
|||
gst_ebml_write_seek (ebml, oldpos);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* gst_ebml_write_header:
|
||||
* @ebml: #GstEbmlWrite
|
||||
* @doctype: Document type.
|
||||
* @version: Document type version.
|
||||
*
|
||||
* Write EBML header.
|
||||
*/
|
||||
|
||||
void
|
||||
gst_ebml_write_header (GstEbmlWrite * ebml, gchar * doctype, guint version)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* GStreamer EBML I/O
|
||||
* (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
||||
* (c) 2005 Michal Benes <michal.benes@xeris.cz>
|
||||
*
|
||||
* ebml-write.c: write EBML data to file/stream
|
||||
*
|
||||
|
@ -41,21 +42,35 @@ G_BEGIN_DECLS
|
|||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_EBML_WRITE, GstEbmlWriteClass))
|
||||
|
||||
typedef struct _GstEbmlWrite {
|
||||
GstElement parent;
|
||||
GstObject object;
|
||||
|
||||
GstPad *srcpad;
|
||||
guint64 pos;
|
||||
|
||||
GstBuffer *cache;
|
||||
guint cache_size;
|
||||
guint handled;
|
||||
|
||||
GstFlowReturn last_write_result;
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
} GstEbmlWrite;
|
||||
|
||||
typedef struct _GstEbmlWriteClass {
|
||||
GstElementClass parent;
|
||||
GstObjectClass parent;
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
} GstEbmlWriteClass;
|
||||
|
||||
GType gst_ebml_write_get_type (void);
|
||||
|
||||
GstEbmlWrite *gst_ebml_write_new (GstPad *srcpad);
|
||||
void gst_ebml_write_reset (GstEbmlWrite *ebml);
|
||||
|
||||
GstFlowReturn gst_ebml_last_write_result (GstEbmlWrite *ebml);
|
||||
|
||||
/*
|
||||
* Caching means that we do not push one buffer for
|
||||
* each element, but fill this one until a flush.
|
||||
|
|
|
@ -132,6 +132,7 @@
|
|||
#define GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_SP "V_MPEG4/ISO/SP"
|
||||
#define GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_ASP "V_MPEG4/ISO/ASP"
|
||||
#define GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_AP "V_MPEG4/ISO/AP"
|
||||
#define GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_AVC "V_MPEG4/ISO/AVC"
|
||||
#define GST_MATROSKA_CODEC_ID_VIDEO_MSMPEG4V3 "V_MPEG4/MS/V3"
|
||||
#define GST_MATROSKA_CODEC_ID_VIDEO_MPEG1 "V_MPEG1"
|
||||
#define GST_MATROSKA_CODEC_ID_VIDEO_MPEG2 "V_MPEG2"
|
||||
|
@ -151,6 +152,7 @@
|
|||
#define GST_MATROSKA_CODEC_ID_AUDIO_MPEG2 "A_AAC/MPEG2/"
|
||||
#define GST_MATROSKA_CODEC_ID_AUDIO_MPEG4 "A_AAC/MPEG4/"
|
||||
#define GST_MATROSKA_CODEC_ID_AUDIO_TTA "A_TTA1"
|
||||
#define GST_MATROSKA_CODEC_ID_AUDIO_WAVPACK4 "A_WAVPACK4"
|
||||
/* TODO: AC3-9/10 (?), Real, Musepack, Quicktime */
|
||||
|
||||
#define GST_MATROSKA_CODEC_ID_SUBTITLE_UTF8 "S_TEXT/UTF8"
|
||||
|
@ -267,4 +269,17 @@ typedef struct _GstMatroskaIndex {
|
|||
guint64 time; /* in nanoseconds */
|
||||
} GstMatroskaIndex;
|
||||
|
||||
typedef struct _Wavpack4Header {
|
||||
guchar ck_id [4]; /* "wvpk" */
|
||||
guint32 ck_size; /* size of entire frame (minus 8, of course) */
|
||||
guint16 version; /* 0x403 for now */
|
||||
guint8 track_no; /* track number (0 if not used, like now) */
|
||||
guint8 index_no; /* remember these? (0 if not used, like now) */
|
||||
guint32 total_samples; /* for entire file (-1 if unknown) */
|
||||
guint32 block_index; /* index of first sample in block (to file begin) */
|
||||
guint32 block_samples; /* # samples in this block */
|
||||
guint32 flags; /* various flags for id and decoding */
|
||||
guint32 crc; /* crc for actual decoded data */
|
||||
} Wavpack4Header;
|
||||
|
||||
#endif /* __GST_MATROSKA_IDS_H__ */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,6 @@
|
|||
/* GStreamer Matroska muxer/demuxer
|
||||
* (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
||||
* (c) 2005 Michal Benes <michal.benes@xeris.cz>
|
||||
*
|
||||
* matroska-mux.h: matroska file/stream muxer object types
|
||||
*
|
||||
|
@ -23,6 +24,7 @@
|
|||
#define __GST_MATROSKA_MUX_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstcollectpads.h>
|
||||
|
||||
#include "ebml-write.h"
|
||||
#include "matroska-ids.h"
|
||||
|
@ -40,8 +42,6 @@ G_BEGIN_DECLS
|
|||
#define GST_IS_MATROSKA_MUX_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MATROSKA_MUX))
|
||||
|
||||
#define GST_MATROSKA_MUX_MAX_STREAMS 64
|
||||
|
||||
typedef struct _BITMAPINFOHEADER {
|
||||
guint32 bi_size;
|
||||
guint32 bi_width;
|
||||
|
@ -67,22 +67,32 @@ typedef struct _GstMatroskaMetaSeekIndex {
|
|||
guint64 pos;
|
||||
} GstMatroskaMetaSeekIndex;
|
||||
|
||||
/* all information needed for one matroska stream */
|
||||
typedef struct
|
||||
{
|
||||
GstCollectData collect; /* we extend the CollectData */
|
||||
GstMatroskaTrackContext *track;
|
||||
|
||||
GstBuffer *buffer; /* the queued buffer for this pad */
|
||||
|
||||
guint64 duration;
|
||||
}
|
||||
GstMatroskaPad;
|
||||
|
||||
|
||||
typedef struct _GstMatroskaMux {
|
||||
GstEbmlWrite parent;
|
||||
GstElement element;
|
||||
|
||||
/* pads */
|
||||
GstPad *srcpad;
|
||||
struct {
|
||||
GstMatroskaTrackContext *track;
|
||||
GstBuffer *buffer;
|
||||
gboolean eos;
|
||||
guint64 duration;
|
||||
} sink[GST_MATROSKA_MUX_MAX_STREAMS];
|
||||
GstCollectPads *collect;
|
||||
GstEbmlWrite *ebml_write;
|
||||
|
||||
guint num_streams,
|
||||
num_v_streams, num_a_streams, num_t_streams;
|
||||
|
||||
/* metadata - includes writing_app and creation_time */
|
||||
GstCaps *metadata;
|
||||
/* Application name (for the writing application header element) */
|
||||
gchar *writing_app;
|
||||
|
||||
/* state */
|
||||
GstMatroskaMuxState state;
|
||||
|
@ -99,15 +109,13 @@ typedef struct _GstMatroskaMux {
|
|||
|
||||
/* byte-positions of master-elements (for replacing contents) */
|
||||
guint64 segment_pos,
|
||||
seekhead_pos,
|
||||
cues_pos,
|
||||
#if 0
|
||||
tags_pos,
|
||||
#endif
|
||||
info_pos,
|
||||
tracks_pos,
|
||||
duration_pos,
|
||||
meta_pos;
|
||||
seekhead_pos,
|
||||
cues_pos,
|
||||
/* tags_pos, */
|
||||
info_pos,
|
||||
tracks_pos,
|
||||
duration_pos,
|
||||
meta_pos;
|
||||
guint64 segment_master;
|
||||
|
||||
/* current cluster */
|
||||
|
@ -121,7 +129,7 @@ typedef struct _GstMatroskaMux {
|
|||
} GstMatroskaMux;
|
||||
|
||||
typedef struct _GstMatroskaMuxClass {
|
||||
GstEbmlWriteClass parent;
|
||||
GstElementClass parent;
|
||||
} GstMatroskaMuxClass;
|
||||
|
||||
GType gst_matroska_mux_get_type (void);
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "matroska-demux.h"
|
||||
/* #include "matroska-demux.h" */
|
||||
#include "matroska-mux.h"
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
return (gst_matroska_demux_plugin_init (plugin) &&
|
||||
gst_matroska_mux_plugin_init (plugin));
|
||||
return /* gst_matroska_demux_plugin_init (plugin) && */
|
||||
gst_matroska_mux_plugin_init (plugin);
|
||||
}
|
||||
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||
|
|
Loading…
Reference in a new issue