[LINUX] xbmc server: possible quick implementation? - Printable Version
+- XBMC Community Forum (http://forum.xbmc.org)
+-- Forum: Development (/forumdisplay.php?fid=32)
+--- Forum: Development (/forumdisplay.php?fid=93)
+--- Thread: [LINUX] xbmc server: possible quick implementation? (/showthread.php?tid=114612)
[LINUX] xbmc server: possible quick implementation? - bladesuk1 - 2011-11-14 15:45
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:
and then before we get to g_application.Run() we wrap the playlist startup code like so:
This obviously requires an addition to Application.h:
As well as the corresponding code in Application.cpp:
Same class, we also make some tweaks in the bool CApplication::Initialize() method:
Finally, AdvancedSettings.cpp needs the following in the CAdvancedSettings::Initialize() method:
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?
- spiff - 2011-11-14 15:46
you're running out of place because inlining patches are ... an interesting approach.
use a pastebin or trac or whatever and post a proper patch file.
- bladesuk1 - 2011-11-14 15:54
spiff Wrote:you're running out of place because inlining patches are ... an interesting approach.
i would if a) i knew how to create patch files and b) i was looking for anything more than a sanity check on what i'm thinking as a potential way to get a library management server
as i asked - does this look like like a feasible approach, or have i missed something? it seems to easy for someone else not to have spotted this earlier given that i know the subject's been raised before, but it's not beyond the realms of possibility...
- spiff - 2011-11-14 15:56
i can't really tell without the code being in context. but to me it looks like a poor man's solution.
i assume you cloned the code using git. to obtain the patch, all you have to do then is 'git diff > patchfile'
- bladesuk1 - 2011-11-14 16:25
spiff Wrote:i can't really tell without the code being in context
what do you need for context?
Quote:but to me it looks like a poor man's solution.
the ideal solution would be a dedicated server process. however, the current codebase isn't written in such a way that any such process can be cleanly extracted from the existing code, so there'd be a massive refactoring process to perform first to do this. for what you'd actually gain (and given the scarcity of people on the development team that seem interested in the server concept) this approach is, essentially, a quick fix to provide *something* that people can use until such time that the rest of the pieces are in place to create a proper server/client architecture, should xbmc development ever go down that route.
so, yes, i agree that it's basically a hack. however, as far as hacks go it's a clean and simple hack that actually replicates other similar processes in the codebase to change the program's behaviour (e.g. the nolirc option - this would be akin to a nogui option). most importantly, it keeps the 'server' code in the main codebase along with all the rest of the library access code so that it's all in one place and it can stay there until such time as the mainline code is architected in a way to make the server/client concept viable. it's also very minimal in terms of its impact, too - an extra flag, and a check on that flag to decide whether to run some code.
of course, if you have a better idea of how to go about this, then fill me in - but please bear in mind that a) i'm a web-and-database developer with very little C/C++ and b) i've got a toddler and a baby at home who'll take priority over pretty much everything
Quote:i assume you cloned the code using git. to obtain the patch, all you have to do then is 'git diff > patchfile'
nope - just a straight download of the .zip file, i'm afraid, so no git involvement at all. i'll get onto that anyway as i'll need to pull it down and compile it on my home machine to see what happens.
- spiff - 2011-11-14 16:28
context would be a what a patch offer. it shows exactly where code is inserted, where code is removed and so on.
- Croaker - 2011-11-15 14:07
interesting...prepared similar approach a while ago and stalled for similar reason too: doughter took most of my time
- pko66 - 2011-11-15 15:33
spiff Wrote:context would be a what a patch offer. it shows exactly where code is inserted, where code is removed and so on.
Hey spiff, bladesuk1, first my apologies for stepping to "explain" bladesuk1 modifications to spiff, maybe is not my place, but just trying to help...
I think that what bladesuk1 is trying to implement is a "server mode": me, and from the forum I think many other ppl, have an installation of several XBMC machines running with a central storage server (usually, a linux or windows not very powerful machine but with lots of hard disk space shared on the network). In that server, a MySQL daemon is used as a central repository for the database of the XBMC machines and a shared folder is used for storing media thumbnails. Also, usually some kind of (semi)automatic download process (flexget/transmission/couch potato/utorrent/whatever) adds new media continuously. The current XBMC architecture needs a XBMC instance (and only one, because two instances simultaneusly trying to update will break the database) to scrape the media and generate thumbnails.
The problem is, the server usually has not graphical capability to run XBMC, maybe the server does not even has an attached screen, so the database needs to be update from one of the clients manually (I have xbmc installed in my main windows computer just to do that). I think what blasesuk1 is trying to implement is a "server mode" xbmc that, simply, runs without GUI and does nothing but running the scrapers from time to time. That could be running in the server (or, maybe even better, in a virtual machine inside the server that could be virtually switched on and off when needed) and will update the database and create the thumbnails automatically whenever is needed. Maybe a "start, look for and scrape new media, optionally clean database and then exit when finished" mode could be included.
I, for one, would find that extremely useful.
- branlr - 2011-11-15 16:33
Indeed--it seems foolish to bog down the weak server system with a full XBMC install, but otherwise, you will be slaving your clients to another client machine that also must more or less remain running all of the time.
Especially when you consider that playback of the files isn't even possible on some of these headless servers, it makes sense to have a way of using the server features of XBMC without all of that overhead.
Although, it would be nice to have some sort of GUI for this "mode" so that certain library-relevant addons could be run, such as logo downloaders, automatic deletion, periodic update....
But, maybe that's implemented in the mysterious code above
- TugboatBill - 2011-11-15 17:51
This would be very helpful. I have an ESX system I use for my servers. With several XBMC boxes in the house I set up a server w/MySQL as my XBMC server. My plan was to do the scrapping on the server with an install of XBMC there too. Alas, XBMC won't run on it as virtual systems just don't have the video drivers that XBMC demands.
- Croaker - 2011-11-17 16:06
pko66 Wrote:Hey spiff, bladesuk1, first my apologies for stepping to "explain" bladesuk1 modifications to spiff, maybe is not my place, but just trying to help...
Just want to second that as it describes my situation 100%
- ubuntu server with MySQL, transmission, tvheadend, smb-shares, ...
- office-pc with embermm (and XBMC Eden testing, so not compatible with the others)
- 2 other XBMC boxes (Dharma for now, more to come, perhaps 1 OpenElec when they reach Eden)
so when new media arrives i have to
- unpack and move to correct folders (not automated this, not XBMC stuff)
- run renamer tool (also not XBMC stuff)
- run embermm and scrape (generates NFO+images)
- go to living room or get laptop running (start XBMC)
- start library update
as my collection grows nearly every day i have to perform those steps often and as the amount of data grows, some steps take a significant amount of time (1000+ movies, 20+ series about 5 modified often)
another crappy thing is this:
- new episodes arrive, but only english NFO data available, so take this for now
- XBMC shows en
- a week later german info is available, so getting that
- XBMC needs refresh and that kills the 'latest episodes' listing as the already watched go to the top of the list
this applies to movies too.
that's exactly what i'm aiming for... - bladesuk1 - 2011-11-17 16:44
it's exactly the situation you're talking about (albeit i'm not yet sharing thumbnails, but that's on the cards when i get some time). i'm basically trying to stop all of the graphical stuff from starting up by using a command line switch. yes, it's still a full installation of xbmc, but i'd hope that the scrapers and database interaction would be able to run headless... keep your fingers crossed!
yes, it would be nicer if all i was doing was running something to populate a database (the scraper utilities and so on) without any additional code overhead, but this side of the code isn't something that can currently be run independently as it stands. also, the database structures and so on change pretty much with every revision (what are we on, db revision 57 now or something like that?), so there's no way in hell you'd want to start writing a new entirely separate codebase to interact with those database changes as then you're maintaining the same code in two places. you'd have to essentially split the database management side of things off entirely and re-architect xbmc to use that project for the media server instead for that to work. occam's razor (for me) suggests keeping the code in the same place, and basically just not running anything that isn't required to do this and only this.
my initial post isn't up-to-date any more - the git revision was different to the dharma code i was looking at, so i've tried to switch to the git codebase instead. i'm most of the way there, but last time i tried it didn't start, and now i can't get the damn thing to compile. i'm pulling from git again, and i'm going to try from there to see what i can do. i'll let you know what happens
- Croaker - 2011-11-18 13:05
well, i've got *something* working... - bladesuk1 - 2011-11-18 16:57
haven't been able to test it as i'm currently remote, but *something* is running without a gui and hasn't fallen over for a while. if anyone else is in a position to try it out and see if it does what's expected, then by all means give it a go and let me know how you get on.
apply the patch, compile, and start it with xbmc --no-test --server and see what happens, i suppose!
anyways, here's the pastebin link:
i've managed to get a little bit of testing done... - bladesuk1 - 2011-11-18 18:12
and it looks like the webserver's running along with the eventserver, and it's connecting to the database. however, the jsonrpc side of things isn't starting up at the moment according to the logs:
ERROR: JSONRPC Server: Failed to bind serversocket
of course, there's no mention of which socket it's trying to use, and i've no idea if that's configurable anyway. still, it's a start, and proves that the general idea seems to be workable. if i can get the jsorpc server to start up, that should give us the back-end server that we want to play with
i'm still getting masses of mysql server connections, mind - don't know what the hell's going on with that, but it might be a known bug: