gstreamer/gst-libs/gst/transcoder/gsttranscoder.h
Thibault Saunier 8c2fd4fff7 transcoder: Rework the API to create/get SignalAdapter
We can only have 1 single GstTranscoderSignalAdapter object for a
given GstTranscoder object, this enforces that by avoiding to expose
a constructor and instead add a method to GstTranscoder to get the
signal adapter (internally creating it when needed). We can still
cleanly ensure that the signal adapter is running for the requested
GMainContext and return NULL if it is not the case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2044>
2021-03-01 12:37:44 +00:00

151 lines
5 KiB
C

#ifndef __GST_TRANSCODER_H
#define __GST_TRANSCODER_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gst/gst.h>
#include <gst/pbutils/pbutils.h>
#include "transcoder-prelude.h"
#include "transcoder-enumtypes.h"
G_BEGIN_DECLS
/*********** Error definitions ************/
#define GST_TRANSCODER_ERROR (gst_transcoder_error_quark ())
/**
* GstTranscoderError:
* @GST_TRANSCODER_ERROR_FAILED: generic error.
*/
typedef enum {
GST_TRANSCODER_ERROR_FAILED = 0
} GstTranscoderError;
GST_TRANSCODER_API
GQuark gst_transcoder_error_quark (void);
GST_TRANSCODER_API
const gchar * gst_transcoder_error_get_name (GstTranscoderError error);
/*********** Messages types definitions ************/
/**
* GstTranscoderMessage:
* @GST_TRANSCODER_MESSAGE_POSITION_UPDATED: Sink position changed
* @GST_TRANSCODER_MESSAGE_DURATION_CHANGED: Duration of stream changed
* @GST_TRANSCODER_MESSAGE_DONE: Transcoding is done
* @GST_TRANSCODER_MESSAGE_ERROR: Message contains an error
* @GST_TRANSCODER_MESSAGE_WARNING: Message contains an error
*
* Types of messages that will be posted on the transcoder API bus.
*
* See also #gst_transcoder_get_message_bus()
*
* Since: 1.20
*/
typedef enum
{
GST_TRANSCODER_MESSAGE_POSITION_UPDATED,
GST_TRANSCODER_MESSAGE_DURATION_CHANGED,
GST_TRANSCODER_MESSAGE_DONE,
GST_TRANSCODER_MESSAGE_ERROR,
GST_TRANSCODER_MESSAGE_WARNING,
} GstTranscoderMessage;
GST_TRANSCODER_API
gboolean gst_transcoder_is_transcoder_message (GstMessage * msg);
GST_TRANSCODER_API
const gchar * gst_transcoder_message_get_name (GstTranscoderMessage message);
GST_TRANSCODER_API
void gst_transcoder_message_parse_position (GstMessage * msg, GstClockTime * position);
GST_TRANSCODER_API
void gst_transcoder_message_parse_duration (GstMessage * msg, GstClockTime * duration);
GST_TRANSCODER_API
void gst_transcoder_message_parse_error (GstMessage * msg, GError * error, GstStructure ** details);
GST_TRANSCODER_API
void gst_transcoder_message_parse_warning (GstMessage * msg, GError * error, GstStructure ** details);
/*********** GstTranscoder definition ************/
#define GST_TYPE_TRANSCODER (gst_transcoder_get_type ())
/**
* GstTranscoderClass.parent_class:
*
* Since: 1.20
*/
GST_TRANSCODER_API
G_DECLARE_FINAL_TYPE (GstTranscoder, gst_transcoder, GST, TRANSCODER, GstObject)
GST_TRANSCODER_API
GstTranscoder * gst_transcoder_new (const gchar * source_uri,
const gchar * dest_uri,
const gchar * encoding_profile);
GST_TRANSCODER_API
GstTranscoder * gst_transcoder_new_full (const gchar * source_uri,
const gchar * dest_uri,
GstEncodingProfile * profile);
GST_TRANSCODER_API
gboolean gst_transcoder_run (GstTranscoder * self,
GError ** error);
GST_TRANSCODER_API
GstBus * gst_transcoder_get_message_bus (GstTranscoder * transcoder);
GST_TRANSCODER_API
void gst_transcoder_set_cpu_usage (GstTranscoder * self,
gint cpu_usage);
GST_TRANSCODER_API
void gst_transcoder_run_async (GstTranscoder * self);
GST_TRANSCODER_API
void gst_transcoder_set_position_update_interval (GstTranscoder * self,
guint interval);
GST_TRANSCODER_API
gchar * gst_transcoder_get_source_uri (GstTranscoder * self);
GST_TRANSCODER_API
gchar * gst_transcoder_get_dest_uri (GstTranscoder * self);
GST_TRANSCODER_API
guint gst_transcoder_get_position_update_interval (GstTranscoder * self);
GST_TRANSCODER_API
GstClockTime gst_transcoder_get_position (GstTranscoder * self);
GST_TRANSCODER_API
GstClockTime gst_transcoder_get_duration (GstTranscoder * self);
GST_TRANSCODER_API
GstElement * gst_transcoder_get_pipeline (GstTranscoder * self);
GST_TRANSCODER_API
gboolean gst_transcoder_get_avoid_reencoding (GstTranscoder * self);
GST_TRANSCODER_API
void gst_transcoder_set_avoid_reencoding (GstTranscoder * self,
gboolean avoid_reencoding);
#include "gsttranscoder-signal-adapter.h"
GST_TRANSCODER_API
GstTranscoderSignalAdapter*
gst_transcoder_get_signal_adapter (GstTranscoder * self,
GMainContext *context);
GST_TRANSCODER_API
GstTranscoderSignalAdapter*
gst_transcoder_get_sync_signal_adapter (GstTranscoder * self);
G_END_DECLS
#endif