⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xineplug_inp_vcd.c

📁 linux下的MPEG1
💻 C
📖 第 1 页 / 共 5 页
字号:
                                                   p_input->x,                                                   p_input->y,                                                   p_vcdplayer->max_x,                                                   p_vcdplayer->max_y);          dbg_print(INPUT_DBG_EVENT, "Selection is: %d\n", i_selection);          if (vcdplayer_pbc_is_on(p_vcdplayer)) {            vcdinfo_itemid_t itemid = p_vcdplayer->play_item;            lid_t i_next=vcdinfo_selection_get_lid(p_vcdplayer->vcd,                                                    p_vcdplayer->i_lid,                                                    i_selection);            if (VCDINFO_INVALID_LID != i_next) {              itemid.num = i_next;              _x_demux_flush_engine(my_vcd.stream);              vcdplayer_play(p_vcdplayer, itemid);              return true;            }          }#endif        }      }      break;    case XINE_EVENT_INPUT_BUTTON_FORCE:        break;    case XINE_EVENT_INPUT_MOUSE_MOVE:       if (my_vcd.stream)       {        xine_input_data_t *p_input = p_event->data;#if LIBVCD_VERSION_NUM >= 23        int32_t i_selection = vcdinfo_get_area_selection(p_vcdplayer->vcd,                                                          p_vcdplayer->i_lid,                                                          p_input->x,                                                         p_input->y,                                                         p_vcdplayer->max_x,                                                         p_vcdplayer->max_y);        dbg_print(INPUT_DBG_EVENT, "Move to x: %d, y: %d\n",                   p_input->x, p_input->y);                if (my_vcd.i_mouse_button != i_selection) {          dbg_print(INPUT_DBG_EVENT, "Old selection: %d, selection: %d\n",                     my_vcd.i_mouse_button, i_selection);          my_vcd.i_mouse_button = i_selection;          if (i_selection < 0)             send_mouse_enter_leave_event(&my_vcd, false);          else             send_mouse_enter_leave_event(&my_vcd, true);        }#else      dbg_print(INPUT_DBG_EVENT, "Move to x: %d, y: %d\n",                 p_input->x, p_input->y);#endif      }      break;    case XINE_EVENT_INPUT_UP:      dbg_print(INPUT_DBG_EVENT, "Called with up\n");      vcdplayer_send_button_update(p_vcdplayer, 0);      break;    case XINE_EVENT_INPUT_DOWN:      dbg_print(INPUT_DBG_EVENT, "Called with down\n");      vcdplayer_send_button_update(p_vcdplayer, 0);      break;    case XINE_EVENT_INPUT_LEFT:      dbg_print(INPUT_DBG_EVENT, "Called with left\n");      vcdplayer_send_button_update(p_vcdplayer, 0);      break;    case XINE_EVENT_INPUT_RIGHT:      dbg_print(INPUT_DBG_EVENT, "Called with right\n");      vcdplayer_send_button_update(p_vcdplayer, 0);      break;    }  }  return false;}/*!  From xine plugin spec:  request optional data from input plugin.*/static int vcd_get_optional_data (input_plugin_t *this_gen,                         void *data, int data_type) {  dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT),              "called with %d\n", data_type);  if (NULL == my_vcd.stream) return INPUT_OPTIONAL_UNSUPPORTED;  /* Fill this out more fully... */  switch(data_type) {      case INPUT_OPTIONAL_DATA_AUDIOLANG:     {      uint8_t   channel;      channel = _x_get_audio_channel(my_vcd.stream);      dbg_print(INPUT_DBG_EXT, "AUDIO CHANNEL = %d\n", channel);      if (channel == (uint8_t)-1) {        strcpy(data, "auto");      } else {        const vcdinfo_obj_t *p_vcdinfo= my_vcd.player.vcd;        unsigned int audio_type;        unsigned int num_channels;        unsigned int track_num = my_vcd.player.i_track;        audio_type = vcdinfo_get_track_audio_type(p_vcdinfo, track_num);        num_channels = vcdinfo_audio_type_num_channels(p_vcdinfo, audio_type);        if (channel >= num_channels) {          sprintf(data, "%d ERR", channel);        } else {          sprintf(data, "%1d", channel);        }      }      return INPUT_OPTIONAL_SUCCESS;    }      case INPUT_OPTIONAL_DATA_SPULANG:     {      /*uint16_t lang;*/      int8_t   channel;      channel = (int8_t) _x_get_spu_channel(my_vcd.stream);      dbg_print(INPUT_DBG_EXT, "SPU CHANNEL = %d\n", channel);      if (-1 == channel) {        strcpy(data, "auto");      } else {        sprintf(data, "%1d", channel);      }          }  default: ;  }      return INPUT_OPTIONAL_UNSUPPORTED;}/* Array to hold MRLs returned by get_autoplay_list */#define MAX_DIR_ENTRIES 250/*!  From xine plugin spec:  generate autoplay list  return value: list of MRLs-- The list of MRLs returned goes into the playlist.   This is called when the SHORT_PLUGIN_NAME button is pressed.*/static char **vcd_class_get_autoplay_list (input_class_t *this_gen, int *num_files) {  vcd_input_class_t *class = (vcd_input_class_t *) this_gen;  static char *filelist[MAX_DIR_ENTRIES];  dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "called\n");  if ( !vcd_build_mrl_list(class, my_vcd.player.psz_source) ) {    *num_files = 0;    return NULL;  } else {    int i;    int size = 0;    vcdinfo_item_enum_t itemtype =       autoplay2itemtype[my_vcd.player.default_autoplay];        int offset = vcd_get_mrl_type_offset(&my_vcd, itemtype, &size);    /* A VCD is not required to have PBC or LID's, default to entry if       this is the case...     */    if (VCDINFO_ITEM_TYPE_LID == itemtype && size==0) {      itemtype=VCDINFO_ITEM_TYPE_ENTRY;      offset = vcd_get_mrl_type_offset(&my_vcd, itemtype, &size);    }    /* This is because entries start at 0 while other playable units        start at 1. Can remove the below when everything has the same       origin.     */    if (VCDINFO_ITEM_TYPE_ENTRY != itemtype) offset++;    for (i=0; i<size; i++) {      if (class->mrls[offset+i] != NULL) {        filelist[i] = class->mrls[offset+i]->mrl;        dbg_print((INPUT_DBG_MRL), "filelist[%d]: %s\n", i, filelist[i]);      } else {        filelist[i] = NULL;        dbg_print((INPUT_DBG_MRL), "filelist[%d]: NULL\n", i);      }    }    *num_files = i;    return filelist;  }}/*!  Things that need to be done when a stream is closed. */static void vcd_plugin_dispose(input_plugin_t *this_gen) {  /* Not sure there's much more to do here...     In open_plugin we are given a stream which      we save...  */  dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "called\n");  my_vcd.stream = NULL;  if (my_vcd.player.b_opened)    vcdio_close(&my_vcd.player);}/* Pointer to vcdimager default log handler. Set by init_input_plugin   routine. Perhaps can remove. */static vcd_log_handler_t  gl_default_vcd_log_handler = NULL;static cdio_log_handler_t gl_default_cdio_log_handler = NULL;/*! This routine is called by libvcd routines on error.    Setup is done by init_input_plugin.*/static void vcd_log_handler (vcd_log_level_t level, const char message[]){  switch (level) {  case VCD_LOG_DEBUG:  case VCD_LOG_INFO:    if (!(vcdplayer_debug & INPUT_DBG_VCDINFO))      return;    /* Fall through if to warn case */  case VCD_LOG_WARN:    LOG_MSG("%s", message);    break;  case VCD_LOG_ERROR:  case VCD_LOG_ASSERT:    LOG_ERR("%s", message);    break;  default:    LOG_ERR("%s\n%s %d",             message,             _("The above message had unknown vcdimager log level"),             level);  }    /* gl_default_vcd_log_handler (level, message); */}/*! This routine is called by libcdio routines on error.    Setup is done by init_input_plugin.*/static void cdio_log_handler (cdio_log_level_t level, const char message[]){  switch (level) {  case CDIO_LOG_DEBUG:  case CDIO_LOG_INFO:    if (!(vcdplayer_debug & INPUT_DBG_CDIO)) return;    /* Fall through if to warn case */  default:    vcd_log_handler (level, message);  }}/*! This routine is when xine is not around.    Setup is done by vcd_class_dispose.*/static void uninit_log_handler (vcd_log_level_t level, const char message[]){  switch (level) {  case VCD_LOG_DEBUG:  case VCD_LOG_INFO:    if (!(vcdplayer_debug & (INPUT_DBG_VCDINFO|INPUT_DBG_CDIO)))      return;    /* Fall through if to warn case */  case VCD_LOG_WARN:    fprintf(stderr, "WARN: %s\n", message);    break;  case VCD_LOG_ERROR:    fprintf(stderr, "ERROR: %s\n", message);    break;  case VCD_LOG_ASSERT:    fprintf(stderr, "ASSERT ERROR: %s\n", message);    break;  default:    fprintf(stderr, "UNKNOWN ERROR: %s\n%s %d",            message,             _("The above message had unknown vcdimager log level"),             level);  }    /* gl_default_vcd_log_handler (level, message); */}/*!  Things that need to be done the vcd plugin is closed. */static void vcd_class_dispose (input_class_t *this_gen) {  vcd_input_class_t  *class = (vcd_input_class_t *) this_gen;  class->xine->config->unregister_callback(class->xine->config,					   "media.vcd.device");  gl_default_vcd_log_handler  = vcd_log_set_handler (uninit_log_handler);  gl_default_cdio_log_handler =     cdio_log_set_handler ((cdio_log_handler_t) uninit_log_handler);  dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "called\n");  vcd_close(class);}/* Update the xine player title text. */static void vcd_update_title_display(void) {  xine_event_t uevent;  xine_ui_data_t data;  char *title_str;    title_str = vcdplayer_format_str(&my_vcd.player,                                    my_vcd.v_config.title_format);  meta_info_assign(XINE_META_INFO_TITLE, my_vcd.stream, title_str);  meta_info_assign(XINE_META_INFO_COMMENT, my_vcd.stream,                   vcdplayer_format_str(&my_vcd.player,                                         my_vcd.v_config.comment_format));  stream_info_assign(XINE_STREAM_INFO_VIDEO_HAS_STILL, my_vcd.stream,                      my_vcd.player.i_still);  /* Set_str title/chapter display */  dbg_print((INPUT_DBG_MRL|INPUT_DBG_CALL),            "Changing title to read '%s'\n", title_str);  uevent.type        = XINE_EVENT_UI_SET_TITLE;  uevent.stream      = my_vcd.stream;  uevent.data        = &data;  uevent.data_length = sizeof(data);  memcpy(data.str, title_str, strlen(title_str) + 1);  data.str_len = strlen(title_str) + 1;  xine_event_send(my_vcd.stream, &uevent);}#if LIBVCD_VERSION_NUM >= 23static void send_mouse_enter_leave_event(vcd_input_plugin_t *p_this, bool b_mouse_in) {  if (b_mouse_in && p_this->b_mouse_in) {    /* Set up to enter the following "if" statement. */    p_this->b_mouse_in = false;  }  if (b_mouse_in != p_this->b_mouse_in) {    xine_event_t        event;    xine_spu_button_t   spu_event;        spu_event.direction = b_mouse_in ? 1 : 0;    spu_event.button    = p_this->i_mouse_button;        event.type        = XINE_EVENT_SPU_BUTTON;    event.stream      = p_this->stream;    event.data        = &spu_event;    event.data_length = sizeof(spu_event);    xine_event_send(p_this->stream, &event);        p_this->b_mouse_in = b_mouse_in;  }  if (!b_mouse_in)    p_this->i_mouse_button = -1;}#endif /*    Not much special initialization needed here. All of the initialization    is either done in the class or when we have an actual MRL we want   to deal with.*/static int vcd_plugin_open (input_plugin_t *this_gen ) {  vcd_input_class_t  *class = (vcd_input_class_t *) this_gen->input_class;  gl_default_vcd_log_handler  = vcd_log_set_handler (vcd_log_handler);  gl_default_cdio_log_handler = cdio_log_set_handler (cdio_log_handler);  /* actually, this is also done by class initialization. But just in      case... */  class->ip          = &my_vcd;   my_vcd.i_old_still = 0;  return 1;}/*!  This basically sets up stream specified by MRL for playing. After this  routine is called, xine-lib can read blocks from the thing  specified by the MRL, set the position of the thing specified by the  MRL, get its size or read its current position...   See vcdplayer_parses_mrl for the for the format that a valid MRL can take.  Return values: 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -