1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
/* GStreamer split muxer bin
* Copyright (C) 2014 Jan Schmidt <jan@centricular.com>
*
* 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.
*/
#ifndef __GST_SPLITMUXSINK_H__
#define __GST_SPLITMUXSINK_H__
#include <gst/gst.h>
#include <gst/pbutils/pbutils.h>
G_BEGIN_DECLS
#define GST_TYPE_SPLITMUX_SINK (gst_splitmux_sink_get_type())
#define GST_SPLITMUX_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SPLITMUX_SINK,GstSplitMuxSink))
#define GST_SPLITMUX_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SPLITMUX_SINK,GstSplitMuxSinkClass))
#define GST_IS_SPLITMUX_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SPLITMUX_SINK))
#define GST_IS_SPLITMUX_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SPLITMUX_SINK))
typedef struct _GstSplitMuxSink GstSplitMuxSink;
typedef struct _GstSplitMuxSinkClass GstSplitMuxSinkClass;
GType gst_splitmux_sink_get_type(void);
gboolean register_splitmuxsink (GstPlugin * plugin);
typedef enum _SplitMuxState {
SPLITMUX_STATE_STOPPED,
SPLITMUX_STATE_COLLECTING_GOP_START,
SPLITMUX_STATE_WAITING_GOP_COMPLETE,
SPLITMUX_STATE_ENDING_FILE,
SPLITMUX_STATE_START_NEXT_FRAGMENT,
} SplitMuxState;
typedef struct _MqStreamBuf
{
gboolean keyframe;
GstClockTime run_ts;
gsize buf_size;
} MqStreamBuf;
typedef struct _MqStreamCtx
{
gint refcount;
GstSplitMuxSink *splitmux;
guint sink_pad_block_id;
guint src_pad_block_id;
gboolean is_reference;
gboolean flushing;
gboolean in_eos;
gboolean out_eos;
GstSegment in_segment;
GstSegment out_segment;
GstClockTime in_running_time;
GstClockTime out_running_time;
gsize in_bytes;
GQueue queued_bufs;
GstPad *sinkpad;
GstPad *srcpad;
gboolean out_blocked;
} MqStreamCtx;
struct _GstSplitMuxSink {
GstBin parent;
GMutex lock;
GCond data_cond;
SplitMuxState state;
gdouble mux_overhead;
GstClockTime threshold_time;
guint64 threshold_bytes;
guint max_files;
guint mq_max_buffers;
GstElement *mq;
GstElement *muxer;
GstElement *sink;
GstElement *provided_muxer;
GstElement *provided_sink;
GstElement *active_sink;
gchar *location;
guint fragment_id;
GList *contexts;
MqStreamCtx *reference_ctx;
guint queued_gops;
GstClockTime max_in_running_time;
GstClockTime max_out_running_time;
GstClockTime muxed_out_time;
gsize muxed_out_bytes;
gboolean have_muxed_something;
GstClockTime mux_start_time;
gsize mux_start_bytes;
gboolean opening_first_fragment;
};
struct _GstSplitMuxSinkClass {
GstBinClass parent_class;
};
G_END_DECLS
#endif /* __GST_SPLITMUXSINK_H__ */
|