From: yomguy Date: Wed, 27 Apr 2011 11:20:52 +0000 (+0200) Subject: - fix streaming from processor although the new Apache directive WSGIApplicationGroup... X-Git-Tag: 1.1~281 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=c9a833c9ab845c6dca6a6ddcf9261fecc8984f94;p=telemeta.git - fix streaming from processor although the new Apache directive WSGIApplicationGroup %{GLOBAL} needed by the last TimeSide decoder prevents from giving a real first streaming (TODO). - Add examples for Apache2 mod-wsgi conf and django settings - Fix documentation --- diff --git a/INSTALL b/INSTALL index 88d22f68..c092d6d7 100644 --- a/INSTALL +++ b/INSTALL @@ -170,6 +170,11 @@ Just paste the lines below:: TELEMETA_DATA_CACHE_DIR = TELEMETA_CACHE_DIR + "/data" CACHE_BACKEND = "file://" + TELEMETA_CACHE_DIR + "/data" +You can find an example for settings.py there:: + + conf/examples/django/settings.py + + -------------------------- 5. Initialize the database -------------------------- @@ -186,6 +191,11 @@ This synchronizes the DB with the model:: The simplest case is to have telemeta running at public root. To do so, add this url in urls.py:: (r'^', include('telemeta.urls')), + (r'^i18n/', include('django.conf.urls.i18n')), + +You can find an example for url.py there:: + + conf/examples/django/urls.py -------------------- @@ -220,14 +230,18 @@ Enjoy it ! If you want to use Telemeta through a web server, it is highly recommended to use Apache 2 with the mod_wsgi module as explained in the following page : -http://docs.djangoproject.com/en/1.1/howto/deployment/modwsgi/#howto-deployment-modwsgi + http://docs.djangoproject.com/en/1.1/howto/deployment/modwsgi/#howto-deployment-modwsgi This will prevent Apache to put some audio data in the cache memory as it is usually the case with mod_python. +You can find an example of an Apache2 VirtualHost conf file there:: + + conf/examples/apache2/telemeta.conf + + ------------------------- 10. Contact / More infos ------------------------- See README and http://telemeta.org. - diff --git a/README b/README index 2c607bfc..508ef94a 100644 --- a/README +++ b/README @@ -81,7 +81,7 @@ Contact :Emails: Guillaume Pellerin , Olivier Guilyardi , - Riccardo Zaccarelli + Riccardo Zaccarelli Sponsors ======== @@ -99,4 +99,4 @@ The Telemeta project is developed by Parisson and Samalyse. It is sponsored by : http://www.musee-europemediterranee.org * MMSH : Maison Méditerranéenne des Sciences de l'Homme http://www.mmsh.univ-aix.fr/ - * The Antropponet Project + * The Antropponet Project (ended) diff --git a/conf/examples/apache2/telemeta.conf b/conf/examples/apache2/telemeta.conf new file mode 100644 index 00000000..ca39eb18 --- /dev/null +++ b/conf/examples/apache2/telemeta.conf @@ -0,0 +1,44 @@ + + ServerAdmin webmaster@localhost + ServerName telemeta.wm22.parisson.org + + LogLevel warn + ErrorLog ${APACHE_LOG_DIR}/error-telemeta.log + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + CustomLog ${APACHE_LOG_DIR}/access-telemeta.log combined + + Alias /media/ /home/dev/telemeta/sandboxes/sandbox_generic/media/ + + Order deny,allow + Allow from all + + + WSGIDaemonProcess telemeta_test user=momo group=momo threads=12 processes=4 maximum-requests=1000 + #deadlock-timeout=1000 + WSGIProcessGroup telemeta_test + WSGIApplicationGroup %{GLOBAL} + WSGIScriptAlias / /home/dev/telemeta/sandboxes/sandbox_generic/wsgi/sandbox_generic.wsgi + + + Order deny,allow + Allow from all + + +# Disallow browsing of Subversion working copy administrative dirs. + + Order deny,allow + Deny from all + + +# +# SetHandler None +# + +Alias /favicon.ico /home/dev/telemeta/telemeta-unstable/telemeta/htdocs/images/favicon.ico + + + SetHandler None + + + diff --git a/conf/examples/django/settings.py b/conf/examples/django/settings.py new file mode 100644 index 00000000..ce7ac900 --- /dev/null +++ b/conf/examples/django/settings.py @@ -0,0 +1,126 @@ +# -*- coding: utf-8 -*- +# Django settings for sandbox project. + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ADMINS = ( + ('Guillaume Pellerin', 'yomguy@parisson.com'), +) + +MANAGERS = ADMINS + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. +# 'OPTIONS': { 'init_command': 'SET storage_engine=INNODB', }, + 'NAME': 'telemeta_generic', # Or path to database file if using sqlite3. + 'USER': 'telemeta', # Not used with sqlite3. + 'PASSWORD': 'xxxxxxx', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# On Unix systems, a value of None will cause Django to use the same +# timezone as the operating system. +# If running in a Windows environment this must be set to the same as your +# system time zone. +TIME_ZONE = 'France/Paris' + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +#LANGUAGE_CODE = 'fr_FR' +LANGUAGES = [ ('fr', 'French'), + ('en', 'English'), +] + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True + +# If you set this to False, Django will not format dates, numbers and +# calendars according to the current locale +USE_L10N = True + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +MEDIA_ROOT = '/home/dev/telemeta/sandboxes/sandbox_generic/media/' + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash if there is a path component (optional in other cases). +# Examples: "http://media.lawrence.com", "http://example.com/media/" +MEDIA_URL = 'http://telemetagen.parisson.com/media/' + +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". +ADMIN_MEDIA_PREFIX = 'http://localhost/django/media/' + +# Make this unique, and don't share it with anybody. +SECRET_KEY = 'a8l7%06wr2k+3=%#*#@#hdie2mmzko)4jdloz(zx%lls^ihm9^5' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', +# 'django.template.loaders.eggs.Loader', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.locale.LocaleMiddleware', +) + +ROOT_URLCONF = 'sandbox_generic.urls' + +TEMPLATE_DIRS = ( + # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". + # Always use forward slashes, even on Windows. + # Don't forget to use absolute paths, not relative paths. +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + 'django.contrib.admin', + 'telemeta', + 'jsonrpc', +) + +TEMPLATE_CONTEXT_PROCESSORS = ( + 'django.core.context_processors.request', + 'django.contrib.auth.context_processors.auth', +) + + +TELEMETA_ORGANIZATION = 'Parisson' +TELEMETA_SUBJECTS = ('telemeta', 'tests') +TELEMETA_GMAP_KEY = 'ABQIAAAArg7eSfnfTkBRma8glnGrlxRVbMrhnNNvToCbZQtWdaMbZTA_3RRGObu5PDoiBImgalVnnLU2yN4RMA' +TELEMETA_DOWNLOAD_ENABLED = True +TELEMETA_PUBLIC_ACCESS_PERIOD = 51 +AUTH_PROFILE_MODULE = 'telemeta.userprofile' + +LOGIN_URL = '/login' +LOGIN_REDIRECT_URL = '/' +EMAIL_HOST = 'smtp.free.fr' +DEFAULT_FROM_EMAIL = 'webmaster@parisson.com' + +TELEMETA_CACHE_DIR = MEDIA_ROOT + 'cache' +TELEMETA_EXPORT_CACHE_DIR = TELEMETA_CACHE_DIR + "/export" +TELEMETA_DATA_CACHE_DIR = TELEMETA_CACHE_DIR + "/data" +CACHE_BACKEND = "file://" + TELEMETA_CACHE_DIR + "/data" +SESSION_EXPIRE_AT_BROWSER_CLOSE = False + diff --git a/conf/examples/django/urls.py b/conf/examples/django/urls.py new file mode 100644 index 00000000..55f5df59 --- /dev/null +++ b/conf/examples/django/urls.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from django.conf.urls.defaults import * + +# Uncomment the next two lines to enable the admin: +from django.contrib import admin +admin.autodiscover() + +urlpatterns = patterns('', + # Example: + # (r'^sandbox/', include('sandbox.foo.urls')), + + # Uncomment the admin/doc line below and add 'django.contrib.admindocs' + # to INSTALLED_APPS to enable admin documentation: + # (r'^admin/doc/', include('django.contrib.admindocs.urls')), + + # Uncomment the next line to enable the admin: + (r'^djangoadmin/', include(admin.site.urls)), + (r'^', include('telemeta.urls')), + # Languages + (r'^i18n/', include('django.conf.urls.i18n')), +) diff --git a/telemeta/web/base.py b/telemeta/web/base.py index 7b796a95..8e8d0ac5 100644 --- a/telemeta/web/base.py +++ b/telemeta/web/base.py @@ -78,15 +78,12 @@ def render(request, template, data = None, mimetype = None): return render_to_response(template, data, context_instance=RequestContext(request), mimetype=mimetype) -def stream_from_processor(decoder, processor): - _decoder = decoder - _processor = processor +def stream_from_processor(__decoder, __processor): while True: - __frames, eod = _decoder.process() - __chunk, eodproc = _processor.process(_frames, eod) + __frames, eodproc = __processor.process(*__decoder.process()) if eodproc: break - yield __chunk + yield __processor.chunk def stream_from_file(file): chunk_size = 0x10000 @@ -528,13 +525,12 @@ class WebView(object): else: if not self.cache_export.exists(file): - if not decoder: - decoder = timeside.decoder.FileDecoder(audio) + decoder = timeside.decoder.FileDecoder(audio) # source > encoder > stream decoder.setup() media = self.cache_export.dir + os.sep + file proc = encoder(media, streaming=True) - proc.setup(channels=decoder.channels(), samplerate=decoder.samplerate(), nframes=decoder.nframes()) + proc.setup(channels=decoder.channels(), samplerate=decoder.samplerate()) # metadata = dublincore.express_item(item).to_list() # enc.set_metadata(metadata) response = HttpResponse(stream_from_processor(decoder, proc), mimetype = mime_type)