[LINUX] xbmc server: possible quick implementation?
#1
Lightbulb 
i'm not that hot on C/C++, so bear with me, but when i was looking over the code i think i spotted a very quick and dirty way of getting a headless server up and running.

steps i'm currently making to get myself something to play with are as follows:

in xbmc.cpp we need a new 'else if' to allow for a '-s' or '--server' flag to fed in like this:

Code:
else if (strnicmp(argv[i], "-s", 2) == 0 || strnicmp(argv[i], "--server", 8) == 0)
      {
        g_application.SetServer(true);
      }

and then before we get to g_application.Run() we wrap the playlist startup code like so:

Code:
if (!g_application.IsServerMode())
  {
      if (playlist.Size() > 0)
      {
        g_playlistPlayer.Add(0,playlist);
        g_playlistPlayer.SetCurrentPlaylist(0);
      }

      ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_PLAY, (DWORD) -1};
      g_application.getApplicationMessenger().SendMessage(tMsg, false);
  }

This obviously requires an addition to Application.h:

Code:
void SetServerMode(bool value);

  bool IsServerMode()
  {
    return m_bServerMode;
  }

As well as the corresponding code in Application.cpp:

Code:
void CApplication::SetServerMode(bool value)
{
  g_advancedSettings.m_serverMode = m_bServerMode = value;
}

Same class, we also make some tweaks in the bool CApplication::Initialize() method:

Code:
...

  // skip the following if we're in server mode
  if (!g_application.IsServerMode())
  {
      StartServices();

      // Init DPMS, before creating the corresponding setting control.
      m_dpms = new DPMSSupport();
      g_guiSettings.GetSetting("powermanagement.displaysoff")->SetVisible(
          m_dpms->IsSupported());

      g_windowManager.Add(new CGUIWindowHome);                     // window id = 0

      ...

      //  Show mute symbol
      if (g_settings.m_nVolumeLevel == VOLUME_MINIMUM)
        Mute();

  }

  g_sysinfo.Refresh();

  CLog::Log(LOGINFO, "removing tempfiles");
  CUtil::RemoveTempFiles();


  // if the user shutoff the xbox during music scan
  // restore the settings
  if (g_settings.m_bMyMusicIsScanning)
  {
    CLog::Log(LOGWARNING,"System rebooted during music scan! ... restoring UseTags and FindRemoteThumbs");
    RestoreMusicScanSettings();
  }
  

  // skip the following if we're in server mode
  if (!g_application.IsServerMode())
  {
      if (!g_settings.UsingLoginScreen())
      {
        UpdateLibraries();
    #ifdef HAS_PYTHON
      g_pythonParser.m_bLogin = true;
    #endif
      }

    #ifdef __APPLE__
      XBMCHelper::GetInstance().CaptureAllInput();
    #endif
    #if defined(HAVE_LIBCRYSTALHD)
      CCrystalHD::GetInstance();
    #endif
      // reset our screensaver (starts timers etc.)
      ResetScreenSaver();
  }

  m_slowTimer.StartZero();
  
  CLog::Log(LOGNOTICE, "initialize done");

  m_bInitializing = false;

  return true;
}

Finally, AdvancedSettings.cpp needs the following in the CAdvancedSettings::Initialize() method:

Code:
m_serverMode = g_application.IsServer();

now, if i'm on the right lines, what i think this will do is to basically knock out all of the gui code from being started up when xbmc starts while still allowing the back end library stuff (i.e. the library management interface) to come up and run in the background. When I get a chance, I'll compile and try it out, but I wanted to check to see if a) this approach is feasible and b) if i'm going to miss anything important buried elsewhere in the code. one thing i think that might be missing from this is an automatic library update, but i think i can trigger that remotely or with a plugin.

anyone got any comments (including 'this isn't going to work' if applicable!)? or should i just go ahead and attempt to compile this and see what happens?

b
Reply


Messages In This Thread
[LINUX] xbmc server: possible quick implementation? - by bladesuk1 - 2011-11-14, 15:45
[No subject] - by spiff - 2011-11-14, 15:46
[No subject] - by bladesuk1 - 2011-11-14, 15:54
[No subject] - by spiff - 2011-11-14, 15:56
[No subject] - by bladesuk1 - 2011-11-14, 16:25
[No subject] - by spiff - 2011-11-14, 16:28
[No subject] - by Croaker - 2011-11-15, 14:07
[No subject] - by pko66 - 2011-11-15, 15:33
[No subject] - by branlr - 2011-11-15, 16:33
[No subject] - by TugboatBill - 2011-11-15, 17:51
[No subject] - by Croaker - 2011-11-17, 16:06
[No subject] - by Croaker - 2011-11-18, 13:05
[No subject] - by Montellese - 2011-11-18, 18:18
thanks for that... - by bladesuk1 - 2011-11-18, 19:17
[No subject] - by bladesuk1 - 2011-11-19, 18:01
[No subject] - by gugahoi - 2011-11-21, 02:43
[No subject] - by Robotica - 2011-11-21, 03:23
[No subject] - by darkscout - 2011-11-21, 03:40
[No subject] - by Croaker - 2011-11-21, 10:38
[No subject] - by bladesuk1 - 2011-11-21, 12:34
just fyi... - by bladesuk1 - 2011-11-21, 13:54
[No subject] - by niietzshe - 2011-11-28, 17:40
[No subject] - by Targettio - 2011-12-22, 14:53
[No subject] - by Robotica - 2011-12-22, 15:06
[No subject] - by bladesuk1 - 2011-12-22, 16:24
[No subject] - by Targettio - 2011-12-22, 17:06
[No subject] - by Robotica - 2011-12-22, 17:18
[No subject] - by Targettio - 2011-12-22, 17:28
[No subject] - by Robotica - 2011-12-22, 18:07
[No subject] - by Targettio - 2011-12-22, 19:21
[No subject] - by vikjon0 - 2011-12-23, 11:29
[No subject] - by Targettio - 2011-12-23, 14:03
[No subject] - by Fuwex - 2011-12-27, 15:52
[No subject] - by bladesuk1 - 2012-01-03, 13:59
[No subject] - by Odon - 2012-01-08, 15:08
[No subject] - by Robotica - 2012-01-08, 17:25
[No subject] - by Odon - 2012-01-08, 17:34
[No subject] - by Robotica - 2012-01-08, 17:41
[No subject] - by Odon - 2012-01-08, 18:37
[No subject] - by vikjon0 - 2012-01-08, 18:52
[No subject] - by bladesuk1 - 2012-01-09, 11:58
[No subject] - by bladesuk1 - 2012-01-09, 12:02
[No subject] - by Odon - 2012-01-09, 12:24
[No subject] - by vikjon0 - 2012-01-09, 12:29
[No subject] - by Odon - 2012-01-09, 12:50
[No subject] - by vikjon0 - 2012-01-09, 22:23
[No subject] - by Odon - 2012-01-09, 23:59
[No subject] - by bladesuk1 - 2012-01-10, 16:41
[No subject] - by Odon - 2012-01-10, 19:52
[No subject] - by bladesuk1 - 2012-01-10, 22:14
[No subject] - by Odon - 2012-01-11, 00:40
[No subject] - by Odon - 2012-01-11, 03:45
[No subject] - by bladesuk1 - 2012-01-11, 14:05
[No subject] - by Odon - 2012-01-11, 14:57
[No subject] - by Odon - 2012-01-11, 15:13
[No subject] - by bladesuk1 - 2012-01-11, 17:00
[No subject] - by j1nx - 2012-01-11, 18:01
[No subject] - by Odon - 2012-01-11, 20:42
[No subject] - by j1nx - 2012-01-12, 17:58
[No subject] - by prot - 2012-01-21, 00:25
[No subject] - by Odon - 2012-01-23, 02:55
[No subject] - by bladesuk1 - 2012-01-23, 11:43
[No subject] - by Targettio - 2012-01-27, 12:49
[No subject] - by prot - 2012-01-30, 00:21
[No subject] - by bladesuk1 - 2012-01-30, 14:35
[No subject] - by Robotica - 2012-02-03, 01:18
RE: - by Robotica - 2012-04-18, 23:03
[No subject] - by duststorm - 2012-02-08, 14:14
[No subject] - by Odon - 2012-02-10, 16:05
[No subject] - by bladesuk1 - 2012-02-10, 17:54
[No subject] - by Odon - 2012-02-10, 19:49
[No subject] - by Odon - 2012-02-10, 21:45
[No subject] - by Gomez - 2012-02-14, 17:38
[No subject] - by Ballistic - 2012-02-21, 22:27
[No subject] - by prot - 2012-03-01, 15:44
[No subject] - by niietzshe - 2012-03-09, 16:38
Logout Mark Read Team Forum Stats Members Help
[LINUX] xbmc server: possible quick implementation?1