Ejemplo n.º 1
0
static void
gst_pipeline_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstPipeline *pipeline = GST_PIPELINE (object);

  switch (prop_id) {
    case PROP_DELAY:
      gst_pipeline_set_delay (pipeline, g_value_get_uint64 (value));
      break;
    case PROP_AUTO_FLUSH_BUS:
      gst_pipeline_set_auto_flush_bus (pipeline, g_value_get_boolean (value));
      break;
    case PROP_LATENCY:
      gst_pipeline_set_latency (pipeline, g_value_get_uint64 (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
Ejemplo n.º 2
0
int main(int argc, char *argv[]) {
  GMainLoop *main_loop;
  GstClock *client_clock, *tmp_clock;
  GstNetTimeProvider *prov_clock;
  guint16 clock_port;
  GstClockTime base_time;

  /* Initialize GStreamer */
  gst_init (&argc, &argv);

  prov_clock = create_net_clock (&clock_port);
  client_clock = gst_net_client_clock_new (NULL, "127.0.0.1", clock_port, 0);

  /* Wait 0.5 seconds for the clock to stabilise */
  g_usleep (G_USEC_PER_SEC / 2);
  base_time = share_base_time (clock_port, prov_clock);

  /* Create the elements */
  playbin = gst_element_factory_make ("playbin", "playbin");
  g_object_set (playbin, "uri", "file:///home/luisbg/samples/big_buck_bunny_1080p_h264.mov", NULL);

  gst_pipeline_use_clock (GST_PIPELINE (playbin), client_clock);
  gst_element_set_base_time (playbin, base_time);
  gst_element_set_start_time (playbin, GST_CLOCK_TIME_NONE);
  gst_pipeline_set_latency (GST_PIPELINE (playbin), GST_SECOND / 2);

  gst_element_set_state (playbin, GST_STATE_PLAYING);

  /* Create a GLib Main Loop and set it to run */
  main_loop = g_main_loop_new (NULL, FALSE);
  g_main_loop_run (main_loop);

  /* Free resources */
  g_main_loop_unref (main_loop);
  gst_element_set_state (playbin, GST_STATE_NULL);
  gst_object_unref (playbin);
  return 0;
}
Ejemplo n.º 3
0
/*!
 * \brief GstOutput::openAppSrc
 * \param filename filename to output to
 * \param fourcc desired codec fourcc
 * \param fps desired framerate
 * \param frameSize the size of the expected frames
 * \param is_color color or grayscale
 * \return success
 *
 *
 */
bool GstShow::open(int xwinid, std::string Laddress, std::string Raddress)
{
    
    // init gstreamer
    gst_initializer::init();

    // init vars
    //int  bufsize = 0;

    bool file = false;
    char *uriL = NULL;
    char *uriR = NULL;
    
    init_pipeline(xwinid);
    
    if(!gst_uri_is_valid(Laddress.c_str()) || !gst_uri_is_valid(Raddress.c_str()))
    {
        uriL = realpath(Laddress.c_str(), NULL);
        uriR = realpath(Raddress.c_str(), NULL);
        if(uriL != NULL && uriR != NULL)
        {
            uriL = g_filename_to_uri(uriL, NULL, NULL);
            uriR = g_filename_to_uri(uriR, NULL, NULL);
            if(uriL != NULL && uriR != NULL)
            {
                file = true;
            }
            else
            {
                L_(lerror) << "GStreamer: Error opening file";
                close();
                return false;
            }
        }
    } else {
        file = false;
        uriL = g_strdup(Laddress.c_str());        
        uriR = g_strdup(Raddress.c_str());        
    }
    if (!file)
    {
        global_clock = gst_system_clock_obtain ();
        gst_net_time_provider_new (global_clock, "0.0.0.0", 8554);
        if (global_clock != NULL)
        L_(ldebug2) << ("Clock created!");
        else
        {
        L_(lerror) << ("Could not creaye clock!");
        return false;
        }
        gst_pipeline_use_clock (GST_PIPELINE (pipeline), global_clock);
    }
        
    
    for (int i = 0; i<2; i++)
    {
        source[i] = gst_element_factory_make("uridecodebin", NULL);

        gst_bin_add_many(GST_BIN(pipeline), source[i], NULL);
        
        if (i==0)
            g_object_set (source[i], "uri", uriL, NULL);
        if (i==1)
            g_object_set (source[i], "uri", uriR, NULL);
            
        //sync if not file!
        if (!file)
        {
            g_signal_connect (source[i], "source-setup", G_CALLBACK (source_created), NULL);
        }
        
        //Set latency if we have a stream
        if (!file)
        {
            /* Set this high enough so that it's higher than the minimum latency
            * on all receivers */
            gst_pipeline_set_latency (GST_PIPELINE (pipeline), PIPELINE_LATENCY_MS * GST_MSECOND);
        }        
        
        g_signal_connect(source[i], "pad-added", G_CALLBACK(newPad), queue[i]);
        
    }

    
    return finish_pipeline();


}