显示标签为“gstreamer”的博文。显示所有博文
显示标签为“gstreamer”的博文。显示所有博文

2011年1月4日星期二

Gstreamer basic Knowledge 2nd

This is my second time to read GStreamer Application Development Manual

Record something important


  • Element:

    Element is an object that can send and/or receive data, also is the most important class of objects in GStreamer
Type Details Number of pads
Source elements do not accept data, only generate data a source pad
Filters and filter-like elements operate the data at least one input and one output pads
Sink elements accept data and do not produce anything a sink pad
  • Create an element(two methods)
    1. gst_element_factory_make
    2. gst_element_factory_find + gst_element_factory_create

    • gst_init has to be called frist
    • When you don’t need the element anymore, you need to unref it using gst_object_unref ()

      The following example isthe simplest way to create an element using gst_element_factory_make
      #include <gst/gst.h>
      int main (int argc, char *argv[])
      {
       GstElement *element;
       /* init GStreamer */
       gst_init (&argc, &argv);
       /* create element */
       element = gst_element_factory_make ("fakesrc", "source");
       if (!element) {
        g_print ("Failed to create element of type ’fakesrc’\n");
        return -1;
       }
       gst_object_unref (GST_OBJECT (element));
       return 0;
      }
      

  • Pad:

    Pad is element’s input or output

    A pad can have any of three availabilities:always, sometimes and on request

  • Bin & Pipeline:

    A bin is a container elements

    A pipeline is a special subtype of a bin that allows scheduling of the containing elements

  • Bus:

    A bus is a simple system that takes care of forwarding messages from the pipeline threads to an application in its own thread context

    Every pipeline contains a bus by default

  • Use a bus(two methods)
    1. Run a main loop and attach some kind of watch to the bus using gst_bus_add_watch () or gst_bus_add_signal_watch ()
    2. Get the messages on the bus using gst_bus_peek () and/or gst_bus_poll ()

      Message types:
Name Details
Error, warning and information notifications those are used by elements if a message should be shown to the user about the state of the pipeline
End-of-stream notification emitted when the stream has ended
Tags emitted when metadata was found in the stream
State-changes emitted after a successful state change
Buffering emitted during caching of network-streams
Element messages these are special messages that are unique to certain elements and usually represent additional features
Application-specific messages any information on those can be extracted by getting the message |structure (see above) and reading its fields
  • Buffers & Events:

    The data flowing through a pipeline consists of a combination of buffers and events
    • Buffers contain the actual media data
    • Events contain control information, such as seeking information and end-of-stream notifiers

  • A buffer consists:
Number Name Description
1 Poniter A pointer to a piece of memory
2 Size The size of the memory
3 Timestamp A timestamp for the buffer
4 refcount A refcount that indicates how many elements are using this buffer, This refcount will be used to destroy the buffer when no element has a reference to it
5 Flags Buffer flags

Get more information here

2010年12月28日星期二

android gstreamer debug information can not work

在android上面做一些gstreamer的工作
尝试显示出gstreamer自己的调试信息
在android模拟器上面运行:

gst-launch-0.10 --gst-debug-level=1 audiotestsrc ! audioflingersink

结果显示:

Could not open converter from 'ASCII' to 'UTF-8'

调试发现:libiconv在android上面已经移除了

在gconvert.c g_convert()中添加了以上代码自己转换,将ASCII 转换成 UTF-8,debug 消息就可以打印出来了

//--> allen add for testing
printf("allen in gconvert.c g_convert() %s %d\n", str, len);
gsize retval;
gchar *utf;
gsize utfmax;
if (len < 0)
{
 len = strlen (str);
}
utfmax = 2 * (len + 1);
printf("utfmax: %d\n", utfmax);
utf = g_malloc (utfmax);
for (retval = 0; *str && utfmax > 1; utfmax -= 2, retval += 2)
{
 *(utf + retval/2) = *(str + retval/2);
 *(utf + retval/2 + 1) = 0;
}
if (utfmax > 0)
{
 *utf = *str;
 ++retval;
}
if (bytes_read)
 *bytes_read = len + 1;
if (bytes_written)
 *bytes_written = retval;
 printf("allen in gconvert.c g_convert() %s %d\n", utf, utfmax);
 return utf;
 //<--end

Gstreamer Why Can't Use the New Added Plugins

* What's The Problem
  • Can't use the plugins added by yourself
  • When you use 'gst-inspect-0.10', and see the informations as below:
  • GStreamer-WARNING **: Failed to load plugin '/system/plugins/libgstvideoflip.so': Cannot load library: alloc_info[269]: 1254 too many libraries when loading libgstvideoflip.so
* Why does This Happen
  • When you update the plugins, but the registry file don't update.
* How to Solve
  • 1. Use this command "export GST_REGISTRY_UPDATE=yes"
  • 2. And also use this command "export GST_REGISTRY /sdcard/reg.bin"
  • 3. Try 'gst-inspect-0.10' again
  • After the 3 steps, the registry file named reg.bin is updated.
  • Now, you can use the new plugins.

How to Use Gstreamer Debug System

How to Use Gstreamer Debug System

     1.To see the debug information of all the elements use :
       gst-launch-0.10 -–gst-debug-level=3 audiotestsrc ! audioflingersink
     2.To see the debug information of the audioflingersink use :
       gst-launch-0.10 -–gst-debug=audioflingersink:3 audiotestsrc ! audioflingersink
   
You can choose the debug level from 1 to 5.