Esempio n. 1
0
/* Handles navigation when NOT in PBC reaching the end of a play item.

   The navigations rules here may be sort of made up, but the intent
   is to do something that's probably right or helpful.

   return true if the caller should return.
*/
static vcdplayer_read_status_t
vcdplayer_non_pbc_nav ( access_t *p_access, uint8_t *wait_time )
{
  vcdplayer_t *p_vcdplayer= (vcdplayer_t *)p_access->p_sys;

  /* Not in playback control. Do we advance automatically or stop? */
  switch (p_vcdplayer->play_item.type) {
  case VCDINFO_ITEM_TYPE_TRACK:
  case VCDINFO_ITEM_TYPE_ENTRY: {
    if ( ! vcdplayer_play_next( p_access ) )
      return READ_END;
    break;
  }
  case VCDINFO_ITEM_TYPE_SPAREID2:
    dbg_print( (INPUT_DBG_STILL|INPUT_DBG_LSN),
               "SPAREID2" );
    if (p_vcdplayer->in_still)
    {
      dbg_print( (INPUT_DBG_STILL|INPUT_DBG_LSN),
                 "End of still spareid2" );
      *wait_time = 255;
      return READ_STILL_FRAME ;
    }
    return READ_END;
  case VCDINFO_ITEM_TYPE_NOTFOUND:
    LOG_ERR ("NOTFOUND outside PBC -- not supposed to happen");
    return READ_ERROR;
  case VCDINFO_ITEM_TYPE_LID:
    LOG_ERR ("LID outside PBC -- not supposed to happen");
    return READ_ERROR;
  case VCDINFO_ITEM_TYPE_SEGMENT:
      /* Hack: Just go back and do still again */
    /* FIXME */
    if (p_vcdplayer->in_still)
    {
      dbg_print( (INPUT_DBG_STILL|INPUT_DBG_LSN),
                 "End of still Segment" );
      *wait_time = 10;
      return READ_STILL_FRAME;
    }
    return READ_END;
  }
  return READ_BLOCK;
}
Esempio n. 2
0
/*****************************************************************************
 * RunIntf: main loop
 *****************************************************************************/
static void RunIntf( intf_thread_t *p_intf )
{
    vlc_object_t      * p_vout = NULL;
    mtime_t             mtime = 0;
    mtime_t             mlast = 0;
    thread_vcd_data_t * p_vcd;
    input_thread_t    * p_input;

    /* What you add to the last input number entry. It accumulates all of
       the 10_ADD keypresses */
    int number_addend = 0;

    if( InitThread( p_intf ) < 0 )
    {
        msg_Err( p_intf, "can't initialize intf" );
        return;
    }

    p_input = p_intf->p_sys->p_input;
    p_vcd   = p_intf->p_sys->p_vcd =
      (thread_vcd_data_t *) p_input->p_access_data;

    dbg_print( INPUT_DBG_CALL, "intf initialized" );

    /* Main loop */
    while( !p_intf->b_die )
    {
      vlc_mutex_lock( &p_intf->change_lock );

        /*
         * Have we timed-out in showing a still frame?
         */
        if( p_intf->p_sys->b_still && !p_intf->p_sys->b_inf_still )
        {
            if( p_intf->p_sys->m_still_time > 0 )
            {
                /* Update remaining still time */
                dbg_print(INPUT_DBG_STILL, "updating still time");
                mtime = mdate();
                if( mlast )
                {
                    p_intf->p_sys->m_still_time -= mtime - mlast;
                }

                mlast = mtime;
            }
            else
            {
                /* Still time has elasped; set to continue playing. */
                dbg_print(INPUT_DBG_STILL, "wait time done - setting play");
                var_SetInteger( p_intf->p_sys->p_input, "state", PLAYING_S );
                p_intf->p_sys->m_still_time = 0;
                p_intf->p_sys->b_still = 0;
                mlast = 0;
            }
        }

      /*
       * Do we have a keyboard event?
       */
      if( p_vout && p_intf->p_sys->b_key_pressed )
        {
          vlc_value_t val;
          int i, i_action = -1;
          struct hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;

          p_intf->p_sys->b_key_pressed = VLC_FALSE;

          /* Find action triggered by hotkey (if any) */
          var_Get( p_intf->p_vlc, "key-pressed", &val );

          dbg_print( INPUT_DBG_EVENT, "Key pressed %d", val.i_int );

          for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
            {
              if( p_hotkeys[i].i_key == val.i_int )
                {
                  i_action = p_hotkeys[i].i_action;
                }
            }

          if( i_action != -1) {
            switch (i_action) {

            case ACTIONID_NAV_LEFT:
              dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_LEFT - prev (%d)",
                         number_addend );
              do {
                vcdplayer_play_prev( p_input );
              }        while (number_addend-- > 0);
              break;

            case ACTIONID_NAV_RIGHT:
              dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_RIGHT - next (%d)",
                         number_addend );
              do {
                vcdplayer_play_next( p_input );
              } while (number_addend-- > 0);
              break;

            case ACTIONID_NAV_UP:
              dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_UP - return" );
              do {
                vcdplayer_play_return( p_input );
              } while (number_addend-- > 0);
              break;

            case ACTIONID_NAV_DOWN:
              dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_DOWN - default"  );
              vcdplayer_play_default( p_input );
              break;

            case ACTIONID_NAV_ACTIVATE:
              {
                vcdinfo_itemid_t itemid;
                itemid.type=p_vcd->play_item.type;

                dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_ACTIVATE" );

                if ( vcdplayer_pbc_is_on( p_vcd ) && number_addend != 0 ) {
                  lid_t next_num=vcdinfo_selection_get_lid(p_vcd->vcd,
                                                           p_vcd->cur_lid,
                                                           number_addend);
                  if (VCDINFO_INVALID_LID != next_num) {
                    itemid.num  = next_num;
                    itemid.type = VCDINFO_ITEM_TYPE_LID;
                    VCDPlay( p_input, itemid );
                  }
                } else {
                  itemid.num = number_addend;
                  VCDPlay( p_input, itemid );
                }
                break;
              }
            }
            number_addend = 0;

            /* Any keypress gets rid of still frame waiting.
               FIXME - should handle just the ones that cause an action.
            */
            if( p_intf->p_sys->b_still )
              {
                dbg_print(INPUT_DBG_STILL, "Playing still after activate");
                var_SetInteger( p_intf->p_sys->p_input, "state", PLAYING_S );
                p_intf->p_sys->b_still = 0;
                p_intf->p_sys->b_inf_still = 0;
                p_intf->p_sys->m_still_time = 0;
              }

          } else {
            unsigned int digit_entered=0;

            switch (val.i_int) {
            case '9':
              digit_entered++;
            case '8':
              digit_entered++;
            case '7':
              digit_entered++;
            case '6':
              digit_entered++;
            case '5':
              digit_entered++;
            case '4':
              digit_entered++;
            case '3':
              digit_entered++;
            case '2':
              digit_entered++;
            case '1':
              digit_entered++;
            case '0':
              {
                number_addend *= 10;
                number_addend += digit_entered;
                dbg_print( INPUT_DBG_EVENT,
                           "Added %d. Number is now: %d\n",
                           digit_entered, number_addend);
                break;
              }
            }
          }
        }


      vlc_mutex_unlock( &p_intf->change_lock );

      if( p_vout == NULL )
        {
          p_vout = vlc_object_find( p_intf->p_sys->p_input,
                                    VLC_OBJECT_VOUT, FIND_CHILD );
          if( p_vout )
            {
              var_AddCallback( p_vout, "key-pressed", KeyEvent, p_intf );
            }
        }


      /* Wait a bit */
      msleep( INTF_IDLE_SLEEP );
    }

    if( p_vout )
    {
        var_DelCallback( p_vout, "key-pressed", KeyEvent, p_intf );
        vlc_object_release( p_vout );
    }

    vlc_object_release( p_intf->p_sys->p_input );
}