[gst-devel] gstreamer in custom applications

Martin Eikermann eikermann at gmx.net
Sun Jan 4 01:11:00 CET 2004


Benjamin Otte wrote:

>>2. How do I draw my own stuff over the video? As far as I understand, I
>>   have to write my own plugin. Are there examples which show how to do
>>   such things? I need to implement something like an on-screen display
>>   where a user can choose something from a menu. Maybe someone already
>>   did something similar?
>>
>>    
>>
>There's something, but nothing really nice. The textoverlay element is an
>example.
>I intend to work on that for my TV viewer though.
>  
>
Hi,

the attached plugin might be interesting for you. It features an
OnScreenDisplay over
RGB32 or YUV Video. We use it in an project from our university in a
pipeline like this:

   filesrc location=abc.mpg ! mpegdemux name=demux demux. ! { queue !
mpeg2dec ! osd ! xvideosink }
   demux. ! { queue ! mad ! osssink }

Our app then calls some code which equivalent to the condensed source
code at the end of this mail.
The OSD-Plugin works fine for us. There might be some issues related to
the fact that we try to follow
gstreamer cvs head. While waiting for some stabilisation in cvs head, we
use cvs head from ~Nov. 19th.

So the plugin won't work with
   - new caps system
   - old plugin init system

However I don't think it is a big issue to backport the plugin to 0.6.x
or make it working with cvs head
(for the latter only the new caps system comes into my mind). The major
work in the plugin was MMX
optimisation (thx to Torsten Bresser) and image scaling (osd -> video size).

Greets,
   Martin



-- Code Sample --

/* Sample Code to demonstrate how to use the osd plugin */
/* adjust it to your source code */
#include "gstosdparam.h"
#define OSD_WIDTH  800
#define OSD_HEIGHT 600
guchar *osd_byte_buffer = NULL;
GstElement *osd = NULL;

/* Set a sample OSD from file. The file is expected to contain
      an OSD_WIDTH*OSD_HEIGHT rgb32 image (raw) */
void set_osd_image()
{
   FILE *fd;
   unsigned int i;
   GstOsdParam *osdParam;

   g_return_if_fail(priv->osd != NULL);

   fd = fopen("osd.raw", "r");
   if (osd_byte_buffer == NULL)
     osd_byte_buffer = g_malloc(OSD_WIDTH * OSD_HEIGHT * 4);

   for(i = 0; i < OSD_WIDTH * OSD_HEIGHT * 4; i++)
   {
     osd_byte_buffer[i] = getc(fd);
   }

   fclose(fd);

   osdParam = g_malloc(sizeof(GstOsdParam));
   osdParam->width = OSD_WIDTH;
   osdParam->height = OSD_HEIGHT;
   osdParam->first_row = 0;
   osdParam->rows_count = OSD_HEIGHT;
   osdParam->is_totally_opaque = FALSE;
   osdParam->rgb_buffer = osd_byte_buffer;

   g_object_set (G_OBJECT (osd), "osdbuffer", osdParam, NULL);

   g_free(osdParam);
}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: osd.zip
Type: application/x-zip-compressed
Size: 11763 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20040104/2d22529e/attachment.bin>


More information about the gstreamer-devel mailing list