mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
mpegtsmux: extract an actual base class
This commit is contained in:
parent
4e7f94f5fa
commit
649cc2d5e8
18 changed files with 2369 additions and 2121 deletions
|
@ -24,11 +24,21 @@
|
|||
GST_DEBUG_CATEGORY (atscmux_debug);
|
||||
#define GST_CAT_DEFAULT atscmux_debug
|
||||
|
||||
G_DEFINE_TYPE (ATSCMux, atscmux, GST_TYPE_MPEG_TSMUX)
|
||||
G_DEFINE_TYPE (ATSCMux, atscmux, GST_TYPE_BASE_TSMUX);
|
||||
|
||||
#define parent_class atscmux_parent_class
|
||||
#define ATSCMUX_ST_PS_AUDIO_EAC3 0x87
|
||||
static GstStaticPadTemplate atscmux_sink_factory =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink_%d",
|
||||
|
||||
static GstStaticPadTemplate atscmux_src_factory =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/mpegts, "
|
||||
"systemstream = (boolean) true, " "packetsize = (int) 192 ")
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate atscmux_sink_factory =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink_%d",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_REQUEST,
|
||||
GST_STATIC_CAPS ("video/mpeg, "
|
||||
|
@ -40,9 +50,9 @@ G_DEFINE_TYPE (ATSCMux, atscmux, GST_TYPE_MPEG_TSMUX)
|
|||
"audio/x-ac3, framed = (boolean) TRUE;"
|
||||
"audio/x-eac3, framed = (boolean) TRUE;"));
|
||||
|
||||
static void
|
||||
atscmux_stream_get_es_descrs (TsMuxStream * stream,
|
||||
GstMpegtsPMTStream * pmt_stream, MpegTsMux * mpegtsmux)
|
||||
static void
|
||||
atscmux_stream_get_es_descrs (TsMuxStream * stream,
|
||||
GstMpegtsPMTStream * pmt_stream, BaseTsMux * mpegtsmux)
|
||||
{
|
||||
GstMpegtsDescriptor *descriptor;
|
||||
|
||||
|
@ -111,7 +121,7 @@ G_DEFINE_TYPE (ATSCMux, atscmux, GST_TYPE_MPEG_TSMUX)
|
|||
|
||||
static TsMuxStream *
|
||||
atscmux_create_new_stream (guint16 new_pid,
|
||||
TsMuxStreamType stream_type, MpegTsMux * mpegtsmux)
|
||||
TsMuxStreamType stream_type, BaseTsMux * mpegtsmux)
|
||||
{
|
||||
TsMuxStream *ret = tsmux_stream_new (new_pid, stream_type);
|
||||
|
||||
|
@ -129,9 +139,9 @@ atscmux_create_new_stream (guint16 new_pid,
|
|||
}
|
||||
|
||||
static TsMux *
|
||||
atscmux_create_ts_mux (MpegTsMux * mpegtsmux)
|
||||
atscmux_create_ts_mux (BaseTsMux * mpegtsmux)
|
||||
{
|
||||
TsMux *ret = ((MpegTsMuxClass *) parent_class)->create_ts_mux (mpegtsmux);
|
||||
TsMux *ret = ((BaseTsMuxClass *) parent_class)->create_ts_mux (mpegtsmux);
|
||||
|
||||
tsmux_set_new_stream_func (ret,
|
||||
(TsMuxNewStreamFunc) atscmux_create_new_stream, mpegtsmux);
|
||||
|
@ -140,8 +150,8 @@ atscmux_create_ts_mux (MpegTsMux * mpegtsmux)
|
|||
}
|
||||
|
||||
static guint
|
||||
atscmux_handle_media_type (MpegTsMux * mux, const gchar * media_type,
|
||||
MpegTsPadData * ts_data)
|
||||
atscmux_handle_media_type (BaseTsMux * mux, const gchar * media_type,
|
||||
BaseTsPadData * ts_data)
|
||||
{
|
||||
guint ret = TSMUX_ST_RESERVED;
|
||||
|
||||
|
@ -156,7 +166,7 @@ static void
|
|||
atscmux_class_init (ATSCMuxClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
||||
MpegTsMuxClass *mpegtsmux_class = (MpegTsMuxClass *) klass;
|
||||
BaseTsMuxClass *mpegtsmux_class = (BaseTsMuxClass *) klass;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (atscmux_debug, "atscmux", 0, "ATSC muxer");
|
||||
|
||||
|
@ -170,6 +180,9 @@ atscmux_class_init (ATSCMuxClass * klass)
|
|||
|
||||
gst_element_class_add_static_pad_template (gstelement_class,
|
||||
&atscmux_sink_factory);
|
||||
|
||||
gst_element_class_add_static_pad_template (gstelement_class,
|
||||
&atscmux_src_factory);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef __ATSCMUX_H__
|
||||
#define __ATSCMUX_H__
|
||||
|
||||
#include "mpegtsmux.h"
|
||||
#include "basetsmux.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -32,11 +32,11 @@ typedef struct ATSCMux ATSCMux;
|
|||
typedef struct ATSCMuxClass ATSCMuxClass;
|
||||
|
||||
struct ATSCMux {
|
||||
MpegTsMux parent;
|
||||
BaseTsMux parent;
|
||||
};
|
||||
|
||||
struct ATSCMuxClass {
|
||||
MpegTsMuxClass parent_class;
|
||||
BaseTsMuxClass parent_class;
|
||||
};
|
||||
|
||||
GType atscmux_get_type (void);
|
||||
|
|
2054
gst/mpegtsmux/basetsmux.c
Normal file
2054
gst/mpegtsmux/basetsmux.c
Normal file
File diff suppressed because it is too large
Load diff
227
gst/mpegtsmux/basetsmux.h
Normal file
227
gst/mpegtsmux/basetsmux.h
Normal file
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* Copyright 2006, 2007, 2008, 2009, 2010 Fluendo S.A.
|
||||
* Authors: Jan Schmidt <jan@fluendo.com>
|
||||
* Kapil Agrawal <kapil@fluendo.com>
|
||||
* Julien Moutte <julien@fluendo.com>
|
||||
*
|
||||
* This library is licensed under 4 different licenses and you
|
||||
* can choose to use it under the terms of any one of them. The
|
||||
* four licenses are the MPL 1.1, the LGPL, the GPL and the MIT
|
||||
* license.
|
||||
*
|
||||
* MPL:
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* LGPL:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* GPL:
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* MIT:
|
||||
*
|
||||
* Unless otherwise indicated, Source Code is licensed under MIT license.
|
||||
* See further explanation attached in License Statement (distributed in the file
|
||||
* LICENSE).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __BASETSMUX_H__
|
||||
#define __BASETSMUX_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstcollectpads.h>
|
||||
#include <gst/base/gstadapter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#include <tsmux/tsmux.h>
|
||||
|
||||
#define GST_TYPE_BASE_TSMUX (basetsmux_get_type())
|
||||
#define GST_BASE_TSMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_BASE_TSMUX, BaseTsMux))
|
||||
#define GST_BASE_TSMUX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_BASE_TSMUX,BaseTsMuxClass))
|
||||
|
||||
#define CLOCK_BASE 9LL
|
||||
#define CLOCK_FREQ (CLOCK_BASE * 10000) /* 90 kHz PTS clock */
|
||||
#define CLOCK_FREQ_SCR (CLOCK_FREQ * 300) /* 27 MHz SCR clock */
|
||||
|
||||
#define GSTTIME_TO_MPEGTIME(time) \
|
||||
(((time) > 0 ? (gint64) 1 : (gint64) -1) * \
|
||||
(gint64) gst_util_uint64_scale (ABS(time), CLOCK_BASE, GST_MSECOND/10))
|
||||
|
||||
/* 27 MHz SCR conversions: */
|
||||
#define MPEG_SYS_TIME_TO_GSTTIME(time) (gst_util_uint64_scale ((time), \
|
||||
GST_USECOND, CLOCK_FREQ_SCR / 1000000))
|
||||
#define GSTTIME_TO_MPEG_SYS_TIME(time) (gst_util_uint64_scale ((time), \
|
||||
CLOCK_FREQ_SCR / 1000000, GST_USECOND))
|
||||
|
||||
#define NORMAL_TS_PACKET_LENGTH 188
|
||||
#define M2TS_PACKET_LENGTH 192
|
||||
|
||||
#define DEFAULT_PROG_ID 0
|
||||
|
||||
typedef struct BaseTsMux BaseTsMux;
|
||||
typedef struct BaseTsMuxClass BaseTsMuxClass;
|
||||
typedef struct BaseTsPadData BaseTsPadData;
|
||||
|
||||
typedef GstBuffer * (*BaseTsPadDataPrepareFunction) (GstBuffer * buf,
|
||||
BaseTsPadData * data, BaseTsMux * mux);
|
||||
|
||||
typedef void (*BaseTsPadDataFreePrepareDataFunction) (gpointer prepare_data);
|
||||
|
||||
struct BaseTsMux {
|
||||
GstElement parent;
|
||||
|
||||
GstPad *srcpad;
|
||||
|
||||
GstCollectPads *collect;
|
||||
|
||||
TsMux *tsmux;
|
||||
GHashTable *programs;
|
||||
|
||||
/* properties */
|
||||
gboolean m2ts_mode;
|
||||
GstStructure *prog_map;
|
||||
guint pat_interval;
|
||||
guint pmt_interval;
|
||||
gint alignment;
|
||||
guint si_interval;
|
||||
guint64 bitrate;
|
||||
|
||||
/* state */
|
||||
gboolean first;
|
||||
GstClockTime pending_key_unit_ts;
|
||||
GstEvent *force_key_unit_event;
|
||||
|
||||
/* write callback handling/state */
|
||||
GstFlowReturn last_flow_ret;
|
||||
GQueue streamheader;
|
||||
gboolean streamheader_sent;
|
||||
gboolean is_delta;
|
||||
gboolean is_header;
|
||||
GstClockTime last_ts;
|
||||
|
||||
/* m2ts specific */
|
||||
gint64 previous_pcr;
|
||||
gint64 previous_offset;
|
||||
gint64 pcr_rate_num;
|
||||
gint64 pcr_rate_den;
|
||||
GstAdapter *adapter;
|
||||
|
||||
/* output buffer aggregation */
|
||||
GstAdapter *out_adapter;
|
||||
GstBuffer *out_buffer;
|
||||
|
||||
#if 0
|
||||
/* SPN/PTS index handling */
|
||||
GstIndex *element_index;
|
||||
gint spn_count;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* BaseTsMuxClass:
|
||||
* @create_ts_mux: Optional.
|
||||
* Called in order to create the #TsMux object.
|
||||
*/
|
||||
struct BaseTsMuxClass {
|
||||
GstElementClass parent_class;
|
||||
|
||||
TsMux * (*create_ts_mux) (BaseTsMux *mux);
|
||||
guint (*handle_media_type) (BaseTsMux *mux, const gchar *media_type, BaseTsPadData * ts_data);
|
||||
};
|
||||
|
||||
struct BaseTsPadData {
|
||||
/* parent */
|
||||
GstCollectData collect;
|
||||
|
||||
gint pid;
|
||||
TsMuxStream *stream;
|
||||
|
||||
/* most recent DTS */
|
||||
gint64 dts;
|
||||
|
||||
#if 0
|
||||
/* (optional) index writing */
|
||||
gint element_index_writer_id;
|
||||
#endif
|
||||
|
||||
/* optional codec data available in the caps */
|
||||
GstBuffer *codec_data;
|
||||
|
||||
/* Opaque data pointer to a structure used by the prepare function */
|
||||
gpointer prepare_data;
|
||||
|
||||
/* handler to prepare input data */
|
||||
BaseTsPadDataPrepareFunction prepare_func;
|
||||
/* handler to free the private data */
|
||||
BaseTsPadDataFreePrepareDataFunction free_func;
|
||||
|
||||
/* program id to which it is attached to (not program pid) */
|
||||
gint prog_id;
|
||||
/* program this stream belongs to */
|
||||
TsMuxProgram *prog;
|
||||
|
||||
gchar *language;
|
||||
};
|
||||
|
||||
GType basetsmux_get_type (void);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
|
@ -84,13 +84,13 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mpegtsmux_aac.h"
|
||||
#include "basetsmux_aac.h"
|
||||
#include <string.h>
|
||||
|
||||
#define GST_CAT_DEFAULT mpegtsmux_debug
|
||||
#define GST_CAT_DEFAULT basetsmux_debug
|
||||
|
||||
GstBuffer *
|
||||
mpegtsmux_prepare_aac (GstBuffer * buf, MpegTsPadData * data, MpegTsMux * mux)
|
||||
basetsmux_prepare_aac (GstBuffer * buf, BaseTsPadData * data, BaseTsMux * mux)
|
||||
{
|
||||
guint8 adts_header[7] = { 0, };
|
||||
gsize out_size = gst_buffer_get_size (buf) + 7;
|
|
@ -80,12 +80,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef __MPEGTSMUX_AAC_H__
|
||||
#define __MPEGTSMUX_AAC_H__
|
||||
#ifndef __BASETSMUX_AAC_H__
|
||||
#define __BASETSMUX_AAC_H__
|
||||
|
||||
#include "mpegtsmux.h"
|
||||
#include "basetsmux.h"
|
||||
|
||||
GstBuffer * mpegtsmux_prepare_aac (GstBuffer * buf, MpegTsPadData * data,
|
||||
MpegTsMux * mux);
|
||||
GstBuffer * basetsmux_prepare_aac (GstBuffer * buf, BaseTsPadData * data,
|
||||
BaseTsMux * mux);
|
||||
|
||||
#endif /* __MPEGTSMUX_AAC_H__ */
|
||||
#endif /* __BASETSMUX_AAC_H__ */
|
|
@ -27,17 +27,17 @@
|
|||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "mpegtsmux_jpeg2000.h"
|
||||
#include "basetsmux_jpeg2000.h"
|
||||
#include <string.h>
|
||||
#include <gst/audio/audio.h>
|
||||
#include <gst/base/gstbytewriter.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
#define GST_CAT_DEFAULT mpegtsmux_debug
|
||||
#define GST_CAT_DEFAULT basetsmux_debug
|
||||
|
||||
GstBuffer *
|
||||
mpegtsmux_prepare_jpeg2000 (GstBuffer * buf, MpegTsPadData * data,
|
||||
MpegTsMux * mux)
|
||||
basetsmux_prepare_jpeg2000 (GstBuffer * buf, BaseTsPadData * data,
|
||||
BaseTsMux * mux)
|
||||
{
|
||||
j2k_private_data *private_data = data->prepare_data;
|
||||
GstByteWriter wr;
|
||||
|
@ -127,7 +127,7 @@ mpegtsmux_prepare_jpeg2000 (GstBuffer * buf, MpegTsPadData * data,
|
|||
}
|
||||
|
||||
void
|
||||
mpegtsmux_free_jpeg2000 (gpointer prepare_data)
|
||||
basetsmux_free_jpeg2000 (gpointer prepare_data)
|
||||
{
|
||||
/* Free prepare data memory object */
|
||||
g_free (prepare_data);
|
|
@ -22,10 +22,10 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __MPEGTSMUX_JPEG2000_H__
|
||||
#define __MPEGTSMUX_JPEG2000_H__
|
||||
#ifndef __BASETSMUX_JPEG2000_H__
|
||||
#define __BASETSMUX_JPEG2000_H__
|
||||
|
||||
#include "mpegtsmux.h"
|
||||
#include "basetsmux.h"
|
||||
|
||||
/* color specifications for JPEG 2000 stream over MPEG TS */
|
||||
typedef enum
|
||||
|
@ -38,7 +38,7 @@ typedef enum
|
|||
GST_MPEGTS_JPEG2000_COLORSPEC_CIEXYZ,
|
||||
GST_MPEGTS_JPEG2000_COLORSPEC_REC2020,
|
||||
GST_MPEGTS_JPEG2000_COLORSPEC_SMPTE2084
|
||||
} GstMpegTsJpeg2000ColorSpec;
|
||||
} GstBaseTsJpeg2000ColorSpec;
|
||||
|
||||
|
||||
typedef struct j2k_private_data
|
||||
|
@ -55,9 +55,9 @@ typedef struct j2k_private_data
|
|||
guint8 color_spec;
|
||||
} j2k_private_data;
|
||||
|
||||
GstBuffer *mpegtsmux_prepare_jpeg2000 (GstBuffer * buf, MpegTsPadData * data,
|
||||
MpegTsMux * mux);
|
||||
GstBuffer *basetsmux_prepare_jpeg2000 (GstBuffer * buf, BaseTsPadData * data,
|
||||
BaseTsMux * mux);
|
||||
|
||||
void mpegtsmux_free_jpeg2000 (gpointer prepare_data);
|
||||
void basetsmux_free_jpeg2000 (gpointer prepare_data);
|
||||
|
||||
#endif /* __MPEGTSMUX_JPEG2000_H__ */
|
||||
#endif /* __BASETSMUX_JPEG2000_H__ */
|
|
@ -84,15 +84,15 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mpegtsmux_opus.h"
|
||||
#include "basetsmux_opus.h"
|
||||
#include <string.h>
|
||||
#include <gst/audio/audio.h>
|
||||
|
||||
#define GST_CAT_DEFAULT mpegtsmux_debug
|
||||
#define GST_CAT_DEFAULT basetsmux_debug
|
||||
|
||||
GstBuffer *
|
||||
mpegtsmux_prepare_opus (GstBuffer * buf, MpegTsPadData * pad_data,
|
||||
MpegTsMux * mux)
|
||||
basetsmux_prepare_opus (GstBuffer * buf, BaseTsPadData * pad_data,
|
||||
BaseTsMux * mux)
|
||||
{
|
||||
gssize insize = gst_buffer_get_size (buf);
|
||||
gsize outsize;
|
|
@ -80,12 +80,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef __MPEGTSMUX_OPUS_H__
|
||||
#define __MPEGTSMUX_OPUS_H__
|
||||
#ifndef __BASETSMUX_OPUS_H__
|
||||
#define __BASETSMUX_OPUS_H__
|
||||
|
||||
#include "mpegtsmux.h"
|
||||
#include "basetsmux.h"
|
||||
|
||||
GstBuffer * mpegtsmux_prepare_opus (GstBuffer * buf, MpegTsPadData * data,
|
||||
MpegTsMux * mux);
|
||||
GstBuffer * basetsmux_prepare_opus (GstBuffer * buf, BaseTsPadData * data,
|
||||
BaseTsMux * mux);
|
||||
|
||||
#endif /* __MPEGTSMUX_OPUS_H__ */
|
||||
#endif /* __BASETSMUX_OPUS_H__ */
|
|
@ -84,10 +84,10 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mpegtsmux_ttxt.h"
|
||||
#include "basetsmux_ttxt.h"
|
||||
#include <string.h>
|
||||
|
||||
#define GST_CAT_DEFAULT mpegtsmux_debug
|
||||
#define GST_CAT_DEFAULT basetsmux_debug
|
||||
|
||||
/* from EN 300 472 spec: ITU-R System B Teletext in DVB
|
||||
*
|
||||
|
@ -98,8 +98,8 @@
|
|||
*/
|
||||
|
||||
GstBuffer *
|
||||
mpegtsmux_prepare_teletext (GstBuffer * buf, MpegTsPadData * pad_data,
|
||||
MpegTsMux * mux)
|
||||
basetsmux_prepare_teletext (GstBuffer * buf, BaseTsPadData * pad_data,
|
||||
BaseTsMux * mux)
|
||||
{
|
||||
GstBuffer *out_buf;
|
||||
guint8 *data, *odata;
|
|
@ -80,12 +80,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef __MPEGTSMUX_TTXT_H__
|
||||
#define __MPEGTSMUX_TTXT_H__
|
||||
#ifndef __BASETSMUX_TTXT_H__
|
||||
#define __BASETSMUX_TTXT_H__
|
||||
|
||||
#include "mpegtsmux.h"
|
||||
#include "basetsmux.h"
|
||||
|
||||
GstBuffer * mpegtsmux_prepare_teletext (GstBuffer * buf, MpegTsPadData * data,
|
||||
MpegTsMux * mux);
|
||||
GstBuffer * basetsmux_prepare_teletext (GstBuffer * buf, BaseTsPadData * data,
|
||||
BaseTsMux * mux);
|
||||
|
||||
#endif /* __MPEGTSMUX_TTXT_H__ */
|
||||
#endif /* __BASETSMUX_TTXT_H__ */
|
|
@ -1,11 +1,12 @@
|
|||
tsmux_sources = [
|
||||
'mpegtsmuxplugin.c',
|
||||
'basetsmux.c',
|
||||
'mpegtsmux.c',
|
||||
'atscmux.c',
|
||||
'mpegtsmux_aac.c',
|
||||
'mpegtsmux_opus.c',
|
||||
'mpegtsmux_ttxt.c',
|
||||
'mpegtsmux_jpeg2000.c',
|
||||
'basetsmux_aac.c',
|
||||
'basetsmux_opus.c',
|
||||
'basetsmux_ttxt.c',
|
||||
'basetsmux_jpeg2000.c',
|
||||
'tsmux/tsmux.c',
|
||||
'tsmux/tsmuxstream.c'
|
||||
]
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -90,138 +90,26 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#include <tsmux/tsmux.h>
|
||||
#include "basetsmux.h"
|
||||
|
||||
#define GST_TYPE_MPEG_TSMUX (mpegtsmux_get_type())
|
||||
#define GST_MPEG_TSMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_MPEG_TSMUX, MpegTsMux))
|
||||
#define GST_MPEG_TSMUX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_MPEG_TSMUX,MpegTsMuxClass))
|
||||
|
||||
#define CLOCK_BASE 9LL
|
||||
#define CLOCK_FREQ (CLOCK_BASE * 10000) /* 90 kHz PTS clock */
|
||||
#define CLOCK_FREQ_SCR (CLOCK_FREQ * 300) /* 27 MHz SCR clock */
|
||||
|
||||
#define GSTTIME_TO_MPEGTIME(time) \
|
||||
(((time) > 0 ? (gint64) 1 : (gint64) -1) * \
|
||||
(gint64) gst_util_uint64_scale (ABS(time), CLOCK_BASE, GST_MSECOND/10))
|
||||
|
||||
/* 27 MHz SCR conversions: */
|
||||
#define MPEG_SYS_TIME_TO_GSTTIME(time) (gst_util_uint64_scale ((time), \
|
||||
GST_USECOND, CLOCK_FREQ_SCR / 1000000))
|
||||
#define GSTTIME_TO_MPEG_SYS_TIME(time) (gst_util_uint64_scale ((time), \
|
||||
CLOCK_FREQ_SCR / 1000000, GST_USECOND))
|
||||
|
||||
#define NORMAL_TS_PACKET_LENGTH 188
|
||||
#define M2TS_PACKET_LENGTH 192
|
||||
|
||||
#define DEFAULT_PROG_ID 0
|
||||
|
||||
typedef struct MpegTsMux MpegTsMux;
|
||||
typedef struct MpegTsMuxClass MpegTsMuxClass;
|
||||
typedef struct MpegTsPadData MpegTsPadData;
|
||||
|
||||
typedef GstBuffer * (*MpegTsPadDataPrepareFunction) (GstBuffer * buf,
|
||||
MpegTsPadData * data, MpegTsMux * mux);
|
||||
|
||||
typedef void (*MpegTsPadDataFreePrepareDataFunction) (gpointer prepare_data);
|
||||
|
||||
struct MpegTsMux {
|
||||
GstElement parent;
|
||||
|
||||
GstPad *srcpad;
|
||||
|
||||
GstCollectPads *collect;
|
||||
|
||||
TsMux *tsmux;
|
||||
GHashTable *programs;
|
||||
|
||||
/* properties */
|
||||
gboolean m2ts_mode;
|
||||
GstStructure *prog_map;
|
||||
guint pat_interval;
|
||||
guint pmt_interval;
|
||||
gint alignment;
|
||||
guint si_interval;
|
||||
guint64 bitrate;
|
||||
|
||||
/* state */
|
||||
gboolean first;
|
||||
GstClockTime pending_key_unit_ts;
|
||||
GstEvent *force_key_unit_event;
|
||||
|
||||
/* write callback handling/state */
|
||||
GstFlowReturn last_flow_ret;
|
||||
GQueue streamheader;
|
||||
gboolean streamheader_sent;
|
||||
gboolean is_delta;
|
||||
gboolean is_header;
|
||||
GstClockTime last_ts;
|
||||
|
||||
/* m2ts specific */
|
||||
gint64 previous_pcr;
|
||||
gint64 previous_offset;
|
||||
gint64 pcr_rate_num;
|
||||
gint64 pcr_rate_den;
|
||||
GstAdapter *adapter;
|
||||
|
||||
/* output buffer aggregation */
|
||||
GstAdapter *out_adapter;
|
||||
GstBuffer *out_buffer;
|
||||
|
||||
#if 0
|
||||
/* SPN/PTS index handling */
|
||||
GstIndex *element_index;
|
||||
gint spn_count;
|
||||
#endif
|
||||
BaseTsMux parent;
|
||||
};
|
||||
|
||||
/**
|
||||
* MpegTsMuxClass:
|
||||
* @create_ts_mux: Optional.
|
||||
* Called in order to create the #TsMux object.
|
||||
*/
|
||||
struct MpegTsMuxClass {
|
||||
GstElementClass parent_class;
|
||||
|
||||
TsMux * (*create_ts_mux) (MpegTsMux *mux);
|
||||
guint (*handle_media_type) (MpegTsMux *mux, const gchar *media_type, MpegTsPadData * ts_data);
|
||||
};
|
||||
|
||||
struct MpegTsPadData {
|
||||
/* parent */
|
||||
GstCollectData collect;
|
||||
|
||||
gint pid;
|
||||
TsMuxStream *stream;
|
||||
|
||||
/* most recent DTS */
|
||||
gint64 dts;
|
||||
|
||||
#if 0
|
||||
/* (optional) index writing */
|
||||
gint element_index_writer_id;
|
||||
#endif
|
||||
|
||||
/* optional codec data available in the caps */
|
||||
GstBuffer *codec_data;
|
||||
|
||||
/* Opaque data pointer to a structure used by the prepare function */
|
||||
gpointer prepare_data;
|
||||
|
||||
/* handler to prepare input data */
|
||||
MpegTsPadDataPrepareFunction prepare_func;
|
||||
/* handler to free the private data */
|
||||
MpegTsPadDataFreePrepareDataFunction free_func;
|
||||
|
||||
/* program id to which it is attached to (not program pid) */
|
||||
gint prog_id;
|
||||
/* program this stream belongs to */
|
||||
TsMuxProgram *prog;
|
||||
|
||||
gchar *language;
|
||||
BaseTsMuxClass parent_class;
|
||||
};
|
||||
|
||||
GType mpegtsmux_get_type (void);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
#include "tsmux.h"
|
||||
#include "tsmuxstream.h"
|
||||
|
||||
#define GST_CAT_DEFAULT mpegtsmux_debug
|
||||
#define GST_CAT_DEFAULT basetsmux_debug
|
||||
|
||||
/* Maximum total data length for a PAT section is 1024 bytes, minus an
|
||||
* 8 byte header, then the length of each program entry is 32 bits,
|
||||
|
|
|
@ -182,7 +182,7 @@ tsmux_put_ts (guint8 **pos, guint8 id, gint64 ts)
|
|||
tsmux_put16 (pos, ((ts << 1) & 0xfffe) | 0x01);
|
||||
}
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (mpegtsmux_debug);
|
||||
GST_DEBUG_CATEGORY_EXTERN (basetsmux_debug);
|
||||
#define TS_DEBUG GST_DEBUG
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
#include "tsmuxcommon.h"
|
||||
#include "tsmuxstream.h"
|
||||
|
||||
#define GST_CAT_DEFAULT mpegtsmux_debug
|
||||
#define GST_CAT_DEFAULT basetsmux_debug
|
||||
|
||||
static guint8 tsmux_stream_pes_header_length (TsMuxStream * stream);
|
||||
static void tsmux_stream_write_pes_header (TsMuxStream * stream, guint8 * data);
|
||||
|
|
Loading…
Reference in a new issue