Hi,
Continuing from http://forums.openpl...ndpost&p=520325
I was investigating use of HTTP timeout in servicemp3, since there were problems that streams sometimes timed out, even when they should not.
Current situation:
1. we are setting HTTP_TIMEOUT to souphttpsrc by "timeout" property, when streaming thread is created (GST_STREAM_STATUS_TYPE_CREATE)
2. we are setting HTTP_TIMEOUT to m_streaming_src eTimer and starting it, when streaming thread is created (GST_STREAM_STATUS_TYPE_CREATE)
3. if HTTP_TIMEOUT is reached eTimer will call sourceTimeout, which stops pipeline and emits EOF event
4. if pipeline gets to PAUSED_TO_PLAYING state change before HTTP_TIMEOUT is reached, it stops eTimer, so sourceTimeout is not called
What are the problems:
1. We are setting HTTP_TIMEOUT to souphttpsrc when streaming thread is created which is too late, since SOUP client was already initialized, which in effect means that there is default timeout set. In gstreamer1.0 it's 15 seconds, in gstreamer 0.10 it's infinity. (note, since gstreamer 1.4 souphttpsrc has option to set "retries" property which sets 'Maximum number of retries until giving up', default is 3, so it should be, timeout = timeout * 3, but by doing tests it's only 2* timeout value)
2. From above point it's clear that m_streaming_src eTimer is effectively doing timeout, which is not precise at all.
3. In sourceTimeout we are emitting EOF without emiting evStart ( evStart is now correctly emited in READY_TO_PAUSED state change since https://github.com/O...ffaa6af62c377d)
4. In sourceTimeout we are emitting EOF, after stopping pipeline. EOF event should mean that end of file was reached, and it should be still possible to do for example seek actions. After we stop pipeline we cannot do that anymore, and we correctly shouldn't be able to do that since source timed out, so EOF shouldn't be emitted at all.
Solution:
1. set timeout for souphttpsrc in playbinNotifySource, so our timeout is actually applied
2-4. remove m_streaming_src timer and instead catch specific resource error messages on the bus: GST_RESOURCE_ERROR_OPEN_READ or GST_RESOURCE_ERROR_OPEN(http://gstreamer.fre...stResourceError), which among other problems will tell us that timeout is reached, so we can stop pipeline. Note we don't emit EOF event as explained.
What's the difference for user:
Playback will behave as before except there will be no unexpected timeout occuring and if stream times out nothing happens, while before EOF event would be emited, which would for example show "END" message in MoviePlayer, or do some other registered action.
Todo:
- I think we should consider to create/reuse some event which would signal that there was some error and we cannot start playback, so we can inform user about it.
- Do the same for servicemp3record
Patch was tested on gstreamer-1.0 and also on gstreamer-0.10 by @ian1095
Any advises are much appreciated.
Patch:
https://gist.github....69e1da108009508