Turning this gst-launch-1.0 command into a C++ app?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Turning this gst-launch-1.0 command into a C++ app?

rick b
Hi all... 

I'm very new to GStreamer, I've gone through the manual but I still
needed a fair amount of assistance....  I'm sorry this email is a bit
long, but I have a LOT of confusion going on and would greatly
appreciate any help I can get.



I have this gst-launch-1.0 command.

==========================================================
gst-launch-1.0 v4l2src device=/dev/video13 do-timestamp=true ! video/x-
raw, format=YUY2, width=640, height=480, framerate=30/1 !
autovideoconvert ! vaapih264enc ! rtph264pay ! udpsink host=192.168.1.2
port=5600
==========================================================

I'm wanting to duplicate this command line into a C++ application using
these elements/settings

I started to try and pick out the various elements.  The ones I came up
with are (which I could be SO COMPLETELY WRONG). Are these the actual
elements I would want to try and create in a C++ app???

* v4l2src
* autovideoconvert
* vaapih264enc
* rtph264pay
* udpsink

On my system, I get errors for autovideoconvert, vaapih264enc.  
WARNING: erroneous pipeline: no element "autovideoconvert"
This warning is what I get from the command line when I run the gst-
launch command.

I'm not exactly sure why vaapih264enc is not working but I suspect the
same. I only know this because in my app, I check to see if each
element was created successfully.  If not I print out an error.

The other elements seem to generate ok. I noticed that autovideoconvert
is classified in the "bad" category, if I wanted to replace it with
something else, is there a way to make an educated guess at another
element?

what is rtph264pay.  I did a search on it. I found the manual page for
it but there is no description.  


Also, if I look at v4l2src, I see that there is "device=/dev/video13".
Is that a property that I would set on my v4l2src element?

What about 
   video/x-raw, format=YUY2, width=640, height=480, framerate=30/1
Is that a set of properties?  If so, what element do they belong on?




_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Turning this gst-launch-1.0 command into a C++ app?

Mert Can Ergun
You don't have to read the whole manual but examining this code will give you a great amount of idea about the framework and how to write basic applications with it.
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-helloworld.html

You can use videoconvert instead of autovideoconvert.

Video4Linux mounts different sources to different points, generally starting from /dev/video0. And in your case you are telling the v4l2src to use the source at /dev/video13. I am not 100% sure but if you don't set that property, the element is supposed to search for valid sources on your system and use the first one it finds.
Reply | Threaded
Open this post in threaded view
|

Re: Turning this gst-launch-1.0 command into a C++ app?

rick b
This post was updated on .
I've made SOME headway

Again, i'm trying to recreate this command line app in C/C++
gst-launch-1.0 v4l2src device=/dev/video13 do-timestamp=true ! video/x-raw, format=YUY2, width=640, height=480, framerate=30/1 ! autovideoconvert ! vaapih264enc ! rtph264pay ! udpsink host=192.168.1.2 port=5600


I've setup all my elements, however, I'm getting an internal data flow error and I'm not sure why. Any help will be AWESOME!!!
Thanks


#include <gst/gst.h>
#include <glib.h>
#include <stdlib.h>
#include <stdio.h>

GMainLoop *loop;

// Contain all the elements into a nice struct.
typedef struct _CustomData
{
        GstElement *pipeline;
        GstElement *videoSource;
        GstElement *videoConvert;
        GstElement *videoEncoder;
        GstElement *rtph264pay;
        GstElement *autoVideoSink;
        GstElement *uUpSink;
} CustomData;



// Constructs the elements in the pipeline
static bool build_elements( CustomData& data );

// Validates the elements in the pipeline
static bool check_elements( CustomData& data );

// Bus message handler
static gboolean my_bus_callback( GstBus *bus, GstMessage *message, gpointer data );





// Main app entry point.
int main( int argc, char *argv[ ] )
{
        CustomData pipe;
        GstBus *bus;
        guint bus_watch_id;
        GstElement *filter;

        // init
        gst_init( &argc, &argv );

        // create elements
        if( !build_elements( pipe ) )
                g_print( "Failed to create elements\n" );

        // check to ensure the elements were created properly
        if( !check_elements( pipe ) )
                g_print( "Failed to create elements\n" );

        // I've tried it WITH and WITHOUT the caps filter whic is not making any difference.
        //filter = gst_element_factory_make ( "capsfilter", NULL);
        //gst_util_set_object_arg( G_OBJECT( filter ), "caps", "video/x-raw, width=640, height=480, " "format={ YUY2 }" );

        // put together a pipeline
        gst_bin_add_many( GST_BIN ( pipe.pipeline ), pipe.videoSource, pipe.videoConvert, pipe.videoEncoder, pipe.rtph264pay, pipe.uUpSink, NULL );

        bus = gst_pipeline_get_bus( GST_PIPELINE( pipe.pipeline ) );
        bus_watch_id = gst_bus_add_watch( bus, my_bus_callback, NULL );
        gst_object_unref( bus );


        if( !gst_element_link_many( pipe.videoSource, pipe.videoEncoder, pipe.rtph264pay, pipe.uUpSink, NULL ) )
                g_print( "Failed to link elements\n" );


        // listen for newly created pads
        // start the pipeline
        gst_element_set_state( GST_ELEMENT( pipe.pipeline ), GST_STATE_PLAYING );
        loop = g_main_loop_new( NULL, FALSE );
        g_main_loop_run( loop );

        return 0;
}




// Constructs the elements for the pipe.
static bool build_elements( CustomData& pipe )
{
        bool retVal = true;
        try
        {
                pipe.pipeline = gst_pipeline_new( "aero_pipeline" );
                pipe.videoSource = gst_element_factory_make( "v4l2src", "videoSource" );
                pipe.videoConvert = gst_element_factory_make( "videoconvert", "videoConvert" );
                pipe.videoEncoder = gst_element_factory_make( "vaapih264enc", "videoEncoder" );
                pipe.rtph264pay = gst_element_factory_make( "rtph264pay", "h264Pay" );
                pipe.uUpSink = gst_element_factory_make( "udpsink", "uUpSink" );
                pipe.autoVideoSink = gst_element_factory_make( "autovideosink", "videoSink" );


                // Set the properties on the video source and the udp sink
                g_object_set( pipe.videoSource,  "device", "/dev/video13", NULL );
                g_object_set( pipe.uUpSink,  "host", "192.168.1.2", NULL );
                g_object_set( pipe.uUpSink,  "port", 5600, NULL );

                gint port;
                gchar *value;

                g_object_get( G_OBJECT( pipe.videoSource), "device", &value, NULL );
                g_print( "\n\n~~~~~~~~~~~~~~~~~ video device = %s \n", value );
                g_free( value );

                g_object_get( G_OBJECT( pipe.uUpSink), "host", &value, NULL );
                g_print( "~~~~~~~~~~~~~~~~~ udp sink host = %s \n", value );
                g_free( value );

                g_object_get( G_OBJECT( pipe.uUpSink ), "port", &port, NULL );
                g_print( "~~~~~~~~~~~~~~~~~ udp sink port = %u \n\n\n", port );

        }
        catch( ... )
        {
                retVal = false;
        }
        return retVal;
}


// Checks to ensure all the elements where successfully created.
static bool check_elements( CustomData& data )
{
        bool retVal = true;
        if (!data.pipeline )
        {
                g_printerr ("Failed to create pipeline .\n");
                retVal = false;
        }
        if( !data.videoSource )
        {
                g_printerr ("Failed to create data source.\n");
                retVal = false;
        }
        if( !data.videoConvert )
        {
                g_printerr ("Failed to create video_convert.\n");
                retVal = false;
        }
        if ( !data.videoEncoder )
        {
                g_printerr ("Failed to create avdec_h264 video encoder.\n");
                retVal = false;
        }
        if( !data.rtph264pay )
        {
                g_printerr ("Failed to create rtph264pay .\n");
                retVal = false;
        }
        if( !data.uUpSink )
        {
                g_printerr ("Failed to create udpsink .\n");
                retVal = false;
        }
        return retVal;
}





static gboolean my_bus_callback( GstBus *bus, GstMessage *message, gpointer data )
{
        return true;
        g_print( "Got %s message\n", GST_MESSAGE_TYPE_NAME( message ) );

        switch( GST_MESSAGE_TYPE( message ) )
        {
    case GST_MESSAGE_ERROR:
    {
                        GError *err;
                        gchar *debug;

                        gst_message_parse_error( message, &err, &debug );
                        g_print( "Error: %s\n", err->message );
                        g_error_free( err );
                        g_free( debug );
                        g_main_loop_quit( loop );
                        break;
    }
    case GST_MESSAGE_EOS:

    // end-of-stream
    g_main_loop_quit (loop);
    break;
    default:
    // unhandled message
    break;
        }

  // we want to be notified again the next time there is a message
   // on the bus, so returning TRUE (FALSE means we want to stop watching
  // for messages on the bus and our callback should not be called again)

  return TRUE;
}
Reply | Threaded
Open this post in threaded view
|

Re: Turning this gst-launch-1.0 command into a C++ app?

Tim Müller
On Wed, 2016-11-09 at 20:31 -0800, rick b wrote:

Hi Rick,

> I've setup all my elements, however, I'm getting an internal data
> flow error and I'm not sure why. Any help will be AWESOME!!!

What kind of flow error are you getting? (not-linked, not-negotiated,
etc.) Could you paste the whole error message including the 'debug'
detail string?

Does this pipeline work for you as is in gst-launch-1.0?

Use videoconvert instead of autovideoconvert, as mentioned already. I
see you do that in your code, but you don't actually link the
videoconvert element with anything else, so it's just going to sit
there unused.

You can also use

  pipeline=gst_parse_launch("...", ...)

to create a simple pipeline from parse-launch syntax.

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Turning this gst-launch-1.0 command into a C++ app?

rick b
Hi Tim, I had thought about just using the gst-launch command inside my source code. And I have, it works. The problem is, I came into a situation where I needed the main app loop.  I had asked about how to get the main app loop and was told that the gst-launch command does not generate a loop.

So, I'm back to trying to do this.

I went back and re-added the videovert element.  Still not working.  I reran and added --gst-debug-level=3
I get a bunch of vaapi errors and warnings.

I wanted to capture these out to a file but
myExe --gst-debug-level=3 > myErrorFile.txt

However, NONE of the gstreamer debug output got put into that file.  I'm sure it's my lack of Linux skills that's the problem.  Is there a linux command command that I can run that will output all the --gst-debug-level output into a file?


Reply | Threaded
Open this post in threaded view
|

Re: Turning this gst-launch-1.0 command into a C++ app?

rick b
Here is debug level 3.  I realize that I need to configure vaapi, but... TO be honest, being so new to GStreamer, I'm not sure exactly what that would look like/how to do it.


~~~~~~~~~~~~~~~~~ video device = /dev/video13
~~~~~~~~~~~~~~~~~ udp sink host = 192.168.1.3
~~~~~~~~~~~~~~~~~ udp sink port = 5600


error: XDG_RUNTIME_DIR not set in the environment.
libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
0:00:00.320809833   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:589:is_chroma_type_supported: We only support YUV 4:2:0 and YUV 4:2:2 for encoding. Please try to use vaapipostproc to convert the input format.
0:00:00.320888060   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:629:set_context_info: failed to determine chroma type for format YUY2
0:00:00.320914636   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:697:gst_vaapi_encoder_reconfigure_internal: failed to update VA context
0:00:00.320936449   735       0x785450 WARN            videoencoder gstvideoencoder.c:674:gst_video_encoder_setcaps:<videoEncoder> rejected caps video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, framerate=(fraction)30/1
0:00:00.321170219   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:589:is_chroma_type_supported: We only support YUV 4:2:0 and YUV 4:2:2 for encoding. Please try to use vaapipostproc to convert the input format.
0:00:00.321189820   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:629:set_context_info: failed to determine chroma type for format YUY2
0:00:00.321210483   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:697:gst_vaapi_encoder_reconfigure_internal: failed to update VA context
0:00:00.321230546   735       0x785450 WARN            videoencoder gstvideoencoder.c:674:gst_video_encoder_setcaps:<videoEncoder> rejected caps video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, framerate=(fraction)30/1
0:00:00.321266372   735       0x785450 WARN    #[00;01;31;41m            GST_PADS gstpad.c:4081:gst_pad_peer_query:<videoConvert:src> could not send sticky events
0:00:00.327260305   735       0x785450 WARN          v4l2bufferpool gstv4l2bufferpool.c:748:gst_v4l2_buffer_pool_start:<videoSource:pool:src> Uncertain or not enough buffers, enabling copy threshold
0:00:00.332172490   735       0x785450 WARN          v4l2bufferpool gstv4l2bufferpool.c:1196:gst_v4l2_buffer_pool_dqbuf:<videoSource:pool:src> Driver should never set v4l2_buffer.field to ANY
0:00:00.332225516   735       0x785450 WARN          v4l2bufferpool gstv4l2bufferpool.c:1958:gst_v4l2_buffer_pool_process:<videoSource:pool:src> Dropping corrupted buffer without payload
0:00:00.332260617   735       0x785450 WARN          v4l2bufferpool gstv4l2bufferpool.c:1958:gst_v4l2_buffer_pool_process:<videoSource:pool:src> Dropping corrupted buffer without payload
0:00:00.332287743   735       0x785450 WARN          v4l2bufferpool gstv4l2bufferpool.c:1958:gst_v4l2_buffer_pool_process:<videoSource:pool:src> Dropping corrupted buffer without payload
0:00:00.332314669   735       0x785450 WARN          v4l2bufferpool gstv4l2bufferpool.c:1958:gst_v4l2_buffer_pool_process:<videoSource:pool:src> Dropping corrupted buffer without payload
0:00:00.744814146   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:589:is_chroma_type_supported: We only support YUV 4:2:0 and YUV 4:2:2 for encoding. Please try to use vaapipostproc to convert the input format.
0:00:00.744951800   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:629:set_context_info: failed to determine chroma type for format YUY2
0:00:00.744995127   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:697:gst_vaapi_encoder_reconfigure_internal: failed to update VA context
0:00:00.745033641   735       0x785450 WARN            videoencoder gstvideoencoder.c:674:gst_video_encoder_setcaps:<videoEncoder> rejected caps video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, framerate=(fraction)30/1
0:00:00.745462429   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:589:is_chroma_type_supported: We only support YUV 4:2:0 and YUV 4:2:2 for encoding. Please try to use vaapipostproc to convert the input format.
0:00:00.745503368   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:629:set_context_info: failed to determine chroma type for format YUY2
0:00:00.745539707   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:697:gst_vaapi_encoder_reconfigure_internal: failed to update VA context
0:00:00.745576146   735       0x785450 WARN            videoencoder gstvideoencoder.c:674:gst_video_encoder_setcaps:<videoEncoder> rejected caps video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, framerate=(fraction)30/1
0:00:00.745689674   735       0x785450 WARN                 basesrc gstbasesrc.c:2948:gst_base_src_loop:<videoSource> error: Internal data flow error.
0:00:00.745727326   735       0x785450 WARN                 basesrc gstbasesrc.c:2948:gst_base_src_loop:<videoSource> error: streaming task paused, reason not-negotiated (-4)
0:00:00.746191491   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:589:is_chroma_type_supported: We only support YUV 4:2:0 and YUV 4:2:2 for encoding. Please try to use vaapipostproc to convert the input format.
0:00:00.746229129   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:629:set_context_info: failed to determine chroma type for format YUY2
0:00:00.746265231   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:697:gst_vaapi_encoder_reconfigure_internal: failed to update VA context
0:00:00.746300532   735       0x785450 WARN            videoencoder gstvideoencoder.c:674:gst_video_encoder_setcaps:<videoEncoder> rejected caps video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, framerate=(fraction)30/1
0:00:00.746687857   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:589:is_chroma_type_supported: We only support YUV 4:2:0 and YUV 4:2:2 for encoding. Please try to use vaapipostproc to convert the input format.
0:00:00.746726208   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:629:set_context_info: failed to determine chroma type for format YUY2
0:00:00.746762659   735       0x785450 ERROR                  vaapi gstvaapiencoder.c:697:gst_vaapi_encoder_reconfigure_internal: failed to update VA context
0:00:00.746798023   735       0x785450 WARN            videoencoder gstvideoencoder.c:674:gst_video_encoder_setcaps:<videoEncoder> rejected caps video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, framerate=(fraction)30/1
Reply | Threaded
Open this post in threaded view
|

Re: Turning this gst-launch-1.0 command into a C++ app?

rick b
This post was updated on .
I pulled out a couple of things that I though might be helpful

ERROR vaapi gstvaapiencoder.c:589:is_chroma_type_supported: We only support YUV 4:2:0 and YUV 4:2:2 for encoding. Please try to use vaapipostproc to convert the input format.
ERROR    vaapi gstvaapiencoder.c:629:set_context_info:failed to determine chroma type for format YUY2
ERROR    vaapi gstvaapiencoder.c:697:gst_vaapi_encoder_reconfigure_internal: failed to update VA context
WARN videoencoder gstvideoencoder.c:674:gst_video_encoder_setcaps:<videoEncoder> rejected caps video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, framerate=(fraction)60/1
WARN     GST_PADS gstpad.c:4081:gst_pad_peer_query:<capsfilter0:src> could not send sticky events
Reply | Threaded
Open this post in threaded view
|

RE: Turning this gst-launch-1.0 command into a C++ app?

allanc
In reply to this post by rick b
I'm not sure I understand where you're coming from with this question.

I'll try answer the easy one first. It's possible the reason you don't see the GST debug stuff is because it's being sent to standard error and ">" redirects standard output. If you want to capture both of these, you can use something like "myProg >someFile 2>&1" which also directs stderr (2) to the same place as stdout (1).

In terms of getting the "main loop", GStreamer itself does not provide this functionality. If you want to have messages delivered to a loop, you need to create one yourself (via gtk or glib) and then notify Gstreamer elements to post messages to it.

By way of example, my current program calls a sequence:
        gst_init(argc, argv);
        GstElement *playbin = gst_parse_launch("<vide stream>", 0);
        gst_element_set_state(playbin, GST_STATE_PLAYING);
to actually kick off a video stream.

However, it also has:
        GstMainContext *context = g_main_context_new()
        g_main_context_push_thread_default(context);
        GMainLoop *mainLoop = g_main_loop_new(context, FALSE);
        :
        g_main_loop_run(m_mainLoop);
to kick of a GLib message pump.

In terms of connecting GStreamer signals to the message pump, you can use something like:
        GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(playbin));
        gst_bus_add_signal_watch(bus);
        g_signal_connect(bus, "message::state-changed", (GCallback)StateChangedCb, NULL);
and that particular signal should be delivered to your callback function:
        gboolean StateChangedCb(GstBus *bus, GstMessage *msg, gpointer data) {
                // bus is the bus (obviously).
                // msg is the constructed message which you can use to get extra details.
                // data is the pointer specified in the signal connect call above (NULL)
                // in this case but can be used to deliver specific detail).
        }

Hope that helps and, as always, any corrections by those more adept in GStreamer are welcome.
Al.

-----Original Message-----
From: gstreamer-devel [mailto:[hidden email]] On Behalf Of rick b
Sent: Friday, 11 November 2016 1:53 AM
To: [hidden email]
Subject: Re: Turning this gst-launch-1.0 command into a C++ app?

Hi Tim, I had thought about just using the gst-launch command inside my source code. And I have, it works. The problem is, I came into a situation where I needed the main app loop.  I had asked about how to get the main app loop and was told that the gst-launch command does not generate a loop.

So, I'm back to trying to do this.

I went back and re-added the videovert element.  Still not working.  I reran and added --gst-debug-level=3 I get a bunch of vaapi errors and warnings.

I wanted to capture these out to a file but myExe --gst-debug-level=3 > myErrorFile.txt

However, NONE of the gstreamer debug output got put into that file.  I'm sure it's my lack of Linux skills that's the problem.  Is there a linux command command that I can run that will output all the --gst-debug-level output into a file?






--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Turning-this-gst-launch-1-0-command-into-a-C-app-tp4680502p4680600.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://linkprotect.cudasvc.com/url?a=https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel&c=E,1,uWtP-yYHCisOwUjYc860aQSeo3hJkessKmXDFwkGPDp6rjubOmZgHFEaZKDyx4bI1zkab5HRIa6DQig6RubJP1DYbF3MZwmRgWDv6F-4&typo=1
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

RE: Turning this gst-launch-1.0 command into a C++ app?

allanc
Must remember to insert more blank lines in the next post, it's conflated my code with my text. In both the first and third code segments, the text at the end of the final line ("to actually kick off ..." and "and that particular signal ...") is not actually part of the code, it's a continuation of the descriptive text surrounding it.

In addition, the " g_main_loop_run(m_mainLoop);" line should be using "mainLoop" - I'd removed the "m_" from all variables except this one.

Cheers once again,
Al.

-----Original Message-----
From: gstreamer-devel [mailto:[hidden email]] On Behalf Of Allan Chandler
Sent: Friday, 11 November 2016 9:53 AM
To: [hidden email]
Subject: RE: Turning this gst-launch-1.0 command into a C++ app?

I'm not sure I understand where you're coming from with this question.

I'll try answer the easy one first. It's possible the reason you don't see the GST debug stuff is because it's being sent to standard error and ">" redirects standard output. If you want to capture both of these, you can use something like "myProg >someFile 2>&1" which also directs stderr (2) to the same place as stdout (1).

In terms of getting the "main loop", GStreamer itself does not provide this functionality. If you want to have messages delivered to a loop, you need to create one yourself (via gtk or glib) and then notify Gstreamer elements to post messages to it.

By way of example, my current program calls a sequence:
        gst_init(argc, argv);
        GstElement *playbin = gst_parse_launch("<vide stream>", 0);
        gst_element_set_state(playbin, GST_STATE_PLAYING); to actually kick off a video stream.

However, it also has:
        GstMainContext *context = g_main_context_new()
        g_main_context_push_thread_default(context);
        GMainLoop *mainLoop = g_main_loop_new(context, FALSE);
        :
        g_main_loop_run(m_mainLoop);
to kick of a GLib message pump.

In terms of connecting GStreamer signals to the message pump, you can use something like:
        GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(playbin));
        gst_bus_add_signal_watch(bus);
        g_signal_connect(bus, "message::state-changed", (GCallback)StateChangedCb, NULL); and that particular signal should be delivered to your callback function:
        gboolean StateChangedCb(GstBus *bus, GstMessage *msg, gpointer data) {
                // bus is the bus (obviously).
                // msg is the constructed message which you can use to get extra details.
                // data is the pointer specified in the signal connect call above (NULL)
                // in this case but can be used to deliver specific detail).
        }

Hope that helps and, as always, any corrections by those more adept in GStreamer are welcome.
Al.

-----Original Message-----
From: gstreamer-devel [mailto:[hidden email]] On Behalf Of rick b
Sent: Friday, 11 November 2016 1:53 AM
To: [hidden email]
Subject: Re: Turning this gst-launch-1.0 command into a C++ app?

Hi Tim, I had thought about just using the gst-launch command inside my source code. And I have, it works. The problem is, I came into a situation where I needed the main app loop.  I had asked about how to get the main app loop and was told that the gst-launch command does not generate a loop.

So, I'm back to trying to do this.

I went back and re-added the videovert element.  Still not working.  I reran and added --gst-debug-level=3 I get a bunch of vaapi errors and warnings.

I wanted to capture these out to a file but myExe --gst-debug-level=3 > myErrorFile.txt

However, NONE of the gstreamer debug output got put into that file.  I'm sure it's my lack of Linux skills that's the problem.  Is there a linux command command that I can run that will output all the --gst-debug-level output into a file?






--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Turning-this-gst-launch-1-0-command-into-a-C-app-tp4680502p4680600.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://linkprotect.cudasvc.com/url?a=https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel&c=E,1,uWtP-yYHCisOwUjYc860aQSeo3hJkessKmXDFwkGPDp6rjubOmZgHFEaZKDyx4bI1zkab5HRIa6DQig6RubJP1DYbF3MZwmRgWDv6F-4&typo=1
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

RE: Turning this gst-launch-1.0 command into a C++ app?

rick b
Hi Allan. it is helpful.  My biggest challenge though is getting vaapi setup properly in my code.