2011-12-31, 20:20
Okay so I realise about 6 months have passed since I said I'd try to some stuff with it. Had little time and motivation until today.
My plan for this plugin was mainly video usage. 6 months ago my problems with the add-on where the following :
a) Bit rate settings too low.
b) I proxy via mod_proxy under ssl and use basic authentication for my external subsonic. Yeah I know I'm paranoid.
c) When playing files in the plugin it would start multiple ffmpegs on the server and start multiple streams to xbmc.
============
I fixed a) one the following simple change :
Settings.xml
to
and
Subsonic.py
Nice and simple.
======
I fixed b) with the following function changes. https was working fine it was the basic auth that was causing the problem. I don't think this would cause an issue if basic auth was switched off but saying that I didn't test it.
Subsonic.py
======
c) was somewhat tricker. Have no clue about xbmc or python addons I just assumed it was some problem with the plugin. However after digging these seems to be a problem with the way Xbmc Interacts with Subsonic.
It looks as though instead of just getting the stream from subsonic with a GET request it will do one or more HEAD request first. I can only guess this is so that it can select the right player.
Subsonic doesn't differentiate between the HEAD and GET and sends the full body instead of just the http header. So hence the multiple streams.
Here is a change I made to subsonic to get around this issue :
StreamController.java
to
I just compiled the project and replaced this class file with a tomcat restart.
I suspect this may also have caused symptoms like having to manually select the DVD Player which just worked after this change.
========
I tried this with xbmc running on an original xbox and on xbmc running on an atv2. Both worked really well after these changes.
Disclaimer : I'm not a python/java developer so these mods may not be the best way to handle these problems and may be a bit "hacky".
Dybuk
My plan for this plugin was mainly video usage. 6 months ago my problems with the add-on where the following :
a) Bit rate settings too low.
b) I proxy via mod_proxy under ssl and use basic authentication for my external subsonic. Yeah I know I'm paranoid.
c) When playing files in the plugin it would start multiple ffmpegs on the server and start multiple streams to xbmc.
============
I fixed a) one the following simple change :
Settings.xml
Code:
<setting id="bitrate" type="enum" label="30105" default="13" values="32k|40k|48k|56k|64k|80k|96k|112k|128k|160k|192k|224k|256k|320k" enable="eq(-1,true)" />
to
Code:
<setting id="bitrate" type="enum" label="30105" default="13" values="32k|40k|48k|56k|64k|80k|96k|112k|128k|160k|192k|224k|256k|320k|512K|720K|1024K|1500K|2048K" enable="eq(-1,true)" />
and
Subsonic.py
Code:
bitrates = [32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320]
Code:
bitrates = [32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 512, 720, 1024, 1500, 2048]
Nice and simple.
======
I fixed b) with the following function changes. https was working fine it was the basic auth that was causing the problem. I don't think this would cause an issue if basic auth was switched off but saying that I didn't test it.
Subsonic.py
Code:
def play(self, song_id):
Addon.log('play: ' + song_id)
if Addon.get_setting('transcode') == 'true':
bitrate = self.bitrates[int(Addon.get_setting('bitrate'))]
non_user_url = self.build_rest_url('stream.view',
{'id': song_id,
'maxBitRate': bitrate});
user_url = non_user_url.replace("://", "://" +self.user + ":" + self.password + "@",1)
Addon.resolve_url(user_url)
else:
Addon.resolve_url(self.build_rest_url('download.view',
{'id': song_id}))
....
def __get_json(self, method, queries={}):
json_response = None
url = self.build_rest_url(method, queries)
Addon.log('getting ' + url)
try:
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, self.server, self.user, self.password)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
response = urllib2.urlopen(url)
try:
json_response = json.loads(response.read())
except ValueError:
Addon.show_error([Addon.get_string(30002)])
return False
except urllib2.URLError, e:
Addon.show_error([Addon.get_string(30001), str(e.reason)])
return False
payload = json_response.get('subsonic-response', None)
if payload.get('status', 'failed') == 'ok':
return payload
else:
Addon.show_error([payload['error']['message'],
'json version: ' + payload['version']])
return False
======
c) was somewhat tricker. Have no clue about xbmc or python addons I just assumed it was some problem with the plugin. However after digging these seems to be a problem with the way Xbmc Interacts with Subsonic.
It looks as though instead of just getting the stream from subsonic with a GET request it will do one or more HEAD request first. I can only guess this is so that it can select the right player.
Subsonic doesn't differentiate between the HEAD and GET and sends the full body instead of just the http header. So hence the multiple streams.
Here is a change I made to subsonic to get around this issue :
StreamController.java
Code:
....
String transcodedSuffix = transcodingService.getSuffix(player, file, preferredTargetFormat);
response.setContentType(StringUtil.getMimeType(transcodedSuffix));
if (file.isVideo()) {
videoTranscodingSettings = createVideoTranscodingSettings(file, request);
}
....
to
Code:
String transcodedSuffix = transcodingService.getSuffix(player, file, preferredTargetFormat);
response.setContentType(StringUtil.getMimeType(transcodedSuffix));
if (request.getMethod().equals("HEAD"))
{
return null;
}
if (file.isVideo()) {
videoTranscodingSettings = createVideoTranscodingSettings(file, request);
}
I just compiled the project and replaced this class file with a tomcat restart.
I suspect this may also have caused symptoms like having to manually select the DVD Player which just worked after this change.
========
I tried this with xbmc running on an original xbox and on xbmc running on an atv2. Both worked really well after these changes.
Disclaimer : I'm not a python/java developer so these mods may not be the best way to handle these problems and may be a bit "hacky".
Dybuk