flv: flvmux ported to the GstAggregator

This makes it possible to create a flv file from a live source and not stop
when there are packet drops.

https://bugzilla.gnome.org/show_bug.cgi?id=782920
This commit is contained in:
Vincent Penquerc'h 2017-12-20 15:23:26 -05:00 committed by Olivier Crête
parent 6ea569841d
commit 8b814f6351
2 changed files with 446 additions and 391 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,9 @@
/* GStreamer /* GStreamer
* *
* Copyright (c) 2008 Sebastian Dröge <sebastian.droege@collabora.co.uk> * Copyright (c) 2008,2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* Copyright (c) 2008-2017 Collabora Ltd
* @author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
* @author: Vincent Penquerc'h <vincent.penquerch@collabora.com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
@ -22,14 +25,25 @@
#define __GST_FLV_MUX_H__ #define __GST_FLV_MUX_H__
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/base/gstcollectpads.h> #include <gst/base/gstaggregator.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define GST_TYPE_FLV_MUX_PAD (gst_flv_mux_pad_get_type())
#define GST_FLV_MUX_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FLV_MUX_PAD, GstFlvMuxPad))
#define GST_FLV_MUX_PAD_CAST(obj) ((GstFlvMuxPad *)(obj))
#define GST_FLV_MUX_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FLV_MUX_PAD, GstFlvMuxPad))
#define GST_IS_FLV_MUX_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FLV_MUX_PAD))
#define GST_IS_FLV_MUX_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FLV_MUX_PAD))
typedef struct _GstFlvMuxPad GstFlvMuxPad;
typedef struct _GstFlvMuxPadClass GstFlvMuxPadClass;
#define GST_TYPE_FLV_MUX \ #define GST_TYPE_FLV_MUX \
(gst_flv_mux_get_type ()) (gst_flv_mux_get_type ())
#define GST_FLV_MUX(obj) \ #define GST_FLV_MUX(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_FLV_MUX, GstFlvMux)) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_FLV_MUX, GstFlvMux))
#define GST_FLV_MUX_CAST(obj) ((GstFlvMux *)obj)
#define GST_FLV_MUX_CLASS(klass) \ #define GST_FLV_MUX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_FLV_MUX, GstFlvMuxClass)) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_FLV_MUX, GstFlvMuxClass))
#define GST_IS_FLV_MUX(obj) \ #define GST_IS_FLV_MUX(obj) \
@ -37,27 +51,26 @@ G_BEGIN_DECLS
#define GST_IS_FLV_MUX_CLASS(klass) \ #define GST_IS_FLV_MUX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FLV_MUX)) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FLV_MUX))
typedef struct struct _GstFlvMuxPad
{ {
GstCollectData collect; GstAggregatorPad aggregator_pad;
gboolean video; guint codec;
guint audio_codec;
guint rate; guint rate;
guint width; guint width;
guint channels; guint channels;
GstBuffer *audio_codec_data; GstBuffer *codec_data;
guint video_codec;
GstBuffer *video_codec_data;
guint bitrate; guint bitrate;
GstClockTime last_timestamp; GstClockTime last_timestamp;
gint64 pts; gint64 pts;
gint64 dts; gint64 dts;
} GstFlvPad; };
typedef struct _GstFlvMuxPadClass {
GstAggregatorPadClass parent;
} GstFlvMuxPadClass;
typedef enum typedef enum
{ {
@ -66,15 +79,14 @@ typedef enum
} GstFlvMuxState; } GstFlvMuxState;
typedef struct _GstFlvMux { typedef struct _GstFlvMux {
GstElement element; GstAggregator aggregator;
GstPad *srcpad; GstPad *srcpad;
GstCollectPads *collect;
/* <private> */ /* <private> */
GstFlvMuxState state; GstFlvMuxState state;
gboolean have_audio; GstFlvMuxPad *audio_pad;
gboolean have_video; GstFlvMuxPad *video_pad;
gboolean streamable; gboolean streamable;
gchar *metadatacreator; gchar *metadatacreator;
@ -87,9 +99,10 @@ typedef struct _GstFlvMux {
} GstFlvMux; } GstFlvMux;
typedef struct _GstFlvMuxClass { typedef struct _GstFlvMuxClass {
GstElementClass parent; GstAggregatorClass parent;
} GstFlvMuxClass; } GstFlvMuxClass;
GType gst_flv_mux_pad_get_type(void);
GType gst_flv_mux_get_type (void); GType gst_flv_mux_get_type (void);
G_END_DECLS G_END_DECLS