Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2701 from FernetMenta/streamfix

dmuxer streams: some fixes after #1757
  • Loading branch information...
commit 854b740d322b170193ac8320335b53123263fe32 2 parents dca4014 + f86d779
@FernetMenta FernetMenta authored
View
30 xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
@@ -646,7 +646,10 @@ DemuxPacket* CDVDDemuxFFmpeg::Read()
return pPacket;
}
- else if (m_pkt.pkt.size < 0 || !GetStreamInternal(m_pkt.pkt.stream_index))
+ // check size and stream index for being in a valid range
+ else if (m_pkt.pkt.size < 0 ||
+ m_pkt.pkt.stream_index < 0 ||
+ m_pkt.pkt.stream_index >= m_pFormatContext->nb_streams)
{
// XXX, in some cases ffmpeg returns a negative packet size
if(m_pFormatContext->pb && !m_pFormatContext->pb->eof_reached)
@@ -751,7 +754,9 @@ DemuxPacket* CDVDDemuxFFmpeg::Read()
}
}
- pPacket->iStreamId = m_pkt.pkt.stream_index; // XXX just for now
+ // store internal id until we know the continuous id presented to player
+ // the stream might not have been created yet
+ pPacket->iStreamId = m_pkt.pkt.stream_index;
}
m_pkt.result = -1;
m_dllAvCodec.av_free_packet(&m_pkt.pkt);
@@ -772,7 +777,7 @@ DemuxPacket* CDVDDemuxFFmpeg::Read()
stream->codec != m_pFormatContext->streams[pPacket->iStreamId]->codec->codec_id)
{
// content has changed, or stream did not yet exist
- AddStream(pPacket->iStreamId);
+ stream = AddStream(pPacket->iStreamId);
}
// we already check for a valid m_streams[pPacket->iStreamId] above
else if (stream->type == STREAM_AUDIO)
@@ -781,7 +786,7 @@ DemuxPacket* CDVDDemuxFFmpeg::Read()
((CDemuxStreamAudio*)stream)->iSampleRate != m_pFormatContext->streams[pPacket->iStreamId]->codec->sample_rate)
{
// content has changed
- AddStream(pPacket->iStreamId);
+ stream = AddStream(pPacket->iStreamId);
}
}
else if (stream->type == STREAM_VIDEO)
@@ -790,9 +795,17 @@ DemuxPacket* CDVDDemuxFFmpeg::Read()
((CDemuxStreamVideo*)stream)->iHeight != m_pFormatContext->streams[pPacket->iStreamId]->codec->height)
{
// content has changed
- AddStream(pPacket->iStreamId);
+ stream = AddStream(pPacket->iStreamId);
}
}
+ if (!stream)
+ {
+ CLog::Log(LOGERROR, "CDVDDemuxFFmpeg::AddStream - internal error, stream is null");
+ CDVDDemuxUtils::FreeDemuxPacket(pPacket);
+ return NULL;
+ }
+ // set continuous stream id for player
+ pPacket->iStreamId = stream->iId;
}
return pPacket;
}
@@ -995,7 +1008,7 @@ void CDVDDemuxFFmpeg::DisposeStreams()
m_stream_index.clear();
}
-void CDVDDemuxFFmpeg::AddStream(int iId)
+CDemuxStream* CDVDDemuxFFmpeg::AddStream(int iId)
{
AVStream* pStream = m_pFormatContext->streams[iId];
if (pStream)
@@ -1186,7 +1199,7 @@ void CDVDDemuxFFmpeg::AddStream(int iId)
#ifdef HAVE_LIBBLURAY
if( m_pInput->IsStreamType(DVDSTREAM_TYPE_BLURAY) )
- static_cast<CDVDInputStreamBluray*>(m_pInput)->GetStreamInfo(pStream->id, m_streams[iId]->language);
+ static_cast<CDVDInputStreamBluray*>(m_pInput)->GetStreamInfo(pStream->id, stream->language);
#endif
if( m_pInput->IsStreamType(DVDSTREAM_TYPE_DVD) )
{
@@ -1219,7 +1232,10 @@ void CDVDDemuxFFmpeg::AddStream(int iId)
stream->iPhysicalId = pStream->id;
AddStream(iId, stream);
+ return stream;
}
+ else
+ return NULL;
}
/**
View
2  xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h
@@ -121,7 +121,7 @@ class CDVDDemuxFFmpeg : public CDVDDemux
friend class CDemuxStreamSubtitleFFmpeg;
int ReadFrame(AVPacket *packet);
- void AddStream(int iId);
+ CDemuxStream* AddStream(int iId);
void AddStream(int iId, CDemuxStream* stream);
CDemuxStream* GetStreamInternal(int iStreamId);
void CreateStreams(unsigned int program = UINT_MAX);
Please sign in to comment.
Something went wrong with that request. Please try again.