All Boards Creating App Video

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

All Boards Creating App Video

All Boards Creating App Video

Instead to use gst-launch to play your audio/video media you can create an application do to that.

This application was tested in iMX27ADS but should to work on iMX27PDK

First execute LTIB (./ltib -c) and select these packages: all gstreamer plugin, alsa-utils and libmad.

Create your file code (i.e.: playvideo.c):

#include <gst/gst.h>

#include <glib.h> #include <string.h>



static GstElement *source, *demuxer, *vdqueue, *adqueue, *vdsink, *adsink, *decvd, *decad;

void on_pad_added (GstElement *element, GstPad *pad)
{
        g_debug ("Signal: pad-added");
        GstCaps *caps;
        GstStructure *str;

        caps = gst_pad_get_caps (pad);
        g_assert (caps != NULL);
        str = gst_caps_get_structure (caps, 0);
        g_assert (str != NULL);

        if (g_strrstr (gst_structure_get_name (str), "video")) {
                g_debug ("Linking video pad to dec_vd");
                // Link it actually
                GstPad *targetsink = gst_element_get_pad (decvd, "sink");
                g_assert (targetsink != NULL);
                gst_pad_link (pad, targetsink);
                gst_object_unref (targetsink);
        }

        if (g_strrstr (gst_structure_get_name (str), "audio")) {
                g_debug ("Linking audio pad to dec_ad");
                // Link it actually
                GstPad *targetsink = gst_element_get_pad (decad, "sink");
                g_assert (targetsink != NULL);
                gst_pad_link (pad, targetsink);
                gst_object_unref (targetsink);
        }

        gst_caps_unref (caps);
}

static gboolean
bus_call (GstBus    *bus,
          GstMessage *msg,
          gpointer    data)
{
  GMainLoop *loop = (GMainLoop *) data;

  switch (GST_MESSAGE_TYPE (msg)) {

    case GST_MESSAGE_EOS:
      g_print ("End of stream\n");
      g_main_loop_quit (loop);
      break;

    case GST_MESSAGE_ERROR: {
      gchar  *debug;
      GError *error;

      gst_message_parse_error (msg, &error, &debug);
      g_free (debug);

      g_printerr ("Error: %s\n", error->message);
      g_error_free (error);

      g_main_loop_quit (loop);
      break;
    }
    default:
      break;
  }

  return TRUE;
}

int
main (int  argc,
      char *argv[])
{
  GMainLoop *loop;

  GstElement *pipeline;
  GstBus *bus;

  /* Initialisation */
  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);


  /* Check input arguments */
  if (argc != 2) {
    g_printerr ("Usage: %s <Video H264 filename>\n", argv[0]);
    return -1;
  }


  /* Create gstreamer elements */
  pipeline      = gst_pipeline_new ("media-player");
  source        = gst_element_factory_make ("filesrc","file-source");
  demuxer      = gst_element_factory_make ("mfw_mp4demuxer","avi-demuxer");
  decvd        = gst_element_factory_make ("mfw_vpudecoder", "video-decoder");
  decad        = gst_element_factory_make ("mad", "mp3-decoder");
  vdsink        = gst_element_factory_make ("mfw_v4lsink",    "video-sink");
  vdqueue      = gst_element_factory_make ("queue",            "video-queue");
  adqueue      = gst_element_factory_make ("queue",            "audio-queue");
  adsink        = gst_element_factory_make ("fakesink",        "audio-sink");

  g_object_set (decvd, "codec-type", "std_avc", NULL);

  if (!pipeline || !source || !demuxer || !decvd || !decad || !vdsink || !vdqueue || !adqueue || !adsink) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;
  }

  /* Set up the pipeline */

  /* we set the input filename to the source element */
  g_object_set (G_OBJECT (source), "location", argv[1], NULL);

  /* we add a message handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);

  /* we add all elements into the pipeline */
  /* file-source | ogg-demuxer | vorbis-decoder | converter | alsa-output */
  gst_bin_add_many (GST_BIN (pipeline),
                    source, demuxer, decvd, decad, adqueue, vdqueue, vdsink, adsink,  NULL);

  /* we link the elements together */
  /* file-source -> ogg-demuxer ~> vorbis-decoder -> converter -> alsa-output */
  gst_element_link (source, demuxer);
  gst_element_link (decvd, vdqueue);
  gst_element_link (vdqueue, vdsink);
  //gst_element_link (decad, adqueue);
  gst_element_link (adqueue, adsink);

  g_signal_connect (demuxer, "pad-added", G_CALLBACK (on_pad_added), NULL);

  /* note that the demuxer will be linked to the decoder dynamically.
    The reason is that Ogg may contain various streams (for example
    audio and video). The source pad(s) will be created at run time,
    by the demuxer when it detects the amount and nature of streams.
    Therefore we connect a callback function which will be executed
    when the "pad-added" is emitted.*/

  /* Set the pipeline to "playing" state*/
  g_print ("Now playing: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);


  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);


  /* Out of the main loop, clean up nicely */
  g_print ("Returned, stopping playback\n");
  gst_element_set_state (pipeline, GST_STATE_NULL);

  g_print ("Deleting pipeline\n");
  gst_object_unref (GST_OBJECT (pipeline));

  return 0;
}

Create a directory inside your ltib directory to compile your source code:

$ mkdir ~/your-ltib-dir/rpm/BUILD/gst

Enter on LTIB shell mode:

$ ./ltib -m shell

Entering ltib shell mode, type 'exit' to quit

LTIB>

Enter in your application dir:

LTIB> cd rpm/BUILD/gst/

Compile your application:

LTIB> gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10) playvideo.c -o playvideo

If everything worked file you will get a "playvideo" arm binary:

LTIB> file playvideo

playvideo: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, dynamically linked (uses shared libs), not stripped

Now just copy it to ~/your-ltib-dir/rootfs/home.

Start your board using this rootfs and execute:

root@freescale ~$ cd /home/

root@freescale /home$ ./playvideo your-file-h264-mp3.avi

Now playing: your-file-h264-mp3.avi

Running...

Comments

Hi Jesseg,

Where I can get mfw_mp3_encode/decode source code and how to add them into my ltib environment, I am using imx27ads board and BSP REL2

Best regards.

%3CLINGO-SUB%20id%3D%22lingo-sub-1104011%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EAll%20Boards%20Creating%20App%20Video%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1104011%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EInstead%20to%20use%20gst-launch%20to%20play%20your%20audio%2Fvideo%20media%20you%20can%20create%20an%20application%20do%20to%20that.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CDIV%20style%3D%22background-color%3A%20%23eeeeff%3B%20padding-left%3A%2030px%3B%20width%3A%2060%25%3B%20margin-left%3A%2020%25%3B%22%3EThis%20application%20was%20tested%20in%20iMX27ADS%20but%20should%20to%20work%20on%20iMX27PDK%3C%2FDIV%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EFirst%20execute%20LTIB%20(.%2Fltib%20-c)%20and%20select%20these%20packages%3A%20all%20gstreamer%20plugin%2C%20alsa-utils%20and%20libmad.%3C%2FP%3E%3CP%3ECreate%20your%20file%20code%20(i.e.%3A%20playvideo.c)%3A%3C%2FP%3E%3CBLOCKQUOTE%3E%23include%20%3CGST%3E%0A%3CP%3E%23include%20%3CGLIB.H%3E%20%23include%20%3CSTRING.H%3E%3C%2FSTRING.H%3E%3C%2FGLIB.H%3E%3C%2FP%3E%0A%0A%0A%3CBR%20%2F%3E%3CBR%20%2F%3E%0A%3CP%3Estatic%20GstElement%20*source%2C%20*demuxer%2C%20*vdqueue%2C%20*adqueue%2C%20*vdsink%2C%20*adsink%2C%20*decvd%2C%20*decad%3B%3CBR%20%2F%3E%3CBR%20%2F%3Evoid%20on_pad_added%20(GstElement%20*element%2C%20GstPad%20*pad)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_debug%20(%22Signal%3A%20pad-added%22)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20GstCaps%20*caps%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20GstStructure%20*str%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20caps%20%3D%20gst_pad_get_caps%20(pad)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_assert%20(caps%20!%3D%20NULL)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20str%20%3D%20gst_caps_get_structure%20(caps%2C%200)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_assert%20(str%20!%3D%20NULL)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20if%20(g_strrstr%20(gst_structure_get_name%20(str)%2C%20%22video%22))%20%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_debug%20(%22Linking%20video%20pad%20to%20dec_vd%22)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2F%2F%20Link%20it%20actually%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20GstPad%20*targetsink%20%3D%20gst_element_get_pad%20(decvd%2C%20%22sink%22)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_assert%20(targetsink%20!%3D%20NULL)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20gst_pad_link%20(pad%2C%20targetsink)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20gst_object_unref%20(targetsink)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20if%20(g_strrstr%20(gst_structure_get_name%20(str)%2C%20%22audio%22))%20%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_debug%20(%22Linking%20audio%20pad%20to%20dec_ad%22)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2F%2F%20Link%20it%20actually%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20GstPad%20*targetsink%20%3D%20gst_element_get_pad%20(decad%2C%20%22sink%22)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_assert%20(targetsink%20!%3D%20NULL)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20gst_pad_link%20(pad%2C%20targetsink)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20gst_object_unref%20(targetsink)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20gst_caps_unref%20(caps)%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%3CBR%20%2F%3Estatic%20gboolean%3CBR%20%2F%3Ebus_call%20(GstBus%26nbsp%3B%26nbsp%3B%26nbsp%3B%20*bus%2C%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20GstMessage%20*msg%2C%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20gpointer%26nbsp%3B%26nbsp%3B%26nbsp%3B%20data)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%26nbsp%3B%20GMainLoop%20*loop%20%3D%20(GMainLoop%20*)%20data%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20switch%20(GST_MESSAGE_TYPE%20(msg))%20%7B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20case%20GST_MESSAGE_EOS%3A%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_print%20(%22End%20of%20stream%5Cn%22)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_main_loop_quit%20(loop)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20break%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20case%20GST_MESSAGE_ERROR%3A%20%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20gchar%26nbsp%3B%20*debug%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20GError%20*error%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20gst_message_parse_error%20(msg%2C%20%26amp%3Berror%2C%20%26amp%3Bdebug)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_free%20(debug)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_printerr%20(%22Error%3A%20%25s%5Cn%22%2C%20error-%26gt%3Bmessage)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_error_free%20(error)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_main_loop_quit%20(loop)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20break%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20default%3A%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20break%3B%3CBR%20%2F%3E%26nbsp%3B%20%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20return%20TRUE%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%3CBR%20%2F%3Eint%3CBR%20%2F%3Emain%20(int%26nbsp%3B%20argc%2C%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20char%20*argv%5B%5D)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%26nbsp%3B%20GMainLoop%20*loop%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20GstElement%20*pipeline%3B%3CBR%20%2F%3E%26nbsp%3B%20GstBus%20*bus%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20Initialisation%20*%2F%3CBR%20%2F%3E%26nbsp%3B%20gst_init%20(%26amp%3Bargc%2C%20%26amp%3Bargv)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20loop%20%3D%20g_main_loop_new%20(NULL%2C%20FALSE)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20Check%20input%20arguments%20*%2F%3CBR%20%2F%3E%26nbsp%3B%20if%20(argc%20!%3D%202)%20%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_printerr%20(%22Usage%3A%20%25s%20%3CVIDEO%20h264%3D%22%22%20filename%3D%22%22%3E%5Cn%22%2C%20argv%5B0%5D)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20return%20-1%3B%3CBR%20%2F%3E%26nbsp%3B%20%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20Create%20gstreamer%20elements%20*%2F%3CBR%20%2F%3E%26nbsp%3B%20pipeline%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3D%20gst_pipeline_new%20(%22media-player%22)%3B%3CBR%20%2F%3E%26nbsp%3B%20source%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3D%20gst_element_factory_make%20(%22filesrc%22%2C%22file-source%22)%3B%3CBR%20%2F%3E%26nbsp%3B%20demuxer%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3D%20gst_element_factory_make%20(%22mfw_mp4demuxer%22%2C%22avi-demuxer%22)%3B%3CBR%20%2F%3E%26nbsp%3B%20decvd%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3D%20gst_element_factory_make%20(%22mfw_vpudecoder%22%2C%20%22video-decoder%22)%3B%3CBR%20%2F%3E%26nbsp%3B%20decad%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3D%20gst_element_factory_make%20(%22mad%22%2C%20%22mp3-decoder%22)%3B%3CBR%20%2F%3E%26nbsp%3B%20vdsink%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3D%20gst_element_factory_make%20(%22mfw_v4lsink%22%2C%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22video-sink%22)%3B%3CBR%20%2F%3E%26nbsp%3B%20vdqueue%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3D%20gst_element_factory_make%20(%22queue%22%2C%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22video-queue%22)%3B%3CBR%20%2F%3E%26nbsp%3B%20adqueue%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3D%20gst_element_factory_make%20(%22queue%22%2C%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22audio-queue%22)%3B%3CBR%20%2F%3E%26nbsp%3B%20adsink%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3D%20gst_element_factory_make%20(%22fakesink%22%2C%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22audio-sink%22)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20g_object_set%20(decvd%2C%20%22codec-type%22%2C%20%22std_avc%22%2C%20NULL)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20if%20(!pipeline%20%7C%7C%20!source%20%7C%7C%20!demuxer%20%7C%7C%20!decvd%20%7C%7C%20!decad%20%7C%7C%20!vdsink%20%7C%7C%20!vdqueue%20%7C%7C%20!adqueue%20%7C%7C%20!adsink)%20%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20g_printerr%20(%22One%20element%20could%20not%20be%20created.%20Exiting.%5Cn%22)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20return%20-1%3B%3CBR%20%2F%3E%26nbsp%3B%20%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20Set%20up%20the%20pipeline%20*%2F%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20we%20set%20the%20input%20filename%20to%20the%20source%20element%20*%2F%3CBR%20%2F%3E%26nbsp%3B%20g_object_set%20(G_OBJECT%20(source)%2C%20%22location%22%2C%20argv%5B1%5D%2C%20NULL)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20we%20add%20a%20message%20handler%20*%2F%3CBR%20%2F%3E%26nbsp%3B%20bus%20%3D%20gst_pipeline_get_bus%20(GST_PIPELINE%20(pipeline))%3B%3CBR%20%2F%3E%26nbsp%3B%20gst_bus_add_watch%20(bus%2C%20bus_call%2C%20loop)%3B%3CBR%20%2F%3E%26nbsp%3B%20gst_object_unref%20(bus)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20we%20add%20all%20elements%20into%20the%20pipeline%20*%2F%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20file-source%20%7C%20ogg-demuxer%20%7C%20vorbis-decoder%20%7C%20converter%20%7C%20alsa-output%20*%2F%3CBR%20%2F%3E%26nbsp%3B%20gst_bin_add_many%20(GST_BIN%20(pipeline)%2C%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20source%2C%20demuxer%2C%20decvd%2C%20decad%2C%20adqueue%2C%20vdqueue%2C%20vdsink%2C%20adsink%2C%26nbsp%3B%20NULL)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20we%20link%20the%20elements%20together%20*%2F%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20file-source%20-%26gt%3B%20ogg-demuxer%20~%26gt%3B%20vorbis-decoder%20-%26gt%3B%20converter%20-%26gt%3B%20alsa-output%20*%2F%3CBR%20%2F%3E%26nbsp%3B%20gst_element_link%20(source%2C%20demuxer)%3B%3CBR%20%2F%3E%26nbsp%3B%20gst_element_link%20(decvd%2C%20vdqueue)%3B%3CBR%20%2F%3E%26nbsp%3B%20gst_element_link%20(vdqueue%2C%20vdsink)%3B%3CBR%20%2F%3E%26nbsp%3B%20%2F%2Fgst_element_link%20(decad%2C%20adqueue)%3B%3CBR%20%2F%3E%26nbsp%3B%20gst_element_link%20(adqueue%2C%20adsink)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20g_signal_connect%20(demuxer%2C%20%22pad-added%22%2C%20G_CALLBACK%20(on_pad_added)%2C%20NULL)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20note%20that%20the%20demuxer%20will%20be%20linked%20to%20the%20decoder%20dynamically.%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20The%20reason%20is%20that%20Ogg%20may%20contain%20various%20streams%20(for%20example%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20audio%20and%20video).%20The%20source%20pad(s)%20will%20be%20created%20at%20run%20time%2C%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20by%20the%20demuxer%20when%20it%20detects%20the%20amount%20and%20nature%20of%20streams.%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Therefore%20we%20connect%20a%20callback%20function%20which%20will%20be%20executed%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20when%20the%20%22pad-added%22%20is%20emitted.*%2F%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20Set%20the%20pipeline%20to%20%22playing%22%20state*%2F%3CBR%20%2F%3E%26nbsp%3B%20g_print%20(%22Now%20playing%3A%20%25s%5Cn%22%2C%20argv%5B1%5D)%3B%3CBR%20%2F%3E%26nbsp%3B%20gst_element_set_state%20(pipeline%2C%20GST_STATE_PLAYING)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20Iterate%20*%2F%3CBR%20%2F%3E%26nbsp%3B%20g_print%20(%22Running...%5Cn%22)%3B%3CBR%20%2F%3E%26nbsp%3B%20g_main_loop_run%20(loop)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20%2F*%20Out%20of%20the%20main%20loop%2C%20clean%20up%20nicely%20*%2F%3CBR%20%2F%3E%26nbsp%3B%20g_print%20(%22Returned%2C%20stopping%20playback%5Cn%22)%3B%3CBR%20%2F%3E%26nbsp%3B%20gst_element_set_state%20(pipeline%2C%20GST_STATE_NULL)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20g_print%20(%22Deleting%20pipeline%5Cn%22)%3B%3CBR%20%2F%3E%26nbsp%3B%20gst_object_unref%20(GST_OBJECT%20(pipeline))%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%20return%200%3B%3CBR%20%2F%3E%7D%3C%2FVIDEO%3E%3C%2FP%3E%0A%0A%0A%0A%3C%2FGST%3E%3C%2FBLOCKQUOTE%3E%3CP%3ECreate%20a%20directory%20inside%20your%20ltib%20directory%20to%20compile%20your%20source%20code%3A%3C%2FP%3E%3CP%3E%24%20mkdir%20~%2Fyour-ltib-dir%2Frpm%2FBUILD%2Fgst%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EEnter%20on%20LTIB%20shell%20mode%3A%3C%2FP%3E%3CP%3E%24%20.%2Fltib%20-m%20shell%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EEntering%20ltib%20shell%20mode%2C%20type%20'exit'%20to%20quit%3C%2FP%3E%3CP%3ELTIB%26gt%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EEnter%20in%20your%20application%20dir%3A%3C%2FP%3E%3CP%3ELTIB%26gt%3B%20cd%20rpm%2FBUILD%2Fgst%2F%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ECompile%20your%20application%3A%3C%2FP%3E%3CP%3ELTIB%26gt%3B%20gcc%20-Wall%20%24(pkg-config%20--cflags%20--libs%20gstreamer-0.10)%20playvideo.c%20-o%20playvideo%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIf%20everything%20worked%20file%20you%20will%20get%20a%20%22playvideo%22%20arm%20binary%3A%3C%2FP%3E%3CP%3ELTIB%26gt%3B%20file%20playvideo%3C%2FP%3E%3CP%3Eplayvideo%3A%20ELF%2032-bit%20LSB%20executable%2C%20ARM%2C%20version%201%20(SYSV)%2C%20for%20GNU%2FLinux%202.6.14%2C%20dynamically%20linked%20(uses%20shared%20libs)%2C%20not%20stripped%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ENow%20just%20copy%20it%20to%20~%2Fyour-ltib-dir%2Frootfs%2Fhome.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EStart%20your%20board%20using%20this%20rootfs%20and%20execute%3A%3C%2FP%3E%3CP%3Eroot%40freescale%20~%24%20cd%20%2Fhome%2F%3C%2FP%3E%3CP%3Eroot%40freescale%20%2Fhome%24%20.%2Fplayvideo%20your-file-h264-mp3.avi%3C%2FP%3E%3CP%3ENow%20playing%3A%20your-file-h264-mp3.avi%3C%2FP%3E%3CP%3ERunning...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1104012%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20All%20Boards%20Creating%20App%20Video%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1104012%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Jesseg%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EWhere%20I%20can%20get%20mfw_mp3_encode%2Fdecode%20source%20code%20and%20how%20to%20add%20them%20into%20my%20ltib%20environment%2C%20I%20am%20using%20imx27ads%20board%20and%20BSP%20REL2%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBest%20regards.%3C%2FP%3E%3C%2FLINGO-BODY%3E
No ratings
Version history
Last update:
‎08-06-2012 12:01 PM
Updated by: