From dd7ee34c8c2512256675907e4fb17efcda47c13c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 1 Jun 2013 17:05:23 +0200 Subject: [PATCH 1/5] cDemux: fix error reporting vor video, audio, ... channels --- azbox/dmx.cpp | 6 +++--- generic-pc/dmx.cpp | 6 +++--- libspark/dmx.cpp | 6 +++--- libtriple/dmx_td.cpp | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/azbox/dmx.cpp b/azbox/dmx.cpp index 1fe5561..a68327c 100644 --- a/azbox/dmx.cpp +++ b/azbox/dmx.cpp @@ -43,10 +43,10 @@ extern cVideo *videoDecoder; #define dmx_err(_errfmt, _errstr, _revents) do { \ uint16_t _pid = (uint16_t)-1; uint16_t _f = 0;\ - if (dmx_type == DMX_PES_CHANNEL) { \ - _pid = p_flt.pid; \ - } else if (dmx_type == DMX_PSI_CHANNEL) { \ + if (dmx_type == DMX_PSI_CHANNEL) { \ _pid = s_flt.pid; _f = s_flt.filter.filter[0]; \ + } else { \ + _pid = p_flt.pid; \ }; \ lt_info("%s " _errfmt " fd:%d, ev:0x%x %s pid:0x%04hx flt:0x%02hx\n", \ __func__, _errstr, fd, _revents, DMX_T[dmx_type], _pid, _f); \ diff --git a/generic-pc/dmx.cpp b/generic-pc/dmx.cpp index 19d8fc4..715e6cd 100644 --- a/generic-pc/dmx.cpp +++ b/generic-pc/dmx.cpp @@ -41,10 +41,10 @@ #define dmx_err(_errfmt, _errstr, _revents) do { \ uint16_t _pid = (uint16_t)-1; uint16_t _f = 0;\ - if (dmx_type == DMX_PES_CHANNEL) { \ - _pid = p_flt.pid; \ - } else if (dmx_type == DMX_PSI_CHANNEL) { \ + if (dmx_type == DMX_PSI_CHANNEL) { \ _pid = s_flt.pid; _f = s_flt.filter.filter[0]; \ + } else { \ + _pid = p_flt.pid; \ }; \ lt_info("%s " _errfmt " fd:%d, ev:0x%x %s pid:0x%04hx flt:0x%02hx\n", \ __func__, _errstr, fd, _revents, DMX_T[dmx_type], _pid, _f); \ diff --git a/libspark/dmx.cpp b/libspark/dmx.cpp index ab55271..da9780d 100644 --- a/libspark/dmx.cpp +++ b/libspark/dmx.cpp @@ -78,10 +78,10 @@ extern cVideo *videoDecoder; #define dmx_err(_errfmt, _errstr, _revents) do { \ uint16_t _pid = (uint16_t)-1; uint16_t _f = 0;\ - if (dmx_type == DMX_PES_CHANNEL) { \ - _pid = p_flt.pid; \ - } else if (dmx_type == DMX_PSI_CHANNEL) { \ + if (dmx_type == DMX_PSI_CHANNEL) { \ _pid = s_flt.pid; _f = s_flt.filter.filter[0]; \ + } else { \ + _pid = p_flt.pid; \ }; \ lt_info("%s " _errfmt " fd:%d, ev:0x%x %s pid:0x%04hx flt:0x%02hx\n", \ __func__, _errstr, fd, _revents, DMX_T[dmx_type], _pid, _f); \ diff --git a/libtriple/dmx_td.cpp b/libtriple/dmx_td.cpp index 7ae9ffe..92242d3 100644 --- a/libtriple/dmx_td.cpp +++ b/libtriple/dmx_td.cpp @@ -40,10 +40,10 @@ extern cVideo *videoDecoder; #define dmx_err(_errfmt, _errstr, _revents) do { \ uint16_t _pid = (uint16_t)-1; uint16_t _f = 0;\ - if (dmx_type == DMX_PES_CHANNEL) { \ - _pid = p_flt.pid; \ - } else if (dmx_type == DMX_PSI_CHANNEL) { \ + if (dmx_type == DMX_PSI_CHANNEL) { \ _pid = s_flt.pid; _f = s_flt.filter[0]; \ + } else { \ + _pid = p_flt.pid; \ }; \ lt_info("%s " _errfmt " fd:%d, ev:0x%x %s pid:0x%04hx flt:0x%02hx\n", \ __func__, _errstr, fd, _revents, DMX_T[dmx_type], _pid, _f); \ From 7e9d0f49a9571a4d6e9510392f73925010c0af00 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 1 Jun 2013 17:15:33 +0200 Subject: [PATCH 2/5] generic-pc: increase video and audio demux buffer --- generic-pc/dmx.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/generic-pc/dmx.cpp b/generic-pc/dmx.cpp index 715e6cd..b0c0ee2 100644 --- a/generic-pc/dmx.cpp +++ b/generic-pc/dmx.cpp @@ -120,7 +120,9 @@ bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBuffe num, DMX_T[pes_type], pes_type, uBufferSize, fd); if (dmx_type == DMX_VIDEO_CHANNEL) - uBufferSize = 0x40000; + uBufferSize = 0x100000; /* 1MB */ + if (dmx_type == DMX_AUDIO_CHANNEL) + uBufferSize = 0x10000; /* 64k */ #if 0 if (!pesfds.empty()) { From 618e7723bf8d80cc8a8492974b32f023b9575041 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 1 Jun 2013 17:16:56 +0200 Subject: [PATCH 3/5] generic-pc: implement cDemux::getSTC() --- generic-pc/dmx.cpp | 6 ++++++ generic-pc/video.cpp | 10 ++++++++++ generic-pc/video_lib.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/generic-pc/dmx.cpp b/generic-pc/dmx.cpp index b0c0ee2..fe1d161 100644 --- a/generic-pc/dmx.cpp +++ b/generic-pc/dmx.cpp @@ -35,6 +35,10 @@ #include "dmx_lib.h" #include "lt_debug.h" +/* needed for getSTC :-( */ +#include "video_lib.h" +extern cVideo *videoDecoder; + #define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_DEMUX, this, args) #define lt_info(args...) _lt_info(TRIPLE_DEBUG_DEMUX, this, args) #define lt_info_c(args...) _lt_info(TRIPLE_DEBUG_DEMUX, NULL, args) @@ -474,6 +478,8 @@ void cDemux::removePid(unsigned short Pid) void cDemux::getSTC(int64_t * STC) { int64_t pts = 0; + if (videoDecoder) + pts = videoDecoder->GetPTS(); *STC = pts; } diff --git a/generic-pc/video.cpp b/generic-pc/video.cpp index 92ee802..0b39414 100644 --- a/generic-pc/video.cpp +++ b/generic-pc/video.cpp @@ -650,3 +650,13 @@ bool cVideo::GetScreenImage(unsigned char * &data, int &xres, int &yres, bool ge return true; } + +int64_t cVideo::GetPTS(void) +{ + int64_t pts = 0; + buf_m.lock(); + if (buf_num != 0) + pts = buffers[buf_out].pts(); + buf_m.unlock(); + return pts; +} diff --git a/generic-pc/video_lib.h b/generic-pc/video_lib.h index 36f9892..69ab36a 100644 --- a/generic-pc/video_lib.h +++ b/generic-pc/video_lib.h @@ -122,6 +122,7 @@ typedef enum class cVideo : public OpenThreads::Thread { friend class GLFramebuffer; + friend class cDemux; private: /* called from GL thread */ class SWFramebuffer : public std::vector @@ -143,6 +144,7 @@ class cVideo : public OpenThreads::Thread AVRational mAR; }; int buf_in, buf_out, buf_num; + int64_t GetPTS(void); public: /* constructor & destructor */ cVideo(int mode, void *, void *); From 70a2f5bca0f2e56e595526c656da636d0fa2f5e5 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 16 Jun 2013 21:42:42 +0200 Subject: [PATCH 4/5] cPlayback: add new API functions for DVD chapter/subtitles right now these are mostly dummies... --- azbox/playback.cpp | 12 ++++++++++-- azbox/playback.h | 7 ++++--- generic-pc/playback.cpp | 14 +++++++++++++- generic-pc/playback.h | 6 ++++-- libspark/playback_libeplayer3.cpp | 19 +++++++++++++++++++ libspark/playback_libeplayer3.h | 4 ++++ libtriple/playback_td.cpp | 18 ++++++++++++++++++ libtriple/playback_td.h | 3 +++ 8 files changed, 75 insertions(+), 8 deletions(-) diff --git a/azbox/playback.cpp b/azbox/playback.cpp index 4523192..1e656f3 100644 --- a/azbox/playback.cpp +++ b/azbox/playback.cpp @@ -336,7 +336,7 @@ bool cPlayback::SetAPid(unsigned short pid, int /*ac3*/) return true; } -bool cPlayback::SetSPid(int pid) +bool cPlayback::SelectSubtitles(int pid) { lt_info("%s: pid %i\n", __func__, pid); if (pid != subpid) @@ -464,7 +464,7 @@ void cPlayback::FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t } } -void cPlayback::FindAllSPids(int *spids, uint16_t *numpids, std::string *language) +void cPlayback::FindAllSubs(uint16_t *spids, unsigned short *supported, uint16_t *numpids, std::string *language) { lt_info("%s\n", __func__); char buf[32]; @@ -487,6 +487,7 @@ void cPlayback::FindAllSPids(int *spids, uint16_t *numpids, std::string *languag spu_lang[20] = '\0'; spids[sid] = atoi(streamidstring); language[sid] = spu_lang; + supported[sid] = 1; lt_info("%s: #%d apid:%d lang: %s\n", __func__, sid, spids[sid], spu_lang); } } @@ -496,6 +497,13 @@ void cPlayback::FindAllSPids(int *spids, uint16_t *numpids, std::string *languag language[spu_count] = "Disable"; } +/* DVD support is not yet ready... */ +void cPlayback::GetChapters(std::vector &positions, std::vector &titles) +{ + positions.clear(); + titles.clear(); +} + cPlayback::cPlayback(int /*num*/) { lt_info("%s: constructor\n", __func__); diff --git a/azbox/playback.h b/azbox/playback.h index d75a76f..c56c69e 100644 --- a/azbox/playback.h +++ b/azbox/playback.h @@ -3,6 +3,7 @@ #include #include +#include typedef enum { PLAYMODE_TS = 0, @@ -42,9 +43,9 @@ class cPlayback bool GetPosition(int &position, int &duration); /* pos: current time in ms, dur: file length in ms */ bool SetPosition(int position, bool absolute = false); /* position: jump in ms */ void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language); - // AZbox specific - void FindAllSPids(int *spids, uint16_t *numpids, std::string *language); - bool SetSPid(int pid); + void FindAllSubs(uint16_t *pids, unsigned short *supported, uint16_t *numpida, std::string *language); + bool SelectSubtitles(int pid); + void GetChapters(std::vector &positions, std::vector &titles); #if 0 // Functions that are not used by movieplayer.cpp: bool Stop(void); diff --git a/generic-pc/playback.cpp b/generic-pc/playback.cpp index 0aa2a75..bea2349 100644 --- a/generic-pc/playback.cpp +++ b/generic-pc/playback.cpp @@ -26,7 +26,7 @@ bool cPlayback::SetAPid(unsigned short pid, bool /*ac3*/) return true; } -bool cPlayback::SetSPid(int pid) +bool cPlayback::SelectSubtitles(int pid) { printf("%s:%s pid %i\n", FILENAME, __func__, pid); return true; @@ -63,6 +63,18 @@ void cPlayback::FindAllPids(uint16_t *, unsigned short *, uint16_t *numpida, std *numpida = 0; } +void cPlayback::FindAllSubs(uint16_t *, unsigned short *, uint16_t *numpida, std::string *) +{ + printf("%s:%s\n", FILENAME, __func__); + *numpida = 0; +} + +void cPlayback::GetChapters(std::vector &positions, std::vector &titles) +{ + positions.clear(); + titles.clear(); +} + cPlayback::cPlayback(int /*num*/) { printf("%s:%s\n", FILENAME, __func__); diff --git a/generic-pc/playback.h b/generic-pc/playback.h index 862f444..dbcc1fe 100644 --- a/generic-pc/playback.h +++ b/generic-pc/playback.h @@ -3,6 +3,7 @@ #include #include +#include typedef enum { PLAYMODE_TS = 0, @@ -19,13 +20,14 @@ class cPlayback bool Start(char * filename, unsigned short vpid, int vtype, unsigned short apid, bool ac3, int duration); bool Stop(void); bool SetAPid(unsigned short pid, bool ac3); - bool SetSPid(int pid); bool SetSpeed(int speed); bool GetSpeed(int &speed) const; bool GetPosition(int &position, int &duration); bool SetPosition(int position, bool absolute = false); void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language); - void FindAllSPids(int *spids, uint16_t *numpids, std::string *language); + void FindAllSubs(uint16_t *pids, unsigned short *supported, uint16_t *numpida, std::string *language); + bool SelectSubtitles(int pid); + void GetChapters(std::vector &positions, std::vector &titles); // cPlayback(int num = 0); ~cPlayback(); diff --git a/libspark/playback_libeplayer3.cpp b/libspark/playback_libeplayer3.cpp index bedf851..f21bd96 100644 --- a/libspark/playback_libeplayer3.cpp +++ b/libspark/playback_libeplayer3.cpp @@ -459,6 +459,25 @@ void cPlayback::FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t } } +/* dummy functions for subtitles */ +void cPlayback::FindAllSubs(uint16_t * /*pids*/, unsigned short * /*supp*/, uint16_t *num, std::string * /*lang*/) +{ + *num = 0; +} + +bool cPlayback::SelectSubtitles(int pid) +{ + printf("%s:%s pid %d\n", FILENAME, __func__, pid); + return false; +} + +/* another dummy function for DVD playback(?) */ +void cPlayback::GetChapters(std::vector &positions, std::vector &titles) +{ + positions.clear(); + titles.clear(); +} + // cPlayback::cPlayback(int num) { diff --git a/libspark/playback_libeplayer3.h b/libspark/playback_libeplayer3.h index d709abb..05c0b6a 100644 --- a/libspark/playback_libeplayer3.h +++ b/libspark/playback_libeplayer3.h @@ -2,6 +2,7 @@ #define __HAL_PLAYBACK_H #include +#include typedef enum { PLAYMODE_TS = 0, @@ -30,6 +31,9 @@ class cPlayback bool GetPosition(int &position, int &duration); bool SetPosition(int position, bool absolute = false); void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language); + void FindAllSubs(uint16_t *pids, unsigned short *supported, uint16_t *numpida, std::string *language); + bool SelectSubtitles(int pid); + void GetChapters(std::vector &positions, std::vector &titles); #if 0 // Functions that are not used by movieplayer.cpp: bool GetOffset(off64_t &offset); diff --git a/libtriple/playback_td.cpp b/libtriple/playback_td.cpp index a1c02e7..2fee33a 100644 --- a/libtriple/playback_td.cpp +++ b/libtriple/playback_td.cpp @@ -576,6 +576,24 @@ void cPlayback::FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida = i; } +/* it is unlikely that subtitle support will be implemented soon */ +void cPlayback::FindAllSubs(uint16_t *, unsigned short *, uint16_t *num, std::string *) +{ + *num = 0; +} + +bool cPlayback::SelectSubtitles(int) +{ + return false; +} + +/* DVD support is also unlikely... */ +void cPlayback::GetChapters(std::vector &positions, std::vector &titles) +{ + positions.clear(); + titles.clear(); +} + off_t cPlayback::seek_to_pts(int64_t pts) { off_t newpos = curr_pos; diff --git a/libtriple/playback_td.h b/libtriple/playback_td.h index dcb78e3..51d5ac1 100644 --- a/libtriple/playback_td.h +++ b/libtriple/playback_td.h @@ -109,6 +109,9 @@ class cPlayback bool GetPosition(int &position, int &duration); /* pos: current time in ms, dur: file length in ms */ bool SetPosition(int position, bool absolute = false); /* position: jump in ms */ void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language); + void FindAllSubs(uint16_t *pids, unsigned short *supported, uint16_t *numpida, std::string *language); + bool SelectSubtitles(int pid); + void GetChapters(std::vector &positions, std::vector &titles); #if 0 // Functions that are not used by movieplayer.cpp: bool Stop(void); From 9338fc6d1f61a71cfb75626a52537fb41587f948 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 16 Jun 2013 22:16:12 +0200 Subject: [PATCH 5/5] modernize configure.ac and Makefile.am autoconf-1.13 has new warnings, silence them by updating the buildsystem --- azbox/Makefile.am | 6 +++--- configure.ac | 4 ++-- generic-pc/Makefile.am | 6 +++--- libeplayer3/Makefile.am | 4 ++-- libspark/Makefile.am | 8 ++++---- libtriple/Makefile.am | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/azbox/Makefile.am b/azbox/Makefile.am index 46a3f6c..0e6b74f 100644 --- a/azbox/Makefile.am +++ b/azbox/Makefile.am @@ -1,8 +1,8 @@ -INCLUDES = \ - -I$(top_srcdir)/common - noinst_LTLIBRARIES = libazbox.la +AM_CPPFLAGS = \ + -I$(top_srcdir)/common + AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing AM_LDFLAGS = -lpthread diff --git a/configure.ac b/configure.ac index 88dbf02..cf816f5 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ -AC_INIT(libstb-hal,0.1.1) -AM_INIT_AUTOMAKE(libstb-hal,0.1.1) +AC_INIT([libstb-hal], [0.1.1]) +AM_INIT_AUTOMAKE m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) AC_CONFIG_MACRO_DIR([m4]) AC_GNU_SOURCE diff --git a/generic-pc/Makefile.am b/generic-pc/Makefile.am index 130e419..f4dbbc7 100644 --- a/generic-pc/Makefile.am +++ b/generic-pc/Makefile.am @@ -1,9 +1,9 @@ -INCLUDES = \ - -I$(top_srcdir)/common - noinst_LTLIBRARIES = libgeneric.la AM_CPPFLAGS = -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS +AM_CPPFLAGS += \ + -I$(top_srcdir)/common + AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing AM_LDFLAGS = \ diff --git a/libeplayer3/Makefile.am b/libeplayer3/Makefile.am index cb31f9d..a5fb28c 100644 --- a/libeplayer3/Makefile.am +++ b/libeplayer3/Makefile.am @@ -2,7 +2,7 @@ noinst_LTLIBRARIES = libeplayer3.la CXXFLAGS = -Wall -INCLUDES = \ +AM_CPPFLAGS = \ -I$(srcdir)/include libeplayer3_la_SOURCES = \ @@ -24,7 +24,7 @@ AM_CFLAGS += \ -Wno-unused -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable \ -Wno-sign-compare -Wno-missing-field-initializers # silence ffmpeg deprecation warnings -AM_CPPFLAGS = -Dattribute_deprecated='' +AM_CPPFLAGS += -Dattribute_deprecated='' #libeplayer3_la_LIBADD = -lpthread -lavformat -lavcodec -lavutil -lz -lass -lm -lpng diff --git a/libspark/Makefile.am b/libspark/Makefile.am index 39afbd1..6d0384c 100644 --- a/libspark/Makefile.am +++ b/libspark/Makefile.am @@ -1,9 +1,9 @@ -INCLUDES = \ +noinst_LTLIBRARIES = libspark.la + +AM_CPPFLAGS = \ -I$(top_srcdir)/common \ -I$(top_srcdir)/libeplayer3/include -noinst_LTLIBRARIES = libspark.la - AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing AM_LDFLAGS = -lpthread -lass @@ -19,4 +19,4 @@ libspark_la_SOURCES = \ pwrmngr.cpp \ record.cpp -AM_CPPFLAGS = -DF_INTERRUPTS=20000 -DIRMP_EMBED -DLIRC_IRMP +AM_CPPFLAGS += -DF_INTERRUPTS=20000 -DIRMP_EMBED -DLIRC_IRMP diff --git a/libtriple/Makefile.am b/libtriple/Makefile.am index 1bad773..6df87cb 100644 --- a/libtriple/Makefile.am +++ b/libtriple/Makefile.am @@ -1,9 +1,9 @@ -INCLUDES = \ +noinst_LTLIBRARIES = libtriple.la + +AM_CPPFLAGS = \ -I$(top_srcdir)/common \ @DIRECTFB_CFLAGS@ -noinst_LTLIBRARIES = libtriple.la - AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing AM_LDFLAGS = \ @DIRECTFB_LIBS@