gstreamer_test_apps/gstplayer/src/SymGstreamer.cpp
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
       
     3 *
       
     4 * This library is free software; you can redistribute it and/or
       
     5 * modify it under the terms of the GNU Lesser General Public
       
     6 * License as published by the Free Software Foundation; either
       
     7 * version 2 of the License, or (at your option) any later version.
       
     8 *
       
     9 * This library is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    12 * Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public
       
    15 * License along with this library; if not, write to the
       
    16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    17 * Boston, MA 02111-1307, USA.
       
    18 *
       
    19 * Description:
       
    20 *
       
    21 */
       
    22 
       
    23 #include "gstreamer.h"
       
    24 #include "GlibEventHandler.h"
       
    25 #include <avkon.hrh>
       
    26 #include <aknnotewrappers.h>
       
    27 #include <StringLoader.h>
       
    28 #include <gstplayer.rsg>
       
    29 #include <CAknMemorySelectionDialog.h>
       
    30 #include <e32base.h>
       
    31 #include <stdlib.h>
       
    32 #include <mmf/server/sounddevice.h>
       
    33 
       
    34 #include "gstplayerappview.h"
       
    35 
       
    36 GstElement *pipeline, *source, *wavparse,*sink,*decoder,*conv,*resample,*record,*fakesink,*filesink,*encoder,*filter,*wavenc, *amrmux, *aacenc, *mp4mux;
       
    37 GstBus *bus;
       
    38 GstCaps* caps;
       
    39 GstState current,pending;
       
    40 char carray[1024];
       
    41 
       
    42 CGSTPlayerAppView *iGstView;
       
    43 
       
    44 GstPad *dssinkpad;
       
    45 GstCaps *dssinkcap;
       
    46 GstPad *dssrcpad;
       
    47 GstCaps *dssrccap;
       
    48 GstStructure *str;
       
    49 
       
    50 gboolean negcaps = FALSE;
       
    51 
       
    52 static gboolean print_field (GQuark field, const GValue *value, gpointer pfx);
       
    53 static void print_caps (const GstCaps *caps, const gchar *pfx);
       
    54 
       
    55 
       
    56 
       
    57 static void
       
    58 cb_raw_playback_handoff (GstElement *src, GstBuffer *buffer, GstPad *pad,
       
    59         gpointer user_data)
       
    60     {
       
    61     static gint readbytes = 0;
       
    62     static gboolean eofReached = FALSE;
       
    63 
       
    64     size_t readsize;
       
    65     gint size;
       
    66     FILE *f;
       
    67     GstCaps *bufCaps;
       
    68     if ( eofReached == TRUE )
       
    69         {
       
    70         //gst_element_set_state (pipeline, GST_STATE_NULL);
       
    71        // gst_object_unref (GST_OBJECT (pipeline));
       
    72         if ( gst_element_send_event (src, gst_event_new_eos ()) == TRUE )
       
    73             {
       
    74             g_print ("posted eos");
       
    75            }
       
    76      
       
    77        else
       
    78            {
       
    79             //g_print ("unable to post eos");
       
    80           }
       
    81        return;
       
    82        }
       
    83 
       
    84     readsize = 0;
       
    85     f = fopen (carray, "r");
       
    86     eofReached = TRUE;
       
    87     if ( fseek(f, readbytes, 0) == 0 )
       
    88         {
       
    89         readsize = fread (GST_BUFFER_DATA (buffer),1,GST_BUFFER_SIZE (buffer),f);
       
    90         eofReached = FALSE;
       
    91         GST_BUFFER_SIZE (buffer) = readsize;
       
    92         }
       
    93     fclose(f);
       
    94 
       
    95     size = GST_BUFFER_SIZE (buffer);
       
    96     readbytes += readsize;
       
    97     if ( (readsize < size) || (readsize == 0) )
       
    98         {
       
    99         eofReached = TRUE;
       
   100         }
       
   101     
       
   102     bufCaps = gst_caps_new_simple ("audio/x-raw-int",
       
   103               "width", G_TYPE_INT, 16,
       
   104               "depth", G_TYPE_INT, 16,
       
   105               "signed",G_TYPE_BOOLEAN, TRUE,
       
   106               "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   107               "rate", G_TYPE_INT, 8000,
       
   108               "channels", G_TYPE_INT, 1, NULL);
       
   109     
       
   110     gst_buffer_set_caps(buffer,bufCaps);
       
   111 
       
   112     }
       
   113 
       
   114 static void
       
   115 cb_play_mp3_handoff (GstElement *fakesrc,
       
   116         GstBuffer  *buffer,
       
   117         GstPad     *pad,
       
   118         gpointer    user_data)
       
   119 {
       
   120 GstCaps *bufCaps;
       
   121   static gint readbytes = 0;
       
   122   size_t readsize = 0;
       
   123   int size = GST_BUFFER_SIZE (buffer);
       
   124   
       
   125   FILE *f = fopen (carray, "r");
       
   126   fseek(f,readbytes,0);
       
   127   readsize = fread(GST_BUFFER_DATA (buffer),1,GST_BUFFER_SIZE (buffer),f);
       
   128   readbytes += readsize;
       
   129   GST_BUFFER_SIZE (buffer) = readsize;
       
   130   if(readsize == 0)
       
   131       {
       
   132       gst_element_send_event(fakesrc,gst_event_new_eos());
       
   133       }
       
   134   fclose(f);
       
   135  
       
   136 }
       
   137 static void
       
   138 cb_record_raw_handoff (GstElement *fakesrc,
       
   139         GstBuffer  *buffer,
       
   140         GstPad     *pad,
       
   141         gpointer    user_data)
       
   142 {
       
   143   int size = GST_BUFFER_SIZE (buffer);
       
   144   //g_print ("[%u]", size);
       
   145   FILE *f = fopen (carray, "a");
       
   146   fwrite(GST_BUFFER_DATA (buffer),1,GST_BUFFER_SIZE (buffer),f);
       
   147   fclose(f);
       
   148 }
       
   149 
       
   150 
       
   151 static gboolean
       
   152 bus_call (GstBus     *bus,
       
   153           GstMessage *msg,
       
   154           gpointer    data)
       
   155 {
       
   156   switch (GST_MESSAGE_TYPE (msg)) {
       
   157     case GST_MESSAGE_EOS:
       
   158         gst_element_set_state (pipeline, GST_STATE_NULL);
       
   159         gst_object_unref (GST_OBJECT (pipeline));
       
   160       break;
       
   161     case GST_MESSAGE_ERROR: {
       
   162       gchar *debug;
       
   163       GError *err;
       
   164       gst_message_parse_error (msg, &err, &debug);
       
   165       g_free (debug);
       
   166       g_print ("Error: %s\n", err->message);
       
   167       g_error_free (err);
       
   168       break;
       
   169     }
       
   170     default:
       
   171       break;
       
   172   }
       
   173 
       
   174   return TRUE;
       
   175 }
       
   176 
       
   177 
       
   178 static void 
       
   179 new_pad_cb (GstElement *wavparse, GstPad *new_pad, gpointer pipeline)
       
   180  {
       
   181    //GstElement *sink,*conv,*resample;
       
   182    gst_element_set_state ((_GstElement *)pipeline, GST_STATE_PAUSED);
       
   183    sink = gst_element_factory_make ("devsoundsink", "sink");
       
   184    conv = gst_element_factory_make ("audioconvert", "audioconvert");
       
   185   	if (!conv) {
       
   186     	g_print ("could not create \"audioconvert\" element!");
       
   187     	return;
       
   188   		}
       
   189    resample = gst_element_factory_make ("audioresample", "audioresample");
       
   190   	if (!resample) {
       
   191     	g_print ("could not create \"audioresample\" element!");
       
   192     	return ;
       
   193   		}
       
   194    gst_bin_add_many(GST_BIN (pipeline), conv, resample, sink, NULL);
       
   195    
       
   196   // if (!gst_element_link (wavparse, sink))
       
   197      // g_error ("link(wavparse, sink) failed!\n");
       
   198      
       
   199  	if(! gst_element_link_many (wavparse,conv, resample, sink, NULL))
       
   200   		g_print ("link(wavparse,conv,remaple sink) failed!\n");  
       
   201  
       
   202    	gst_element_set_state ((_GstElement *)pipeline, GST_STATE_PLAYING);
       
   203  }
       
   204 
       
   205  #define FILENAME 1024
       
   206  int GstreamerNew(TFileName filename)
       
   207  {
       
   208   size_t ret;
       
   209   
       
   210   ret = wcstombs(carray, (const wchar_t *)filename.PtrZ(), FILENAME);
       
   211   int file_type=0;
       
   212   
       
   213   
       
   214   
       
   215   	char *p;
       
   216 	p = strrchr(carray, '.');
       
   217 
       
   218 	if ((p != NULL) && (strcmp(p, ".mp3") == 0))
       
   219 	{
       
   220 	file_type=2;	
       
   221 	}
       
   222 	else if ((p != NULL) && (strcmp(p, ".wav") == 0))
       
   223 	{
       
   224 	file_type=1;	
       
   225 	}
       
   226     else if ((p != NULL) && (strcmp(p, ".raw") == 0))
       
   227     {
       
   228     file_type=3;    
       
   229     }
       
   230     else if ((p != NULL) && (strcmp(p, ".amr") == 0))
       
   231     {
       
   232     file_type=4;    
       
   233     }
       
   234     else if ((p != NULL) && (strcmp(p, ".g711") == 0))
       
   235     {
       
   236     file_type=5;    
       
   237     }
       
   238     else if ((p != NULL) && (strcmp(p, ".g729") == 0))
       
   239     {
       
   240     file_type=6;    
       
   241     }
       
   242     else if ((p != NULL) && (strcmp(p, ".lbc") == 0))
       
   243     {
       
   244     file_type=7;    
       
   245     }
       
   246 	else
       
   247 		return -1;
       
   248 	
       
   249 	if(file_type==1)
       
   250 	{
       
   251 		gst_play_wave();
       
   252 	}
       
   253 	else if(file_type==2)
       
   254 	{
       
   255 		gst_play_mp3();
       
   256 	}
       
   257     else if(file_type==3)
       
   258     {
       
   259         gst_play_raw();
       
   260     }
       
   261     else if(file_type==4)
       
   262     {
       
   263         gst_play_amr();
       
   264     }
       
   265     else if(file_type==5)
       
   266     {
       
   267         gst_play_g711();
       
   268     }
       
   269     else if(file_type==6)
       
   270     {
       
   271         gst_play_g729();
       
   272     }
       
   273     else if(file_type==7)
       
   274     {
       
   275         gst_play_ilbc();
       
   276     }
       
   277 
       
   278 	else
       
   279 	{
       
   280 		return 0;
       
   281 	}
       
   282  } 
       
   283  
       
   284  
       
   285 int gst_play_mp3()
       
   286 {
       
   287  /* create elements */
       
   288  gboolean link_ok;
       
   289  
       
   290  pipeline = gst_pipeline_new ("pipeline");
       
   291  source = gst_element_factory_make ("filesrc", "filesrc");
       
   292  //sink = gst_element_factory_make ("fakesink", "sink");
       
   293  sink = gst_element_factory_make ("devsoundsink", "sink");
       
   294 
       
   295  caps = gst_caps_new_simple ("audio/mp3",
       
   296               "width", G_TYPE_INT, 16,
       
   297               "depth", G_TYPE_INT, 16,
       
   298               "signed",G_TYPE_BOOLEAN, TRUE,
       
   299               "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   300               "rate", G_TYPE_INT, 16000,
       
   301               "channels", G_TYPE_INT, 2, NULL);
       
   302              
       
   303  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
   304  gst_bus_add_watch( bus, bus_call, NULL);
       
   305  gst_object_unref (bus);
       
   306 
       
   307  g_object_set (G_OBJECT (source), "location", carray, NULL);
       
   308 
       
   309  gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
       
   310  
       
   311  //gst_element_link (source, sink);
       
   312  link_ok = gst_element_link_filtered (source, sink, caps);
       
   313 
       
   314  gst_element_set_state (pipeline, GST_STATE_PLAYING);
       
   315 
       
   316  return 0;  
       
   317 }
       
   318  
       
   319  int gst_play_wave()
       
   320  {
       
   321     /* create elements */
       
   322   pipeline = gst_pipeline_new ("pipeline");
       
   323   source = gst_element_factory_make ("filesrc", "pavsrc");
       
   324   wavparse = gst_element_factory_make ("wavparse", "parse");
       
   325  
       
   326   /* set filename property on the file source */
       
   327   g_object_set (G_OBJECT (source), "location", carray, NULL);
       
   328   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
   329   gst_bus_add_watch (bus, bus_call, NULL);
       
   330   gst_object_unref (bus);
       
   331   gst_bin_add_many (GST_BIN (pipeline), source, wavparse, NULL);
       
   332   if (!gst_element_link (source, wavparse))
       
   333      g_error ("link(src, wavparse) failed!\n");
       
   334 
       
   335   
       
   336   g_signal_connect (wavparse, "pad-added", G_CALLBACK (new_pad_cb),pipeline);
       
   337     
       
   338   gst_element_set_state (pipeline, GST_STATE_PLAYING); 
       
   339   return 0; 
       
   340  }
       
   341  
       
   342  int gst_record_wav()
       
   343     {
       
   344      
       
   345      iGstView->DrawText(_L("Recording Wave"),KRgbBlack);
       
   346 
       
   347     /* create a new bin to hold the elements */
       
   348     pipeline = gst_pipeline_new("pipeline");
       
   349 
       
   350     record = gst_element_factory_make("devsoundsrc", "record_audio");
       
   351     if (!record)
       
   352         {
       
   353         g_print("could not create \"record\" element!");
       
   354         return -1;
       
   355         }
       
   356     //g_object_set (G_OBJECT (record), "num-buffers", 5000 , NULL);
       
   357     filesink = gst_element_factory_make("filesink", "filesink");
       
   358     if (!filesink)
       
   359         {
       
   360         g_print("could not create \"filesink\" element!");
       
   361         return -1;
       
   362         }
       
   363 
       
   364     wavenc = gst_element_factory_make("wavenc", "wavencoder");
       
   365     if (!wavenc)
       
   366         {
       
   367         g_print("could not create \"wavenc\" element!");
       
   368         return -1;
       
   369         }
       
   370 
       
   371     _LIT(KFILENAME,"c:\\data\\test.wav");
       
   372     TFileName fn;
       
   373     fn.Append(KFILENAME);
       
   374     TInt ret;
       
   375     // char carray[FILENAME];
       
   376     ret = wcstombs(carray, (const wchar_t *)fn.PtrZ(), FILENAME);
       
   377 
       
   378     g_object_set(G_OBJECT (filesink), "location", carray, NULL);
       
   379     bus = gst_pipeline_get_bus(GST_PIPELINE (pipeline));
       
   380     gst_bus_add_watch(bus, bus_call, NULL);
       
   381     gst_object_unref(bus);
       
   382 
       
   383     /* add objects to the main pipeline */
       
   384     gst_bin_add_many(GST_BIN (pipeline),record,wavenc,filesink, NULL);
       
   385 
       
   386     /* link the elements */
       
   387     //gst_element_link_many(record, wavenc,filesink, NULL);
       
   388     caps = gst_caps_new_simple ("audio/x-raw-int",
       
   389               "width", G_TYPE_INT, 16,
       
   390               "depth", G_TYPE_INT, 16,
       
   391               "signed",G_TYPE_BOOLEAN, TRUE,
       
   392               "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   393               "rate", G_TYPE_INT, 16000,
       
   394               "channels", G_TYPE_INT, 1, NULL);
       
   395     
       
   396     gst_element_link_filtered (record, wavenc, caps);
       
   397     gst_element_link (wavenc, filesink);
       
   398     gst_caps_unref (caps);
       
   399     iGstView->DrawText(_L("pipeline created\n"),KRgbBlack);
       
   400     /* start recording */
       
   401     gst_element_set_state(pipeline, GST_STATE_PLAYING);
       
   402     iGstView->DrawText(_L("set to play wave file\n"),KRgbBlack);
       
   403     return 0;
       
   404     }
       
   405  
       
   406  
       
   407  int gst_record_aac()
       
   408     {
       
   409      GstPad *qtsinkpad,*aacencsrcpad;
       
   410      iGstView->DrawText(_L("Recording aac"),KRgbBlack);
       
   411 
       
   412     /* create a new bin to hold the elements */
       
   413     pipeline = gst_pipeline_new("pipeline");
       
   414 
       
   415     record = gst_element_factory_make("devsoundsrc", "record_audio");
       
   416     if (!record)
       
   417         {
       
   418         g_print("could not create \"record\" element!");
       
   419         return -1;
       
   420         }
       
   421     //g_object_set (G_OBJECT (record), "num-buffers", 5000 , NULL);
       
   422     filesink = gst_element_factory_make("filesink", "filesink");
       
   423     if (!filesink)
       
   424         {
       
   425         g_print("could not create \"filesink\" element!");
       
   426         return -1;
       
   427         }
       
   428 
       
   429     aacenc = gst_element_factory_make("nokiaaacenc", "nokiaaacenc");
       
   430     if (!aacenc)
       
   431         {
       
   432         g_print("could not create \"aacenc\" element!");
       
   433         return -1;
       
   434         }
       
   435     
       
   436     mp4mux = gst_element_factory_make("mp4mux", "mp4mux");
       
   437     if (!mp4mux)
       
   438         {
       
   439         g_print("could not create \"mp4mux\" element!");
       
   440         return -1;
       
   441         }    
       
   442     //name = gst_pad_get_name( sinkpad );    
       
   443 
       
   444     _LIT(KFILENAME,"c:\\data\\test.mp4");
       
   445     TFileName fn;
       
   446     fn.Append(KFILENAME);
       
   447     TInt ret;
       
   448     // char carray[FILENAME];
       
   449     ret = wcstombs(carray, (const wchar_t *)fn.PtrZ(), FILENAME);
       
   450 
       
   451     g_object_set(G_OBJECT (filesink), "location", carray, NULL);
       
   452     bus = gst_pipeline_get_bus(GST_PIPELINE (pipeline));
       
   453     gst_bus_add_watch(bus, bus_call, NULL);
       
   454     gst_object_unref(bus);
       
   455 
       
   456     /* add objects to the main pipeline */
       
   457     gst_bin_add_many(GST_BIN (pipeline),record,aacenc,mp4mux,filesink, NULL);
       
   458 
       
   459     /* link the elements */
       
   460     //gst_element_link_many(record, aacenc,filesink, NULL);
       
   461     caps = gst_caps_new_simple ("audio/x-raw-int",
       
   462               "width", G_TYPE_INT, 16,
       
   463               "depth", G_TYPE_INT, 16,
       
   464               "signed",G_TYPE_BOOLEAN, TRUE,
       
   465               "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   466               "rate", G_TYPE_INT, 16000,
       
   467               "channels", G_TYPE_INT, 1, NULL);
       
   468     
       
   469     gst_element_link_filtered (record, aacenc, caps);
       
   470     qtsinkpad  = gst_element_get_request_pad( mp4mux, "audio_%d");
       
   471     aacencsrcpad  = gst_element_get_pad( aacenc, "src");  
       
   472     if (gst_pad_link (aacencsrcpad,qtsinkpad) != GST_PAD_LINK_OK) {
       
   473 
       
   474     g_print("gst_pad_link (aacencsrcpad,qtsinkpad) failed");
       
   475     return -1;
       
   476     }       
       
   477     //gst_element_link (aacenc, filesink);
       
   478     gst_element_link (mp4mux, filesink);
       
   479     gst_caps_unref (caps);
       
   480     iGstView->DrawText(_L("pipeline created\n"),KRgbBlack);
       
   481     /* start recording */
       
   482     gst_element_set_state(pipeline, GST_STATE_PLAYING);
       
   483     iGstView->DrawText(_L("set to play aac file\n"),KRgbBlack);
       
   484     return 0;
       
   485     }
       
   486  
       
   487  int gst_record_amr()
       
   488  {
       
   489  iGstView->DrawText(_L("Recording AMR-NB"),KRgbRed);
       
   490 
       
   491    /* create a new bin to hold the elements */
       
   492   pipeline = gst_pipeline_new ("pipeline");
       
   493   
       
   494   //g_print ("pipeline created");
       
   495   record = gst_element_factory_make ("devsoundsrc", "record_audio"); 
       
   496  // encoder = gst_element_factory_make ("wavenc", NULL); 
       
   497   if (!record) {
       
   498     g_print ("could not create \"record\" element!");
       
   499     iGstView->DrawText(_L("Devsound src not available"),KRgbRed);
       
   500     return -1;
       
   501   }
       
   502 
       
   503             
       
   504       amrmux = gst_element_factory_make ("amrmux", "muxer"); 
       
   505  // encoder = gst_element_factory_make ("wavenc", NULL); 
       
   506   if (!amrmux) {
       
   507     g_print ("could not create \"amrmuxer\" element!");
       
   508     iGstView->DrawText(_L("amrmuxer not available"),KRgbRed);
       
   509     return -1;
       
   510   }
       
   511 
       
   512   filesink = gst_element_factory_make("filesink", "filesink");
       
   513       if (!filesink)
       
   514           {
       
   515           g_print("could not create \"filesink\" element!");
       
   516           return -1;
       
   517           }        
       
   518 
       
   519   caps = gst_caps_new_simple ("audio/amr",
       
   520              "width", G_TYPE_INT, 8,
       
   521              "depth", G_TYPE_INT, 8,
       
   522              "signed",G_TYPE_BOOLEAN, TRUE,
       
   523              "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   524              "rate", G_TYPE_INT,  8000,
       
   525              "channels", G_TYPE_INT, 1, NULL);
       
   526   
       
   527   
       
   528   g_object_set (G_OBJECT (record),
       
   529             "blocksize", 1280,
       
   530              NULL);
       
   531   
       
   532   _LIT(KFILENAME,"c:\\data\\recordtest.amr");
       
   533   TFileName fn;
       
   534   fn.Append(KFILENAME);
       
   535   TInt ret;
       
   536   ret = wcstombs(carray, (const wchar_t *)fn.PtrZ(), FILENAME);
       
   537   g_object_set(G_OBJECT (filesink), "location", carray, NULL);
       
   538    
       
   539   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
   540   gst_bus_add_watch (bus, bus_call, NULL);
       
   541   gst_object_unref (bus);
       
   542   
       
   543 
       
   544   /* add objects to the main pipeline */
       
   545   gst_bin_add_many(GST_BIN (pipeline),record,amrmux,filesink , NULL);
       
   546   /* link the elements */
       
   547   gst_element_link_filtered (record, amrmux, caps);
       
   548   
       
   549   gst_element_link( amrmux, filesink );
       
   550   
       
   551   gst_element_set_state (pipeline, GST_STATE_PLAYING);
       
   552   
       
   553   return 0;
       
   554  }
       
   555  
       
   556  int gst_record_g711()
       
   557   {
       
   558     /* create a new bin to hold the elements */
       
   559    pipeline = gst_pipeline_new ("pipeline");
       
   560    
       
   561    //g_print ("pipeline created");
       
   562    record = gst_element_factory_make ("devsoundsrc", "record_audio"); 
       
   563   // encoder = gst_element_factory_make ("wavenc", NULL); 
       
   564    if (!record) {
       
   565      g_print ("could not create \"record\" element!");
       
   566      return -1;
       
   567    }
       
   568 
       
   569    filesink = gst_element_factory_make("filesink", "filesink");
       
   570        if (!filesink)
       
   571            {
       
   572            g_print("could not create \"filesink\" element!");
       
   573            return -1;
       
   574            }
       
   575 
       
   576    caps = gst_caps_new_simple ("audio/x-alaw",
       
   577               "width", G_TYPE_INT, 8,
       
   578               "depth", G_TYPE_INT, 8,
       
   579               "signed",G_TYPE_BOOLEAN, TRUE,
       
   580               "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   581               "rate", G_TYPE_INT,  8000,
       
   582               "channels", G_TYPE_INT, 1, NULL);
       
   583    
       
   584    g_object_set (G_OBJECT (record),
       
   585              "blocksize", 1280,
       
   586               NULL);
       
   587    
       
   588    _LIT(KFILENAME,"c:\\data\\recordtest.g711");
       
   589    TFileName fn;
       
   590    fn.Append(KFILENAME);
       
   591    TInt ret;
       
   592    ret = wcstombs(carray, (const wchar_t *)fn.PtrZ(), FILENAME);
       
   593    g_object_set(G_OBJECT (filesink), "location", carray, NULL);
       
   594     
       
   595    bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
   596    gst_bus_add_watch (bus, bus_call, NULL);
       
   597    gst_object_unref (bus);
       
   598    
       
   599 
       
   600    /* add objects to the main pipeline */
       
   601    gst_bin_add_many(GST_BIN (pipeline),record,filesink , NULL);
       
   602    /* link the elements */
       
   603    gst_element_link_filtered (record, filesink, caps);
       
   604    gst_element_set_state (pipeline, GST_STATE_PLAYING);
       
   605    
       
   606    return 0;
       
   607   }
       
   608  
       
   609  int gst_record_g729()
       
   610   {
       
   611     /* create a new bin to hold the elements */
       
   612    pipeline = gst_pipeline_new ("pipeline");
       
   613    
       
   614    record = gst_element_factory_make ("devsoundsrc", "record_audio"); 
       
   615    if (!record) {
       
   616      g_print ("could not create \"record\" element!");
       
   617      return -1;
       
   618    }
       
   619 
       
   620    filesink = gst_element_factory_make("filesink", "filesink");
       
   621        if (!filesink)
       
   622            {
       
   623            g_print("could not create \"filesink\" element!");
       
   624            return -1;
       
   625            }
       
   626 
       
   627    caps = gst_caps_new_simple ("audio/g729",
       
   628               "width", G_TYPE_INT, 16,
       
   629               "depth", G_TYPE_INT, 16,
       
   630               "signed",G_TYPE_BOOLEAN, TRUE,
       
   631               "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   632               "rate", G_TYPE_INT,  8000,
       
   633               "channels", G_TYPE_INT, 1, NULL);
       
   634    
       
   635    g_object_set (G_OBJECT (record),
       
   636              "blocksize", 1280,
       
   637               NULL);
       
   638    
       
   639    _LIT(KFILENAME,"c:\\data\\recordtest.g729");
       
   640    TFileName fn;
       
   641    fn.Append(KFILENAME);
       
   642    TInt ret;
       
   643    ret = wcstombs(carray, (const wchar_t *)fn.PtrZ(), FILENAME);
       
   644    g_object_set(G_OBJECT (filesink), "location", carray, NULL);
       
   645     
       
   646    bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
   647    gst_bus_add_watch (bus, bus_call, NULL);
       
   648    gst_object_unref (bus);
       
   649    
       
   650 
       
   651    /* add objects to the main pipeline */
       
   652    gst_bin_add_many(GST_BIN (pipeline),record,filesink , NULL);
       
   653    /* link the elements */
       
   654    gst_element_link_filtered (record, filesink, caps);
       
   655    gst_element_set_state (pipeline, GST_STATE_PLAYING);
       
   656    
       
   657    return 0;
       
   658   }
       
   659  
       
   660  int gst_record_ilbc()
       
   661   {
       
   662     /* create a new bin to hold the elements */
       
   663    pipeline = gst_pipeline_new ("pipeline");
       
   664    
       
   665    record = gst_element_factory_make ("devsoundsrc", "record_audio"); 
       
   666    if (!record) {
       
   667      g_print ("could not create \"record\" element!");
       
   668      return -1;
       
   669    }
       
   670 
       
   671    filesink = gst_element_factory_make("filesink", "filesink");
       
   672        if (!filesink)
       
   673            {
       
   674            g_print("could not create \"filesink\" element!");
       
   675            return -1;
       
   676            }
       
   677 
       
   678    caps = gst_caps_new_simple ("audio/ilbc",
       
   679               "width", G_TYPE_INT, 16,
       
   680               "depth", G_TYPE_INT, 16,
       
   681               "signed",G_TYPE_BOOLEAN, TRUE,
       
   682               "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   683               "rate", G_TYPE_INT,  8000,
       
   684               "channels", G_TYPE_INT, 1, NULL);
       
   685    
       
   686    g_object_set (G_OBJECT (record),
       
   687              "blocksize", 1280,
       
   688               NULL);
       
   689    
       
   690    _LIT(KFILENAME,"c:\\data\\recordtest.lbc");
       
   691    TFileName fn;
       
   692    fn.Append(KFILENAME);
       
   693    TInt ret;
       
   694    ret = wcstombs(carray, (const wchar_t *)fn.PtrZ(), FILENAME);
       
   695    g_object_set(G_OBJECT (filesink), "location", carray, NULL);
       
   696     
       
   697    bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
   698    gst_bus_add_watch (bus, bus_call, NULL);
       
   699    gst_object_unref (bus);
       
   700    
       
   701 
       
   702    /* add objects to the main pipeline */
       
   703    gst_bin_add_many(GST_BIN (pipeline),record,filesink , NULL);
       
   704    /* link the elements */
       
   705    gst_element_link_filtered (record, filesink, caps);
       
   706    gst_element_set_state (pipeline, GST_STATE_PLAYING);
       
   707    
       
   708    return 0;
       
   709   }
       
   710 
       
   711  int gst_record_raw()
       
   712  {
       
   713  
       
   714    /* create a new bin to hold the elements */
       
   715   pipeline = gst_pipeline_new ("pipeline");
       
   716   
       
   717   //g_print ("pipeline created");
       
   718   record = gst_element_factory_make ("devsoundsrc", "record_audio"); 
       
   719  // encoder = gst_element_factory_make ("wavenc", NULL); 
       
   720   if (!record) {
       
   721     g_print ("could not create \"record\" element!");
       
   722     return -1;
       
   723   }
       
   724   //g_print ("record created");
       
   725   filesink = gst_element_factory_make("filesink", "filesink");
       
   726       if (!filesink)
       
   727           {
       
   728           g_print("could not create \"filesink\" element!");
       
   729           return -1;
       
   730           }
       
   731   //GstRingBufferSpec
       
   732   //g_print ("sink created");
       
   733   caps = gst_caps_new_simple ("audio/x-raw-int",
       
   734              "width", G_TYPE_INT, 16,
       
   735              "depth", G_TYPE_INT, 16,
       
   736              "signed",G_TYPE_BOOLEAN, TRUE,
       
   737              "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   738              "rate", G_TYPE_INT,  8000,
       
   739              "channels", G_TYPE_INT, 1, NULL);
       
   740   
       
   741   //g_print ("caps created");
       
   742    g_object_set (G_OBJECT (record),
       
   743              //"signal-handoffs", TRUE,
       
   744              "blocksize", 1280,
       
   745           // "gain",10000,
       
   746               NULL);
       
   747   
       
   748   /*g_object_set (G_OBJECT (fakesink),
       
   749              "signal-handoffs", TRUE,
       
   750              "sizemax", 4096,
       
   751              "sizetype", 2, NULL);*/
       
   752   
       
   753   _LIT(KFILENAME,"c:\\data\\test.raw");
       
   754   TFileName fn;
       
   755   fn.Append(KFILENAME);
       
   756   TInt ret;
       
   757   //char carray[FILENAME];
       
   758   carray[0]='\0';
       
   759   ret = wcstombs(carray, (const wchar_t *)fn.PtrZ(), FILENAME);
       
   760    
       
   761    
       
   762   g_object_set (G_OBJECT (filesink), "location", carray,"buffer-size",1280, NULL);
       
   763   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
   764   gst_bus_add_watch (bus, bus_call, NULL);
       
   765   gst_object_unref (bus);
       
   766   
       
   767 
       
   768   /* add objects to the main pipeline */
       
   769   gst_bin_add_many(GST_BIN (pipeline),record,filesink , NULL);
       
   770   //g_print ("added to pipe");
       
   771   /* link the elements */
       
   772   //gst_element_link(record,/*encoder,*/ fakesink/*audiosink*/);
       
   773   gst_element_link_filtered (record, filesink, caps);
       
   774   //g_signal_connect (fakesink, "handoff", G_CALLBACK (cb_record_raw_handoff), NULL);
       
   775   /* start recording */
       
   776  // g_print ("start pipe");
       
   777  
       
   778   gst_element_set_state (pipeline, GST_STATE_PLAYING);
       
   779   
       
   780   return 0;
       
   781  }
       
   782      
       
   783  
       
   784  int gst_play_raw()
       
   785  {
       
   786  /* create elements */
       
   787  gboolean link_ok;
       
   788  
       
   789  pipeline = gst_pipeline_new ("pipeline");
       
   790  source = gst_element_factory_make ("filesrc", "filesrc");
       
   791  //sink = gst_element_factory_make ("fakesink", "sink");
       
   792  sink = gst_element_factory_make ("devsoundsink", "sink");
       
   793 
       
   794 caps = gst_caps_new_simple ("audio/x-raw-int",
       
   795              "width", G_TYPE_INT, 16,
       
   796              "depth", G_TYPE_INT, 16,
       
   797              "signed",G_TYPE_BOOLEAN, TRUE,
       
   798              "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   799              "rate", G_TYPE_INT,  8000,
       
   800              "channels", G_TYPE_INT, 1, NULL);
       
   801              
       
   802  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
   803  gst_bus_add_watch( bus, bus_call, NULL);
       
   804  gst_object_unref (bus);
       
   805 
       
   806  /*g_object_set (G_OBJECT(source),
       
   807          "signal-handoffs", TRUE,
       
   808          //"num-buffers", 4,
       
   809          "sizemax", 4096,
       
   810          "sizetype", 2,
       
   811          NULL);*/
       
   812  
       
   813  g_object_set (G_OBJECT (source), "location", carray, NULL);
       
   814 // g_signal_connect (source, "handoff", G_CALLBACK (cb_raw_playback_handoff), NULL);
       
   815 
       
   816  gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
       
   817  
       
   818  //gst_element_link (source, sink);
       
   819  link_ok = gst_element_link_filtered (source, sink, caps);
       
   820 
       
   821  gst_element_set_state (pipeline, GST_STATE_PLAYING);
       
   822 
       
   823 while (caps->refcount > 1)
       
   824      {
       
   825      gst_caps_unref (caps);
       
   826      }
       
   827  gst_caps_unref (caps);
       
   828 
       
   829  
       
   830  return 0; 
       
   831  }
       
   832 
       
   833  int gst_play_amr()
       
   834   {
       
   835   /* create elements */
       
   836   gboolean link_ok;
       
   837   
       
   838   pipeline = gst_pipeline_new ("pipeline");
       
   839   source = gst_element_factory_make ("filesrc", "filesrc");
       
   840   //sink = gst_element_factory_make ("fakesink", "sink");
       
   841   sink = gst_element_factory_make ("devsoundsink", "sink");
       
   842 
       
   843  caps = gst_caps_new_simple ("audio/amr",
       
   844               "width", G_TYPE_INT, 8,
       
   845               "depth", G_TYPE_INT, 8,
       
   846               "signed",G_TYPE_BOOLEAN, TRUE,
       
   847               "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   848               "rate", G_TYPE_INT,  8000,
       
   849               "channels", G_TYPE_INT, 1, NULL);
       
   850               
       
   851   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
   852   gst_bus_add_watch( bus, bus_call, NULL);
       
   853   gst_object_unref (bus);
       
   854 
       
   855   g_object_set (G_OBJECT (source), "location", carray, NULL);
       
   856 
       
   857   gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
       
   858   
       
   859   link_ok = gst_element_link_filtered (source, sink, caps);
       
   860 
       
   861   gst_element_set_state (pipeline, GST_STATE_PLAYING);
       
   862 
       
   863   return 0; 
       
   864   }
       
   865 
       
   866  int gst_play_g711()
       
   867   {
       
   868   /* create elements */
       
   869   gboolean link_ok;
       
   870   
       
   871   pipeline = gst_pipeline_new ("pipeline");
       
   872   source = gst_element_factory_make ("filesrc", "filesrc");
       
   873   sink = gst_element_factory_make ("devsoundsink", "sink");
       
   874 
       
   875  caps = gst_caps_new_simple ("audio/x-alaw",
       
   876               "width", G_TYPE_INT, 16,
       
   877               "depth", G_TYPE_INT, 16,
       
   878               "signed",G_TYPE_BOOLEAN, TRUE,
       
   879               "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   880               "rate", G_TYPE_INT,  8000,
       
   881               "channels", G_TYPE_INT, 1, NULL);
       
   882               
       
   883   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
   884   gst_bus_add_watch( bus, bus_call, NULL);
       
   885   gst_object_unref (bus);
       
   886 
       
   887   g_object_set (G_OBJECT (source), "location", carray, NULL);
       
   888   gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
       
   889   
       
   890   link_ok = gst_element_link_filtered (source, sink, caps);
       
   891 
       
   892   gst_element_set_state (pipeline, GST_STATE_PLAYING);
       
   893 
       
   894   return 0; 
       
   895   }
       
   896  int gst_play_g729()
       
   897   {
       
   898   /* create elements */
       
   899   gboolean link_ok;
       
   900   
       
   901   pipeline = gst_pipeline_new ("pipeline");
       
   902   source = gst_element_factory_make ("filesrc", "filesrc");
       
   903   sink = gst_element_factory_make ("devsoundsink", "sink");
       
   904 
       
   905  caps = gst_caps_new_simple ("audio/g729",
       
   906               "width", G_TYPE_INT, 16,
       
   907               "depth", G_TYPE_INT, 16,
       
   908               "signed",G_TYPE_BOOLEAN, TRUE,
       
   909               "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   910               "rate", G_TYPE_INT,  8000,
       
   911               "channels", G_TYPE_INT, 1, NULL);
       
   912               
       
   913   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
   914   gst_bus_add_watch( bus, bus_call, NULL);
       
   915   gst_object_unref (bus);
       
   916 
       
   917   g_object_set (G_OBJECT (source), "location", carray, NULL);
       
   918 
       
   919   gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
       
   920   
       
   921   link_ok = gst_element_link_filtered (source, sink, caps);
       
   922 
       
   923   gst_element_set_state (pipeline, GST_STATE_PLAYING);
       
   924 
       
   925   return 0; 
       
   926   }
       
   927  int gst_play_ilbc()
       
   928   {
       
   929   /* create elements */
       
   930   gboolean link_ok;
       
   931   
       
   932   pipeline = gst_pipeline_new ("pipeline");
       
   933   source = gst_element_factory_make ("filesrc", "filesrc");
       
   934   sink = gst_element_factory_make ("devsoundsink", "sink");
       
   935 
       
   936  caps = gst_caps_new_simple ("audio/ilbc",
       
   937               "width", G_TYPE_INT, 16,
       
   938               "depth", G_TYPE_INT, 16,
       
   939               "signed",G_TYPE_BOOLEAN, TRUE,
       
   940               "endianness",G_TYPE_INT, G_BYTE_ORDER,
       
   941               "rate", G_TYPE_INT,  8000,
       
   942               "channels", G_TYPE_INT, 1, NULL);
       
   943               
       
   944   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
   945   gst_bus_add_watch( bus, bus_call, NULL);
       
   946   gst_object_unref (bus);
       
   947 
       
   948   g_object_set (G_OBJECT (source), "location", carray, NULL);
       
   949 
       
   950   gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
       
   951   
       
   952   link_ok = gst_element_link_filtered (source, sink, caps);
       
   953 
       
   954   gst_element_set_state (pipeline, GST_STATE_PLAYING);
       
   955   return 0; 
       
   956   }
       
   957 
       
   958  
       
   959  //******
       
   960  int gst_current_volume()
       
   961      {     
       
   962      if(!sink)
       
   963          {
       
   964          iGstView->DrawText(_L("Devsound sink not available"),KRgbRed);
       
   965          return -1;
       
   966          }
       
   967      int vol;
       
   968      TBuf<25> currentvolume(_L("current volume "));    
       
   969      g_object_get(G_OBJECT(sink),
       
   970                     "volume",&vol,NULL);
       
   971      
       
   972      currentvolume.AppendNum(vol);
       
   973      
       
   974      iGstView->DrawText(currentvolume,KRgbBlack);
       
   975      return 0;
       
   976      }
       
   977  
       
   978  int gst_max_volume()
       
   979       {    
       
   980       if(!sink)
       
   981            {
       
   982            iGstView->DrawText(_L("Devsound sink not available"),KRgbRed);
       
   983            return -1;
       
   984            }
       
   985       
       
   986       int maxvol;
       
   987       TBuf<25> maxvolume(_L("max volume "));   
       
   988       
       
   989       g_object_get(G_OBJECT(sink),
       
   990                      "maxvolume",&maxvol,NULL);
       
   991       
       
   992       maxvolume.AppendNum(maxvol);
       
   993       
       
   994       iGstView->DrawText(maxvolume,KRgbBlack);
       
   995       return 0;
       
   996       
       
   997       }
       
   998  int gst_volume_up()
       
   999      {
       
  1000      
       
  1001      if(!sink)
       
  1002           {
       
  1003           iGstView->DrawText(_L("Devsound sink not available"),KRgbRed);
       
  1004           return -1;
       
  1005           }
       
  1006      iGstView->DrawText(_L("volume up"),KRgbBlack);
       
  1007      int maxvol;
       
  1008      g_object_get(G_OBJECT(sink),
       
  1009                        "maxvolume",&maxvol,NULL);
       
  1010      g_object_set (G_OBJECT (sink), 
       
  1011                         "volume", maxvol, NULL);
       
  1012      return 0;
       
  1013      }
       
  1014 
       
  1015  int gst_volume_down()
       
  1016      {
       
  1017      if(!sink)
       
  1018           {
       
  1019           iGstView->DrawText(_L("Devsound sink not available"),KRgbRed);
       
  1020           return -1;
       
  1021           }
       
  1022      
       
  1023      iGstView->DrawText(_L("volume down"),KRgbBlack);
       
  1024      int maxvol;
       
  1025      g_object_get(G_OBJECT(sink),
       
  1026                         "maxvolume",&maxvol,NULL);
       
  1027      g_object_set (G_OBJECT (sink), 
       
  1028                         "volume", maxvol/2, NULL);
       
  1029      return 0;
       
  1030      }
       
  1031  
       
  1032  int gst_current_gain()
       
  1033      {     
       
  1034      if(!record)
       
  1035          {
       
  1036          iGstView->DrawText(_L("Devsound source not available"),KRgbRed);
       
  1037          return -1;
       
  1038          }
       
  1039      int gain;
       
  1040      TBuf<25> currentgain(_L("current gain "));    
       
  1041      g_object_get(G_OBJECT(record),
       
  1042                     "gain",&gain,NULL);
       
  1043      
       
  1044      currentgain.AppendNum(gain);
       
  1045      
       
  1046      iGstView->DrawText(currentgain,KRgbBlack);
       
  1047      return 0;
       
  1048      }
       
  1049  
       
  1050  int gst_max_gain()
       
  1051       {    
       
  1052       if(!record)
       
  1053            {
       
  1054            iGstView->DrawText(_L("Devsound source not available"),KRgbRed);
       
  1055            return -1;
       
  1056            }
       
  1057       
       
  1058       int max;
       
  1059       TBuf<25> maxgain(_L("max gain "));   
       
  1060       
       
  1061       g_object_get(G_OBJECT(record),
       
  1062                      "maxgain",&max,NULL);
       
  1063       
       
  1064       maxgain.AppendNum(max);
       
  1065       
       
  1066       iGstView->DrawText(maxgain,KRgbBlack);
       
  1067       return 0;
       
  1068       
       
  1069       }
       
  1070  int gst_gain_up()
       
  1071      {
       
  1072      
       
  1073      if(!record)
       
  1074           {
       
  1075           iGstView->DrawText(_L("Devsound source not available"),KRgbRed);
       
  1076           return -1;
       
  1077           }
       
  1078      int max;
       
  1079      g_object_get(G_OBJECT(record),
       
  1080                       "maxgain",&max,NULL);
       
  1081      
       
  1082      iGstView->DrawText(_L("gain up"),KRgbBlack);
       
  1083      g_object_set (G_OBJECT (record), 
       
  1084                         "gain", max, NULL);
       
  1085      return 0;
       
  1086      }
       
  1087 
       
  1088  int gst_gain_down()
       
  1089      {
       
  1090      if(!record)
       
  1091           {
       
  1092           iGstView->DrawText(_L("Devsound source not available"),KRgbRed);
       
  1093           return -1;
       
  1094           }
       
  1095      int max;
       
  1096      g_object_get(G_OBJECT(record),
       
  1097                       "maxgain",&max,NULL);
       
  1098      iGstView->DrawText(_L("gain down"),KRgbBlack);
       
  1099      g_object_set (G_OBJECT (sink), 
       
  1100                         "gain", max/2, NULL);
       
  1101      return 0;
       
  1102      }
       
  1103  
       
  1104  
       
  1105  
       
  1106  int gst_balance()
       
  1107      {
       
  1108      if(!sink)
       
  1109            {
       
  1110            iGstView->DrawText(_L("Devsound sink not available"),KRgbRed);
       
  1111            return -1;
       
  1112            }
       
  1113       
       
  1114       iGstView->DrawText(_L("balance"),KRgbBlack);
       
  1115     /*  g_object_set (G_OBJECT (sink), 
       
  1116                          "left balance", 5000,
       
  1117                          "right balance",5000,NULL);
       
  1118                          */
       
  1119      return 0;
       
  1120      }
       
  1121  
       
  1122  void samplesplayed()
       
  1123       {
       
  1124       if(!sink)
       
  1125            {
       
  1126            iGstView->DrawText(_L("Devsound sink not available"),KRgbRed);      
       
  1127            }
       
  1128       int samples;
       
  1129       TBuf<25> samplesplayed(_L("samples played "));    
       
  1130       g_object_get (G_OBJECT (sink), 
       
  1131                    "samples played", &samples, NULL);
       
  1132       
       
  1133       samplesplayed.AppendNum(samples);
       
  1134       iGstView->DrawText(samplesplayed,KRgbBlack);   
       
  1135       }
       
  1136 
       
  1137  void samplesrecorded()
       
  1138        {
       
  1139        if(!record)
       
  1140             {
       
  1141             iGstView->DrawText(_L("Devsound src not available"),KRgbRed);      
       
  1142             }
       
  1143        int samples;
       
  1144        TBuf<25> samplesrecorded(_L("samples recorded "));    
       
  1145        g_object_get (G_OBJECT (record), 
       
  1146                     "samples recorded", &samples, NULL);
       
  1147        
       
  1148        samplesrecorded.AppendNum(samples);
       
  1149        iGstView->DrawText(samplesrecorded,KRgbBlack);   
       
  1150        } 
       
  1151  
       
  1152  static gboolean print_field (GQuark field, const GValue *value, gpointer pfx)
       
  1153      {
       
  1154      gchar *str = gst_value_serialize (value);
       
  1155      
       
  1156      const gchar* c;
       
  1157 
       
  1158      RDebug::Printf("%s  %15s: %s\n", (gchar *) pfx, c = g_quark_to_string (field), str);
       
  1159      
       
  1160      if(negcaps)
       
  1161          {
       
  1162          TPtrC8 property((const TText8*)c);
       
  1163          TPtrC8 val((const TText8*)str);
       
  1164          TBuf<10> appdval;
       
  1165          appdval.Copy(val);
       
  1166       
       
  1167          TBuf<25> name;
       
  1168          name.Copy(property);
       
  1169          name.Append(':');
       
  1170          name.Append(appdval);
       
  1171        
       
  1172          iGstView->DrawText(name,KRgbBlack);
       
  1173          }    
       
  1174      g_free (str);
       
  1175      return TRUE;
       
  1176      }
       
  1177 
       
  1178  static void print_caps (const GstCaps *caps, const gchar *pfx)
       
  1179      {
       
  1180      guint i;
       
  1181 
       
  1182      g_return_if_fail (caps != NULL);
       
  1183 
       
  1184      if (gst_caps_is_any (caps)) {
       
  1185      RDebug::Printf("%sANY\n", pfx);
       
  1186      return;
       
  1187      }
       
  1188      if (gst_caps_is_empty (caps)) {
       
  1189      RDebug::Printf("%sEMPTY\n", pfx);
       
  1190      return;
       
  1191      }
       
  1192      const gchar *c;
       
  1193      for (i = 0; i < gst_caps_get_size (caps); i++) {
       
  1194      GstStructure *structure = gst_caps_get_structure (caps, i);
       
  1195      
       
  1196      RDebug::Printf("%s%s\n", pfx,c = gst_structure_get_name (structure));
       
  1197      
       
  1198      TPtrC8 fmt((const TText8*)c);
       
  1199    
       
  1200      TBuf<25> name;
       
  1201      name.Copy(fmt);
       
  1202     
       
  1203      iGstView->DrawText(name,KRgbBlack);
       
  1204          
       
  1205      gst_structure_foreach (structure, print_field, (gpointer) pfx);
       
  1206      }
       
  1207      }
       
  1208  
       
  1209  void getsinkpadcaps()
       
  1210      {
       
  1211      RDebug::Print(_L("Devsound Pad Caps"));
       
  1212      if(!sink)
       
  1213           {
       
  1214           iGstView->DrawText(_L("Devsound sink not available"),KRgbRed);
       
  1215           return;
       
  1216           }
       
  1217      negcaps = FALSE;
       
  1218      dssinkpad = gst_element_get_pad (sink, "sink");   
       
  1219      dssinkcap = gst_pad_get_caps (dssinkpad);
       
  1220      
       
  1221      print_caps (dssinkcap, "     ");
       
  1222      }
       
  1223  
       
  1224  void negotiatedsinkcaps()
       
  1225      {
       
  1226      RDebug::Print(_L("Negotiated caps"));
       
  1227       if(!sink)
       
  1228            {
       
  1229            iGstView->DrawText(_L("Devsound sink not available"),KRgbRed);
       
  1230            return;
       
  1231            }
       
  1232       negcaps = TRUE;
       
  1233       dssinkpad = gst_element_get_pad (sink, "sink");   
       
  1234       dssinkcap = gst_pad_get_negotiated_caps (dssinkpad);
       
  1235       
       
  1236       print_caps (dssinkcap, "     ");    
       
  1237      }
       
  1238  
       
  1239  void getsrcpadcaps()
       
  1240       {
       
  1241       RDebug::Print(_L("Devsound Source Pad Caps"));
       
  1242       if(!record)
       
  1243            {
       
  1244            iGstView->DrawText(_L("Devsound src not available"),KRgbRed);
       
  1245            return;
       
  1246            }
       
  1247       negcaps = FALSE;
       
  1248       dssrcpad = gst_element_get_pad (record, "src");   
       
  1249       dssrccap = gst_pad_get_caps (dssrcpad);
       
  1250       
       
  1251       print_caps (dssrccap, "     ");
       
  1252       }
       
  1253   
       
  1254   void negotiatedsrccaps()
       
  1255       {
       
  1256       RDebug::Print(_L("Negotiated  src caps"));
       
  1257        if(!record)
       
  1258             {
       
  1259             iGstView->DrawText(_L("Devsound src not available"),KRgbRed);
       
  1260             return;
       
  1261             }
       
  1262        negcaps = TRUE;
       
  1263        dssrcpad = gst_element_get_pad (record, "src");   
       
  1264        dssrccap = gst_pad_get_negotiated_caps (dssrcpad);
       
  1265    
       
  1266        print_caps (dssrccap, "     ");
       
  1267           
       
  1268       }