All pastes #218708 Raw Edit

Untitled

public text v1 · immutable
#218708 ·published 2006-10-24 09:29 UTC
rendered paste body
void cb_typefound(GstElement* typefind,
		  guint probability,
		  GstCaps* caps,
		  gpointer data){

  g_print ("Media type %s found, probability %d%%\n",
	   gst_caps_to_string (caps),
	   probability);


}

class Gst_pipeline{
public:
  Gst_pipeline();
  void set_source(const gchar*);
  void find_type(); //only done after setting source
   void start();
  virtual ~Gst_pipeline();
private:
  GstElement *_pipeline, *_source, *_typefind;
  GMainLoop *_loop;
};

int main (int argc, char *argv[]){
  Gst_pipeline pipeline;
  pipeline.set_source(argv[1]);
  pipeline.find_type();
  g_print("start()");
  pipeline.start();
  g_print("Return 0");
  return 0;
}


Gst_pipeline::Gst_pipeline(){
  gst_init(NULL, NULL); 
  _loop = g_main_loop_new(NULL, FALSE);
  _pipeline = gst_pipeline_new("demux-pipeline");
}

void Gst_pipeline::set_source(const gchar* filename){
  _source = gst_element_factory_make ("filesrc", "source");
  g_object_set(_source, "location", filename, NULL);
}

 void Gst_pipeline::find_type(){
  _typefind = gst_element_factory_make("typefind", "typefinder");
  g_signal_connect(_typefind, "have-type", G_CALLBACK(cb_typefound), _loop);
}

void Gst_pipeline::start(){
  g_main_loop_run(_loop);
}
 


Gst_pipeline::~Gst_pipeline(){
  gst_element_set_state(_pipeline, GST_STATE_NULL);
  gst_object_unref(_pipeline);
  g_main_loop_quit(_loop);
}