#390 Adds basic proxy support for http source

This commit is contained in:
Alexandre Petitjean 2014-02-13 10:49:56 +01:00
parent d0a305a8e2
commit de21872d67

View File

@ -102,6 +102,7 @@ class Audio(pykka.ThreadingActor):
self._connect(playbin, 'about-to-finish', self._on_about_to_finish)
self._connect(playbin, 'notify::source', self._on_new_source)
self._connect(playbin, 'source-setup', self._on_source_setup)
self._playbin = playbin
@ -133,6 +134,22 @@ class Audio(pykka.ThreadingActor):
self._appsrc = source
def _on_source_setup(self, element, source):
uri = element.get_property('uri')
if not uri or not uri.startswith('http://'):
return
if self._config['proxy']['hostname']:
full_proxy = self._config['proxy']['hostname']
if self._config['proxy']['port']:
full_proxy += ':' + str(self._config['proxy']['port'])
if self._config['proxy']['scheme']:
full_proxy = self._config['proxy']['scheme'] + "://" + full_proxy
source.set_property('proxy', full_proxy)
source.set_property('proxy-id', self._config['proxy']['username'])
source.set_property('proxy-pw', self._config['proxy']['password'])
def _appsrc_on_need_data(self, appsrc, gst_length_hint):
length_hint = utils.clocktime_to_millisecond(gst_length_hint)
if self._appsrc_need_data_callback is not None:
@ -153,6 +170,7 @@ class Audio(pykka.ThreadingActor):
def _teardown_playbin(self):
self._disconnect(self._playbin, 'about-to-finish')
self._disconnect(self._playbin, 'notify::source')
self._disconnect(self._playbin, 'source-setup')
self._playbin.set_state(gst.STATE_NULL)
def _setup_output(self):