Opened 19 years ago

Closed 18 years ago

#303 closed enhancement (fixed)

Some code to guess the category of an insert cd/dvd

Reported by: anonymous Owned by: danielk
Priority: minor Milestone: 0.20
Component: mythtv Version: head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

Attached is a small patch that tries to figure out the category of data present on a cd/dvd. The idea is to use this info to atomatically start the right plugin when a cd/dvd is inserted.

Attachments (4)

DetectMediaType.diff (3.7 KB) - added by anonymous 19 years ago.
extensions-mythtv.diff (9.8 KB) - added by leo weppelman 19 years ago.
extend REG_MEDIA_HANDLER to handle extensions (mythtv-part)
extensions-plugins.diff (1.4 KB) - added by leo weppelman 19 years ago.
extend REG_MEDIA_HANDLER to handle extensions (mythplugins-part)
303.patch (11.8 KB) - added by danielk 18 years ago.
updated version of patch (not reviewed yet).

Download all attachments as: .zip

Change History (19)

Changed 19 years ago by anonymous

Attachment: DetectMediaType.diff added

comment:1 Changed 19 years ago by leo@…

Sorry, it was not my intention to file this anonymous. I'm responsible for this piece of code ;-)

comment:2 Changed 19 years ago by jdonavan

Mind tweaking this to not use static lists and pull it from the database instead?

comment:3 Changed 19 years ago by jdonavan

Milestone: 0.19
Owner: changed from Isaac Richards to jdonavan
Status: newassigned

comment:4 Changed 19 years ago by leo@…

Not at all. But currently there is no table with these extensions. Well, mythvideo has 'videotypes', that might be used. We could create audiotypes, gallery types etc... Another option is to create a table that maps suffixes to a media category, more or less the data of the now static array but stored in the database.

Suggestions?

comment:5 Changed 19 years ago by jcaputo1 (at) comcast.net

Would it be of any benefit to use some system-supported mapping of extensions to MIME types (maybe system() out the "file -i" command?) and then use the MIME major type ("text/", "video/", "audio/", "image/", "application/") to map to the appropriate module for handling that type of media?

comment:6 Changed 19 years ago by leo weppelman

Using file(1) the time used on a CD with mp3-file is 28sec! There were 155 mp3 files on this disk. I also have dvd's with mp3's. Extrapolating the previous, this will take about 3 minutes to scan. Only retrieving the filenames takes about 1/5 second on the 155 mp3 files.... That's why I used the extension ;-)

comment:7 Changed 19 years ago by jcaputo1 (at) comcast.net

I didn't mean that file(1) necessarily had to be used; only that it might be a good idea to use MIME types instead of custom internal enumerations; and if we use MIME types, then it would probably be of some benefit to see if there isn't something that's usable to determine the MIME type from the extension. If there isn't something that can be (efficiently) used, I'd still recommend internally mapping extensions to MIME types instead of custom enumerations.

Changed 19 years ago by leo weppelman

Attachment: extensions-mythtv.diff added

extend REG_MEDIA_HANDLER to handle extensions (mythtv-part)

Changed 19 years ago by leo weppelman

Attachment: extensions-plugins.diff added

extend REG_MEDIA_HANDLER to handle extensions (mythplugins-part)

comment:8 Changed 19 years ago by leo weppelman

I added 2 new diff-files that together implement the extension registration by adding an extra argument to REG_MEDIA_HANDLER(). The bulk of the code also moved from mythcdrom.cpp to mythmedia.cpp...

The first pach is obsolete by now...

comment:9 Changed 18 years ago by anonymous

Owner: changed from jdonavan to Isaac Richards
Status: assignednew

comment:10 Changed 18 years ago by danielk

Milestone: 0.190.20
Version: head

jdonovan, this was reassigned by 'anonymous' to Isaac.. I'm leaving to you to reassign

comment:11 Changed 18 years ago by leo@…

The function void MythMediaDevice::DetectMediaType?(void) has a bug. It does not reset the value of 'score'. At the head of the code block in the for-loop:

  for (em = ExtensionMapList.first(); em; em = ExtensionMapList.next())

The statement 'score = 0;' should be added.

I can generate a new diff on request, but I think the above will suffice for now.

comment:12 Changed 18 years ago by danielk

Owner: changed from Isaac Richards to danielk

Changed 18 years ago by danielk

Attachment: 303.patch added

updated version of patch (not reviewed yet).

comment:13 Changed 18 years ago by danielk

Resolution: fixed
Status: newclosed

(In [10095]) Closes #303. Enhances media detection by looking at file name extensions with modified patch from Leo Weppelman.

If we can't detect a type other than "DATA" by any other means (such as used for DVDs and CDs), then with this patch we look at the file extensions, and select the media handler which will handle the greatest number of files on the device.

For example we count things such as "gif,jpg,png" and "ogg,mp3,aac,flac" and use the one with the highest file count to select mythgallery or mythmusic, resp. (This is assuming both media plugins are present.)

BTW This is surprisingly fast for the photo cd's I have laying around.

NOTE: This changes the MYTH_BINARY_VERSION, so plugins must be recompiled and installed after you've installed the updated mythtv libs.

comment:14 Changed 18 years ago by anonymous

Resolution: fixed
Status: closedreopened

Only works with Photo-CD's. It doesnt'matter which CD I insert, mythgallery is used as handler.

See also #1921

comment:15 Changed 18 years ago by danielk

Resolution: fixed
Status: reopenedclosed

not support forum

Note: See TracTickets for help on using tickets.