Exemple #1
0
GF_Err LIBPLAYER_CloseService(GF_InputService *plug)
{
	LibPlayerIn *read = (LibPlayerIn *) plug->priv;

#ifndef TEST_LIBPLAYER
	// only disconnect if
	if (read->player_type == PLAYER_FILE) {
		player_playback_stop(read->player);
		fprintf(stderr, "[LibPlayerIN]player_playback_stop for instance %d\n", read->player_id);
		player_uninit(read->player);
		fprintf(stderr, "[LibPlayerIN]player_uninit for instance %d\n", read->player_id);
		read->player = NULL;
		libplayer_id--;

		read->state = 0;

		gf_service_disconnect_ack(read->service, NULL, GF_OK);
		GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIn] Closing libplayer instance %d\n", read->player_id));



		// channel zapping dvb case, don't disconnect service
	} else {
		GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIn] Don't close service libplayer instance %d, use this instance for channel zapping\n", read->player_id));
	}

	return GF_OK;
#endif
}
Exemple #2
0
static enum command_state
filescanner_fullrescan(void *arg, int *retval)
{
  DPRINTF(E_LOG, L_SCAN, "Full rescan triggered\n");

  player_playback_stop();
  player_queue_clear();
  inofd_event_unset(); // Clears all inotify watches
  db_purge_all(); // Clears files, playlists, playlistitems, inotify and groups

  inofd_event_set();
  bulk_scan(F_SCAN_BULK);

  *retval = 0;
  return COMMAND_END;
}
Exemple #3
0
static int
mp_stop(void)
{

    Enna_File *file;

    int pos = 0;

    pos = mp_position_percent_get();

    if (pos >= 90)
    {
        file = enna_mediaplayer_current_file_get();
        _info_played_set(file);
    }
    player_playback_stop(mp->player);
    return 0;
}
Exemple #4
0
static int on_libplayer_event(player_event_t e, void *data)
{
	GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] Received event %d\n", e));

  switch (e) {
	case PLAYER_EVENT_PLAYBACK_FINISHED:
	  player_playback_stop(data);
	  player_playback_start(data);
	  if ((in.w && in.h) || (out.w && out.h))
					player_video_io_windows_set(data, &in, &out);
	  break;
    case PLAYER_EVENT_FE_HAS_LOCK:
      break;
    case PLAYER_EVENT_FE_TIMEDOUT:
      break;
    default:
      break;
  }

  return 0;
}
Exemple #5
0
static int on_libplayer_event(player_event_t e, void *data)
{
	GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerEvent] Received event %d\n", e));

	switch (e) {
	case PLAYER_EVENT_PLAYBACK_FINISHED:
		player_playback_stop(data);
		player_playback_start(data);
		break;
	case PLAYER_EVENT_FE_HAS_LOCK:
		break;
	case PLAYER_EVENT_FE_TIMEDOUT:
		break;
	case PLAYER_EVENT_VIDEO_PICTURE:
		break;
	default:
		break;
	}

	return 0;
}
Exemple #6
0
static enum command_state
fullrescan(void *arg, int *ret)
{
  time_t starttime;
  time_t endtime;
  int i;

  DPRINTF(E_LOG, L_LIB, "Library full-rescan triggered\n");
  listener_notify(LISTENER_UPDATE);
  starttime = time(NULL);

  player_playback_stop();
  db_queue_clear(0);
  db_purge_all(); // Clears files, playlists, playlistitems, inotify and groups

  for (i = 0; sources[i]; i++)
    {
      if (!sources[i]->disabled && sources[i]->fullrescan)
	{
	  DPRINTF(E_INFO, L_LIB, "Full-rescan library source '%s'\n", sources[i]->name);
	  sources[i]->fullrescan();
	}
      else
	{
	  DPRINTF(E_INFO, L_LIB, "Library source '%s' is disabled\n", sources[i]->name);
	}
    }

  endtime = time(NULL);
  DPRINTF(E_LOG, L_LIB, "Library full-rescan completed in %.f sec (%d changes)\n", difftime(endtime, starttime), deferred_update_notifications);
  scanning = false;

  if (handle_deferred_update_notifications())
    listener_notify(LISTENER_UPDATE | LISTENER_DATABASE);
  else
    listener_notify(LISTENER_UPDATE);

  *ret = 0;
  return COMMAND_END;
}
Exemple #7
0
GF_Err LIBPLAYER_CloseService(GF_InputService *plug)
{
	LibPlayerIn *read = (LibPlayerIn *) plug->priv;
	if(libplayer_id >= 0){
#ifndef TEST_LIBPLAYER
		printf("in do loop\n");
		printf("[LibPlayerIN]read->url: %s\n", read->url);
		player_playback_stop(read->player);
		printf("[LibPlayerIN]player_playback_stop\n");
		player_uninit(read->player);
		printf("[LibPlayerIN]player_uninit\n");
		read->player = NULL;
		libplayer_id--;


#endif
		read->state = 0;
	}
	gf_term_on_disconnect(read->service, NULL, GF_OK);
	GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIn] Closing libplayer instance %d\n", read->player_id));
	return GF_OK;
}
/* Thread: scan */
static void
process_file(char *file, time_t mtime, off_t size, int type, int flags)
{
  switch (file_type_get(file))
    {
      case FILE_REGULAR:
	filescanner_process_media(file, mtime, size, type, NULL);

	counter++;

	/* When in bulk mode, split transaction in pieces of 200 */
	if ((flags & F_SCAN_BULK) && (counter % 200 == 0))
	  {
	    DPRINTF(E_LOG, L_SCAN, "Scanned %d files...\n", counter);
	    db_transaction_end();
	    db_transaction_begin();
	  }
	break;

      case FILE_PLAYLIST:
      case FILE_ITUNES:
	if (flags & F_SCAN_BULK)
	  defer_playlist(file, mtime);
	else
	  process_playlist(file, mtime);
	break;

      case FILE_CTRL_REMOTE:
	remote_pairing_read_pin(file);
	break;

#ifdef LASTFM
      case FILE_CTRL_LASTFM:
	lastfm_login(file);
	break;
#endif

#ifdef HAVE_SPOTIFY_H
      case FILE_CTRL_SPOTIFY:
	spotify_login(file);
	break;
#endif

      case FILE_CTRL_INITSCAN:
	if (flags & F_SCAN_BULK)
	  break;

	DPRINTF(E_LOG, L_SCAN, "Startup rescan triggered, found init-rescan file: %s\n", file);

	inofd_event_unset(); // Clears all inotify watches
	db_watch_clear();

	inofd_event_set();
	bulk_scan(F_SCAN_BULK | F_SCAN_RESCAN);
	break;

      case FILE_CTRL_FULLSCAN:
	if (flags & F_SCAN_BULK)
	  break;

	DPRINTF(E_LOG, L_SCAN, "Full rescan triggered, found full-rescan file: %s\n", file);

	player_playback_stop();
	player_queue_clear();
	inofd_event_unset(); // Clears all inotify watches
	db_purge_all(); // Clears files, playlists, playlistitems, inotify and groups

	inofd_event_set();
	bulk_scan(F_SCAN_BULK);
	break;

      default:
	DPRINTF(E_WARN, L_SCAN, "Ignoring file: %s\n", file);
    }
}
Exemple #9
0
GF_Err LIBPLAYER_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com)
{
	LibPlayerIn *read = (LibPlayerIn *) plug->priv;
	unsigned long prop = 0;
	GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] ServiceCommand for instance %d, read->state=%d\n", read->player_id, read->state));
	if (!com->base.on_channel) return GF_NOT_SUPPORTED;

	if (com->command_type==GF_NET_SERVICE_HAS_AUDIO) return GF_NOT_SUPPORTED;

	switch (com->command_type) {
	case GF_NET_CHAN_SET_PULL:
		return GF_NOT_SUPPORTED;
	case GF_NET_CHAN_INTERACTIVE:
		return GF_OK;
	/*since data is file-based, no padding is needed (decoder plugin will handle it itself)*/
	case GF_NET_CHAN_SET_PADDING:
		return GF_OK;
	case GF_NET_CHAN_BUFFER:
		return GF_OK;
		com->buffer.max = com->buffer.min = 0;
		return GF_OK;
	case GF_NET_CHAN_DURATION:
		/*this module is not made for updates, use undefined duration*/
		com->duration.duration = -1;
		return GF_OK;
	case GF_NET_CHAN_PLAY:
		if (read->state==0) {
#ifndef TEST_LIBPLAYER
			if ((read->player_id == 0) && (read->player_type == PLAYER_DVB) && (start_dvb == 1)) {
				GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] Instance %d has already started, zapping mode\n", read->player_id));

			} else {
				player_playback_start(read->player);
				if ((read->player_id == 0) && (read->player_type == PLAYER_DVB)) {
					start_dvb = 1;
				}

				read->state = 1;
				GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] Starting playback for instance %d\n", read->player_id));
			}
#endif
		}

		return GF_OK;
	case GF_NET_CHAN_STOP:
		if (read->state==1) {
#ifndef TEST_LIBPLAYER
			// channel zapping, don't stop channel
			if ((read->player_id == 0) && (read->player_type == PLAYER_DVB) && (start_dvb = 1)) {
				GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] Instance %d is in zapping mode, don't stop channel\n", read->player_id));
			} else {
				player_playback_stop(read->player);
				read->state = 0;
				GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] Stopping playback for instance %d\n", read->player_id));
			}
#endif
		}
		return GF_OK;
	case GF_NET_CHAN_CONFIG:
		return GF_OK;
	case GF_NET_CHAN_GET_DSI:
		com->get_dsi.dsi = NULL;
		com->get_dsi.dsi_len = 0;
		return GF_OK;
	}
	return GF_OK;
}