GNOME Bugzilla – Bug 557171
enhance filesrc to support progressive download
Last modified: 2011-05-19 08:56:25 UTC
Progressive Download is a very popular feature supported by nearly all commercial players. The typical user case is: - User click an http URL, which link to a media content (such as a mp3 file), in browser - Browser downloads the mp3 file, and starts a player to play it. - The player shall start playback as soon as enough data is available, before everything has been downloaded. This feature can provide better user experience than normal RTSP / HTTP streaming, especially, if user want to replay the content later. This technology has been used by a lot of video share community, such as YouTube. Currently filesrc only supports to read from a local file. Motorola enhances filesrc to support to read from a progressive downloading file, whose filesize is incremental. If the player wants to access data outside downloaded range, filesrc will block pipeline, until the all needed data is arrived. So, the pipeline can play a downloading file step by step. Filesrc shall run in push mode while enable PD. A protocol of "pd://" is added for this feautre, the uri parser is also enchaned, I add a suffix "?pd-filesize=xxx" to the file name, which indicates the file size of a completed progressive downloaded file. 3 properties are added to support PD: is-pd, whether to use PD mode pd-filesize, indicate predefined file size, is-pd will be set to true if pd-filesize is set pd-downloadedsize, indicate incremental downloaded size This patch uses a macro of GST_DISABLE_FILESRC_PD to enable/disable PD(Progressive Download) feature. Default is disable GST_DISABLE_FILESRC_PD. This feature is conflicted with use-mmap, that is use-mmap must be false when enable PD. Now, do_seek hasn't been implemented yet, will be implemented in the future. Changed files: gstfilesrc.c gstfilesrc.h example: Download http://brwtest.vicp.net/media/Video/MP4/MatrixII3_320x240_20fps_350kbps.mp4 to local disk, the temp file name is /home/w20711/MatrixII3_320x240_20fps_350kbps.mp4.part You can use gst-launch and playbin2 to play it. ./gst-launch-0.10 playbin2 -v uri=pd:///home/w20711/music/MatrixII3_320x240_20fps_350kbps.mp4.part?pd-filesize=2091279 It works well while filesrc runs in push mode. While filesrc runs in pull mode, I've met following issues: 1) typefind will read the last 32 bytes, which hasn't be downloaded yet, the whole pipeline will blocks. 2) if filesrc blocks before the pipeline enters playing state, a deadlock occurs. This is because the timer in filesrc runs in GMainLoop, which hasn't been started yet, as a result, the timer cannot be launched, then the downloaded data cannot be updated. Motorola would like to contribute the patch to the Gstreamer open source community project. Please find attached the patch applicable for Gstreamer. For any questions, please feel free to contact (Zhao Liang "e3423c@motorola.com", Shi Ling "w20230@motorola.com", Wang Xuefeng "w20711@motorola.com").
Created attachment 120978 [details] [review] gstfilesrc.h.patch
Created attachment 120979 [details] [review] gstfilesrc.c.patch
A different more modular approach is in queue2 with the temp-location property. It also implements the buffering protocols.
Hi, I checked queue2 and found it must work with neonhttpsrc, who will download media files. But, in most cases, it's the browser or other 3-rd party application download the content, does the community have any solution about it?
Shi, the http source should no do the on-disk buffering. This would duplicate the efforts as there are different http sources for gstreamer (soup, neon, curl, ...)
I'll close this as WONTFIX now, progressive downloading can be implemented for every source by using queue2... as is done in playbin2 for example.