After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 566661 - [typefind] Fall back to file extension using uri query
[typefind] Fall back to file extension using uri query
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
0.10.x
Other All
: Normal normal
: 0.10.23
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-01-05 18:40 UTC by Fabián Rodríguez
Modified: 2009-12-17 06:01 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
Example .gsm audio file (11.99 KB, audio/x-gsm)
2009-01-05 18:42 UTC, Fabián Rodríguez
  Details
first patch to core (9.06 KB, patch)
2009-01-09 17:57 UTC, Wim Taymans
committed Details | Review
Patch to register a gsm typefinder (3.81 KB, patch)
2009-01-09 17:59 UTC, Wim Taymans
committed Details | Review

Description Fabián Rodríguez 2009-01-05 18:40:34 UTC
Please describe the problem:
Using Ubuntu Intrepid (8.10).

When trying to play an audio .gsm file, Totem displays the following error dialog:
"An error occurred. Could not determine type of stream."

Running totem from command line, the following output is shown:

magicfab@magicfab-laptop:~$ totem Desktop/msg0001.gsm 
** (totem:10268): DEBUG: Init of Python module
** (totem:10268): DEBUG: Registering Python plugin instance: YouTube+TotemPythonPlugin
** (totem:10268): DEBUG: Creating object of type YouTube+TotemPythonPlugin
** (totem:10268): DEBUG: Creating Python plugin instance
** (totem:10268): DEBUG: Init of Python module
** (totem:10268): DEBUG: Registering Python plugin instance: BBCViewer+TotemPythonPlugin
** (totem:10268): DEBUG: Creating object of type BBCViewer+TotemPythonPlugin
** (totem:10268): DEBUG: Creating Python plugin instance
** Message: Error: Could not determine type of stream.
gsttypefindelement.c(806): gst_type_find_element_activate (): /GstPlayBin:play/GstDecodeBin:decodebin0/GstTypeFindElement:typefind


Steps to reproduce:
1. Double click on .gsm file on the Desktop


Actual results:
Totem displays the following error dialog:
"An error occurred. Could not determine type of stream."

Expected results:
Totem should play the .gsm audio file.

Does this happen every time?
Yes.

Other information:
This has also been files as an Ubuntu bug at: 
https://bugs.edge.launchpad.net/ubuntu/+bug/290527
Comment 1 Fabián Rodríguez 2009-01-05 18:42:57 UTC
Created attachment 125799 [details]
Example .gsm audio file

I've attached an example .gsm file. This is commonly used in Asterisk servers to send voice mail as GSM attachments via email.
Comment 2 Bastien Nocera 2009-01-06 11:15:20 UTC
Added the file detection to shared-mime-info (without any magic):
* freedesktop.org.xml.in:
* tests/list:
* tests/msg0001.gsm: Add audio/x-gsm for GSM 06.10 encoded audio files

Added it to Totem as well:
2009-01-06  Bastien Nocera  <hadess@hadess.net>

        * data/mime-type-list.txt: Add audio/x-gsm

GStreamer should be able to play the file, it has a gsm decoder, and ffmpeg contains a demuxer for the format. Didn't work in my tests though. Sox played it fine.
Comment 3 Wim Taymans 2009-01-06 11:43:52 UTC
This file contains raw GSM data, there is not enough information to typefind this. It would work better if the GSM data was inside a container like AVI or so.

I don't think we can automatically play this file without the user specifying the type of the file.
Comment 4 Bastien Nocera 2009-01-06 11:54:31 UTC
Or inside a wav file, which is all spec'ed up.
Comment 5 Fabián Rodríguez 2009-01-06 12:21:18 UTC
The file comes from voice mail sent by an Asterisk system. Is it malformed ?

aplay (from sox) deals fine with it, I suppose it doesn't block playback on knowing what type of audio it is. 

Fixing this for Totem seemed like a good way to have support for GSM in other applications too. I am interested in playing such files in Totem (or else) because aplay doesn't provide any visual indication of playback nor can it stop/pause/forward/rewind playback.

Comment 6 Wim Taymans 2009-01-07 14:02:57 UTC
It's not malformed, it can be played with GStreamer if you make a custom pipeline. 

It's just that the type of those files cannot be determined reliably. We could assume the gsm format based on the extension when the typefinder cannot find anything but it's unclear how that should work.

what are you using to play the file back, none of the tools I have can automatically play this file.
Comment 7 Bastien Nocera 2009-01-07 14:52:00 UTC
Sox plays it fine, it needs to be compiled with gsm support though. The one in Fedora is plays it out-of-the-box though.
Comment 8 Wim Taymans 2009-01-07 15:18:43 UTC
what if you rename the file to a different extension? does it still play it as a gsm file?
Comment 9 Fabián Rodríguez 2009-01-07 17:06:22 UTC
In Ubuntu I need to install the following packages:
sox libsox-fmt-gsm

Then I can assign "aplay" to play .gsm attachment in Thunderbird (or else).

aplay however is only command line and although the file plays well I can't control anything about it. In fact I often stop its playback using the System Monitor or kill.
Comment 10 Wim Taymans 2009-01-07 17:41:30 UTC
sorry, I don't get it:

 wim@wtay:~$ dpkg-query -S /usr/bin/aplay
 alsa-utils: /usr/bin/aplay
 wim@wtay:~$ 

my aplay is from alsa-utils, what does that have to do with sox? 

Also:

 wim@wtay:~$ aplay /home/wim/data/msg0001.gsm 
 Playing raw data '/home/wim/data/msg0001.gsm' : Unsigned 8 bit, Rate 8000 Hz, Mono
 wim@wtay:~$ 

which results in noisy output.

sox however comes with play, which does:

 wim@wtay:~$ play /home/wim/data/msg0001.gsm 

 Input File     : '/home/wim/data/msg0001.gsm'
 Sample Size    : 8-bit (1 byte)
 Sample Encoding: GSM
 Channels       : 1
 Sample Rate    : 8000

 Time: 00:07.44 [00:00.00] of 00:00.00 (0.00%) Samples out: 357k  Clips: 0    
 Done.

Nicely sounding GSM decoded and all.

Then when I rename the file, removing the .gsm extension:

 wim@wtay:~$ play /home/wim/data/msg0001
 play soxio: Can't open input file `/home/wim/data/msg0001': unknown file type
 wim@wtay:~$ 

As expected because you can't guess the type of a raw GSM file.

So it seems that is is simply using the .gsm extension to determine the codec. 

Comment 11 Fabián Rodríguez 2009-01-07 19:25:16 UTC
Apologies, of course I wanted to write "play" and instead my keyboard decided otherwise. I can confirm everything in Wim's comment.

I also renamed to .wav and this confirms it uses extensions:

magicfab@bachue:~$ play Desktop/msg0001.wav
play soxio: Failed reading `Desktop/msg0001.wav': WAVE: RIFF header not found

Comment 12 Wim Taymans 2009-01-08 09:49:36 UTC
Ok, cool. What we should do then is let the typefinder fall back to the file extension if the type could not be determined by looking at the data. 

It also happens that GST_QUERY_URI from Bug #562949 was commited recently which allows us to to get the uri and file extension in typefind.

Changing subject to reflect this.
Comment 13 Wim Taymans 2009-01-09 17:57:15 UTC
Created attachment 126127 [details] [review]
first patch to core

First part of a patch.

 * Add gst_type_find_helper_for_extension() to the typefind helper
 * Allow registering typefind factories that only register extension/caps without
   a real typefind function.
 * patch the typefindelement to search for extensions<->caps mappings when we
   can determine the type algorithmically.
Comment 14 Wim Taymans 2009-01-09 17:59:00 UTC
Created attachment 126128 [details] [review]
Patch to register a gsm typefinder

 * Add a GSM extension to caps typefindfactory
 * allow for making the extension strings static
Comment 15 Wim Taymans 2009-01-23 10:43:05 UTC
commit cc8b9ae5e8d11d16f313cde3a74bd871052a9dec
Author: Wim Taymans <wim.taymans@collabora.co.uk>
Date:   Fri Jan 23 11:40:26 2009 +0100

    Add typefind function for gsm
    
    Because core now supports typefindfactories without a typefind function we can
    register a factory fo GSM that will --if all else fails-- assume the file is a
    GSM file based on the registered extension.
    Fixes #566661.
Comment 16 Martin Mai 2009-12-17 06:01:42 UTC
Comment from the launchpad bug:
>>>
I'm running 9.10. Totem says Pause | 0:00 (Streaming) and when I hit play, the "visual effects" play for what I would approximate as the time of the recording, however the time does not change and no audio is heard.
<<<

gstreamer in Ubuntu 9.10 has the following components:
gstreamer0.10 |  0.10.25-2 |        karmic | source
gstreamer0.10-plugins-bad | 0.10.14-4ubuntu1 | karmic/universe | amd64, i386
gstreamer0.10-plugins-ugly |  0.10.12-1 | karmic/universe | amd64, i386
gstreamer0.10-plugins-good | 0.10.16-1ubuntu3 |        karmic | amd64, i386
gstreamer0.10-plugins-base | 0.10.25-2ubuntu1 |        karmic | amd64, i386