Skip to content

Commit

Permalink
[VideoPlayer] Disable reading extension stream from input stream if d…
Browse files Browse the repository at this point in the history
…ecoder doesn't support it.
  • Loading branch information
afedchin authored and popcornmix committed Nov 11, 2016
1 parent 5e339df commit 0b59b35
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 17 deletions.
5 changes: 5 additions & 0 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h
Expand Up @@ -311,6 +311,11 @@ class CDVDVideoCodec
*/
virtual void Reopen() {};

/**
* Indicates that the decoder supports extention streams.
*/
virtual bool SupportsExtention() { return false; }

protected:
CProcessInfo &m_processInfo;
};
18 changes: 9 additions & 9 deletions xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
Expand Up @@ -504,14 +504,14 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput, bool streaminfo, bool filein

UpdateCurrentPTS();

if (!fileinfo && m_pInput->IsStreamType(DVDSTREAM_TYPE_BLURAY))
if (!fileinfo)
{
CDVDInputStreamBluray *bluRay = static_cast<CDVDInputStreamBluray*>(m_pInput);
if (bluRay->HasMVC())
CDVDInputStream::IExtentionStream* pExt = dynamic_cast<CDVDInputStream::IExtentionStream*>(m_pInput);
if (pExt && pExt->HasExtention())
{
SAFE_DELETE(m_pSSIF);
m_pSSIF = new CDemuxStreamSSIF();
m_pSSIF->SetBluRay(bluRay);
m_pSSIF->SetBluRay(pExt);
}
}
// in case of mpegts and we have not seen pat/pmt, defer creation of streams
Expand Down Expand Up @@ -1475,13 +1475,13 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int streamIdx)
pStream->codec->codec_tag = MKTAG('A', 'M', 'V', 'C');

AVStream* mvcStream = nullptr;
if (m_pInput->IsStreamType(DVDSTREAM_TYPE_BLURAY))
CDVDInputStream::IExtentionStream* pExt = dynamic_cast<CDVDInputStream::IExtentionStream*>(m_pInput);
if (pExt)
{
CDVDInputStreamBluray *bluRay = static_cast<CDVDInputStreamBluray*>(m_pInput);
if (bluRay->HasMVC())
if (pExt->HasExtention())
{
st->stereo_mode = bluRay->AreEyesFlipped() ? "block_rl" : "block_lr";
mvcStream = static_cast<CDemuxMVC*>(bluRay->GetDemuxMVC())->GetAVStream();
st->stereo_mode = pExt->AreEyesFlipped() ? "block_rl" : "block_lr";
mvcStream = static_cast<CDemuxMVC*>(pExt->GetExtentionDemux())->GetAVStream();
}
}
else
Expand Down
4 changes: 3 additions & 1 deletion xbmc/cores/VideoPlayer/DVDDemuxers/DemuxStreamSSIF.cpp
Expand Up @@ -35,6 +35,8 @@ DemuxPacket* CDemuxStreamSSIF::AddPacket(DemuxPacket* &srcPkt)

if (srcPkt->iStreamId == m_h264StreamId)
{
if (m_bluRay && !m_bluRay->HasExtention())
return srcPkt;
m_H264queue.push(srcPkt);
}
else if (srcPkt->iStreamId == m_mvcStreamId)
Expand Down Expand Up @@ -170,7 +172,7 @@ bool CDemuxStreamSSIF::FillMVCQueue(double dtsBase)
if (!m_bluRay)
return false;

CDVDDemux* demux = m_bluRay->GetDemuxMVC();
CDVDDemux* demux = m_bluRay->GetExtentionDemux();
DemuxPacket* mvc;
while ((m_MVCqueue.size() < MVC_QUEUE_SIZE) && (mvc = demux->Read()))
{
Expand Down
6 changes: 3 additions & 3 deletions xbmc/cores/VideoPlayer/DVDDemuxers/DemuxStreamSSIF.h
Expand Up @@ -21,7 +21,7 @@
*/

#include "DVDDemuxPacket.h"
#include "DVDInputStreams/DVDInputStreamBluray.h"
#include "DVDInputStreams/DVDInputStream.h"
#include <queue>

extern "C" {
Expand All @@ -41,15 +41,15 @@ class CDemuxStreamSSIF
int GetH264StreamId() { return m_h264StreamId; };
int GetMVCStreamId() { return m_mvcStreamId; };
void AddMVCExtPacket(DemuxPacket* &scrPkt);
void SetBluRay(CDVDInputStreamBluray* &bluRay) { m_bluRay = bluRay; };
void SetBluRay(CDVDInputStream::IExtentionStream* &bluRay) { m_bluRay = bluRay; };
bool IsBluRay() { return m_bluRay != nullptr; };

private:
DemuxPacket* GetMVCPacket();
DemuxPacket* MergePacket(DemuxPacket* &srcPkt, DemuxPacket* &appendPkt);
bool FillMVCQueue(double dtsBase);

CDVDInputStreamBluray* m_bluRay = nullptr;
CDVDInputStream::IExtentionStream* m_bluRay = nullptr;
std::queue<DemuxPacket*> m_H264queue;
std::queue<DemuxPacket*> m_MVCqueue;
int m_h264StreamId = -1;
Expand Down
11 changes: 11 additions & 0 deletions xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.h
Expand Up @@ -57,6 +57,7 @@ namespace XFILE

struct DemuxPacket;
class CDemuxStream;
class CDVDDemux;

class CDVDInputStream
{
Expand Down Expand Up @@ -131,6 +132,16 @@ class CDVDInputStream
virtual void SetVideoResolution(int width, int height) {};
};

class IExtentionStream
{
public:
virtual ~IExtentionStream() {}
virtual bool HasExtention() = 0;
virtual bool AreEyesFlipped() = 0;
virtual CDVDDemux* GetExtentionDemux() = 0;
virtual void DisableExtention() = 0;
};

enum ENextStream
{
NEXTSTREAM_NONE,
Expand Down
Expand Up @@ -617,6 +617,13 @@ void CDVDInputStreamBluray::ProcessEvent() {
}
}

void CDVDInputStreamBluray::DisableExtention()
{
CloseMVCDemux();
m_bMVCDisabled = true;
m_bMVCPlayback = false;
}

int CDVDInputStreamBluray::Read(uint8_t* buf, int buf_size)
{
int result = 0;
Expand Down Expand Up @@ -1165,7 +1172,7 @@ bool CDVDInputStreamBluray::ProcessItem(int playitem)

m_title = m_dll->bd_get_playlist_info(m_bd, playitem, m_angle);

if (CSettings::GetInstance().GetBool("videoplayer.supportmvc"))
if (CSettings::GetInstance().GetBool("videoplayer.supportmvc") && !m_bMVCDisabled)
{
MPLS_PL * mpls = m_dll->bd_get_title_mpls(m_bd);
if (mpls)
Expand Down
9 changes: 6 additions & 3 deletions xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.h
Expand Up @@ -46,6 +46,7 @@ class CDVDInputStreamBluray
, public CDVDInputStream::IChapter
, public CDVDInputStream::IPosTime
, public CDVDInputStream::IMenus
, public CDVDInputStream::IExtentionStream
{
public:
CDVDInputStreamBluray(IVideoPlayer* player, const CFileItem& fileitem);
Expand Down Expand Up @@ -120,9 +121,10 @@ class CDVDInputStreamBluray
BLURAY_TITLE_INFO* GetTitleFile(const std::string& name);

void ProcessEvent();
CDVDDemux* GetDemuxMVC() { return m_pMVCDemux; };
bool HasMVC() { return m_bMVCPlayback; }
bool AreEyesFlipped() { return m_bFlipEyes; }
CDVDDemux* GetExtentionDemux() override { return m_pMVCDemux; };
bool HasExtention() override { return m_bMVCPlayback; }
bool AreEyesFlipped() override { return m_bFlipEyes; }
void DisableExtention() override;

protected:
struct SPlane;
Expand Down Expand Up @@ -157,6 +159,7 @@ class CDVDInputStreamBluray
int m_nMVCSubPathIndex = 0;
int m_nMVCClip = -1;
bool m_bFlipEyes = false;
bool m_bMVCDisabled = false;
uint64_t m_clipStartTime = 0;

typedef std::shared_ptr<CDVDOverlayImage> SOverlay;
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoPlayer/IVideoPlayer.h
Expand Up @@ -111,6 +111,7 @@ class IDVDStreamPlayerVideo : public IDVDStreamPlayer
virtual int GetDecoderBufferSize() { return 0; }
virtual int GetDecoderFreeSpace() = 0;
virtual bool IsEOS() { return false; };
virtual bool SupportsExtention() const = 0;
};

class CDVDAudioCodec;
Expand Down
4 changes: 4 additions & 0 deletions xbmc/cores/VideoPlayer/VideoPlayer.cpp
Expand Up @@ -3891,6 +3891,10 @@ bool CVideoPlayer::OpenVideoStream(CDVDStreamInfo& hint, bool reset)
if (!player->OpenStream(hint))
return false;

CDVDInputStream::IExtentionStream* pExt = dynamic_cast<CDVDInputStream::IExtentionStream*>(m_pInputStream);
if (pExt && !static_cast<IDVDStreamPlayerVideo*>(player)->SupportsExtention())
pExt->DisableExtention();

s.stereo_mode = static_cast<IDVDStreamPlayerVideo*>(player)->GetStereoMode();
if (s.stereo_mode == "mono")
s.stereo_mode = "";
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoPlayer/VideoPlayerVideo.h
Expand Up @@ -91,6 +91,7 @@ class CVideoPlayerVideo : public CThread, public IDVDStreamPlayerVideo
int GetVideoBitrate();
std::string GetStereoMode();
void SetSpeed(int iSpeed);
bool SupportsExtention() const override { return m_pVideoCodec && m_pVideoCodec->SupportsExtention(); }

// classes
CDVDOverlayContainer* m_pOverlayContainer;
Expand Down

0 comments on commit 0b59b35

Please sign in to comment.