mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
rtmp2: Clean up (improve) GstRtmpStopCommands type
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1256>
This commit is contained in:
parent
9a2828c216
commit
30274dee52
4 changed files with 44 additions and 43 deletions
|
@ -38,6 +38,7 @@ plugin_init (GstPlugin * plugin)
|
|||
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_RTMP_SCHEME, 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_RTMP_AUTHMOD, 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_RTMP_STOP_COMMANDS, 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ typedef struct
|
|||
gboolean async_connect;
|
||||
guint peak_kbps;
|
||||
guint32 chunk_size;
|
||||
GstRtmpStopCommands stop_commands;
|
||||
GstStructure *stats;
|
||||
|
||||
/* If both self->lock and OBJECT_LOCK are needed,
|
||||
|
@ -88,8 +89,6 @@ typedef struct
|
|||
|
||||
GPtrArray *headers;
|
||||
guint64 last_ts, base_ts; /* timestamp fixup */
|
||||
|
||||
GstRtmpStopCommands stop_commands;
|
||||
} GstRtmp2Sink;
|
||||
|
||||
typedef struct
|
||||
|
@ -153,32 +152,6 @@ enum
|
|||
PROP_STOP_COMMANDS,
|
||||
};
|
||||
|
||||
#define DEFAULT_STOP_COMMANDS GST_RTMP_STOP_COMMAND_FCUNPUBLISH | \
|
||||
GST_RTMP_STOP_COMMAND_DELETE_STREAM /* FCUnpublish + deleteStream */
|
||||
|
||||
#define GST_RTMP_STOP_COMMANDS_TYPE \
|
||||
(gst_rtmp2_sink_stop_commands_get_type())
|
||||
|
||||
static GType
|
||||
gst_rtmp2_sink_stop_commands_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
static const GFlagsValue types[] = {
|
||||
{GST_RTMP_STOP_COMMAND_NONE, "No command", "none"},
|
||||
{GST_RTMP_STOP_COMMAND_FCUNPUBLISH, "FCUnpublish", "fcunpublish"},
|
||||
{GST_RTMP_STOP_COMMAND_CLOSE_STREAM, "closeStream", "closestream"},
|
||||
{GST_RTMP_STOP_COMMAND_DELETE_STREAM, "deleteStream", "deletestream"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&type)) {
|
||||
GType tmp = g_flags_register_static ("GstRtmp2SinkStopCommandsFlags",
|
||||
types);
|
||||
g_once_init_leave (&type, tmp);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/* pad templates */
|
||||
|
||||
static GstStaticPadTemplate gst_rtmp2_sink_sink_template =
|
||||
|
@ -261,7 +234,7 @@ gst_rtmp2_sink_class_init (GstRtmp2SinkClass * klass)
|
|||
g_object_class_install_property (gobject_class, PROP_STOP_COMMANDS,
|
||||
g_param_spec_flags ("stop-commands", "Stop commands",
|
||||
"RTMP commands to send on EOS event before closing connection",
|
||||
GST_RTMP_STOP_COMMANDS_TYPE, DEFAULT_STOP_COMMANDS,
|
||||
GST_TYPE_RTMP_STOP_COMMANDS, GST_RTMP_DEFAULT_STOP_COMMANDS,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_RTMP_LOCATION_HANDLER, 0);
|
||||
|
@ -276,6 +249,7 @@ gst_rtmp2_sink_init (GstRtmp2Sink * self)
|
|||
self->location.publish = TRUE;
|
||||
self->async_connect = TRUE;
|
||||
self->chunk_size = GST_RTMP_DEFAULT_CHUNK_SIZE;
|
||||
self->stop_commands = GST_RTMP_DEFAULT_STOP_COMMANDS;
|
||||
|
||||
g_mutex_init (&self->lock);
|
||||
g_cond_init (&self->cond);
|
||||
|
@ -286,8 +260,6 @@ gst_rtmp2_sink_init (GstRtmp2Sink * self)
|
|||
|
||||
self->headers = g_ptr_array_new_with_free_func
|
||||
((GDestroyNotify) gst_mini_object_unref);
|
||||
|
||||
self->stop_commands = DEFAULT_STOP_COMMANDS;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -612,7 +584,7 @@ stop_publish_invoker (gpointer user_data)
|
|||
|
||||
if (self->connection) {
|
||||
GST_OBJECT_LOCK (self);
|
||||
if (self->stop_commands != GST_RTMP_STOP_COMMAND_NONE) {
|
||||
if (self->stop_commands != GST_RTMP_STOP_COMMANDS_NONE) {
|
||||
gst_rtmp_client_stop_publish (self->connection, self->location.stream,
|
||||
self->stop_commands);
|
||||
}
|
||||
|
|
|
@ -166,6 +166,26 @@ gst_rtmp_authmod_get_nick (GstRtmpAuthmod value)
|
|||
return ev ? ev->value_nick : "(unknown)";
|
||||
}
|
||||
|
||||
GType
|
||||
gst_rtmp_stop_commands_get_type (void)
|
||||
{
|
||||
static volatile gsize stop_commands_type = 0;
|
||||
static const GFlagsValue stop_commands[] = {
|
||||
{GST_RTMP_STOP_COMMANDS_NONE, "No command", "none"},
|
||||
{GST_RTMP_STOP_COMMANDS_FCUNPUBLISH, "FCUnpublish", "fcunpublish"},
|
||||
{GST_RTMP_STOP_COMMANDS_CLOSE_STREAM, "closeStream", "closestream"},
|
||||
{GST_RTMP_STOP_COMMANDS_DELETE_STREAM, "deleteStream", "deletestream"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&stop_commands_type)) {
|
||||
GType tmp = g_flags_register_static ("GstRtmpStopCommands", stop_commands);
|
||||
g_once_init_leave (&stop_commands_type, tmp);
|
||||
}
|
||||
|
||||
return (GType) stop_commands_type;
|
||||
}
|
||||
|
||||
void
|
||||
gst_rtmp_location_copy (GstRtmpLocation * dest, const GstRtmpLocation * src)
|
||||
{
|
||||
|
@ -1365,17 +1385,17 @@ send_stop (GstRtmpConnection * connection, const gchar * stream,
|
|||
command_object = gst_amf_node_new_null ();
|
||||
stream_name = gst_amf_node_new_string (stream, -1);
|
||||
|
||||
if (stop_commands & GST_RTMP_STOP_COMMAND_FCUNPUBLISH) {
|
||||
if (stop_commands & GST_RTMP_STOP_COMMANDS_FCUNPUBLISH) {
|
||||
GST_DEBUG ("Sending stop command 'FCUnpublish' for stream '%s'", stream);
|
||||
gst_rtmp_connection_send_command (connection, NULL, NULL, 0,
|
||||
"FCUnpublish", command_object, stream_name, NULL);
|
||||
}
|
||||
if (stop_commands & GST_RTMP_STOP_COMMAND_CLOSE_STREAM) {
|
||||
if (stop_commands & GST_RTMP_STOP_COMMANDS_CLOSE_STREAM) {
|
||||
GST_DEBUG ("Sending stop command 'closeStream' for stream '%s'", stream);
|
||||
gst_rtmp_connection_send_command (connection, NULL, NULL, 0,
|
||||
"closeStream", command_object, stream_name, NULL);
|
||||
}
|
||||
if (stop_commands & GST_RTMP_STOP_COMMAND_DELETE_STREAM) {
|
||||
if (stop_commands & GST_RTMP_STOP_COMMANDS_DELETE_STREAM) {
|
||||
GST_DEBUG ("Sending stop command 'deleteStream' for stream '%s'", stream);
|
||||
gst_rtmp_connection_send_command (connection, NULL, NULL, 0,
|
||||
"deleteStream", command_object, stream_name, NULL);
|
||||
|
|
|
@ -56,6 +56,22 @@ GType gst_rtmp_authmod_get_type (void);
|
|||
|
||||
|
||||
|
||||
#define GST_TYPE_RTMP_STOP_COMMANDS (gst_rtmp_stop_commands_get_type ())
|
||||
#define GST_RTMP_DEFAULT_STOP_COMMANDS (GST_RTMP_STOP_COMMANDS_FCUNPUBLISH | \
|
||||
GST_RTMP_STOP_COMMANDS_DELETE_STREAM) /* FCUnpublish + deleteStream */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_RTMP_STOP_COMMANDS_NONE = 0,
|
||||
GST_RTMP_STOP_COMMANDS_FCUNPUBLISH = (1 << 0),
|
||||
GST_RTMP_STOP_COMMANDS_CLOSE_STREAM = (1 << 1),
|
||||
GST_RTMP_STOP_COMMANDS_DELETE_STREAM = (1 << 2)
|
||||
} GstRtmpStopCommands;
|
||||
|
||||
GType gst_rtmp_stop_commands_get_type (void);
|
||||
|
||||
|
||||
|
||||
typedef struct _GstRtmpLocation
|
||||
{
|
||||
GstRtmpScheme scheme;
|
||||
|
@ -73,14 +89,6 @@ typedef struct _GstRtmpLocation
|
|||
gboolean publish;
|
||||
} GstRtmpLocation;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_RTMP_STOP_COMMAND_NONE = 0,
|
||||
GST_RTMP_STOP_COMMAND_FCUNPUBLISH = (1 << 0),
|
||||
GST_RTMP_STOP_COMMAND_CLOSE_STREAM = (1 << 1),
|
||||
GST_RTMP_STOP_COMMAND_DELETE_STREAM = (1 << 2)
|
||||
} GstRtmpStopCommands;
|
||||
|
||||
void gst_rtmp_location_copy (GstRtmpLocation * dest,
|
||||
const GstRtmpLocation * src);
|
||||
void gst_rtmp_location_clear (GstRtmpLocation * uri);
|
||||
|
|
Loading…
Reference in a new issue