예제 #1
0
void test_refcounts()
{
  GstNetTimeProvider *ntp;
  GstClock *clock;

	 xmlfile = "test_refcounts";
  std_log(LOG_FILENAME_LINE, "Test Started test_refcounts");
  
  clock = gst_system_clock_obtain ();
  fail_unless (clock != NULL, "failed to get system clock");

  /* one for gstreamer, one for us */
  ASSERT_OBJECT_REFCOUNT (clock, "system clock", 2);

  ntp = gst_net_time_provider_new (clock, NULL, 0);
  fail_unless (ntp != NULL, "failed to create net time provider");

  /* one for ntp, one for gstreamer, one for us */
  ASSERT_OBJECT_REFCOUNT (clock, "system clock", 3);
  /* one for us */
  ASSERT_OBJECT_REFCOUNT (ntp, "net time provider", 1);

  gst_object_unref (ntp);
  ASSERT_OBJECT_REFCOUNT (clock, "net time provider", 2);

  gst_object_unref (clock);
    
  std_log(LOG_FILENAME_LINE, "Test Successful");
  create_xml(0); 
}
예제 #2
0
static GstNetTimeProvider *
create_net_clock ()
{
  GstClock *clock;
  GstNetTimeProvider *net_time;

  clock = gst_system_clock_obtain ();
  net_time = gst_net_time_provider_new (clock, NULL, 0);
  gst_object_unref (clock);

  return net_time;
}
예제 #3
0
static GstNetTimeProvider *
create_net_clock (guint16 *port)
{
  GstClock *clock;
  GstNetTimeProvider *net_time;

  clock = gst_system_clock_obtain ();
  net_time = gst_net_time_provider_new (clock, NULL, 0);
  g_object_get (net_time, "port", port, NULL);
  gst_object_unref (clock);

  return net_time;
}
예제 #4
0
extern EXPORT_API gboolean gst_dvb_css_wc_start(const gchar *address, gint port, gboolean followup, guint32 max_freq_error_ppm,  gboolean isDebug) {
	GST_DEBUG("dvb_css_wc_start\n");
	G_LOCK(mutex);
	sServer = server_new();
	if (sServer == NULL) {
		goto server_struct_not_initialized;
	}
	gst_init(NULL, NULL);
	sServer->loop = g_main_loop_new(NULL, FALSE);
	sServer->clock = gst_system_clock_obtain();

	if(isDebug == FALSE){
		sServer->gstdvbcsswcserver = gst_dvb_css_wc_server_new(sServer->clock, address, port, followup, max_freq_error_ppm);		
	}
	else{
		sServer->gstdvbcsswcserver = gst_net_time_provider_new(sServer->clock, address, port);		
	}
	
	if (sServer->gstdvbcsswcserver == NULL) {
		GST_ERROR("Dvb_css_wc server not created\n");
		goto cleanup;
	}

	g_object_get(sServer->gstdvbcsswcserver, "port", &port, NULL);
	GST_DEBUG("Published network clock on port %u\n", port);

	sServer->thread = g_thread_try_new("dvb_css_wc_thread", (GThreadFunc) g_main_loop_run, sServer->loop, NULL);
	if (sServer->thread == NULL) {
		GST_ERROR("Thread for dvb_css_wc server not created\n");
		goto cleanup;
	}
	
	GST_DEBUG("Dvb_css_wc server started\n");
	G_UNLOCK(mutex);
	return TRUE;

	/* ERRORS */
server_struct_not_initialized:{
	GST_ERROR("Dvb_css_wc server struct not initialized\n");
	G_UNLOCK(mutex);
	return FALSE;
	}
cleanup:{
	server_free(&sServer);
	G_UNLOCK(mutex);
	return FALSE;
	}
}
예제 #5
0
void test_functioning()
{
  GstNetTimeProvider *ntp;
  GstNetTimePacket *packet;
  GstClock *clock;
  GstClockTime local;
  struct sockaddr_in servaddr;
  gint port = -1, sockfd, ret;
  socklen_t len;

	xmlfile = "test_functioning";
  std_log(LOG_FILENAME_LINE, "Test Started test_functioning");
  
  clock = gst_system_clock_obtain ();
  fail_unless (clock != NULL, "failed to get system clock");
  ntp = gst_net_time_provider_new (clock, "127.0.0.1", 0);
  fail_unless (ntp != NULL, "failed to create net time provider");

  g_object_get (ntp, "port", &port, NULL);
  fail_unless (port > 0);

  sockfd = socket (AF_INET, SOCK_DGRAM, 0);
  fail_if (sockfd < 0, "socket failed");

  memset (&servaddr, 0, sizeof (servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_port = htons (port);
  inet_aton ("127.0.0.1", &servaddr.sin_addr);

  packet = gst_net_time_packet_new (NULL);
  fail_unless (packet != NULL, "failed to create packet");

  packet->local_time = local = gst_clock_get_time (clock);
  
  len = sizeof (servaddr);
  ret = gst_net_time_packet_send (packet, sockfd,
      (struct sockaddr *) &servaddr, len);

  fail_unless (ret == GST_NET_TIME_PACKET_SIZE, "failed to send packet");

  g_free (packet);

  packet = gst_net_time_packet_receive (sockfd, (struct sockaddr *) &servaddr,
      &len);

  fail_unless (packet != NULL, "failed to receive packet");
  
 // fail_unless (packet->local_time == local, "local time is not the same");  //local time has changed
  fail_unless (packet->remote_time > local, "remote time not after local time");
  fail_unless (packet->remote_time < gst_clock_get_time (clock),
      "remote time in the future");

  g_free (packet);

  close (sockfd);

  //gst_object_unref (ntp); //thread is blocking
  gst_object_unref (clock);
  
  std_log(LOG_FILENAME_LINE, "Test Successful");
  create_xml(0); 
  
}
예제 #6
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();


}