static void
keyboard_cb (const gchar * key_input, gpointer user_data)
{
  GstPlay *play = (GstPlay *) user_data;

  switch (g_ascii_tolower (key_input[0])) {
    case 'i':
    {
      GstPlayerMediaInfo *media_info = gst_player_get_media_info (play->player);
      if (media_info) {
        print_media_info (media_info);
        g_object_unref (media_info);
        print_current_tracks (play);
      }
      break;
    }
    case ' ':
      toggle_paused (play);
      break;
    case 'q':
    case 'Q':
      g_main_loop_quit (play->loop);
      break;
    case '>':
      if (!play_next (play)) {
        g_print ("\nReached end of play list.\n");
        g_main_loop_quit (play->loop);
      }
      break;
    case '<':
      play_prev (play);
      break;
    case 27:                   /* ESC */
      if (key_input[1] == '\0') {
        g_main_loop_quit (play->loop);
        break;
      }
      /* fall through */
    default:
      if (strcmp (key_input, GST_PLAY_KB_ARROW_RIGHT) == 0) {
        relative_seek (play, +0.08);
      } else if (strcmp (key_input, GST_PLAY_KB_ARROW_LEFT) == 0) {
        relative_seek (play, -0.01);
      } else if (strcmp (key_input, GST_PLAY_KB_ARROW_UP) == 0) {
        play_set_relative_volume (play, +1.0 / VOLUME_STEPS);
      } else if (strcmp (key_input, GST_PLAY_KB_ARROW_DOWN) == 0) {
        play_set_relative_volume (play, -1.0 / VOLUME_STEPS);
      } else {
        GST_INFO ("keyboard input:");
        for (; *key_input != '\0'; ++key_input)
          GST_INFO ("  code %3d", *key_input);
      }
      break;
  }
}
static void
media_info_cb (GstPlayer * player, GstPlayerMediaInfo * info, GstPlay * play)
{
  static int once = 0;

  if (!once) {
    print_media_info (info);
    print_current_tracks (play);
    once = 1;
  }
}
/*
 * This routine collects information of all available tape libraries
 * and tape drives connected to the node.
 *
 * Return: success = struct media_info [or] failure = NULL
 */
struct media_info *
collect_media_info(void)
{
	int			i, j;
	node_t		*node_lib, *node_drv, *node_stkdev;
	sqm_lst_t	*lib_list;
	library_t	*print_lib;
	drive_t		*print_drv;
	stk_device_t		*print_stkdev;
	struct media_info	*minfo;

	/*
	 * Collect all the available information of libraries and tape
	 * drives connected to the node
	 */
	i = get_all_libraries(NULL, &lib_list);
	if (i != 0) {
		scds_syslog(LOG_ERR, "Error getting library list.");
		dprintf(stderr, "Error getting library list\n");
		return (NULL);
	}

	minfo = (struct media_info *)malloc(sizeof (struct media_info));
	if (minfo == NULL) {
		scds_syslog(LOG_ERR, "Out of Memory");
		return (NULL);
	}
	bzero((char *)minfo, sizeof (struct media_info));

	num_drives = 0;
	num_cat = 0;
	j = 0;

	/*
	 * We have got the library information, now go over the
	 * list and store the required information
	 */
	for (node_lib = lib_list->head; node_lib != NULL;
	    node_lib = node_lib->next) {
		print_lib = (library_t *)node_lib->data;

		/*
		 * Skip information on historian
		 */
		if (strcmp(print_lib->base_info.equ_type, "hy") == 0) {
			continue;
		}

		/*
		 * For all libraries connected to this node,
		 * save information on their tape drives
		 */
		for (node_drv = (print_lib->drive_list)->head;
		    node_drv != NULL; node_drv = node_drv->next) {
			print_drv = (drive_t *)node_drv->data;

			strlcpy(minfo->dinfo[j].drive_path,
			    (print_drv->base_info).name,
			    sizeof (minfo->dinfo[j].drive_path));

			strlcpy(minfo->dinfo[j].drive_eqtype,
			    print_drv->base_info.equ_type,
			    sizeof (minfo->dinfo[j].drive_eqtype));

			minfo->dinfo[j].drive_eq =
			    (int)((print_drv->base_info).eq);

			if (minfo->dinfo[j].drive_eq <= 0) {
				minfo->dinfo[j].drive_eq = WRONG_EQ;
			} else {
				num_drives++;
				j++;
			}
		}

		/* Get path to catalog for the libraries */
		if (print_lib->catalog_path != NULL) {
			strlcpy(minfo->catalog_path[num_cat],
			    print_lib->catalog_path,
			    sizeof (minfo->catalog_path[num_cat]));
			num_cat++;
		} else {
			dprintf(stderr, "No catalog for library %s\n",
			    print_lib->base_info.equ_type);
		}

		/*
		 * For STK library, save additional information such as
		 * hostname, configuration file, acs_num, lsm_num etc.
		 */
		if (strcmp(print_lib->base_info.equ_type, "sk") == 0) {

			strlcpy(minfo->linfo.lib_eqtype,
			    print_lib->base_info.equ_type,
			    sizeof (minfo->linfo.lib_eqtype));

			strlcpy(minfo->linfo.hostname,
			    print_lib->storage_tek_parameter->hostname,
			    sizeof (minfo->linfo.hostname));

			strlcpy(minfo->linfo.conf_file,
			    (print_lib->base_info).name,
			    sizeof (minfo->linfo.conf_file));


			for (node_stkdev = (print_lib->
			    storage_tek_parameter->stk_device_list)->head;
			    node_stkdev != NULL;
			    node_stkdev = node_stkdev->next) {
				print_stkdev =
				    (stk_device_t *)node_stkdev->data;

				minfo->linfo.acs_param = print_stkdev->acs_num;
				minfo->linfo.lsm_param = print_stkdev->lsm_num;
				minfo->linfo.panel_param =
				    print_stkdev->panel_num;
				minfo->linfo.drive_param =
				    print_stkdev->drive_num;
			}
		}
		if (print_lib->base_info.eq >= 0) {
			libstate[num_lib++].l_eq = print_lib->base_info.eq;
		}
	}

	dprintf(stderr, "Total lib = %d \n", num_lib);
	print_media_info(minfo);

	/*
	 * Free library list as the job of collection is over
	 */
	if (lib_list != NULL) {
		free_list_of_libraries(lib_list);
		lib_list = NULL;
	}

	return (minfo);
}