63
Phonon Matthias Kretz What is Phonon? Design of Phonon Core Classes Code Examples User Visible Features How to Write a Backend Phonon Matthias Kretz former KView maintainer work on aRts and KDE Multimedia Student of Physics and Computer Science at the University of Heidelberg KDE Multimedia Meeting 2006

Phonon - static.kdenews.org

  • Upload
    others

  • View
    21

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Phonon

Matthias Kretz

former KView maintainer

work on aRts and KDE Multimedia

Student of Physics and Computer Science at the University of Heidelberg

KDE Multimedia Meeting 2006

Page 2: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Outline

What is Phonon?

Design of PhononCore ClassesCode ExamplesUser Visible FeaturesHow to Write a Backend

Page 3: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Multimedia API

I task-oriented designI 80/20I easy multimedia developmentI no “competition” for GStreamer/NMM like media

frameworksI in KDE SVN: trunk/KDE/kdelibs/phonon (or

branches/work/kdelibs4_snapshot/phonon)

Page 4: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Multimedia API

I task-oriented designI 80/20I easy multimedia developmentI no “competition” for GStreamer/NMM like media

frameworksI in KDE SVN: trunk/KDE/kdelibs/phonon (or

branches/work/kdelibs4_snapshot/phonon)

Page 5: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Multimedia API

I task-oriented designI 80/20I easy multimedia developmentI no “competition” for GStreamer/NMM like media

frameworksI in KDE SVN: trunk/KDE/kdelibs/phonon (or

branches/work/kdelibs4_snapshot/phonon)

Page 6: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Multimedia API

I task-oriented designI 80/20I easy multimedia developmentI no “competition” for GStreamer/NMM like media

frameworksI in KDE SVN: trunk/KDE/kdelibs/phonon (or

branches/work/kdelibs4_snapshot/phonon)

Page 7: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Multimedia API

I task-oriented designI 80/20I easy multimedia developmentI no “competition” for GStreamer/NMM like media

frameworksI in KDE SVN: trunk/KDE/kdelibs/phonon (or

branches/work/kdelibs4_snapshot/phonon)

Page 8: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Motivationthe user’s perspective

I A user should be able to playback any media withoutconfiguration steps

I “power users” want great flexibilityI additional multimedia hardware should be available

to all applications without any further stepsI users need to decide what device to use for what

purpose/programI KDE should not get in the way of “media producers”

Page 9: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Motivationthe user’s perspective

I A user should be able to playback any media withoutconfiguration steps

I “power users” want great flexibilityI additional multimedia hardware should be available

to all applications without any further stepsI users need to decide what device to use for what

purpose/programI KDE should not get in the way of “media producers”

Page 10: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Motivationthe user’s perspective

I A user should be able to playback any media withoutconfiguration steps

I “power users” want great flexibilityI additional multimedia hardware should be available

to all applications without any further stepsI users need to decide what device to use for what

purpose/programI KDE should not get in the way of “media producers”

Page 11: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Motivationthe user’s perspective

I A user should be able to playback any media withoutconfiguration steps

I “power users” want great flexibilityI additional multimedia hardware should be available

to all applications without any further stepsI users need to decide what device to use for what

purpose/programI KDE should not get in the way of “media producers”

Page 12: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Motivationthe user’s perspective

I A user should be able to playback any media withoutconfiguration steps

I “power users” want great flexibilityI additional multimedia hardware should be available

to all applications without any further stepsI users need to decide what device to use for what

purpose/programI KDE should not get in the way of “media producers”

Page 13: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Motivationthe developer’s perspective

I Qt/KDE style APII developers need APIs that are straightforward, easy

to use and understandI applications need a multimedia API that works on

UNIX systems (including OS X) and WindowsI ABI changes should not hinder KDE from using the

newest version of some media framework

Page 14: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Motivationthe developer’s perspective

I Qt/KDE style APII developers need APIs that are straightforward, easy

to use and understandI applications need a multimedia API that works on

UNIX systems (including OS X) and WindowsI ABI changes should not hinder KDE from using the

newest version of some media framework

Page 15: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Motivationthe developer’s perspective

I Qt/KDE style APII developers need APIs that are straightforward, easy

to use and understandI applications need a multimedia API that works on

UNIX systems (including OS X) and WindowsI ABI changes should not hinder KDE from using the

newest version of some media framework

Page 16: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Motivationthe developer’s perspective

I Qt/KDE style APII developers need APIs that are straightforward, easy

to use and understandI applications need a multimedia API that works on

UNIX systems (including OS X) and WindowsI ABI changes should not hinder KDE from using the

newest version of some media framework

Page 17: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Phonon Backends

Xine

Application

Phonon

Phonon−Xine

Page 18: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Phonon Backends

GStreamer

Application

Phonon

Phonon−GStreamer

Page 19: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Phonon Backends

NMM

Application

Phonon

Phonon−NMM

Page 20: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Outline

What is Phonon?

Design of PhononCore ClassesCode ExamplesUser Visible FeaturesHow to Write a Backend

Page 21: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

The Core Classes

AudioOutput

VideoOutput

send to

send to

AudioEffect

VideoEffect

VideoPath

AudioPathprocess audio in

process video in

MediaObjectMediaObject

Page 22: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

The Core Classes

AudioOutput

VideoOutput

send to

send to

AudioEffect

VideoEffect

VideoPath

AudioPathprocess audio in

process video in

MediaObjectMediaObject

VideoPath

AudioPathprocess audio in

process video in

Page 23: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

The Core Classes

AudioOutput

VideoOutput

send to

send to

AudioEffect

VideoEffect

VideoPath

AudioPathprocess audio in

process video in

MediaObjectMediaObject

VideoPath

AudioPathprocess audio in

process video in

AudioOutput

VideoOutput

send to

send to

Page 24: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

The Core Classes

AudioOutput

VideoOutput

send to

send to

AudioEffect

VideoEffect

VideoPath

AudioPathprocess audio in

process video in

MediaObjectMediaObject

VideoPath

AudioPathprocess audio in

process video in

AudioEffect

VideoEffect

AudioOutput

VideoOutput

send to

send to

Page 25: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

A Glance at the Phonon Classes

I BackendCapabilitiesI AbstractMediaProducer

I MediaObjectI ByteStreamI AvCapture

I AbstractAudioOutputI AudioOutputI AudioDataOutput

I AbstractVideoOutputI VideoWidgetI VideoDataOutput

I AudioPathI VideoPathI AudioEffect

I VolumeFaderEffect

I VideoEffect

I NameDescriptionTupleI AudioOutputDeviceI AudioCaptureDeviceI VideoOutputDeviceI VideoCaptureDeviceI AudioEffectDescriptionI VideoEffectDescription

I Ui::VideoWidgetI Ui::SeekSliderI Ui::VolumeSliderI Ui::MediaControlsI Ui::EffectWidget

Page 26: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

A Glance at the Phonon Classes

I BackendCapabilitiesI AbstractMediaProducer

I MediaObjectI ByteStreamI AvCapture

I AbstractAudioOutputI AudioOutputI AudioDataOutput

I AbstractVideoOutputI VideoWidgetI VideoDataOutput

I AudioPathI VideoPathI AudioEffect

I VolumeFaderEffect

I VideoEffect

I NameDescriptionTupleI AudioOutputDeviceI AudioCaptureDeviceI VideoOutputDeviceI VideoCaptureDeviceI AudioEffectDescriptionI VideoEffectDescription

I Ui::VideoWidgetI Ui::SeekSliderI Ui::VolumeSliderI Ui::MediaControlsI Ui::EffectWidget

Page 27: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

A Glance at the Phonon Classes

I BackendCapabilitiesI AbstractMediaProducer

I MediaObjectI ByteStreamI AvCapture

I AbstractAudioOutputI AudioOutputI AudioDataOutput

I AbstractVideoOutputI VideoWidgetI VideoDataOutput

I AudioPathI VideoPathI AudioEffect

I VolumeFaderEffect

I VideoEffect

I NameDescriptionTupleI AudioOutputDeviceI AudioCaptureDeviceI VideoOutputDeviceI VideoCaptureDeviceI AudioEffectDescriptionI VideoEffectDescription

I Ui::VideoWidgetI Ui::SeekSliderI Ui::VolumeSliderI Ui::MediaControlsI Ui::EffectWidget

Page 28: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

A Glance at the Phonon Classes

I BackendCapabilitiesI AbstractMediaProducer

I MediaObjectI ByteStreamI AvCapture

I AbstractAudioOutputI AudioOutputI AudioDataOutput

I AbstractVideoOutputI VideoWidgetI VideoDataOutput

I AudioPathI VideoPathI AudioEffect

I VolumeFaderEffect

I VideoEffect

I NameDescriptionTupleI AudioOutputDeviceI AudioCaptureDeviceI VideoOutputDeviceI VideoCaptureDeviceI AudioEffectDescriptionI VideoEffectDescription

I Ui::VideoWidgetI Ui::SeekSliderI Ui::VolumeSliderI Ui::MediaControlsI Ui::EffectWidget

Page 29: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

A Glance at the Phonon Classes

I BackendCapabilitiesI AbstractMediaProducer

I MediaObjectI ByteStreamI AvCapture

I AbstractAudioOutputI AudioOutputI AudioDataOutput

I AbstractVideoOutputI VideoWidgetI VideoDataOutput

I AudioPathI VideoPathI AudioEffect

I VolumeFaderEffect

I VideoEffect

I NameDescriptionTupleI AudioOutputDeviceI AudioCaptureDeviceI VideoOutputDeviceI VideoCaptureDeviceI AudioEffectDescriptionI VideoEffectDescription

I Ui::VideoWidgetI Ui::SeekSliderI Ui::VolumeSliderI Ui::MediaControlsI Ui::EffectWidget

Page 30: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

A Glance at the Phonon Classes

I BackendCapabilitiesI AbstractMediaProducer

I MediaObjectI ByteStreamI AvCapture

I AbstractAudioOutputI AudioOutputI AudioDataOutput

I AbstractVideoOutputI VideoWidgetI VideoDataOutput

I AudioPathI VideoPathI AudioEffect

I VolumeFaderEffect

I VideoEffect

I NameDescriptionTupleI AudioOutputDeviceI AudioCaptureDeviceI VideoOutputDeviceI VideoCaptureDeviceI AudioEffectDescriptionI VideoEffectDescription

I Ui::VideoWidgetI Ui::SeekSliderI Ui::VolumeSliderI Ui::MediaControlsI Ui::EffectWidget

Page 31: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

A Glance at the Phonon Classes

I BackendCapabilitiesI AbstractMediaProducer

I MediaObjectI ByteStreamI AvCapture

I AbstractAudioOutputI AudioOutputI AudioDataOutput

I AbstractVideoOutputI VideoWidgetI VideoDataOutput

I AudioPathI VideoPathI AudioEffect

I VolumeFaderEffect

I VideoEffect

I NameDescriptionTupleI AudioOutputDeviceI AudioCaptureDeviceI VideoOutputDeviceI VideoCaptureDeviceI AudioEffectDescriptionI VideoEffectDescription

I Ui::VideoWidgetI Ui::SeekSliderI Ui::VolumeSliderI Ui::MediaControlsI Ui::EffectWidget

Page 32: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

A Glance at the Phonon Classes

I BackendCapabilitiesI AbstractMediaProducer

I MediaObjectI ByteStreamI AvCapture

I AbstractAudioOutputI AudioOutputI AudioDataOutput

I AbstractVideoOutputI VideoWidgetI VideoDataOutput

I AudioPathI VideoPathI AudioEffect

I VolumeFaderEffect

I VideoEffect

I NameDescriptionTupleI AudioOutputDeviceI AudioCaptureDeviceI VideoOutputDeviceI VideoCaptureDeviceI AudioEffectDescriptionI VideoEffectDescription

I Ui::VideoWidgetI Ui::SeekSliderI Ui::VolumeSliderI Ui::MediaControlsI Ui::EffectWidget

Page 33: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Outline

What is Phonon?

Design of PhononCore ClassesCode ExamplesUser Visible FeaturesHow to Write a Backend

Page 34: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio Playbackthe simplest case

SimplePlayer

SimplePlayer* player = new SimplePlayer;player->play( "file:///home/user/song.ogg" );

seek/pause/stop

player->seek( milliseconds );player->pause();player->stop();

volume

float volume = player->volume();volume *= 0.5;player->setVolume( volume );

Page 35: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio Playbackthe simplest case

SimplePlayer

SimplePlayer* player = new SimplePlayer;player->play( "file:///home/user/song.ogg" );

seek/pause/stop

player->seek( milliseconds );player->pause();player->stop();

volume

float volume = player->volume();volume *= 0.5;player->setVolume( volume );

Page 36: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio Playbackthe simplest case

SimplePlayer

SimplePlayer* player = new SimplePlayer;player->play( "file:///home/user/song.ogg" );

seek/pause/stop

player->seek( milliseconds );player->pause();player->stop();

volume

float volume = player->volume();volume *= 0.5;player->setVolume( volume );

Page 37: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio Playbackwith more control

define the output

output = new AudioOutput;output->setCategory( Phonon::MusicCategory );path1 = new AudioPath;path1->addOutput( output );

AudioOutputAudioPathMediaObject

AudioOutputAudioPath

simple MediaObject use

media1 = new MediaObject;media1->addAudioPath( path1 );media1->setUrl( "file:///home/user/song.ogg" );media1->play();

Page 38: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio Playbackwith more control

define the output

output = new AudioOutput;output->setCategory( Phonon::MusicCategory );path1 = new AudioPath;path1->addOutput( output );

AudioOutputAudioPathMediaObject AudioOutputAudioPath

simple MediaObject use

media1 = new MediaObject;media1->addAudioPath( path1 );media1->setUrl( "file:///home/user/song.ogg" );media1->play();

Page 39: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio Playbackwith more control

define the output

output = new AudioOutput;output->setCategory( Phonon::MusicCategory );path1 = new AudioPath;path1->addOutput( output );

AudioOutputAudioPathMediaObject AudioOutputAudioPath

simple MediaObject use

media1 = new MediaObject;media1->addAudioPath( path1 );media1->setUrl( "file:///home/user/song.ogg" );media1->play();

Page 40: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio Playbackwith more control

define the output

output = new AudioOutput;output->setCategory( Phonon::MusicCategory );path1 = new AudioPath;path1->addOutput( output );

AudioOutputAudioPathMediaObject

AudioOutputAudioPath

simple MediaObject use

media1 = new MediaObject;media1->addAudioPath( path1 );media1->setUrl( "file:///home/user/song.ogg" );media1->play();

Page 41: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio Playbackadding a Fader

recall the AudioPath

path1 = new AudioPath;

AudioOutput

AudioEffect

AudioPathMediaObject AudioOutputAudioPathMediaObject

insert the Fader

fader1 = new VolumeFaderEffect;fader1->setVolume( 1.0 );path1->insertEffect( fader1 );

Page 42: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio Playbackadding a Fader

recall the AudioPath

path1 = new AudioPath;

AudioOutput

AudioEffect

AudioPathMediaObject AudioOutputAudioPathMediaObject

insert the Fader

fader1 = new VolumeFaderEffect;fader1->setVolume( 1.0 );path1->insertEffect( fader1 );

Page 43: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio Playbackadding a Fader

recall the AudioPath

path1 = new AudioPath;

AudioOutput

AudioEffect

AudioPathMediaObject

AudioOutputAudioPathMediaObject

insert the Fader

fader1 = new VolumeFaderEffect;fader1->setVolume( 1.0 );path1->insertEffect( fader1 );

Page 44: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio Playbackprepare next MediaObject for Crossfade

path2 = new AudioPath;path2->addOutput( output );media2 = new MediaObject;media2->addAudioPath( path2 );media2->setUrl( "file:///home/user/moremusic.

ogg" );fader2 = new VolumeFaderEffect;fader2->setVolume( 0.0 );path2->insertEffect( fader2 );

AudioOutput

AudioEffect

AudioEffect

AudioPath

AudioPath

MediaObject

MediaObject

Page 45: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio Playbackprepare next MediaObject for Crossfade

path2 = new AudioPath;path2->addOutput( output );media2 = new MediaObject;media2->addAudioPath( path2 );media2->setUrl( "file:///home/user/moremusic.

ogg" );fader2 = new VolumeFaderEffect;fader2->setVolume( 0.0 );path2->insertEffect( fader2 );

AudioOutput

AudioEffect

AudioEffect

AudioPath

AudioPath

MediaObject

MediaObject

Page 46: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Audio PlaybackCrossfade 2s before the first song ends

media1->setAboutToFinishTime( 2000 );connect( media1, SIGNAL( aboutToFinish( long )

), SLOT( crossfade( long ) ) );

void MyPlayer::crossfade( long remaining )

fader1->fadeOut( remaining );fader2->fadeIn( remaining );media2->play();

Page 47: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Outline

What is Phonon?

Design of PhononCore ClassesCode ExamplesUser Visible FeaturesHow to Write a Backend

Page 48: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

The Mixer

I Every AudioOutput has a volume controlI Volume can be read and written using IPCI Central “desktop-mixer” can then control the volume

of all Phonon applicationsI To not let the number of volume controls explode they

are be combined into the categories Notifications,Music, Movies, Games and Communication

Page 49: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Devices

I central place for device selectionI select device per categoryI applications can override the selection

Page 50: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Devices

I central place for device selectionI select device per categoryI applications can override the selection

Page 51: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Plug Your USB Headset

I hotplugging a device will change outputs to the newdevice if it is preferred

I consider VoIPI call comes inI you answer the call using the internal soundcardI plug in the USB headsetI notification shows that the device has been switchedI you can use your headset for the conversation now

Page 52: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Configurationor: Hiding tedious configuration work from the user

I applications should not need to configure the soundsystem, selecting the device to use is enough

I one central place for configurationI configuration options include

I default video output deviceI default capture devicesI whether to use a soundserver (the soundserver will

then be started by KDE and made available as adevice)

I backend specific options

I For system wide integration a shared configuration isneeded for the cases where hardware mixing orALSA dmix is unavailable

Page 53: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Network and Special Routingor: How to integrate NMM

I NMM provides for a high degree of networktransparency

I Out of scope for the Phonon APII IPC hooks in the NMM backendI NMM-Phonon control application

Page 54: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Outline

What is Phonon?

Design of PhononCore ClassesCode ExamplesUser Visible FeaturesHow to Write a Backend

Page 55: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Where do I Start?

I many classes to implementI starting point: Backend class

I mediaframework initializationI works as factory for all other classes

I then implement MediaObject, AudioPath andAudioOutput : enough for audio playback

Page 56: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Main Audio Playback Classes

MediaObject

I read and decode mediafileI play, pause, stop, seek, tickI takes multiple Audio - and VideoPath s

AudioPath

I defines routing (and signal processing)I takes multiple AudioOutput s

AudioOutput

I defines audio sinkI software volume control

Page 57: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Main Audio Playback Classes

MediaObject

I read and decode mediafileI play, pause, stop, seek, tickI takes multiple Audio - and VideoPath s

AudioPath

I defines routing (and signal processing)I takes multiple AudioOutput s

AudioOutput

I defines audio sinkI software volume control

Page 58: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Main Audio Playback Classes

MediaObject

I read and decode mediafileI play, pause, stop, seek, tickI takes multiple Audio - and VideoPath s

AudioPath

I defines routing (and signal processing)I takes multiple AudioOutput s

AudioOutput

I defines audio sinkI software volume control

Page 59: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Optimized

I MediaObject::setUrlI start decoding the media to fill audio and video

buffersI emit the length signalI prepare for calls to hasVideo(), seekable(),

availableAudioStreams(),availableVideoStreams(),availableSubtitleStreams and totalTime()

I MediaObject::add{Audio,Video}PathI preprocess audio/video buffers with effects defined

for the pathI prepare for output to the audio device if the

AudioOutput is known

Page 60: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Optimized cont.

I AbstractMediaProducer::play()I the backend should start playing immediatelyI the tick signal should be emitted - if possible without

pollingI effect change while playing

I buffers will make reaction sluggishI first priority: no dropoutsI second: no latency - overwrite as much of the buffers

with changed audio/video data as possible

Page 61: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

other MediaProducers

subclasses of AbstractMediaProducerI ByteStream

I same as MediaObjectI instead of reading media data located using a URL→ media data is passed (streamed) from theapplication (or frontend)

I AvCaptureI Backend i18n(“anbieten”) audio and video capture

devicesI one video and/or one audio capture device can be

selectedI implicitly synchronized

Page 62: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Two Designs

I 1:1I Phonon objects create and hold objects of the media

frameworkI good when there’s a 1:1 mapping between Phonon

classes and media framework classesI Phonon objects as description

I Phonon objects describe what the application wantsI Backend object(s) look at what the user wants and

wire media framework objects accordingly

Page 63: Phonon - static.kdenews.org

Phonon

Matthias Kretz

What is Phonon?

Design of PhononCore Classes

Code Examples

User Visible Features

How to Write a Backend

Summary

using Multimedia functionality in KDE 4 will be easier forI developersI users

Outlook

I network interfaces, DVD-/TV-Support, OSDI backend developmentI reviewI more tests, esp. backend “certification” tests