diff -upr reelbox-3-svn14835_orig/fs453settings.c reelbox-new/fs453settings.c --- reelbox-3-svn14835_orig/fs453settings.c 2010-07-24 10:58:10.714085000 +0200 +++ reelbox-new/fs453settings.c 2010-07-29 19:32:55.000000000 +0200 @@ -188,8 +188,8 @@ void cFs453Settings::Show(void) int lineHeight = cFont::GetFont(fontSml)->Height(); int helper = RBSetup.usehdext ? 3+1 : FS453_SETTINGS+1; int totalHeight = helper * lineHeight + (helper + 1) * (lineHeight / 2); - osd = cOsdProvider::NewTrueColorOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - totalHeight, 0, 0); - tArea Areas[] = { { 0, 0, Setup.OSDWidth - 1, totalHeight - 1 , 32 } }; + osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - totalHeight, 0); + tArea Areas[] = { { 0, 0, Setup.OSDWidth - 1, totalHeight - 1 , 8 } }; osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea)); osd->DrawRectangle(0, 0,Setup.OSDWidth - 1, totalHeight - 1, backgroundColor); int offset = 0; diff -upr reelbox-3-svn14835_orig/HdCommChannel.c reelbox-new/HdCommChannel.c --- reelbox-3-svn14835_orig/HdCommChannel.c 2010-07-24 10:58:10.726085000 +0200 +++ reelbox-new/HdCommChannel.c 2010-07-29 19:32:55.000000000 +0200 @@ -120,11 +120,10 @@ namespace Reel Byte const *data, int dataSize) { if (!ch_) return; - + if (!hda->hdp_running) // Player not running, avoid stall return; - -// static FairMutex mutex; + mutex_.Lock(); header.magic = HD_PACKET_MAGIC; @@ -133,12 +132,13 @@ namespace Reel header.packet_size = headerSize + dataSize; packetSeqNr_++; - + void *buffer; int ch_packet_size = (header.packet_size + 3) & 0x7FFFFFFC; // Align 4 int bufferSize = hd_channel_write_start(ch_, &buffer, ch_packet_size, 0); + if (!bufferSize) { for (int n = 0; n < 2000000 && !bufferSize; n += 5000) @@ -150,7 +150,7 @@ namespace Reel if (bufferSize) { safe_memcpy(buffer, &header, headerSize); - + if (dataSize) { safe_memcpy(static_cast(buffer) + headerSize, data, dataSize); diff -upr reelbox-3-svn14835_orig/HdFbTrueColorOsd.c reelbox-new/HdFbTrueColorOsd.c --- reelbox-3-svn14835_orig/HdFbTrueColorOsd.c 2010-07-24 10:58:10.746084000 +0200 +++ reelbox-new/HdFbTrueColorOsd.c 2010-07-29 19:32:55.000000000 +0200 @@ -545,8 +545,8 @@ void HdFbTrueColorOsd::new_osd() { unsigned char const *xs; unsigned int qx, qy, xt1, yt1, xt, yt, vfx, vfy, vfw, vfh, x, y, w, h, m, *px, n; - x = X + left; - y = Y + top; + x = X + Left(); + y = Y + Top(); w = bitmap.Width(); h = bitmap.Height(); @@ -627,8 +627,8 @@ void HdFbTrueColorOsd::new_osd() { static unsigned int qx, qy, xt1, yt1, x, y, w, h, *px, line, row; static unsigned int pxs; - x = X + left; - y = Y + top; + x = X + Left(); + y = Y + Top(); w = bitmap.Width(); h = bitmap.Height(); UpdateDirty(x, y, x+w, y+h); @@ -690,10 +690,10 @@ void HdFbTrueColorOsd::new_osd() { //esyslog("HdFbTrueColorOsd: DrawEllipse\n"); unsigned int l, t, r, b; - l = left + X1; - t = top + Y1; - r = left + X2 + 1; - b = top + Y2 + 1; + l = Left() + X1; + t = Top() + Y1; + r = Left() + X2 + 1; + b = Top() + Y2 + 1; int x1 = l; int y1 = t; @@ -806,8 +806,8 @@ void HdFbTrueColorOsd::new_osd() { if (ImageIdInRange(imageId)) LoadImage(imageId); - x += left; - y += top; + x += Left(); + y += Top(); CachedImage const *img = cachedImages_[imageId]; //hda->osd_cached_images[imageId]; int m, n, h_, v; @@ -821,8 +821,8 @@ void HdFbTrueColorOsd::new_osd() { h = img->height; unsigned int w_all = horRepeat ? horRepeat * w : w; unsigned int h_all = vertRepeat ? vertRepeat * h : h; - if(horRepeat * w > width) horRepeat = width / w; - if(vertRepeat * h > height) vertRepeat = height / h; + if(horRepeat * w > Width()) horRepeat = Width() / w; + if(vertRepeat * h > Height()) vertRepeat = Height() / h; UpdateDirty(x, y, x+w_all, y+h_all); w_all = horRepeat ? horRepeat * w : w; @@ -897,12 +897,12 @@ void HdFbTrueColorOsd::new_osd() { if (ImageIdInRange(imageId)) { LoadImage(imageId); - x+=left; - y+=top; - x0+=left; - y0+=top; - x1+=left; - y1+=top; + x+=Left(); + y+=Top(); + x0+=Left(); + y0+=Top(); + x1+=Left(); + y1+=Top(); UpdateDirty(x0, y0, x1, y1); CachedImage const *img = cachedImages_[imageId]; @@ -930,7 +930,7 @@ void HdFbTrueColorOsd::new_osd() { unsigned int *tgtPixels = (unsigned int*)(osd->buffer + osd->bpp * osd->width * y0++ + x0*osd->bpp); for (h = horRepeat; h > 0; --h) { unsigned int const *src = srcPixels; - for (m = width; m > 0; --m) { + for (m = Width(); m > 0; --m) { *tgtPixels = AlphaBlend((*src++), (*tgtPixels) ); ++tgtPixels; } @@ -976,10 +976,10 @@ void HdFbTrueColorOsd::new_osd() { //esyslog("HdFbTrueColorOsd: DrawRectangle\n"); unsigned int l, t, r, b; - l = left + x1; - t = top + y1; - r = left + x2 + 1; - b = top + y2 + 1; + l = Left() + x1; + t = Top() + y1; + r = Left() + x2 + 1; + b = Top() + y2 + 1; if (ClipArea(osd, &l, &t, &r, &b)) { UpdateDirty(l, t, r, b); @@ -1014,10 +1014,10 @@ void HdFbTrueColorOsd::new_osd() { dirty_ = true; unsigned int l, t, r, b; - l = left + x1; - t = top + y1; - r = left + x2 + 1; - b = top + y2 + 1; + l = Left() + x1; + t = Top() + y1; + r = Left() + x2 + 1; + b = Top() + y2 + 1; if (ClipArea(osd, &l, &t, &r, &b)) { UpdateDirty(l, t, r, b); @@ -1057,8 +1057,8 @@ void HdFbTrueColorOsd::new_osd() { if (s_in) { /* adjust coordinates with global OSD-margins */ - x+=left; - y+=top; + x+=Left(); + y+=Top(); /* check for empty string */ unsigned int i; @@ -1075,7 +1075,7 @@ void HdFbTrueColorOsd::new_osd() { if(i == len) { /* every char is a space */ if((colorBg >> 24) != 0) /* not transparent */ - DrawRectangle(x-left, y-top, x + w - left, y + h - top, colorBg); /* clear the background */ + DrawRectangle(x-Left(), y-Top(), x + w - Left(), y + h - Top(), colorBg); /* clear the background */ return; } @@ -1364,7 +1364,7 @@ void HdFbTrueColorOsd::new_osd() { /* override */ void HdFbTrueColorOsd::SaveRegion(int x1, int y1, int x2, int y2) { - x1 += left; y1 += top; x2 += left; y2 += top; + x1 += Left(); y1 += Top(); x2 += Left(); y2 += Top(); savedRegion_x0 = x1; savedRegion_y0 = y1; savedRegion_x1 = x2; savedRegion_y1 = y2; int lines = y2 - y1; int pixels = x2 - x1; @@ -1453,10 +1453,10 @@ void HdFbTrueColorOsd::new_osd() { l = std::max(0, l); t = std::max(0, l); - width = r - l; - height = b - t; - width = std::max(1, width); - height = std::max(1, height); +// width = r - l; +// height = b - t; +// width = std::max(1, width); +// height = std::max(1, height); } return ret; diff -upr reelbox-3-svn14835_orig/HdTrueColorOsd.c reelbox-new/HdTrueColorOsd.c --- reelbox-3-svn14835_orig/HdTrueColorOsd.c 2010-07-24 10:58:10.766084000 +0200 +++ reelbox-new/HdTrueColorOsd.c 2010-07-29 19:32:55.000000000 +0200 @@ -371,7 +371,7 @@ namespace Reel // Send the palette indexes. SendOsdCmd(bco, sizeof(hdcmd_osd_palette_t) + payloadSize); - hdcmd_osd_draw8_t bco2 = {HDCMD_OSD_DRAW8, left + x, top + y, bitmap.Width(), bitmap.Height(), blend}; + hdcmd_osd_draw8_t bco2 = {HDCMD_OSD_DRAW8, Left() + x, Top() + y, bitmap.Width(), bitmap.Height(), blend}; SendOsdCmd(&bco2, sizeof(hdcmd_osd_draw8_t), bitmap.Data(0, 0), bitmap.Width() * bitmap.Height()); free(buffer); @@ -419,7 +419,7 @@ namespace Reel // Send the palette indexes. SendOsdCmd(bco, sizeof(hdcmd_osd_palette_t) + payloadSize); - hdcmd_osd_draw8_t bco2 = {HDCMD_OSD_DRAW8_OVERLAY, left + x, top + y, width, height, blend}; + hdcmd_osd_draw8_t bco2 = {HDCMD_OSD_DRAW8_OVERLAY, Left() + x, Top() + y, width, height, blend}; SendOsdCmd(&bco2, sizeof(hdcmd_osd_draw8_t), bitmap.Data(0, 0), width * height); free(buffer); @@ -448,10 +448,10 @@ namespace Reel //esyslog("HdTrueColorOsd: DrawEllipse\n"); hdcmd_osd_draw_ellipse const bco = {HDCMD_OSD_DRAW_ELLIPSE, - left + x1, - top + y1, - left + x2 + 1, - top + y2 + 1, + Left() + x1, + Top() + y1, + Left() + x2 + 1, + Top() + y2 + 1, color, quadrants}; @@ -473,7 +473,7 @@ namespace Reel CacheImage(imageId); hdcmd_osd_draw_image const bco = {HDCMD_OSD_DRAW_IMAGE, imageId, - left + x, top + y, + Left() + x, Top() + y, blend, horRepeat, vertRepeat}; @@ -494,9 +494,9 @@ namespace Reel CacheImage(imageId); hdcmd_osd_draw_crop_image const bco = {HDCMD_OSD_DRAW_CROP_IMAGE, imageId, - left + x, top + y, - left + x0, top + y0, - left + x1, top + y1, + Left() + x, Top() + y, + Left() + x0, Top() + y0, + Left() + x1, Top() + y1, blend}; SendOsdCmd(bco); } @@ -519,10 +519,10 @@ namespace Reel //esyslog("HdTrueColorOsd: DrawRectangle\n"); hdcmd_osd_draw_rect const bco = {HDCMD_OSD_DRAW_RECT, - left + x1, - top + y1, - left + x2 + 1, - top + y2 + 1, + Left() + x1, + Top() + y1, + Left() + x2 + 1, + Top() + y2 + 1, color}; SendOsdCmd(bco); @@ -537,10 +537,10 @@ namespace Reel //esyslog("HdTrueColorOsd: DrawRectangle\n"); hdcmd_osd_draw_rect2 const bco = {HDCMD_OSD_DRAW_RECT2, - left + x1, - top + y1, - left + x2 + 1, - top + y2 + 1, + Left() + x1, + Top() + y1, + Left() + x2 + 1, + Top() + y2 + 1, color, alphaGradH, alphaGradV, @@ -590,7 +590,7 @@ namespace Reel if(height == 0) height=font->Height(); - cacheBitmap->SetSizeWithoutRealloc(width, height); + cacheBitmap->SetSize(width, height); if((colorBg >> 24 == 0) || ((colorBg&0x00ffffff) == 0x00000000)){ /* TB: transparent as bgcolor is evil */ colorBg = colorFg&0x01ffffff; @@ -782,7 +782,7 @@ namespace Reel /* override */ void HdTrueColorOsd::SaveRegion(int x1, int y1, int x2, int y2) { - hdcmd_osd_clear_t const bco = {HDCMD_OSD_SAVE_REGION, x1+left, y1+top, x2+left, y2+top}; + hdcmd_osd_clear_t const bco = {HDCMD_OSD_SAVE_REGION, x1+Left(), y1+Top(), x2+Left(), y2+Top()}; SendOsdCmd(bco); } @@ -904,10 +904,10 @@ namespace Reel l = std::max(0, l); t = std::max(0, l); - width = r - l; - height = b - t; - width = std::max(1, width); - height = std::max(1, height); +// width = r - l; +// height = b - t; +// width = std::max(1, width); +// height = std::max(1, height); } return ret; diff -upr reelbox-3-svn14835_orig/Makefile reelbox-new/Makefile --- reelbox-3-svn14835_orig/Makefile 2010-07-24 10:58:10.722095000 +0200 +++ reelbox-new/Makefile 2010-07-29 19:32:55.000000000 +0200 @@ -10,7 +10,7 @@ PLUGIN = reelbox # set it if you want to compile the skin for use with the reelbox -REELSKIN=1 +#REELSKIN=1 ### The object files (add further files here): @@ -32,8 +32,8 @@ VDRDIR = ../../.. LIBDIR = ../../lib TMPDIR = /tmp -BSPSHM = ../../../utils/bspshm -HDSHM = ../../../utils/hdshm3/src +BSPSHM = ./utils/bspshm +HDSHM = ./utils/hdshm3/src BSPINCLUDE = -I$(BSPSHM) -I$(BSPSHM)/include HDINCLUDE = -I$(HDSHM) -I$(HDSHM)/include @@ -70,8 +70,126 @@ endif LDFLAGS += -L$(LIBASOUND)/src/.libs LDFLAGS += -L$(LIBMAD)/.libs -# Include common rules -include $(VDRDIR)/Make.common +### The version number of this plugin (taken from the main source file): + +VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g') + +### The version number of VDR (taken from VDR's "config.h"): + +APIVERSION = $(shell grep 'define APIVERSION ' $(VDRDIR)/config.h | awk '{ print $$3 }' | sed -e 's/"//g') + +VDRLOCALE = $(shell grep '^LOCALEDIR' $(VDRDIR)/Makefile) + +### The name of the distribution archive: + +ARCHIVE = $(PLUGIN)-$(VERSION) +PACKAGE = vdr-$(ARCHIVE) + +### Includes and Defines (add further entries here): + +INCLUDES += -I$(VDRDIR)/include -I$(DVBDIR)/include +DEFINES += -D_GNU_SOURCE -D_LARGEFILE_SOURCE + +ifdef DEBUG + DEFINES += -DDEBUG + CXXFLAGS += -g +endif + +### Targets: + +plug: libvdr-$(PLUGIN).so + +all: libvdr-$(PLUGIN).so i18n + +### Implicit rules: + +%.o: %.c + $(CXX) $(CXXFLAGS) -c $(DEFINES) -DPLUGIN_NAME='"$(PLUGIN)"' -DPLUGIN_NAME_I18N='"$(PLUGIN)"' $(INCLUDES) -o $@ $< + +# Dependencies: + +MAKEDEP = $(CXX) -MM -MG +DEPFILE = .dependencies +$(DEPFILE): Makefile + @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@ + +-include $(DEPFILE) + +### Internationalization (I18N): +ifneq ($(strip $(VDRLOCALE)),) +### do gettext based i18n stuff + +PODIR = po +LOCALEDIR = $(VDRDIR)/locale +I18Npo = $(wildcard $(PODIR)/*.po) +I18Nmsgs = $(addprefix $(LOCALEDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, \ + $(notdir $(foreach file, $(I18Npo), $(basename $(file)))))) +I18Npot = $(PODIR)/$(PLUGIN).pot + +%.mo: %.po + msgfmt -c -o $@ $< + +$(I18Npot): $(wildcard *.c $(PLUGIN).h $(EXTRA_I18N)) + echo $(I18Nmsgs) + xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --from-code=utf-8 --msgid-bugs-address='' $^ -o $@ + +#%.po: +%.po: $(I18Npot) + msgmerge -U --no-wrap --no-location --backup=none -q $@ $< + @touch $@ + +$(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo + @mkdir -p $(dir $@) + cp $< $@ + +.PHONY: i18n +i18n: $(I18Npot) $(I18Nmsgs) + +#i18n-dist: $(I18Nmsgs) +i18n-dist: + for i in `ls po/*.po` ; do \ + odir=`echo $$i | cut -b4-8` ;\ + msgfmt -c -o $(LOCALEDIR)/$$odir/LC_MESSAGES/vdr-$(PLUGIN).mo $$i ;\ + done + +else ### do i18n.c based i18n stuff + +i18n: + @### nothing to do + +#i18n compatibility generator: +i18n.c: i18n-template.c po2i18n.pl $(I18Npo) + ./po2i18n.pl < i18n-template.c > i18n.c + +endif + +libvdr-$(PLUGIN).so: $(OBJS) + $(CXX) $(CXXFLAGS) -shared $(OBJS) $(LDFLAGS) $(LIBS) -o $@ + @cp $@ $(LIBDIR)/$@.$(APIVERSION) + +dist: distclean + @rm -rf $(TMPDIR)/$(ARCHIVE) + @mkdir $(TMPDIR)/$(ARCHIVE) + @cp -a * $(TMPDIR)/$(ARCHIVE) + @rm -f $(TMPDIR)/$(ARCHIVE)/$(PLUGIN).kdevelop + @rm -f $(TMPDIR)/$(ARCHIVE)/$(PLUGIN).kdevelop.filelist + @rm -f $(TMPDIR)/$(ARCHIVE)/$(PLUGIN).kdevelop.pcs + @rm -f $(TMPDIR)/$(ARCHIVE)/$(PLUGIN).kdevses + @rm -rf $(TMPDIR)/$(ARCHIVE)/CVS + @rm -rf $(TMPDIR)/$(ARCHIVE)/Examples/CVS + @rm -rf $(TMPDIR)/$(ARCHIVE)/Patch/CVS + @ln -s $(ARCHIVE) $(TMPDIR)/$(PLUGIN) + @tar czf $(PACKAGE).tgz -C $(TMPDIR) $(ARCHIVE) $(PLUGIN) + @rm -rf $(TMPDIR)/$(ARCHIVE) $(TMPDIR)/$(PLUGIN) + @echo Distribution package created as $(PACKAGE).tgz + +clean: + @-rm -f $(PODIR)/*.mo + @-rm -f $(OBJS) $(MAIN) $(DEPFILE) *.so *.tgz core* *~ + @-rm -f $(LIBDIR)/libvdr-$(PLUGIN).so.$(APIVERSION) + +distclean: clean + @-rm -f $(PODIR)/*.pot useless-target-for-compatibility-with-vanilla-vdr: $(LIBDIR)/$@.$(APIVERSION) diff -upr reelbox-3-svn14835_orig/MpegPes.c reelbox-new/MpegPes.c --- reelbox-3-svn14835_orig/MpegPes.c 2010-07-24 10:58:10.742085000 +0200 +++ reelbox-new/MpegPes.c 2010-07-29 19:32:55.000000000 +0200 @@ -155,7 +155,7 @@ namespace Reel if ((b & 0xC0) == 0x80) { // MPEG-2 - // ::printf("MPEG-2\n"); + //::printf("MPEG-2\n"); if (pesLength >= 2) { b = *pesPtr++; @@ -190,7 +190,7 @@ namespace Reel else { // MPEG-1 - // ::printf("MPEG-1\n"); + //::printf("MPEG-1\n"); if ((b & 0xC0) == 0x40) { if (pesLength < 2) Nur in reelbox-3-svn14835_orig/: po. diff -upr reelbox-3-svn14835_orig/ReelBoxDevice.c reelbox-new/ReelBoxDevice.c --- reelbox-3-svn14835_orig/ReelBoxDevice.c 2010-07-24 10:58:10.738085000 +0200 +++ reelbox-new/ReelBoxDevice.c 2010-07-29 19:35:48.000000000 +0200 @@ -145,6 +145,9 @@ namespace Reel AudioPlayerBsp::Destroy(); AudioPlayerHd::Destroy(); VideoPlayer::Destroy(); + + if(ringBuffer) + delete ringBuffer; } Int ReelBoxDevice::AudioDelay() const @@ -667,65 +670,114 @@ namespace Reel printf("SetAudioTrack: %i\n", index); } - Int ReelBoxDevice::PlayVideoTs(Byte const *data, Int length, bool VideoOnly, uchar* PATPMT) - { - CHECK_CONCURRENCY; - if(audioChannel_ != oldAudioChannel){ - oldAudioChannel = audioChannel_; - } - if(PATPMT){ - int vpidpatpmt = PATPMT[TS_SIZE + 19]&0xff | ((PATPMT[TS_SIZE+18]&0x1f) << 8); - int apidpatpmt[MAXAPIDS] = { 0 }; - int dpidpatpmt[MAXDPIDS] = { 0 }; - int dpidsfound = 0, apidsfound = 0; - int offset = 17+5; /* after header and vpid */ - /* as long as there are audio tracks */ - while(PATPMT[TS_SIZE + offset] == 0x06 || PATPMT[TS_SIZE + offset] == 0x04){ - /* test for dolby */ - if (PATPMT[TS_SIZE + offset]==0x06 && dpidsfound < MAXDPIDS){ - /* set first mpa also, will be overriden if a real mpa-track is found */ - dpidpatpmt[dpidsfound] = apidpatpmt[apidsfound] = PATPMT[TS_SIZE + offset + 2]&0xff | ((PATPMT[TS_SIZE + offset + 1]&0x1f ) << 8); - SetAvailableTrack(ttDolby, dpidsfound, dpidpatpmt[dpidsfound], 0); - dpidsfound++; - offset += 8; - } - /* test for mpa */ - if (PATPMT[TS_SIZE + offset]==0x04 && apidsfound < MAXAPIDS){ - apidpatpmt[apidsfound] = PATPMT[TS_SIZE + offset + 2]&0xff | ((PATPMT[TS_SIZE + offset + 1]&0x1f ) << 8); - SetAvailableTrack(ttAudio, apidsfound, apidpatpmt[apidsfound], 0); - offset += 5; - apidsfound++; - } - } - - printf("PATPMT: vpid: %x apid: %x dpid : %x dpid2: %x\n",vpidpatpmt, apidpatpmt[0], dpidpatpmt[0], dpidpatpmt[1]); - - if(vpidpatpmt != 0 && (apidpatpmt[0] !=0 || dpidpatpmt[0] != 0) ){ - printf("VALID PATPMT: vpid: %x apid: %x dpid : %x dpid2: %x\n",vpidpatpmt, apidpatpmt[0], dpidpatpmt[0], dpidpatpmt[1]); - if(!dpidpatpmt[0] && audioIndex > 0) //TB: if there's only one track select it regardless what VDR wants - audioIndex = 0; - } - } - - try - { - bkgPicPlayer_.Stop(); - videoPlayback_ = 3500; - if (-- audioPlayback_ < 0) - { - audioPlayback_ = 0; - } - - videoPlayer_->PlayTsPacket((void*)data, length, PATPMT); - - } catch (std::exception const &e) - { - REEL_LOG_EXCEPTION(e); - } - return length; - } +int ReelBoxDevice::PlayTsVideo(const uchar *Data, int length) + { + CHECK_CONCURRENCY; + + if(!TsHasPayload(Data)) return length; + + int pid = TsPid(Data); + + if(pid != playVideoPid_) + { + printf("PlayTsVideo: new Vpid: %i\n", pid); + playVideoPid_ = pid; + bkgPicPlayer_.Stop(); + videoPlayback_ = 3500; + if (-- audioPlayback_ < 0) + { + audioPlayback_ = 0; + } + + if(ringBuffer) + ringBuffer->Clear(); + } + + PlayAudioVideoTS(Data,length); + + + return length; + } + + int ReelBoxDevice::PlayTsAudio(const uchar *Data, int Length) + { + CHECK_CONCURRENCY; + int pid = TsPid(Data); + + if(pid != playAudioPid_) + { + printf("PlayTsAudio: new Apid: %i\n", pid); + playAudioPid_ = pid; + + audioPlayback_ = 200; + + if (-- videoPlayback_ < 0) + { + videoPlayback_ = 0; +#if 1 + bkgPicPlayer_.Start(); +#else + if (audioBackgroundPics_) + bkgPicPlayer_.Start(); + else + bkgPicPlayer_.Stop(); +#endif + } + + if(audioPlayerBsp_) + { + tsToPesConverter.Reset(); + audioPlayerBsp_->Stop(); + } + } + PlayAudioVideoTS(Data,Length); + + if(!audioPlayerBsp_) //send packets to alsa too + return Length; + + try + { + //first make PES and then ES for alsa output + UInt l; + if (const Reel::Byte *p = tsToPesConverter.GetPes((int&)l)) + { + while (l > 0) + { + Mpeg::EsPacket esPacket(p, l); + audioPlayerBsp_->PlayPacket(esPacket); + } + + tsToPesConverter.Reset(); + } + tsToPesConverter.PutTs(Data, Length); + } + catch (std::exception const &e) + { + REEL_LOG_EXCEPTION(e); + printf("PlayTsAudio: exception caught \n"); + } + return Length; + } + + void ReelBoxDevice::PlayAudioVideoTS(const uchar *data, int length) + { + + if(!ringBuffer) + ringBuffer = new cRingBufferLinear(RINGBUFSIZE, BUFFEREDTSPACKETSSIZE, false, "PlayTsBuffer"); + + ringBuffer->Put(data, length); + + int count = ringBuffer->Available(); + if(count == BUFFEREDTSPACKETSSIZE) + { + uchar *b = ringBuffer->Get(count); + videoPlayer_->PlayTsPacket((void*)b, count, playVideoPid_, playAudioPid_); + ringBuffer->Del(count); + } + } + Int ReelBoxDevice::PlayVideo(Byte const *data, Int length) { CHECK_CONCURRENCY; @@ -1030,6 +1082,18 @@ namespace Reel } } + void ReelBoxDevice::GetOsdSize(int &Width, int &Height, double &PixelAspect) + { + Width = 720; + Height = 576; + + if (Setup.VideoFormat == 1) // 16:9 Format + PixelAspect = 16.0 /9.0; + else + PixelAspect = 4.0 /3.0; + PixelAspect /= double(Width) / Height; + } + void ReelBoxDevice::SetVolumeDevice(int volume) { DEBUG_DEVICE("[reelbox] \033[0;44n %s \033[0m \n", __PRETTY_FUNCTION__); @@ -1044,16 +1108,6 @@ namespace Reel audioPlayerBsp_->SetChannel(channel); } -#ifndef RBLITE - if (audioOverHd_) - return; -#endif - // ALSA - - volume = volume / 8; // range is from 0-31 on RB_Lite, 0-255 on RB_II; - // FIXME: SetVolume() should check volume_range before setting - // and take volume as % as input - if (digitalAudio_ ) // we have ac3 { if (RBSetup.ac3 || !useHDExtension_) @@ -1143,7 +1197,13 @@ namespace Reel continue; if (snd_mixer_selem_has_playback_channel(elem, chn)) { if (snd_mixer_selem_has_playback_volume(elem)) { - snd_mixer_selem_set_playback_volume(elem, chn, Volume); + long min, max; + if(snd_mixer_selem_get_playback_volume_range(elem, &min, &max) >= 0) + { + unsigned int percent = 100*Volume/MAXVOLUME; + long relVol = (max-min)*percent/100 + min; + snd_mixer_selem_set_playback_volume(elem, chn, relVol); + } } } } @@ -1170,14 +1230,23 @@ namespace Reel { std::vector videoPackets; - if (length >= 4 && + if(data[0] == 0x47) + { + // TS + // Just send it back to the cDevice StillPicture method that will make PES out of it and then we will try again + tsMode_ = true; + playVideoPid_ = -1; + playAudioPid_ = -1; + cDevice::StillPicture(data, length); + return; + } + else if (length >= 4 && data[0] == 0x00 && data[1] == 0x00 && data[2] == 0x01 && data[3] <= 0xB8) { // ES - int const maxLen = 2000; while (length > 0) { @@ -1194,28 +1263,32 @@ namespace Reel else { // PES - + UInt pesLength = length; - + printf("reelbox: StillPicture PES with length: %i \n", length); + + // Parse packets. while (pesLength) { Mpeg::EsPacket const esPacket(data, pesLength); if (esPacket.GetMediaType() == Mpeg::MediaTypeVideo) - { + { videoPackets.push_back(esPacket); } - } + } } - // Display them. - if (videoPackets.size()) - { - videoPlayer_->StillPicture(&videoPackets[0], videoPackets.size()); - } + // Display them. + if (videoPackets.size()) + { + videoPlayer_->StillPicture(&videoPackets[0], videoPackets.size(), tsMode_); + } + + tsMode_ = false; } catch (std::exception const &e) - { + { REEL_LOG_EXCEPTION(e); // Restart(); } @@ -1225,7 +1298,7 @@ namespace Reel { try { - // printf("Trick speed %i\n",speed); + //printf("Trick speed %i\n",speed); /* if (audioPlayerHd_) { audioPlayerHd_->Freeze(); @@ -1276,6 +1349,11 @@ namespace Reel audioPlayback_ = 100; videoPlayback_ = 10; + //reset the vpid and apid for PlayTsVideo and PlayTsAudio whenever PlayMode was set to On + //without the reset there a some problems with the audio output over alsa + playVideoPid_ = -1; + playAudioPid_ = -1; + if (audioPlayerHd_) { //printf ("[reelbox] \033[0;44m audioPlayerHd_->Start() \033[0m\n"); diff -upr reelbox-3-svn14835_orig/ReelBoxDevice.h reelbox-new/ReelBoxDevice.h --- reelbox-3-svn14835_orig/ReelBoxDevice.h 2010-07-24 10:58:10.742085000 +0200 +++ reelbox-new/ReelBoxDevice.h 2010-07-29 19:32:55.000000000 +0200 @@ -34,16 +34,20 @@ #include #include +#include -#if 1 //def REELVDR +#ifdef REELVDR #include #endif #include +#define BUFFEREDTSPACKETSSIZE 64*TS_SIZE //size of ts buffered packets before sending to eHD +#define RINGBUFSIZE MEGABYTE(25) //size of the ring buffer used for ts buffering (must be at least 2*BUFFEREDTSPACKETSSIZE) + namespace Reel { -#if 1 //def REELVDR +#ifdef REELVDR class ReelBoxDevice : public cDevice, public cReelBoxBase /* final */ #else class ReelBoxDevice : public cDevice /* final */ @@ -94,10 +98,13 @@ namespace Reel SampleRate sampleRate, UInt pts); /* override */ Int PlayVideo(Byte const *data, Int length); + + /* override */ virtual int PlayTsVideo(const uchar *Data, int Length); + /* override */ virtual int PlayTsAudio(const uchar *Data, int Length); void PlayVideoEs(Byte const *data, Int length, UInt pts); - Int PlayVideoTs(Byte const *data, Int length, bool VideoOnly, uchar* PATPMT); + //Int PlayVideoTs(Byte const *data, Int length, bool VideoOnly, uchar* PATPMT); /* override */ void PlayPipVideo(Byte const *data, Int length); @@ -115,6 +122,8 @@ namespace Reel /* override */ void SetVideoFormat(bool videoFormat16_9); + /* override */ void GetOsdSize(int &Width, int &Height, double &PixelAspect); + /* override */ void SetVolumeDevice(int volume); /* override */ void StartPip(bool on); @@ -144,10 +153,17 @@ namespace Reel private: static ReelBoxDevice *instance_; + + int playVideoPid_; + int playAudioPid_; + cTsToPes tsToPesConverter; + cRingBufferLinear *ringBuffer; + bool tsMode_; ReelBoxDevice(ReelBoxDevice const &); // Forbid copy construction. ReelBoxDevice &operator=(ReelBoxDevice const &); // Forbid copy assignment. + void PlayAudioVideoTS(const uchar *data, int length); void PlayAudioVideoPesPacket(Byte const *data, Int length); void SetPlayModeOff(); void SetPlayModeOn(); diff -upr reelbox-3-svn14835_orig/ReelBoxMenu.c reelbox-new/ReelBoxMenu.c --- reelbox-3-svn14835_orig/ReelBoxMenu.c 2010-07-24 10:58:10.770084000 +0200 +++ reelbox-new/ReelBoxMenu.c 2010-07-29 19:32:55.000000000 +0200 @@ -129,7 +129,7 @@ void cMenuVideoMode::Setup() if (expert_mode) SetHelp(NULL/*tr("Audio")*/, NULL, NULL, tr("Normal")); else - SetHelp(NULL/*tr("Audio")*/, NULL, NULL, data.ExpertOptions ? tr("Experts") : NULL); + SetHelp(NULL/*tr("Audio")*/, NULL, NULL, tr("Experts")); } else { SetHelp(NULL/*tr("Audio")*/, NULL, NULL, NULL); } @@ -502,7 +502,7 @@ eOSState cMenuVideoMode::ProcessKey(eKey else menu_mode = video_mode; Setup(); - } else if (Key == kBlue && menu_mode == video_mode && data.ExpertOptions) { + } else if (Key == kBlue && menu_mode == video_mode) { expert_mode_changed = true; expert_mode = !expert_mode; Setup(); diff -upr reelbox-3-svn14835_orig/setupmenu.c reelbox-new/setupmenu.c --- reelbox-3-svn14835_orig/setupmenu.c 2010-07-24 10:58:10.714085000 +0200 +++ reelbox-new/setupmenu.c 2010-07-29 19:32:55.000000000 +0200 @@ -27,6 +27,7 @@ eOSState cMenuReelBoxSetup::ProcessKey(e if (state == osUnknown && key == kOk) { + if (HasSubMenu()) return cMenuSetupPage::ProcessKey(key); const char *text = Get(Current())->Text(); if ( text && strstr(text, tr("Video Settings")) ) Nur in reelbox-3-svn14835_orig/: symbols. diff -upr reelbox-3-svn14835_orig/VideoPlayerBsp.c reelbox-new/VideoPlayerBsp.c --- reelbox-3-svn14835_orig/VideoPlayerBsp.c 2010-07-24 10:58:10.774084000 +0200 +++ reelbox-new/VideoPlayerBsp.c 2010-07-29 19:32:55.000000000 +0200 @@ -164,7 +164,7 @@ namespace Reel //-------------------------------------------------------------------------------------------------------------- - void VideoPlayerBsp::StillPicture(Mpeg::EsPacket const esPackets[], UInt packetCount) + void VideoPlayerBsp::StillPicture(Mpeg::EsPacket const esPackets[], UInt packetCount, bool tsMode) { MutexLocker lock(mutex_); diff -upr reelbox-3-svn14835_orig/VideoPlayerBsp.h reelbox-new/VideoPlayerBsp.h --- reelbox-3-svn14835_orig/VideoPlayerBsp.h 2010-07-24 10:58:10.778084000 +0200 +++ reelbox-new/VideoPlayerBsp.h 2010-07-29 19:32:55.000000000 +0200 @@ -44,7 +44,7 @@ namespace Reel /* override */ void Play(); /* override */ void PlayPacket(Mpeg::EsPacket const &esPacket, bool still = false); - void PlayTsPacket(void *data, int length, unsigned char* PATPMT){}; + void PlayTsPacket(void *data, int length, int vpid, int apid){}; /* override */ bool Poll(); @@ -52,7 +52,7 @@ namespace Reel /* override */ void SetStc(bool stcValid, UInt stc); - /* override */ void StillPicture(Mpeg::EsPacket const esPackets[], UInt packetCount); + /* override */ void StillPicture(Mpeg::EsPacket const esPackets[], UInt packetCount, bool tsMode = false); /* override */ void Start(); diff -upr reelbox-3-svn14835_orig/VideoPlayer.h reelbox-new/VideoPlayer.h --- reelbox-3-svn14835_orig/VideoPlayer.h 2010-07-24 10:58:10.742085000 +0200 +++ reelbox-new/VideoPlayer.h 2010-07-29 19:32:55.000000000 +0200 @@ -56,9 +56,9 @@ namespace Reel virtual void PlayPacket(Mpeg::EsPacket const &esPacket, bool still = false) = 0; ///< Play the given es packet. Return as soon as possible if data can be buffered, otherwise block. - virtual void PlayTsPacket(void *packet, int length, unsigned char *PATPMT) = 0; + virtual void PlayTsPacket(void *packet, int length, int vpid, int apid) = 0; - virtual void PlayPesPacket(void *data, int length, int av) {}; + virtual void PlayPesPacket(void *data, int length, int av) {}; virtual bool Poll() = 0; ///< Return true if further data is needed. Return immediately without blocking, even if other member @@ -68,7 +68,7 @@ namespace Reel virtual void SetStc(bool valid, UInt stc) = 0; - virtual void StillPicture(Mpeg::EsPacket const esPackets[], UInt packetCount) = 0; + virtual void StillPicture(Mpeg::EsPacket const esPackets[], UInt packetCount, bool tsMode = false) = 0; ///< Display a sequence of es packets as a still picture. virtual void Start() = 0; diff -upr reelbox-3-svn14835_orig/VideoPlayerHd.c reelbox-new/VideoPlayerHd.c --- reelbox-3-svn14835_orig/VideoPlayerHd.c 2010-07-24 10:58:10.762084000 +0200 +++ reelbox-new/VideoPlayerHd.c 2010-07-29 19:32:55.000000000 +0200 @@ -111,16 +111,8 @@ namespace Reel hdPlayer_.pause=0; } - //-------------------------------------------------------------------------------------------------------------- - - static unsigned int oldvpid = 0; - static unsigned int oldapidpatpmt[MAXAPIDS] = {0}; - static unsigned int oldAudioIndex = 0; - // static int off; - static Byte sendbuf[64*TS_SIZE]; - static int buffill = 0; - - void VideoPlayerHd::PlayTsPacket ( void *data, int length, unsigned char* PATPMT ) + //-------------------------------------------------------------------------------------------------------------- + void VideoPlayerHd::PlayTsPacket ( void *data, int length, int vpid, int apid) { hd_packet_ts_data_t packet; @@ -131,116 +123,17 @@ namespace Reel if ( ac3_pts_shift_ != 10 * RBSetup.delay_ac3 ) { hdPlayer_.ac3_pts_shift = ac3_pts_shift_ = 10 * RBSetup.delay_ac3; - } - + } + hdPlayer_.pause=0; - hdPlayer_.data_generation = generation_; // Must be done _before_ sending the packet! - - unsigned int audioIndex = ReelBoxDevice::Instance()->GetAudioTrack(); - - packet.generation = generation_; - - int bytes_sent = 0; - Byte const* d = ( Byte const* ) data; - - packet.vpid = 0; packet.apid = 0; - - if ( PATPMT ) - { - // ++generation_; // no longer required - //int ix; - //printf("%x %x %d %d\n", PATPMT[TS_SIZE + 19], PATPMT[TS_SIZE + 18], PATPMT[TS_SIZE + 19], PATPMT[TS_SIZE + 18]); - int vpidpatpmt = PATPMT[TS_SIZE + 19]&0xff | ( ( PATPMT[TS_SIZE+18]&0x1f ) << 8 ); - int apidpatpmt[MAXAPIDS] = { 0 }; - unsigned int apidsfound = 0; - int offset = 17+5; /* after header and vpid */ - /* as long as there are audio tracks */ - while ( PATPMT[TS_SIZE + offset] == 0x06 || PATPMT[TS_SIZE + offset] == 0x04 ) - { - /* test for mpa */ - if ( PATPMT[TS_SIZE + offset]==0x04 && apidsfound < MAXAPIDS ) - { - apidpatpmt[apidsfound] = PATPMT[TS_SIZE + offset + 2]&0xff | ( ( PATPMT[TS_SIZE + offset + 1]&0x1f ) << 8 ); - offset += 5; - apidsfound++; - } - /* test for dolby */ - if ( PATPMT[TS_SIZE + offset]==0x06 && apidsfound < MAXAPIDS ) - { - /* set first mpa also, will be overriden if a real mpa-track is found */ - apidpatpmt[apidsfound] = PATPMT[TS_SIZE + offset + 2]&0xff | ( ( PATPMT[TS_SIZE + offset + 1]&0x1f ) << 8 ); - apidsfound++; - offset += 8; - } - } - if ( vpidpatpmt != 0 ) - { - /* A audiotrack is desired that doesn't exist */ - if (audioIndex >= apidsfound){ - ReelBoxDevice::Instance()->SetAudioTrack(0); - audioIndex = 0; - } - packet.vpid = vpidpatpmt; - packet.apid = apidpatpmt[audioIndex]; - //printf ( "VALID PATPMT: vpid: %x apid: %x audioIndex: %x\n",packet.vpid, packet.apid, audioIndex ); - // if(oldvpid != packet.vpid || oldapid != packet.apid) - // packet.generation++; - HdCommChannel::chStream1.SendPacket ( HD_PACKET_TS_DATA, packet, d, 0 ); - - oldvpid = vpidpatpmt; - int i = 0; - while ( apidpatpmt[i] ) - { - oldapidpatpmt[i] = apidpatpmt[i]; - i++; - } - } - } - if ( !d || !length ) - return; - - //printf("DEBUG: PlayTsPacket: len: %i \n", length); - - // sync to 0x47 - if ( length>=2*TS_SIZE ) - { - while (length>=TS_SIZE && d[0]!=0x47 && d[TS_SIZE]!=0x47 ) - { - sendbuf[buffill++] = *d; - d++; - length--; - } - } - - if ( oldAudioIndex != audioIndex ) - { - //printf("Audio Index changed from %i to %i\n", oldAudioIndex, audioIndex); - oldAudioIndex = audioIndex; - } - packet.vpid=oldvpid; // Always include PIDs in packet - packet.apid=oldapidpatpmt[oldAudioIndex]; - - if ( buffill>=TS_SIZE ) - { - HdCommChannel::chStream1.SendPacket ( HD_PACKET_TS_DATA, packet, ( Byte const* ) &sendbuf, buffill ); - buffill=0; - } - -#define MAXPACKLEN (TS_SIZE*64) - while ( length>=TS_SIZE ) - { - int len_rounded = length - ( length%TS_SIZE ); - int tosend = len_rounded > MAXPACKLEN ? MAXPACKLEN : len_rounded; - HdCommChannel::chStream1.SendPacket ( HD_PACKET_TS_DATA, packet, d+bytes_sent, tosend ); -// HdCommChannel::chStream1.SendPacket(HD_PACKET_TS_DATA, packet, d, length); - bytes_sent += tosend; - length -= tosend; - } - if ( length>0 ) - { - memcpy ( &sendbuf, d+bytes_sent, length ); - buffill+=length; - } + hdPlayer_.data_generation = generation_; + + packet.vpid = vpid; + packet.apid = apid; + packet.generation = generation_; + + HdCommChannel::chStream1.SendPacket ( HD_PACKET_TS_DATA, packet.header, sizeof ( packet ), ( const Reel::Byte* ) data, length ); + freeze_ = false; } void VideoPlayerHd::PlayPacket ( Mpeg::EsPacket const &esPacket, bool still ) @@ -301,26 +194,34 @@ namespace Reel } //-------------------------------------------------------------------------------------------------------------- - - void VideoPlayerHd::StillPicture ( Mpeg::EsPacket const esPackets[], UInt packetCount ) + void VideoPlayerHd::StillPicture ( Mpeg::EsPacket const esPackets[], UInt packetCount, bool tsMode ) { - //printf("VideoPlayerHd::StillPicture()\n"); + //printf("VideoPlayerHd::StillPicture(): packetCount: %i\n", packetCount); + + /* + if(tsMode) + printf("VideoPlayerHd::StillPicture(): TS Mode enabled\n"); + else + printf("VideoPlayerHd::StillPicture(): TS Mode disabled\n"); + */ /* TB: resend picture settings, auto format may have resetted them */ Reel::HdCommChannel::SetPicture(&RBSetup); // const UInt repeat = 40; //send the frame several times (still frame prob with hdext) // Set to 4 or showing picture will result in audio scatch // const UInt repeat = 4; //send the frame several times (still frame prob with hdext) - const UInt repeat = 6; //send the frame several times (still frame prob with hdext) - increased again due to fade-in + const UInt repeat = (tsMode?10:6); //send the frame several times (still frame prob with hdext) + for ( UInt rep = 0; rep < repeat; ++rep ) { for ( UInt n = 0; n < packetCount; ++n ) { Mpeg::EsPacket const &esPacket = esPackets[n]; PlayPacket ( esPacket, true ); + if(tsMode) + usleep(25000); } } } - //-------------------------------------------------------------------------------------------------------------- void VideoPlayerHd::Start() diff -upr reelbox-3-svn14835_orig/VideoPlayerHd.h reelbox-new/VideoPlayerHd.h --- reelbox-3-svn14835_orig/VideoPlayerHd.h 2010-07-24 10:58:10.766084000 +0200 +++ reelbox-new/VideoPlayerHd.h 2010-07-29 19:32:55.000000000 +0200 @@ -24,7 +24,6 @@ #define VIDEO_PLAYER_HD_H_INCLUDED #include "VideoPlayer.h" - #include "HdCommChannel.h" namespace Reel @@ -45,9 +44,9 @@ namespace Reel /* override */ void PlayPacket(Mpeg::EsPacket const &esPacket, bool still = false); - void PlayTsPacket(void *data, int length, unsigned char *PATPMT); + void PlayTsPacket(void *data, int length, int vpid, int apid); - void PlayPesPacket(void *data, int length, int av); + void PlayPesPacket(void *data, int length, int av); /* override */ bool Poll(); @@ -61,7 +60,7 @@ namespace Reel /* override */ void SetStc(bool stcValid, UInt stc); - /* override */ void StillPicture(Mpeg::EsPacket const esPackets[], UInt packetCount); + /* override */ void StillPicture(Mpeg::EsPacket const esPackets[], UInt packetCount, bool tsMode = false); /* override */ void Start(); @@ -70,7 +69,7 @@ namespace Reel /* override */ void Trickmode(UInt trickSpeed); virtual int AproxFramesInQueue(void); - void IncGen(void) { generation_++; } + void IncGen(void) { generation_++; } protected: VideoPlayerHd(); // Allow construction only through Create(). virtual ~VideoPlayerHd() NO_THROW; // Allow destruction only through Destroy(). @@ -83,7 +82,7 @@ namespace Reel UInt generation_; bool volatile freeze_; Int pts_shift_; - Int ac3_pts_shift_; + Int ac3_pts_shift_; template void SendPacket(T const &header, void const *data, size_t dataSize);