Skip to content
Permalink
Browse files

[VideoPlayer] Disable reading extension stream from input stream if d…

…ecoder doesn't support it.
  • Loading branch information...
afedchin authored and popcornmix committed Apr 7, 2016
1 parent 5e339df commit 0b59b35efe79ff29974b57b64011844c5a1836ef
@@ -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;
};
@@ -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
@@ -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
@@ -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)
@@ -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()))
{
@@ -21,7 +21,7 @@
*/

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

extern "C" {
@@ -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;
@@ -57,6 +57,7 @@ namespace XFILE

struct DemuxPacket;
class CDemuxStream;
class CDVDDemux;

class CDVDInputStream
{
@@ -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,
@@ -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;
@@ -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)
@@ -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);
@@ -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;
@@ -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;
@@ -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;
@@ -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 = "";
@@ -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;

0 comments on commit 0b59b35

Please sign in to comment.
You can’t perform that action at this time.