From 6401bef067ca27019399b94569c490ea56817226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 13 Apr 2017 20:36:14 +0300 Subject: [PATCH] Add GstApp bindings --- Cargo.toml | 1 + Gir_GstApp.toml | 14 + gir-files/GstApp-1.0.gir | 1824 ++++++++++++++++++++++++++++++++++ gstreamer-app-sys/Cargo.toml | 48 + gstreamer-app-sys/LICENSE | 23 + gstreamer-app-sys/build.rs | 66 ++ gstreamer-app-sys/src/lib.rs | 153 +++ 7 files changed, 2129 insertions(+) create mode 100644 Gir_GstApp.toml create mode 100644 gir-files/GstApp-1.0.gir create mode 100644 gstreamer-app-sys/Cargo.toml create mode 100644 gstreamer-app-sys/LICENSE create mode 100644 gstreamer-app-sys/build.rs create mode 100644 gstreamer-app-sys/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 110be8b8a..5622edfcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,4 +7,5 @@ members = [ "gstreamer-audio-sys", "gstreamer-video-sys", "gstreamer-pbutils-sys", + "gstreamer-app-sys", ] diff --git a/Gir_GstApp.toml b/Gir_GstApp.toml new file mode 100644 index 000000000..db14a9f27 --- /dev/null +++ b/Gir_GstApp.toml @@ -0,0 +1,14 @@ +[options] +girs_dir = "gir-files" +library = "GstApp" +version = "1.0" +min_cfg_version = "1.0" +target_path = "gstreamer-app-sys" +work_mode = "sys" + +external_libraries = [ + "GLib", + "GObject", + "Gst", + "GstBase", +] diff --git a/gir-files/GstApp-1.0.gir b/gir-files/GstApp-1.0.gir new file mode 100644 index 000000000..433d83685 --- /dev/null +++ b/gir-files/GstApp-1.0.gir @@ -0,0 +1,1824 @@ + + + + + + + + + + Appsink is a sink plugin that supports many different methods for making +the application get a handle on the GStreamer data in a pipeline. Unlike +most GStreamer elements, Appsink provides external API functions. + +appsink can be used by linking to the gstappsink.h header file to access the +methods or by using the appsink action signals and properties. + +The normal way of retrieving samples from appsink is by using the +gst_app_sink_pull_sample() and gst_app_sink_pull_preroll() methods. +These methods block until a sample becomes available in the sink or when the +sink is shut down or reaches EOS. There are also timed variants of these +methods, gst_app_sink_try_pull_sample() and gst_app_sink_try_pull_preroll(), +which accept a timeout parameter to limit the amount of time to wait. + +Appsink will internally use a queue to collect buffers from the streaming +thread. If the application is not pulling samples fast enough, this queue +will consume a lot of memory over time. The "max-buffers" property can be +used to limit the queue size. The "drop" property controls whether the +streaming thread blocks or if older buffers are dropped when the maximum +queue size is reached. Note that blocking the streaming thread can negatively +affect real-time performance and should be avoided. + +If a blocking behaviour is not desirable, setting the "emit-signals" property +to %TRUE will make appsink emit the "new-sample" and "new-preroll" signals +when a sample can be pulled without blocking. + +The "caps" property on appsink can be used to control the formats that +appsink can receive. This property can contain non-fixed caps, the format of +the pulled samples can be obtained by getting the sample caps. + +If one of the pull-preroll or pull-sample methods return %NULL, the appsink +is stopped or in the EOS state. You can check for the EOS state with the +"eos" property or with the gst_app_sink_is_eos() method. + +The eos signal can also be used to be informed when the EOS state is reached +to avoid polling. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Get the last preroll sample in @appsink. This was the sample that caused the +appsink to preroll in the PAUSED state. This sample can be pulled many times +and remains available to the application even after EOS. + +This function is typically used when dealing with a pipeline in the PAUSED +state. Calling this function after doing a seek will give the sample right +after the seek position. + +Note that the preroll sample will also be returned as the first sample +when calling gst_app_sink_pull_sample(). + +If an EOS event was received before any buffers, this function returns +%NULL. Use gst_app_sink_is_eos () to check for the EOS condition. + +This function blocks until a preroll sample or EOS is received or the appsink +element is set to the READY/NULL state. + + a #GstSample or NULL when the appsink is stopped or EOS. + Call gst_sample_unref() after usage. + + + + + a #GstAppSink + + + + + + This function blocks until a sample or EOS becomes available or the appsink +element is set to the READY/NULL state. + +This function will only return samples when the appsink is in the PLAYING +state. All rendered buffers will be put in a queue so that the application +can pull samples at its own rate. Note that when the application does not +pull samples fast enough, the queued buffers could consume a lot of memory, +especially when dealing with raw video frames. + +If an EOS event was received before any buffers, this function returns +%NULL. Use gst_app_sink_is_eos () to check for the EOS condition. + + a #GstSample or NULL when the appsink is stopped or EOS. + Call gst_sample_unref() after usage. + + + + + a #GstAppSink + + + + + + Get the last preroll sample in @appsink. This was the sample that caused the +appsink to preroll in the PAUSED state. This sample can be pulled many times +and remains available to the application even after EOS. + +This function is typically used when dealing with a pipeline in the PAUSED +state. Calling this function after doing a seek will give the sample right +after the seek position. + +Note that the preroll sample will also be returned as the first sample +when calling gst_app_sink_pull_sample(). + +If an EOS event was received before any buffers or the timeout expires, +this function returns %NULL. Use gst_app_sink_is_eos () to check for the EOS +condition. + +This function blocks until a preroll sample or EOS is received, the appsink +element is set to the READY/NULL state, or the timeout expires. + + a #GstSample or NULL when the appsink is stopped or EOS or the timeout expires. + Call gst_sample_unref() after usage. + + + + + a #GstAppSink + + + + the maximum amount of time to wait for the preroll sample + + + + + + This function blocks until a sample or EOS becomes available or the appsink +element is set to the READY/NULL state or the timeout expires. + +This function will only return samples when the appsink is in the PLAYING +state. All rendered buffers will be put in a queue so that the application +can pull samples at its own rate. Note that when the application does not +pull samples fast enough, the queued buffers could consume a lot of memory, +especially when dealing with raw video frames. + +If an EOS event was received before any buffers or the timeout expires, +this function returns %NULL. Use gst_app_sink_is_eos () to check for the EOS +condition. + + a #GstSample or NULL when the appsink is stopped or EOS or the timeout expires. +Call gst_sample_unref() after usage. + + + + + a #GstAppSink + + + + the maximum amount of time to wait for a sample + + + + + + Check if @appsink supports buffer lists. + + %TRUE if @appsink supports buffer lists. + + + + + a #GstAppSink + + + + + + Get the configured caps on @appsink. + + the #GstCaps accepted by the sink. gst_caps_unref() after usage. + + + + + a #GstAppSink + + + + + + Check if @appsink will drop old buffers when the maximum amount of queued +buffers is reached. + + %TRUE if @appsink is dropping old buffers when the queue is +filled. + + + + + a #GstAppSink + + + + + + Check if appsink will emit the "new-preroll" and "new-sample" signals. + + %TRUE if @appsink is emiting the "new-preroll" and "new-sample" +signals. + + + + + a #GstAppSink + + + + + + Get the maximum amount of buffers that can be queued in @appsink. + + The maximum amount of buffers that can be queued. + + + + + a #GstAppSink + + + + + + Check if @appsink will wait for all buffers to be consumed when an EOS is +received. + + %TRUE if @appsink will wait for all buffers to be consumed when an +EOS is received. + + + + + a #GstAppSink + + + + + + Check if @appsink is EOS, which is when no more samples can be pulled because +an EOS event was received. + +This function also returns %TRUE when the appsink is not in the PAUSED or +PLAYING state. + + %TRUE if no more samples can be pulled and the appsink is EOS. + + + + + a #GstAppSink + + + + + + Get the last preroll sample in @appsink. This was the sample that caused the +appsink to preroll in the PAUSED state. This sample can be pulled many times +and remains available to the application even after EOS. + +This function is typically used when dealing with a pipeline in the PAUSED +state. Calling this function after doing a seek will give the sample right +after the seek position. + +Note that the preroll sample will also be returned as the first sample +when calling gst_app_sink_pull_sample(). + +If an EOS event was received before any buffers, this function returns +%NULL. Use gst_app_sink_is_eos () to check for the EOS condition. + +This function blocks until a preroll sample or EOS is received or the appsink +element is set to the READY/NULL state. + + a #GstSample or NULL when the appsink is stopped or EOS. + Call gst_sample_unref() after usage. + + + + + a #GstAppSink + + + + + + This function blocks until a sample or EOS becomes available or the appsink +element is set to the READY/NULL state. + +This function will only return samples when the appsink is in the PLAYING +state. All rendered buffers will be put in a queue so that the application +can pull samples at its own rate. Note that when the application does not +pull samples fast enough, the queued buffers could consume a lot of memory, +especially when dealing with raw video frames. + +If an EOS event was received before any buffers, this function returns +%NULL. Use gst_app_sink_is_eos () to check for the EOS condition. + + a #GstSample or NULL when the appsink is stopped or EOS. + Call gst_sample_unref() after usage. + + + + + a #GstAppSink + + + + + + Instruct @appsink to enable or disable buffer list support. + +For backwards-compatibility reasons applications need to opt in +to indicate that they will be able to handle buffer lists. + + + + + + a #GstAppSink + + + + enable or disable buffer list support + + + + + + Set callbacks which will be executed for each new preroll, new sample and eos. +This is an alternative to using the signals, it has lower overhead and is thus +less expensive, but also less flexible. + +If callbacks are installed, no signals will be emitted for performance +reasons. + + + + + + a #GstAppSink + + + + the callbacks + + + + a user_data argument for the callbacks + + + + a destroy notify function + + + + + + Set the capabilities on the appsink element. This function takes +a copy of the caps structure. After calling this method, the sink will only +accept caps that match @caps. If @caps is non-fixed, or incomplete, +you must check the caps on the samples to get the actual used caps. + + + + + + a #GstAppSink + + + + caps to set + + + + + + Instruct @appsink to drop old buffers when the maximum amount of queued +buffers is reached. + + + + + + a #GstAppSink + + + + the new state + + + + + + Make appsink emit the "new-preroll" and "new-sample" signals. This option is +by default disabled because signal emission is expensive and unneeded when +the application prefers to operate in pull mode. + + + + + + a #GstAppSink + + + + the new state + + + + + + Set the maximum amount of buffers that can be queued in @appsink. After this +amount of buffers are queued in appsink, any more buffers will block upstream +elements until a sample is pulled from @appsink. + + + + + + a #GstAppSink + + + + the maximum number of buffers to queue + + + + + + Instruct @appsink to wait for all buffers to be consumed when an EOS is received. + + + + + + a #GstAppSink + + + + the new state + + + + + + Get the last preroll sample in @appsink. This was the sample that caused the +appsink to preroll in the PAUSED state. This sample can be pulled many times +and remains available to the application even after EOS. + +This function is typically used when dealing with a pipeline in the PAUSED +state. Calling this function after doing a seek will give the sample right +after the seek position. + +Note that the preroll sample will also be returned as the first sample +when calling gst_app_sink_pull_sample(). + +If an EOS event was received before any buffers or the timeout expires, +this function returns %NULL. Use gst_app_sink_is_eos () to check for the EOS +condition. + +This function blocks until a preroll sample or EOS is received, the appsink +element is set to the READY/NULL state, or the timeout expires. + + a #GstSample or NULL when the appsink is stopped or EOS or the timeout expires. + Call gst_sample_unref() after usage. + + + + + a #GstAppSink + + + + the maximum amount of time to wait for the preroll sample + + + + + + This function blocks until a sample or EOS becomes available or the appsink +element is set to the READY/NULL state or the timeout expires. + +This function will only return samples when the appsink is in the PLAYING +state. All rendered buffers will be put in a queue so that the application +can pull samples at its own rate. Note that when the application does not +pull samples fast enough, the queued buffers could consume a lot of memory, +especially when dealing with raw video frames. + +If an EOS event was received before any buffers or the timeout expires, +this function returns %NULL. Use gst_app_sink_is_eos () to check for the EOS +condition. + + a #GstSample or NULL when the appsink is stopped or EOS or the timeout expires. +Call gst_sample_unref() after usage. + + + + + a #GstAppSink + + + + the maximum amount of time to wait for a sample + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Signal that the end-of-stream has been reached. This signal is emitted from +the streaming thread. + + + + + + Signal that a new preroll sample is available. + +This signal is emitted from the streaming thread and only when the +"emit-signals" property is %TRUE. + +The new preroll sample can be retrieved with the "pull-preroll" action +signal or gst_app_sink_pull_preroll() either from this signal callback +or from any other thread. + +Note that this signal is only emitted when the "emit-signals" property is +set to %TRUE, which it is not by default for performance reasons. + + + + + + Signal that a new sample is available. + +This signal is emitted from the streaming thread and only when the +"emit-signals" property is %TRUE. + +The new sample can be retrieved with the "pull-sample" action +signal or gst_app_sink_pull_sample() either from this signal callback +or from any other thread. + +Note that this signal is only emitted when the "emit-signals" property is +set to %TRUE, which it is not by default for performance reasons. + + + + + + Get the last preroll sample in @appsink. This was the sample that caused the +appsink to preroll in the PAUSED state. This sample can be pulled many times +and remains available to the application even after EOS. + +This function is typically used when dealing with a pipeline in the PAUSED +state. Calling this function after doing a seek will give the sample right +after the seek position. + +Note that the preroll sample will also be returned as the first sample +when calling gst_app_sink_pull_sample() or the "pull-sample" action signal. + +If an EOS event was received before any buffers, this function returns +%NULL. Use gst_app_sink_is_eos () to check for the EOS condition. + +This function blocks until a preroll sample or EOS is received or the appsink +element is set to the READY/NULL state. + + a #GstSample or NULL when the appsink is stopped or EOS. + + + + + This function blocks until a sample or EOS becomes available or the appsink +element is set to the READY/NULL state. + +This function will only return samples when the appsink is in the PLAYING +state. All rendered samples will be put in a queue so that the application +can pull samples at its own rate. + +Note that when the application does not pull samples fast enough, the +queued samples could consume a lot of memory, especially when dealing with +raw video frames. It's possible to control the behaviour of the queue with +the "drop" and "max-buffers" properties. + +If an EOS event was received before any buffers, this function returns +%NULL. Use gst_app_sink_is_eos () to check for the EOS condition. + + a #GstSample or NULL when the appsink is stopped or EOS. + + + + + Get the last preroll sample in @appsink. This was the sample that caused the +appsink to preroll in the PAUSED state. This sample can be pulled many times +and remains available to the application even after EOS. + +This function is typically used when dealing with a pipeline in the PAUSED +state. Calling this function after doing a seek will give the sample right +after the seek position. + +Note that the preroll sample will also be returned as the first sample +when calling gst_app_sink_pull_sample() or the "pull-sample" action signal. + +If an EOS event was received before any buffers or the timeout expires, +this function returns %NULL. Use gst_app_sink_is_eos () to check for the EOS +condition. + +This function blocks until a preroll sample or EOS is received, the appsink +element is set to the READY/NULL state, or the timeout expires. + + a #GstSample or NULL when the appsink is stopped or EOS or the timeout expires. + + + + + the maximum amount of time to wait for the preroll sample + + + + + + This function blocks until a sample or EOS becomes available or the appsink +element is set to the READY/NULL state or the timeout expires. + +This function will only return samples when the appsink is in the PLAYING +state. All rendered samples will be put in a queue so that the application +can pull samples at its own rate. + +Note that when the application does not pull samples fast enough, the +queued samples could consume a lot of memory, especially when dealing with +raw video frames. It's possible to control the behaviour of the queue with +the "drop" and "max-buffers" properties. + +If an EOS event was received before any buffers or the timeout expires, +this function returns %NULL. Use gst_app_sink_is_eos () to check +for the EOS condition. + + a #GstSample or NULL when the appsink is stopped or EOS or the timeout expires. + + + + + the maximum amount of time to wait for a sample + + + + + + + A set of callbacks that can be installed on the appsink with +gst_app_sink_set_callbacks(). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + a #GstSample or NULL when the appsink is stopped or EOS. + Call gst_sample_unref() after usage. + + + + + a #GstAppSink + + + + + + + + + a #GstSample or NULL when the appsink is stopped or EOS. + Call gst_sample_unref() after usage. + + + + + a #GstAppSink + + + + + + + + + a #GstSample or NULL when the appsink is stopped or EOS or the timeout expires. + Call gst_sample_unref() after usage. + + + + + a #GstAppSink + + + + the maximum amount of time to wait for the preroll sample + + + + + + + + + a #GstSample or NULL when the appsink is stopped or EOS or the timeout expires. +Call gst_sample_unref() after usage. + + + + + a #GstAppSink + + + + the maximum amount of time to wait for a sample + + + + + + + + + + + + + + + The appsrc element can be used by applications to insert data into a +GStreamer pipeline. Unlike most GStreamer elements, appsrc provides +external API functions. + +appsrc can be used by linking with the libgstapp library to access the +methods directly or by using the appsrc action signals. + +Before operating appsrc, the caps property must be set to fixed caps +describing the format of the data that will be pushed with appsrc. An +exception to this is when pushing buffers with unknown caps, in which case no +caps should be set. This is typically true of file-like sources that push raw +byte buffers. If you don't want to explicitly set the caps, you can use +gst_app_src_push_sample. This method gets the caps associated with the +sample and sets them on the appsrc replacing any previously set caps (if +different from sample's caps). + +The main way of handing data to the appsrc element is by calling the +gst_app_src_push_buffer() method or by emitting the push-buffer action signal. +This will put the buffer onto a queue from which appsrc will read from in its +streaming thread. It is important to note that data transport will not happen +from the thread that performed the push-buffer call. + +The "max-bytes" property controls how much data can be queued in appsrc +before appsrc considers the queue full. A filled internal queue will always +signal the "enough-data" signal, which signals the application that it should +stop pushing data into appsrc. The "block" property will cause appsrc to +block the push-buffer method until free data becomes available again. + +When the internal queue is running out of data, the "need-data" signal is +emitted, which signals the application that it should start pushing more data +into appsrc. + +In addition to the "need-data" and "enough-data" signals, appsrc can emit the +"seek-data" signal when the "stream-mode" property is set to "seekable" or +"random-access". The signal argument will contain the new desired position in +the stream expressed in the unit set with the "format" property. After +receiving the seek-data signal, the application should push-buffers from the +new position. + +These signals allow the application to operate the appsrc in two different +ways: + +The push mode, in which the application repeatedly calls the push-buffer/push-sample +method with a new buffer/sample. Optionally, the queue size in the appsrc +can be controlled with the enough-data and need-data signals by respectively +stopping/starting the push-buffer/push-sample calls. This is a typical +mode of operation for the stream-type "stream" and "seekable". Use this +mode when implementing various network protocols or hardware devices. + +The pull mode, in which the need-data signal triggers the next push-buffer call. +This mode is typically used in the "random-access" stream-type. Use this +mode for file access or other randomly accessable sources. In this mode, a +buffer of exactly the amount of bytes given by the need-data signal should be +pushed into appsrc. + +In all modes, the size property on appsrc should contain the total stream +size in bytes. Setting this property is mandatory in the random-access mode. +For the stream and seekable modes, setting this property is optional but +recommended. + +When the application has finished pushing data into appsrc, it should call +gst_app_src_end_of_stream() or emit the end-of-stream action signal. After +this call, no more buffers can be pushed into appsrc until a flushing seek +occurs or the state of the appsrc has gone through READY. + + + Indicates to the appsrc element that the last buffer queued in the +element is the last buffer of the stream. + + #GST_FLOW_OK when the EOS was successfuly queued. +#GST_FLOW_FLUSHING when @appsrc is not PAUSED or PLAYING. + + + + + a #GstAppSrc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Adds a buffer to the queue of buffers that the appsrc element will +push to its source pad. This function takes ownership of the buffer. + +When the block property is TRUE, this function can block until free +space becomes available in the queue. + + #GST_FLOW_OK when the buffer was successfuly queued. +#GST_FLOW_FLUSHING when @appsrc is not PAUSED or PLAYING. +#GST_FLOW_EOS when EOS occured. + + + + + a #GstAppSrc + + + + a #GstBuffer to push + + + + + + Extract a buffer from the provided sample and adds it to the queue of +buffers that the appsrc element will push to its source pad. Any +previous caps that were set on appsrc will be replaced by the caps +associated with the sample if not equal. + +When the block property is TRUE, this function can block until free +space becomes available in the queue. + + #GST_FLOW_OK when the buffer was successfuly queued. +#GST_FLOW_FLUSHING when @appsrc is not PAUSED or PLAYING. +#GST_FLOW_EOS when EOS occured. + + + + + a #GstAppSrc + + + + a #GstSample from which buffer and caps may be +extracted + + + + + + + + + + + + + + + + + + + Indicates to the appsrc element that the last buffer queued in the +element is the last buffer of the stream. + + #GST_FLOW_OK when the EOS was successfuly queued. +#GST_FLOW_FLUSHING when @appsrc is not PAUSED or PLAYING. + + + + + a #GstAppSrc + + + + + + Get the configured caps on @appsrc. + + the #GstCaps produced by the source. gst_caps_unref() after usage. + + + + + a #GstAppSrc + + + + + + Get the number of currently queued bytes inside @appsrc. + + The number of currently queued bytes. + + + + + a #GstAppSrc + + + + + + Get the duration of the stream in nanoseconds. A value of GST_CLOCK_TIME_NONE means that the duration is +not known. + + the duration of the stream previously set with gst_app_src_set_duration(); + + + + + a #GstAppSrc + + + + + + Check if appsrc will emit the "new-preroll" and "new-buffer" signals. + + %TRUE if @appsrc is emitting the "new-preroll" and "new-buffer" +signals. + + + + + a #GstAppSrc + + + + + + Retrieve the min and max latencies in @min and @max respectively. + + + + + + a #GstAppSrc + + + + the min latency + + + + the min latency + + + + + + Get the maximum amount of bytes that can be queued in @appsrc. + + The maximum amount of bytes that can be queued. + + + + + a #GstAppSrc + + + + + + Get the size of the stream in bytes. A value of -1 means that the size is +not known. + + the size of the stream previously set with gst_app_src_set_size(); + + + + + a #GstAppSrc + + + + + + Get the stream type. Control the stream type of @appsrc +with gst_app_src_set_stream_type(). + + the stream type. + + + + + a #GstAppSrc + + + + + + Adds a buffer to the queue of buffers that the appsrc element will +push to its source pad. This function takes ownership of the buffer. + +When the block property is TRUE, this function can block until free +space becomes available in the queue. + + #GST_FLOW_OK when the buffer was successfuly queued. +#GST_FLOW_FLUSHING when @appsrc is not PAUSED or PLAYING. +#GST_FLOW_EOS when EOS occured. + + + + + a #GstAppSrc + + + + a #GstBuffer to push + + + + + + Extract a buffer from the provided sample and adds it to the queue of +buffers that the appsrc element will push to its source pad. Any +previous caps that were set on appsrc will be replaced by the caps +associated with the sample if not equal. + +When the block property is TRUE, this function can block until free +space becomes available in the queue. + + #GST_FLOW_OK when the buffer was successfuly queued. +#GST_FLOW_FLUSHING when @appsrc is not PAUSED or PLAYING. +#GST_FLOW_EOS when EOS occured. + + + + + a #GstAppSrc + + + + a #GstSample from which buffer and caps may be +extracted + + + + + + Set callbacks which will be executed when data is needed, enough data has +been collected or when a seek should be performed. +This is an alternative to using the signals, it has lower overhead and is thus +less expensive, but also less flexible. + +If callbacks are installed, no signals will be emitted for performance +reasons. + + + + + + a #GstAppSrc + + + + the callbacks + + + + a user_data argument for the callbacks + + + + a destroy notify function + + + + + + Set the capabilities on the appsrc element. This function takes +a copy of the caps structure. After calling this method, the source will +only produce caps that match @caps. @caps must be fixed and the caps on the +buffers must match the caps or left NULL. + + + + + + a #GstAppSrc + + + + caps to set + + + + + + Set the duration of the stream in nanoseconds. A value of GST_CLOCK_TIME_NONE means that the duration is +not known. + + + + + + a #GstAppSrc + + + + the duration to set + + + + + + Make appsrc emit the "new-preroll" and "new-buffer" signals. This option is +by default disabled because signal emission is expensive and unneeded when +the application prefers to operate in pull mode. + + + + + + a #GstAppSrc + + + + the new state + + + + + + Configure the @min and @max latency in @src. If @min is set to -1, the +default latency calculations for pseudo-live sources will be used. + + + + + + a #GstAppSrc + + + + the min latency + + + + the min latency + + + + + + Set the maximum amount of bytes that can be queued in @appsrc. +After the maximum amount of bytes are queued, @appsrc will emit the +"enough-data" signal. + + + + + + a #GstAppSrc + + + + the maximum number of bytes to queue + + + + + + Set the size of the stream in bytes. A value of -1 means that the size is +not known. + + + + + + a #GstAppSrc + + + + the size to set + + + + + + Set the stream type on @appsrc. For seekable streams, the "seek" signal must +be connected to. + +A stream_type stream + + + + + + a #GstAppSrc + + + + the new state + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Notify @appsrc that no more buffer are available. + + + + + + Signal that the source has enough data. It is recommended that the +application stops calling push-buffer until the need-data signal is +emitted again to avoid excessive buffer queueing. + + + + + + Signal that the source needs more data. In the callback or from another +thread you should call push-buffer or end-of-stream. + +@length is just a hint and when it is set to -1, any number of bytes can be +pushed into @appsrc. + +You can call push-buffer multiple times until the enough-data signal is +fired. + + + + + + the amount of bytes needed. + + + + + + Adds a buffer to the queue of buffers that the appsrc element will +push to its source pad. This function does not take ownership of the +buffer so the buffer needs to be unreffed after calling this function. + +When the block property is TRUE, this function can block until free space +becomes available in the queue. + + + + + + a buffer to push + + + + + + Extract a buffer from the provided sample and adds the extracted buffer +to the queue of buffers that the appsrc element will +push to its source pad. This function set the appsrc caps based on the caps +in the sample and reset the caps if they change. +Only the caps and the buffer of the provided sample are used and not +for example the segment in the sample. +This function does not take ownership of the +sample so the sample needs to be unreffed after calling this function. + +When the block property is TRUE, this function can block until free space +becomes available in the queue. + + + + + + a sample from which extract buffer to push + + + + + + Seek to the given offset. The next push-buffer should produce buffers from +the new @offset. +This callback is only called for seekable stream types. + + %TRUE if the seek succeeded. + + + + + the offset to seek to + + + + + + + A set of callbacks that can be installed on the appsrc with +gst_app_src_set_callbacks(). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #GST_FLOW_OK when the buffer was successfuly queued. +#GST_FLOW_FLUSHING when @appsrc is not PAUSED or PLAYING. +#GST_FLOW_EOS when EOS occured. + + + + + a #GstAppSrc + + + + a #GstBuffer to push + + + + + + + + + #GST_FLOW_OK when the EOS was successfuly queued. +#GST_FLOW_FLUSHING when @appsrc is not PAUSED or PLAYING. + + + + + a #GstAppSrc + + + + + + + + + #GST_FLOW_OK when the buffer was successfuly queued. +#GST_FLOW_FLUSHING when @appsrc is not PAUSED or PLAYING. +#GST_FLOW_EOS when EOS occured. + + + + + a #GstAppSrc + + + + a #GstSample from which buffer and caps may be +extracted + + + + + + + + + + + + + + + The stream type. + + No seeking is supported in the stream, such as a +live stream. + + + The stream is seekable but seeking might not +be very fast, such as data from a webserver. + + + The stream is seekable and seeking is fast, +such as in a local file. + + + + diff --git a/gstreamer-app-sys/Cargo.toml b/gstreamer-app-sys/Cargo.toml new file mode 100644 index 000000000..8d62a0000 --- /dev/null +++ b/gstreamer-app-sys/Cargo.toml @@ -0,0 +1,48 @@ +[build-dependencies] +pkg-config = "0.3.7" + +[dependencies] +bitflags = "0.8" +glib-sys = "0.3" +gobject-sys = "0.3" +libc = "0.2" + +[dependencies.gstreamer-sys] +path = "../gstreamer-sys" +version = "0.1.0" + +[dependencies.gstreamer-base-sys] +path = "../gstreamer-base-sys" +version = "0.1.0" + +[features] +v1_0_10 = [] +v1_10 = ["v1_8"] +v1_12 = ["v1_10"] +v1_2 = ["v1_0_10"] +v1_2_3 = ["v1_2"] +v1_4 = ["v1_2_3"] +v1_6 = ["v1_4"] +v1_8 = ["v1_6"] + +[lib] +name = "gstreamer_app_sys" + +[package] +build = "build.rs" +links = "gstapp-1.0" +name = "gstreamer-app-sys" +version = "0.1.0" +authors = ["Sebastian Dröge "] +description = "FFI bindings to libgstapp-1.0" +homepage = "https://gstreamer.freedesktop.org" +keywords = ["ffi", "gstreamer", "gnome", "multimedia"] +repository = "https://github.com/sdroege/gstreamer-sys" +license = "MIT" + +include = [ + "src/*.rs", + "Cargo.toml", + "build.rs", + "LICENSE", +] diff --git a/gstreamer-app-sys/LICENSE b/gstreamer-app-sys/LICENSE new file mode 100644 index 000000000..3d76f6e2f --- /dev/null +++ b/gstreamer-app-sys/LICENSE @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) 2017 Sebastian Dröge . + +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. + + diff --git a/gstreamer-app-sys/build.rs b/gstreamer-app-sys/build.rs new file mode 100644 index 000000000..348e6f064 --- /dev/null +++ b/gstreamer-app-sys/build.rs @@ -0,0 +1,66 @@ +extern crate pkg_config; + +use pkg_config::{Config, Error}; +use std::env; +use std::io::prelude::*; +use std::io; +use std::process; + +fn main() { + if let Err(s) = find() { + let _ = writeln!(io::stderr(), "{}", s); + process::exit(1); + } +} + +fn find() -> Result<(), Error> { + let package_name = "gstreamer-app-1.0"; + let shared_libs = ["gstapp-1.0"]; + let version = if cfg!(feature = "v1_12") { + "1.12" + } else if cfg!(feature = "v1_10") { + "1.10" + } else if cfg!(feature = "v1_6") { + "1.6" + } else { + "1.0" + }; + + if let Ok(lib_dir) = env::var("GTK_LIB_DIR") { + for lib_ in shared_libs.iter() { + println!("cargo:rustc-link-lib=dylib={}", lib_); + } + println!("cargo:rustc-link-search=native={}", lib_dir); + return Ok(()) + } + + let target = env::var("TARGET").unwrap(); + let hardcode_shared_libs = target.contains("windows"); + + let mut config = Config::new(); + config.atleast_version(version); + if hardcode_shared_libs { + config.cargo_metadata(false); + } + match config.probe(package_name) { + Ok(library) => { + if hardcode_shared_libs { + for lib_ in shared_libs.iter() { + println!("cargo:rustc-link-lib=dylib={}", lib_); + } + for path in library.link_paths.iter() { + println!("cargo:rustc-link-search=native={}", path.to_str().unwrap()); + } + } + Ok(()) + } + Err(Error::EnvNoPkgConfig(_)) | Err(Error::Command { .. }) => { + for lib_ in shared_libs.iter() { + println!("cargo:rustc-link-lib=dylib={}", lib_); + } + Ok(()) + } + Err(err) => Err(err), + } +} + diff --git a/gstreamer-app-sys/src/lib.rs b/gstreamer-app-sys/src/lib.rs new file mode 100644 index 000000000..6ed1255ba --- /dev/null +++ b/gstreamer-app-sys/src/lib.rs @@ -0,0 +1,153 @@ +// This file was generated by gir (038b513) from gir-files (???) +// DO NOT EDIT + +#![allow(non_camel_case_types, non_upper_case_globals)] + +extern crate libc; +#[macro_use] extern crate bitflags; +extern crate glib_sys as glib; +extern crate gobject_sys as gobject; +extern crate gstreamer_sys as gst; +extern crate gstreamer_base_sys as gst_base; + +#[allow(unused_imports)] +use libc::{c_int, c_char, c_uchar, c_float, c_uint, c_double, + c_short, c_ushort, c_long, c_ulong, + c_void, size_t, ssize_t, intptr_t, uintptr_t, time_t, FILE}; + +#[allow(unused_imports)] +use glib::{gboolean, gconstpointer, gpointer, GType, Volatile}; + +// Enums +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[repr(C)] +pub enum GstAppStreamType { + Stream = 0, + Seekable = 1, + RandomAccess = 2, +} +pub const GST_APP_STREAM_TYPE_STREAM: GstAppStreamType = GstAppStreamType::Stream; +pub const GST_APP_STREAM_TYPE_SEEKABLE: GstAppStreamType = GstAppStreamType::Seekable; +pub const GST_APP_STREAM_TYPE_RANDOM_ACCESS: GstAppStreamType = GstAppStreamType::RandomAccess; + +// Records +#[repr(C)] +pub struct GstAppSinkCallbacks { + pub eos: Option, + pub new_preroll: Option gst::GstFlowReturn>, + pub new_sample: Option gst::GstFlowReturn>, + pub _gst_reserved: [gpointer; 4], +} + +#[repr(C)] +pub struct GstAppSinkClass { + pub basesink_class: gst_base::GstBaseSinkClass, + pub eos: Option, + pub new_preroll: Option gst::GstFlowReturn>, + pub new_sample: Option gst::GstFlowReturn>, + pub pull_preroll: Option *mut gst::GstSample>, + pub pull_sample: Option *mut gst::GstSample>, + pub try_pull_preroll: Option *mut gst::GstSample>, + pub try_pull_sample: Option *mut gst::GstSample>, + pub _gst_reserved: [gpointer; 2], +} + +#[repr(C)] +pub struct GstAppSinkPrivate(c_void); + +#[repr(C)] +pub struct GstAppSrcCallbacks { + pub need_data: Option, + pub enough_data: Option, + pub seek_data: Option gboolean>, + pub _gst_reserved: [gpointer; 4], +} + +#[repr(C)] +pub struct GstAppSrcClass { + pub basesrc_class: gst_base::GstBaseSrcClass, + pub need_data: Option, + pub enough_data: Option, + pub seek_data: Option gboolean>, + pub push_buffer: Option gst::GstFlowReturn>, + pub end_of_stream: Option gst::GstFlowReturn>, + pub push_sample: Option gst::GstFlowReturn>, + pub _gst_reserved: [gpointer; 3], +} + +#[repr(C)] +pub struct GstAppSrcPrivate(c_void); + +// Classes +#[repr(C)] +pub struct GstAppSink { + pub basesink: gst_base::GstBaseSink, + pub priv_: *mut GstAppSinkPrivate, + pub _gst_reserved: [gpointer; 4], +} + +#[repr(C)] +pub struct GstAppSrc { + pub basesrc: gst_base::GstBaseSrc, + pub priv_: *mut GstAppSrcPrivate, + pub _gst_reserved: [gpointer; 4], +} + +extern "C" { + + //========================================================================= + // GstAppSink + //========================================================================= + pub fn gst_app_sink_get_type() -> GType; + #[cfg(feature = "v1_12")] + pub fn gst_app_sink_get_buffer_list_support(appsink: *mut GstAppSink) -> gboolean; + pub fn gst_app_sink_get_caps(appsink: *mut GstAppSink) -> *mut gst::GstCaps; + pub fn gst_app_sink_get_drop(appsink: *mut GstAppSink) -> gboolean; + pub fn gst_app_sink_get_emit_signals(appsink: *mut GstAppSink) -> gboolean; + pub fn gst_app_sink_get_max_buffers(appsink: *mut GstAppSink) -> c_uint; + pub fn gst_app_sink_get_wait_on_eos(appsink: *mut GstAppSink) -> gboolean; + pub fn gst_app_sink_is_eos(appsink: *mut GstAppSink) -> gboolean; + pub fn gst_app_sink_pull_preroll(appsink: *mut GstAppSink) -> *mut gst::GstSample; + pub fn gst_app_sink_pull_sample(appsink: *mut GstAppSink) -> *mut gst::GstSample; + #[cfg(feature = "v1_12")] + pub fn gst_app_sink_set_buffer_list_support(appsink: *mut GstAppSink, enable_lists: gboolean); + pub fn gst_app_sink_set_callbacks(appsink: *mut GstAppSink, callbacks: *mut GstAppSinkCallbacks, user_data: gpointer, notify: glib::GDestroyNotify); + pub fn gst_app_sink_set_caps(appsink: *mut GstAppSink, caps: *const gst::GstCaps); + pub fn gst_app_sink_set_drop(appsink: *mut GstAppSink, drop: gboolean); + pub fn gst_app_sink_set_emit_signals(appsink: *mut GstAppSink, emit: gboolean); + pub fn gst_app_sink_set_max_buffers(appsink: *mut GstAppSink, max: c_uint); + pub fn gst_app_sink_set_wait_on_eos(appsink: *mut GstAppSink, wait: gboolean); + #[cfg(feature = "v1_10")] + pub fn gst_app_sink_try_pull_preroll(appsink: *mut GstAppSink, timeout: gst::GstClockTime) -> *mut gst::GstSample; + #[cfg(feature = "v1_10")] + pub fn gst_app_sink_try_pull_sample(appsink: *mut GstAppSink, timeout: gst::GstClockTime) -> *mut gst::GstSample; + + //========================================================================= + // GstAppSrc + //========================================================================= + pub fn gst_app_src_get_type() -> GType; + pub fn gst_app_src_end_of_stream(appsrc: *mut GstAppSrc) -> gst::GstFlowReturn; + pub fn gst_app_src_get_caps(appsrc: *mut GstAppSrc) -> *mut gst::GstCaps; + #[cfg(feature = "v1_2")] + pub fn gst_app_src_get_current_level_bytes(appsrc: *mut GstAppSrc) -> u64; + #[cfg(feature = "v1_10")] + pub fn gst_app_src_get_duration(appsrc: *mut GstAppSrc) -> gst::GstClockTime; + pub fn gst_app_src_get_emit_signals(appsrc: *mut GstAppSrc) -> gboolean; + pub fn gst_app_src_get_latency(appsrc: *mut GstAppSrc, min: *mut u64, max: *mut u64); + pub fn gst_app_src_get_max_bytes(appsrc: *mut GstAppSrc) -> u64; + pub fn gst_app_src_get_size(appsrc: *mut GstAppSrc) -> i64; + pub fn gst_app_src_get_stream_type(appsrc: *mut GstAppSrc) -> GstAppStreamType; + pub fn gst_app_src_push_buffer(appsrc: *mut GstAppSrc, buffer: *mut gst::GstBuffer) -> gst::GstFlowReturn; + #[cfg(feature = "v1_6")] + pub fn gst_app_src_push_sample(appsrc: *mut GstAppSrc, sample: *mut gst::GstSample) -> gst::GstFlowReturn; + pub fn gst_app_src_set_callbacks(appsrc: *mut GstAppSrc, callbacks: *mut GstAppSrcCallbacks, user_data: gpointer, notify: glib::GDestroyNotify); + pub fn gst_app_src_set_caps(appsrc: *mut GstAppSrc, caps: *const gst::GstCaps); + #[cfg(feature = "v1_10")] + pub fn gst_app_src_set_duration(appsrc: *mut GstAppSrc, duration: gst::GstClockTime); + pub fn gst_app_src_set_emit_signals(appsrc: *mut GstAppSrc, emit: gboolean); + pub fn gst_app_src_set_latency(appsrc: *mut GstAppSrc, min: u64, max: u64); + pub fn gst_app_src_set_max_bytes(appsrc: *mut GstAppSrc, max: u64); + pub fn gst_app_src_set_size(appsrc: *mut GstAppSrc, size: i64); + pub fn gst_app_src_set_stream_type(appsrc: *mut GstAppSrc, type_: GstAppStreamType); + +}