Você está na página 1de 52

Flumotion: streaming with Python, Twisted and GStreamer

T&o+a1 2ander Stic&ele t&o+a1 3at4 fluendo 3dot4 co+

10-7-7
Europython 2007, Vilnius
Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

C alibration

Adjusting the talk to the audience

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Overview

Introduction Flumotion architecture internals new in 0.4 a real customer making a product happy hacking

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Introduction

Who is Fluendo ? overview of Flumotion overview of GStreamer and Twisted a sample run

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Fluendo

Spanish (group of) companies built around GStreamer focusing on: streaming server and platform plugins and applications for GStreamer consultancy for multimedia and GStreamer Elisa

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Flumotion the project


A streaming server (*) GPL or Advanced license written in Python using GStreamer, Twisted focused on live streaming distributed and extensible multi-format end to end including player

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Flumotion the company

exploits a platform using Flumotion (the project) customers mostly in Spain built an additional layer on top of Flumotion for HA/load balancing

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

History

June 29 2004: First public use, 90 Mbit/sec Oct 20 2004: 0.1.0 Mar 03 2006: 0.2.0 Dec 22 2006: 500 Mbit/sec on one stream Jan 19 2007: 0.4.0

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Flumotion features: components

sources: Firewire, soundcard, videocard,


webcam, test, looper, DVB, playlist, ivtv

codecs: Vorbis, Theora, mulaw, JPEG,


smoke (but also ...)

consumption: effects:

HTTP streaming, RTSP streaming (coming soon), archiving colorbalance, overlaying, volume

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Flumotion features

friendly UI localized code distribution from central server runtime checks of software, devices, ...

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Flumotion target users

people and companies that want to extend the basic use scenario use media sources in multiple ways provide media in different codecs nice user experience use a free stack

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Flumotion users

Conferences: GUADEC FUDCON FISL LCA Radio stations A series of mosques RTVE, Antena3 a bunch of random people

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

GStreamer

written in C multimedia library elements in pipelines abstracting away lots of MM libraries optimized for speed threaded comes with bindings (*)

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

wisted

written in Python event-based framework central concepts: reactor (main loop) deferreds (promise of result) PB (client/server protocol) cooperative multitasking

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

sample run

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Flumotion architecture

manager, worker, and admin components planets, atmosphere and flows

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

processes
one manager process one or more workers connect to manager, receive code run components as a forked process one or more admin clients connect to manager, receive code sends commands to manager presents UI for components through manager all across the network

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

processes

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

components

run inside a spawn of the worker produce/consume/convert/combine feeds Twisted connection setup GStreamer data protocol or provide services (authentication, testing) combination of set of parameters collection of GStreamer elements wizard pages for configuration administration pages

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

configuration

planet is managed by a manager contains one or more flows separated from each other containing feed components contains one atmosphere containing components used by flow components

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Flumotion internals

streaming bundles wizard authentication state objects translatables Feel free to discuss these with me !

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

State objects

job processes have state from job to manager pid, mood, ... components have state from manager to admin mood, type, worker requested, ip, ... planet, flows, atmosphere have state -> tree Implements MVC for admin (*)

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

State objects

StateCacheable/StateRemoteCac he .addKey(), .addListKey() .get(), .set(), .append(), .remove() IStateListener for listeners to StateRemoteCache changes

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

ranslations An error happens in a component An admin client connects to the manager after the error ... ... and the admin client needs to show the translated error How do you make gettext do this ?

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

ranslations !"# Create a Translatable class That holds the format string, the arguments, and the domain Send this object to the admin Admin downloads bundles with .mo file for the language and translates locally show (*)

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Streaming

connection setup in python our code steals the socket from reactor we hand the fd to GStreamer all actual streaming is done on the C level

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

$undles partitioned module namespace to import code from transferred from the manager cached locally in workers and admin clients method registers bundle and modifies modules so normal import statements work

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

$undles

BundledFile: .hasChanged() Bundle: .setZip(), .getZip() Bundler: .add(), .bundle() BundlerBasket: registry of bundles .add(), .depend() getBundlerByName() getBundlerNameByFile(), ByImport()

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

$undles

Unbundler: .unbundle() flumotion.common.common.regi sterPackagePath() go in sys.path find package candidates add to __path__ of already loaded packages and modules

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

%eycards and bouncers something wants a service provided keycards are created: serializable abstracts away type information challenge/response sent to a bouncer component back and forth can be expired by bouncer

%eycards and bouncers Bouncer can be anywhere in the network Is very easy to write Specific bouncers written for customers GET request and token Filtered on IP HTTP authentication

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

&i'ard

scenario-based pulls in code while you make choices checks requirements workerside(*) tells manager to ask worker to run a callable from a module manager forwards worker gets bundle, runs and returns

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

(ew in )*+

porter on demand http server iCal bouncer and disker feeder information IVTV and playlist producer switch component

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

a real customer a TV channel has a news show not at a fixed time want it recorded and available immediately on the website too difficult to integrate with them we capture from TDT

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

a real customer

solution one: a web button to start and stop recording easy to miss/forget

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

a real customer

solution two: a barcode-like bit pattern at start and end of show includes CRC and data bits a component detects this pattern disker starts/stops recording

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

a real customer

further solutions: colored, not black and white watermarking ...

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

,roblems

What version of the code is running ? How do we discover network topology ?

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

-ersion

lots of flumotion processes on different machines modules imported at different times what version is running ?

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

(etwor. workers connect to managers manager needs to tell worker how to connect to other worker firewalls get in the way each TCP connection has four IP addresses Someone must have done this already

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Flumotion future ideas

live integration with PiTiVi video editor screencasts yelp integration bug reporting tools stream preview almost-live translation other admins (web, flash, mud, ...)

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

future use cases

picture-in-picture streams multi-audio streams live annotation using annodex high-res slides using Ogg + MNG + OpenOffice multiple codecs and bandwidths flash overlaying

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

/eveloping

Python UI standards focus on usability unit tests hacking the stack

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

the ,ython challenge

51cri'tin67 lan6ua6e no t8'in6 in declaration1 d8na+ic con1truct1 S'eed

Design document 8our !P% 'ro'erl8 unit test1


3e9a+'le4

i+'le+ent t&e +o1t-u1ed 'at&1 lo*erle:el 3;<!=EC


e9a+'le4

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

the ,ython nirvana


great bindings GTK, GStreamer easy prototyping quick development during programming great features rebuild modules and objects on the fly Twisted

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

0I standards

programmers try to avoid thinking about UI we try to follow the GNOME HIG the HIG does not talk about implementation unittest UI (show flumotion.test.test_greeter) ? stolen from gazpacho weird but works

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

usability

move to run-time checking devices, elements, library versions, ... (show library version check) use a graphic language to describe your program planets, moods, ... centralize all actions in one program

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Stac. hac.ing

A bug shows up using Flumotion Could be in Flumotion gst-python GStreamer library Python Kernel driver

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Happy Hac.ing

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Flumotion template

Sample add-on project Has: Build infrastructure Component code UI code Glade file translations

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

1uestions 2

thomas <at> fluendo <dot> com http://www.fluendo.com/ http://www.flumotion.net/ http://www.flumotion.com/

<BLINK>GET HIRED!</BLINK>

Fluendo S.L. - World Trade Center Edificio Norte 2 Pl. - Moll de Barcelona, 0803 B!"CEL#N! $ SP!%N &tt'())***.fluendo.co+ - ,3- 33./0.03

Você também pode gostar