[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
2009-05-14 08:29:49 +00:00
|
|
|
* Copyright (c) 2008,2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
2017-12-20 20:23:26 +00:00
|
|
|
* Copyright (c) 2008-2017 Collabora Ltd
|
|
|
|
* @author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
|
|
|
* @author: Vincent Penquerc'h <vincent.penquerch@collabora.com>
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
*/
|
|
|
|
|
2009-04-22 17:52:05 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-flvmux
|
|
|
|
*
|
|
|
|
* flvmux muxes different streams into an FLV file.
|
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* <title>Example launch line</title>
|
|
|
|
* |[
|
2013-10-12 19:44:31 +00:00
|
|
|
* gst-launch-1.0 -v flvmux name=mux ! filesink location=test.flv audiotestsrc samplesperbuffer=44100 num-buffers=10 ! faac ! mux. videotestsrc num-buffers=250 ! video/x-raw,framerate=25/1 ! x264enc ! mux.
|
|
|
|
* ]| This pipeline encodes a test audio and video stream and muxes both into an FLV file.
|
2009-04-22 17:52:05 +00:00
|
|
|
* </refsect2>
|
|
|
|
*/
|
|
|
|
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-02-06 14:52:36 +00:00
|
|
|
#include <gst/audio/audio.h>
|
|
|
|
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
#include "gstflvmux.h"
|
2011-10-26 13:37:03 +00:00
|
|
|
#include "amfdefs.h"
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (flvmux_debug);
|
|
|
|
#define GST_CAT_DEFAULT flvmux_debug
|
|
|
|
|
2010-03-14 00:34:02 +00:00
|
|
|
enum
|
|
|
|
{
|
2010-03-15 12:47:13 +00:00
|
|
|
PROP_0,
|
2016-11-09 06:25:27 +00:00
|
|
|
PROP_STREAMABLE,
|
|
|
|
PROP_METADATACREATOR
|
2010-03-14 00:34:02 +00:00
|
|
|
};
|
|
|
|
|
2010-06-09 12:13:09 +00:00
|
|
|
#define DEFAULT_STREAMABLE FALSE
|
2010-03-14 00:38:21 +00:00
|
|
|
#define MAX_INDEX_ENTRIES 128
|
2016-11-09 06:25:27 +00:00
|
|
|
#define DEFAULT_METADATACREATOR "GStreamer " PACKAGE_VERSION " FLV muxer"
|
2010-03-14 00:34:02 +00:00
|
|
|
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/x-flv")
|
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate videosink_templ = GST_STATIC_PAD_TEMPLATE ("video",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_REQUEST,
|
|
|
|
GST_STATIC_CAPS ("video/x-flash-video; "
|
|
|
|
"video/x-flash-screen; "
|
2011-04-04 09:31:44 +00:00
|
|
|
"video/x-vp6-flash; " "video/x-vp6-alpha; "
|
|
|
|
"video/x-h264, stream-format=avc;")
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate audiosink_templ = GST_STATIC_PAD_TEMPLATE ("audio",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_REQUEST,
|
|
|
|
GST_STATIC_CAPS
|
|
|
|
("audio/x-adpcm, layout = (string) swf, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "
|
2009-04-29 11:56:07 +00:00
|
|
|
"audio/mpeg, mpegversion = (int) 1, layer = (int) 3, channels = (int) { 1, 2 }, rate = (int) { 5512, 8000, 11025, 22050, 44100 }, parsed = (boolean) TRUE; "
|
2013-10-12 19:37:41 +00:00
|
|
|
"audio/mpeg, mpegversion = (int) { 4, 2 }, stream-format = (string) raw; "
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
"audio/x-nellymoser, channels = (int) { 1, 2 }, rate = (int) { 5512, 8000, 11025, 16000, 22050, 44100 }; "
|
2012-02-06 14:52:36 +00:00
|
|
|
"audio/x-raw, format = (string) { U8, S16LE}, layout = (string) interleaved, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
"audio/x-alaw, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "
|
2008-10-27 09:33:40 +00:00
|
|
|
"audio/x-mulaw, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "
|
2014-06-26 12:43:33 +00:00
|
|
|
"audio/x-speex, channels = (int) 1, rate = (int) 16000;")
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
);
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
G_DEFINE_TYPE (GstFlvMuxPad, gst_flv_mux_pad, GST_TYPE_AGGREGATOR_PAD);
|
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
#define gst_flv_mux_parent_class parent_class
|
2017-12-20 20:23:26 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstFlvMux, gst_flv_mux, GST_TYPE_AGGREGATOR,
|
2011-07-04 09:09:19 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
|
|
|
static GstFlowReturn
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_aggregate (GstAggregator * aggregator, gboolean timeout);
|
2011-12-15 15:40:21 +00:00
|
|
|
static gboolean
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_sink_event (GstAggregator * aggregator, GstAggregatorPad * pad,
|
2011-11-17 14:02:55 +00:00
|
|
|
GstEvent * event);
|
2017-12-20 20:23:26 +00:00
|
|
|
|
|
|
|
static GstAggregatorPad *gst_flv_mux_create_new_pad (GstAggregator * agg,
|
2011-07-04 09:09:19 +00:00
|
|
|
GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
static void gst_flv_mux_release_pad (GstElement * element, GstPad * pad);
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
static gboolean gst_flv_mux_video_pad_setcaps (GstFlvMuxPad * pad,
|
|
|
|
GstCaps * caps);
|
|
|
|
static gboolean gst_flv_mux_audio_pad_setcaps (GstFlvMuxPad * pad,
|
|
|
|
GstCaps * caps);
|
2011-07-04 09:09:19 +00:00
|
|
|
|
2010-03-14 00:34:02 +00:00
|
|
|
static void gst_flv_mux_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_flv_mux_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
2017-12-20 20:23:26 +00:00
|
|
|
static void gst_flv_mux_finalize (GObject * object);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
|
|
|
static void gst_flv_mux_reset (GstElement * element);
|
2017-12-20 20:23:26 +00:00
|
|
|
static void gst_flv_mux_reset_pad (GstFlvMuxPad * pad);
|
|
|
|
|
|
|
|
static void gst_flv_mux_pad_finalize (GObject * object);
|
|
|
|
|
|
|
|
static gboolean gst_flv_mux_start (GstAggregator * aggregator);
|
|
|
|
static GstFlowReturn gst_flv_mux_flush (GstAggregator * aggregator);
|
|
|
|
static GstClockTime gst_flv_mux_get_next_time (GstAggregator * aggregator);
|
|
|
|
static GstFlowReturn gst_flv_mux_write_eos (GstFlvMux * mux);
|
|
|
|
static GstFlowReturn gst_flv_mux_write_header (GstFlvMux * mux);
|
|
|
|
static GstFlowReturn gst_flv_mux_rewrite_header (GstFlvMux * mux);
|
|
|
|
static gboolean gst_flv_mux_are_all_pads_eos (GstFlvMux * mux);
|
2018-09-06 04:13:19 +00:00
|
|
|
static GstFlowReturn gst_flv_mux_update_src_caps (GstAggregator * aggregator,
|
|
|
|
GstCaps * caps, GstCaps ** ret);
|
2017-12-20 20:23:26 +00:00
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_flv_mux_pad_flush (GstAggregatorPad * pad, GstAggregator * aggregator)
|
|
|
|
{
|
|
|
|
GstFlvMuxPad *flvpad = GST_FLV_MUX_PAD (pad);
|
|
|
|
|
|
|
|
flvpad->last_timestamp = 0;
|
|
|
|
flvpad->pts = GST_CLOCK_STIME_NONE;
|
|
|
|
flvpad->dts = GST_CLOCK_STIME_NONE;
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_flv_mux_pad_class_init (GstFlvMuxPadClass * klass)
|
|
|
|
{
|
|
|
|
GstAggregatorPadClass *aggregatorpad_class = (GstAggregatorPadClass *) klass;
|
|
|
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
|
|
|
|
|
|
|
gobject_class->finalize = gst_flv_mux_pad_finalize;
|
|
|
|
|
|
|
|
aggregatorpad_class->flush = GST_DEBUG_FUNCPTR (gst_flv_mux_pad_flush);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_flv_mux_pad_init (GstFlvMuxPad * pad)
|
|
|
|
{
|
|
|
|
gst_flv_mux_reset_pad (pad);
|
|
|
|
}
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2009-05-14 08:29:49 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gdouble position;
|
|
|
|
gdouble time;
|
|
|
|
} GstFlvMuxIndexEntry;
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_flv_mux_index_entry_free (GstFlvMuxIndexEntry * entry)
|
|
|
|
{
|
|
|
|
g_slice_free (GstFlvMuxIndexEntry, entry);
|
|
|
|
}
|
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
static GstBuffer *
|
|
|
|
_gst_buffer_new_wrapped (gpointer mem, gsize size, GFreeFunc free_func)
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
{
|
2011-07-04 09:09:19 +00:00
|
|
|
GstBuffer *buf;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
buf = gst_buffer_new ();
|
2012-03-30 16:13:08 +00:00
|
|
|
gst_buffer_append_memory (buf,
|
2011-07-04 09:09:19 +00:00
|
|
|
gst_memory_new_wrapped (free_func ? 0 : GST_MEMORY_FLAG_READONLY,
|
2012-02-22 01:06:17 +00:00
|
|
|
mem, size, 0, size, mem, free_func));
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gst_buffer_new_and_alloc (gsize size, GstBuffer ** buffer, guint8 ** data)
|
|
|
|
{
|
|
|
|
g_return_if_fail (data != NULL);
|
|
|
|
g_return_if_fail (buffer != NULL);
|
|
|
|
|
|
|
|
*data = g_malloc (size);
|
|
|
|
*buffer = _gst_buffer_new_wrapped (*data, size, g_free);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_flv_mux_class_init (GstFlvMuxClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
2017-12-20 20:23:26 +00:00
|
|
|
GstAggregatorClass *gstaggregator_class;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (flvmux_debug, "flvmux", 0, "FLV muxer");
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2017-12-20 20:23:26 +00:00
|
|
|
gstaggregator_class = (GstAggregatorClass *) klass;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2010-03-14 00:34:02 +00:00
|
|
|
gobject_class->get_property = gst_flv_mux_get_property;
|
|
|
|
gobject_class->set_property = gst_flv_mux_set_property;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
gobject_class->finalize = gst_flv_mux_finalize;
|
|
|
|
|
2010-06-08 12:09:00 +00:00
|
|
|
/* FIXME: ideally the right mode of operation should be detected
|
|
|
|
* automatically using queries when parameter not specified. */
|
2010-06-17 16:24:22 +00:00
|
|
|
/**
|
|
|
|
* GstFlvMux:streamable
|
|
|
|
*
|
|
|
|
* If True, the output will be streaming friendly. (ie without indexes and
|
|
|
|
* duration)
|
2013-11-18 14:44:36 +00:00
|
|
|
*/
|
2010-06-09 12:13:09 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_STREAMABLE,
|
|
|
|
g_param_spec_boolean ("streamable", "streamable",
|
|
|
|
"If set to true, the output should be as if it is to be streamed "
|
|
|
|
"and hence no indexes written or duration written.",
|
|
|
|
DEFAULT_STREAMABLE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2016-11-09 06:25:27 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_METADATACREATOR,
|
|
|
|
g_param_spec_string ("metadatacreator", "metadatacreator",
|
|
|
|
"The value of metadatacreator in the meta packet.",
|
|
|
|
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2010-03-14 00:34:02 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
gstaggregator_class->create_new_pad =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_flv_mux_create_new_pad);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_flv_mux_release_pad);
|
2011-07-04 09:09:19 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
gstaggregator_class->start = GST_DEBUG_FUNCPTR (gst_flv_mux_start);
|
|
|
|
gstaggregator_class->aggregate = GST_DEBUG_FUNCPTR (gst_flv_mux_aggregate);
|
|
|
|
gstaggregator_class->sink_event = GST_DEBUG_FUNCPTR (gst_flv_mux_sink_event);
|
|
|
|
gstaggregator_class->flush = GST_DEBUG_FUNCPTR (gst_flv_mux_flush);
|
|
|
|
gstaggregator_class->get_next_time =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_flv_mux_get_next_time);
|
2018-09-06 04:13:19 +00:00
|
|
|
gstaggregator_class->update_src_caps =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_flv_mux_update_src_caps);
|
2017-12-20 20:23:26 +00:00
|
|
|
|
|
|
|
gst_element_class_add_static_pad_template_with_gtype (gstelement_class,
|
|
|
|
&videosink_templ, GST_TYPE_FLV_MUX_PAD);
|
|
|
|
gst_element_class_add_static_pad_template_with_gtype (gstelement_class,
|
|
|
|
&audiosink_templ, GST_TYPE_FLV_MUX_PAD);
|
2018-02-28 23:34:20 +00:00
|
|
|
gst_element_class_add_static_pad_template_with_gtype (gstelement_class,
|
|
|
|
&src_templ, GST_TYPE_AGGREGATOR_PAD);
|
2012-04-09 23:51:41 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class, "FLV muxer",
|
2011-07-04 09:09:19 +00:00
|
|
|
"Codec/Muxer",
|
|
|
|
"Muxes video/audio streams into a FLV stream",
|
|
|
|
"Sebastian Dröge <sebastian.droege@collabora.co.uk>");
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (flvmux_debug, "flvmux", 0, "FLV muxer");
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-07-04 09:09:19 +00:00
|
|
|
gst_flv_mux_init (GstFlvMux * mux)
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
{
|
2017-12-20 20:23:26 +00:00
|
|
|
mux->srcpad = GST_AGGREGATOR_CAST (mux)->srcpad;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2010-03-14 00:34:02 +00:00
|
|
|
/* property */
|
2010-06-09 12:13:09 +00:00
|
|
|
mux->streamable = DEFAULT_STREAMABLE;
|
2016-11-09 06:25:27 +00:00
|
|
|
mux->metadatacreator = g_strdup (DEFAULT_METADATACREATOR);
|
2010-03-14 00:34:02 +00:00
|
|
|
|
2010-09-20 17:43:45 +00:00
|
|
|
mux->new_tags = FALSE;
|
|
|
|
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
gst_flv_mux_reset (GST_ELEMENT (mux));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_flv_mux_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstFlvMux *mux = GST_FLV_MUX (object);
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_reset (GST_ELEMENT (object));
|
2016-11-09 06:25:27 +00:00
|
|
|
g_free (mux->metadatacreator);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
G_OBJECT_CLASS (gst_flv_mux_parent_class)->finalize (object);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_pad_finalize (GObject * object)
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
{
|
2017-12-20 20:23:26 +00:00
|
|
|
GstFlvMuxPad *pad = GST_FLV_MUX_PAD (object);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_reset_pad (pad);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
G_OBJECT_CLASS (gst_flv_mux_pad_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_flv_mux_flush (GstAggregator * aggregator)
|
|
|
|
{
|
|
|
|
/* TODO: What is the right behaviour on flush? Should we just ignore it ?
|
|
|
|
* This still needs to be defined. */
|
|
|
|
|
|
|
|
gst_flv_mux_reset (GST_ELEMENT (aggregator));
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_flv_mux_start (GstAggregator * aggregator)
|
|
|
|
{
|
|
|
|
gst_flv_mux_reset (GST_ELEMENT (aggregator));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_flv_mux_reset (GstElement * element)
|
|
|
|
{
|
|
|
|
GstFlvMux *mux = GST_FLV_MUX (element);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2009-05-14 08:29:49 +00:00
|
|
|
g_list_foreach (mux->index, (GFunc) gst_flv_mux_index_entry_free, NULL);
|
|
|
|
g_list_free (mux->index);
|
|
|
|
mux->index = NULL;
|
|
|
|
mux->byte_count = 0;
|
|
|
|
|
2010-03-16 00:29:36 +00:00
|
|
|
mux->duration = GST_CLOCK_TIME_NONE;
|
2010-09-20 17:43:45 +00:00
|
|
|
mux->new_tags = FALSE;
|
2015-06-10 22:15:52 +00:00
|
|
|
mux->first_timestamp = GST_CLOCK_STIME_NONE;
|
2009-08-03 18:07:00 +00:00
|
|
|
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
mux->state = GST_FLV_MUX_STATE_HEADER;
|
2009-09-03 11:40:20 +00:00
|
|
|
|
|
|
|
/* tags */
|
|
|
|
gst_tag_setter_reset_tags (GST_TAG_SETTER (mux));
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
2015-07-29 14:59:15 +00:00
|
|
|
/* Extract per-codec relevant tags for
|
|
|
|
* insertion into the metadata later - ie bitrate,
|
|
|
|
* but maybe others in the future */
|
|
|
|
static void
|
|
|
|
gst_flv_mux_store_codec_tags (GstFlvMux * mux,
|
2017-12-20 20:23:26 +00:00
|
|
|
GstFlvMuxPad * flvpad, GstTagList * list)
|
2015-07-29 14:59:15 +00:00
|
|
|
{
|
|
|
|
/* Look for a bitrate as either nominal or actual bitrate tag */
|
2017-12-20 20:23:26 +00:00
|
|
|
if (gst_tag_list_get_uint (list, GST_TAG_NOMINAL_BITRATE, &flvpad->bitrate)
|
|
|
|
|| gst_tag_list_get_uint (list, GST_TAG_BITRATE, &flvpad->bitrate)) {
|
2015-07-29 14:59:15 +00:00
|
|
|
GST_DEBUG_OBJECT (mux, "Stored bitrate for pad %" GST_PTR_FORMAT " = %u",
|
|
|
|
flvpad, flvpad->bitrate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
static gboolean
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_sink_event (GstAggregator * aggregator, GstAggregatorPad * pad,
|
|
|
|
GstEvent * event)
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
{
|
2017-12-20 20:23:26 +00:00
|
|
|
GstFlvMux *mux = GST_FLV_MUX (aggregator);
|
|
|
|
GstFlvMuxPad *flvpad = (GstFlvMuxPad *) pad;
|
2012-04-16 14:37:49 +00:00
|
|
|
gboolean ret = TRUE;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2011-07-04 09:09:19 +00:00
|
|
|
case GST_EVENT_CAPS:
|
|
|
|
{
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
gst_event_parse_caps (event, &caps);
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (mux->video_pad == flvpad) {
|
|
|
|
ret = gst_flv_mux_video_pad_setcaps (flvpad, caps);
|
|
|
|
} else if (mux->audio_pad == flvpad) {
|
|
|
|
ret = gst_flv_mux_audio_pad_setcaps (flvpad, caps);
|
2011-07-04 09:09:19 +00:00
|
|
|
} else {
|
2017-12-20 20:23:26 +00:00
|
|
|
g_assert_not_reached ();
|
2011-07-04 09:09:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2009-04-29 11:03:46 +00:00
|
|
|
case GST_EVENT_TAG:{
|
2009-09-03 11:40:20 +00:00
|
|
|
GstTagList *list;
|
|
|
|
GstTagSetter *setter = GST_TAG_SETTER (mux);
|
2010-06-01 08:26:11 +00:00
|
|
|
const GstTagMergeMode mode = gst_tag_setter_get_tag_merge_mode (setter);
|
2009-04-29 11:03:46 +00:00
|
|
|
|
2009-09-03 11:40:20 +00:00
|
|
|
gst_event_parse_tag (event, &list);
|
|
|
|
gst_tag_setter_merge_tags (setter, list, mode);
|
2015-07-29 14:59:15 +00:00
|
|
|
gst_flv_mux_store_codec_tags (mux, flvpad, list);
|
2010-09-20 17:43:45 +00:00
|
|
|
mux->new_tags = TRUE;
|
2012-01-26 09:28:51 +00:00
|
|
|
ret = TRUE;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
break;
|
2009-04-29 11:03:46 +00:00
|
|
|
}
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (!ret)
|
|
|
|
return FALSE;
|
2012-04-16 14:37:49 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
return GST_AGGREGATOR_CLASS (parent_class)->sink_event (aggregator, pad,
|
|
|
|
event);;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_video_pad_setcaps (GstFlvMuxPad * pad, GstCaps * caps)
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
{
|
|
|
|
GstFlvMux *mux = GST_FLV_MUX (gst_pad_get_parent (pad));
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
GstStructure *s;
|
|
|
|
|
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
if (strcmp (gst_structure_get_name (s), "video/x-flash-video") == 0) {
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 2;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else if (strcmp (gst_structure_get_name (s), "video/x-flash-screen") == 0) {
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 3;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else if (strcmp (gst_structure_get_name (s), "video/x-vp6-flash") == 0) {
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 4;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else if (strcmp (gst_structure_get_name (s), "video/x-vp6-alpha") == 0) {
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 5;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else if (strcmp (gst_structure_get_name (s), "video/x-h264") == 0) {
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 7;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else {
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret && gst_structure_has_field (s, "codec_data")) {
|
|
|
|
const GValue *val = gst_structure_get_value (s, "codec_data");
|
|
|
|
|
2010-03-15 23:35:46 +00:00
|
|
|
if (val)
|
2018-09-20 03:12:55 +00:00
|
|
|
gst_buffer_replace (&pad->codec_data, gst_value_get_buffer (val));
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gst_object_unref (mux);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_audio_pad_setcaps (GstFlvMuxPad * pad, GstCaps * caps)
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
{
|
|
|
|
GstFlvMux *mux = GST_FLV_MUX (gst_pad_get_parent (pad));
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
GstStructure *s;
|
|
|
|
|
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
if (strcmp (gst_structure_get_name (s), "audio/x-adpcm") == 0) {
|
|
|
|
const gchar *layout = gst_structure_get_string (s, "layout");
|
|
|
|
if (layout && strcmp (layout, "swf") == 0) {
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 1;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else {
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
} else if (strcmp (gst_structure_get_name (s), "audio/mpeg") == 0) {
|
|
|
|
gint mpegversion;
|
|
|
|
|
|
|
|
if (gst_structure_get_int (s, "mpegversion", &mpegversion)) {
|
|
|
|
if (mpegversion == 1) {
|
|
|
|
gint layer;
|
|
|
|
|
|
|
|
if (gst_structure_get_int (s, "layer", &layer) && layer == 3) {
|
|
|
|
gint rate;
|
|
|
|
|
|
|
|
if (gst_structure_get_int (s, "rate", &rate) && rate == 8000)
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 14;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
else
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 2;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else {
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
2011-05-09 17:00:45 +00:00
|
|
|
} else if (mpegversion == 4 || mpegversion == 2) {
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 10;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else {
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
} else if (strcmp (gst_structure_get_name (s), "audio/x-nellymoser") == 0) {
|
|
|
|
gint rate, channels;
|
|
|
|
|
|
|
|
if (gst_structure_get_int (s, "rate", &rate)
|
|
|
|
&& gst_structure_get_int (s, "channels", &channels)) {
|
|
|
|
if (channels == 1 && rate == 16000)
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 4;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
else if (channels == 1 && rate == 8000)
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 5;
|
2010-10-23 23:34:00 +00:00
|
|
|
else
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 6;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else {
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 6;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
2012-02-06 14:52:36 +00:00
|
|
|
} else if (strcmp (gst_structure_get_name (s), "audio/x-raw") == 0) {
|
|
|
|
GstAudioInfo info;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2012-02-06 14:52:36 +00:00
|
|
|
if (gst_audio_info_from_caps (&info, caps)) {
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 3;
|
2012-02-06 14:52:36 +00:00
|
|
|
|
|
|
|
if (GST_AUDIO_INFO_WIDTH (&info) == 8)
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->width = 0;
|
2012-02-06 14:52:36 +00:00
|
|
|
else if (GST_AUDIO_INFO_WIDTH (&info) == 16)
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->width = 1;
|
2012-02-06 14:52:36 +00:00
|
|
|
else
|
|
|
|
ret = FALSE;
|
|
|
|
} else
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
ret = FALSE;
|
|
|
|
} else if (strcmp (gst_structure_get_name (s), "audio/x-alaw") == 0) {
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 7;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else if (strcmp (gst_structure_get_name (s), "audio/x-mulaw") == 0) {
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 8;
|
2008-10-27 09:33:40 +00:00
|
|
|
} else if (strcmp (gst_structure_get_name (s), "audio/x-speex") == 0) {
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->codec = 11;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else {
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret) {
|
2012-02-06 14:52:36 +00:00
|
|
|
gint rate, channels;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
|
|
|
if (gst_structure_get_int (s, "rate", &rate)) {
|
2017-12-20 20:23:26 +00:00
|
|
|
if (pad->codec == 10)
|
|
|
|
pad->rate = 3;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
else if (rate == 5512)
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->rate = 0;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
else if (rate == 11025)
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->rate = 1;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
else if (rate == 22050)
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->rate = 2;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
else if (rate == 44100)
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->rate = 3;
|
|
|
|
else if (rate == 8000 && (pad->codec == 5 || pad->codec == 14))
|
|
|
|
pad->rate = 0;
|
|
|
|
else if (rate == 16000 && (pad->codec == 4 || pad->codec == 11))
|
|
|
|
pad->rate = 0;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
else
|
|
|
|
ret = FALSE;
|
2017-12-20 20:23:26 +00:00
|
|
|
} else if (pad->codec == 10) {
|
|
|
|
pad->rate = 3;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else {
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gst_structure_get_int (s, "channels", &channels)) {
|
2017-12-20 20:23:26 +00:00
|
|
|
if (pad->codec == 4 || pad->codec == 5
|
|
|
|
|| pad->codec == 6 || pad->codec == 11)
|
|
|
|
pad->channels = 0;
|
|
|
|
else if (pad->codec == 10)
|
|
|
|
pad->channels = 1;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
else if (channels == 1)
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->channels = 0;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
else if (channels == 2)
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->channels = 1;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
else
|
|
|
|
ret = FALSE;
|
2017-12-20 20:23:26 +00:00
|
|
|
} else if (pad->codec == 4 || pad->codec == 5 || pad->codec == 6) {
|
|
|
|
pad->channels = 0;
|
|
|
|
} else if (pad->codec == 10) {
|
|
|
|
pad->channels = 1;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else {
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (pad->codec != 3)
|
|
|
|
pad->width = 1;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ret && gst_structure_has_field (s, "codec_data")) {
|
|
|
|
const GValue *val = gst_structure_get_value (s, "codec_data");
|
|
|
|
|
2010-03-15 23:35:46 +00:00
|
|
|
if (val)
|
2018-09-20 03:12:55 +00:00
|
|
|
gst_buffer_replace (&pad->codec_data, gst_value_get_buffer (val));
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gst_object_unref (mux);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-09-12 05:55:19 +00:00
|
|
|
static void
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_reset_pad (GstFlvMuxPad * pad)
|
2011-09-12 05:55:19 +00:00
|
|
|
{
|
2017-12-20 20:23:26 +00:00
|
|
|
GST_DEBUG_OBJECT (pad, "resetting pad");
|
|
|
|
|
|
|
|
if (pad->codec_data)
|
|
|
|
gst_buffer_unref (pad->codec_data);
|
|
|
|
pad->codec_data = NULL;
|
|
|
|
pad->codec = G_MAXUINT;
|
|
|
|
pad->rate = G_MAXUINT;
|
|
|
|
pad->width = G_MAXUINT;
|
|
|
|
pad->channels = G_MAXUINT;
|
|
|
|
|
|
|
|
gst_flv_mux_pad_flush (GST_AGGREGATOR_PAD_CAST (pad), NULL);
|
2011-09-12 05:55:19 +00:00
|
|
|
}
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
static GstAggregatorPad *
|
|
|
|
gst_flv_mux_create_new_pad (GstAggregator * agg,
|
2011-07-04 09:09:19 +00:00
|
|
|
GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps)
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
{
|
2017-12-20 20:23:26 +00:00
|
|
|
GstElementClass *klass = GST_ELEMENT_GET_CLASS (agg);
|
|
|
|
GstAggregatorPad *aggpad;
|
|
|
|
GstFlvMux *mux = GST_FLV_MUX (agg);
|
|
|
|
GstFlvMuxPad *pad = NULL;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
const gchar *name = NULL;
|
|
|
|
gboolean video;
|
|
|
|
|
|
|
|
if (mux->state != GST_FLV_MUX_STATE_HEADER) {
|
|
|
|
GST_WARNING_OBJECT (mux, "Can't request pads after writing header");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (templ == gst_element_class_get_pad_template (klass, "audio")) {
|
2017-12-20 20:23:26 +00:00
|
|
|
if (mux->audio_pad) {
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
GST_WARNING_OBJECT (mux, "Already have an audio pad");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
name = "audio";
|
|
|
|
video = FALSE;
|
|
|
|
} else if (templ == gst_element_class_get_pad_template (klass, "video")) {
|
2017-12-20 20:23:26 +00:00
|
|
|
if (mux->video_pad) {
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
GST_WARNING_OBJECT (mux, "Already have a video pad");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
name = "video";
|
|
|
|
video = TRUE;
|
|
|
|
} else {
|
|
|
|
GST_WARNING_OBJECT (mux, "Invalid template");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
aggpad =
|
|
|
|
GST_AGGREGATOR_CLASS (gst_flv_mux_parent_class)->create_new_pad (agg,
|
|
|
|
templ, name, caps);
|
|
|
|
if (aggpad == NULL)
|
|
|
|
return NULL;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
pad = GST_FLV_MUX_PAD (aggpad);
|
2008-10-27 09:33:40 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_reset_pad (pad);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (video)
|
|
|
|
mux->video_pad = pad;
|
|
|
|
else
|
|
|
|
mux->audio_pad = pad;
|
|
|
|
|
|
|
|
return aggpad;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_flv_mux_release_pad (GstElement * element, GstPad * pad)
|
|
|
|
{
|
2017-12-20 20:23:26 +00:00
|
|
|
GstFlvMux *mux = GST_FLV_MUX (element);
|
|
|
|
GstFlvMuxPad *flvpad = GST_FLV_MUX_PAD (pad);
|
|
|
|
|
|
|
|
gst_pad_set_active (pad, FALSE);
|
|
|
|
gst_flv_mux_reset_pad (flvpad);
|
|
|
|
|
|
|
|
if (flvpad == mux->video_pad) {
|
|
|
|
mux->video_pad = NULL;
|
|
|
|
} else if (flvpad == mux->audio_pad) {
|
|
|
|
mux->audio_pad = NULL;
|
|
|
|
} else {
|
|
|
|
GST_WARNING_OBJECT (pad, "Pad is not known audio or video pad");
|
|
|
|
}
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
|
|
|
gst_element_remove_pad (element, pad);
|
|
|
|
}
|
|
|
|
|
2009-05-14 08:29:49 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_flv_mux_push (GstFlvMux * mux, GstBuffer * buffer)
|
|
|
|
{
|
2018-04-23 15:19:18 +00:00
|
|
|
GstAggregator *agg = GST_AGGREGATOR (mux);
|
|
|
|
GstAggregatorPad *srcpad = GST_AGGREGATOR_PAD (agg->srcpad);
|
|
|
|
|
|
|
|
if (GST_BUFFER_PTS_IS_VALID (buffer))
|
|
|
|
srcpad->segment.position = GST_BUFFER_PTS (buffer);
|
|
|
|
|
2010-03-18 00:51:19 +00:00
|
|
|
/* pushing the buffer that rewrites the header will make it no longer be the
|
|
|
|
* total output size in bytes, but it doesn't matter at that point */
|
2011-07-04 09:09:19 +00:00
|
|
|
mux->byte_count += gst_buffer_get_size (buffer);
|
2010-03-14 00:09:37 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
return gst_aggregator_finish_buffer (GST_AGGREGATOR_CAST (mux), buffer);
|
2009-05-14 08:29:49 +00:00
|
|
|
}
|
|
|
|
|
2010-03-14 18:32:20 +00:00
|
|
|
static GstBuffer *
|
|
|
|
gst_flv_mux_create_header (GstFlvMux * mux)
|
|
|
|
{
|
|
|
|
GstBuffer *header;
|
|
|
|
guint8 *data;
|
2017-12-20 20:23:26 +00:00
|
|
|
gboolean have_audio;
|
|
|
|
gboolean have_video;
|
2010-03-14 18:32:20 +00:00
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
_gst_buffer_new_and_alloc (9 + 4, &header, &data);
|
2010-03-14 18:32:20 +00:00
|
|
|
|
|
|
|
data[0] = 'F';
|
|
|
|
data[1] = 'L';
|
|
|
|
data[2] = 'V';
|
|
|
|
data[3] = 0x01; /* Version */
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
have_audio = (mux->audio_pad && mux->audio_pad->codec != G_MAXUINT);
|
|
|
|
have_video = (mux->video_pad && mux->video_pad->codec != G_MAXUINT);
|
|
|
|
|
|
|
|
data[4] = (have_audio << 2) | have_video; /* flags */
|
2010-03-14 18:32:20 +00:00
|
|
|
GST_WRITE_UINT32_BE (data + 5, 9); /* data offset */
|
|
|
|
GST_WRITE_UINT32_BE (data + 9, 0); /* previous tag size */
|
|
|
|
|
|
|
|
return header;
|
|
|
|
}
|
|
|
|
|
2010-03-14 00:38:21 +00:00
|
|
|
static GstBuffer *
|
|
|
|
gst_flv_mux_preallocate_index (GstFlvMux * mux)
|
|
|
|
{
|
|
|
|
GstBuffer *tmp;
|
|
|
|
guint8 *data;
|
|
|
|
gint preallocate_size;
|
|
|
|
|
|
|
|
/* preallocate index of size:
|
|
|
|
* - 'keyframes' ECMA array key: 2 + 9 = 11 bytes
|
|
|
|
* - nested ECMA array header, length and end marker: 8 bytes
|
|
|
|
* - 'times' and 'filepositions' keys: 22 bytes
|
|
|
|
* - two strict arrays headers and lengths: 10 bytes
|
|
|
|
* - each index entry: 18 bytes
|
|
|
|
*/
|
|
|
|
preallocate_size = 11 + 8 + 22 + 10 + MAX_INDEX_ENTRIES * 18;
|
|
|
|
GST_DEBUG_OBJECT (mux, "preallocating %d bytes for the index",
|
|
|
|
preallocate_size);
|
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
_gst_buffer_new_and_alloc (preallocate_size, &tmp, &data);
|
2010-03-14 00:38:21 +00:00
|
|
|
|
|
|
|
/* prefill the space with a gstfiller: <spaces> script tag variable */
|
|
|
|
GST_WRITE_UINT16_BE (data, 9); /* 9 characters */
|
|
|
|
memcpy (data + 2, "gstfiller", 9);
|
2011-10-26 13:37:03 +00:00
|
|
|
GST_WRITE_UINT8 (data + 11, AMF0_STRING_MARKER); /* a string value */
|
2010-03-14 00:38:21 +00:00
|
|
|
GST_WRITE_UINT16_BE (data + 12, preallocate_size - 14);
|
|
|
|
memset (data + 14, ' ', preallocate_size - 14); /* the rest is spaces */
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2010-03-18 00:51:19 +00:00
|
|
|
static GstBuffer *
|
|
|
|
gst_flv_mux_create_number_script_value (const gchar * name, gdouble value)
|
|
|
|
{
|
2011-07-04 09:09:19 +00:00
|
|
|
GstBuffer *tmp;
|
|
|
|
guint8 *data;
|
2011-10-26 13:37:03 +00:00
|
|
|
gsize len = strlen (name);
|
2011-07-04 09:09:19 +00:00
|
|
|
|
2011-10-27 17:06:06 +00:00
|
|
|
_gst_buffer_new_and_alloc (2 + len + 1 + 8, &tmp, &data);
|
2010-03-18 00:51:19 +00:00
|
|
|
|
2011-10-26 13:37:03 +00:00
|
|
|
GST_WRITE_UINT16_BE (data, len);
|
|
|
|
data += 2; /* name length */
|
|
|
|
memcpy (data, name, len);
|
|
|
|
data += len;
|
|
|
|
*data++ = AMF0_NUMBER_MARKER; /* double type */
|
|
|
|
GST_WRITE_DOUBLE_BE (data, value);
|
2010-03-18 00:51:19 +00:00
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2010-03-14 18:32:20 +00:00
|
|
|
static GstBuffer *
|
2011-12-19 12:56:30 +00:00
|
|
|
gst_flv_mux_create_metadata (GstFlvMux * mux, gboolean full)
|
2009-04-29 11:03:46 +00:00
|
|
|
{
|
2009-09-03 11:40:20 +00:00
|
|
|
const GstTagList *tags;
|
2009-04-29 11:03:46 +00:00
|
|
|
GstBuffer *script_tag, *tmp;
|
2012-01-23 16:25:37 +00:00
|
|
|
GstMapInfo map;
|
2009-04-29 11:03:46 +00:00
|
|
|
guint8 *data;
|
|
|
|
gint i, n_tags, tags_written = 0;
|
|
|
|
|
2009-09-03 11:40:20 +00:00
|
|
|
tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (mux));
|
2009-04-29 11:03:46 +00:00
|
|
|
|
2009-09-03 11:40:20 +00:00
|
|
|
GST_DEBUG_OBJECT (mux, "tags = %" GST_PTR_FORMAT, tags);
|
2009-04-29 11:03:46 +00:00
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
/* FIXME perhaps some bytewriter'ing here ... */
|
|
|
|
|
|
|
|
_gst_buffer_new_and_alloc (11, &script_tag, &data);
|
2009-04-29 11:03:46 +00:00
|
|
|
|
|
|
|
data[0] = 18;
|
|
|
|
|
|
|
|
/* Data size, unknown for now */
|
|
|
|
data[1] = 0;
|
|
|
|
data[2] = 0;
|
|
|
|
data[3] = 0;
|
|
|
|
|
|
|
|
/* Timestamp */
|
|
|
|
data[4] = data[5] = data[6] = data[7] = 0;
|
|
|
|
|
|
|
|
/* Stream ID */
|
|
|
|
data[8] = data[9] = data[10] = 0;
|
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
_gst_buffer_new_and_alloc (13, &tmp, &data);
|
2011-10-26 13:37:03 +00:00
|
|
|
data[0] = AMF0_STRING_MARKER; /* string */
|
2009-04-29 11:03:46 +00:00
|
|
|
data[1] = 0;
|
2009-07-31 19:25:17 +00:00
|
|
|
data[2] = 10; /* length 10 */
|
|
|
|
memcpy (&data[3], "onMetaData", 10);
|
2009-04-29 11:03:46 +00:00
|
|
|
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2009-04-29 11:03:46 +00:00
|
|
|
|
2012-05-26 23:02:08 +00:00
|
|
|
n_tags = (tags) ? gst_tag_list_n_tags (tags) : 0;
|
2011-07-04 09:09:19 +00:00
|
|
|
_gst_buffer_new_and_alloc (5, &tmp, &data);
|
2009-04-29 11:03:46 +00:00
|
|
|
data[0] = 8; /* ECMA array */
|
|
|
|
GST_WRITE_UINT32_BE (data + 1, n_tags);
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2009-04-29 11:03:46 +00:00
|
|
|
|
2011-12-19 12:56:30 +00:00
|
|
|
if (!full)
|
|
|
|
goto tags;
|
|
|
|
|
2010-03-16 00:29:36 +00:00
|
|
|
/* Some players expect the 'duration' to be always set. Fill it out later,
|
|
|
|
after querying the pads or after getting EOS */
|
2011-01-22 08:13:16 +00:00
|
|
|
if (!mux->streamable) {
|
|
|
|
tmp = gst_flv_mux_create_number_script_value ("duration", 86400);
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2011-01-22 08:13:16 +00:00
|
|
|
tags_written++;
|
2010-03-16 00:29:36 +00:00
|
|
|
|
2011-10-26 13:37:03 +00:00
|
|
|
/* Sometimes the information about the total file size is useful for the
|
|
|
|
player. It will be filled later, after getting EOS */
|
2010-03-18 00:51:19 +00:00
|
|
|
tmp = gst_flv_mux_create_number_script_value ("filesize", 0);
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2010-03-18 00:51:19 +00:00
|
|
|
tags_written++;
|
|
|
|
|
2011-10-26 13:37:03 +00:00
|
|
|
/* Preallocate space for the index to be written at EOS */
|
2010-03-14 00:38:21 +00:00
|
|
|
tmp = gst_flv_mux_preallocate_index (mux);
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2010-03-14 00:38:21 +00:00
|
|
|
} else {
|
2010-06-09 12:13:09 +00:00
|
|
|
GST_DEBUG_OBJECT (mux, "not preallocating index, streamable mode");
|
2010-03-14 00:38:21 +00:00
|
|
|
}
|
|
|
|
|
2011-12-19 12:56:30 +00:00
|
|
|
tags:
|
2009-09-03 11:40:20 +00:00
|
|
|
for (i = 0; tags && i < n_tags; i++) {
|
2012-05-26 23:02:08 +00:00
|
|
|
const gchar *tag_name = gst_tag_list_nth_tag_name (tags, i);
|
2009-04-29 11:03:46 +00:00
|
|
|
if (!strcmp (tag_name, GST_TAG_DURATION)) {
|
|
|
|
guint64 dur;
|
|
|
|
|
2009-09-03 11:40:20 +00:00
|
|
|
if (!gst_tag_list_get_uint64 (tags, GST_TAG_DURATION, &dur))
|
2009-04-29 11:03:46 +00:00
|
|
|
continue;
|
2010-03-16 00:29:36 +00:00
|
|
|
mux->duration = dur;
|
2009-04-29 11:03:46 +00:00
|
|
|
} else if (!strcmp (tag_name, GST_TAG_ARTIST) ||
|
|
|
|
!strcmp (tag_name, GST_TAG_TITLE)) {
|
|
|
|
gchar *s;
|
2009-05-15 06:44:39 +00:00
|
|
|
const gchar *t = NULL;
|
2009-04-29 11:03:46 +00:00
|
|
|
|
|
|
|
if (!strcmp (tag_name, GST_TAG_ARTIST))
|
|
|
|
t = "creator";
|
|
|
|
else if (!strcmp (tag_name, GST_TAG_TITLE))
|
|
|
|
t = "title";
|
|
|
|
|
2009-09-03 11:40:20 +00:00
|
|
|
if (!gst_tag_list_get_string (tags, tag_name, &s))
|
2009-04-29 11:03:46 +00:00
|
|
|
continue;
|
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
_gst_buffer_new_and_alloc (2 + strlen (t) + 1 + 2 + strlen (s),
|
|
|
|
&tmp, &data);
|
2009-04-29 11:03:46 +00:00
|
|
|
data[0] = 0; /* tag name length */
|
|
|
|
data[1] = strlen (t);
|
|
|
|
memcpy (&data[2], t, strlen (t));
|
|
|
|
data[2 + strlen (t)] = 2; /* string */
|
|
|
|
data[3 + strlen (t)] = (strlen (s) >> 8) & 0xff;
|
|
|
|
data[4 + strlen (t)] = (strlen (s)) & 0xff;
|
|
|
|
memcpy (&data[5 + strlen (t)], s, strlen (s));
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2009-04-29 11:03:46 +00:00
|
|
|
|
|
|
|
g_free (s);
|
|
|
|
tags_written++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-19 12:56:30 +00:00
|
|
|
if (!full)
|
|
|
|
goto end;
|
|
|
|
|
2010-03-16 00:29:36 +00:00
|
|
|
if (mux->duration == GST_CLOCK_TIME_NONE) {
|
2017-12-20 20:23:26 +00:00
|
|
|
GList *l;
|
2009-05-14 08:35:22 +00:00
|
|
|
guint64 dur;
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
for (l = GST_ELEMENT_CAST (mux)->sinkpads; l; l = l->next) {
|
|
|
|
GstFlvMuxPad *pad = GST_FLV_MUX_PAD (l->data);
|
2009-05-14 08:35:22 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (gst_pad_peer_query_duration (GST_PAD (pad), GST_FORMAT_TIME,
|
2011-07-28 09:54:38 +00:00
|
|
|
(gint64 *) & dur) && dur != GST_CLOCK_TIME_NONE) {
|
2010-03-16 00:29:36 +00:00
|
|
|
if (mux->duration == GST_CLOCK_TIME_NONE)
|
|
|
|
mux->duration = dur;
|
2009-05-14 08:35:22 +00:00
|
|
|
else
|
2010-03-16 00:29:36 +00:00
|
|
|
mux->duration = MAX (dur, mux->duration);
|
2009-05-14 08:35:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-01 04:04:03 +00:00
|
|
|
if (!mux->streamable && mux->duration != GST_CLOCK_TIME_NONE) {
|
2009-05-14 08:35:22 +00:00
|
|
|
gdouble d;
|
2012-01-23 16:25:37 +00:00
|
|
|
GstMapInfo map;
|
|
|
|
|
2010-03-16 00:29:36 +00:00
|
|
|
d = gst_guint64_to_gdouble (mux->duration);
|
2009-05-14 08:35:22 +00:00
|
|
|
d /= (gdouble) GST_SECOND;
|
|
|
|
|
2010-03-16 00:29:36 +00:00
|
|
|
GST_DEBUG_OBJECT (mux, "determined the duration to be %f", d);
|
2012-01-23 16:25:37 +00:00
|
|
|
gst_buffer_map (script_tag, &map, GST_MAP_WRITE);
|
|
|
|
GST_WRITE_DOUBLE_BE (map.data + 29 + 2 + 8 + 1, d);
|
|
|
|
gst_buffer_unmap (script_tag, &map);
|
2009-05-14 08:35:22 +00:00
|
|
|
}
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (mux->video_pad && mux->video_pad->codec != G_MAXUINT) {
|
2015-12-16 12:40:39 +00:00
|
|
|
GstCaps *caps = NULL;
|
2009-04-29 11:16:25 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (mux->video_pad)
|
|
|
|
caps = gst_pad_get_current_caps (GST_PAD (mux->video_pad));
|
2015-12-16 12:40:39 +00:00
|
|
|
|
|
|
|
if (caps != NULL) {
|
2011-07-04 09:09:19 +00:00
|
|
|
GstStructure *s;
|
2010-03-16 22:43:39 +00:00
|
|
|
gint size;
|
2010-03-18 00:51:19 +00:00
|
|
|
gint num, den;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mux, "putting videocodecid %d in the metadata",
|
2017-12-20 20:23:26 +00:00
|
|
|
mux->video_pad->codec);
|
2010-03-18 00:51:19 +00:00
|
|
|
|
|
|
|
tmp = gst_flv_mux_create_number_script_value ("videocodecid",
|
2017-12-20 20:23:26 +00:00
|
|
|
mux->video_pad->codec);
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2010-03-18 00:51:19 +00:00
|
|
|
tags_written++;
|
2009-04-29 11:16:25 +00:00
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
2010-03-16 22:43:39 +00:00
|
|
|
if (gst_structure_get_int (s, "width", &size)) {
|
|
|
|
GST_DEBUG_OBJECT (mux, "putting width %d in the metadata", size);
|
|
|
|
|
2010-03-18 00:51:19 +00:00
|
|
|
tmp = gst_flv_mux_create_number_script_value ("width", size);
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2010-03-16 22:43:39 +00:00
|
|
|
tags_written++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gst_structure_get_int (s, "height", &size)) {
|
|
|
|
GST_DEBUG_OBJECT (mux, "putting height %d in the metadata", size);
|
|
|
|
|
2010-03-18 00:51:19 +00:00
|
|
|
tmp = gst_flv_mux_create_number_script_value ("height", size);
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2010-03-16 22:43:39 +00:00
|
|
|
tags_written++;
|
|
|
|
}
|
|
|
|
|
2010-03-18 00:51:19 +00:00
|
|
|
if (gst_structure_get_fraction (s, "pixel-aspect-ratio", &num, &den)) {
|
2009-04-29 11:16:25 +00:00
|
|
|
gdouble d;
|
|
|
|
|
2010-03-18 00:51:19 +00:00
|
|
|
d = num;
|
2010-03-16 22:43:39 +00:00
|
|
|
GST_DEBUG_OBJECT (mux, "putting AspectRatioX %f in the metadata", d);
|
|
|
|
|
2010-03-18 00:51:19 +00:00
|
|
|
tmp = gst_flv_mux_create_number_script_value ("AspectRatioX", d);
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2009-04-29 11:16:25 +00:00
|
|
|
tags_written++;
|
|
|
|
|
2010-03-18 00:51:19 +00:00
|
|
|
d = den;
|
2010-03-16 22:43:39 +00:00
|
|
|
GST_DEBUG_OBJECT (mux, "putting AspectRatioY %f in the metadata", d);
|
|
|
|
|
2010-03-18 00:51:19 +00:00
|
|
|
tmp = gst_flv_mux_create_number_script_value ("AspectRatioY", d);
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2010-03-18 00:51:19 +00:00
|
|
|
tags_written++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gst_structure_get_fraction (s, "framerate", &num, &den)) {
|
|
|
|
gdouble d;
|
|
|
|
|
|
|
|
gst_util_fraction_to_double (num, den, &d);
|
|
|
|
GST_DEBUG_OBJECT (mux, "putting framerate %f in the metadata", d);
|
|
|
|
|
|
|
|
tmp = gst_flv_mux_create_number_script_value ("framerate", d);
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2009-04-29 11:16:25 +00:00
|
|
|
tags_written++;
|
|
|
|
}
|
2015-07-29 14:59:15 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mux, "putting videodatarate %u KB/s in the metadata",
|
2017-12-20 20:23:26 +00:00
|
|
|
mux->video_pad->bitrate / 1024);
|
2015-07-29 14:59:15 +00:00
|
|
|
tmp = gst_flv_mux_create_number_script_value ("videodatarate",
|
2017-12-20 20:23:26 +00:00
|
|
|
mux->video_pad->bitrate / 1024);
|
2015-07-29 14:59:15 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
|
|
|
tags_written++;
|
2009-04-29 11:16:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (mux->audio_pad && mux->audio_pad->codec != G_MAXUINT) {
|
|
|
|
GST_DEBUG_OBJECT (mux, "putting audiocodecid %d in the metadata",
|
|
|
|
mux->audio_pad->codec);
|
2010-03-18 00:51:19 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
tmp = gst_flv_mux_create_number_script_value ("audiocodecid",
|
|
|
|
mux->audio_pad->codec);
|
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
|
|
|
tags_written++;
|
2015-07-29 14:59:15 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
GST_DEBUG_OBJECT (mux, "putting audiodatarate %u KB/s in the metadata",
|
|
|
|
mux->audio_pad->bitrate / 1024);
|
|
|
|
tmp = gst_flv_mux_create_number_script_value ("audiodatarate",
|
|
|
|
mux->audio_pad->bitrate / 1024);
|
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
|
|
|
tags_written++;
|
2010-03-18 00:51:19 +00:00
|
|
|
}
|
|
|
|
|
2016-11-09 06:25:27 +00:00
|
|
|
_gst_buffer_new_and_alloc (2 + 15 + 1 + 2 + strlen (mux->metadatacreator),
|
|
|
|
&tmp, &data);
|
|
|
|
data[0] = 0; /* 15 bytes name */
|
|
|
|
data[1] = 15;
|
|
|
|
memcpy (&data[2], "metadatacreator", 15);
|
|
|
|
data[17] = 2; /* string */
|
|
|
|
data[18] = (strlen (mux->metadatacreator) >> 8) & 0xff;
|
|
|
|
data[19] = (strlen (mux->metadatacreator)) & 0xff;
|
|
|
|
memcpy (&data[20], mux->metadatacreator, strlen (mux->metadatacreator));
|
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2009-04-29 11:03:46 +00:00
|
|
|
|
2016-11-09 06:25:27 +00:00
|
|
|
tags_written++;
|
2009-04-29 11:03:46 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
GTimeVal tv = { 0, };
|
|
|
|
time_t secs;
|
|
|
|
struct tm *tm;
|
|
|
|
gchar *s;
|
|
|
|
static const gchar *weekdays[] = {
|
|
|
|
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
|
|
|
};
|
|
|
|
static const gchar *months[] = {
|
|
|
|
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
|
|
|
|
"Aug", "Sep", "Oct", "Nov", "Dec"
|
|
|
|
};
|
|
|
|
|
|
|
|
g_get_current_time (&tv);
|
|
|
|
secs = tv.tv_sec;
|
|
|
|
tm = gmtime (&secs);
|
|
|
|
|
2015-10-21 10:16:01 +00:00
|
|
|
s = g_strdup_printf ("%s %s %d %02d:%02d:%02d %d", weekdays[tm->tm_wday],
|
2009-04-29 11:03:46 +00:00
|
|
|
months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
|
|
|
|
tm->tm_year + 1900);
|
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
_gst_buffer_new_and_alloc (2 + 12 + 1 + 2 + strlen (s), &tmp, &data);
|
2009-04-29 11:03:46 +00:00
|
|
|
data[0] = 0; /* 12 bytes name */
|
|
|
|
data[1] = 12;
|
2009-07-31 19:25:17 +00:00
|
|
|
memcpy (&data[2], "creationdate", 12);
|
2009-04-29 11:03:46 +00:00
|
|
|
data[14] = 2; /* string */
|
|
|
|
data[15] = (strlen (s) >> 8) & 0xff;
|
|
|
|
data[16] = (strlen (s)) & 0xff;
|
|
|
|
memcpy (&data[17], s, strlen (s));
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2009-04-29 11:03:46 +00:00
|
|
|
|
|
|
|
g_free (s);
|
|
|
|
tags_written++;
|
|
|
|
}
|
|
|
|
|
2011-12-19 12:56:30 +00:00
|
|
|
end:
|
|
|
|
|
|
|
|
if (!tags_written) {
|
|
|
|
gst_buffer_unref (script_tag);
|
2011-12-25 14:23:29 +00:00
|
|
|
script_tag = NULL;
|
2011-12-19 12:56:30 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
_gst_buffer_new_and_alloc (2 + 0 + 1, &tmp, &data);
|
2009-04-29 11:03:46 +00:00
|
|
|
data[0] = 0; /* 0 byte size */
|
|
|
|
data[1] = 0;
|
|
|
|
data[2] = 9; /* end marker */
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2013-10-11 15:13:00 +00:00
|
|
|
|
2009-04-29 11:03:46 +00:00
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
_gst_buffer_new_and_alloc (4, &tmp, &data);
|
|
|
|
GST_WRITE_UINT32_BE (data, gst_buffer_get_size (script_tag));
|
2012-03-28 10:49:19 +00:00
|
|
|
script_tag = gst_buffer_append (script_tag, tmp);
|
2009-04-29 11:03:46 +00:00
|
|
|
|
2012-01-23 16:25:37 +00:00
|
|
|
gst_buffer_map (script_tag, &map, GST_MAP_WRITE);
|
|
|
|
map.data[1] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 16) & 0xff;
|
|
|
|
map.data[2] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 8) & 0xff;
|
|
|
|
map.data[3] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 0) & 0xff;
|
2009-04-29 11:03:46 +00:00
|
|
|
|
2012-01-23 16:25:37 +00:00
|
|
|
GST_WRITE_UINT32_BE (map.data + 11 + 13 + 1, tags_written);
|
|
|
|
gst_buffer_unmap (script_tag, &map);
|
2009-04-29 11:03:46 +00:00
|
|
|
|
2011-12-19 12:56:30 +00:00
|
|
|
exit:
|
2010-03-14 18:32:20 +00:00
|
|
|
return script_tag;
|
2009-04-29 11:03:46 +00:00
|
|
|
}
|
|
|
|
|
2010-03-14 18:32:20 +00:00
|
|
|
static GstBuffer *
|
2010-03-15 00:09:49 +00:00
|
|
|
gst_flv_mux_buffer_to_tag_internal (GstFlvMux * mux, GstBuffer * buffer,
|
2017-12-20 20:23:26 +00:00
|
|
|
GstFlvMuxPad * pad, gboolean is_codec_data)
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
{
|
|
|
|
GstBuffer *tag;
|
2012-01-23 16:25:37 +00:00
|
|
|
GstMapInfo map;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
guint size;
|
2014-06-07 03:17:52 +00:00
|
|
|
guint32 pts, dts, cts;
|
2015-06-22 18:35:52 +00:00
|
|
|
guint8 *data, *bdata = NULL;
|
|
|
|
gsize bsize = 0;
|
2011-07-04 09:09:19 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (!GST_CLOCK_STIME_IS_VALID (pad->dts)) {
|
|
|
|
pts = dts = pad->last_timestamp / GST_MSECOND;
|
2015-06-10 22:15:52 +00:00
|
|
|
} else {
|
2017-12-20 20:23:26 +00:00
|
|
|
pts = pad->pts / GST_MSECOND;
|
|
|
|
dts = pad->dts / GST_MSECOND;
|
2015-06-10 22:15:52 +00:00
|
|
|
}
|
2014-06-07 03:17:52 +00:00
|
|
|
|
2015-06-10 22:15:52 +00:00
|
|
|
/* Be safe in case TS are buggy */
|
2014-06-07 03:17:52 +00:00
|
|
|
if (pts > dts)
|
|
|
|
cts = pts - dts;
|
|
|
|
else
|
|
|
|
cts = 0;
|
|
|
|
|
2014-07-29 00:58:59 +00:00
|
|
|
/* Timestamp must start at zero */
|
2015-06-10 22:15:52 +00:00
|
|
|
if (GST_CLOCK_STIME_IS_VALID (mux->first_timestamp)) {
|
2014-08-28 01:07:26 +00:00
|
|
|
dts -= mux->first_timestamp / GST_MSECOND;
|
|
|
|
pts = dts + cts;
|
|
|
|
}
|
2014-07-29 00:58:59 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
GST_LOG_OBJECT (mux, "got pts %i dts %i cts %i", pts, dts, cts);
|
2014-06-07 03:17:52 +00:00
|
|
|
|
2015-06-22 18:35:52 +00:00
|
|
|
if (buffer != NULL) {
|
|
|
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
|
|
|
bdata = map.data;
|
|
|
|
bsize = map.size;
|
|
|
|
}
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
|
|
|
size = 11;
|
2017-12-20 20:23:26 +00:00
|
|
|
if (mux->video_pad == pad) {
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
size += 1;
|
2017-12-20 20:23:26 +00:00
|
|
|
if (pad->codec == 7)
|
2011-07-04 09:09:19 +00:00
|
|
|
size += 4 + bsize;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
else
|
2011-07-04 09:09:19 +00:00
|
|
|
size += bsize;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else {
|
|
|
|
size += 1;
|
2017-12-20 20:23:26 +00:00
|
|
|
if (pad->codec == 10)
|
2011-07-04 09:09:19 +00:00
|
|
|
size += 1 + bsize;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
else
|
2011-07-04 09:09:19 +00:00
|
|
|
size += bsize;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
size += 4;
|
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
_gst_buffer_new_and_alloc (size, &tag, &data);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
memset (data, 0, size);
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
data[0] = (mux->video_pad == pad) ? 9 : 8;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
|
|
|
data[1] = ((size - 11 - 4) >> 16) & 0xff;
|
|
|
|
data[2] = ((size - 11 - 4) >> 8) & 0xff;
|
|
|
|
data[3] = ((size - 11 - 4) >> 0) & 0xff;
|
|
|
|
|
2014-06-07 03:17:52 +00:00
|
|
|
GST_WRITE_UINT24_BE (data + 4, dts);
|
|
|
|
data[7] = (((guint) dts) >> 24) & 0xff;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
|
|
|
data[8] = data[9] = data[10] = 0;
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (mux->video_pad == pad) {
|
2015-06-22 18:35:52 +00:00
|
|
|
if (buffer && GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT))
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
data[11] |= 2 << 4;
|
|
|
|
else
|
|
|
|
data[11] |= 1 << 4;
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
data[11] |= pad->codec & 0x0f;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (pad->codec == 7) {
|
2014-06-07 03:17:52 +00:00
|
|
|
if (is_codec_data) {
|
|
|
|
data[12] = 0;
|
|
|
|
GST_WRITE_UINT24_BE (data + 13, 0);
|
2015-06-22 18:35:52 +00:00
|
|
|
} else if (bsize == 0) {
|
|
|
|
/* AVC end of sequence */
|
|
|
|
data[12] = 2;
|
|
|
|
GST_WRITE_UINT24_BE (data + 13, 0);
|
2014-06-07 03:17:52 +00:00
|
|
|
} else {
|
|
|
|
/* ACV NALU */
|
|
|
|
data[12] = 1;
|
|
|
|
GST_WRITE_UINT24_BE (data + 13, cts);
|
|
|
|
}
|
2011-07-04 09:09:19 +00:00
|
|
|
memcpy (data + 11 + 1 + 4, bdata, bsize);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else {
|
2011-07-04 09:09:19 +00:00
|
|
|
memcpy (data + 11 + 1, bdata, bsize);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
} else {
|
2017-12-20 20:23:26 +00:00
|
|
|
data[11] |= (pad->codec << 4) & 0xf0;
|
|
|
|
data[11] |= (pad->rate << 2) & 0x0c;
|
|
|
|
data[11] |= (pad->width << 1) & 0x02;
|
|
|
|
data[11] |= (pad->channels << 0) & 0x01;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2015-09-02 08:44:59 +00:00
|
|
|
GST_DEBUG_OBJECT (mux, "Creating byte %02x with "
|
2017-12-20 20:23:26 +00:00
|
|
|
"codec:%d, rate:%d, width:%d, channels:%d",
|
|
|
|
data[11], pad->codec, pad->rate, pad->width, pad->channels);
|
2015-09-02 08:44:59 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (pad->codec == 10) {
|
2010-03-14 18:32:20 +00:00
|
|
|
data[12] = is_codec_data ? 0 : 1;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
memcpy (data + 11 + 1 + 1, bdata, bsize);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
} else {
|
2011-07-04 09:09:19 +00:00
|
|
|
memcpy (data + 11 + 1, bdata, bsize);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-22 18:35:52 +00:00
|
|
|
if (buffer)
|
|
|
|
gst_buffer_unmap (buffer, &map);
|
2011-07-04 09:09:19 +00:00
|
|
|
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
GST_WRITE_UINT32_BE (data + size - 4, size - 4);
|
|
|
|
|
2014-06-07 03:17:52 +00:00
|
|
|
GST_BUFFER_PTS (tag) = GST_CLOCK_TIME_NONE;
|
|
|
|
GST_BUFFER_DTS (tag) = GST_CLOCK_TIME_NONE;
|
|
|
|
GST_BUFFER_DURATION (tag) = GST_CLOCK_TIME_NONE;
|
2011-07-04 09:09:19 +00:00
|
|
|
|
2015-06-22 18:35:52 +00:00
|
|
|
if (buffer) {
|
2015-09-02 08:44:59 +00:00
|
|
|
/* if we are streamable we copy over timestamps and offsets,
|
|
|
|
if not just copy the offsets */
|
|
|
|
if (mux->streamable) {
|
2018-03-01 22:15:02 +00:00
|
|
|
GstClockTime timestamp = GST_CLOCK_TIME_NONE;
|
|
|
|
|
|
|
|
if (gst_segment_to_running_time_full (&GST_AGGREGATOR_PAD (pad)->segment,
|
2018-03-01 23:24:33 +00:00
|
|
|
GST_FORMAT_TIME, GST_BUFFER_DTS_OR_PTS (buffer),
|
|
|
|
×tamp) == 1) {
|
2018-03-01 22:15:02 +00:00
|
|
|
GST_BUFFER_PTS (tag) = timestamp;
|
2018-03-01 23:24:33 +00:00
|
|
|
GST_BUFFER_DURATION (tag) = GST_BUFFER_DURATION (buffer);
|
|
|
|
}
|
2015-09-22 20:59:16 +00:00
|
|
|
GST_BUFFER_OFFSET (tag) = GST_BUFFER_OFFSET_NONE;
|
|
|
|
GST_BUFFER_OFFSET_END (tag) = GST_BUFFER_OFFSET_NONE;
|
2015-09-02 08:44:59 +00:00
|
|
|
} else {
|
|
|
|
GST_BUFFER_OFFSET (tag) = GST_BUFFER_OFFSET (buffer);
|
|
|
|
GST_BUFFER_OFFSET_END (tag) = GST_BUFFER_OFFSET_END (buffer);
|
|
|
|
}
|
2010-03-15 00:09:49 +00:00
|
|
|
|
2015-06-22 18:35:52 +00:00
|
|
|
/* mark the buffer if it's an audio buffer and there's also video being muxed
|
|
|
|
* or it's a video interframe */
|
2017-12-20 20:23:26 +00:00
|
|
|
if (mux->video_pad == pad &&
|
2015-06-22 18:35:52 +00:00
|
|
|
GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT))
|
|
|
|
GST_BUFFER_FLAG_SET (tag, GST_BUFFER_FLAG_DELTA_UNIT);
|
|
|
|
} else {
|
|
|
|
GST_BUFFER_FLAG_SET (tag, GST_BUFFER_FLAG_DELTA_UNIT);
|
|
|
|
GST_BUFFER_OFFSET (tag) = GST_BUFFER_OFFSET_END (tag) =
|
|
|
|
GST_BUFFER_OFFSET_NONE;
|
|
|
|
}
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2010-03-14 18:32:20 +00:00
|
|
|
return tag;
|
|
|
|
}
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2010-03-14 18:32:20 +00:00
|
|
|
static inline GstBuffer *
|
2010-03-15 00:09:49 +00:00
|
|
|
gst_flv_mux_buffer_to_tag (GstFlvMux * mux, GstBuffer * buffer,
|
2017-12-20 20:23:26 +00:00
|
|
|
GstFlvMuxPad * pad)
|
2010-03-14 18:32:20 +00:00
|
|
|
{
|
2017-12-20 20:23:26 +00:00
|
|
|
return gst_flv_mux_buffer_to_tag_internal (mux, buffer, pad, FALSE);
|
2010-03-14 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline GstBuffer *
|
2010-03-15 00:09:49 +00:00
|
|
|
gst_flv_mux_codec_data_buffer_to_tag (GstFlvMux * mux, GstBuffer * buffer,
|
2017-12-20 20:23:26 +00:00
|
|
|
GstFlvMuxPad * pad)
|
2010-03-14 18:32:20 +00:00
|
|
|
{
|
2017-12-20 20:23:26 +00:00
|
|
|
return gst_flv_mux_buffer_to_tag_internal (mux, buffer, pad, TRUE);
|
2010-03-14 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
2015-06-22 18:35:52 +00:00
|
|
|
static inline GstBuffer *
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_eos_to_tag (GstFlvMux * mux, GstFlvMuxPad * pad)
|
2015-06-22 18:35:52 +00:00
|
|
|
{
|
2017-12-20 20:23:26 +00:00
|
|
|
return gst_flv_mux_buffer_to_tag_internal (mux, NULL, pad, FALSE);
|
2015-06-22 18:35:52 +00:00
|
|
|
}
|
|
|
|
|
2010-03-14 18:32:20 +00:00
|
|
|
static void
|
|
|
|
gst_flv_mux_put_buffer_in_streamheader (GValue * streamheader,
|
|
|
|
GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GValue value = { 0 };
|
|
|
|
GstBuffer *buf;
|
|
|
|
|
|
|
|
g_value_init (&value, GST_TYPE_BUFFER);
|
|
|
|
buf = gst_buffer_copy (buffer);
|
|
|
|
gst_value_set_buffer (&value, buf);
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
gst_value_array_append_value (streamheader, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
|
2018-09-06 04:13:19 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_flv_mux_prepare_src_caps (GstFlvMux * mux, GstBuffer ** header_buf,
|
|
|
|
GstBuffer ** metadata_buf, GstBuffer ** video_codec_data_buf,
|
|
|
|
GstBuffer ** audio_codec_data_buf)
|
2010-03-14 18:32:20 +00:00
|
|
|
{
|
|
|
|
GstBuffer *header, *metadata;
|
|
|
|
GstBuffer *video_codec_data, *audio_codec_data;
|
|
|
|
GstCaps *caps;
|
|
|
|
GstStructure *structure;
|
|
|
|
GValue streamheader = { 0 };
|
2017-12-20 20:23:26 +00:00
|
|
|
GList *l;
|
2012-02-25 15:48:44 +00:00
|
|
|
|
2010-03-14 18:32:20 +00:00
|
|
|
header = gst_flv_mux_create_header (mux);
|
2011-12-19 12:56:30 +00:00
|
|
|
metadata = gst_flv_mux_create_metadata (mux, TRUE);
|
2010-03-14 18:32:20 +00:00
|
|
|
video_codec_data = NULL;
|
|
|
|
audio_codec_data = NULL;
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
for (l = GST_ELEMENT_CAST (mux)->sinkpads; l != NULL; l = l->next) {
|
|
|
|
GstFlvMuxPad *pad = l->data;
|
2010-03-14 18:32:20 +00:00
|
|
|
|
|
|
|
/* Get H.264 and AAC codec data, if present */
|
2017-12-20 20:23:26 +00:00
|
|
|
if (pad && mux->video_pad == pad && pad->codec == 7) {
|
|
|
|
if (pad->codec_data == NULL)
|
2010-03-14 18:32:20 +00:00
|
|
|
GST_WARNING_OBJECT (mux, "Codec data for video stream not found, "
|
|
|
|
"output might not be playable");
|
|
|
|
else
|
|
|
|
video_codec_data =
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_codec_data_buffer_to_tag (mux, pad->codec_data, pad);
|
|
|
|
} else if (pad && mux->audio_pad == pad && pad->codec == 10) {
|
|
|
|
if (pad->codec_data == NULL)
|
2010-03-14 18:32:20 +00:00
|
|
|
GST_WARNING_OBJECT (mux, "Codec data for audio stream not found, "
|
|
|
|
"output might not be playable");
|
|
|
|
else
|
|
|
|
audio_codec_data =
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_codec_data_buffer_to_tag (mux, pad->codec_data, pad);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
2010-03-14 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mark buffers that will go in the streamheader */
|
2012-01-30 16:16:51 +00:00
|
|
|
GST_BUFFER_FLAG_SET (header, GST_BUFFER_FLAG_HEADER);
|
|
|
|
GST_BUFFER_FLAG_SET (metadata, GST_BUFFER_FLAG_HEADER);
|
2010-03-15 00:09:49 +00:00
|
|
|
if (video_codec_data != NULL) {
|
2012-01-30 16:16:51 +00:00
|
|
|
GST_BUFFER_FLAG_SET (video_codec_data, GST_BUFFER_FLAG_HEADER);
|
2010-03-15 00:09:49 +00:00
|
|
|
/* mark as a delta unit, so downstream will not try to synchronize on that
|
|
|
|
* buffer - to actually start playback you need a real video keyframe */
|
|
|
|
GST_BUFFER_FLAG_SET (video_codec_data, GST_BUFFER_FLAG_DELTA_UNIT);
|
|
|
|
}
|
|
|
|
if (audio_codec_data != NULL) {
|
2012-01-30 16:16:51 +00:00
|
|
|
GST_BUFFER_FLAG_SET (audio_codec_data, GST_BUFFER_FLAG_HEADER);
|
2010-03-15 00:09:49 +00:00
|
|
|
}
|
2010-03-14 18:32:20 +00:00
|
|
|
|
|
|
|
/* put buffers in streamheader */
|
|
|
|
g_value_init (&streamheader, GST_TYPE_ARRAY);
|
|
|
|
gst_flv_mux_put_buffer_in_streamheader (&streamheader, header);
|
|
|
|
gst_flv_mux_put_buffer_in_streamheader (&streamheader, metadata);
|
|
|
|
if (video_codec_data != NULL)
|
|
|
|
gst_flv_mux_put_buffer_in_streamheader (&streamheader, video_codec_data);
|
|
|
|
if (audio_codec_data != NULL)
|
|
|
|
gst_flv_mux_put_buffer_in_streamheader (&streamheader, audio_codec_data);
|
|
|
|
|
|
|
|
/* create the caps and put the streamheader in them */
|
2011-10-27 17:00:52 +00:00
|
|
|
caps = gst_caps_new_empty_simple ("video/x-flv");
|
2010-03-14 18:32:20 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
gst_structure_set_value (structure, "streamheader", &streamheader);
|
|
|
|
g_value_unset (&streamheader);
|
|
|
|
|
2018-09-06 04:13:19 +00:00
|
|
|
if (header_buf) {
|
|
|
|
*header_buf = header;
|
|
|
|
} else {
|
|
|
|
gst_buffer_unref (header);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (metadata_buf) {
|
|
|
|
*metadata_buf = metadata;
|
|
|
|
} else {
|
|
|
|
gst_buffer_unref (metadata);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (video_codec_data_buf) {
|
|
|
|
*video_codec_data_buf = video_codec_data;
|
|
|
|
} else if (video_codec_data) {
|
|
|
|
gst_buffer_unref (video_codec_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (audio_codec_data_buf) {
|
|
|
|
*audio_codec_data_buf = audio_codec_data;
|
|
|
|
} else if (audio_codec_data) {
|
|
|
|
gst_buffer_unref (audio_codec_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_flv_mux_write_header (GstFlvMux * mux)
|
|
|
|
{
|
|
|
|
GstBuffer *header, *metadata;
|
|
|
|
GstBuffer *video_codec_data, *audio_codec_data;
|
|
|
|
GstCaps *caps;
|
|
|
|
GstFlowReturn ret;
|
|
|
|
|
|
|
|
header = metadata = video_codec_data = audio_codec_data = NULL;
|
|
|
|
|
|
|
|
/* if not streaming, check if downstream is seekable */
|
|
|
|
if (!mux->streamable) {
|
|
|
|
gboolean seekable;
|
|
|
|
GstQuery *query;
|
|
|
|
|
|
|
|
query = gst_query_new_seeking (GST_FORMAT_BYTES);
|
|
|
|
if (gst_pad_peer_query (mux->srcpad, query)) {
|
|
|
|
gst_query_parse_seeking (query, NULL, &seekable, NULL, NULL);
|
|
|
|
GST_INFO_OBJECT (mux, "downstream is %sseekable", seekable ? "" : "not ");
|
|
|
|
} else {
|
|
|
|
/* have to assume seeking is supported if query not handled downstream */
|
|
|
|
GST_WARNING_OBJECT (mux, "downstream did not handle seeking query");
|
|
|
|
seekable = FALSE;
|
|
|
|
}
|
|
|
|
if (!seekable) {
|
|
|
|
mux->streamable = TRUE;
|
|
|
|
g_object_notify (G_OBJECT (mux), "streamable");
|
|
|
|
GST_WARNING_OBJECT (mux, "downstream is not seekable, but "
|
|
|
|
"streamable=false. Will ignore that and create streamable output "
|
|
|
|
"instead");
|
|
|
|
}
|
|
|
|
gst_query_unref (query);
|
|
|
|
}
|
|
|
|
|
|
|
|
caps = gst_flv_mux_prepare_src_caps (mux,
|
|
|
|
&header, &metadata, &video_codec_data, &audio_codec_data);
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_aggregator_set_src_caps (GST_AGGREGATOR_CAST (mux), caps);
|
2010-03-14 18:32:20 +00:00
|
|
|
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
/* push the header buffer, the metadata and the codec info, if any */
|
|
|
|
ret = gst_flv_mux_push (mux, header);
|
|
|
|
if (ret != GST_FLOW_OK)
|
2015-12-03 13:46:34 +00:00
|
|
|
goto failure_header;
|
2010-03-14 18:32:20 +00:00
|
|
|
ret = gst_flv_mux_push (mux, metadata);
|
|
|
|
if (ret != GST_FLOW_OK)
|
2015-12-03 13:46:34 +00:00
|
|
|
goto failure_metadata;
|
2010-03-14 18:32:20 +00:00
|
|
|
if (video_codec_data != NULL) {
|
|
|
|
ret = gst_flv_mux_push (mux, video_codec_data);
|
|
|
|
if (ret != GST_FLOW_OK)
|
2015-12-03 13:46:34 +00:00
|
|
|
goto failure_video_codec_data;
|
2010-03-14 18:32:20 +00:00
|
|
|
}
|
|
|
|
if (audio_codec_data != NULL) {
|
|
|
|
ret = gst_flv_mux_push (mux, audio_codec_data);
|
|
|
|
if (ret != GST_FLOW_OK)
|
2015-12-03 13:46:34 +00:00
|
|
|
goto failure_audio_codec_data;
|
2010-03-14 18:32:20 +00:00
|
|
|
}
|
|
|
|
return GST_FLOW_OK;
|
2015-12-03 13:46:34 +00:00
|
|
|
|
|
|
|
failure_header:
|
2016-02-19 15:02:04 +00:00
|
|
|
gst_buffer_unref (metadata);
|
2015-12-03 13:46:34 +00:00
|
|
|
|
|
|
|
failure_metadata:
|
2016-02-19 15:02:04 +00:00
|
|
|
if (video_codec_data != NULL)
|
|
|
|
gst_buffer_unref (video_codec_data);
|
2015-12-03 13:46:34 +00:00
|
|
|
|
|
|
|
failure_video_codec_data:
|
2016-02-19 15:02:04 +00:00
|
|
|
if (audio_codec_data != NULL)
|
|
|
|
gst_buffer_unref (audio_codec_data);
|
2015-12-03 13:46:34 +00:00
|
|
|
|
|
|
|
failure_audio_codec_data:
|
2016-02-19 15:02:04 +00:00
|
|
|
return ret;
|
2010-03-14 18:32:20 +00:00
|
|
|
}
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
static GstClockTime
|
|
|
|
gst_flv_mux_segment_to_running_time (const GstSegment * segment, GstClockTime t)
|
|
|
|
{
|
|
|
|
/* we can get a dts before the segment, if dts < pts and pts is inside
|
|
|
|
* the segment, so we consider early times as 0 */
|
|
|
|
if (t < segment->start)
|
|
|
|
return 0;
|
|
|
|
return gst_segment_to_running_time (segment, GST_FORMAT_TIME, t);
|
|
|
|
}
|
|
|
|
|
2010-03-14 18:32:20 +00:00
|
|
|
static void
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_update_index (GstFlvMux * mux, GstBuffer * buffer,
|
|
|
|
GstFlvMuxPad * pad)
|
2010-03-14 18:32:20 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Add the tag byte offset and to the index if it's a valid seek point, which
|
|
|
|
* means it's either a video keyframe or if there is no video pad (in that
|
|
|
|
* case every FLV tag is a valid seek point)
|
|
|
|
*/
|
2017-12-20 20:23:26 +00:00
|
|
|
if (mux->video_pad == pad &&
|
|
|
|
GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT))
|
2010-03-14 18:32:20 +00:00
|
|
|
return;
|
2008-10-27 09:33:40 +00:00
|
|
|
|
2014-06-07 03:17:52 +00:00
|
|
|
if (GST_BUFFER_PTS_IS_VALID (buffer)) {
|
2010-03-14 18:32:20 +00:00
|
|
|
GstFlvMuxIndexEntry *entry = g_slice_new (GstFlvMuxIndexEntry);
|
2017-12-20 20:23:26 +00:00
|
|
|
GstClockTime pts =
|
|
|
|
gst_flv_mux_segment_to_running_time (&GST_AGGREGATOR_PAD
|
|
|
|
(pad)->segment, GST_BUFFER_PTS (buffer));
|
2010-03-14 18:32:20 +00:00
|
|
|
entry->position = mux->byte_count;
|
2017-12-20 20:23:26 +00:00
|
|
|
entry->time = gst_guint64_to_gdouble (pts) / GST_SECOND;
|
2010-03-14 18:32:20 +00:00
|
|
|
mux->index = g_list_prepend (mux->index, entry);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
2010-03-14 18:32:20 +00:00
|
|
|
}
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2010-03-14 18:32:20 +00:00
|
|
|
static GstFlowReturn
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_write_buffer (GstFlvMux * mux, GstFlvMuxPad * pad,
|
|
|
|
GstBuffer * buffer)
|
2010-03-14 18:32:20 +00:00
|
|
|
{
|
|
|
|
GstBuffer *tag;
|
|
|
|
GstFlowReturn ret;
|
2017-12-20 20:23:26 +00:00
|
|
|
GstClockTime dts =
|
|
|
|
gst_flv_mux_segment_to_running_time (&GST_AGGREGATOR_PAD (pad)->segment,
|
|
|
|
GST_BUFFER_DTS (buffer));
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
2011-12-16 18:15:03 +00:00
|
|
|
/* clipping function arranged for running_time */
|
2011-03-22 18:36:31 +00:00
|
|
|
|
2010-06-09 12:13:09 +00:00
|
|
|
if (!mux->streamable)
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_update_index (mux, buffer, pad);
|
2010-03-14 00:25:42 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
tag = gst_flv_mux_buffer_to_tag (mux, buffer, pad);
|
2010-03-14 18:32:20 +00:00
|
|
|
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
2009-05-14 08:29:49 +00:00
|
|
|
ret = gst_flv_mux_push (mux, tag);
|
2008-10-27 09:33:40 +00:00
|
|
|
|
2014-08-28 00:56:12 +00:00
|
|
|
if (ret == GST_FLOW_OK && GST_CLOCK_TIME_IS_VALID (dts))
|
2017-12-20 20:23:26 +00:00
|
|
|
pad->last_timestamp = dts;
|
2014-08-28 00:56:12 +00:00
|
|
|
|
2008-10-27 09:33:40 +00:00
|
|
|
|
|
|
|
return ret;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
2010-03-16 00:29:36 +00:00
|
|
|
static guint64
|
|
|
|
gst_flv_mux_determine_duration (GstFlvMux * mux)
|
|
|
|
{
|
2017-12-20 20:23:26 +00:00
|
|
|
GList *l;
|
2010-03-16 00:29:36 +00:00
|
|
|
GstClockTime duration = GST_CLOCK_TIME_NONE;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mux, "trying to determine the duration "
|
|
|
|
"from pad timestamps");
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
for (l = GST_ELEMENT_CAST (mux)->sinkpads; l != NULL; l = l->next) {
|
|
|
|
GstFlvMuxPad *pad = GST_FLV_MUX_PAD (l->data);
|
2010-03-16 00:29:36 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (pad && (pad->last_timestamp != GST_CLOCK_TIME_NONE)) {
|
2010-03-16 00:29:36 +00:00
|
|
|
if (duration == GST_CLOCK_TIME_NONE)
|
2017-12-20 20:23:26 +00:00
|
|
|
duration = pad->last_timestamp;
|
2010-03-16 00:29:36 +00:00
|
|
|
else
|
2017-12-20 20:23:26 +00:00
|
|
|
duration = MAX (duration, pad->last_timestamp);
|
2010-03-16 00:29:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return duration;
|
|
|
|
}
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
static gboolean
|
|
|
|
gst_flv_mux_are_all_pads_eos (GstFlvMux * mux)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = GST_ELEMENT_CAST (mux)->sinkpads; l; l = l->next) {
|
|
|
|
GstFlvMuxPad *pad = GST_FLV_MUX_PAD (l->data);
|
|
|
|
|
|
|
|
if (!gst_aggregator_pad_is_eos (GST_AGGREGATOR_PAD (pad)))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-06-22 18:35:52 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_flv_mux_write_eos (GstFlvMux * mux)
|
|
|
|
{
|
|
|
|
GstBuffer *tag;
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
if (mux->video_pad == NULL)
|
2015-06-22 18:35:52 +00:00
|
|
|
return GST_FLOW_OK;
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
tag = gst_flv_mux_eos_to_tag (mux, mux->video_pad);
|
2015-06-22 18:35:52 +00:00
|
|
|
|
|
|
|
return gst_flv_mux_push (mux, tag);
|
|
|
|
}
|
|
|
|
|
2009-05-14 08:29:49 +00:00
|
|
|
static GstFlowReturn
|
2010-03-16 00:29:36 +00:00
|
|
|
gst_flv_mux_rewrite_header (GstFlvMux * mux)
|
2009-05-14 08:29:49 +00:00
|
|
|
{
|
2010-03-18 00:51:19 +00:00
|
|
|
GstBuffer *rewrite, *index, *tmp;
|
2010-03-14 00:38:21 +00:00
|
|
|
GstEvent *event;
|
2009-05-14 08:29:49 +00:00
|
|
|
guint8 *data;
|
2010-03-16 00:29:36 +00:00
|
|
|
gdouble d;
|
2009-05-14 08:29:49 +00:00
|
|
|
GList *l;
|
2010-03-14 00:38:21 +00:00
|
|
|
guint32 index_len, allocate_size;
|
2009-05-14 08:29:49 +00:00
|
|
|
guint32 i, index_skip;
|
2011-07-04 09:09:19 +00:00
|
|
|
GstSegment segment;
|
2011-12-16 18:15:38 +00:00
|
|
|
GstClockTime dur;
|
2009-05-14 08:29:49 +00:00
|
|
|
|
2010-06-09 12:13:09 +00:00
|
|
|
if (mux->streamable)
|
2010-03-14 00:38:21 +00:00
|
|
|
return GST_FLOW_OK;
|
2009-05-14 08:29:49 +00:00
|
|
|
|
2010-03-14 00:38:21 +00:00
|
|
|
/* seek back to the preallocated index space */
|
2011-07-04 09:09:19 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
|
|
|
segment.start = segment.time = 13 + 29;
|
|
|
|
event = gst_event_new_segment (&segment);
|
2010-03-14 00:38:21 +00:00
|
|
|
if (!gst_pad_push_event (mux->srcpad, event)) {
|
2010-03-16 00:29:36 +00:00
|
|
|
GST_WARNING_OBJECT (mux, "Seek to rewrite header failed");
|
2010-03-14 00:38:21 +00:00
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2009-05-14 08:29:49 +00:00
|
|
|
|
2011-12-16 18:15:38 +00:00
|
|
|
/* determine duration now based on our own timestamping,
|
|
|
|
* so that it is likely many times better and consistent
|
|
|
|
* than whatever obtained by some query */
|
|
|
|
dur = gst_flv_mux_determine_duration (mux);
|
|
|
|
if (dur != GST_CLOCK_TIME_NONE)
|
|
|
|
mux->duration = dur;
|
2010-03-16 00:29:36 +00:00
|
|
|
|
|
|
|
/* rewrite the duration tag */
|
|
|
|
d = gst_guint64_to_gdouble (mux->duration);
|
|
|
|
d /= (gdouble) GST_SECOND;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mux, "determined the final duration to be %f", d);
|
|
|
|
|
2010-03-18 00:51:19 +00:00
|
|
|
rewrite = gst_flv_mux_create_number_script_value ("duration", d);
|
|
|
|
|
|
|
|
/* rewrite the filesize tag */
|
|
|
|
d = gst_guint64_to_gdouble (mux->byte_count);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mux, "putting total filesize %f in the metadata", d);
|
|
|
|
|
|
|
|
tmp = gst_flv_mux_create_number_script_value ("filesize", d);
|
2012-03-28 10:49:19 +00:00
|
|
|
rewrite = gst_buffer_append (rewrite, tmp);
|
2010-03-18 00:51:19 +00:00
|
|
|
|
|
|
|
if (!mux->index) {
|
|
|
|
/* no index, so push buffer and return */
|
|
|
|
return gst_flv_mux_push (mux, rewrite);
|
|
|
|
}
|
2010-03-16 00:29:36 +00:00
|
|
|
|
|
|
|
/* rewrite the index */
|
2009-05-14 08:29:49 +00:00
|
|
|
mux->index = g_list_reverse (mux->index);
|
|
|
|
index_len = g_list_length (mux->index);
|
|
|
|
|
2010-03-14 00:38:21 +00:00
|
|
|
/* We write at most MAX_INDEX_ENTRIES elements */
|
|
|
|
if (index_len > MAX_INDEX_ENTRIES) {
|
|
|
|
index_skip = 1 + index_len / MAX_INDEX_ENTRIES;
|
|
|
|
index_len = (index_len + index_skip - 1) / index_skip;
|
|
|
|
} else {
|
|
|
|
index_skip = 1;
|
|
|
|
}
|
2009-05-14 08:29:49 +00:00
|
|
|
|
2010-03-14 00:38:21 +00:00
|
|
|
GST_DEBUG_OBJECT (mux, "Index length is %d", index_len);
|
|
|
|
/* see size calculation in gst_flv_mux_preallocate_index */
|
|
|
|
allocate_size = 11 + 8 + 22 + 10 + index_len * 18;
|
|
|
|
GST_DEBUG_OBJECT (mux, "Allocating %d bytes for index", allocate_size);
|
2011-07-04 09:09:19 +00:00
|
|
|
_gst_buffer_new_and_alloc (allocate_size, &index, &data);
|
2010-03-14 00:38:21 +00:00
|
|
|
|
|
|
|
GST_WRITE_UINT16_BE (data, 9); /* the 'keyframes' key */
|
|
|
|
memcpy (data + 2, "keyframes", 9);
|
|
|
|
GST_WRITE_UINT8 (data + 11, 8); /* nested ECMA array */
|
|
|
|
GST_WRITE_UINT32_BE (data + 12, 2); /* two elements */
|
|
|
|
GST_WRITE_UINT16_BE (data + 16, 5); /* first string key: 'times' */
|
|
|
|
memcpy (data + 18, "times", 5);
|
|
|
|
GST_WRITE_UINT8 (data + 23, 10); /* strict array */
|
|
|
|
GST_WRITE_UINT32_BE (data + 24, index_len);
|
|
|
|
data += 28;
|
|
|
|
|
|
|
|
/* the keyframes' times */
|
2009-05-14 08:29:49 +00:00
|
|
|
for (i = 0, l = mux->index; l; l = l->next, i++) {
|
|
|
|
GstFlvMuxIndexEntry *entry = l->data;
|
|
|
|
|
|
|
|
if (i % index_skip != 0)
|
|
|
|
continue;
|
2010-03-14 00:38:21 +00:00
|
|
|
GST_WRITE_UINT8 (data, 0); /* numeric (aka double) */
|
|
|
|
GST_WRITE_DOUBLE_BE (data + 1, entry->time);
|
2009-05-14 08:29:49 +00:00
|
|
|
data += 9;
|
|
|
|
}
|
|
|
|
|
2010-03-14 00:38:21 +00:00
|
|
|
GST_WRITE_UINT16_BE (data, 13); /* second string key: 'filepositions' */
|
|
|
|
memcpy (data + 2, "filepositions", 13);
|
|
|
|
GST_WRITE_UINT8 (data + 15, 10); /* strict array */
|
|
|
|
GST_WRITE_UINT32_BE (data + 16, index_len);
|
2009-05-14 08:29:49 +00:00
|
|
|
data += 20;
|
|
|
|
|
2010-03-14 00:38:21 +00:00
|
|
|
/* the keyframes' file positions */
|
2009-05-14 08:29:49 +00:00
|
|
|
for (i = 0, l = mux->index; l; l = l->next, i++) {
|
|
|
|
GstFlvMuxIndexEntry *entry = l->data;
|
|
|
|
|
|
|
|
if (i % index_skip != 0)
|
|
|
|
continue;
|
2010-03-14 00:38:21 +00:00
|
|
|
GST_WRITE_UINT8 (data, 0);
|
|
|
|
GST_WRITE_DOUBLE_BE (data + 1, entry->position);
|
2009-05-14 08:29:49 +00:00
|
|
|
data += 9;
|
|
|
|
}
|
|
|
|
|
2009-11-09 11:17:34 +00:00
|
|
|
GST_WRITE_UINT24_BE (data, 9); /* finish the ECMA array */
|
|
|
|
|
2010-03-14 00:38:21 +00:00
|
|
|
/* If there is space left in the prefilled area, reinsert the filler.
|
|
|
|
There is at least 18 bytes free, so it will always fit. */
|
|
|
|
if (index_len < MAX_INDEX_ENTRIES) {
|
|
|
|
GstBuffer *tmp;
|
|
|
|
guint8 *data;
|
|
|
|
guint32 remaining_filler_size;
|
2009-05-14 08:29:49 +00:00
|
|
|
|
2011-07-04 09:09:19 +00:00
|
|
|
_gst_buffer_new_and_alloc (14, &tmp, &data);
|
2010-03-14 00:38:21 +00:00
|
|
|
GST_WRITE_UINT16_BE (data, 9);
|
|
|
|
memcpy (data + 2, "gstfiller", 9);
|
|
|
|
GST_WRITE_UINT8 (data + 11, 2); /* string */
|
|
|
|
|
|
|
|
/* There is 18 bytes per remaining index entry minus what is used for
|
|
|
|
* the'gstfiller' key. The rest is already filled with spaces, so just need
|
|
|
|
* to update length. */
|
|
|
|
remaining_filler_size = (MAX_INDEX_ENTRIES - index_len) * 18 - 14;
|
|
|
|
GST_DEBUG_OBJECT (mux, "Remaining filler size is %d bytes",
|
|
|
|
remaining_filler_size);
|
|
|
|
GST_WRITE_UINT16_BE (data + 12, remaining_filler_size);
|
2012-03-28 10:49:19 +00:00
|
|
|
index = gst_buffer_append (index, tmp);
|
2010-03-14 00:38:21 +00:00
|
|
|
}
|
2009-05-14 08:29:49 +00:00
|
|
|
|
2012-03-28 10:49:19 +00:00
|
|
|
rewrite = gst_buffer_append (rewrite, index);
|
2010-03-16 00:29:36 +00:00
|
|
|
|
2010-03-18 00:51:19 +00:00
|
|
|
return gst_flv_mux_push (mux, rewrite);
|
2009-05-14 08:29:49 +00:00
|
|
|
}
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
static GstFlvMuxPad *
|
|
|
|
gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts)
|
|
|
|
{
|
|
|
|
GstAggregatorPad *apad;
|
|
|
|
GstFlvMuxPad *pad, *best = NULL;
|
|
|
|
GList *l;
|
|
|
|
GstBuffer *buffer;
|
|
|
|
GstClockTime best_ts = GST_CLOCK_TIME_NONE;
|
|
|
|
|
|
|
|
for (l = GST_ELEMENT_CAST (aggregator)->sinkpads; l; l = l->next) {
|
|
|
|
apad = GST_AGGREGATOR_PAD (l->data);
|
|
|
|
pad = GST_FLV_MUX_PAD (l->data);
|
2018-01-23 09:46:32 +00:00
|
|
|
buffer = gst_aggregator_pad_peek_buffer (GST_AGGREGATOR_PAD (pad));
|
2017-12-20 20:23:26 +00:00
|
|
|
if (!buffer)
|
|
|
|
continue;
|
|
|
|
if (best_ts == GST_CLOCK_TIME_NONE) {
|
|
|
|
best = pad;
|
|
|
|
best_ts = gst_flv_mux_segment_to_running_time (&apad->segment,
|
|
|
|
GST_BUFFER_DTS_OR_PTS (buffer));
|
|
|
|
} else if (GST_BUFFER_DTS_OR_PTS (buffer) != GST_CLOCK_TIME_NONE) {
|
|
|
|
gint64 t = gst_flv_mux_segment_to_running_time (&apad->segment,
|
|
|
|
GST_BUFFER_DTS_OR_PTS (buffer));
|
|
|
|
if (t < best_ts) {
|
|
|
|
best = pad;
|
|
|
|
best_ts = t;
|
|
|
|
}
|
|
|
|
}
|
2018-04-13 21:01:20 +00:00
|
|
|
gst_buffer_unref (buffer);
|
2017-12-20 20:23:26 +00:00
|
|
|
}
|
|
|
|
GST_DEBUG_OBJECT (aggregator,
|
|
|
|
"Best pad found with %" GST_TIME_FORMAT ": %" GST_PTR_FORMAT,
|
|
|
|
GST_TIME_ARGS (best_ts), best);
|
|
|
|
if (ts)
|
|
|
|
*ts = best_ts;
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
static GstFlowReturn
|
2017-12-20 20:23:26 +00:00
|
|
|
gst_flv_mux_aggregate (GstAggregator * aggregator, gboolean timeout)
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
{
|
2017-12-20 20:23:26 +00:00
|
|
|
GstFlvMux *mux = GST_FLV_MUX (aggregator);
|
|
|
|
GstFlvMuxPad *best;
|
2015-06-12 21:44:51 +00:00
|
|
|
gint64 best_time = GST_CLOCK_STIME_NONE;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
GstFlowReturn ret;
|
2017-12-20 20:23:26 +00:00
|
|
|
GstClockTime ts;
|
|
|
|
GstBuffer *buffer = NULL;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
|
|
|
|
if (mux->state == GST_FLV_MUX_STATE_HEADER) {
|
2017-12-20 20:23:26 +00:00
|
|
|
if (GST_ELEMENT_CAST (mux)->sinkpads == NULL) {
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
GST_ELEMENT_ERROR (mux, STREAM, MUX, (NULL),
|
|
|
|
("No input streams configured"));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
|
2013-05-13 13:06:03 +00:00
|
|
|
ret = gst_flv_mux_write_header (mux);
|
2017-12-20 20:23:26 +00:00
|
|
|
if (ret != GST_FLOW_OK)
|
2016-02-19 15:02:04 +00:00
|
|
|
return ret;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
mux->state = GST_FLV_MUX_STATE_DATA;
|
2014-08-28 01:07:26 +00:00
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
best = gst_flv_mux_find_best_pad (aggregator, &ts);
|
|
|
|
if (best && GST_CLOCK_STIME_IS_VALID (ts))
|
|
|
|
mux->first_timestamp = ts;
|
2014-08-28 01:07:26 +00:00
|
|
|
else
|
|
|
|
mux->first_timestamp = 0;
|
2017-12-20 20:23:26 +00:00
|
|
|
} else {
|
|
|
|
best = gst_flv_mux_find_best_pad (aggregator, &ts);
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
2010-09-20 17:43:45 +00:00
|
|
|
if (mux->new_tags) {
|
2011-12-19 12:56:30 +00:00
|
|
|
GstBuffer *buf = gst_flv_mux_create_metadata (mux, FALSE);
|
|
|
|
if (buf)
|
|
|
|
gst_flv_mux_push (mux, buf);
|
2010-09-20 17:43:45 +00:00
|
|
|
mux->new_tags = FALSE;
|
|
|
|
}
|
|
|
|
|
2011-12-16 18:15:03 +00:00
|
|
|
if (best) {
|
2018-01-23 09:46:32 +00:00
|
|
|
buffer = gst_aggregator_pad_pop_buffer (GST_AGGREGATOR_PAD (best));
|
2011-12-16 18:15:03 +00:00
|
|
|
g_assert (buffer);
|
2017-12-20 20:23:26 +00:00
|
|
|
best->dts =
|
|
|
|
gst_flv_mux_segment_to_running_time (&GST_AGGREGATOR_PAD
|
|
|
|
(best)->segment, GST_BUFFER_DTS_OR_PTS (buffer));
|
2015-06-10 22:15:52 +00:00
|
|
|
|
|
|
|
if (GST_CLOCK_STIME_IS_VALID (best->dts))
|
|
|
|
best_time = best->dts - mux->first_timestamp;
|
|
|
|
|
|
|
|
if (GST_BUFFER_PTS_IS_VALID (buffer))
|
2017-12-20 20:23:26 +00:00
|
|
|
best->pts =
|
|
|
|
gst_flv_mux_segment_to_running_time (&GST_AGGREGATOR_PAD
|
|
|
|
(best)->segment, GST_BUFFER_PTS (buffer));
|
2015-06-10 22:15:52 +00:00
|
|
|
else
|
|
|
|
best->pts = best->dts;
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
GST_LOG_OBJECT (best, "got buffer PTS %" GST_TIME_FORMAT " DTS %"
|
|
|
|
GST_STIME_FORMAT, GST_TIME_ARGS (best->pts),
|
2015-06-10 22:15:52 +00:00
|
|
|
GST_STIME_ARGS (best->dts));
|
2011-12-16 18:15:03 +00:00
|
|
|
} else {
|
2015-06-10 22:15:52 +00:00
|
|
|
best_time = GST_CLOCK_STIME_NONE;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
2010-03-16 22:32:45 +00:00
|
|
|
/* The FLV timestamp is an int32 field. For non-live streams error out if a
|
|
|
|
bigger timestamp is seen, for live the timestamp will get wrapped in
|
|
|
|
gst_flv_mux_buffer_to_tag */
|
2015-06-10 22:15:52 +00:00
|
|
|
if (!mux->streamable && (GST_CLOCK_STIME_IS_VALID (best_time))
|
2010-03-16 22:32:45 +00:00
|
|
|
&& best_time / GST_MSECOND > G_MAXINT32) {
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
GST_WARNING_OBJECT (mux, "Timestamp larger than FLV supports - EOS");
|
2017-12-20 20:23:26 +00:00
|
|
|
if (buffer) {
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
buffer = NULL;
|
|
|
|
}
|
2011-12-16 18:15:03 +00:00
|
|
|
best = NULL;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
2011-12-16 18:15:03 +00:00
|
|
|
if (best) {
|
|
|
|
return gst_flv_mux_write_buffer (mux, best, buffer);
|
|
|
|
} else {
|
2017-12-20 20:23:26 +00:00
|
|
|
if (gst_flv_mux_are_all_pads_eos (mux)) {
|
|
|
|
gst_flv_mux_write_eos (mux);
|
|
|
|
gst_flv_mux_rewrite_header (mux);
|
2018-04-13 20:44:14 +00:00
|
|
|
return GST_FLOW_EOS;
|
2017-12-20 20:23:26 +00:00
|
|
|
}
|
|
|
|
return GST_FLOW_OK;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-14 00:34:02 +00:00
|
|
|
static void
|
|
|
|
gst_flv_mux_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2010-03-15 12:47:13 +00:00
|
|
|
GstFlvMux *mux = GST_FLV_MUX (object);
|
2010-03-14 00:34:02 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2010-06-09 12:13:09 +00:00
|
|
|
case PROP_STREAMABLE:
|
|
|
|
g_value_set_boolean (value, mux->streamable);
|
2010-03-14 00:34:02 +00:00
|
|
|
break;
|
2016-11-09 06:25:27 +00:00
|
|
|
case PROP_METADATACREATOR:
|
|
|
|
g_value_set_string (value, mux->metadatacreator);
|
|
|
|
break;
|
2010-03-14 00:34:02 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_flv_mux_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2010-03-15 12:47:13 +00:00
|
|
|
GstFlvMux *mux = GST_FLV_MUX (object);
|
2010-03-14 00:34:02 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2010-06-09 12:13:09 +00:00
|
|
|
case PROP_STREAMABLE:
|
|
|
|
mux->streamable = g_value_get_boolean (value);
|
2010-09-20 17:43:45 +00:00
|
|
|
if (mux->streamable)
|
|
|
|
gst_tag_setter_set_tag_merge_mode (GST_TAG_SETTER (mux),
|
|
|
|
GST_TAG_MERGE_REPLACE);
|
|
|
|
else
|
|
|
|
gst_tag_setter_set_tag_merge_mode (GST_TAG_SETTER (mux),
|
|
|
|
GST_TAG_MERGE_KEEP);
|
2010-03-14 00:34:02 +00:00
|
|
|
break;
|
2016-11-09 06:25:27 +00:00
|
|
|
case PROP_METADATACREATOR:
|
|
|
|
g_free (mux->metadatacreator);
|
|
|
|
if (!g_value_get_string (value)) {
|
|
|
|
GST_WARNING_OBJECT (mux, "metadatacreator property can not be NULL");
|
|
|
|
mux->metadatacreator = g_strdup (DEFAULT_METADATACREATOR);
|
|
|
|
} else {
|
|
|
|
mux->metadatacreator = g_value_dup_string (value);
|
|
|
|
}
|
|
|
|
break;
|
2010-03-14 00:34:02 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-20 20:23:26 +00:00
|
|
|
static GstClockTime
|
|
|
|
gst_flv_mux_get_next_time (GstAggregator * aggregator)
|
|
|
|
{
|
2018-04-19 21:53:51 +00:00
|
|
|
GstFlvMux *mux = GST_FLV_MUX (aggregator);
|
2018-04-23 15:26:12 +00:00
|
|
|
GstAggregatorPad *agg_audio_pad = GST_AGGREGATOR_PAD_CAST (mux->audio_pad);
|
|
|
|
GstAggregatorPad *agg_video_pad = GST_AGGREGATOR_PAD_CAST (mux->video_pad);
|
2018-04-19 21:53:51 +00:00
|
|
|
|
|
|
|
GST_OBJECT_LOCK (aggregator);
|
|
|
|
if (mux->state == GST_FLV_MUX_STATE_HEADER &&
|
|
|
|
((mux->audio_pad && mux->audio_pad->codec == G_MAXUINT) ||
|
|
|
|
(mux->video_pad && mux->video_pad->codec == G_MAXUINT)))
|
|
|
|
goto wait_for_data;
|
2018-04-23 15:26:12 +00:00
|
|
|
|
|
|
|
if (!((agg_audio_pad && gst_aggregator_pad_has_buffer (agg_audio_pad)) ||
|
|
|
|
(agg_video_pad && gst_aggregator_pad_has_buffer (agg_video_pad))))
|
|
|
|
goto wait_for_data;
|
2018-04-19 21:53:51 +00:00
|
|
|
GST_OBJECT_UNLOCK (aggregator);
|
|
|
|
|
2018-04-23 17:29:30 +00:00
|
|
|
return gst_aggregator_simple_get_next_time (aggregator);
|
2018-04-19 21:53:51 +00:00
|
|
|
|
|
|
|
wait_for_data:
|
|
|
|
GST_OBJECT_UNLOCK (aggregator);
|
|
|
|
return GST_CLOCK_TIME_NONE;
|
[MOVED FROM BAD 22/57] gst/flv/: Add first version of a FLV muxer. The only missing feature is writing of stream metadata.
Original commit message from CVS:
* gst/flv/Makefile.am:
* gst/flv/gstflvdemux.c: (plugin_init):
* gst/flv/gstflvmux.c: (gst_flv_mux_base_init),
(gst_flv_mux_class_init), (gst_flv_mux_init),
(gst_flv_mux_finalize), (gst_flv_mux_reset),
(gst_flv_mux_handle_src_event), (gst_flv_mux_handle_sink_event),
(gst_flv_mux_video_pad_setcaps), (gst_flv_mux_audio_pad_setcaps),
(gst_flv_mux_request_new_pad), (gst_flv_mux_release_pad),
(gst_flv_mux_write_header), (gst_flv_mux_write_buffer),
(gst_flv_mux_collected), (gst_flv_mux_change_state):
* gst/flv/gstflvmux.h:
Add first version of a FLV muxer. The only missing feature is writing
of stream metadata.
2008-10-09 09:26:58 +00:00
|
|
|
}
|
2018-09-06 04:13:19 +00:00
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_flv_mux_update_src_caps (GstAggregator * aggregator,
|
|
|
|
GstCaps * caps, GstCaps ** ret)
|
|
|
|
{
|
|
|
|
GstFlvMux *mux = GST_FLV_MUX (aggregator);
|
|
|
|
|
|
|
|
*ret = gst_flv_mux_prepare_src_caps (mux, NULL, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|