Ikke's Blog

Post details: New prototype

Apr 19
New prototype

Lots of traffic on GIMPNet today, many different and interesting things were discussed between some GNOME hackers. But I guess others will write about those things (Philip? Jeff?).
Anyway, more related to myself and my own project (yeah, CDIS, you know): I had a great talk with Robert "Robot101" McQueen, who gave some very sensible insights in the D-BUS system, and how I could (ab)use it.
First of all, last night I was thinking about the D-BUS glossary a little, and came to the conclusion that "interfaces" might at a certain level be compared to "namespaces" instead of "interfaces", at least in some point of views. Might be interesting if you try to "get" D-BUS. Questions? Leave a comment ;-)

After this talk and some help from J5, #1 python-dbus guru, I managed to get a new sample setup working. In this new design, there is no central daemon at all any longer, which is great, obviously. Some changes/enhancements to the D-BUS bindings might be necessary though (I hate the fact you can't get the sender service/object path in a signal handler!).

As a picture says more than a thousand words, first open up this screenshot. Code's here.
As you can see, first the user starts his favorite media player, RhythmBox, and spins his favorite song (1). In the background, a screensaver application is running (in the sample I started it after RB, but hey, its a sample) (2). After a while (3 seconds ;-)), the user starts his VoIP softphone, Ekiga (3). As the user is very popular, he almost immediately receives a call, and accepts it (4).
As you can see, Ekiga knows about music players, and asks them to pause playback. RB is CDIS-aware, and stops playing (5). Obviously, the music player should do a generic "Paused" signal here (see later). Next, Ekiga sends out a signal on the org.freedesktop.CDIS.SoftPhone interface, "IncomingCall". This signal can be used by any application listening for it. It is not related to pausing music players: in (4-5), Ekiga tells all music players to pause. It knows about this kind of applications, and knows how to handle them. In (6) Ekiga provides application types it doesn't know about (or, maybe more likely, doesn't want to know about, doesn't care about) to do some action based on the fact there's an incoming call.
As this is a video conference, the screensaver traps that signal, and stops his internal timer (7).
After a while, the call is over, the user disconnects (8). Ekiga sends now tells all music players they can resume playback if they were playing before (9). It also sends out a "CallTerminated" signal on the SoftPhone interface, which is again seen by the screensaver, who restarts his timer.
Then, something happens that will/should not be supported, but I just implemented it as a sample. When the screensaver decides it's time to blank the screen (11), it tells all SoftPhones to go "Idle" (12). This is not the way we should handle this in "real" applications, as a screensaver should not put SoftPhones in idle state, it should send out a signal "ScreenSaverStarted", the softphone should watch for that one, and go idle when the screen blanks. Anyway, I just wanted to give one more example of the "action" paradigm, just like "Pause" and "Resume" on the MediaPlayer interface.

As usual, the prototype code is extremely ugly, but it does show what I got in mind regarding code generation. There should be 3 "objects":

  • CdisMusicPlayer: inherited by a "real" music player, or by some internal CdisHandler object. Needs function pointers to all supported CDIS function calls. In the sample, used by RhythBox.
  • CdisMusicPlayerController: Used by code that wants to control a class of applications. Used by Ekiga to pause all music players. Only provides "active" functions that, when called, result in a change on remote objects.
  • CdisSoftPhoneClient: helper class for "generic" applications that want to be notified about things by a SoftPhone application. Used by ScreenSaver to be able to work with SoftPhone applications on the system, as the SoftPhone doesnt know about screensavers

For all of these objects, I'm sure there's some pattern for them. Philip, help! :-)

This should be fairly clear I guess... If not, ask. Lots of things can/will/should change, eg authorisation, and issue raised by sri yesterday. Don't know yet how this should be tackled thogh.
Duplicate events should be prohibited too (although this can for a big part be done by having well designed interfaces): when app A asks MusicPlayers to pause, then B does the same, and A sends a "Resume" signal, the player(s) should not resume unless B also sends the "Resume" command. This and other issues will need to be fixed!

After all a pretty fun day :-) Although you can't imagine how much I hate Blast by now :> Big thanks to all help on IRC, I should get all of you a beer at GUADEC. Sadly enough due to exams I can't be there though ;-)

Comments:

Comment from: Nathan [Visitor]
Whoo...this is great to read. Ekiga needs this...I use it as my primary phone, and whenever I get a call and I'm listening to music, I have to rush to stop the music and answer. Is there any chance of this working with MPC/MPD?
PermalinkPermalink 04/20/06 @ 03:38
Comment from: bkor [Visitor]
Nice! Finally some good use of dbus.
PermalinkPermalink 04/20/06 @ 07:53
Comment from: j [Visitor]
nice, but shouln't that be MediaPlayer and not MusicPlayer,
totem should also pause playing videos if in window mode,
mediaplayer fullscreen mode should be a bit like screensaver,
i.e. phone and a jabber client setting the state bussy.

what about fullscreen presentations with OO or evince -
no jabber or phone windows poping up, no notifications
PermalinkPermalink 04/20/06 @ 11:48
Comment from: Ikke [Member] · http://www.eikke.com
There are hundreds of things that can be combined. I'm not going to write up all interface specs and patch all applications. What I do want to do though is come up with an interface specification format, tools to write helper code based on these specs, and patch some apps/help others patching their app.
So yes, it could work with MPC, or if someone writes a "Presentation" spec, OO and Evince could implement that interface and be able to disable screensavers or whatever more.

About MediaPlayer vs MusicPlayer: is should be MusicPlayer, and VideoPlayer, as a MusicPlayer doesn't "use" the screen: a screensaver *may* pop up. A VideoPlayer should prevent the Screensaver to blank when it's playing a movie (whether it's fullscreen or not). Or when a video is playing fullscreen, one might indeed want his IM status to be "Idle", and disable notification icons. When your softphone is running though, and you're getting a call while watching a DVD, you might want to get notified of this anyway though, then when picking up the phone, the movie might be shrinked to a normal window again, and paused, untill you stop the call, where it becomes fullscreen again and starts playing. Whatever, it's up to application developers and users to figure out what suits them best.
PermalinkPermalink 04/20/06 @ 12:21
Comment from: George [Visitor]
OK but there must be a way to keep the music playing. Sometimes I talk on voip AND still want to listen to my music in the bakground. This has to be flexable or it will piss off a major number of people who like auto controls but alsoa want human intervention.
PermalinkPermalink 04/20/06 @ 16:42
Comment from: JoseSogo [Visitor]
George,
Of course that will depend or on the client, or there will be a "CDIS manager" in which you can define a set of policies that will be followed where some signal is emitted.
PermalinkPermalink 04/20/06 @ 20:10
Comment from: Ikke [Member] · http://www.eikke.com
I don't think central management is a good idea (although it might be used). Every application should allow you to enable or disable specific behaviour though, both the controlees ("Enable other apps to pause playback") and the controllers ("Pause music playback when I'm calling")
PermalinkPermalink 04/20/06 @ 22:42
Comment from: make money at home [Visitor] · http://www.howto-getrich.com
Great article, that was interesting
PermalinkPermalink 05/01/06 @ 00:56
Comment from: jg [Visitor] Email
Is there a way to allow the softphone to pop when the screen saver has kicked in?
without having to enter the unlock credentials?
PermalinkPermalink 11/09/07 @ 22:31

This post has 2 feedbacks awaiting moderation...

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))

Categories

Who's Online?

  • Guest Users: 202

Misc

XML Feeds

What is RSS?