Esempio n. 1
0
gint
main (gint argc, gchar * argv[])
{
  GSList *before, *after;

  unsetenv ("GST_DEBUG");
  gst_init (&argc, &argv);

  before = gst_debug_get_all_categories ();
  GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN,
      "default category for this test");
  GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static",
      GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED,
      "static category for this test");
  after = gst_debug_get_all_categories ();

  g_print ("removing default log function\n");
#ifdef GST_DISABLE_GST_DEBUG
  g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 0);
#else
  g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1);
  g_print
      ("checking, if the two new categories are put into the category list correctly...\n");
  g_assert (g_slist_length (after) - g_slist_length (before) == 2);
  /* check the _get stuff */
  g_print
      ("checking, if the gst_debug_category_get_* stuff works with the categories...\n");
  g_assert (strcmp (gst_debug_category_get_name (cat), "cat") == 0);
  g_assert (gst_debug_category_get_color (cat) == GST_DEBUG_FG_GREEN);
  g_assert (strcmp (gst_debug_category_get_description (cat),
          "default category for this test") == 0);
  g_assert (gst_debug_category_get_threshold (cat) ==
      gst_debug_get_default_threshold ());
  g_assert (strcmp (gst_debug_category_get_name (cat_static),
          "cat_static") == 0);
  g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_FG_GREEN);
  g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BG_RED);
  g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BOLD);
  g_assert (strcmp (gst_debug_category_get_description (cat_static),
          "static category for this test") == 0);
  g_assert (gst_debug_category_get_threshold (cat_static) ==
      gst_debug_get_default_threshold ());
  /* check if setting levels for names work */
  g_print
      ("checking if changing threshold for names affects existing categories...\n");
  gst_debug_set_threshold_for_name ("cat", GST_LEVEL_DEBUG);
  g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
  g_assert (gst_debug_category_get_threshold (cat_static) ==
      gst_debug_get_default_threshold ());
  gst_debug_set_threshold_for_name ("cat_static", GST_LEVEL_INFO);
  g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
  g_assert (gst_debug_category_get_threshold (cat_static) == GST_LEVEL_INFO);
#endif

  g_print ("everything ok.\n");
  return 0;
}
Esempio n. 2
0
static void
native_class_init (JNIEnv * env, jclass klass)
{
  native_player_field_id =
      (*env)->GetFieldID (env, klass, "native_player", "J");
  on_position_updated_method_id =
      (*env)->GetMethodID (env, klass, "onPositionUpdated", "(J)V");
  on_duration_changed_method_id =
      (*env)->GetMethodID (env, klass, "onDurationChanged", "(J)V");
  on_state_changed_method_id =
      (*env)->GetMethodID (env, klass, "onStateChanged", "(I)V");
  on_buffering_method_id =
      (*env)->GetMethodID (env, klass, "onBuffering", "(I)V");
  on_end_of_stream_method_id =
      (*env)->GetMethodID (env, klass, "onEndOfStream", "()V");
  on_error_method_id =
      (*env)->GetMethodID (env, klass, "onError", "(ILjava/lang/String;)V");
  on_video_dimensions_changed_method_id =
      (*env)->GetMethodID (env, klass, "onVideoDimensionsChanged", "(II)V");

  if (!native_player_field_id ||
      !on_position_updated_method_id || !on_duration_changed_method_id ||
      !on_state_changed_method_id || !on_buffering_method_id ||
      !on_end_of_stream_method_id ||
      !on_error_method_id || !on_video_dimensions_changed_method_id) {
    static const gchar *message =
        "The calling class does not implement all necessary interface methods";
    jclass exception_class = (*env)->FindClass (env, "java/lang/Exception");
    __android_log_print (ANDROID_LOG_ERROR, "GstPlayer", "%s", message);
    (*env)->ThrowNew (env, exception_class, message);
  }

  gst_debug_set_threshold_for_name ("gst-player", GST_LEVEL_TRACE);
}
Esempio n. 3
0
static void
parse_debug_list (const gchar * list)
{
  gchar **split;
  gchar **walk;

  g_assert (list);

  split = g_strsplit (list, ",", 0);

  for (walk = split; *walk; walk++) {
    if (strchr (*walk, ':')) {
      gchar **values = g_strsplit (*walk, ":", 2);

      if (values[0] && values[1]) {
        gint level;
        const gchar *category;

        if (parse_debug_category (values[0], &category)
            && parse_debug_level (values[1], &level))
          gst_debug_set_threshold_for_name (category, level);
      }

      g_strfreev (values);
    } else {
      gint level;

      if (parse_debug_level (*walk, &level))
        gst_debug_set_default_threshold (level);
    }
  }

  g_strfreev (split);
}
Esempio n. 4
0
/* Instruct the native code to create its internal data structure, pipeline and thread */
static void gst_native_init (JNIEnv* env, jobject thiz) {
    CustomData *data = g_new0 (CustomData, 1);
    SET_CUSTOM_DATA (env, thiz, custom_data_field_id, data);
    GST_DEBUG_CATEGORY_INIT (debug_category, "tutorial-5", 0, "Android tutorial 5");
    gst_debug_set_threshold_for_name("tutorial-5", GST_LEVEL_DEBUG);
    GST_DEBUG ("Created CustomData at %p", data);
    data->app = (*env)->NewGlobalRef (env, thiz);
    GST_DEBUG ("Created GlobalRef for app object at %p", data->app);
    pthread_create (&gst_app_thread, NULL, &app_function, data);
}
/* Instruct the native code to create its internal data structure, pipeline and thread */
static void gst_native_init (JNIEnv* env, jobject thiz) {
    //gst_init(NULL, NULL);
    CustomData *data = g_new0 (CustomData, 1);
    g_data = data;
    SET_CUSTOM_DATA (env, thiz, custom_data_field_id, data);
    GST_DEBUG_CATEGORY_INIT (debug_category, "evercam", 0, "Android evercam");
    gst_debug_set_threshold_for_name("evercam", GST_LEVEL_LOG);
    GST_DEBUG ("Created CustomData at %p", data);
    data->app = env->NewGlobalRef (thiz);
    GST_DEBUG ("Created GlobalRef for app object at %p", data->app);
    pthread_create (&gst_app_thread, NULL, &app_function, data);
    //app_function(data);
}
/* Instruct the native code to create its internal data structure and
 * pipeline */
static jlong
gst_native_player_create (JNIEnv * env, jobject thiz)
{
  GstMediaPlayer *player;
  GObject *viewer;
  CustomData *data;
  jlong result;

  data = g_new0 (CustomData, 1);
  GST_DEBUG ("Created CustomData at %p", data);

  viewer = g_object_new (GST_TYPE_RTSP_VIEWER, NULL);

  player = gst_media_player_new (GST_RTSP_STREAMER (viewer), GST_WINDOW_RENDERER (viewer));

  g_signal_connect (viewer, "size-changed", (GCallback) size_changed,
      data);

  g_signal_connect (G_OBJECT (player), "new-status", (GCallback) new_status,
      data);
  g_signal_connect (G_OBJECT (player), "error", (GCallback) error, data);
  g_signal_connect (G_OBJECT (player), "new-position", (GCallback) new_position,
      data);

  if (!gst_media_player_setup_thread (player, NULL)) {
    GST_ERROR ("Could not configure player");
  }
  GST_DEBUG ("Created GstMediaPlayer at %p", player);

  data->player = player;
  data->app = (*env)->NewGlobalRef (env, thiz);
  GST_DEBUG ("Created GlobalRef for app object at %p", data->app);

  GST_DEBUG_CATEGORY_INIT (debug_category, "nativelayer", 0, "Native layer");
  gst_debug_set_threshold_for_name ("nativelayer", GST_LEVEL_DEBUG);

  return NATIVEP_TO_J (data);
}
Esempio n. 7
0
/* Instruct the native code to create its internal data structure, pipeline and thread */
static void gst_native_init(JNIEnv* env, jobject thiz) {

	if (-1 == access("/storage/sdcard0/fifo9000", F_OK)) {
		int res = mkfifo("/storage/sdcard0/fifo9000", S_IRWXO);
		if (res != 0) {
			g_print("Error while creating a pipe (return:%d, errno:%d)", res,
					errno);
		}
	}
	else
	{

	}
	// Initialize mutex
	if (0 != pthread_mutex_init(&mutex, NULL)) {

		// Get the exception class
		jclass exceptionClazz = (*env)->FindClass(env,
				"java/lang/RuntimeException");
		// Throw exception
		(*env)->ThrowNew(env, exceptionClazz, "Unable to initialize mutex");

		g_print("pthread_mutex_init fail!");

	} else {

	}
	CustomData *data = g_new0(CustomData, 1);
	SET_CUSTOM_DATA(env, thiz, custom_data_field_id, data);
	GST_DEBUG_CATEGORY_INIT(debug_category, "tutorial-2", 0,
			"Android tutorial 2");
	gst_debug_set_threshold_for_name("tutorial-2", GST_LEVEL_DEBUG);
	GST_DEBUG("Created CustomData at %p", data);
	data->app = (*env)->NewGlobalRef(env, thiz);
	GST_DEBUG("Created GlobalRef for app object at %p", data->app);
	pthread_create(&gst_app_thread, NULL, &app_function, data);
}