From c45eccf8653d4744510bf477375f118594fb5ffc Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sun, 18 Nov 2012 15:23:19 +0100 Subject: [PATCH] Query Mpeg2 support and fix of aspect switching --- vdr.cc | 3 ++- video.h | 3 ++- videoomx.cc | 28 +++++++++++++++++++++++++++- videoomx.h | 3 +++ vrecordinglist.cc | 19 ++++++++++++++++++- 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/vdr.cc b/vdr.cc index f16b481..b455330 100644 --- a/vdr.cc +++ b/vdr.cc @@ -792,6 +792,7 @@ ChannelList* VDR::getChannelsList(ULONG type) ChannelList* chanList = new ChannelList(); bool h264support=Video::getInstance()->supportsh264(); + bool mpeg2support=Video::getInstance()->supportsmpeg2(); while (!vresp->end()) { @@ -801,7 +802,7 @@ ChannelList* VDR::getChannelsList(ULONG type) chan->name = vresp->extractString(); chan->vstreamtype = vresp->extractULONG(); - if (chan->type == type && (chan->vstreamtype!=0x1b || h264support)) + if (chan->type == type && ((chan->vstreamtype==0x1b && h264support)|| mpeg2support) ) { chanList->push_back(chan); logger->log("VDR", Log::DEBUG, "Have added a channel to list. %lu %lu %s", chan->number, chan->type, chan->name); diff --git a/video.h b/video.h index 2a670f5..5624421 100644 --- a/video.h +++ b/video.h @@ -75,6 +75,7 @@ class Video: public DrainTarget, public AbstractOption virtual int EnterIframePlayback() {return 1;}; // Must not be implemented virtual bool supportsh264(){return false;}; + virtual bool supportsmpeg2(){return true;}; virtual void seth264mode(bool ish264) {h264=ish264;}; virtual int getTeletextBufferFaktor(){return 1;}; @@ -105,7 +106,7 @@ class Video: public DrainTarget, public AbstractOption UCHAR getFormat() { return format; } UINT getScreenWidth() { return screenWidth; } UINT getScreenHeight() { return screenHeight; } - UCHAR getTVsize() { return tvsize; } + virtual UCHAR getTVsize() { return tvsize; } diff --git a/videoomx.cc b/videoomx.cc index 26c8077..6c88e6b 100644 --- a/videoomx.cc +++ b/videoomx.cc @@ -54,6 +54,7 @@ VideoOMX::VideoOMX() { lastreftimePTS = 0; firstsynched = false; cur_clock_time=0; + mpeg2_supported=false; //cur_pts=0; mode=NORMAL; @@ -75,6 +76,25 @@ int VideoOMX::init(UCHAR tformat) if (initted) return 0; initted = 1; + int ret=vc_gencmd_send("codec_enabled MPG2"); + if (ret!=0) { + Log::getInstance()->log("Video", Log::DEBUG, "vc_gencmd_send failed %x",ret); + } else { + char buffer[1024]; + ret=vc_gencmd_read_response(buffer,sizeof(buffer)); + if (ret!=0) { + Log::getInstance()->log("Video", Log::DEBUG, "vc_gencmd_read_response failed %x",ret); + } else { + if (STRCASECMP(buffer,"MPG2=enabled")==0) { + mpeg2_supported=true; + } else if (STRCASECMP(buffer,"MPG2=disabled")==0) { + mpeg2_supported=false; + } else { + Log::getInstance()->log("Video", Log::DEBUG, "Undefined mpg codec answer %s",buffer); + } + } + } + if (!setFormat(tformat)) { shutdown(); return 0; } if (!setConnection(HDMI)) { shutdown(); return 0; } if (!setAspectRatio(ASPECT4X3,12,11)) { shutdown(); return 0; } @@ -82,7 +102,7 @@ int VideoOMX::init(UCHAR tformat) if (!setSource()) { shutdown(); return 0; } if (!attachFrameBuffer()) { shutdown(); return 0; } - setTVsize(ASPECT4X3); + setTVsize(ASPECT16X9); selectVideoMode(0); @@ -306,6 +326,12 @@ int VideoOMX::setTVsize(UCHAR ttvsize) return 1; } +UCHAR VideoOMX::getTVsize() { + /*if (hdmi)*/ + return ASPECT16X9; // in order that aspect ratio changes are reported + //return tvsize; +} + void VideoOMX::executePendingModeChanges() { if (pendingmodechange) { diff --git a/videoomx.h b/videoomx.h index 286f084..85c0a5b 100644 --- a/videoomx.h +++ b/videoomx.h @@ -81,6 +81,7 @@ class VideoOMX : public Video int setAspectRatio(UCHAR aspectRatio, int tparx,int tpary); // This one does the pin 8 scart widescreen switching int setMode(UCHAR mode); int setTVsize(UCHAR size); // Is the TV a widescreen? + UCHAR getTVsize(); void executePendingModeChanges(); int setDefaultAspect(); @@ -111,6 +112,7 @@ class VideoOMX : public Video virtual bool supportsh264(){return true;}; + virtual bool supportsmpeg2(){return mpeg2_supported;}; int WriteOutTS(const unsigned char *bulibaver,int length, int type); void WriteOutPATPMT(); @@ -278,6 +280,7 @@ class VideoOMX : public Video bool signalon; bool pendingmodechange; bool hdmi; + bool mpeg2_supported; int outputinterlaced; diff --git a/vrecordinglist.cc b/vrecordinglist.cc index 0426ae8..c96bd41 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -360,7 +360,24 @@ int VRecordingList::doPlay(bool resume) boxstack->add(vi); boxstack->update(vi); - } else { + } else if (!ish264 && !Video::getInstance()->supportsmpeg2()) { + VInfo* vi = new VInfo(); + vi->setSize(360, 200); + vi->createBuffer(); + if (Video::getInstance()->getFormat() == Video::PAL) + vi->setPosition(190, 170); + else + vi->setPosition(180, 120); + vi->setOneLiner(tr("Mpeg2 video not supported")); + vi->setExitable(); + vi->setBorderOn(1); + vi->setTitleBarColour(DrawStyle::DANGER); + vi->okButton(); + vi->draw(); + boxstack->add(vi); + boxstack->update(vi); + + }else { VVideoRec* vidrec = new VVideoRec(toPlay, ish264); vidrec->draw(); boxstack->add(vidrec); -- 2.39.5