aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Arrskog <topfs2@xbmc.org>2014-11-15 17:45:07 +0100
committerTobias Arrskog <topfs2@xbmc.org>2014-11-15 17:45:07 +0100
commit647205ae8b70a7d463aab4b7c94ed047d115daa5 (patch)
treeee9faf0bb10b25b240bd694e299c35c51bd2a542
parent343cebf2a6e4db3b0e4f51a3d7c7721b9b688c88 (diff)
parent0339c8cdf564d056fc307c04d12370ccdc75499b (diff)
Merge pull request #5693 from wsnipex/rtmp
[rtmp] fix crash on seek on live streams
-rw-r--r--xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamRTMP.cpp47
-rw-r--r--xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamRTMP.h8
2 files changed, 25 insertions, 30 deletions
diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamRTMP.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamRTMP.cpp
index 62ddd3de07..324eadbde3 100644
--- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamRTMP.cpp
+++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamRTMP.cpp
@@ -63,7 +63,10 @@ extern "C"
}
}
-CDVDInputStreamRTMP::CDVDInputStreamRTMP() : CDVDInputStream(DVDSTREAM_TYPE_RTMP)
+CDVDInputStreamRTMP::CDVDInputStreamRTMP()
+ : CDVDInputStream(DVDSTREAM_TYPE_RTMP)
+ , m_canSeek(true)
+ , m_canPause(true)
{
if (m_libRTMP.Load())
{
@@ -119,19 +122,6 @@ bool CDVDInputStreamRTMP::IsEOF()
#undef AVC
#define AVC(str) {(char *)str,sizeof(str)-1}
-/* librtmp option names are slightly different */
-static const struct {
- const char *name;
- AVal key;
-} options[] = {
- { "SWFPlayer", AVC("swfUrl") },
- { "PageURL", AVC("pageUrl") },
- { "PlayPath", AVC("playpath") },
- { "TcUrl", AVC("tcUrl") },
- { "IsLive", AVC("live") },
- { NULL }
-};
-
bool CDVDInputStreamRTMP::Open(const char* strFile, const std::string& content)
{
if (m_sStreamPlaying)
@@ -152,21 +142,23 @@ bool CDVDInputStreamRTMP::Open(const char* strFile, const std::string& content)
if (!m_libRTMP.SetupURL(m_rtmp, m_sStreamPlaying))
return false;
- // SetOpt and SetAVal copy pointers to the value. librtmp doesn't use the values until the Connect() call,
- // so value objects must stay allocated until then. To be extra safe, keep the values around until Close(),
- // in case librtmp needs them again.
- m_optionvalues.clear();
- for (int i=0; options[i].name; i++)
+ /* Look for protocol options in the URL.
+ * Options are added to the URL in space separated key=value pairs.
+ * We are only interested in the "live" option to disable seeking,
+ * the rest is handled by librtmp internally
+ *
+ * example URL suitable for use with RTMP_SetupURL():
+ * "rtmp://flashserver:1935/ondemand/thefile swfUrl=http://flashserver/player.swf swfVfy=1 live=1"
+ * details: https://rtmpdump.mplayerhq.hu/librtmp.3.html
+ */
+ std::string url = strFile;
+ size_t iPosBlank = url.find(' ');
+ if (iPosBlank != string::npos && (url.find("live=true") != string::npos || url.find("live=1") != string::npos))
{
- std::string tmp = m_item.GetProperty(options[i].name).asString();
- if (!tmp.empty())
- {
- m_optionvalues.push_back(tmp);
- AVal av_tmp;
- SetAVal(av_tmp, m_optionvalues.back());
- m_libRTMP.SetOpt(m_rtmp, &options[i].key, &av_tmp);
- }
+ m_canSeek = false;
+ m_canPause = false;
}
+ CLog::Log(LOGDEBUG, "RTMP canseek: %s", m_canSeek ? "true" : "false");
if (!m_libRTMP.Connect(m_rtmp, NULL) || !m_libRTMP.ConnectStream(m_rtmp, 0))
return false;
@@ -185,7 +177,6 @@ void CDVDInputStreamRTMP::Close()
if (m_rtmp)
m_libRTMP.Close(m_rtmp);
- m_optionvalues.clear();
m_eof = true;
m_bPaused = false;
}
diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamRTMP.h b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamRTMP.h
index b013f33725..5568c14cf1 100644
--- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamRTMP.h
+++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamRTMP.h
@@ -27,6 +27,7 @@
class CDVDInputStreamRTMP
: public CDVDInputStream
, public CDVDInputStream::ISeekTime
+ , public CDVDInputStream::ISeekable
{
public:
CDVDInputStreamRTMP();
@@ -36,7 +37,9 @@ public:
virtual int Read(uint8_t* buf, int buf_size);
virtual int64_t Seek(int64_t offset, int whence);
bool SeekTime(int iTimeInMsec);
- virtual bool Pause(double dTime);
+ bool CanSeek() { return m_canSeek; }
+ bool CanPause() { return m_canPause; }
+ virtual bool Pause(double dTime);
virtual bool IsEOF();
virtual int64_t GetLength();
@@ -45,8 +48,9 @@ public:
protected:
bool m_eof;
bool m_bPaused;
+ bool m_canSeek;
+ bool m_canPause;
char* m_sStreamPlaying;
- std::vector<std::string> m_optionvalues;
RTMP *m_rtmp;
DllLibRTMP m_libRTMP;