maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   OS2008 / Maemo 4 / Chinook - Diablo (https://talk.maemo.org/forumdisplay.php?f=29)
-   -   Understanding Maemo Mime handling (https://talk.maemo.org/showthread.php?t=15194)

qole 2008-03-11 17:22

Re: Understanding Maemo Mime handling
 
"dbus-switchboard loading..."

"MPlayer launching..."

Hey presto! There's my video.

Thanks, pipeline. No reboots or hassles involved. Just installed the .deb, edited the defaults.list and it worked.

As a side note, the built-in media player definitely handles .mp4 video better than mplayer. I was a bit shocked to discover that.

qole 2008-03-11 18:10

Re: Understanding Maemo Mime handling
 
Adding the following line to dbus-switchboard.desktop seems to speed up the process:

StartupNotify=false

tso 2008-03-11 18:47

Re: Understanding Maemo Mime handling
 
Quote:

Originally Posted by qole (Post 153537)
As a side note, the built-in media player definitely handles .mp4 video better than mplayer. I was a bit shocked to discover that.

not sure, but i suspect that there may be a dedicated decoder chip in there somewhere. something the mplayer cant access but the built in one maybe can.

this is also why i think nokia opposed going for ogg as a default web media, no hardware decoders...

qole 2008-03-11 23:29

Re: Understanding Maemo Mime handling
 
I just went to the garage page, the mplayer dev admits he hasn't optimized mplayer for .mp4 video yet, and that it doesn't handle it well, although he says that it is "fixed in SVN" so I guess we'll see an improvement in the next version.

pipeline 2008-03-12 00:06

Re: Understanding Maemo Mime handling
 
Thanks for StartupNotification setting... disabling hides this ugly part from user (as it should be). Not sure it speeds up much or any but its less distracting.

I guess ican add mp4 since its up to the user has to elect (by editing defaults.list) to have that mime type associated with dbus-switchboard anyways.

tso 2008-03-12 13:00

Re: Understanding Maemo Mime handling
 
now to get some kind of gui bolted onto it ;)

qole 2008-03-18 18:04

Re: Understanding Maemo Mime handling
 
Ok, more news.

I've been experimenting with Orb and getting video streaming working. The problem is that I can't stream ASX (WMV) files to mplayer, because Media Player always intercepts the call from the browser, and then, if I can get mplayer to take over using dbus-switchboard.py, mplayer doesn't understand the .asx file format!

So I embarked on my first jaunt into python programming, and I tweaked dbus-switchboard.py to open up an asx file and find the wmv file inside. Here's my new code (note the first two lines and the last line are old code, just to give context: )

Code:

#convert common hex encodings, and format and wrap in single quotes
argstr = "%s" % arguments

    #if the argument string is an asx file, find the wmv file
    if argstr.find(".asx") <> -1:
        fileHandle = open ( argstr, 'r' )
        fcont = fileHandle.read()
        newargstr = re.search('(<REF HREF=")(.*)("/>)', fcont)
        argstr = newargstr.group ( 2 )
        print "sending extracted wmv to mplayer:"
        print argstr

    argstr = argstr.replace("%5B", "[")

Oh, I almost forgot, I also had to add the following two import lines at the top of the program (to be able to read files and use regular expressions):
Code:

import sys
import re

I found I also had to remove a bunch of mime types from mp_ui.desktop (pretty much anything starting with 'video/x-ms-') to get dbus-switchboard.py to take the asx file at all. I also put a few extras into defaults.list, but I don't know if that had any effect.

The result? I can click on a "Play" link on my Orb page, and it will play in mplayer! The video is a bit "smeary," because I think mplayer is getting some frames that it doesn't know how to decode, but that's better than the built-in Media Player's halting, freezing, attempts to play RealMedia streams via Orb.

qole 2008-03-18 18:54

Re: Understanding Maemo Mime handling
 
I tried to add .flv (Flash video, like from YouTube) to the recognized mime types, but no luck. I added "video/x-flv" to the defaults.list, but the file manager still sees it as an "unknown file type". Anybody got any ideas?

If I choose "dbus switchboard" from the list of applications, everything works well (I added .flv to dbus-switchboard.py), but I can't figure how to make .flv files recognized by maemo.

EDIT: It looks like .flv files are being labeled as "application/octet-stream" so I just pointed application/octet-stream to dbus-switchboard, and now ALL unknown file types are being piped through there. Now Flash videos play from File Manager, but clicking on other unknown files does absolutely nothing... This is looking more and more like we should make this shim into a full-powered mime handler; if dbus-switchboard doesn't recognize the file type, ask the user what to do, and, unlike the current mime type handling (ask every time) REMEMBER what the user chose.

pipeline 2008-03-18 22:57

Re: Understanding Maemo Mime handling
 
Thanks for info about parsing asx... python isnt so bad (and great for stuff like this). I didnt know mplayer cant handle those asx 'wrappers' natively though.. i guess that makes sense though.

Good ideas on both counts, yes this could grow to be rather elaborate. I was planning on keeping the switchboard itself simple but i like idea of simple picklist when no association has been made yet... and a separate app to let you manage them all at once in visual app... working on common configuration file.

In order to be general purpose i need to copy sample to pass params to hildon app (acting as intermediary). That way dbus-switchboard can let you 'sink' the file to either a command-line app -or- dbus/hildon app.

So first guess i'd need to set up simple appregistry (like Name, DBUS-Support, mime-type, command-line) :
'mplayer def settings', 'false', '', '/usr/bin/mplayer %s'
'Media Player', 'true', 'whateverineedtopass', ''

And simple cross-ref config file (mimetype/sink) :
'video/x-flv', 'mplayer def settings'
'application/x-bittorrent', 'transmission'

With that setup then your newly added logic can check to see if its mplayer and if so it can handle your 'custom logic' where for Media Player it might not need to.

I knight you 'python-veteran' (btw im newb) and conscript you into the service :) I'm splitting time right now but the next thing to tackle is probably config files in /home/user/.somewhere and reading them into object array. Maybe if i can get that set up it will be easier for group contribution in permanent way.

residentsummer 2008-03-21 20:47

Re: Understanding Maemo Mime handling
 
Hello.
Pipeline: Can you add pdf handling (with evince) to you package? It will be very usefull for me(I hope, not for me only :) ). Thank you. :)


All times are GMT. The time now is 16:30.

vBulletin® Version 3.8.8