Commit 2641cd9d authored by Thiago Santos's avatar Thiago Santos

asfmux: Adds new plugin asfmux

Adds the brand new asfmux plugin, containing 3 elements:
asfmux, rtpasfpay and asfparse. This plugin was developed
as a GSoC 2009 project, with David Schleef as the mentor and
Thiago Santos as the student.
parent 30feab57
......@@ -254,6 +254,7 @@ AG_GST_CHECK_PLUGIN(aacparse)
AG_GST_CHECK_PLUGIN(adpcmdec)
AG_GST_CHECK_PLUGIN(aiffparse)
AG_GST_CHECK_PLUGIN(amrparse)
AG_GST_CHECK_PLUGIN(asfmux)
AG_GST_CHECK_PLUGIN(autoconvert)
AG_GST_CHECK_PLUGIN(camerabin)
AG_GST_CHECK_PLUGIN(legacyresample)
......@@ -1626,6 +1627,7 @@ gst/aacparse/Makefile
gst/adpcmdec/Makefile
gst/aiffparse/Makefile
gst/amrparse/Makefile
gst/asfmux/Makefile
gst/autoconvert/Makefile
gst/bayer/Makefile
gst/camerabin/Makefile
......
# plugindir is set in configure
plugin_LTLIBRARIES = libgstasfmux.la
# sources used to compile this plug-in
libgstasfmux_la_SOURCES = gstasfmux.c \
gstasfobjects.c \
gstasfparse.c \
gstrtpasfpay.c \
gstasf.c
# flags used to compile this plugin
# add other _CFLAGS and _LIBS as needed
libgstasfmux_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
libgstasfmux_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) \
-lgstrtp-@GST_MAJORMINOR@
libgstasfmux_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
#libgstasfmux_la_LIBTOOLFLAGS = --tag=disable-static
# headers we need but don't want installed
noinst_HEADERS = gstasfmux.h \
gstasfobjects.h \
gstasfparse.h \
gstrtpasfpay.h
/* GStreamer
* Copyright (C) 2009 Thiago Santos <thiagoss@embeddeed.ufcg.edu.br>
*
* gstasf.c: plugin registering
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include "gstasfmux.h"
#include "gstrtpasfpay.h"
#include "gstasfparse.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_asf_mux_plugin_init (plugin)) {
return FALSE;
}
if (!gst_rtp_asf_pay_plugin_init (plugin)) {
return FALSE;
}
if (!gst_asf_parse_plugin_init (plugin)) {
return FALSE;
}
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"asfmux",
"ASF Muxer Plugin",
plugin_init, VERSION, "LGPL", "gsoc2009 package", "embedded.ufcg.edu.br")
This diff is collapsed.
/* ASF muxer plugin for GStreamer
* Copyright (C) 2009 Thiago Santos <thiagoss@embedded.ufcg.edu.br>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_ASF_MUX_H__
#define __GST_ASF_MUX_H__
#include <gst/gst.h>
#include <gst/base/gstcollectpads.h>
#include <gst/riff/riff-media.h>
#include "gstasfobjects.h"
G_BEGIN_DECLS
#define GST_TYPE_ASF_MUX \
(gst_asf_mux_get_type())
#define GST_ASF_MUX(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ASF_MUX,GstAsfMux))
#define GST_ASF_MUX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ASF_MUX,GstAsfMuxClass))
#define GST_IS_ASF_MUX(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ASF_MUX))
#define GST_IS_ASF_MUX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ASF_MUX))
#define GST_ASF_MUX_CAST(obj) ((GstAsfMux*)(obj))
typedef struct _GstAsfMux GstAsfMux;
typedef struct _GstAsfMuxClass GstAsfMuxClass;
typedef struct _GstAsfPad GstAsfPad;
typedef struct _GstAsfAudioPad GstAsfAudioPad;
typedef struct _GstAsfVideoPad GstAsfVideoPad;
typedef enum _GstAsfMuxState GstAsfMuxState;
enum _GstAsfMuxState
{
GST_ASF_MUX_STATE_NONE,
GST_ASF_MUX_STATE_STARTED,
GST_ASF_MUX_STATE_HEADERS,
GST_ASF_MUX_STATE_DATA,
GST_ASF_MUX_STATE_EOS
};
struct _GstAsfPad
{
GstCollectData collect;
gboolean is_audio;
guint8 stream_number;
guint8 media_object_number;
guint32 bitrate;
GstClockTime play_duration;
GstBuffer *codec_data;
/* stream only metadata */
GstTagList *taglist;
};
struct _GstAsfAudioPad
{
GstAsfPad pad;
gst_riff_strf_auds audioinfo;
};
struct _GstAsfVideoPad
{
GstAsfPad pad;
gst_riff_strf_vids vidinfo;
/* Simple Index Entries */
GSList *simple_index;
gboolean has_keyframe; /* if we have received one at least */
guint32 last_keyframe_packet;
guint16 last_keyframe_packet_count;
guint16 max_keyframe_packet_count;
GstClockTime next_index_time;
guint64 time_interval;
};
struct _GstAsfMux
{
GstElement element;
/* output stream state */
GstAsfMuxState state;
/* counter to assign stream numbers */
guint8 stream_number;
/* counting variables */
guint64 file_size;
guint64 data_object_size;
guint64 total_data_packets;
/*
* data object size field position
* needed for updating when finishing the file
*/
guint64 data_object_position;
guint64 file_properties_object_position;
/* payloads still to be sent in a packet */
guint32 payload_data_size;
GSList *payloads;
Guid file_id;
/* properties */
guint32 prop_packet_size;
guint64 prop_preroll;
gboolean prop_merge_stream_tags;
guint64 prop_padding;
gboolean prop_is_live;
/* same as properties, but those are stored here to be
* used without modification while muxing a single file */
guint32 packet_size;
guint64 preroll; /* milisecs */
gboolean merge_stream_tags;
/* pads */
GstPad *srcpad;
/* sinkpads, video first */
GSList *sinkpads;
GstCollectPads *collect;
GstPadEventFunction collect_event;
};
struct _GstAsfMuxClass
{
GstElementClass parent_class;
};
GType gst_asf_mux_get_type (void);
gboolean gst_asf_mux_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_ASF_MUX_H__ */
This diff is collapsed.
/* ASF muxer plugin for GStreamer
* Copyright (C) 2009 Thiago Santos <thiagoss@embedded.ufcg.edu.br>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_ASF_OBJECTS_H__
#define __GST_ASF_OBJECTS_H__
#include <glib.h>
#include <gst/gst.h>
#include <gst/base/gstbytereader.h>
#include <gst/base/gstcollectpads.h>
#define ASF_PAYLOAD_IS_KEYFRAME(pay) ((pay->stream_number & 0x80) != 0)
#define ASF_MILI_TO_100NANO(v) (v * 10000)
#define ASF_GUID_SIZE 16
#define ASF_GUID_OBJSIZE_SIZE 24
typedef struct _Guid
{
guint32 v1;
guint16 v2;
guint16 v3;
guint64 v4;
} Guid;
typedef struct _GstAsfFileInfo
{
guint64 packets_count;
guint32 packet_size;
gboolean broadcast;
} GstAsfFileInfo;
typedef struct _GstAsfPacketInfo
{
guint32 packet_size;
guint32 padding;
guint32 send_time;
guint16 duration;
gboolean has_keyframe;
} GstAsfPacketInfo;
typedef struct _SimpleIndexEntry
{
guint32 packet_number;
guint16 packet_count;
} SimpleIndexEntry;
typedef struct _AsfPayload
{
guint8 stream_number;
guint8 media_obj_num;
guint32 offset_in_media_obj;
guint8 replicated_data_length;
guint32 media_object_size;
guint32 presentation_time;
GstBuffer *data;
GstCollectData *pad;
/* simple index info */
gboolean has_packet_info;
guint32 packet_number;
guint16 packet_count;
} AsfPayload;
Guid gst_asf_generate_file_id ();
gboolean gst_byte_reader_get_asf_var_size_field (GstByteReader * reader,
guint8 field_type, guint32 * var);
guint32 gst_asf_read_var_size_field (guint8 * data, guint8 field_type);
guint gst_asf_get_var_size_field_len (guint8 field_type);
GstAsfFileInfo *gst_asf_file_info_new ();
void gst_asf_file_info_reset (GstAsfFileInfo * info);
void gst_asf_file_info_free (GstAsfFileInfo * info);
guint32 gst_asf_payload_get_size (AsfPayload * payload);
void gst_asf_payload_free (AsfPayload * payload);
guint64 gst_asf_get_current_time ();
gboolean gst_asf_match_guid (const guint8 * data, const Guid * g);
void gst_asf_put_i32 (guint8 * buf, gint32 data);
void gst_asf_put_time (guint8 * buf, guint64 time);
void gst_asf_put_guid (guint8 * buf, Guid guid);
void gst_asf_put_payload (guint8 * buf, AsfPayload * payload);
guint16 gst_asf_put_subpayload (guint8 * buf, AsfPayload * payload,
guint16 size);
gboolean gst_asf_parse_packet (GstBuffer * buffer, GstAsfPacketInfo * packet,
gboolean trust_delta_flag);
guint64 gst_asf_match_and_peek_obj_size (const guint8 * data,
const Guid * guid);
gboolean gst_asf_parse_headers (GstBuffer * buffer, GstAsfFileInfo * file_info);
/* ASF tags
* found at http://msdn.microsoft.com/en-us/library/dd562330(VS.85).aspx
*/
#define ASF_TAG_TITLE "Title\0"
#define ASF_TAG_TITLE_SORTNAME "TitleSortOrder\0"
/* FIXME asf has no artist tag other than AlbumArtist, but it has Author
* What to use here? */
#define ASF_TAG_ARTIST "WM/AlbumArtist\0"
#define ASF_TAG_ARTIST_SORTNAME "AlbumArtistSortOrder\0"
#define ASF_TAG_ALBUM_TITLE "WM/AlbumTitle\0"
#define ASF_TAG_ALBUM_TITLE_SORTNAME "AlbumTitleSortOrder\0"
#define ASF_TAG_GENRE "WM/Genre\0"
#define ASF_TAG_COMMENT "Comment\0"
#define ASF_TAG_TRACK_NUMBER "WM/TrackNumber\0"
#define ASF_TAG_COPYRIGHT "Copyright\0"
#define ASF_TAG_COMPOSER "WM/Composer\0"
const gchar *gst_asf_get_asf_tag (const gchar * gsttag);
guint gst_asf_get_tag_field_type (GValue * value);
gboolean gst_asf_tag_present_in_content_description (const gchar * tag);
/* ASF Objects Sizes */
#define ASF_HEADER_OBJECT_SIZE 30
#define ASF_FILE_PROPERTIES_OBJECT_SIZE 104
#define ASF_STREAM_PROPERTIES_OBJECT_SIZE 78
#define ASF_HEADER_EXTENSION_OBJECT_SIZE 46
#define ASF_AUDIO_SPECIFIC_DATA_SIZE 18
#define ASF_VIDEO_SPECIFIC_DATA_SIZE 51
#define ASF_DATA_OBJECT_SIZE 50
#define ASF_PAYLOAD_PARSING_INFO_SIZE 16
#define ASF_SINGLE_PAYLOAD_HEADER_SIZE 15
#define ASF_MULTIPLE_PAYLOAD_HEADER_SIZE 17
#define ASF_EXTENDED_STREAM_PROPERTIES_OBJECT_SIZE 88
#define ASF_CONTENT_DESCRIPTION_OBJECT_SIZE 34
#define ASF_EXT_CONTENT_DESCRIPTION_OBJECT_SIZE 26
#define ASF_SIMPLE_INDEX_OBJECT_SIZE 56
#define ASF_SIMPLE_INDEX_ENTRY_SIZE 6
#define ASF_METADATA_OBJECT_SIZE 26
#define ASF_PADDING_OBJECT_SIZE 24
/* Field types for data object payload description */
#define ASF_FIELD_TYPE_NONE 0
#define ASF_FIELD_TYPE_BYTE 1
#define ASF_FIELD_TYPE_WORD 2
#define ASF_FIELD_TYPE_DWORD 3
/* tag types */
#define ASF_TAG_TYPE_UNICODE_STR 0
#define ASF_TAG_TYPE_BYTES 1
#define ASF_TAG_TYPE_BOOL 2
#define ASF_TAG_TYPE_DWORD 3
#define ASF_TAG_TYPE_QWORD 4
#define ASF_TAG_TYPE_WORD 5
/* GUID objects */
#define ASF_HEADER_OBJECT_INDEX 0
#define ASF_FILE_PROPERTIES_OBJECT_INDEX 1
#define ASF_STREAM_PROPERTIES_OBJECT_INDEX 2
#define ASF_AUDIO_MEDIA_INDEX 3
#define ASF_NO_ERROR_CORRECTION_INDEX 4
#define ASF_AUDIO_SPREAD_INDEX 5
#define ASF_HEADER_EXTENSION_OBJECT_INDEX 6
#define ASF_RESERVED_1_INDEX 7
#define ASF_DATA_OBJECT_INDEX 8
#define ASF_EXTENDED_STREAM_PROPERTIES_OBJECT_INDEX 9
#define ASF_VIDEO_MEDIA_INDEX 10
#define ASF_SIMPLE_INDEX_OBJECT_INDEX 11
#define ASF_CONTENT_DESCRIPTION_INDEX 12
#define ASF_EXT_CONTENT_DESCRIPTION_INDEX 13
#define ASF_METADATA_OBJECT_INDEX 14
#define ASF_PADDING_OBJECT_INDEX 15
extern const Guid guids[];
#endif
This diff is collapsed.
/* ASF Parser plugin for GStreamer
* Copyright (C) 2009 Thiago Santos <thiagoss@embedded.ufcg.edu.br>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_ASF_PARSE_H__
#define __GST_ASF_PARSE_H__
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
#include <gst/base/gstbytereader.h>
#include "gstasfobjects.h"
G_BEGIN_DECLS
#define GST_TYPE_ASF_PARSE \
(gst_asf_parse_get_type())
#define GST_ASF_PARSE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ASF_PARSE,GstAsfParse))
#define GST_ASF_PARSE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ASF_PARSE,GstAsfParseClass))
#define GST_IS_ASF_PARSE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ASF_PARSE))
#define GST_IS_ASF_PARSE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ASF_PARSE))
#define GST_ASF_PARSE_CAST(obj) ((GstAsfParse*)(obj))
enum GstAsfParsingState {
ASF_PARSING_HEADERS,
ASF_PARSING_DATA,
ASF_PARSING_PACKETS,
ASF_PARSING_INDEXES
};
typedef struct _GstAsfParse GstAsfParse;
typedef struct _GstAsfParseClass GstAsfParseClass;
struct _GstAsfParse {
GstElement element;
enum GstAsfParsingState parse_state;
GstAdapter *adapter;
GstPad *srcpad;
GstPad *sinkpad;
GstCaps *outcaps;
guint64 parsed_packets;
guint64 offset; /* used in pull mode */
/* parsed info */
GstAsfFileInfo *asfinfo;
GstAsfPacketInfo *packetinfo; /* we keep it here to avoid allocs */
guint64 headers_size;
guint64 data_size;
};
struct _GstAsfParseClass {
GstElementClass parent_class;
};
GType gst_asf_parse_get_type(void);
gboolean gst_asf_parse_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_ASF_PARSE_H__ */
This diff is collapsed.
/* ASF RTP Payloader plugin for GStreamer
* Copyright (C) 2009 Thiago Santos <thiagoss@embedded.ufcg.edu.br>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_RTP_ASF_PAY_H__
#define __GST_RTP_ASF_PAY_H__
#include <gst/gst.h>
#include <gst/rtp/gstbasertppayload.h>
#include <gst/rtp/gstrtpbuffer.h>
#include <gst/base/gstadapter.h>
#include "gstasfobjects.h"
G_BEGIN_DECLS
#define GST_TYPE_RTP_ASF_PAY \
(gst_rtp_asf_pay_get_type())
#define GST_RTP_ASF_PAY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_ASF_PAY,GstRtpAsfPay))
#define GST_RTP_ASF_PAY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_ASF_PAY,GstRtpAsfPayClass))
#define GST_IS_RTP_ASF_PAY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_ASF_PAY))
#define GST_IS_RTP_ASF_PAY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_ASF_PAY))
#define GST_RTP_ASF_PAY_CAST(obj) ((GstRtpAsfPay*)(obj))
enum GstRtpAsfPayState
{
ASF_NOT_STARTED,
ASF_DATA_OBJECT,
ASF_PACKETS,
ASF_END
};
typedef struct _GstRtpAsfPay GstRtpAsfPay;
typedef struct _GstRtpAsfPayClass GstRtpAsfPayClass;
struct _GstRtpAsfPay
{
GstBaseRTPPayload rtppay;
enum GstRtpAsfPayState state;
guint32 first_ts;
gchar *config;
guint64 packets_count;
GstAsfFileInfo asfinfo;
/* current output buffer */
GstBuffer *current;
guint32 cur_off;
guint32 ts;
gboolean has_ts;
gboolean marker;
/* keeping it here to avoid allocs/frees */
GstAsfPacketInfo packetinfo;
GstBuffer *headers;
};
struct _GstRtpAsfPayClass
{
GstBaseRTPPayloadClass parent_class;
};
GType gst_rtp_asf_pay_get_type (void);
gboolean gst_rtp_asf_pay_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_RTP_ASF_PAY_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment