stream video for a certain period

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

stream video for a certain period

Krishnan
Hi,

I am new to gstreamer. My requirement is to stream a camera for certain period (say 2 mins) and then switch camera and stream again for 2 mins and so on. The code looks like this


loop = g_main_loop_new (NULL, FALSE);

  /* create a server instance */
  server = gst_rtsp_server_new ();
  gst_rtsp_server_set_service( server, "554" );
 

  /* get the mapping for this server, every server has a default mapper object
   * that be used to map uri mount points to media factories */
  mapping = gst_rtsp_server_get_media_mapping (server);

  /* make a media factory for a test stream. The default media factory can use
   * gst-launch syntax to create pipelines.
   * any launch line works as long as it contains elements named pay%d. Each
   * element with pay%d names will be a stream */
  factory = gst_rtsp_media_factory_new ();
  gst_rtsp_media_factory_set_launch (factory, argv[1]);
  gst_rtsp_media_factory_set_shared( factory, 1 );

  /* attach the test factory to the /test url */
  gst_rtsp_media_mapping_add_factory (mapping, "/test", factory);

  /* don't need the ref to the mapper anymore */
  g_object_unref (mapping);

  /* attach the server to the default maincontext */
  gst_rtsp_server_attach (server, NULL);

  /* start serving */
  g_main_loop_run (loop);


So, the g_main_loop_run (loop) function loops forever. How can I make it to stop after certain period of time?

Thanks,
Krishnan