Ejemplo n.º 1
0
CHAR8 *
ConvertComponentName2SupportLanguage (
    IN EFI_COMPONENT_NAME2_PROTOCOL    *ComponentName,
    IN CHAR8                           *Language
)
/*++

  Routine Description:

    Do some convertion for the ComponentName2 supported language. It do
    the convertion just for english language code currently.

  Arguments:

    ComponentName         - Pointer to the ComponentName2 protocl pointer.
    Language              - The language string.

  Returns:

    Return the duplication of Language if it is not english otherwise return
    the supported english language code.

--*/
{
    CHAR8                              *SupportedLanguages;
    CHAR8                              *LangCode;
    UINTN                              Index;

    LangCode           = NULL;
    SupportedLanguages = NULL;

    //
    // treat all the english language code (en-xx or eng) equally
    //
    if ((strncmpa(Language, "en-", 3) == 0) || (strcmpa(Language, "eng") == 0)) {
        SupportedLanguages = strstra(ComponentName->SupportedLanguages, "en-");
        if (SupportedLanguages == NULL) {
            SupportedLanguages = strstra(ComponentName->SupportedLanguages, "eng");
        }
    }

    //
    // duplicate the Language if it is not english
    //
    if (SupportedLanguages == NULL) {
        SupportedLanguages = Language;
    }

    //
    // duplicate the returned language code.
    //
    if (strstra(SupportedLanguages, "-") != NULL) {
        LangCode = EfiLibAllocateZeroPool(32);
        for(Index = 0; (Index < 31) && (SupportedLanguages[Index] != '\0') && (SupportedLanguages[Index] != ';'); Index++) {
            LangCode[Index] = SupportedLanguages[Index];
        }
        LangCode[Index] = '\0';
    } else {
        LangCode = EfiLibAllocateZeroPool(4);
        for(Index = 0; (Index < 3) && (SupportedLanguages[Index] != '\0'); Index++) {
            LangCode[Index] = SupportedLanguages[Index];
        }
        LangCode[Index] = '\0';
    }
    return LangCode;
}
Ejemplo n.º 2
0
eOSState cMenuXinelib::ProcessHotkey(eKeys Key)
{
  eOSState NewState = osEnd;
  cString  Message;
  time_t   now      = time(NULL);
  bool     OnlyInfo = ((xc.last_hotkey_time < now-3) || xc.last_hotkey != Key);

  switch (Key) {
    case HOTKEY_DVD:
      cPlayerFactory::Launch(m_Dev, "dvd:/");
      break;

    case HOTKEY_DVD_TRACK1:
      cPlayerFactory::Launch(m_Dev, "dvd:/1");
      break;

    case HOTKEY_LOCAL_FE:
      /* off, on */
      {
        int local_frontend = strstra(xc.local_frontend, xc.s_frontends, 0);

#ifndef OLD_TOGGLE_FE
        if (local_frontend==FRONTEND_NONE)
          // no need to show current frontend if there is no output device ...
          OnlyInfo = false;
#endif
        if (!OnlyInfo) {
#ifndef OLD_TOGGLE_FE
          static int orig_frontend = -1;
          if (orig_frontend < 0)
            orig_frontend = local_frontend;

          if (orig_frontend == FRONTEND_NONE) {
            // no frontends were loaded at startup -> loop thru all frontends
            local_frontend++;
          } else {
            // frontend was loaded at startup -> toggle it on/off
            if (local_frontend == FRONTEND_NONE)
              local_frontend = orig_frontend;
            else
              local_frontend = FRONTEND_NONE;
          }
#else
          local_frontend++;
#endif
          if (local_frontend >= FRONTEND_count)
            local_frontend = 0;
          strn0cpy(xc.local_frontend, xc.s_frontends[local_frontend], sizeof(xc.local_frontend));
          m_Dev->ConfigureWindow(
              xc.fullscreen, xc.width, xc.height, xc.modeswitch, xc.modeline,
              xc.display_aspect, xc.scale_video);
        }
        Message = cString::sprintf("%s %s %s", tr("Local Frontend"),
                                   OnlyInfo ? ":" : "->",
                                   xc.s_frontendNames[local_frontend]);
      }
      break;

    case HOTKEY_NEXT_ASPECT:
      /* auto, 4:3, 16:9, ... */
      if (!OnlyInfo) {
        xc.display_aspect = (xc.display_aspect < ASPECT_count-1) ? xc.display_aspect+1 : 0;
        m_Dev->ConfigureWindow(xc.fullscreen, xc.width, xc.height,
                               xc.modeswitch, xc.modeline, xc.display_aspect,
                               xc.scale_video);
      }
      Message = cString::sprintf("%s %s %s", tr("Aspect ratio"),
                                 OnlyInfo ? ":" : "->",
                                 tr(xc.s_aspects[xc.display_aspect]));
      break;

    case HOTKEY_TOGGLE_VO_ASPECT:
      /* auto, square, 4:3, anamorphic or DVB */
      if (!OnlyInfo) {
        xc.vo_aspect_ratio = (xc.vo_aspect_ratio < VO_ASPECT_count-1) ? xc.vo_aspect_ratio + 1 : 0;
        m_Dev->ConfigureVideo(xc.hue, xc.saturation, xc.brightness, xc.sharpness,
                              xc.noise_reduction, xc.contrast, xc.overscan,
                              xc.vo_aspect_ratio);
      }
      Message = cString::sprintf("%s %s %s", tr("Video aspect ratio"),
                                 OnlyInfo ? ":" : "->",
                                 tr(xc.s_vo_aspects[xc.vo_aspect_ratio]));
      break;

    case HOTKEY_TOGGLE_CROP:
      /* off, force, auto */
      if (!OnlyInfo) {
        if (!xc.autocrop) {
          xc.autocrop = 1;
          xc.autocrop_autodetect = 1;
        } else if (xc.autocrop_autodetect) {
          xc.autocrop_autodetect = 0;
        } else {
          xc.autocrop = 0;
        }
        m_Dev->ConfigurePostprocessing("autocrop",
                                       xc.autocrop ? true : false,
                                       xc.AutocropOptions());
      }

      Message = cString::sprintf("%s %s %s", tr("Crop letterbox 4:3 to 16:9"),
                                 OnlyInfo ? ":" : "->",
                                 !xc.autocrop ? tr("Off") : xc.autocrop_autodetect ? tr("automatic") : tr("On"));
      break;

    case HOTKEY_DEINTERLACE:
      {
        /* off, on */
        int off = !strcmp(xc.deinterlace_method, "none");
        if (!OnlyInfo) {
          off = !off;
          if (off)
            strcpy(xc.deinterlace_method, "none");
          else
            strcpy(xc.deinterlace_method, "tvtime");
          m_Dev->ConfigurePostprocessing(xc.deinterlace_method, xc.audio_delay,
                                         compression, xc.audio_equalizer,
                                         xc.audio_surround, xc.speaker_type);
        }
        Message = cString::sprintf("%s %s %s", tr("Deinterlacing"),
                                   OnlyInfo ? ":" : "->",
                                   tr(off ? "Off":"On"));
      }
      break;

    case HOTKEY_UPMIX:
      /* off, on */
      if (!OnlyInfo) {
        xc.audio_upmix = xc.audio_upmix ? 0 : 1;
        m_Dev->ConfigurePostprocessing("upmix", xc.audio_upmix ? true : false, NULL);
      }
      Message = cString::sprintf("%s %s %s",
                                 tr("Upmix stereo to 5.1"),
                                 OnlyInfo ? ":" : "->",
                                 tr(xc.audio_upmix ? "On" : "Off"));
      break;

    case HOTKEY_DOWNMIX:
      /* off, on */
      if (!OnlyInfo) {
        xc.audio_surround = xc.audio_surround ? 0 : 1;
        m_Dev->ConfigurePostprocessing(
            xc.deinterlace_method, xc.audio_delay, xc.audio_compression,
            xc.audio_equalizer, xc.audio_surround, xc.speaker_type);
      }
      Message = cString::sprintf("%s %s %s",
                                 tr("Downmix AC3 to surround"),
                                 OnlyInfo ? ":" : "->",
                                 tr(xc.audio_surround ? "On":"Off"));
      break;

      case HOTKEY_PLAYLIST:
        /* Start replaying playlist or file pointed by
           symlink $(CONFDIR)/plugins/xineliboutput/default_playlist */
        {
          struct stat st;
          cString file = cString::sprintf("%s%s", cPlugin::ConfigDirectory("xineliboutput"), "/default_playlist");
          if (lstat(file, &st) == 0) {
            if (S_ISLNK(st.st_mode)) {
              cString buffer(ReadLink(file), true);
              if (!*buffer || stat(buffer, &st)) {
                Message = tr("Default playlist not found");
              } else {
                LOGDBG("Replaying default playlist: %s", *file);
                cPlayerFactory::Launch(m_Dev, buffer);
              }
            } else {
              Message = tr("Default playlist is not symlink");
            }
          } else {
            Message = tr("Default playlist not defined");
          }
        }
        break;

    case HOTKEY_ADELAY_UP:
      /* audio delay up */
      if (!OnlyInfo) {
        xc.audio_delay++;
        m_Dev->ConfigurePostprocessing(xc.deinterlace_method, xc.audio_delay,
                                       xc.audio_compression, xc.audio_equalizer,
                                       xc.audio_surround, xc.speaker_type);
      }
      Message = cString::sprintf("%s %s %d %s", tr("Delay"),
                                 OnlyInfo ? ":" : "->",
                                 xc.audio_delay, tr("ms"));
      break;

    case HOTKEY_ADELAY_DOWN:
      /* audio delay up */
      if (!OnlyInfo) {
        xc.audio_delay--;
        m_Dev->ConfigurePostprocessing(xc.deinterlace_method, xc.audio_delay,
                                       xc.audio_compression, xc.audio_equalizer,
                                       xc.audio_surround, xc.speaker_type);
      }
      Message = cString::sprintf("%s %s %d %s", tr("Delay"),
                                 OnlyInfo ? ":" : "->",
                                 xc.audio_delay, tr("ms"));
      break;

    default:
      Message = cString::sprintf(tr("xineliboutput: hotkey %s not binded"), cKey::ToString(Key));
      break;
  }

  if (*Message) {
    if (!xc.pending_menu_action &&
        !cRemote::HasKeys() &&
        cRemote::CallPlugin("xineliboutput"))
      xc.pending_menu_action = new cDisplayMessage(Message);
  }

  xc.last_hotkey_time = now;
  xc.last_hotkey = Key;

  return NewState;
}
bool cPluginXinelibOutput::Service(const char *Id, void *Data)
{
  if(Id) {
    char *CData = (char*)Data;

    if(!strcmp(Id, "MediaPlayer-1.0")) {
      if(CData && *CData) {
        LOGMSG("Service(%s, %s)", Id, CData);
        cPlayerFactory::Launch(m_Dev, pmAudioVideo, CData);
        return true;
      }
      LOGMSG("Service(%s) -> true", Id);
      return true;
    }

    else if(!strcmp(Id, "MusicPlayer-1.0")) {
      if(CData && *CData) {
        LOGMSG("Service(%s, %s)", Id, CData);
        cPlayerFactory::Launch(m_Dev, pmAudioOnly, CData);
        return true;
      }
      LOGMSG("Service(%s) -> true", Id);
      return true;
    }

    else if(!strcmp(Id, "DvdPlayer-1.0")) {
      if(Data && *CData) {
        LOGMSG("Service(%s, %s)", Id, CData);
        cPlayerFactory::Launch(m_Dev, pmNone, CData);
        return true;
      }
      LOGMSG("Service(%s) -> true", Id);
      return true;
    }

    else if(!strcmp(Id, "ImagePlayer-1.0")) {
      if(CData && *CData) {
        LOGMSG("Service(%s, %s)", Id, CData);
        cPlayerFactory::Launch(m_Dev, pmVideoOnly, CData);
        return true;
      }
      LOGMSG("Service(%s) -> true", Id);
      return true;
    }

    else if(!strcmp(Id, "StartFrontend-1.0")) {
      if(CData && *CData) {
        LOGMSG("Service(%s, %s)", Id, CData);
        int local_frontend = strstra(CData, xc.s_frontends, -1);
        if (local_frontend >= 0 && local_frontend < FRONTEND_count && strcmp(CData, xc.local_frontend)) {
          strn0cpy(xc.local_frontend, xc.s_frontends[local_frontend], sizeof(xc.local_frontend));
          m_Dev->ConfigureWindow(
               xc.fullscreen, xc.width, xc.height, xc.modeswitch, xc.modeline,
               xc.display_aspect, xc.scale_video);
        }
        return true;
      }
      LOGMSG("Service(%s) -> true", Id);
      return true;
    }

  }
  return false;
}