[gst-devel] video file and pad...
Erwan Masson
masson.erwan1 at gmail.com
Wed May 9 10:19:35 CEST 2007
Hello,
My code are always messy, and maybe you need to do some g_object_unref to
clean(see the last line in comment), but this code works.
A new pad callback function:
static void
cb_new_pad (GstElement *element,
GstPad *pad,
gpointer data)
{
GstPad *sinkpad;
GstCaps *caps;
GstStructure *str;
gint i, max;
caps = gst_pad_get_caps (pad);
str = gst_caps_get_structure (caps, 0);
/* We can now link this pad with the audio or video decoder */
g_print ("\n Dynamic pad created, linking parser/decoder \n");
if (g_strrstr (gst_structure_get_name (str), "video"))
{
g_print("Video link\n");
max = gst_structure_n_fields (str); // Récupère le nombre de field
dans la structure
for(i=0;i<max; i++){
g_print("\n Nom de la structure %s \n",
gst_structure_nth_field_name (str, i)); // Recupère le nom de la structure.
}
g_print(gst_caps_to_string(caps));
//Add now the video thread in the main pipeline
gst_bin_add(GST_BIN(pipeline), pipeVideo);
//Put the pipeline video on state ready (It can bug if it is not
init to ready)
gst_element_set_state (pipeVideo, GST_STATE_READY);
//Retrieves the sink pad of the pipevideo(the ghost pad)
sinkpad = gst_element_get_pad (pipeVideo, "sink");
//If the pileline is already link, stop here
if (GST_PAD_IS_LINKED (sinkpad)) return;
//You can add here a notify caps:
//g_signal_connect(sinkpad,
"notify::caps",G_CALLBACK(cb_notify_caps), NULL);
//Link the main pipeline pad with the pipeline video pad
if (gst_pad_link(pad, sinkpad)!= GST_PAD_LINK_OK)
{
g_error("Cannot link video\n");
return;
}
//Put the state at pause, it can be crash if not init
gst_element_set_state (pipeVideo, GST_STATE_PAUSED);
}
if ( g_strrstr (gst_structure_get_name (str), "audio"))
{
g_print("Audio link\n");
gst_bin_add(GST_BIN(pipeline), pipeAudio);
gst_element_set_state (pipeAudio, GST_STATE_READY);
sinkpad = gst_element_get_pad (pipeAudio, "sink");
if (GST_PAD_IS_LINKED (sinkpad)){
g_print("Already link");
}
if (gst_pad_link(pad, sinkpad) != GST_PAD_LINK_OK)
{
g_error("Cannot link audio\n");
return;
}
//g_print("Audio paused\n");
// gst_element_set_state (pipeAudio, GST_STATE_PAUSED);
// g_print("Audio playing\n");
//gst_element_set_state (pipeAudio, GST_STATE_PLAYING);
// g_print("Video playing\n");
// gst_element_set_state (pipeVideo, GST_STATE_PLAYING);
//g_print("pipe playing2\n")
if(!haveTypeAudio){
g_print("Type de l'audio pas encore trouvé %d \n",
video_frames);
return;
};
gst_element_set_state (pipeline, GST_STATE_PLAYING);
//gst_object_unref (sinkpad);
}
}
2007/5/6, fabien <fabien.castan at free.fr>:
>
> Hello,
>
> It's me again. I tried and I tried by I still can't read a video file.
> So I tried to write the smallest and simplest code possible, based on
> the example that was sent to the mailing list.
> The only thing missing is the connection of the "pad" in the
> "cb_new_pad()" function and without this connection nothing can really
> happen..
> I added the video pipeline to the global pipeline, but there must be
> something missing and I don't know what?
> I've attached the file to this e-mail.
>
> Thanks for your patience
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20070509/666ec04e/attachment.htm>
More information about the gstreamer-devel
mailing list