From 0150a109f1449418fac6f9e10ec5ba6f27815278 Mon Sep 17 00:00:00 2001 From: Frankenstone Date: Sun, 19 Aug 2018 18:18:55 +0200 Subject: [PATCH 01/59] fix CEC TV ON after deepstandby - init 4 / init 3 Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/8e37565740b54d2b9aedd7578f27bd73799c46d7 Author: Frankenstone Date: 2018-08-19 (Sun, 19 Aug 2018) ------------------ This commit was generated by Migit --- libeplayer3-arm/main/exteplayer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libeplayer3-arm/main/exteplayer.c b/libeplayer3-arm/main/exteplayer.c index 7538799..6bea361 100644 --- a/libeplayer3-arm/main/exteplayer.c +++ b/libeplayer3-arm/main/exteplayer.c @@ -676,6 +676,7 @@ static int ParseParams(int argc, char *argv[], PlayFiles_t *playbackFiles, int * int main(int argc, char *argv[]) { + system("echo 'encoder' > /proc/stb/avs/0/input"); pthread_t termThread; int isTermThreadStarted = 0; From 0f9070a68ed66d884af8ce3da6d309eac5606076 Mon Sep 17 00:00:00 2001 From: BPanther Date: Tue, 28 Aug 2018 07:46:08 +0200 Subject: [PATCH 02/59] vusolo4k: small fix - but not yet ready Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/360661992ed604873e9b28f1591eebf05fb5cc22 Author: BPanther Date: 2018-08-28 (Tue, 28 Aug 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/hardware_caps.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libarmbox/hardware_caps.c b/libarmbox/hardware_caps.c index 1190939..782e35d 100644 --- a/libarmbox/hardware_caps.c +++ b/libarmbox/hardware_caps.c @@ -7,6 +7,7 @@ * License: GPL v2 or later */ +#include #include #include #include @@ -28,6 +29,23 @@ hw_caps_t *get_hwcaps(void) memset(&caps, 0, sizeof(hw_caps_t)); +#if BOXMODEL_VUSOLO4K + initialized = 1; + caps.has_CI = 1; + caps.can_cec = 1; + caps.can_shutdown = 1; + caps.display_xres = 480; + caps.display_yres = 320; + caps.display_type = HW_DISPLAY_GFX; + caps.display_can_deepstandby = 1; + caps.display_can_set_brightness = 1; + caps.display_has_statusline = 1; + caps.has_button_timer = 1; + caps.has_HDMI = 1; + strcpy(caps.boxvendor, "VU"); + strcpy(caps.boxname, "SOLO4K"); + strcpy(caps.boxarch, "BCM7376"); +#else initialized = 1; caps.has_CI = 1; caps.can_cec = 1; @@ -42,5 +60,6 @@ hw_caps_t *get_hwcaps(void) strcpy(caps.boxvendor, "AX-Technologies"); strcpy(caps.boxname, "HD51"); strcpy(caps.boxarch, "BCM7251S"); +#endif return ∩︀ } From 8628231f86e5e3f47a80dcd670878e45f30354e0 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Tue, 25 Sep 2018 20:23:08 +0200 Subject: [PATCH 03/59] add frontpanel xres for sh4 (thx dbo) Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/477bbc064cf6a390cfbdb7095862aa9442ed1621 Author: TangoCash Date: 2018-09-25 (Tue, 25 Sep 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libduckbox/hardware_caps.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libduckbox/hardware_caps.c b/libduckbox/hardware_caps.c index 56e9254..8550149 100644 --- a/libduckbox/hardware_caps.c +++ b/libduckbox/hardware_caps.c @@ -59,6 +59,8 @@ hw_caps_t *get_hwcaps(void) caps.has_fan = 0; caps.has_CI = 2; caps.display_can_set_brightness = 1; + caps.display_type = HW_DISPLAY_LINE_TEXT; + caps.display_xres = 16; } else if (!strncmp(buf, "ufs913", 6)) { strcpy(caps.boxvendor, "DUCKBOX"); @@ -70,6 +72,8 @@ hw_caps_t *get_hwcaps(void) caps.has_fan = 0; caps.has_CI = 2; caps.display_can_set_brightness = 1; + caps.display_type = HW_DISPLAY_LINE_TEXT; + caps.display_xres = 16; } else if (!strncmp(buf, "ufs922", 6)) { strcpy(caps.boxvendor, "DUCKBOX"); @@ -81,6 +85,8 @@ hw_caps_t *get_hwcaps(void) caps.has_fan = 1; caps.has_CI = 2; caps.display_can_set_brightness = 1; + caps.display_type = HW_DISPLAY_LINE_TEXT; + caps.display_xres = 16; } else if (!strncmp(buf, "ufs910", 6)) { strcpy(caps.boxvendor, "DUCKBOX"); @@ -92,6 +98,8 @@ hw_caps_t *get_hwcaps(void) caps.has_fan = 0; caps.has_CI = 2; caps.display_can_set_brightness = 1; + caps.display_type = HW_DISPLAY_LINE_TEXT; + caps.display_xres = 16; } else if (!strncmp(buf, "hdbox", 5)) { strcpy(caps.boxvendor, "DUCKBOX"); From 0c3bd690407b9bf480a6c92a30bb5dab26895c49 Mon Sep 17 00:00:00 2001 From: max_10 Date: Wed, 29 Aug 2018 12:13:43 +0200 Subject: [PATCH 04/59] [libarmbox] playback_libeplayer3.cpp code format Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/5402933900be9b930be9294986199cd0aa5ce3ad Author: max_10 Date: 2018-08-29 (Wed, 29 Aug 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/playback_libeplayer3.cpp | 104 ++++++++++++++++++++++------- 1 file changed, 81 insertions(+), 23 deletions(-) diff --git a/libarmbox/playback_libeplayer3.cpp b/libarmbox/playback_libeplayer3.cpp index e293ea1..f5f5d21 100644 --- a/libarmbox/playback_libeplayer3.cpp +++ b/libarmbox/playback_libeplayer3.cpp @@ -47,33 +47,41 @@ bool cPlayback::Open(playmode_t PlayMode) last_size = 0; nPlaybackSpeed = 0; init_jump = -1; + if (player) free(player); player = NULL; + player = (Context_t *) malloc(sizeof(Context_t)); + if (player) { player->playback = &PlaybackHandler; player->output = &OutputHandler; player->container = &ContainerHandler; player->manager = &ManagerHandler; + lt_info("%s - player output name: %s PlayMode: %s\n", __func__, player->output->Name, aPLAYMODE[PlayMode]); } + //Registration of output devices if (player && player->output) { player->output->Command(player, OUTPUT_ADD, (void *)"audio"); player->output->Command(player, OUTPUT_ADD, (void *)"video"); } + return 0; } void cPlayback::Close(void) { lt_info("%s\n", __func__); + //Dagobert: movieplayer does not call stop, it calls close ;) if(playing) Stop(); + if (decoders_closed) { audioDecoder->openDevice(); @@ -92,7 +100,9 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, in bool ret = false; bool isHTTP = false; no_probe = false; + lt_info("%s - filename=%s vpid=%u vtype=%d apid=%u ac3=%d\n", __func__, filename, vpid, vtype, apid, ac3); + init_jump = -1; //create playback path mAudioStream = 0; @@ -100,11 +110,14 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, in mTeletextStream = -1; unlink("/tmp/.id3coverart"); std::string file; + if (*filename == '/') file = "file://"; file += filename; + if ((file.find(":31339/id=") != std::string::npos) || (file.find(":10000") != std::string::npos) || (file.find(":8001/") != std::string::npos)) // for LocalTV and Entertain-TV streaming no_probe = true; + if (file.substr(0, 7) == "file://") { if (file.substr(file.length() - 3) == ".ts") @@ -117,6 +130,7 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, in } else isHTTP = true; + PlayFiles_t playbackFiles = { (char *) file.c_str(), NULL, NULL, NULL, 0, 0, 0, 0}; if (player->playback->Command(player, PLAYBACK_OPEN, &playbackFiles) == 0) { @@ -140,15 +154,16 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, in { printf("AudioTrack List\n"); int i = 0; - for (i = 0; TrackList[i] != NULL; i+=2) + for (i = 0; TrackList[i] != NULL; i += 2) { - printf("\t%s - %s\n", TrackList[i], TrackList[i+1]); + printf("\t%s - %s\n", TrackList[i], TrackList[i + 1]); free(TrackList[i]); - free(TrackList[i+1]); + free(TrackList[i + 1]); } free(TrackList); } } + //SUB if (player && player->manager && player->manager->subtitle) { @@ -160,13 +175,14 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, in int i = 0; for (i = 0; TrackList[i] != NULL; i+=2) { - printf("\t%s - %s\n", TrackList[i], TrackList[i+1]); + printf("\t%s - %s\n", TrackList[i], TrackList[i + 1]); free(TrackList[i]); - free(TrackList[i+1]); + free(TrackList[i + 1]); } free(TrackList); } } + /* //Teletext if (player && player->manager && player->manager->teletext) @@ -177,15 +193,16 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, in { printf("TeletextTrack List\n"); int i = 0; - for (i = 0; TrackList[i] != NULL; i+=2) + for (i = 0; TrackList[i] != NULL; i += 2) { - printf("\t%s - %s\n", TrackList[i], TrackList[i+1]); + printf("\t%s - %s\n", TrackList[i], TrackList[i + 1]); free(TrackList[i]); - free(TrackList[i+1]); + free(TrackList[i + 1]); } free(TrackList); } } + */ //Chapters if (player && player->manager && player->manager->chapter) @@ -196,19 +213,21 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, in { printf("Chapter List\n"); int i = 0; - for (i = 0; TrackList[i] != NULL; i+=2) + for (i = 0; TrackList[i] != NULL; i += 2) { - printf("\t%s - %s\n", TrackList[i], TrackList[i+1]); + printf("\t%s - %s\n", TrackList[i], TrackList[i + 1]); free(TrackList[i]); - free(TrackList[i+1]); + free(TrackList[i + 1]); } free(TrackList); } } + playing = true; first = true; player->output->Command(player, OUTPUT_OPEN, NULL); ret = (player->playback->Command(player, PLAYBACK_PLAY, NULL) == 0); + if (ret && !isHTTP) playing = ret = (player->playback->Command(player, PLAYBACK_PAUSE, NULL) == 0); } @@ -219,17 +238,22 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, in bool cPlayback::Stop(void) { lt_info("%s playing %d\n", __func__, playing); + if (player && player->playback) player->playback->Command(player, PLAYBACK_STOP, NULL); + if (player && player->output) player->output->Command(player, OUTPUT_CLOSE, NULL); + if (player && player->output) { player->output->Command(player, OUTPUT_DEL, (void *)"audio"); player->output->Command(player, OUTPUT_DEL, (void *)"video"); } + if (player && player->playback) player->playback->Command(player, PLAYBACK_CLOSE, NULL); + playing = false; return true; } @@ -238,6 +262,7 @@ bool cPlayback::SetAPid(int pid, bool /* ac3 */) { lt_info("%s\n", __func__); int i = pid; + if (pid != mAudioStream) { if (player && player->playback) @@ -257,6 +282,7 @@ bool cPlayback::SetSubtitlePid(int pid) { lt_info("%s\n", __func__); int i = pid; + if (pid != mSubtitleStream) { if (player && player->playback) @@ -269,11 +295,13 @@ bool cPlayback::SetSubtitlePid(int pid) bool cPlayback::SetTeletextPid(int pid) { lt_info("%s\n", __func__); + //int i = pid; + if (pid != mTeletextStream) { - //if(player && player->playback) - //player->playback->Command(player, PLAYBACK_SWITCH_TELETEXT, (void*)&i); + //if (player && player->playback) + // player->playback->Command(player, PLAYBACK_SWITCH_TELETEXT, (void*)&i); mTeletextStream = pid; } return true; @@ -282,6 +310,7 @@ bool cPlayback::SetTeletextPid(int pid) bool cPlayback::SetSpeed(int speed) { lt_info("%s playing %d speed %d\n", __func__, playing, speed); + if (!decoders_closed) { audioDecoder->closeDevice(); @@ -295,12 +324,15 @@ bool cPlayback::SetSpeed(int speed) playing = true; } } + if (!playing) return false; + if (player && player->playback) { int result = 0; nPlaybackSpeed = speed; + if (speed > 1) { /* direction switch ? */ @@ -337,11 +369,13 @@ bool cPlayback::SetSpeed(int speed) { result = player->playback->Command(player, PLAYBACK_CONTINUE, NULL); } + if (init_jump > -1) { SetPosition(init_jump); init_jump = -1; } + if (result != 0) { printf("returning false\n"); @@ -369,6 +403,7 @@ bool cPlayback::GetPosition(int &position, int &duration) { bool got_duration = false; lt_debug("%s %d %d\n", __func__, position, duration); + /* hack: if the file is growing (timeshift), then determine its length * by comparing the mtime with the mtime of the xml file */ if (pm == PLAYMODE_TS) @@ -390,17 +425,21 @@ bool cPlayback::GetPosition(int &position, int &duration) } } } + if (!playing) return false; + if (player && player->playback && !player->playback->isPlaying) { lt_info("%s !!!!EOF!!!! < -1\n", __func__); position = duration + 1000; return false; } + int64_t vpts = 0; if (player && player->playback) player->playback->Command(player, PLAYBACK_PTS, &vpts); + if (vpts <= 0) { //printf("ERROR: vpts==0"); @@ -410,21 +449,31 @@ bool cPlayback::GetPosition(int &position, int &duration) /* len is in nanoseconds. we have 90 000 pts per second. */ position = vpts / 90; } + if (got_duration) return true; + int64_t length = 0; + if (player && player->playback) player->playback->Command(player, PLAYBACK_LENGTH, &length); + if (length <= 0) + { duration = duration + 1000; + } else + { duration = length * 1000; + } + return true; } bool cPlayback::SetPosition(int position, bool absolute) { lt_info("%s %d\n", __func__, position); + if (playing && first) { /* the calling sequence is: @@ -437,9 +486,12 @@ bool cPlayback::SetPosition(int position, bool absolute) first = false; return false; } + int64_t pos = (position / 1000.0); + if (player && player->playback) player->playback->Command(player, absolute ? PLAYBACK_SEEK_ABS : PLAYBACK_SEEK, (void *)&pos); + return true; } @@ -448,6 +500,7 @@ void cPlayback::FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *nu lt_info("%s\n", __func__); int max_numpida = *numpida; *numpida = 0; + if (player && player->manager && player->manager->audio) { char **TrackList = NULL; @@ -467,9 +520,9 @@ void cPlayback::FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *nu { apids[j] = _pid; // atUnknown, atMPEG, atMP3, atAC3, atDTS, atAAC, atPCM, atOGG, atFLAC - if (!strncmp("A_MPEG/L3", TrackList[i + 1], 9)) + if (!strncmp("A_MPEG/L3", TrackList[i + 1], 9)) ac3flags[j] = 3; - if (!strncmp("A_MP3", TrackList[i + 1], 5)) + if (!strncmp("A_MP3", TrackList[i + 1], 5)) ac3flags[j] = 4; else if (!strncmp("A_AC3", TrackList[i + 1], 5)) ac3flags[j] = 1; @@ -502,8 +555,10 @@ void cPlayback::FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *nu void cPlayback::FindAllSubtitlePids(int *pids, unsigned int *numpids, std::string *language) { lt_info("%s\n", __func__); + int max_numpids = *numpids; *numpids = 0; + if (player && player->manager && player->manager->subtitle) { char **TrackList = NULL; @@ -539,8 +594,8 @@ void cPlayback::FindAllTeletextsubtitlePids(int */*pids*/, unsigned int *numpids lt_info("%s\n", __func__); //int max_numpids = *numpids; *numpids = 0; - /* - if (player && player->manager && player->manager->teletext) + +/* if (player && player->manager && player->manager->teletext) { char **TrackList = NULL; player->manager->teletext->Command(player, MANAGER_LIST, &TrackList); @@ -569,16 +624,15 @@ void cPlayback::FindAllTeletextsubtitlePids(int */*pids*/, unsigned int *numpids free(TrackList); *numpids = j; } - } - */ + } */ } int cPlayback::GetTeletextPid(void) { lt_info("%s\n", __func__); int pid = -1; - /* - if (player && player->manager && player->manager->teletext) + +/* if (player && player->manager && player->manager->teletext) { char **TrackList = NULL; player->manager->teletext->Command(player, MANAGER_LIST, &TrackList); @@ -602,8 +656,8 @@ int cPlayback::GetTeletextPid(void) } free(TrackList); } - } - */ + } */ + printf("teletext pid id %d (0x%x)\n", pid, pid); return pid; } @@ -623,6 +677,7 @@ void cPlayback::GetChapters(std::vector &positions, std::vectormanager && player->manager->chapter) { char **TrackList = NULL; @@ -690,6 +745,7 @@ cPlayback::cPlayback(int num __attribute__((unused))) cPlayback::~cPlayback() { lt_info("%s\n", __func__); + if (player) free(player); player = NULL; @@ -736,6 +792,7 @@ void cPlayback::ReleaseAVFormatContext() bool cPlayback::IsPlaying(void) const { lt_info("%s\n", __func__); + /* konfetti: there is no event/callback mechanism in libeplayer2 * so in case of ending playback we have no information on a * terminated stream currently (or did I oversee it?). @@ -745,6 +802,7 @@ bool cPlayback::IsPlaying(void) const { return player->playback->isPlaying; } + return playing; } #endif From b449c83bf31d9871928c33abe808e82d137b2665 Mon Sep 17 00:00:00 2001 From: max_10 Date: Wed, 29 Aug 2018 13:09:21 +0200 Subject: [PATCH 05/59] [libarmbox] Change Makefile.am Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/9c5221298bdf1df594e47181b479f0672d779320 Author: max_10 Date: 2018-08-29 (Wed, 29 Aug 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3-arm/Makefile.am | 61 ++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/libeplayer3-arm/Makefile.am b/libeplayer3-arm/Makefile.am index 7ba03f2..0db258d 100644 --- a/libeplayer3-arm/Makefile.am +++ b/libeplayer3-arm/Makefile.am @@ -1,30 +1,43 @@ AUTOMAKE_OPTIONS = subdir-objects +AM_CFLAGS = -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE + +CXXFLAGS = -Wall noinst_LTLIBRARIES = libeplayer3_arm.la -AM_CFLAGS = -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE +AM_CPPFLAGS = -I$(srcdir)/include +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -I$(srcdir)/external -AM_CPPFLAGS = -I$(srcdir)/include -AM_CPPFLAGS += -I$(top_srcdir)/include -AM_CPPFLAGS += -I$(srcdir)/external +AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing -AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing +SOURCE_FILES = container/container.c +SOURCE_FILES += container/container_ffmpeg.c +SOURCE_FILES += manager/manager.c +SOURCE_FILES += manager/audio.c +SOURCE_FILES += manager/video.c +SOURCE_FILES += manager/chapter.c +SOURCE_FILES += manager/subtitle.c +SOURCE_FILES += output/output_subtitle.c +SOURCE_FILES += output/output.c +SOURCE_FILES += output/writer/common/pes.c +SOURCE_FILES += output/writer/common/misc.c +SOURCE_FILES += output/writer/common/writer.c +SOURCE_FILES += output/linuxdvb_buffering.c +SOURCE_FILES += playback/playback.c +SOURCE_FILES += external/ffmpeg/src/bitstream.c +SOURCE_FILES += external/ffmpeg/src/latmenc.c +SOURCE_FILES += external/ffmpeg/src/mpeg4audio.c -libeplayer3_arm_la_SOURCES = \ - container/container.c \ - container/container_ffmpeg.c \ - manager/manager.c \ - manager/audio.c \ - manager/video.c \ - manager/subtitle.c \ - manager/chapter.c \ +#AM_CFLAGS += -DHAVE_FLV2MPEG4_CONVERTER +#AM_CPPFLAGS += -I$(srcdir)/external/flv2mpeg4 +#SOURCE_FILES += external/flv2mpeg4/src/m4vencode.c +#SOURCE_FILES += external/flv2mpeg4/src/flvdecoder.c +#SOURCE_FILES += external/flv2mpeg4/src/dcprediction.c +#SOURCE_FILES += external/flv2mpeg4/src/flv2mpeg4.c + +SOURCE_FILES += \ output/linuxdvb_mipsel.c \ - output/linuxdvb_buffering.c \ - output/output_subtitle.c \ - output/output.c \ - output/writer/common/pes.c \ - output/writer/common/misc.c \ - output/writer/common/writer.c \ output/writer/mipsel/writer.c \ output/writer/mipsel/aac.c \ output/writer/mipsel/ac3.c \ @@ -42,15 +55,13 @@ libeplayer3_arm_la_SOURCES = \ output/writer/mipsel/divx3.c \ output/writer/mipsel/vp.c \ output/writer/mipsel/wmv.c \ - output/writer/mipsel/vc1.c \ - playback/playback.c \ - external/ffmpeg/src/bitstream.c \ - external/ffmpeg/src/latmenc.c \ - external/ffmpeg/src/mpeg4audio.c + output/writer/mipsel/vc1.c +libeplayer3_arm_la_SOURCES = $(SOURCE_FILES) -LIBEPLAYER3_LIBS = libeplayer3_arm.la -lpthread -lavformat -lavcodec -lavutil -lswresample -lz -lm +LIBEPLAYER3_LIBS = libeplayer3_arm.la -lpthread -lavformat -lavcodec -lavutil -lswresample bin_PROGRAMS = eplayer3 eplayer3_SOURCES = main/exteplayer.c eplayer3_LDADD = $(LIBEPLAYER3_LIBS) +eplayer3_DEPENDENCIES = libeplayer3_arm.la From cdbc3c7a7d011c76660224976ea14be29129c60c Mon Sep 17 00:00:00 2001 From: max_10 Date: Wed, 29 Aug 2018 14:29:29 +0200 Subject: [PATCH 06/59] [libarmbox] add libeplayer3-arm --enable-flv2mpeg4 Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/f8e5b9a4a0d7137556037a4f14f1dd8baf9fc82e Author: max_10 Date: 2018-08-29 (Wed, 29 Aug 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- acinclude.m4 | 6 +++--- configure.ac | 9 +++++++++ libeplayer3-arm/Makefile.am | 14 ++++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index b9d9be1..6b9232b 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -152,11 +152,11 @@ AC_SUBST(PLUGINDIR) AC_SUBST(THEMESDIR) dnl end workaround -AC_DEFUN([TUXBOX_BOXTYPE],[ +AC_DEFUN([TUXBOX_BOXTYPE], [ AC_ARG_WITH(boxtype, - [ --with-boxtype valid values: tripledragon,spark,azbox,generic,duckbox,spark7162,armbox], + AS_HELP_STRING([--with-boxtype], [valid values: tripledragon, spark, azbox, generic, armbox, duckbox, spark7162]), [case "${withval}" in - tripledragon|azbox|generic) + tripledragon|azbox|generic|armbox) BOXTYPE="$withval" ;; spark|spark7162) diff --git a/configure.ac b/configure.ac index f6bf9fe..0775f23 100644 --- a/configure.ac +++ b/configure.ac @@ -62,6 +62,15 @@ if test x$BOXTYPE = xgeneric -a x$BOXMODEL != xraspi; then PKG_CHECK_MODULES([SWRESAMPLE], [libswresample]) fi +AC_ARG_ENABLE(flv2mpeg4, + AS_HELP_STRING(--enable-flv2mpeg4, use flv2mpeg4 libeplayer3-arm), + ,[enable_flv2mpeg4=no]) + +AM_CONDITIONAL(FLV2MPEG4, test "$enable_flv2mpeg4" = "yes") +if test "$enable_flv2mpeg4" = "yes"; then + AC_DEFINE(ENABLE_FLV2MPEG4, 1, [use flv2mpeg4 libeplayer3-arm]) +fi + AC_OUTPUT([ Makefile common/Makefile diff --git a/libeplayer3-arm/Makefile.am b/libeplayer3-arm/Makefile.am index 0db258d..193f427 100644 --- a/libeplayer3-arm/Makefile.am +++ b/libeplayer3-arm/Makefile.am @@ -29,12 +29,14 @@ SOURCE_FILES += external/ffmpeg/src/bitstream.c SOURCE_FILES += external/ffmpeg/src/latmenc.c SOURCE_FILES += external/ffmpeg/src/mpeg4audio.c -#AM_CFLAGS += -DHAVE_FLV2MPEG4_CONVERTER -#AM_CPPFLAGS += -I$(srcdir)/external/flv2mpeg4 -#SOURCE_FILES += external/flv2mpeg4/src/m4vencode.c -#SOURCE_FILES += external/flv2mpeg4/src/flvdecoder.c -#SOURCE_FILES += external/flv2mpeg4/src/dcprediction.c -#SOURCE_FILES += external/flv2mpeg4/src/flv2mpeg4.c +if ENABLE_FLV2MPEG4 +AM_CFLAGS += -DHAVE_FLV2MPEG4_CONVERTER +AM_CPPFLAGS += -I$(srcdir)/external/flv2mpeg4 +SOURCE_FILES += external/flv2mpeg4/src/m4vencode.c +SOURCE_FILES += external/flv2mpeg4/src/flvdecoder.c +SOURCE_FILES += external/flv2mpeg4/src/dcprediction.c +SOURCE_FILES += external/flv2mpeg4/src/flv2mpeg4.c +endif SOURCE_FILES += \ output/linuxdvb_mipsel.c \ From 94ed6dd2911fd6ce505fa57059c43a6b04aa628c Mon Sep 17 00:00:00 2001 From: max_10 Date: Wed, 29 Aug 2018 14:33:31 +0200 Subject: [PATCH 07/59] [libarmbox] fix last commit Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/4dc1decaf49c4f8aed30d2b6ab6277b2f404ef76 Author: max_10 Date: 2018-08-29 (Wed, 29 Aug 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 0775f23..202eaaf 100644 --- a/configure.ac +++ b/configure.ac @@ -66,7 +66,7 @@ AC_ARG_ENABLE(flv2mpeg4, AS_HELP_STRING(--enable-flv2mpeg4, use flv2mpeg4 libeplayer3-arm), ,[enable_flv2mpeg4=no]) -AM_CONDITIONAL(FLV2MPEG4, test "$enable_flv2mpeg4" = "yes") +AM_CONDITIONAL(ENABLE_FLV2MPEG4, test "$enable_flv2mpeg4" = "yes") if test "$enable_flv2mpeg4" = "yes"; then AC_DEFINE(ENABLE_FLV2MPEG4, 1, [use flv2mpeg4 libeplayer3-arm]) fi From 2472bff7d2e9dc1c33a97ca3b790df94fb1a981f Mon Sep 17 00:00:00 2001 From: max_10 Date: Thu, 30 Aug 2018 14:05:36 +0200 Subject: [PATCH 08/59] [libarmbox] libeplayer3-arm code format Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/6886c61e10b8371aad1675881d3e718027940add Author: max_10 Date: 2018-08-30 (Thu, 30 Aug 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3-arm/container/container_ffmpeg.c | 86 ++++++++++++------- libeplayer3-arm/include/container.h | 1 - libeplayer3-arm/include/manager.h | 2 +- libeplayer3-arm/include/playback.h | 2 +- libeplayer3-arm/main/exteplayer.c | 32 ++++--- libeplayer3-arm/manager/audio.c | 14 +-- libeplayer3-arm/manager/subtitle.c | 17 ++-- libeplayer3-arm/manager/video.c | 14 +-- libeplayer3-arm/output/linuxdvb_mipsel.c | 6 +- libeplayer3-arm/output/output.c | 1 + libeplayer3-arm/output/output_subtitle.c | 3 +- libeplayer3-arm/output/writer/common/writer.c | 2 +- libeplayer3-arm/output/writer/mipsel/dts.c | 1 + libeplayer3-arm/output/writer/mipsel/wma.c | 1 + libeplayer3-arm/playback/playback.c | 46 ++++++---- 15 files changed, 138 insertions(+), 90 deletions(-) diff --git a/libeplayer3-arm/container/container_ffmpeg.c b/libeplayer3-arm/container/container_ffmpeg.c index bb12b6e..236d86f 100644 --- a/libeplayer3-arm/container/container_ffmpeg.c +++ b/libeplayer3-arm/container/container_ffmpeg.c @@ -105,6 +105,7 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); #define cERR_CONTAINER_FFMPEG_END_OF_FILE -10 #define IPTV_AV_CONTEXT_MAX_NUM 2 + /* ***************************** */ /* Types */ /* ***************************** */ @@ -548,8 +549,7 @@ static void FFMPEGThread(Context_t *context) threadname[16] = 0; prctl(PR_SET_NAME, (unsigned long)&threadname); AVPacket packet; - //off_t lastSeek = -1; - //int64_t lastPts = -1; + int64_t currentVideoPts = -1; int64_t currentAudioPts = -1; @@ -561,7 +561,6 @@ static void FFMPEGThread(Context_t *context) int64_t showtime = 0; int64_t bofcount = 0; - //int32_t err = 0; AudioVideoOut_t avOut; g_context = context; @@ -583,13 +582,14 @@ static void FFMPEGThread(Context_t *context) memset(&flv2mpeg4_context, 0, sizeof(Flv2Mpeg4Context)); #endif ffmpeg_printf(10, "\n"); + while (context->playback->isCreationPhase) { ffmpeg_printf(10, "Thread waiting for end of init phase...\n"); usleep(1000); } ffmpeg_printf(10, "Running!\n"); - + #ifdef __sh__ uint32_t bufferSize = 0; context->output->Command(context, OUTPUT_GET_BUFFER_SIZE, &bufferSize); @@ -597,6 +597,7 @@ static void FFMPEGThread(Context_t *context) #endif int8_t isWaitingForFinish = 0; + while (context && context->playback && context->playback->isPlaying) { /* When user press PAUSE we call pause on AUDIO and VIDEO decoders, @@ -636,19 +637,24 @@ static void FFMPEGThread(Context_t *context) } continue; } - if (context->playback->BackWard && av_gettime() >= showtime) { + + if (context->playback->BackWard && av_gettime() >= showtime) + { context->output->Command(context, OUTPUT_CLEAR, "video"); - if (bofcount == 1) { - showtime = av_gettime(); - usleep(100000); - continue; + if (bofcount == 1) + { + showtime = av_gettime(); + usleep(100000); + continue; } - if (avContextTab[0]->iformat->flags & AVFMT_TS_DISCONT) { + if (avContextTab[0]->iformat->flags & AVFMT_TS_DISCONT) + { off_t pos = avio_tell(avContextTab[0]->pb); - if (pos > 0) { + if (pos > 0) + { float br; if (avContextTab[0]->bit_rate) br = avContextTab[0]->bit_rate / 8.0; @@ -669,7 +675,7 @@ static void FFMPEGThread(Context_t *context) seek_target_seconds = AV_TIME_BASE; do_seek_target_seconds = 1; } - showtime = av_gettime() + 300000; //jump back every 300ms + showtime = av_gettime() + 300000; //jump back every 300ms } else { @@ -770,15 +776,16 @@ static void FFMPEGThread(Context_t *context) if (!isWaitingForFinish && (ffmpegStatus = av_read_frame(avContextTab[cAVIdx], &packet)) == 0) { - int64_t pts = 0; - int64_t dts = 0; - Track_t *videoTrack = NULL; - Track_t *audioTrack = NULL; + int64_t pts = 0; + int64_t dts = 0; + Track_t *videoTrack = NULL; + Track_t *audioTrack = NULL; Track_t *subtitleTrack = NULL; int32_t pid = avContextTab[cAVIdx]->streams[packet.stream_index]->id; reset_finish_timeout(); + if (avContextTab[cAVIdx]->streams[packet.stream_index]->discard != AVDISCARD_ALL) { if (context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack) < 0) @@ -992,6 +999,7 @@ static void FFMPEGThread(Context_t *context) decoded_frame = NULL; } } + #if (LIBAVFORMAT_VERSION_MAJOR > 57) || ((LIBAVFORMAT_VERSION_MAJOR == 57) && (LIBAVFORMAT_VERSION_MINOR > 32)) while (packet.size > 0 || (!packet.size && !packet.data)) #else @@ -1059,6 +1067,7 @@ static void FFMPEGThread(Context_t *context) continue; } #endif + int32_t e = 0; if (!swr) { @@ -1085,6 +1094,7 @@ static void FFMPEGThread(Context_t *context) { c->channel_layout = av_get_default_channel_layout(c->channels); } + out_channel_layout = c->channel_layout; uint8_t downmix = stereo_software_decoder && out_channels > 2 ? 1 : 0; @@ -1108,7 +1118,6 @@ static void FFMPEGThread(Context_t *context) av_opt_set_int(swr, "in_sample_fmt", c->sample_fmt, 0); av_opt_set_int(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); - e = swr_init(swr); if (e < 0) { @@ -1346,6 +1355,7 @@ static void FFMPEGThread(Context_t *context) seek_target_seconds = 0; do_seek_target_seconds = 0; PlaybackDieNow(1); + ffmpeg_printf(10, "terminating\n"); } @@ -1888,13 +1898,16 @@ int32_t container_ffmpeg_init(Context_t *context, PlayFiles_t *playFilesNames) } ffmpeg_printf(10, "filename %s\n", playFilesNames->szFirstFile); + if (playFilesNames->szSecondFile) { ffmpeg_printf(10, "second filename %s\n", playFilesNames->szSecondFile); } + /* initialize ffmpeg */ avcodec_register_all(); av_register_all(); + avformat_network_init(); // SULGE DEBUG ENABLED @@ -1904,7 +1917,8 @@ int32_t container_ffmpeg_init(Context_t *context, PlayFiles_t *playFilesNames) context->playback->abortRequested = 0; int32_t res = container_ffmpeg_init_av_context(context, playFilesNames->szFirstFile, playFilesNames->iFirstFileSize, \ - playFilesNames->szFirstMoovAtomFile, playFilesNames->iFirstMoovAtomOffset, 0); + playFilesNames->szFirstMoovAtomFile, playFilesNames->iFirstMoovAtomOffset, 0); + if (0 != res) { return res; @@ -1913,7 +1927,7 @@ int32_t container_ffmpeg_init(Context_t *context, PlayFiles_t *playFilesNames) if (playFilesNames->szSecondFile && playFilesNames->szSecondFile[0] != '\0') { res = container_ffmpeg_init_av_context(context, playFilesNames->szSecondFile, playFilesNames->iSecondFileSize, \ - playFilesNames->szSecondMoovAtomFile, playFilesNames->iSecondMoovAtomOffset, 1); + playFilesNames->szSecondMoovAtomFile, playFilesNames->iSecondMoovAtomOffset, 1); } if (0 != res) @@ -1972,6 +1986,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 uint32_t cAVIdx = 0; + for (cAVIdx = 0; cAVIdx < IPTV_AV_CONTEXT_MAX_NUM; cAVIdx += 1) { if (NULL == avContextTab[cAVIdx]) @@ -2082,6 +2097,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 case AVMEDIA_TYPE_VIDEO: ffmpeg_printf(10, "CODEC_TYPE_VIDEO %d\n", get_codecpar(stream)->codec_type); stream->discard = AVDISCARD_ALL; /* by default we discard all video streams */ + if (encoding != NULL) { track.type = eTypeES; @@ -2098,6 +2114,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 */ track.aspect_ratio_num = stream->sample_aspect_ratio.num; track.aspect_ratio_den = stream->sample_aspect_ratio.den; + if (0 == track.aspect_ratio_num || 0 == track.aspect_ratio_den) { track.aspect_ratio_num = get_codecpar(stream)->sample_aspect_ratio.num; @@ -2117,6 +2134,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 } /* fixme: revise this */ + if (track.frame_rate < 23970) { track.TimeScale = 1001; @@ -2181,6 +2199,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 case AVMEDIA_TYPE_AUDIO: ffmpeg_printf(10, "CODEC_TYPE_AUDIO %d\n", get_codecpar(stream)->codec_type); stream->discard = AVDISCARD_ALL; + if (encoding != NULL) { AVDictionaryEntry *lang; @@ -2199,6 +2218,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 track.have_aacheader = -1; track.duration = (int64_t)av_rescale(stream->duration, (int64_t)stream->time_base.num * 1000, stream->time_base.den); + if (stream->duration == AV_NOPTS_VALUE) { ffmpeg_printf(10, "Stream has no duration so we take the duration from context\n"); @@ -2516,7 +2536,9 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 ffmpeg_printf(10, "CODEC_TYPE_SUBTITLE %d\n", get_codecpar(stream)->codec_type); lang = av_dict_get(stream->metadata, "language", NULL, 0); + track.Name = lang ? lang->value : "und"; + ffmpeg_printf(10, "Language %s\n", track.Name); track.Encoding = encoding; @@ -2597,6 +2619,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 } releaseMutex(__FILE__, __FUNCTION__, __LINE__); + return cERR_CONTAINER_FFMPEG_NO_ERROR; } @@ -2625,14 +2648,12 @@ static int32_t container_ffmpeg_play(Context_t *context) if ((error = pthread_create(&PlayThread, &attr, (void *)&FFMPEGThread, context)) != 0) { ffmpeg_printf(10, "Error creating thread, error:%d:%s\n", error, strerror(error)); - hasPlayThreadStarted = 0; ret = cERR_CONTAINER_FFMPEG_ERR; } else { ffmpeg_printf(10, "Created thread\n"); - hasPlayThreadStarted = 1; } } @@ -2643,6 +2664,7 @@ static int32_t container_ffmpeg_play(Context_t *context) } ffmpeg_printf(10, "exiting with value %d\n", ret); + return ret; } @@ -2672,6 +2694,7 @@ static int32_t container_ffmpeg_stop(Context_t *context) { /* force close */ ffmpeg_err("Timeout waiting for thread!\n"); + ret = cERR_CONTAINER_FFMPEG_ERR; /* to speed up close - we are in separate process for the moment this process will * be closed and whole resources will be free by the system @@ -2923,15 +2946,16 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab } ffmpeg_printf(10, "iformat->flags 0x%08x\n", avContextTab[0]->iformat->flags); + #if defined(TS_BYTES_SEEKING) && TS_BYTES_SEEKING if (avContextTab[0]->iformat->flags & AVFMT_TS_DISCONT) { /* konfetti: for ts streams seeking frame per seconds does not work (why?). - * I take this algo partly from ffplay.c. - * - * seeking per HTTP does still not work very good. forward seeks everytime - * about 10 seconds, backward does not work. - */ + * I take this algo partly from ffplay.c. + * + * seeking per HTTP does still not work very good. forward seeks everytime + * about 10 seconds, backward does not work. + */ getMutex(__FILE__, __FUNCTION__, __LINE__); off_t pos = avio_tell(avContextTab[0]->pb); @@ -3029,6 +3053,7 @@ static int32_t container_ffmpeg_switch_audio(Context_t *context, int32_t *arg __ { ffmpeg_printf(10, "track %d\n", *arg); getMutex(__FILE__, __FUNCTION__, __LINE__); + if (context->manager->audio) { Track_t *Tracks = NULL; @@ -3129,7 +3154,7 @@ static int32_t container_ffmpeg_get_info(Context_t *context, char **infoString) return cERR_CONTAINER_FFMPEG_NO_ERROR; } -static int container_ffmpeg_get_metadata(Context_t * context, char ***p) +static int container_ffmpeg_get_metadata(Context_t *context, char ***p) { Track_t *videoTrack = NULL; Track_t *audioTrack = NULL; @@ -3251,12 +3276,12 @@ static int32_t Command(Context_t *context, ContainerCmd_t command, void *argumen } case CONTAINER_SWITCH_AUDIO: { - ret = container_ffmpeg_switch_audio(context, (int32_t *) argument); + ret = container_ffmpeg_switch_audio(context, (int32_t *)argument); break; } case CONTAINER_SWITCH_SUBTITLE: { - ret = container_ffmpeg_switch_subtitle(context, (int32_t *) argument); + ret = container_ffmpeg_switch_subtitle(context, (int32_t *)argument); break; } case CONTAINER_INFO: @@ -3288,7 +3313,7 @@ static int32_t Command(Context_t *context, ContainerCmd_t command, void *argumen } case CONTAINER_GET_METADATA: { - ret = container_ffmpeg_get_metadata(context, (char ***) argument); + ret = container_ffmpeg_get_metadata(context, (char ***)argument); break; } default: @@ -3298,6 +3323,7 @@ static int32_t Command(Context_t *context, ContainerCmd_t command, void *argumen } ffmpeg_printf(50, "exiting with value %d\n", ret); + return ret; } diff --git a/libeplayer3-arm/include/container.h b/libeplayer3-arm/include/container.h index a8a87e0..dc1a585 100644 --- a/libeplayer3-arm/include/container.h +++ b/libeplayer3-arm/include/container.h @@ -45,7 +45,6 @@ typedef struct ContainerHandler_s { char *Name; Container_t *selectedContainer; - int (* Command)(Context_t *, ContainerCmd_t, void *); } ContainerHandler_t; diff --git a/libeplayer3-arm/include/manager.h b/libeplayer3-arm/include/manager.h index baed788..1363271 100644 --- a/libeplayer3-arm/include/manager.h +++ b/libeplayer3-arm/include/manager.h @@ -44,7 +44,7 @@ typedef struct Track_s /* new field for ffmpeg - add at the end so no problem * can occur with not changed srt saa container */ - char *language; + char *language; /* length of track */ int64_t duration; diff --git a/libeplayer3-arm/include/playback.h b/libeplayer3-arm/include/playback.h index 68a7fc8..b6d9b63 100644 --- a/libeplayer3-arm/include/playback.h +++ b/libeplayer3-arm/include/playback.h @@ -4,7 +4,7 @@ #include #include -typedef void( * PlaybackDieNowCallback )(); +typedef void(* PlaybackDieNowCallback)(); bool PlaybackDieNowRegisterCallback(PlaybackDieNowCallback callback); typedef enum { diff --git a/libeplayer3-arm/main/exteplayer.c b/libeplayer3-arm/main/exteplayer.c index 6bea361..cba7d2a 100644 --- a/libeplayer3-arm/main/exteplayer.c +++ b/libeplayer3-arm/main/exteplayer.c @@ -252,11 +252,12 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac ptrManager->Command(g_player, MANAGER_LIST, &TrackList); if (NULL != TrackList) { - int i = 0, Id = -1; + int i = 0; + int Id = -1; char * pch; char Name[] = " "; fprintf(stderr, "{\"%c_%c\": [", argvBuff[0], argvBuff[1]); - for (i = 0; TrackList[i] != NULL; i+=2) + for (i = 0; TrackList[i] != NULL; i += 2) { pch = strtok(TrackList[i], " "); if (pch != NULL) { @@ -272,7 +273,7 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac } fprintf(stderr, "{\"id\":%d,\"e\":\"%s\",\"n\":\"%s\"}", Id, TrackList[i+1], Name); free(TrackList[i]); - free(TrackList[i+1]); + free(TrackList[i + 1]); } fprintf(stderr, "]}\n"); free(TrackList); @@ -297,7 +298,7 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac else // video { fprintf(stderr, "{\"%c_%c\":{\"id\":%d,\"e\":\"%s\",\"n\":\"%s\",\"w\":%d,\"h\":%d,\"f\":%u,\"p\":%d,\"an\":%d,\"ad\":%d}}\n", \ - argvBuff[0], argvBuff[1], track->Id, track->Encoding, track->Name, track->width, track->height, track->frame_rate, track->progressive, track->aspect_ratio_num, track->aspect_ratio_den); + argvBuff[0], argvBuff[1], track->Id, track->Encoding, track->Name, track->width, track->height, track->frame_rate, track->progressive, track->aspect_ratio_num, track->aspect_ratio_den); } free(track->Encoding); free(track->Name); @@ -336,7 +337,7 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac { int i = 0; char * pch; - for (i = 0; TrackList[i] != NULL; i+=2) + for (i = 0; TrackList[i] != NULL; i += 2) { if (idx == i) { @@ -345,7 +346,7 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac id = atoi(pch); } free(TrackList[i]); - free(TrackList[i+1]); + free(TrackList[i + 1]); } free(TrackList); } @@ -501,7 +502,7 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac static void UpdateVideoTrack() { - HandleTracks(g_player->manager->video, (PlaybackCmd_t) - 1, "vc"); + HandleTracks(g_player->manager->video, (PlaybackCmd_t) -1, "vc"); } static int ParseParams(int argc, char *argv[], PlayFiles_t *playbackFiles, int *pAudioTrackIdx, int *subtitleTrackIdx, uint32_t *linuxDvbBufferSizeMB) @@ -657,6 +658,7 @@ static int ParseParams(int argc, char *argv[], PlayFiles_t *playbackFiles, int * ret = 0; playbackFiles->szFirstFile = malloc(IPTV_MAX_FILE_PATH); playbackFiles->szFirstFile[0] = '\0'; + if (NULL == strstr(argv[optind], "://")) { strcpy(playbackFiles->szFirstFile, "file://"); @@ -693,6 +695,7 @@ int main(int argc, char *argv[]) PlayFiles_t playbackFiles; memset(&playbackFiles, 0x00, sizeof(playbackFiles)); + if (0 != ParseParams(argc, argv, &playbackFiles, &audioTrackIdx, &subtitleTrackIdx, &linuxDvbBufferSizeMB)) { printf("Usage: exteplayer3 filePath [-u user-agent] [-c cookies] [-h headers] [-p prio] [-a] [-d] [-w] [-l] [-s] [-i] [-t audioTrackId] [-9 subtitleTrackId] [-x separateAudioUri] plabackUri\n"); @@ -816,24 +819,24 @@ int main(int argc, char *argv[]) { PlaybackDieNowRegisterCallback(TerminateWakeUp); - HandleTracks(g_player->manager->video, (PlaybackCmd_t) - 1, "vc"); - HandleTracks(g_player->manager->audio, (PlaybackCmd_t) - 1, "al"); + HandleTracks(g_player->manager->video, (PlaybackCmd_t) -1, "vc"); + HandleTracks(g_player->manager->audio, (PlaybackCmd_t) -1, "al"); if (audioTrackIdx >= 0) { static char cmd[128] = ""; // static to not allocate on stack sprintf(cmd, "ai%d\n", audioTrackIdx); commandRetVal = HandleTracks(g_player->manager->audio, PLAYBACK_SWITCH_AUDIO, cmd); } - HandleTracks(g_player->manager->audio, (PlaybackCmd_t) - 1, "ac"); + HandleTracks(g_player->manager->audio, (PlaybackCmd_t) -1, "ac"); - HandleTracks(g_player->manager->subtitle, (PlaybackCmd_t) - 1, "sl"); + HandleTracks(g_player->manager->subtitle, (PlaybackCmd_t) -1, "sl"); if (subtitleTrackIdx >= 0) { static char cmd[128] = ""; // static to not allocate on stack sprintf(cmd, "si%d\n", subtitleTrackIdx); commandRetVal = HandleTracks(g_player->manager->subtitle, PLAYBACK_SWITCH_SUBTITLE, cmd); } - HandleTracks(g_player->manager->subtitle, (PlaybackCmd_t) - 1, "sc"); + HandleTracks(g_player->manager->subtitle, (PlaybackCmd_t) -1, "sc"); } while (g_player->playback->isPlaying && 0 == PlaybackDieNow(0)) @@ -855,7 +858,7 @@ int main(int argc, char *argv[]) { case 'v': { - HandleTracks(g_player->manager->video, (PlaybackCmd_t) - 1, argvBuff); + HandleTracks(g_player->manager->video, (PlaybackCmd_t) -1, argvBuff); break; } case 'a': @@ -966,10 +969,12 @@ int main(int argc, char *argv[]) commandRetVal = g_player->playback->Command(g_player, PLAYBACK_PTS, &pts); CurrentSec = (int32_t)(pts / 90000); + if (0 == commandRetVal) { fprintf(stderr, "{\"J\":{\"ms\":%lld}}\n", pts / 90); } + if (0 == commandRetVal || force) { commandRetVal = g_player->playback->Command(g_player, PLAYBACK_LENGTH, (void *)&length); @@ -1016,6 +1021,7 @@ int main(int argc, char *argv[]) { int64_t lastPts = 0; commandRetVal = 1; + if (g_player->container && g_player->container->selectedContainer) { commandRetVal = g_player->container->selectedContainer->Command((Context_t*)g_player->container, CONTAINER_LAST_PTS, &lastPts); diff --git a/libeplayer3-arm/manager/audio.c b/libeplayer3-arm/manager/audio.c index 6543f51..d4eef50 100644 --- a/libeplayer3-arm/manager/audio.c +++ b/libeplayer3-arm/manager/audio.c @@ -128,6 +128,7 @@ static int ManagerAdd(Context_t *context, Track_t track) } audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); + return cERR_AUDIO_MGR_NO_ERROR; } @@ -137,6 +138,7 @@ static char **ManagerList(Context_t *context __attribute__((unused))) char **tracklist = NULL; audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); + if (Tracks != NULL) { tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1)); @@ -160,9 +162,9 @@ static char **ManagerList(Context_t *context __attribute__((unused))) tracklist[j] = strdup(tmp); tracklist[j + 1] = strdup(Tracks[i].Encoding); } - tracklist[j] = NULL; } + audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount); return tracklist; @@ -256,7 +258,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) { container_ffmpeg_update_tracks(context, context->playback->uri, 0); // *((TrackDescription_t **)argument) = ManagerList(context); - *((char ** *) argument) = (char **) ManagerList(context); + *((char ***)argument) = (char **)ManagerList(context); break; } case MANAGER_REF_LIST: @@ -279,7 +281,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) } else { - *((int *)argument) = (int) - 1; + *((int *)argument) = (int) -1; } break; } @@ -292,9 +294,9 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) if (track) { memset(track, 0, sizeof(TrackDescription_t)); - track->Id = Tracks[CurrentTrack].Id; - track->Name = strdup(Tracks[CurrentTrack].Name); - track->Encoding = strdup(Tracks[CurrentTrack].Encoding); + track->Id = Tracks[CurrentTrack].Id; + track->Name = strdup(Tracks[CurrentTrack].Name); + track->Encoding = strdup(Tracks[CurrentTrack].Encoding); } } else diff --git a/libeplayer3-arm/manager/subtitle.c b/libeplayer3-arm/manager/subtitle.c index 144cb5c..db1761a 100644 --- a/libeplayer3-arm/manager/subtitle.c +++ b/libeplayer3-arm/manager/subtitle.c @@ -134,8 +134,8 @@ static int ManagerAdd(Context_t *context __attribute__((unused)), Track_t track) static char **ManagerList(Context_t *context __attribute__((unused))) { - char **tracklist = NULL; int i = 0, j = 0; + char **tracklist = NULL; subtitle_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); @@ -162,7 +162,6 @@ static char **ManagerList(Context_t *context __attribute__((unused))) tracklist[j] = strdup(tmp); tracklist[j + 1] = strdup(Tracks[i].Encoding); } - tracklist[j] = NULL; } @@ -219,7 +218,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) case MANAGER_LIST: { container_ffmpeg_update_tracks(context, context->playback->uri, 0); - *((char ** *)argument) = (char **)ManagerList(context); + *((char ***)argument) = (char **)ManagerList(context); break; } case MANAGER_GET: @@ -230,7 +229,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) } else { - *((int *)argument) = (int) - 1; + *((int *)argument) = (int) -1; } break; } @@ -243,9 +242,9 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) if (track) { memset(track, 0, sizeof(TrackDescription_t)); - track->Id = Tracks[CurrentTrack].Id; - track->Name = strdup(Tracks[CurrentTrack].Name); - track->Encoding = strdup(Tracks[CurrentTrack].Encoding); + track->Id = Tracks[CurrentTrack].Id; + track->Name = strdup(Tracks[CurrentTrack].Name); + track->Encoding = strdup(Tracks[CurrentTrack].Encoding); } } else @@ -332,12 +331,12 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) break; } default: - subtitle_mgr_err("%s:%s: ContainerCmd not supported!", __FILE__, __FUNCTION__); + subtitle_mgr_err("%s::%s ContainerCmd not supported!", __FILE__, __FUNCTION__); ret = cERR_SUBTITLE_MGR_ERROR; break; } - subtitle_mgr_printf(50, "%s:%s: returning %d\n", __FILE__, __FUNCTION__, ret); + subtitle_mgr_printf(50, "%s::%s returning %d\n", __FILE__, __FUNCTION__, ret); return ret; } diff --git a/libeplayer3-arm/manager/video.c b/libeplayer3-arm/manager/video.c index 8a94d4a..93b7073 100644 --- a/libeplayer3-arm/manager/video.c +++ b/libeplayer3-arm/manager/video.c @@ -97,7 +97,7 @@ static int ManagerAdd(Context_t *context, Track_t track) if (Tracks == NULL) { - video_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__); + video_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__); return cERR_VIDEO_MGR_ERROR; } @@ -118,7 +118,7 @@ static int ManagerAdd(Context_t *context, Track_t track) } else { - video_mgr_err("%s:%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP); + video_mgr_err("%s::%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP); return cERR_VIDEO_MGR_ERROR; } @@ -128,6 +128,7 @@ static int ManagerAdd(Context_t *context, Track_t track) } video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); + return cERR_VIDEO_MGR_NO_ERROR; } @@ -144,7 +145,7 @@ static char **ManagerList(Context_t *context __attribute__((unused))) if (tracklist == NULL) { - video_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__); + video_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__); return NULL; } @@ -164,6 +165,7 @@ static char **ManagerList(Context_t *context __attribute__((unused))) } video_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount); + return tracklist; } @@ -213,7 +215,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) case MANAGER_LIST: { container_ffmpeg_update_tracks(context, context->playback->uri, 0); - *((char ** *)argument) = (char **)ManagerList(context); + *((char ***)argument) = (char **)ManagerList(context); break; } case MANAGER_GET: @@ -224,7 +226,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) } else { - *((int *)argument) = (int) - 1; + *((int *)argument) = (int) -1; } break; } @@ -342,7 +344,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) break; } - video_mgr_printf(10, "%s:%s: returning %d\n", __FILE__, __FUNCTION__, ret); + video_mgr_printf(10, "%s::%s returning %d\n", __FILE__, __FUNCTION__, ret); return ret; } diff --git a/libeplayer3-arm/output/linuxdvb_mipsel.c b/libeplayer3-arm/output/linuxdvb_mipsel.c index 58afc9b..455fc8e 100644 --- a/libeplayer3-arm/output/linuxdvb_mipsel.c +++ b/libeplayer3-arm/output/linuxdvb_mipsel.c @@ -252,6 +252,7 @@ int LinuxDvbPlay(Context_t *context, char *type) linuxdvb_printf(10, "V %s\n", Encoding); writer = getWriter(Encoding); + if (writer == NULL) { linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding); @@ -324,7 +325,6 @@ int LinuxDvbPlay(Context_t *context, char *type) ret = cERR_LINUXDVB_NO_ERROR; return ret; - //return 0; } int LinuxDvbStop(Context_t *context __attribute__((unused)), char *type) @@ -354,6 +354,7 @@ int LinuxDvbStop(Context_t *context __attribute__((unused)), char *type) ioctl(videofd, VIDEO_FAST_FORWARD, 0); ioctl(videofd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX); } + if (audio && audiofd != -1) { if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1) @@ -634,6 +635,7 @@ int LinuxDvbPts(Context_t *context __attribute__((unused)), unsigned long long i } *((unsigned long long int *)pts) = (unsigned long long int)sCURRENT_PTS; + return ret; } @@ -1095,7 +1097,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) case OUTPUT_GET_BUFFER_SIZE: { ret = cERR_LINUXDVB_NO_ERROR; - *((uint32_t*)argument) = LinuxDvbBuffGetSize(); + *((uint32_t *)argument) = LinuxDvbBuffGetSize(); break; } default: diff --git a/libeplayer3-arm/output/output.c b/libeplayer3-arm/output/output.c index 60760e8..0544137 100644 --- a/libeplayer3-arm/output/output.c +++ b/libeplayer3-arm/output/output.c @@ -90,6 +90,7 @@ static void printOutputCapabilities() for (i = 0; AvailableOutput[i] != NULL; i++) { output_printf(10, "\t%s : ", AvailableOutput[i]->Name); + for (j = 0; AvailableOutput[i]->Capabilities[j] != NULL; j++) { output_printf(10, "%s ", AvailableOutput[i]->Capabilities[j]); diff --git a/libeplayer3-arm/output/output_subtitle.c b/libeplayer3-arm/output/output_subtitle.c index 16fc2bb..5810440 100644 --- a/libeplayer3-arm/output/output_subtitle.c +++ b/libeplayer3-arm/output/output_subtitle.c @@ -266,8 +266,6 @@ static int32_t subtitle_Open(Context_t *context __attribute__((unused))) static int32_t subtitle_Close(Context_t *context __attribute__((unused))) { - //uint32_t i = 0 ; - subtitle_printf(10, "\n"); getMutex(__LINE__); @@ -341,6 +339,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument __att } subtitle_printf(50, "exiting with value %d\n", ret); + return ret; } diff --git a/libeplayer3-arm/output/writer/common/writer.c b/libeplayer3-arm/output/writer/common/writer.c index b866e2a..0ad4b3e 100644 --- a/libeplayer3-arm/output/writer/common/writer.c +++ b/libeplayer3-arm/output/writer/common/writer.c @@ -70,5 +70,5 @@ if (debug_level >= level) printf(x); } while (0) void FlushPipe(int pipefd) { char tmp; - while(1 == read(pipefd, &tmp, 1)); + while (1 == read(pipefd, &tmp, 1)); } diff --git a/libeplayer3-arm/output/writer/mipsel/dts.c b/libeplayer3-arm/output/writer/mipsel/dts.c index 34548ba..7e1ea7a 100644 --- a/libeplayer3-arm/output/writer/mipsel/dts.c +++ b/libeplayer3-arm/output/writer/mipsel/dts.c @@ -52,6 +52,7 @@ /* ***************************** */ /* Makros/Constants */ /* ***************************** */ + #define PES_AUDIO_PRIVATE_HEADER_SIZE 16 // consider maximum private header size. #define PES_AUDIO_HEADER_SIZE (32 + PES_AUDIO_PRIVATE_HEADER_SIZE) #define PES_AUDIO_PACKET_SIZE 2028 diff --git a/libeplayer3-arm/output/writer/mipsel/wma.c b/libeplayer3-arm/output/writer/mipsel/wma.c index 15d6b2d..e953ed8 100644 --- a/libeplayer3-arm/output/writer/mipsel/wma.c +++ b/libeplayer3-arm/output/writer/mipsel/wma.c @@ -169,6 +169,7 @@ static int writeData(WriterAVCallData_t *call) iov[0].iov_len = headerSize; iov[1].iov_base = call->data; iov[1].iov_len = call->len; + return call->WriteV(call->fd, iov, 2); } diff --git a/libeplayer3-arm/playback/playback.c b/libeplayer3-arm/playback/playback.c index 098cc4d..e2bfd7e 100644 --- a/libeplayer3-arm/playback/playback.c +++ b/libeplayer3-arm/playback/playback.c @@ -54,7 +54,7 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); #define cERR_PLAYBACK_NO_ERROR 0 #define cERR_PLAYBACK_ERROR -1 -#define cMaxSpeed_ff 128 /* fixme: revise */ +#define cMaxSpeed_ff 128 /* fixme: revise */ #define cMaxSpeed_fr -320 /* fixme: revise */ #define MAX_PLAYBACK_DIE_NOW_CALLBACKS 10 @@ -140,6 +140,7 @@ static void SupervisorThread(Context_t *context) { usleep(100000); } + playback_printf(10, "<\n"); hasThreadStarted = 2; PlaybackTerminate(context); @@ -293,6 +294,7 @@ static int PlaybackPlay(Context_t *context) { playback_err("OUTPUT_PLAY failed!\n"); playback_err("clearing isCreationPhase!\n"); + context->playback->isCreationPhase = 0; // allow thread to go into next state context->playback->isPlaying = 0; context->playback->isPaused = 0; @@ -300,6 +302,7 @@ static int PlaybackPlay(Context_t *context) context->playback->BackWard = 0; context->playback->SlowMotion = 0; context->playback->Speed = 0; + if (context->container && context->container->selectedContainer) context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL); } @@ -317,7 +320,8 @@ static int PlaybackPlay(Context_t *context) int error; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - if ((error = pthread_create(&supervisorThread, &attr, (void *) &SupervisorThread, context)) != 0) + + if ((error = pthread_create(&supervisorThread, &attr, (void *)&SupervisorThread, context)) != 0) { playback_printf(10, "Error creating thread, error:%d:%s\n", error, strerror(error)); ret = cERR_PLAYBACK_ERROR; @@ -331,13 +335,14 @@ static int PlaybackPlay(Context_t *context) playback_printf(10, "clearing isCreationPhase!\n"); context->playback->isCreationPhase = 0; // allow thread to go into next state + if (context->container && context->container->selectedContainer) ret = context->container->selectedContainer->Command(context, CONTAINER_PLAY, NULL); + if (ret != 0) { playback_err("CONTAINER_PLAY failed!\n"); } - } } else @@ -362,10 +367,9 @@ static int PlaybackPause(Context_t *context) if (context->playback->SlowMotion) context->output->Command(context, OUTPUT_CLEAR, NULL); - context->playback->isPaused = 1; - context->output->Command(context, OUTPUT_PAUSE, NULL); + context->playback->isPaused = 1; //context->playback->isPlaying = 1; context->playback->isForwarding = 0; context->playback->BackWard = 0; @@ -395,6 +399,8 @@ static int32_t PlaybackContinue(Context_t *context) if (context->playback->SlowMotion || context->playback->isForwarding || context->playback->BackWard) context->output->Command(context, OUTPUT_CLEAR, NULL); + context->output->Command(context, OUTPUT_CONTINUE, NULL); + if (context->playback->BackWard) context->output->Command(context, OUTPUT_AUDIOMUTE, "0"); @@ -404,7 +410,6 @@ static int32_t PlaybackContinue(Context_t *context) context->playback->BackWard = 0; context->playback->SlowMotion = 0; context->playback->Speed = 1; - context->output->Command(context, OUTPUT_CONTINUE, NULL); } else { @@ -413,6 +418,7 @@ static int32_t PlaybackContinue(Context_t *context) } playback_printf(10, "exiting with value %d\n", ret); + return ret; } @@ -427,7 +433,6 @@ static int32_t PlaybackStop(Context_t *context) if (context && context->playback && context->playback->isPlaying) { - context->playback->isPaused = 0; context->playback->isPlaying = 0; context->playback->isForwarding = 0; @@ -437,7 +442,6 @@ static int32_t PlaybackStop(Context_t *context) context->output->Command(context, OUTPUT_STOP, NULL); context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL); - } else { @@ -458,13 +462,13 @@ static int32_t PlaybackStop(Context_t *context) } playback_printf(10, "exiting with value %d\n", ret); + return ret; } static int32_t PlaybackTerminate(Context_t *context) { int32_t ret = cERR_PLAYBACK_NO_ERROR; - int wait_time = 20; playback_printf(20, "\n"); @@ -474,12 +478,13 @@ static int32_t PlaybackTerminate(Context_t *context) if (context && context->playback && context->playback->isPlaying) { //First Flush and than delete container, else e2 cant read length of file anymore - if (context->output->Command(context, OUTPUT_FLUSH, NULL) < 0) { playback_err("failed to flush output.\n"); } + ret = context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL); + context->playback->isPaused = 0; context->playback->isPlaying = 0; context->playback->isForwarding = 0; @@ -487,7 +492,6 @@ static int32_t PlaybackTerminate(Context_t *context) context->playback->SlowMotion = 0; context->playback->Speed = 0; context->output->Command(context, OUTPUT_STOP, NULL); - ret = context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL); } else { @@ -512,6 +516,7 @@ static int32_t PlaybackTerminate(Context_t *context) } playback_printf(20, "exiting with value %d\n", ret); + return ret; } @@ -529,6 +534,7 @@ static int PlaybackFastForward(Context_t *context, int *speed) playback_err("speed %d out of range (1 - %d) \n", *speed, cMaxSpeed_ff); return cERR_PLAYBACK_ERROR; } + context->playback->isForwarding = 1; context->playback->Speed = *speed; playback_printf(20, "Speed: %d x {%d}\n", *speed, context->playback->Speed); @@ -561,6 +567,7 @@ static int PlaybackFastBackward(Context_t *context, int *speed) playback_err("speed %d out of range (0 - %d) \n", *speed, cMaxSpeed_fr); return cERR_PLAYBACK_ERROR; } + if (*speed == 0) { context->playback->BackWard = 0; @@ -601,6 +608,7 @@ static int32_t PlaybackSlowMotion(Context_t *context, int *speed) { if (context->playback->isPaused) PlaybackContinue(context); + switch (*speed) { case 2: @@ -613,7 +621,9 @@ static int32_t PlaybackSlowMotion(Context_t *context, int *speed) context->playback->SlowMotion = 8; break; } + playback_printf(20, "SlowMotion: %d x {%d}\n", *speed, context->playback->SlowMotion); + context->output->Command(context, OUTPUT_SLOWMOTION, NULL); } else @@ -726,6 +736,7 @@ static int32_t PlaybackLength(Context_t *context, int64_t *length) } playback_printf(20, "exiting with value %d\n", ret); + return ret; } @@ -753,7 +764,6 @@ static int32_t PlaybackSwitchAudio(Context_t *context, int32_t *track) if (nextrackid != curtrackid) { - //PlaybackPause(context); if (context->output && context->output->audio) { @@ -774,6 +784,7 @@ static int32_t PlaybackSwitchAudio(Context_t *context, int32_t *track) } playback_printf(10, "exiting with value %d\n", ret); + return ret; } @@ -860,7 +871,6 @@ static int32_t Command(Context_t *context, PlaybackCmd_t command, void *argument playback_printf(20, "Command %d\n", command); - switch (command) { case PLAYBACK_OPEN: @@ -898,6 +908,11 @@ static int32_t Command(Context_t *context, PlaybackCmd_t command, void *argument ret = PlaybackTerminate(context); break; } + case PLAYBACK_FASTFORWARD: + { + ret = PlaybackFastForward(context, (int *)argument); + break; + } case PLAYBACK_SEEK: { ret = PlaybackSeek(context, (int64_t *)argument, 0); @@ -943,11 +958,6 @@ static int32_t Command(Context_t *context, PlaybackCmd_t command, void *argument ret = PlaybackFastBackward(context, (int *)argument); break; } - case PLAYBACK_FASTFORWARD: - { - ret = PlaybackFastForward(context, (int *)argument); - break; - } case PLAYBACK_GET_FRAME_COUNT: { ret = PlaybackGetFrameCount(context, (uint64_t *)argument); From dfc5ec2d2750c472f4ab5774848e502ed1025d70 Mon Sep 17 00:00:00 2001 From: max_10 Date: Thu, 30 Aug 2018 21:19:18 +0200 Subject: [PATCH 09/59] [libarmbox] libeplayer3-arm code format Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/83f8661c7b05bcf080fe31b20c95d5fe75a3f645 Author: max_10 Date: 2018-08-30 (Thu, 30 Aug 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3-arm/container/container_ffmpeg.c | 4 ++-- libeplayer3-arm/manager/audio.c | 12 ++++++------ libeplayer3-arm/manager/subtitle.c | 9 +++++++-- libeplayer3-arm/output/output.c | 20 ++++++++++++++++++++ 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/libeplayer3-arm/container/container_ffmpeg.c b/libeplayer3-arm/container/container_ffmpeg.c index 236d86f..59fa887 100644 --- a/libeplayer3-arm/container/container_ffmpeg.c +++ b/libeplayer3-arm/container/container_ffmpeg.c @@ -80,13 +80,13 @@ static short debug_level = 1; #define ffmpeg_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) +if (debug_level >= level) printf("[%s::%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) #else #define ffmpeg_printf(level, fmt, x...) #endif #ifndef FFMPEG_SILENT -#define ffmpeg_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) +#define ffmpeg_err(fmt, x...) do { printf("[%s::%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) #else #define ffmpeg_err(fmt, x...) #endif diff --git a/libeplayer3-arm/manager/audio.c b/libeplayer3-arm/manager/audio.c index d4eef50..9e029e8 100644 --- a/libeplayer3-arm/manager/audio.c +++ b/libeplayer3-arm/manager/audio.c @@ -46,7 +46,7 @@ static short debug_level = 40; #define audio_mgr_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] \n" fmt, __FILE__, __FUNCTION__, ## x); } while (0) +if (debug_level >= level) printf("[%s::%s] \n" fmt, __FILE__, __FUNCTION__, ## x); } while (0) #else #define audio_mgr_printf(level, x...) #endif @@ -97,7 +97,7 @@ static int ManagerAdd(Context_t *context, Track_t track) if (Tracks == NULL) { - audio_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__); + audio_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__); return cERR_AUDIO_MGR_ERROR; } @@ -118,7 +118,7 @@ static int ManagerAdd(Context_t *context, Track_t track) } else { - audio_mgr_err("%s:%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP); + audio_mgr_err("%s::%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP); return cERR_AUDIO_MGR_ERROR; } @@ -145,7 +145,7 @@ static char **ManagerList(Context_t *context __attribute__((unused))) if (tracklist == NULL) { - audio_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__); + audio_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__); return NULL; } @@ -183,7 +183,7 @@ static TrackDescription_t *ManagerList(Context_t *context __attribute__((unused if (tracklist == NULL) { - audio_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__); + audio_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__); return NULL; } @@ -384,7 +384,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) break; } - audio_mgr_printf(10, "%s:%s: returning %d\n", __FILE__, __FUNCTION__, ret); + audio_mgr_printf(10, "%s::%s returning %d\n", __FILE__, __FUNCTION__, ret); return ret; } diff --git a/libeplayer3-arm/manager/subtitle.c b/libeplayer3-arm/manager/subtitle.c index db1761a..5386bde 100644 --- a/libeplayer3-arm/manager/subtitle.c +++ b/libeplayer3-arm/manager/subtitle.c @@ -118,7 +118,7 @@ static int ManagerAdd(Context_t *context __attribute__((unused)), Track_t track) } else { - subtitle_mgr_err("%s:%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP); + subtitle_mgr_err("%s::%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP); return cERR_SUBTITLE_MGR_ERROR; } @@ -145,7 +145,7 @@ static char **ManagerList(Context_t *context __attribute__((unused))) if (tracklist == NULL) { - subtitle_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__); + subtitle_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__); return NULL; } @@ -223,6 +223,8 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) } case MANAGER_GET: { + subtitle_mgr_printf(20, "%s::%s MANAGER_GET\n", FILENAME, __FUNCTION__); + if (TrackCount > 0 && CurrentTrack >= 0) { *((int *)argument) = (int)Tracks[CurrentTrack].Id; @@ -255,6 +257,8 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) } case MANAGER_GET_TRACK: { + subtitle_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, __FUNCTION__); + if ((TrackCount > 0) && (CurrentTrack >= 0)) { *((Track_t **)argument) = (Track_t *) &Tracks[CurrentTrack]; @@ -292,6 +296,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) case MANAGER_SET: { int i; + subtitle_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", __FILE__, __FUNCTION__, *((int *)argument)); if (*((int *)argument) < 0) diff --git a/libeplayer3-arm/output/output.c b/libeplayer3-arm/output/output.c index 0544137..c1b3ce4 100644 --- a/libeplayer3-arm/output/output.c +++ b/libeplayer3-arm/output/output.c @@ -192,10 +192,12 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { ret |= context->output->video->Command(context, OUTPUT_CLOSE, "video"); } + if (context->playback->isAudio) { ret |= context->output->audio->Command(context, OUTPUT_CLOSE, "audio"); } + if (context->playback->isSubtitle) { ret |= context->output->subtitle->Command(context, OUTPUT_CLOSE, "subtitle"); @@ -239,6 +241,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { ret = context->output->audio->Command(context, OUTPUT_PLAY, "audio"); } + if (!ret) { if (context->playback->isSubtitle) @@ -261,10 +264,12 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { ret |= context->output->video->Command(context, OUTPUT_STOP, "video"); } + if (context->playback->isAudio) { ret |= context->output->audio->Command(context, OUTPUT_STOP, "audio"); } + if (context->playback->isSubtitle) { ret |= context->output->subtitle->Command(context, OUTPUT_STOP, "subtitle"); @@ -284,10 +289,12 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { ret |= context->output->video->Command(context, OUTPUT_FLUSH, "video"); } + if (context->playback->isAudio) { ret |= context->output->audio->Command(context, OUTPUT_FLUSH, "audio"); } + if (context->playback->isSubtitle) { ret |= context->output->subtitle->Command(context, OUTPUT_FLUSH, "subtitle"); @@ -307,10 +314,12 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { ret |= context->output->video->Command(context, OUTPUT_PAUSE, "video"); } + if (context->playback->isAudio) { ret |= context->output->audio->Command(context, OUTPUT_PAUSE, "audio"); } + if (context->playback->isSubtitle) { ret |= context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle"); @@ -330,6 +339,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { ret |= context->output->video->Command(context, OUTPUT_FASTFORWARD, "video"); } + if (context->playback->isAudio) { ret |= context->output->audio->Command(context, OUTPUT_FASTFORWARD, "audio"); @@ -349,6 +359,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { ret |= context->output->video->Command(context, OUTPUT_REVERSE, "video"); } + if (context->playback->isAudio) { ret |= context->output->audio->Command(context, OUTPUT_REVERSE, "audio"); @@ -368,10 +379,12 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { ret |= context->output->video->Command(context, OUTPUT_CONTINUE, "video"); } + if (context->playback->isAudio) { ret |= context->output->audio->Command(context, OUTPUT_CONTINUE, "audio"); } + if (context->playback->isSubtitle) { ret |= context->output->subtitle->Command(context, OUTPUT_CONTINUE, "subtitle"); @@ -406,10 +419,12 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { ret |= context->output->video->Command(context, OUTPUT_CLEAR, "video"); } + if (context->playback->isAudio && (argument == NULL || *(char *) argument == 'a')) { ret |= context->output->audio->Command(context, OUTPUT_CLEAR, "audio"); } + if (context->playback->isSubtitle && (argument == NULL || *(char *) argument == 's')) { ret |= context->output->subtitle->Command(context, OUTPUT_CLEAR, "subtitle"); @@ -429,6 +444,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { return context->output->video->Command(context, OUTPUT_PTS, argument); } + if (context->playback->isAudio) { return context->output->audio->Command(context, OUTPUT_PTS, argument); @@ -448,10 +464,12 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { return context->output->audio->Command(context, OUTPUT_SWITCH, "audio"); } + if (context->playback->isVideo) { return context->output->video->Command(context, OUTPUT_SWITCH, "video"); } + if (context->playback->isSubtitle) { return context->output->subtitle->Command(context, OUTPUT_SWITCH, "subtitle"); @@ -471,6 +489,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { ret |= context->output->video->Command(context, OUTPUT_SLOWMOTION, "video"); } + if (context->playback->isAudio) { ret |= context->output->audio->Command(context, OUTPUT_SLOWMOTION, "audio"); @@ -520,6 +539,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) { return context->output->video->Command(context, OUTPUT_GET_FRAME_COUNT, argument); } + if (context->playback->isAudio) { return context->output->audio->Command(context, OUTPUT_GET_FRAME_COUNT, argument); From 955ec86ed7507322938c93c2b27540c998e19284 Mon Sep 17 00:00:00 2001 From: BPanther Date: Wed, 5 Sep 2018 18:08:50 +0200 Subject: [PATCH 10/59] small fix Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/04fd634c0d2766df53c75b55f0f83c870239837f Author: BPanther Date: 2018-09-05 (Wed, 05 Sep 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- common/ca_ci.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/common/ca_ci.cpp b/common/ca_ci.cpp index aa1fbc6..0f6c05d 100644 --- a/common/ca_ci.cpp +++ b/common/ca_ci.cpp @@ -1652,6 +1652,13 @@ FROM_FIRST: bool cCA::SendCaPMT(eDVBCISlot* slot) { printf("%s -> %s\n", FILENAME, __func__); + if (slot->fd > 0) + { +#if HAVE_ARM_HARDWARE + setInputSource(slot, true); +#endif + setSource(slot); + } if ((slot->fd > 0) && (slot->camIsReady)) { if (slot->hasCAManager) @@ -1667,14 +1674,6 @@ bool cCA::SendCaPMT(eDVBCISlot* slot) slot->camgrSession->sendSPDU(0x90, 0, 0, slot->pmtdata, slot->pmtlen); } } - - if (slot->fd > 0) - { -#if HAVE_ARM_HARDWARE - setInputSource(slot, true); -#endif - setSource(slot); - } return true; } From 7cf6d51d29058ac82db8ee8ed716bad67f8102c8 Mon Sep 17 00:00:00 2001 From: max_10 Date: Thu, 20 Sep 2018 16:57:11 +0200 Subject: [PATCH 11/59] Revert "fix missing compiler include" This reverts commit f4bbd252ceac62f593ec586b3febec6565a4eeb0. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/b3d05f59bf066170f490f148598fa3018f1e9214 Author: max_10 Date: 2018-09-20 (Thu, 20 Sep 2018) ------------------ This commit was generated by Migit --- libeplayer3/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libeplayer3/Makefile.am b/libeplayer3/Makefile.am index 602c42c..814d106 100644 --- a/libeplayer3/Makefile.am +++ b/libeplayer3/Makefile.am @@ -4,7 +4,7 @@ noinst_LTLIBRARIES = libeplayer3.la AM_CPPFLAGS = -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS AM_CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -AM_CPPFLAGS += -I$(srcdir)/include -I$(top_srcdir)/include +AM_CPPFLAGS += -I$(srcdir)/include AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing libeplayer3_la_SOURCES = \ From 3a618f5c1bf1b7bf85ec4258eb5e42c4666646c7 Mon Sep 17 00:00:00 2001 From: max_10 Date: Thu, 20 Sep 2018 16:58:06 +0200 Subject: [PATCH 12/59] Revert "changed raspi to own thread class" This reverts commit a93605761900887923e05d323525ec608bca003c. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/89ab7c86dc82c3c1132b527e73ce5a9a2c224643 Author: max_10 Date: 2018-09-20 (Thu, 20 Sep 2018) ------------------ This commit was generated by Migit --- raspi/Makefile.am | 3 ++- raspi/glfb.cpp | 10 +++++----- raspi/glfb.h | 6 +++--- raspi/init.cpp | 8 ++++---- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/raspi/Makefile.am b/raspi/Makefile.am index 3bc2d31..32cd87a 100644 --- a/raspi/Makefile.am +++ b/raspi/Makefile.am @@ -10,7 +10,8 @@ AM_CPPFLAGS += \ AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing AM_LDFLAGS = \ - -L/opt/vc/lib/ -lopenmaxil -lbcm_host -lvcos -lvchiq_arm -lpthread -lrt + -L/opt/vc/lib/ -lopenmaxil -lbcm_host -lvcos -lvchiq_arm -lpthread -lrt \ + -lOpenThreads libraspi_la_SOURCES = \ hardware_caps.c \ diff --git a/raspi/glfb.cpp b/raspi/glfb.cpp index 764afa9..45d6473 100644 --- a/raspi/glfb.cpp +++ b/raspi/glfb.cpp @@ -19,7 +19,7 @@ */ #include -#include +#include #include "glfb.h" #include "bcm_host.h" @@ -47,8 +47,8 @@ static int curr_res; static int pitch; static VC_IMAGE_TYPE_T type = VC_IMAGE_ARGB8888; -static Mutex blit_mutex; -static Condition blit_cond; +static OpenThreads::Mutex blit_mutex; +static OpenThreads::Condition blit_cond; static bool goodbye = false; /* if set main loop is left */ static bool ready = false; /* condition predicate */ @@ -71,7 +71,7 @@ GLFramebuffer::GLFramebuffer(int x, int y) si.red.offset = 16; si.transp.offset = 24; - Thread::start(); + OpenThreads::Thread::start(); while (!ready) usleep(1); } @@ -80,7 +80,7 @@ GLFramebuffer::~GLFramebuffer() { goodbye = true; blit(); /* wake up thread */ - Thread::join(); + OpenThreads::Thread::join(); } void GLFramebuffer::run() diff --git a/raspi/glfb.h b/raspi/glfb.h index 68e2055..c5fcce6 100644 --- a/raspi/glfb.h +++ b/raspi/glfb.h @@ -17,11 +17,11 @@ #ifndef __glthread__ #define __glthread__ -#include +#include #include #include /* for screeninfo etc. */ -class GLFramebuffer : public Thread +class GLFramebuffer : public OpenThreads::Thread { public: GLFramebuffer(int x, int y); @@ -34,7 +34,7 @@ private: void *pdata; /* not yet used */ fb_var_screeninfo si; std::vector osd_buf; /* silly bounce buffer */ - void run(); /* for Thread */ + void run(); /* for OpenThreads::Thread */ void setup(); void blit_osd(); diff --git a/raspi/init.cpp b/raspi/init.cpp index 6e6adfc..47f6d9e 100644 --- a/raspi/init.cpp +++ b/raspi/init.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include "init_td.h" #include "lt_debug.h" @@ -69,7 +69,7 @@ static void init_keymap(void) kmap[KEY_F8] = KEY_SLEEP; } -class Input: public Thread +class Input: public OpenThreads::Thread { public: Input(); @@ -82,13 +82,13 @@ class Input: public Thread Input::Input() { Init(); - Thread::start(); + start(); } Input::~Input() { running = false; - Thread::join(); + join(); } static int dirfilter(const struct dirent *d) From e61caae9830af8ddba0502b042c6a6524f14ce37 Mon Sep 17 00:00:00 2001 From: max_10 Date: Thu, 20 Sep 2018 17:18:35 +0200 Subject: [PATCH 13/59] Revert "change libeplayer3 to own thread class" This reverts commit 3f238feb60426c4e4720e6a42c8697174549d0b2. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/10710b9b5362cfd745fe5dba50287a61fcf7d459 Author: max_10 Date: 2018-09-20 (Thu, 20 Sep 2018) ------------------ This commit was generated by Migit --- libeplayer3/include/input.h | 6 +++-- libeplayer3/include/manager.h | 6 +++-- libeplayer3/include/output.h | 6 +++-- libeplayer3/include/player.h | 6 +++-- libeplayer3/input.cpp | 10 +++---- libeplayer3/manager.cpp | 14 +++++----- libeplayer3/output.cpp | 50 +++++++++++++++++------------------ libeplayer3/player.cpp | 4 +-- 8 files changed, 55 insertions(+), 47 deletions(-) diff --git a/libeplayer3/include/input.h b/libeplayer3/include/input.h index 2488cf9..d27e0fa 100644 --- a/libeplayer3/include/input.h +++ b/libeplayer3/include/input.h @@ -26,7 +26,9 @@ #include #include -#include +#include +#include +#include extern "C" { #include @@ -46,7 +48,7 @@ class Input friend int interrupt_cb(void *arg); private: - Mutex mutex; + OpenThreads::Mutex mutex; Track *videoTrack; Track *audioTrack; diff --git a/libeplayer3/include/manager.h b/libeplayer3/include/manager.h index 41ef416..364595b 100644 --- a/libeplayer3/include/manager.h +++ b/libeplayer3/include/manager.h @@ -26,7 +26,9 @@ #include #include -#include +#include +#include +#include extern "C" { #include @@ -64,7 +66,7 @@ class Manager private: Player *player; - Mutex mutex; + OpenThreads::Mutex mutex; std::map videoTracks, audioTracks, subtitleTracks, teletextTracks; std::map Programs; void addTrack(std::map &tracks, Track &track); diff --git a/libeplayer3/include/output.h b/libeplayer3/include/output.h index 2fec93e..b154427 100644 --- a/libeplayer3/include/output.h +++ b/libeplayer3/include/output.h @@ -26,7 +26,9 @@ #include #include -#include +#include +#include +#include extern "C" { #include @@ -48,7 +50,7 @@ class Output int videofd; int audiofd; Writer *videoWriter, *audioWriter; - Mutex audioMutex, videoMutex; + OpenThreads::Mutex audioMutex, videoMutex; Track *audioTrack, *videoTrack; Player *player; public: diff --git a/libeplayer3/include/player.h b/libeplayer3/include/player.h index 93629a6..b675adc 100644 --- a/libeplayer3/include/player.h +++ b/libeplayer3/include/player.h @@ -21,7 +21,9 @@ #ifndef __PLAYER_H__ #define __PLAYER_H__ -#include +#include +#include +#include extern "C" { #include @@ -61,7 +63,7 @@ class Player { Input input; Output output; Manager manager; - Mutex chapterMutex; + OpenThreads::Mutex chapterMutex; std::vector chapters; pthread_t playThread; diff --git a/libeplayer3/input.cpp b/libeplayer3/input.cpp index 7218a4f..46208aa 100644 --- a/libeplayer3/input.cpp +++ b/libeplayer3/input.cpp @@ -290,17 +290,17 @@ static int lock_callback(void **mutex, enum AVLockOp op) { switch (op) { case AV_LOCK_CREATE: - *mutex = (void *) new Mutex; + *mutex = (void *) new OpenThreads::Mutex; return !*mutex; case AV_LOCK_DESTROY: - delete static_cast(*mutex); + delete static_cast(*mutex); *mutex = NULL; return 0; case AV_LOCK_OBTAIN: - static_cast(*mutex)->lock(); + static_cast(*mutex)->lock(); return 0; case AV_LOCK_RELEASE: - static_cast(*mutex)->unlock(); + static_cast(*mutex)->unlock(); return 0; default: return -1; @@ -656,7 +656,7 @@ bool Input::Stop() av_log(NULL, AV_LOG_QUIET, "%s", ""); if (avfc) { - ScopedLock lock(mutex); + OpenThreads::ScopedLock lock(mutex); for (unsigned int i = 0; i < avfc->nb_streams; i++) avcodec_close(avfc->streams[i]->codec); avformat_close_input(&avfc); diff --git a/libeplayer3/manager.cpp b/libeplayer3/manager.cpp index 275205c..da39024 100644 --- a/libeplayer3/manager.cpp +++ b/libeplayer3/manager.cpp @@ -25,7 +25,7 @@ void Manager::addTrack(std::map &tracks, Track &track) { - ScopedLock m_lock(mutex); + OpenThreads::ScopedLock m_lock(mutex); std::map::iterator it = tracks.find(track.pid); if (it == tracks.end()) { Track *t = new Track; @@ -59,7 +59,7 @@ std::vector Manager::getTracks(std::map &tracks) { player->input.UpdateTracks(); std::vector res; - ScopedLock m_lock(mutex); + OpenThreads::ScopedLock m_lock(mutex); for(std::map::iterator it = tracks.begin(); it != tracks.end(); ++it) if (!it->second->inactive && !it->second->hidden) res.push_back(*it->second); @@ -88,7 +88,7 @@ std::vector Manager::getTeletextTracks() Track *Manager::getTrack(std::map &tracks, int pid) { - ScopedLock m_lock(mutex); + OpenThreads::ScopedLock m_lock(mutex); std::map::iterator it = tracks.find(pid); if (it != tracks.end() && !it->second->inactive) return it->second; @@ -116,7 +116,7 @@ Track *Manager::getTeletextTrack(int pid) bool Manager::initTrackUpdate() { - ScopedLock m_lock(mutex); + OpenThreads::ScopedLock m_lock(mutex); for (std::map::iterator it = audioTracks.begin(); it != audioTracks.end(); ++it) it->second->inactive = !it->second->is_static; @@ -140,7 +140,7 @@ void Manager::addProgram(Program &program) std::vector Manager::getPrograms(void) { - ScopedLock m_lock(mutex); + OpenThreads::ScopedLock m_lock(mutex); std::vector res; for (std::map::iterator it = Programs.begin(); it != Programs.end(); ++it) res.push_back(it->second); @@ -149,7 +149,7 @@ std::vector Manager::getPrograms(void) bool Manager::selectProgram(const int id) { - ScopedLock m_lock(mutex); + OpenThreads::ScopedLock m_lock(mutex); std::map::iterator i = Programs.find(id); if (i != Programs.end()) { @@ -236,7 +236,7 @@ bool Manager::selectProgram(const int id) void Manager::clearTracks() { - ScopedLock m_lock(mutex); + OpenThreads::ScopedLock m_lock(mutex); for (std::map::iterator it = audioTracks.begin(); it != audioTracks.end(); ++it) delete it->second; diff --git a/libeplayer3/output.cpp b/libeplayer3/output.cpp index 431dcb5..11e4eb7 100644 --- a/libeplayer3/output.cpp +++ b/libeplayer3/output.cpp @@ -68,9 +68,9 @@ Output::~Output() bool Output::Open() { - ScopedLock v_lock(videoMutex); - ScopedLock a_lock(audioMutex); - + OpenThreads::ScopedLock v_lock(videoMutex); + OpenThreads::ScopedLock a_lock(audioMutex); + if (videofd < 0) videofd = open(VIDEODEV, O_RDWR); @@ -102,8 +102,8 @@ bool Output::Close() { Stop(); - ScopedLock v_lock(videoMutex); - ScopedLock a_lock(audioMutex); + OpenThreads::ScopedLock v_lock(videoMutex); + OpenThreads::ScopedLock a_lock(audioMutex); if (videofd > -1) { close(videofd); @@ -124,8 +124,8 @@ bool Output::Play() { bool ret = true; - ScopedLock v_lock(videoMutex); - ScopedLock a_lock(audioMutex); + OpenThreads::ScopedLock v_lock(videoMutex); + OpenThreads::ScopedLock a_lock(audioMutex); AVCodecContext *avcc; @@ -154,8 +154,8 @@ bool Output::Stop() { bool ret = true; - ScopedLock v_lock(videoMutex); - ScopedLock a_lock(audioMutex); + OpenThreads::ScopedLock v_lock(videoMutex); + OpenThreads::ScopedLock a_lock(audioMutex); if (videofd > -1) { ioctl(videofd, VIDEO_CLEAR_BUFFER, NULL); @@ -180,8 +180,8 @@ bool Output::Pause() { bool ret = true; - ScopedLock v_lock(videoMutex); - ScopedLock a_lock(audioMutex); + OpenThreads::ScopedLock v_lock(videoMutex); + OpenThreads::ScopedLock a_lock(audioMutex); if (videofd > -1) { if (dioctl(videofd, VIDEO_FREEZE, NULL)) @@ -200,8 +200,8 @@ bool Output::Continue() { bool ret = true; - ScopedLock v_lock(videoMutex); - ScopedLock a_lock(audioMutex); + OpenThreads::ScopedLock v_lock(videoMutex); + OpenThreads::ScopedLock a_lock(audioMutex); if (videofd > -1 && dioctl(videofd, VIDEO_CONTINUE, NULL)) ret = false; @@ -214,7 +214,7 @@ bool Output::Continue() bool Output::Mute(bool b) { - ScopedLock a_lock(audioMutex); + OpenThreads::ScopedLock a_lock(audioMutex); //AUDIO_SET_MUTE has no effect with new player return audiofd > -1 && !dioctl(audiofd, b ? AUDIO_STOP : AUDIO_PLAY, NULL); } @@ -224,8 +224,8 @@ bool Output::Flush() { bool ret = true; - ScopedLock v_lock(videoMutex); - ScopedLock a_lock(audioMutex); + OpenThreads::ScopedLock v_lock(videoMutex); + OpenThreads::ScopedLock a_lock(audioMutex); if (videofd > -1 && ioctl(videofd, VIDEO_FLUSH, NULL)) ret = false; @@ -246,31 +246,31 @@ bool Output::Flush() bool Output::FastForward(int speed) { - ScopedLock v_lock(videoMutex); + OpenThreads::ScopedLock v_lock(videoMutex); return videofd > -1 && !dioctl(videofd, VIDEO_FAST_FORWARD, speed); } bool Output::SlowMotion(int speed) { - ScopedLock v_lock(videoMutex); + OpenThreads::ScopedLock v_lock(videoMutex); return videofd > -1 && !dioctl(videofd, VIDEO_SLOWMOTION, speed); } bool Output::AVSync(bool b) { - ScopedLock a_lock(audioMutex); + OpenThreads::ScopedLock a_lock(audioMutex); return audiofd > -1 && !dioctl(audiofd, AUDIO_SET_AV_SYNC, b); } bool Output::ClearAudio() { - ScopedLock a_lock(audioMutex); + OpenThreads::ScopedLock a_lock(audioMutex); return audiofd > -1 && !ioctl(audiofd, AUDIO_CLEAR_BUFFER, NULL); } bool Output::ClearVideo() { - ScopedLock v_lock(videoMutex); + OpenThreads::ScopedLock v_lock(videoMutex); return videofd > -1 && !ioctl(videofd, VIDEO_CLEAR_BUFFER, NULL); } @@ -302,7 +302,7 @@ bool Output::GetFrameCount(int64_t &framecount) bool Output::SwitchAudio(Track *track) { - ScopedLock a_lock(audioMutex); + OpenThreads::ScopedLock a_lock(audioMutex); if (audioTrack && track->stream == audioTrack->stream) return true; if (audiofd > -1) { @@ -329,7 +329,7 @@ bool Output::SwitchAudio(Track *track) bool Output::SwitchVideo(Track *track) { - ScopedLock v_lock(videoMutex); + OpenThreads::ScopedLock v_lock(videoMutex); if (videoTrack && track->stream == videoTrack->stream) return true; if (videofd > -1) { @@ -355,11 +355,11 @@ bool Output::Write(AVStream *stream, AVPacket *packet, int64_t pts) { switch (stream->codec->codec_type) { case AVMEDIA_TYPE_VIDEO: { - ScopedLock v_lock(videoMutex); + OpenThreads::ScopedLock v_lock(videoMutex); return videofd > -1 && videoWriter && videoWriter->Write(packet, pts); } case AVMEDIA_TYPE_AUDIO: { - ScopedLock a_lock(audioMutex); + OpenThreads::ScopedLock a_lock(audioMutex); return audiofd > -1 && audioWriter && audioWriter->Write(packet, pts); } default: diff --git a/libeplayer3/player.cpp b/libeplayer3/player.cpp index 2c0bfe5..37ad7c1 100644 --- a/libeplayer3/player.cpp +++ b/libeplayer3/player.cpp @@ -372,7 +372,7 @@ bool Player::GetChapters(std::vector &positions, std::vector & positions.clear(); titles.clear(); input.UpdateTracks(); - ScopedLock m_lock(chapterMutex); + OpenThreads::ScopedLock m_lock(chapterMutex); for (std::vector::iterator it = chapters.begin(); it != chapters.end(); ++it) { positions.push_back(it->start/1000); titles.push_back(it->title); @@ -382,7 +382,7 @@ bool Player::GetChapters(std::vector &positions, std::vector & void Player::SetChapters(std::vector &Chapters) { - ScopedLock m_lock(chapterMutex); + OpenThreads::ScopedLock m_lock(chapterMutex); chapters = Chapters; } From 611435648db5265e19440bd249015c45c378ce53 Mon Sep 17 00:00:00 2001 From: max_10 Date: Thu, 20 Sep 2018 17:42:13 +0200 Subject: [PATCH 14/59] Revert "move libthread to libstb-hal" This reverts commit d5cea508e05a6b38b1edf38d7725cd41217d7c6a. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/1aece863c11038f05c824ecb2a1ed1f72f1ef295 Author: max_10 Date: 2018-09-20 (Thu, 20 Sep 2018) ------------------ This commit was generated by Migit --- Makefile.am | 5 +- common/Makefile.am | 2 + {libthread => common}/mutex_abstraction.cpp | 12 +---- {include => common}/mutex_abstraction.h | 9 +--- common/thread_abstraction.cpp | 34 ++++++++++++ common/thread_abstraction.h | 25 +++++++++ configure.ac | 1 - generic-pc/audio.cpp | 4 +- generic-pc/audio_lib.h | 3 +- generic-pc/dmx.cpp | 31 +++-------- generic-pc/glfb.cpp | 4 +- generic-pc/glfb.h | 6 +-- generic-pc/video.cpp | 4 +- generic-pc/video_lib.h | 6 +-- include/condition_abstraction.h | 23 -------- include/reentrant_mutex.h | 16 ------ include/scoped_lock.h | 18 ------- include/thread_abstraction.h | 30 ----------- libthread/Makefile.am | 16 ------ libthread/condition_abstraction.cpp | 27 ---------- libthread/reentrant_mutex.cpp | 11 ---- libthread/scoped_lock.cpp | 12 ----- libthread/thread_abstraction.cpp | 58 --------------------- 23 files changed, 85 insertions(+), 272 deletions(-) rename {libthread => common}/mutex_abstraction.cpp (52%) rename {include => common}/mutex_abstraction.h (68%) create mode 100644 common/thread_abstraction.cpp create mode 100644 common/thread_abstraction.h delete mode 100644 include/condition_abstraction.h delete mode 100644 include/reentrant_mutex.h delete mode 100644 include/scoped_lock.h delete mode 100644 include/thread_abstraction.h delete mode 100644 libthread/Makefile.am delete mode 100644 libthread/condition_abstraction.cpp delete mode 100644 libthread/reentrant_mutex.cpp delete mode 100644 libthread/scoped_lock.cpp delete mode 100644 libthread/thread_abstraction.cpp diff --git a/Makefile.am b/Makefile.am index 5466534..c26789f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,12 +2,11 @@ ACLOCAL_AMFLAGS = -I m4 lib_LTLIBRARIES = libstb-hal.la libstb_hal_la_SOURCES = -SUBDIRS = common tools libthread +SUBDIRS = common tools #bin_PROGRAMS = libstb-hal-test libstb_hal_la_LIBADD = \ - common/libcommon.la \ - libthread/libthread.la + common/libcommon.la #libstb_hal_test_SOURCES = libtest.cpp diff --git a/common/Makefile.am b/common/Makefile.am index 17395fc..86f3517 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -31,6 +31,8 @@ endif endif libcommon_la_SOURCES += \ + thread_abstraction.cpp \ + mutex_abstraction.cpp \ lt_debug.cpp \ proc_tools.c \ pwrmngr.cpp diff --git a/libthread/mutex_abstraction.cpp b/common/mutex_abstraction.cpp similarity index 52% rename from libthread/mutex_abstraction.cpp rename to common/mutex_abstraction.cpp index 906407a..a5a886f 100644 --- a/libthread/mutex_abstraction.cpp +++ b/common/mutex_abstraction.cpp @@ -1,4 +1,4 @@ -#include +#include "mutex_abstraction.h" Mutex::Mutex() : mMutex() @@ -6,16 +6,6 @@ Mutex::Mutex() : pthread_mutex_init(&mMutex, 0); } -Mutex::Mutex(int attr) : - mMutex() -{ - pthread_mutexattr_t Attr; - - pthread_mutexattr_init(&Attr); - pthread_mutexattr_settype(&Attr, attr); - pthread_mutex_init(&mMutex, &Attr); -} - Mutex::~Mutex() { pthread_mutex_destroy(&mMutex); diff --git a/include/mutex_abstraction.h b/common/mutex_abstraction.h similarity index 68% rename from include/mutex_abstraction.h rename to common/mutex_abstraction.h index 3ea5357..c2b78d8 100644 --- a/include/mutex_abstraction.h +++ b/common/mutex_abstraction.h @@ -5,21 +5,16 @@ class Mutex { - friend class Condition; - pthread_mutex_t mMutex; Mutex(const Mutex&); const Mutex& operator=(const Mutex&); - protected: - explicit Mutex(int); - public: Mutex(); virtual ~Mutex(); - virtual void lock(); - virtual void unlock(); + void lock(); + void unlock(); }; #endif diff --git a/common/thread_abstraction.cpp b/common/thread_abstraction.cpp new file mode 100644 index 0000000..0494fc4 --- /dev/null +++ b/common/thread_abstraction.cpp @@ -0,0 +1,34 @@ +#include "thread_abstraction.h" + +SimpleThread::SimpleThread() : + mIsRunning(false), + mThread() +{ +} + +SimpleThread::~SimpleThread() +{ + // if thread is still running on object destruction, cancel thread the hard way: + if (mIsRunning) + { + pthread_cancel(mThread); + } +} + +void SimpleThread::startThread() +{ + mIsRunning = true; + pthread_create(&mThread, 0, &SimpleThread::runThread, this); +} + +void SimpleThread::joinThread() +{ + pthread_join(mThread, 0); + mIsRunning = false; +} + +void* SimpleThread::runThread(void* ptr) +{ + static_cast(ptr)->run(); + return 0; +} diff --git a/common/thread_abstraction.h b/common/thread_abstraction.h new file mode 100644 index 0000000..45a20b6 --- /dev/null +++ b/common/thread_abstraction.h @@ -0,0 +1,25 @@ +#ifndef _SIMPLETHREAD_ABSTRACTION_H +#define _SIMPLETHREAD_ABSTRACTION_H + +#include + +class SimpleThread +{ + bool mIsRunning; + pthread_t mThread; + + static void* runThread(void*); + SimpleThread(const SimpleThread&); + const SimpleThread& operator=(const SimpleThread&); + + public: + SimpleThread(); + ~SimpleThread(); + void startThread(); + void joinThread(); + + protected: + virtual void run() = 0; +}; + +#endif diff --git a/configure.ac b/configure.ac index 202eaaf..cac007d 100644 --- a/configure.ac +++ b/configure.ac @@ -76,7 +76,6 @@ Makefile common/Makefile libeplayer3/Makefile libeplayer3-arm/Makefile -libthread/Makefile azbox/Makefile generic-pc/Makefile libduckbox/Makefile diff --git a/generic-pc/audio.cpp b/generic-pc/audio.cpp index 1bba357..0ee8b3b 100644 --- a/generic-pc/audio.cpp +++ b/generic-pc/audio.cpp @@ -104,7 +104,7 @@ int cAudio::Start(void) { lt_debug("%s >\n", __func__); if (! HAL_nodec) - Thread::startThread(); + SimpleThread::startThread(); lt_debug("%s <\n", __func__); return 0; } @@ -115,7 +115,7 @@ int cAudio::Stop(void) if (thread_started) { thread_started = false; - Thread::joinThread(); + SimpleThread::joinThread(); } lt_debug("%s <\n", __func__); return 0; diff --git a/generic-pc/audio_lib.h b/generic-pc/audio_lib.h index dc09c8d..6bcd80a 100644 --- a/generic-pc/audio_lib.h +++ b/generic-pc/audio_lib.h @@ -4,7 +4,6 @@ #define _AUDIO_LIB_H_ #include -#include #include "cs_types.h" typedef enum @@ -38,7 +37,7 @@ typedef enum AUDIO_FMT_ADVANCED = AUDIO_FMT_MLP } AUDIO_FORMAT; -class cAudio : public Thread +class cAudio : public SimpleThread { friend class cPlayback; private: diff --git a/generic-pc/dmx.cpp b/generic-pc/dmx.cpp index 1af785f..769a971 100644 --- a/generic-pc/dmx.cpp +++ b/generic-pc/dmx.cpp @@ -64,15 +64,12 @@ static const char *DMX_T[] = { }; /* map the device numbers. for now only demux0 is used */ -#define NUM_DEMUXDEV 1 -static const char *devname[NUM_DEMUXDEV] = { +static const char *devname[] = { "/dev/dvb/adapter0/demux0", + "/dev/dvb/adapter0/demux0", + "/dev/dvb/adapter0/demux0" }; -#define NUM_DEMUX 1 -static int dmx_source[NUM_DEMUX] = { 0 }; -// static bool init[NUM_DEMUXDEV] = { false }; - /* uuuugly */ static int dmx_tp_count = 0; #define MAX_TS_COUNT 8 @@ -492,28 +489,12 @@ int cDemux::getUnit(void) bool cDemux::SetSource(int unit, int source) { - //lt_info_c("%s(%d, %d): not implemented yet\n", __func__, unit, source); - //return true; - if (unit >= NUM_DEMUX || unit < 0) { - lt_info_c("%s: unit (%d) out of range, NUM_DEMUX %d\n", __func__, unit, NUM_DEMUX); - return false; - } - lt_info_c("%s(%d, %d) => %d to %d\n", __func__, unit, source, dmx_source[unit], source); - if (source < 0 || source >= NUM_DEMUXDEV) - lt_info_c("%s(%d, %d) ERROR: source %d out of range!\n", __func__, unit, source, source); - else - dmx_source[unit] = source; + lt_info_c("%s(%d, %d): not implemented yet\n", __func__, unit, source); return true; } int cDemux::GetSource(int unit) { - //lt_info_c("%s(%d): not implemented yet\n", __func__, unit); - //return 0; - if (unit >= NUM_DEMUX || unit < 0) { - lt_info_c("%s: unit (%d) out of range, NUM_DEMUX %d\n", __func__, unit, NUM_DEMUX); - return -1; - } - lt_info_c("%s(%d) => %d\n", __func__, unit, dmx_source[unit]); - return dmx_source[unit]; + lt_info_c("%s(%d): not implemented yet\n", __func__, unit); + return 0; } diff --git a/generic-pc/glfb.cpp b/generic-pc/glfb.cpp index a838997..3cffd0e 100644 --- a/generic-pc/glfb.cpp +++ b/generic-pc/glfb.cpp @@ -97,7 +97,7 @@ GLFramebuffer::GLFramebuffer(int x, int y): mReInit(true), mShutDown(false), mIn if (input_fd < 0) lt_info("%s: could not open /tmp/neutrino.input FIFO: %m\n", __func__); initKeys(); - Thread::startThread(); + SimpleThread::startThread(); while (!mInitDone) usleep(1); } @@ -105,7 +105,7 @@ GLFramebuffer::GLFramebuffer(int x, int y): mReInit(true), mShutDown(false), mIn GLFramebuffer::~GLFramebuffer() { mShutDown = true; - Thread::joinThread(); + SimpleThread::joinThread(); if (input_fd >= 0) close(input_fd); } diff --git a/generic-pc/glfb.h b/generic-pc/glfb.h index 6cb803d..755a01f 100644 --- a/generic-pc/glfb.h +++ b/generic-pc/glfb.h @@ -18,8 +18,8 @@ #ifndef __glthread__ #define __glthread__ -#include -#include +#include "../common/thread_abstraction.h" +#include "../common/mutex_abstraction.h" #include #include @@ -31,7 +31,7 @@ extern "C" { #include } -class GLFramebuffer : public Thread +class GLFramebuffer : public SimpleThread { public: GLFramebuffer(int x, int y); diff --git a/generic-pc/video.cpp b/generic-pc/video.cpp index abcfd75..06ea690 100644 --- a/generic-pc/video.cpp +++ b/generic-pc/video.cpp @@ -145,7 +145,7 @@ int cVideo::Start(void *, unsigned short, unsigned short, void *) { lt_debug("%s running %d >\n", __func__, thread_running); if (!thread_running && !HAL_nodec) - Thread::startThread(); + SimpleThread::startThread(); lt_debug("%s running %d <\n", __func__, thread_running); return 0; } @@ -155,7 +155,7 @@ int cVideo::Stop(bool) lt_debug("%s running %d >\n", __func__, thread_running); if (thread_running) { thread_running = false; - Thread::joinThread(); + SimpleThread::joinThread(); } lt_debug("%s running %d <\n", __func__, thread_running); return 0; diff --git a/generic-pc/video_lib.h b/generic-pc/video_lib.h index a8274e8..144b53f 100644 --- a/generic-pc/video_lib.h +++ b/generic-pc/video_lib.h @@ -1,8 +1,8 @@ #ifndef _VIDEO_LIB_H #define _VIDEO_LIB_H -#include -#include +#include "../common/thread_abstraction.h" +#include "../common/mutex_abstraction.h" #include #include #include "cs_types.h" @@ -121,7 +121,7 @@ typedef enum #define VDEC_MAXBUFS 0x30 -class cVideo : public Thread +class cVideo : public SimpleThread { friend class GLFramebuffer; friend class cDemux; diff --git a/include/condition_abstraction.h b/include/condition_abstraction.h deleted file mode 100644 index 8374efa..0000000 --- a/include/condition_abstraction.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _CONDITION_ABSTRACTION_H -#define _CONDITION_ABSTRACTION_H - -#include - -#include "mutex_abstraction.h" - -class Condition -{ - pthread_cond_t mCondition; - - Condition(const Condition&); - const Condition& operator=(const Condition&); - - public: - Condition(); - virtual ~Condition(); - virtual int wait(Mutex* const aMutex); - virtual int broadcast(); - virtual int signal(); -}; - -#endif diff --git a/include/reentrant_mutex.h b/include/reentrant_mutex.h deleted file mode 100644 index bf9f740..0000000 --- a/include/reentrant_mutex.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _REENTRANT_MUTEX_H -#define _REENTRANT_MUTEX_H - -#include "mutex_abstraction.h" - -class ReentrantMutex : public Mutex -{ - ReentrantMutex(const ReentrantMutex&); - const ReentrantMutex& operator=(const ReentrantMutex&); - - public: - ReentrantMutex(); - virtual ~ReentrantMutex(); -}; - -#endif diff --git a/include/scoped_lock.h b/include/scoped_lock.h deleted file mode 100644 index 0c1fdb2..0000000 --- a/include/scoped_lock.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _SCOPED_LOCK_H -#define _SCOPED_LOCK_H - -#include "mutex_abstraction.h" - -class ScopedLock -{ - Mutex& mMutex; - - ScopedLock(const ScopedLock&); - const ScopedLock& operator=(const ScopedLock&); - - public: - ScopedLock(Mutex&); - ~ScopedLock(); -}; - -#endif diff --git a/include/thread_abstraction.h b/include/thread_abstraction.h deleted file mode 100644 index 12f9f76..0000000 --- a/include/thread_abstraction.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _THREAD_ABSTRACTION_H -#define _THREAD_ABSTRACTION_H - -#include - -class Thread -{ - bool mIsRunning; - pthread_t mThread; - - static void* runThread(void*); - Thread(const Thread&); - const Thread& operator=(const Thread&); - - public: - Thread(); - virtual ~Thread(); - int startThread(); - int cancelThread(); - int detachThread(); - int joinThread(); - - int setCancelModeDisable(); - int setSchedulePriority(int); - - protected: - virtual void run() = 0; -}; - -#endif diff --git a/libthread/Makefile.am b/libthread/Makefile.am deleted file mode 100644 index 9369b1f..0000000 --- a/libthread/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -noinst_LTLIBRARIES = libthread.la - -AM_CPPFLAGS = -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -AM_CPPFLAGS += \ - -I$(top_srcdir)/include - -AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing - -AM_LDFLAGS = -lpthread -lrt - -libthread_la_SOURCES = \ - condition_abstraction.cpp \ - reentrant_mutex.cpp \ - scoped_lock.cpp \ - thread_abstraction.cpp \ - mutex_abstraction.cpp diff --git a/libthread/condition_abstraction.cpp b/libthread/condition_abstraction.cpp deleted file mode 100644 index 68d246a..0000000 --- a/libthread/condition_abstraction.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include - -Condition::Condition() : - mCondition() -{ - pthread_cond_init(&mCondition, 0); -} - -Condition::~Condition() -{ - pthread_cond_destroy(&mCondition); -} - -int Condition::wait(Mutex* const aMutex) -{ - return pthread_cond_wait(&mCondition, &(aMutex->mMutex)); -} - -int Condition::broadcast() -{ - return pthread_cond_broadcast(&mCondition); -} - -int Condition::signal() -{ - return pthread_cond_signal(&mCondition); -} diff --git a/libthread/reentrant_mutex.cpp b/libthread/reentrant_mutex.cpp deleted file mode 100644 index 82c3069..0000000 --- a/libthread/reentrant_mutex.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -ReentrantMutex::ReentrantMutex() : - Mutex(PTHREAD_MUTEX_RECURSIVE) -{ -} - -ReentrantMutex::~ReentrantMutex() -{ - //safely destroyed in ~Mutex(); -} diff --git a/libthread/scoped_lock.cpp b/libthread/scoped_lock.cpp deleted file mode 100644 index 7ff573d..0000000 --- a/libthread/scoped_lock.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include - -ScopedLock::ScopedLock(Mutex& aMutex) : - mMutex(aMutex) -{ - mMutex.lock(); -} - -ScopedLock::~ScopedLock() -{ - mMutex.unlock(); -} diff --git a/libthread/thread_abstraction.cpp b/libthread/thread_abstraction.cpp deleted file mode 100644 index afaff86..0000000 --- a/libthread/thread_abstraction.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include - -Thread::Thread() : - mIsRunning(false), - mThread() -{ -} - -Thread::~Thread() -{ - // if thread is still running on object destruction, cancel thread the hard way: - if (mIsRunning) - { - pthread_cancel(mThread); - } -} - -int Thread::startThread() -{ - mIsRunning = true; - return pthread_create(&mThread, 0, &Thread::runThread, this); -} - -int Thread::cancelThread() -{ - return pthread_cancel(mThread); - mIsRunning = false; -} - -int Thread::detachThread() -{ - mIsRunning = false; // thread shall not cancel on object destruction! - return pthread_detach(mThread); -} - -int Thread::joinThread() -{ - int ret = pthread_join(mThread, 0); - mIsRunning = false; - return ret; -} - -int Thread::setCancelModeDisable() -{ - return pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0); -} - -int Thread::setSchedulePriority(int prio) -{ - return pthread_setschedprio(mThread, prio); -} - -void* Thread::runThread(void* ptr) -{ - Thread* t = static_cast(ptr); - t->run(); - return 0; -} From 6f64c1822ea0211424fd6557a54f69e26e6c493c Mon Sep 17 00:00:00 2001 From: max_10 Date: Thu, 20 Sep 2018 17:42:46 +0200 Subject: [PATCH 15/59] Revert "fix thread namespace" This reverts commit 03a7525218ce205ec0a508109ff9ca4179bc7408. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/bc7be9dd74113429e5b7836035fa39bf2d3276c7 Author: max_10 Date: 2018-09-20 (Thu, 20 Sep 2018) ------------------ This commit was generated by Migit --- common/thread_abstraction.cpp | 14 +++++++------- common/thread_abstraction.h | 14 +++++++------- generic-pc/audio.cpp | 4 ++-- generic-pc/audio_lib.h | 2 +- generic-pc/glfb.cpp | 4 ++-- generic-pc/glfb.h | 2 +- generic-pc/video.cpp | 4 ++-- generic-pc/video_lib.h | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/common/thread_abstraction.cpp b/common/thread_abstraction.cpp index 0494fc4..271755c 100644 --- a/common/thread_abstraction.cpp +++ b/common/thread_abstraction.cpp @@ -1,12 +1,12 @@ #include "thread_abstraction.h" -SimpleThread::SimpleThread() : +Thread::Thread() : mIsRunning(false), mThread() { } -SimpleThread::~SimpleThread() +Thread::~Thread() { // if thread is still running on object destruction, cancel thread the hard way: if (mIsRunning) @@ -15,20 +15,20 @@ SimpleThread::~SimpleThread() } } -void SimpleThread::startThread() +void Thread::startThread() { mIsRunning = true; - pthread_create(&mThread, 0, &SimpleThread::runThread, this); + pthread_create(&mThread, 0, &Thread::runThread, this); } -void SimpleThread::joinThread() +void Thread::joinThread() { pthread_join(mThread, 0); mIsRunning = false; } -void* SimpleThread::runThread(void* ptr) +void* Thread::runThread(void* ptr) { - static_cast(ptr)->run(); + ((Thread*)ptr)->run(); return 0; } diff --git a/common/thread_abstraction.h b/common/thread_abstraction.h index 45a20b6..3c3e35f 100644 --- a/common/thread_abstraction.h +++ b/common/thread_abstraction.h @@ -1,20 +1,20 @@ -#ifndef _SIMPLETHREAD_ABSTRACTION_H -#define _SIMPLETHREAD_ABSTRACTION_H +#ifndef _THREAD_ABSTRACTION_H +#define _THREAD_ABSTRACTION_H #include -class SimpleThread +class Thread { bool mIsRunning; pthread_t mThread; static void* runThread(void*); - SimpleThread(const SimpleThread&); - const SimpleThread& operator=(const SimpleThread&); + Thread(const Thread&); + const Thread& operator=(const Thread&); public: - SimpleThread(); - ~SimpleThread(); + Thread(); + ~Thread(); void startThread(); void joinThread(); diff --git a/generic-pc/audio.cpp b/generic-pc/audio.cpp index 0ee8b3b..d5605f0 100644 --- a/generic-pc/audio.cpp +++ b/generic-pc/audio.cpp @@ -104,7 +104,7 @@ int cAudio::Start(void) { lt_debug("%s >\n", __func__); if (! HAL_nodec) - SimpleThread::startThread(); + startThread(); lt_debug("%s <\n", __func__); return 0; } @@ -115,7 +115,7 @@ int cAudio::Stop(void) if (thread_started) { thread_started = false; - SimpleThread::joinThread(); + joinThread(); } lt_debug("%s <\n", __func__); return 0; diff --git a/generic-pc/audio_lib.h b/generic-pc/audio_lib.h index 6bcd80a..0670cd9 100644 --- a/generic-pc/audio_lib.h +++ b/generic-pc/audio_lib.h @@ -37,7 +37,7 @@ typedef enum AUDIO_FMT_ADVANCED = AUDIO_FMT_MLP } AUDIO_FORMAT; -class cAudio : public SimpleThread +class cAudio : public Thread { friend class cPlayback; private: diff --git a/generic-pc/glfb.cpp b/generic-pc/glfb.cpp index 3cffd0e..fa35e88 100644 --- a/generic-pc/glfb.cpp +++ b/generic-pc/glfb.cpp @@ -97,7 +97,7 @@ GLFramebuffer::GLFramebuffer(int x, int y): mReInit(true), mShutDown(false), mIn if (input_fd < 0) lt_info("%s: could not open /tmp/neutrino.input FIFO: %m\n", __func__); initKeys(); - SimpleThread::startThread(); + startThread(); while (!mInitDone) usleep(1); } @@ -105,7 +105,7 @@ GLFramebuffer::GLFramebuffer(int x, int y): mReInit(true), mShutDown(false), mIn GLFramebuffer::~GLFramebuffer() { mShutDown = true; - SimpleThread::joinThread(); + joinThread(); if (input_fd >= 0) close(input_fd); } diff --git a/generic-pc/glfb.h b/generic-pc/glfb.h index 755a01f..aa4017d 100644 --- a/generic-pc/glfb.h +++ b/generic-pc/glfb.h @@ -31,7 +31,7 @@ extern "C" { #include } -class GLFramebuffer : public SimpleThread +class GLFramebuffer : public Thread { public: GLFramebuffer(int x, int y); diff --git a/generic-pc/video.cpp b/generic-pc/video.cpp index 06ea690..8544e8b 100644 --- a/generic-pc/video.cpp +++ b/generic-pc/video.cpp @@ -145,7 +145,7 @@ int cVideo::Start(void *, unsigned short, unsigned short, void *) { lt_debug("%s running %d >\n", __func__, thread_running); if (!thread_running && !HAL_nodec) - SimpleThread::startThread(); + startThread(); lt_debug("%s running %d <\n", __func__, thread_running); return 0; } @@ -155,7 +155,7 @@ int cVideo::Stop(bool) lt_debug("%s running %d >\n", __func__, thread_running); if (thread_running) { thread_running = false; - SimpleThread::joinThread(); + joinThread(); } lt_debug("%s running %d <\n", __func__, thread_running); return 0; diff --git a/generic-pc/video_lib.h b/generic-pc/video_lib.h index 144b53f..2b8e14e 100644 --- a/generic-pc/video_lib.h +++ b/generic-pc/video_lib.h @@ -121,7 +121,7 @@ typedef enum #define VDEC_MAXBUFS 0x30 -class cVideo : public SimpleThread +class cVideo : public Thread { friend class GLFramebuffer; friend class cDemux; From 0000cd168ce399cd009a247a02826b28741304a7 Mon Sep 17 00:00:00 2001 From: max_10 Date: Thu, 20 Sep 2018 17:45:07 +0200 Subject: [PATCH 16/59] Revert "add changed files" This reverts commit 7f2f83b16e94b73b309a086fbee049b8fc7f76e3. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/745b3054ba807b1db32e37a41a054f352b4c2edf Author: max_10 Date: 2018-09-20 (Thu, 20 Sep 2018) ------------------ This commit was generated by Migit --- common/Makefile.am | 2 -- common/thread_abstraction.cpp | 1 - generic-pc/Makefile.am | 1 + generic-pc/audio.cpp | 5 +++-- generic-pc/audio_lib.h | 3 ++- generic-pc/glfb.cpp | 4 ++-- generic-pc/glfb.h | 9 ++++----- generic-pc/video.cpp | 4 ++-- generic-pc/video_lib.h | 9 ++++----- 9 files changed, 18 insertions(+), 20 deletions(-) diff --git a/common/Makefile.am b/common/Makefile.am index 86f3517..17395fc 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -31,8 +31,6 @@ endif endif libcommon_la_SOURCES += \ - thread_abstraction.cpp \ - mutex_abstraction.cpp \ lt_debug.cpp \ proc_tools.c \ pwrmngr.cpp diff --git a/common/thread_abstraction.cpp b/common/thread_abstraction.cpp index 271755c..57b7759 100644 --- a/common/thread_abstraction.cpp +++ b/common/thread_abstraction.cpp @@ -30,5 +30,4 @@ void Thread::joinThread() void* Thread::runThread(void* ptr) { ((Thread*)ptr)->run(); - return 0; } diff --git a/generic-pc/Makefile.am b/generic-pc/Makefile.am index baf15da..fd230bd 100644 --- a/generic-pc/Makefile.am +++ b/generic-pc/Makefile.am @@ -9,6 +9,7 @@ AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing AM_LDFLAGS = \ -lglut -lGL -lGLU -lGLEW -lao \ + -lOpenThreads \ @AVFORMAT_LIBS@ \ @AVUTIL_LIBS@ \ @AVCODEC_LIBS@ \ diff --git a/generic-pc/audio.cpp b/generic-pc/audio.cpp index d5605f0..03558f8 100644 --- a/generic-pc/audio.cpp +++ b/generic-pc/audio.cpp @@ -29,6 +29,7 @@ #define lt_debug(args...) _lt_debug(HAL_DEBUG_AUDIO, this, args) #define lt_info(args...) _lt_info(HAL_DEBUG_AUDIO, this, args) +#include extern "C" { #include @@ -104,7 +105,7 @@ int cAudio::Start(void) { lt_debug("%s >\n", __func__); if (! HAL_nodec) - startThread(); + OpenThreads::Thread::start(); lt_debug("%s <\n", __func__); return 0; } @@ -115,7 +116,7 @@ int cAudio::Stop(void) if (thread_started) { thread_started = false; - joinThread(); + OpenThreads::Thread::join(); } lt_debug("%s <\n", __func__); return 0; diff --git a/generic-pc/audio_lib.h b/generic-pc/audio_lib.h index 0670cd9..fc96d27 100644 --- a/generic-pc/audio_lib.h +++ b/generic-pc/audio_lib.h @@ -4,6 +4,7 @@ #define _AUDIO_LIB_H_ #include +#include #include "cs_types.h" typedef enum @@ -37,7 +38,7 @@ typedef enum AUDIO_FMT_ADVANCED = AUDIO_FMT_MLP } AUDIO_FORMAT; -class cAudio : public Thread +class cAudio : public OpenThreads::Thread { friend class cPlayback; private: diff --git a/generic-pc/glfb.cpp b/generic-pc/glfb.cpp index fa35e88..099f213 100644 --- a/generic-pc/glfb.cpp +++ b/generic-pc/glfb.cpp @@ -97,7 +97,7 @@ GLFramebuffer::GLFramebuffer(int x, int y): mReInit(true), mShutDown(false), mIn if (input_fd < 0) lt_info("%s: could not open /tmp/neutrino.input FIFO: %m\n", __func__); initKeys(); - startThread(); + OpenThreads::Thread::start(); while (!mInitDone) usleep(1); } @@ -105,7 +105,7 @@ GLFramebuffer::GLFramebuffer(int x, int y): mReInit(true), mShutDown(false), mIn GLFramebuffer::~GLFramebuffer() { mShutDown = true; - joinThread(); + OpenThreads::Thread::join(); if (input_fd >= 0) close(input_fd); } diff --git a/generic-pc/glfb.h b/generic-pc/glfb.h index aa4017d..78376ba 100644 --- a/generic-pc/glfb.h +++ b/generic-pc/glfb.h @@ -18,9 +18,8 @@ #ifndef __glthread__ #define __glthread__ -#include "../common/thread_abstraction.h" -#include "../common/mutex_abstraction.h" - +#include +#include #include #include #include @@ -31,7 +30,7 @@ extern "C" { #include } -class GLFramebuffer : public Thread +class GLFramebuffer : public OpenThreads::Thread { public: GLFramebuffer(int x, int y); @@ -67,7 +66,7 @@ private: bool mFullscreen; /* fullscreen? */ bool mReInit; /* setup things for GL */ - Mutex mReInitLock; + OpenThreads::Mutex mReInitLock; bool mShutDown; /* if set main loop is left */ bool mInitDone; /* condition predicate */ // OpenThreads::Condition mInitCond; /* condition variable for init */ diff --git a/generic-pc/video.cpp b/generic-pc/video.cpp index 8544e8b..dcfb341 100644 --- a/generic-pc/video.cpp +++ b/generic-pc/video.cpp @@ -145,7 +145,7 @@ int cVideo::Start(void *, unsigned short, unsigned short, void *) { lt_debug("%s running %d >\n", __func__, thread_running); if (!thread_running && !HAL_nodec) - startThread(); + OpenThreads::Thread::start(); lt_debug("%s running %d <\n", __func__, thread_running); return 0; } @@ -155,7 +155,7 @@ int cVideo::Stop(bool) lt_debug("%s running %d >\n", __func__, thread_running); if (thread_running) { thread_running = false; - joinThread(); + OpenThreads::Thread::join(); } lt_debug("%s running %d <\n", __func__, thread_running); return 0; diff --git a/generic-pc/video_lib.h b/generic-pc/video_lib.h index 2b8e14e..ca130f5 100644 --- a/generic-pc/video_lib.h +++ b/generic-pc/video_lib.h @@ -1,8 +1,8 @@ #ifndef _VIDEO_LIB_H #define _VIDEO_LIB_H -#include "../common/thread_abstraction.h" -#include "../common/mutex_abstraction.h" +#include +#include #include #include #include "cs_types.h" @@ -121,7 +121,7 @@ typedef enum #define VDEC_MAXBUFS 0x30 -class cVideo : public Thread +class cVideo : public OpenThreads::Thread { friend class GLFramebuffer; friend class cDemux; @@ -211,8 +211,7 @@ class cVideo : public Thread bool thread_running; VIDEO_FORMAT v_format; VIDEO_STD v_std; - //OpenThreads::Mutex buf_m; - Mutex buf_m; + OpenThreads::Mutex buf_m; DISPLAY_AR display_aspect; DISPLAY_AR_MODE display_crop; int output_h; From 5de36fbbd0efc8f23753f84ee7b61a8b7decbdf0 Mon Sep 17 00:00:00 2001 From: max_10 Date: Thu, 20 Sep 2018 17:45:31 +0200 Subject: [PATCH 17/59] Revert "add mutex and thread abstraction to common files" This reverts commit 65ee259b43a521e42464d728d5d9953067446184. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/b08367d83a974543d13949423cbafb72a66658b1 Author: max_10 Date: 2018-09-20 (Thu, 20 Sep 2018) ------------------ This commit was generated by Migit --- {common => generic-pc}/mutex_abstraction.cpp | 0 {common => generic-pc}/mutex_abstraction.h | 0 {common => generic-pc}/thread_abstraction.cpp | 0 {common => generic-pc}/thread_abstraction.h | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {common => generic-pc}/mutex_abstraction.cpp (100%) rename {common => generic-pc}/mutex_abstraction.h (100%) rename {common => generic-pc}/thread_abstraction.cpp (100%) rename {common => generic-pc}/thread_abstraction.h (100%) diff --git a/common/mutex_abstraction.cpp b/generic-pc/mutex_abstraction.cpp similarity index 100% rename from common/mutex_abstraction.cpp rename to generic-pc/mutex_abstraction.cpp diff --git a/common/mutex_abstraction.h b/generic-pc/mutex_abstraction.h similarity index 100% rename from common/mutex_abstraction.h rename to generic-pc/mutex_abstraction.h diff --git a/common/thread_abstraction.cpp b/generic-pc/thread_abstraction.cpp similarity index 100% rename from common/thread_abstraction.cpp rename to generic-pc/thread_abstraction.cpp diff --git a/common/thread_abstraction.h b/generic-pc/thread_abstraction.h similarity index 100% rename from common/thread_abstraction.h rename to generic-pc/thread_abstraction.h From ebf636489696e1402a28ff29c3e94b6df58b6062 Mon Sep 17 00:00:00 2001 From: max_10 Date: Thu, 20 Sep 2018 17:45:51 +0200 Subject: [PATCH 18/59] Revert "add mutex and thread abstraction" This reverts commit e36707596a774f4bb8511a78e3e2abf13c2cd823. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/bdf8de2c4246a7bc6a2d0cb6f0ded82de356e87d Author: max_10 Date: 2018-09-20 (Thu, 20 Sep 2018) ------------------ This commit was generated by Migit --- generic-pc/mutex_abstraction.cpp | 22 --------------------- generic-pc/mutex_abstraction.h | 20 ------------------- generic-pc/thread_abstraction.cpp | 33 ------------------------------- generic-pc/thread_abstraction.h | 25 ----------------------- 4 files changed, 100 deletions(-) delete mode 100644 generic-pc/mutex_abstraction.cpp delete mode 100644 generic-pc/mutex_abstraction.h delete mode 100644 generic-pc/thread_abstraction.cpp delete mode 100644 generic-pc/thread_abstraction.h diff --git a/generic-pc/mutex_abstraction.cpp b/generic-pc/mutex_abstraction.cpp deleted file mode 100644 index a5a886f..0000000 --- a/generic-pc/mutex_abstraction.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "mutex_abstraction.h" - -Mutex::Mutex() : - mMutex() -{ - pthread_mutex_init(&mMutex, 0); -} - -Mutex::~Mutex() -{ - pthread_mutex_destroy(&mMutex); -} - -void Mutex::lock() -{ - pthread_mutex_lock(&mMutex); -} - -void Mutex::unlock() -{ - pthread_mutex_unlock(&mMutex); -} diff --git a/generic-pc/mutex_abstraction.h b/generic-pc/mutex_abstraction.h deleted file mode 100644 index c2b78d8..0000000 --- a/generic-pc/mutex_abstraction.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _MUTEX_ABSTRACTION_H -#define _MUTEX_ABSTRACTION_H - -#include - -class Mutex -{ - pthread_mutex_t mMutex; - - Mutex(const Mutex&); - const Mutex& operator=(const Mutex&); - - public: - Mutex(); - virtual ~Mutex(); - void lock(); - void unlock(); -}; - -#endif diff --git a/generic-pc/thread_abstraction.cpp b/generic-pc/thread_abstraction.cpp deleted file mode 100644 index 57b7759..0000000 --- a/generic-pc/thread_abstraction.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "thread_abstraction.h" - -Thread::Thread() : - mIsRunning(false), - mThread() -{ -} - -Thread::~Thread() -{ - // if thread is still running on object destruction, cancel thread the hard way: - if (mIsRunning) - { - pthread_cancel(mThread); - } -} - -void Thread::startThread() -{ - mIsRunning = true; - pthread_create(&mThread, 0, &Thread::runThread, this); -} - -void Thread::joinThread() -{ - pthread_join(mThread, 0); - mIsRunning = false; -} - -void* Thread::runThread(void* ptr) -{ - ((Thread*)ptr)->run(); -} diff --git a/generic-pc/thread_abstraction.h b/generic-pc/thread_abstraction.h deleted file mode 100644 index 3c3e35f..0000000 --- a/generic-pc/thread_abstraction.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _THREAD_ABSTRACTION_H -#define _THREAD_ABSTRACTION_H - -#include - -class Thread -{ - bool mIsRunning; - pthread_t mThread; - - static void* runThread(void*); - Thread(const Thread&); - const Thread& operator=(const Thread&); - - public: - Thread(); - ~Thread(); - void startThread(); - void joinThread(); - - protected: - virtual void run() = 0; -}; - -#endif From 577642d431d5e36fde61ebbcad7339eb5e0986eb Mon Sep 17 00:00:00 2001 From: max_10 Date: Thu, 20 Sep 2018 18:18:46 +0200 Subject: [PATCH 19/59] fix mutex revert Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/b7d195ecaa9e37a1fe66f00c80f7aa3a634150d0 Author: max_10 Date: 2018-09-20 (Thu, 20 Sep 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- generic-pc/audio_lib.h | 2 +- generic-pc/video_lib.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generic-pc/audio_lib.h b/generic-pc/audio_lib.h index fc96d27..375208c 100644 --- a/generic-pc/audio_lib.h +++ b/generic-pc/audio_lib.h @@ -4,7 +4,7 @@ #define _AUDIO_LIB_H_ #include -#include +#include #include "cs_types.h" typedef enum diff --git a/generic-pc/video_lib.h b/generic-pc/video_lib.h index ca130f5..694965c 100644 --- a/generic-pc/video_lib.h +++ b/generic-pc/video_lib.h @@ -220,7 +220,7 @@ class cVideo : public OpenThreads::Thread int pig_w; int pig_h; bool pig_changed; - Mutex still_m; + OpenThreads::Mutex still_m; bool stillpicture; }; From 253e5cd4a991272d3c59dd881ac1a1c8534e5482 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Tue, 14 Mar 2017 21:31:02 +0100 Subject: [PATCH 20/59] fix audio video rate info Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/1d4329a505dfd0ace9f91d3080cb9828e30f0790 Author: Jacek Jendrzej Date: 2017-03-14 (Tue, 14 Mar 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- generic-pc/audio.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/generic-pc/audio.cpp b/generic-pc/audio.cpp index 03558f8..54d5457 100644 --- a/generic-pc/audio.cpp +++ b/generic-pc/audio.cpp @@ -203,7 +203,30 @@ void cAudio::getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &m bitrate = 0; /* not used, but easy to get :-) */ mode = 0; /* default: stereo */ if (c) { - type = (c->codec_id != AV_CODEC_ID_MP2); /* only mpeg / not mpeg is indicated */ + switch (c->codec_id) { + case AV_CODEC_ID_MP2: + type = AUDIO_FMT_MPEG; + break; + case AV_CODEC_ID_MP3: + type = AUDIO_FMT_MP3; + break; + case AV_CODEC_ID_AC3: + case AV_CODEC_ID_TRUEHD: + type = AUDIO_FMT_DOLBY_DIGITAL; + break; + case AV_CODEC_ID_EAC3: + type = AUDIO_FMT_DD_PLUS; + break; + case AV_CODEC_ID_AAC: + type = AUDIO_FMT_AAC; + break; + case AV_CODEC_ID_DTS: + type = AUDIO_FMT_DTS; + break; + case AV_CODEC_ID_MLP: + type = AUDIO_FMT_MLP; + break; + } freq = c->sample_rate; bitrate = c->bit_rate; if (c->channels == 1) From 08fdcf16d28761c68ece422108493fb8881ba64f Mon Sep 17 00:00:00 2001 From: vanhofen Date: Fri, 17 Mar 2017 11:19:27 +0100 Subject: [PATCH 21/59] generic-pc/audio.cpp: add default-section to c->codec_id switch ... to avoid compiler warnings Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/8a87094b11009bf27b2e2cf445b8b7ee8dbf7a24 Author: vanhofen Date: 2017-03-17 (Fri, 17 Mar 2017) Origin message was: ------------------ - generic-pc/audio.cpp: add default-section to c->codec_id switch ... to avoid compiler warnings ------------------ This commit was generated by Migit --- generic-pc/audio.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/generic-pc/audio.cpp b/generic-pc/audio.cpp index 54d5457..862bf2b 100644 --- a/generic-pc/audio.cpp +++ b/generic-pc/audio.cpp @@ -225,7 +225,9 @@ void cAudio::getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &m break; case AV_CODEC_ID_MLP: type = AUDIO_FMT_MLP; - break; + break; + default: + break; } freq = c->sample_rate; bitrate = c->bit_rate; From ec4c40fbc171a8ac98172afbc3583d288b48c229 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 21 Oct 2013 17:44:31 +0200 Subject: [PATCH 22/59] generic-pc: don't crash in getAudioInfo if no codec is set Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/9a5bc535b4fa7c626806470f1237cfaddfef3812 Author: Stefan Seyfried Date: 2013-10-21 (Mon, 21 Oct 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- generic-pc/audio.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generic-pc/audio.cpp b/generic-pc/audio.cpp index 862bf2b..e3ea30a 100644 --- a/generic-pc/audio.cpp +++ b/generic-pc/audio.cpp @@ -202,6 +202,7 @@ void cAudio::getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &m freq = 0; bitrate = 0; /* not used, but easy to get :-) */ mode = 0; /* default: stereo */ + printf("cAudio::getAudioInfo c %p\n", c); if (c) { switch (c->codec_id) { case AV_CODEC_ID_MP2: @@ -266,7 +267,7 @@ void cAudio::getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &m } } lt_debug("%s t: %d l: %d f: %d b: %d m: %d codec_id: %x\n", - __func__, type, layer, freq, bitrate, mode, c ? c->codec_id : 0); + __func__, type, layer, freq, bitrate, mode, c?c->codec_id:-1); }; void cAudio::SetSRS(int /*iq_enable*/, int /*nmgr_enable*/, int /*iq_mode*/, int /*iq_level*/) From 02694ca7365ad3cb698a523bb75d152723fba582 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 30 Oct 2016 13:08:34 +0100 Subject: [PATCH 23/59] generic-pc: add alternative clutter based framebuffer Add a framebuffer implementation based on clutter instead of "raw" OpenGL. The performance is slightly worse, but it might bring some platform abstraction and other benefits for the future. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/c8c7f0c45feea4b263760a60e83fa585fccd166a Author: Stefan Seyfried Date: 2016-10-30 (Sun, 30 Oct 2016) ------------------ This commit was generated by Migit --- configure.ac | 15 ++ generic-pc/Makefile.am | 22 +- generic-pc/clutterfb.cpp | 481 +++++++++++++++++++++++++++++++++++++++ generic-pc/glfb.cpp | 1 + generic-pc/glfb.h | 33 ++- generic-pc/video.cpp | 20 +- 6 files changed, 553 insertions(+), 19 deletions(-) create mode 100644 generic-pc/clutterfb.cpp diff --git a/configure.ac b/configure.ac index cac007d..aad1437 100644 --- a/configure.ac +++ b/configure.ac @@ -20,6 +20,18 @@ AC_DISABLE_STATIC AC_SYS_LARGEFILE AC_PROG_LIBTOOL +AC_ARG_ENABLE(clutter, + AS_HELP_STRING(--enable-clutter, use clutter instead of OpenGL), + ,[enable_clutter=no]) + +AM_CONDITIONAL(USE_CLUTTER,test "$enable_clutter" = "yes") +AM_CONDITIONAL(USE_OPENGL,test "$enable_clutter" = "no") +if test "$enable_clutter" = "yes"; then + AC_DEFINE(USE_CLUTTER,1,[use clutter instead of opengl]) +else + AC_DEFINE(USE_OPENGL,1,[use opengl instead of clutter]) +fi + if test x"$BOXTYPE" = x"tripledragon"; then PKG_CHECK_MODULES([DIRECTFB], [directfb]) fi @@ -54,6 +66,9 @@ if test x$BOXTYPE = xarmbox -a "$enable_gstreamer_10" = "yes"; then fi if test x$BOXTYPE = xgeneric -a x$BOXMODEL != xraspi; then + if test x"$enable_clutter" = xyes; then + PKG_CHECK_MODULES([CLUTTER], [clutter-1.0]) + fi PKG_CHECK_MODULES([AVFORMAT], [libavformat >= 53.21.1]) PKG_CHECK_MODULES([AVCODEC], [libavcodec >= 54.28.0]) # don't know which version is exactly needed here... diff --git a/generic-pc/Makefile.am b/generic-pc/Makefile.am index fd230bd..e2b6a5e 100644 --- a/generic-pc/Makefile.am +++ b/generic-pc/Makefile.am @@ -1,30 +1,44 @@ noinst_LTLIBRARIES = libgeneric.la AM_CPPFLAGS = -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS +AM_CPPFLAGS += -Wfatal-errors AM_CPPFLAGS += \ -I$(top_srcdir)/common \ - -I$(top_srcdir)/include + -I$(top_srcdir)/include \ + @AVUTIL_CFLAGS@ \ + @CLUTTER_CFLAGS@ AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing AM_LDFLAGS = \ - -lglut -lGL -lGLU -lGLEW -lao \ + -lao \ -lOpenThreads \ @AVFORMAT_LIBS@ \ @AVUTIL_LIBS@ \ @AVCODEC_LIBS@ \ @SWRESAMPLE_LIBS@ \ - @SWSCALE_LIBS@ + @SWSCALE_LIBS@ \ + @CLUTTER_LIBS@ + +if USE_OPENGL +AM_LDFLAGS += -lglut -lGL -lGLU -lGLEW -lao +endif libgeneric_la_SOURCES = \ hardware_caps.c \ dmx.cpp \ video.cpp \ audio.cpp \ - glfb.cpp \ init.cpp \ record.cpp +if USE_CLUTTER +libgeneric_la_SOURCES += clutterfb.cpp +endif +if USE_OPENGL +libgeneric_la_SOURCES += glfb.cpp +endif + if ENABLE_GSTREAMER_01 libgeneric_la_SOURCES += \ playback_gst_01.cpp diff --git a/generic-pc/clutterfb.cpp b/generic-pc/clutterfb.cpp new file mode 100644 index 0000000..2c61def --- /dev/null +++ b/generic-pc/clutterfb.cpp @@ -0,0 +1,481 @@ +/* + Framebuffer implementation using clutter https://developer.gnome.org/clutter/ + Copyright (C) 2016 Stefan Seyfried + + based on the openGL framebuffer implementation + Copyright 2010 Carsten Juttner + Copyright 2012,2013 Stefan Seyfried + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + TODO: AV-Sync code is "experimental" at best +*/ + +#include "config.h" +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include "glfb_priv.h" +#include "video_priv.h" +#include "audio_priv.h" + +#include + +#include "lt_debug.h" + +#define lt_debug_c(args...) _lt_debug(HAL_DEBUG_INIT, NULL, args) +#define lt_info_c(args...) _lt_info(HAL_DEBUG_INIT, NULL, args) +#define lt_debug(args...) _lt_debug(HAL_DEBUG_INIT, this, args) +#define lt_info(args...) _lt_info(HAL_DEBUG_INIT, this, args) + + +extern VDec *vdec; +extern ADec *adec; + +/* the private class that does stuff only needed inside libstb-hal. + * is used e.g. by cVideo... */ +GLFbPC *glfb_priv = NULL; + +GLFramebuffer::GLFramebuffer(int x, int y) +{ + Init(); + glfb_priv = new GLFbPC(x, y, osd_buf); + si = glfb_priv->getScreenInfo(); + start(); + while (!glfb_priv->mInitDone) + usleep(1); +} + +GLFramebuffer::~GLFramebuffer() +{ + glfb_priv->mShutDown = true; + join(); + delete glfb_priv; + glfb_priv = NULL; +} + +void GLFramebuffer::blit() +{ + glfb_priv->blit(); +} + +GLFbPC::GLFbPC(int x, int y, std::vector &buf): mReInit(true), mShutDown(false), mInitDone(false) +{ + osd_buf = &buf; + mState.width = x; + mState.height = y; + mX = &_mX[0]; + mY = &_mY[0]; + *mX = x; + *mY = y; + av_reduce(&mOA.num, &mOA.den, x, y, INT_MAX); + mVA = mOA; /* initial aspect ratios are from the FB resolution, those */ + _mVA = mVA; /* will be updated by the videoDecoder functions anyway */ + mVAchanged = true; + mCrop = DISPLAY_AR_MODE_PANSCAN; + zoom = 1.0; + xscale = 1.0; + const char *tmp = getenv("GLFB_FULLSCREEN"); + mFullscreen = !!(tmp); + + mState.blit = true; + last_apts = 0; + + /* linux framebuffer compat mode */ + si.bits_per_pixel = 32; + si.xres = mState.width; + si.xres_virtual = si.xres; + si.yres = mState.height; + si.yres_virtual = si.yres; + si.blue.length = 8; + si.blue.offset = 0; + si.green.length = 8; + si.green.offset = 8; + si.red.length = 8; + si.red.offset = 16; + si.transp.length = 8; + si.transp.offset = 24; + + unlink("/tmp/neutrino.input"); + mkfifo("/tmp/neutrino.input", 0600); + input_fd = open("/tmp/neutrino.input", O_RDWR|O_CLOEXEC|O_NONBLOCK); + if (input_fd < 0) + lt_info("%s: could not open /tmp/neutrino.input FIFO: %m\n", __func__); + initKeys(); +} + +GLFbPC::~GLFbPC() +{ + mShutDown = true; + if (input_fd >= 0) + close(input_fd); + osd_buf->clear(); +} + +void GLFbPC::initKeys() +{ + mKeyMap[CLUTTER_KEY_Up] = KEY_UP; + mKeyMap[CLUTTER_KEY_Down] = KEY_DOWN; + mKeyMap[CLUTTER_KEY_Left] = KEY_LEFT; + mKeyMap[CLUTTER_KEY_Right] = KEY_RIGHT; + + mKeyMap[CLUTTER_KEY_F1] = KEY_RED; + mKeyMap[CLUTTER_KEY_F2] = KEY_GREEN; + mKeyMap[CLUTTER_KEY_F3] = KEY_YELLOW; + mKeyMap[CLUTTER_KEY_F4] = KEY_BLUE; + + mKeyMap[CLUTTER_KEY_F5] = KEY_WWW; + mKeyMap[CLUTTER_KEY_F6] = KEY_SUBTITLE; + mKeyMap[CLUTTER_KEY_F7] = KEY_MOVE; + mKeyMap[CLUTTER_KEY_F8] = KEY_SLEEP; + + mKeyMap[CLUTTER_KEY_Page_Up] = KEY_PAGEUP; + mKeyMap[CLUTTER_KEY_Page_Down] = KEY_PAGEDOWN; + + mKeyMap[CLUTTER_KEY_Return] = KEY_OK; + mKeyMap[CLUTTER_KEY_Escape] = KEY_EXIT; + mKeyMap['e'] = KEY_EPG; + mKeyMap['i'] = KEY_INFO; + mKeyMap['m'] = KEY_MENU; + + mKeyMap['+'] = KEY_VOLUMEUP; + mKeyMap['-'] = KEY_VOLUMEDOWN; + mKeyMap['.'] = KEY_MUTE; + mKeyMap['h'] = KEY_HELP; + mKeyMap['p'] = KEY_POWER; + + mKeyMap['0'] = KEY_0; + mKeyMap['1'] = KEY_1; + mKeyMap['2'] = KEY_2; + mKeyMap['3'] = KEY_3; + mKeyMap['4'] = KEY_4; + mKeyMap['5'] = KEY_5; + mKeyMap['6'] = KEY_6; + mKeyMap['7'] = KEY_7; + mKeyMap['8'] = KEY_8; + mKeyMap['9'] = KEY_9; +} + +static ClutterActor *stage = NULL; +static ClutterActor *fb_actor = NULL; +static ClutterActor *vid_actor = NULL; +static ClutterTimeline *tl = NULL; +void GLFramebuffer::run() +{ + int argc = 1; + int x = glfb_priv->mState.width; + int y = glfb_priv->mState.height; + /* some dummy commandline for GLUT to be happy */ + char *a = (char *)"neutrino"; + char **argv = (char **)malloc(sizeof(char *) * 2); + argv[0] = a; + argv[1] = NULL; + lt_info("GLFB: GL thread starting x %d y %d\n", x, y); + if (clutter_init(&argc, &argv) != CLUTTER_INIT_SUCCESS) { + lt_info("GLFB: error initializing clutter\n"); + return; + } + lt_info("GLFB: %s:%d\n", __func__, __LINE__); + ClutterColor stage_color = { 0, 0, 0, 255 }; + stage = clutter_stage_new(); + clutter_actor_set_size(stage, x, y); + clutter_actor_set_background_color(stage, &stage_color); + clutter_actor_set_content_gravity(stage, CLUTTER_CONTENT_GRAVITY_RESIZE_ASPECT); + //g_signal_connect(stage, "destroy", G_CALLBACK(clutter_main_quit), NULL); + g_signal_connect(stage, "key-press-event", G_CALLBACK(GLFbPC::keyboardcb), (void *)1); + g_signal_connect(stage, "key-release-event", G_CALLBACK(GLFbPC::keyboardcb), NULL); + clutter_stage_set_user_resizable(CLUTTER_STAGE (stage), TRUE); + clutter_actor_grab_key_focus(stage); + clutter_actor_show(stage); + + /* 32bit FB depth, *2 because tuxtxt uses a shadow buffer */ + int fbmem = x * y * 4 * 2; + osd_buf.resize(fbmem); + lt_info("GLFB: OSD buffer set to %d bytes at 0x%p\n", fbmem, osd_buf.data()); + + /* video plane is below FB plane, so it comes first */ + vid_actor = clutter_actor_new(); + ClutterContent *fb = clutter_image_new(); + /* osd_buf, because it starts up black */ + if (!clutter_image_set_data(CLUTTER_IMAGE(fb), osd_buf.data(), COGL_PIXEL_FORMAT_BGR_888, x, y, x*3, NULL)) { + lt_info("GLFB::%s clutter_image_set_data failed? (vid)\n", __func__); + _exit(1); /* life is hard */ + } + clutter_actor_set_content(vid_actor, fb); + g_object_unref(fb); + clutter_actor_set_size(vid_actor, x, y); + clutter_actor_set_position(vid_actor, 0, 0); + clutter_actor_add_constraint(vid_actor, clutter_bind_constraint_new(stage, CLUTTER_BIND_WIDTH, 0)); + clutter_actor_add_constraint(vid_actor, clutter_bind_constraint_new(stage, CLUTTER_BIND_HEIGHT, 0)); + clutter_actor_add_constraint(vid_actor, clutter_bind_constraint_new(stage, CLUTTER_BIND_X, 0)); + clutter_actor_add_constraint(vid_actor, clutter_bind_constraint_new(stage, CLUTTER_BIND_Y, 0)); + clutter_actor_set_content_gravity(vid_actor, CLUTTER_CONTENT_GRAVITY_RESIZE_ASPECT); + clutter_actor_set_pivot_point(vid_actor, 0.5, 0.5); + clutter_actor_add_child(stage, vid_actor); + clutter_actor_show(vid_actor); + + fb_actor = clutter_actor_new(); + fb = clutter_image_new(); + if (!clutter_image_set_data(CLUTTER_IMAGE(fb), osd_buf.data(), COGL_PIXEL_FORMAT_BGRA_8888, x, y, x*4, NULL)) { + lt_info("GLFB::%s clutter_image_set_data failed? (osd)\n", __func__); + _exit(1); /* life is hard */ + } + clutter_actor_set_content(fb_actor, fb); + g_object_unref(fb); + clutter_actor_set_size(fb_actor, x, y); + clutter_actor_set_position(fb_actor, 0, 0); + clutter_actor_add_constraint(fb_actor, clutter_bind_constraint_new(stage, CLUTTER_BIND_WIDTH, 0)); + clutter_actor_add_constraint(fb_actor, clutter_bind_constraint_new(stage, CLUTTER_BIND_HEIGHT, 0)); + clutter_actor_add_constraint(fb_actor, clutter_bind_constraint_new(stage, CLUTTER_BIND_X, 0)); + clutter_actor_add_constraint(fb_actor, clutter_bind_constraint_new(stage, CLUTTER_BIND_Y, 0)); + clutter_actor_set_content_gravity(fb_actor, CLUTTER_CONTENT_GRAVITY_RESIZE_ASPECT); + clutter_actor_add_child(stage, fb_actor); + clutter_actor_show(fb_actor); + + glfb_priv->mInitDone = true; /* signal that setup is finished */ + tl = clutter_timeline_new(100); + g_signal_connect(tl, "new-frame", G_CALLBACK(GLFbPC::rendercb), NULL); + clutter_timeline_set_repeat_count(tl, -1); + clutter_timeline_start(tl); + clutter_main(); + lt_info("GLFB: GL thread stopping\n"); +} + +/* static */ void GLFbPC::rendercb() +{ + glfb_priv->render(); +} + +/* static */ bool GLFbPC::keyboardcb(ClutterActor * /*actor*/, ClutterEvent *event, gpointer user_data) +{ + guint key = clutter_event_get_key_symbol (event); + int keystate = user_data ? 1 : 0; + lt_info_c("GLFB::%s: 0x%x, %d\n", __func__, key, keystate); + + struct input_event ev; + if (key == 'f' && keystate) + { + lt_info_c("GLFB::%s: toggle fullscreen %s\n", __func__, glfb_priv->mFullscreen?"off":"on"); + glfb_priv->mFullscreen = !(glfb_priv->mFullscreen); + glfb_priv->mReInit = true; + return true; + } + std::map::const_iterator i = glfb_priv->mKeyMap.find(key); + if (i == glfb_priv->mKeyMap.end()) + return true; + ev.code = i->second; + ev.value = keystate; /* key own */ + ev.type = EV_KEY; + gettimeofday(&ev.time, NULL); + lt_debug_c("GLFB::%s: pushing 0x%x\n", __func__, ev.code); + write(glfb_priv->input_fd, &ev, sizeof(ev)); + return true; +} + +int sleep_us = 30000; + +void GLFbPC::render() +{ + if(mShutDown) + clutter_main_quit(); + + mReInitLock.lock(); + if (mReInit) + { + int xoff = 0; + int yoff = 0; + mVAchanged = true; + mReInit = false; +#if 0 + mX = &_mX[mFullscreen]; + mY = &_mY[mFullscreen]; +#endif + *mX = *mY * mOA.num / mOA.den; + if (mFullscreen) { + clutter_stage_set_fullscreen(CLUTTER_STAGE(stage), TRUE); + clutter_actor_show(stage); + clutter_stage_ensure_redraw(CLUTTER_STAGE(stage)); + } else { + clutter_stage_set_fullscreen(CLUTTER_STAGE(stage), FALSE); +// *mX = *mY * mOA.num / mOA.den; + clutter_actor_set_size(stage, *mX, *mY); + } + lt_info("%s: reinit mX:%d mY:%d xoff:%d yoff:%d fs %d\n", + __func__, *mX, *mY, xoff, yoff, mFullscreen); + } + mReInitLock.unlock(); + + bltDisplayBuffer(); /* decoded video stream */ + if (mState.blit) { + /* only blit manually after fb->blit(), this helps to find missed blit() calls */ + mState.blit = false; + lt_debug("GLFB::%s blit!\n", __func__); + bltOSDBuffer(); /* OSD */ + } + + if (mVAchanged) + { + mVAchanged = false; + zoom = 1.0; + float xzoom = 1.0; + //xscale = 1.0; + int cmp = av_cmp_q(mVA, mOA); + const AVRational a149 = { 14, 9 }; + switch (cmp) { + default: + case INT_MIN: /* invalid */ + case 0: /* identical */ + lt_debug("%s: mVA == mOA (or fullscreen mode :-)\n", __func__); + break; + case 1: /* mVA > mOA -- video is wider than display */ + lt_debug("%s: mVA > mOA\n", __func__); + switch (mCrop) { + case DISPLAY_AR_MODE_PANSCAN: + zoom = av_q2d(mVA) / av_q2d(mOA); + break; + case DISPLAY_AR_MODE_LETTERBOX: + break; + case DISPLAY_AR_MODE_PANSCAN2: + zoom = av_q2d(a149) / av_q2d(mOA); + break; + case DISPLAY_AR_MODE_NONE: + xzoom = av_q2d(mOA) / av_q2d(mVA); + zoom = av_q2d(mVA) / av_q2d(mOA); + break; + default: + break; + } + break; + case -1: /* mVA < mOA -- video is taller than display */ + lt_debug("%s: mVA < mOA\n", __func__); + switch (mCrop) { + case DISPLAY_AR_MODE_LETTERBOX: + break; + case DISPLAY_AR_MODE_PANSCAN2: + if (av_cmp_q(a149, mOA) < 0) { + zoom = av_q2d(mVA) * av_q2d(a149) / av_q2d(mOA); + break; + } + /* fallthrough for output format 14:9 */ + case DISPLAY_AR_MODE_PANSCAN: + zoom = av_q2d(mOA) / av_q2d(mVA); + break; + case DISPLAY_AR_MODE_NONE: + xzoom = av_q2d(mOA) / av_q2d(mVA); + break; + default: + break; + } + break; + } + lt_debug("zoom: %f xscale: %f xzoom: %f\n", zoom, xscale,xzoom); + clutter_actor_set_scale(vid_actor, xscale*zoom*xzoom, zoom); + } + clutter_timeline_stop(tl); + clutter_timeline_set_delay(tl, sleep_us/1000); + clutter_timeline_start(tl); +} + +void GLFbPC::bltOSDBuffer() +{ + // lt_info("%s\n", __func__); + int x = glfb_priv->mState.width; + int y = glfb_priv->mState.height; + ClutterContent *fb = clutter_image_new(); + if (!clutter_image_set_data(CLUTTER_IMAGE(fb), osd_buf->data(), COGL_PIXEL_FORMAT_BGRA_8888, x, y, x*4, NULL)) { + lt_info("GLFB::%s clutter_image_set_data failed?\n", __func__); + _exit(1); /* life is hard */ + } + clutter_actor_set_content(fb_actor, fb); + g_object_unref(fb); + clutter_actor_show(fb_actor); +} + +void GLFbPC::bltDisplayBuffer() +{ + // lt_info("GLFB::%s vdec: %p\n", __func__, vdec); + if (!vdec) /* cannot start yet */ + return; + static bool warn = true; + VDec::SWFramebuffer *buf = vdec->getDecBuf(); + if (!buf) { + if (warn) + lt_info("GLFB::%s did not get a buffer...\n", __func__); + warn = false; + return; + } + warn = true; + int w = buf->width(), h = buf->height(); + if (w == 0 || h == 0) + return; + + AVRational a = buf->AR(); + if (a.den != 0 && a.num != 0 && av_cmp_q(a, _mVA)) { + _mVA = a; + /* _mVA is the raw buffer's aspect, mVA is the real scaled output aspect */ + av_reduce(&mVA.num, &mVA.den, w * a.num, h * a.den, INT_MAX); + // mVA.num: 16 mVA.den: 9 w: 720 h: 576 + // 16*576/720/9 = 1.42222 + xscale = (double)mVA.num*h/(double)mVA.den/w; + mVAchanged = true; + } + + ClutterContent *fb = clutter_image_new(); + if (!clutter_image_set_data(CLUTTER_IMAGE(fb), &(*buf)[0], COGL_PIXEL_FORMAT_BGR_888, w, h, w*3, NULL)) { + lt_info("GLFB::%s clutter_image_set_data failed?\n", __func__); + _exit(1); /* life is hard */ + } + clutter_actor_set_content(vid_actor, fb); + g_object_unref(fb); + clutter_actor_show(vid_actor); + + /* "rate control" mechanism starts here... + * this implementation is pretty naive and not working too well, but + * better this than nothing... :-) */ + int64_t apts = 0; + int64_t vpts = buf->pts(); + if (adec) + apts = adec->getPts(); + if (apts != last_apts) { + int rate, dummy1, dummy2; + if (apts < vpts) + sleep_us = (sleep_us * 2 + (vpts - apts)*10/9) / 3; + else if (sleep_us > 1000) + sleep_us -= 1000; + last_apts = apts; + vdec->getPictureInfo(dummy1, dummy2, rate); + if (rate > 0) + rate = 2000000 / rate; /* limit to half the frame rate */ + else + rate = 50000; /* minimum 20 fps */ + if (sleep_us > rate) + sleep_us = rate; + else if (sleep_us < 1) + sleep_us = 1; + } + lt_debug("vpts: 0x%" PRIx64 " apts: 0x%" PRIx64 " diff: %6.3f sleep_us %d buf %d\n", + buf->pts(), apts, (buf->pts() - apts)/90000.0, sleep_us, vdec->buf_num); +} diff --git a/generic-pc/glfb.cpp b/generic-pc/glfb.cpp index 099f213..3811056 100644 --- a/generic-pc/glfb.cpp +++ b/generic-pc/glfb.cpp @@ -22,6 +22,7 @@ TODO: AV-Sync code is "experimental" at best */ +#include "config.h" #include #include diff --git a/generic-pc/glfb.h b/generic-pc/glfb.h index 78376ba..bc7b9f5 100644 --- a/generic-pc/glfb.h +++ b/generic-pc/glfb.h @@ -1,6 +1,6 @@ /* Copyright 2010 Carsten Juttner - Copyright 2012,2013 Stefan Seyfried + Copyright 2012,2013,2016 Stefan Seyfried This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,14 +18,20 @@ #ifndef __glthread__ #define __glthread__ +#include #include #include #include #include +#if USE_OPENGL #include #include #include #include /* for screeninfo etc. */ +#endif +#if USE_CLUTTER +#include +#endif extern "C" { #include } @@ -35,18 +41,15 @@ class GLFramebuffer : public OpenThreads::Thread public: GLFramebuffer(int x, int y); ~GLFramebuffer(); - void run(); std::vector *getOSDBuffer() { return &mOSDBuffer; } /* pointer to OSD bounce buffer */ - int getOSDWidth() { return mState.width; } int getOSDHeight() { return mState.height; } void blit() { mState.blit = true; } - + fb_var_screeninfo getScreenInfo() { return screeninfo; } void setOutputFormat(AVRational a, int h, int c) { mOA = a; *mY = h; mCrop = c; mReInit = true; } void clear(); - fb_var_screeninfo getScreenInfo() { return screeninfo; } int getWindowID() { return GLWinID; } private: @@ -74,33 +77,45 @@ private: std::vector mOSDBuffer; /* silly bounce buffer */ +#if USE_OPENGL std::map mKeyMap; std::map mSpecialMap; +#endif +#if USE_CLUTTER + std::map mKeyMap; +#endif int input_fd; int64_t last_apts; static void rendercb(); /* callback for GLUT */ void render(); /* actual render function */ +#if USE_OPENGL static void keyboardcb(unsigned char key, int x, int y); static void specialcb(int key, int x, int y); static void resizecb(int w, int h); void checkReinit(int w, int h); /* e.g. in case window was resized */ + void setupGLObjects(); /* PBOs, textures and stuff */ + void releaseGLObjects(); + void drawSquare(float size, float x_factor = 1); /* do not be square */ +#endif +#if USE_CLUTTER + static bool keyboardcb(ClutterActor *actor, ClutterEvent *event, gpointer user_data); +#endif void initKeys(); /* setup key bindings for window */ void setupCtx(); /* create the window and make the context current */ void setupOSDBuffer(); /* create the OSD buffer */ - void setupGLObjects(); /* PBOs, textures and stuff */ - void releaseGLObjects(); - void drawSquare(float size, float x_factor = 1); /* do not be square */ struct { int width; /* width and height, fixed for a framebuffer instance */ int height; + bool blit; +#if USE_OPENGL GLuint osdtex; /* holds the OSD texture */ GLuint pbo; /* PBO we use for transfer to texture */ GLuint displaytex; /* holds the display texture */ GLuint displaypbo; - bool blit; +#endif } mState; void bltOSDBuffer(); diff --git a/generic-pc/video.cpp b/generic-pc/video.cpp index dcfb341..8237305 100644 --- a/generic-pc/video.cpp +++ b/generic-pc/video.cpp @@ -23,6 +23,7 @@ * TODO: buffer handling surely needs some locking... */ +#include "config.h" #include #include #include @@ -39,6 +40,13 @@ extern "C" { /* my own buf 256k */ #define DMX_BUF_SZ 0x20000 +#if USE_OPENGL +#define VDEC_PIXFMT AV_PIX_FMT_RGB32 +#endif +#if USE_CLUTTER +#define VDEC_PIXFMT AV_PIX_FMT_BGR24 +#endif + #include "video_lib.h" #include "dmx_hal.h" #include "glfb.h" @@ -294,9 +302,9 @@ void cVideo::ShowPicture(const char *fname) if (avpkt.size > len) lt_info("%s: WARN: pkt->size %d != len %d\n", __func__, avpkt.size, len); if (got_frame) { - unsigned int need = av_image_get_buffer_size(AV_PIX_FMT_RGB32, c->width, c->height, 1); + unsigned int need = av_image_get_buffer_size(VDEC_PIXFMT, c->width, c->height, 1); struct SwsContext *convert = sws_getContext(c->width, c->height, c->pix_fmt, - c->width, c->height, AV_PIX_FMT_RGB32, + c->width, c->height, VDEC_PIXFMT, SWS_BICUBIC, 0, 0, 0); if (!convert) lt_info("%s: ERROR setting up SWS context\n", __func__); @@ -305,7 +313,7 @@ void cVideo::ShowPicture(const char *fname) SWFramebuffer *f = &buffers[buf_in]; if (f->size() < need) f->resize(need); - av_image_fill_arrays(rgbframe->data, rgbframe->linesize, &(*f)[0], AV_PIX_FMT_RGB32, + av_image_fill_arrays(rgbframe->data, rgbframe->linesize, &(*f)[0], VDEC_PIXFMT, c->width, c->height, 1); sws_scale(convert, frame->data, frame->linesize, 0, c->height, rgbframe->data, rgbframe->linesize); @@ -538,10 +546,10 @@ void cVideo::run(void) lt_info("%s: WARN: pkt->size %d != len %d\n", __func__, avpkt.size, len); still_m.lock(); if (got_frame && ! stillpicture) { - unsigned int need = av_image_get_buffer_size(AV_PIX_FMT_RGB32, c->width, c->height, 1); + unsigned int need = av_image_get_buffer_size(VDEC_PIXFMT, c->width, c->height, 1); convert = sws_getCachedContext(convert, c->width, c->height, c->pix_fmt, - c->width, c->height, AV_PIX_FMT_RGB32, + c->width, c->height, VDEC_PIXFMT, SWS_BICUBIC, 0, 0, 0); if (!convert) lt_info("%s: ERROR setting up SWS context\n", __func__); @@ -550,7 +558,7 @@ void cVideo::run(void) SWFramebuffer *f = &buffers[buf_in]; if (f->size() < need) f->resize(need); - av_image_fill_arrays(rgbframe->data, rgbframe->linesize, &(*f)[0], AV_PIX_FMT_RGB32, + av_image_fill_arrays(rgbframe->data, rgbframe->linesize, &(*f)[0], VDEC_PIXFMT, c->width, c->height, 1); sws_scale(convert, frame->data, frame->linesize, 0, c->height, rgbframe->data, rgbframe->linesize); From 119ca4b73df40d63ff73f942e23c5da7e2b887d9 Mon Sep 17 00:00:00 2001 From: max_10 Date: Fri, 21 Sep 2018 19:00:11 +0200 Subject: [PATCH 24/59] generic-pc: rework glfb (thx seife) Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/cf45b803346682c6f9ad0043e25f565e378441f1 Author: max_10 Date: 2018-09-21 (Fri, 21 Sep 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- generic-pc/glfb.cpp | 179 +++++++++++++++++------------ generic-pc/{glfb.h => glfb_priv.h} | 38 +++--- generic-pc/init.cpp | 1 + generic-pc/video.cpp | 33 ++++-- generic-pc/video_lib.h | 4 +- include/glfb.h | 50 ++++++-- 6 files changed, 191 insertions(+), 114 deletions(-) rename generic-pc/{glfb.h => glfb_priv.h} (82%) diff --git a/generic-pc/glfb.cpp b/generic-pc/glfb.cpp index 3811056..19d1f29 100644 --- a/generic-pc/glfb.cpp +++ b/generic-pc/glfb.cpp @@ -38,8 +38,7 @@ #include #include #include -#include "glfb.h" -#include +#include "glfb_priv.h" #include "video_lib.h" #include "audio_lib.h" @@ -54,10 +53,36 @@ extern cVideo *videoDecoder; extern cAudio *audioDecoder; -static GLFramebuffer *gThiz = 0; /* GLUT does not allow for an arbitrary argument to the render func */ +/* the private class that does stuff only needed inside libstb-hal. + * is used e.g. by cVideo... */ +GLFbPC *glfb_priv = NULL; -GLFramebuffer::GLFramebuffer(int x, int y): mReInit(true), mShutDown(false), mInitDone(false) +GLFramebuffer::GLFramebuffer(int x, int y) { + Init(); + glfb_priv = new GLFbPC(x, y, osd_buf); + si = glfb_priv->getScreenInfo(); + start(); + while (!glfb_priv->mInitDone) + usleep(1); +} + +GLFramebuffer::~GLFramebuffer() +{ + glfb_priv->mShutDown = true; + join(); + delete glfb_priv; + glfb_priv = NULL; +} + +void GLFramebuffer::blit() +{ + glfb_priv->blit(); +} + +GLFbPC::GLFbPC(int x, int y, std::vector &buf): mReInit(true), mShutDown(false), mInitDone(false) +{ + osd_buf = &buf; mState.width = x; mState.height = y; mX = &_mX[0]; @@ -78,19 +103,19 @@ GLFramebuffer::GLFramebuffer(int x, int y): mReInit(true), mShutDown(false), mIn last_apts = 0; /* linux framebuffer compat mode */ - screeninfo.bits_per_pixel = 32; - screeninfo.xres = mState.width; - screeninfo.xres_virtual = screeninfo.xres; - screeninfo.yres = mState.height; - screeninfo.yres_virtual = screeninfo.yres; - screeninfo.blue.length = 8; - screeninfo.blue.offset = 0; - screeninfo.green.length = 8; - screeninfo.green.offset = 8; - screeninfo.red.length = 8; - screeninfo.red.offset = 16; - screeninfo.transp.length = 8; - screeninfo.transp.offset = 24; + si.bits_per_pixel = 32; + si.xres = mState.width; + si.xres_virtual = si.xres; + si.yres = mState.height; + si.yres_virtual = si.yres; + si.blue.length = 8; + si.blue.offset = 0; + si.green.length = 8; + si.green.offset = 8; + si.red.length = 8; + si.red.offset = 16; + si.transp.length = 8; + si.transp.offset = 24; unlink("/tmp/neutrino.input"); mkfifo("/tmp/neutrino.input", 0600); @@ -98,21 +123,22 @@ GLFramebuffer::GLFramebuffer(int x, int y): mReInit(true), mShutDown(false), mIn if (input_fd < 0) lt_info("%s: could not open /tmp/neutrino.input FIFO: %m\n", __func__); initKeys(); - OpenThreads::Thread::start(); - while (!mInitDone) - usleep(1); } -GLFramebuffer::~GLFramebuffer() +GLFbPC::~GLFbPC() { mShutDown = true; - OpenThreads::Thread::join(); if (input_fd >= 0) close(input_fd); + osd_buf->clear(); } -void GLFramebuffer::initKeys() +void GLFbPC::initKeys() { + /* + Keep in sync with initKeys() in clutterfb.cpp + */ + mSpecialMap[GLUT_KEY_UP] = KEY_UP; mSpecialMap[GLUT_KEY_DOWN] = KEY_DOWN; mSpecialMap[GLUT_KEY_LEFT] = KEY_LEFT; @@ -133,8 +159,8 @@ void GLFramebuffer::initKeys() mSpecialMap[GLUT_KEY_F11] = KEY_NEXT; mSpecialMap[GLUT_KEY_F12] = KEY_PREVIOUS; - mSpecialMap[GLUT_KEY_PAGE_UP] = KEY_PAGEUP; - mSpecialMap[GLUT_KEY_PAGE_DOWN] = KEY_PAGEDOWN; + mSpecialMap[GLUT_KEY_PAGE_UP] = KEY_PAGEUP; + mSpecialMap[GLUT_KEY_PAGE_DOWN] = KEY_PAGEDOWN; mKeyMap[0x0d] = KEY_OK; mKeyMap[0x1b] = KEY_EXIT; @@ -177,9 +203,21 @@ void GLFramebuffer::initKeys() void GLFramebuffer::run() { - setupCtx(); - setupOSDBuffer(); - mInitDone = true; /* signal that setup is finished */ + int argc = 1; + int x = glfb_priv->mState.width; + int y = glfb_priv->mState.height; + /* some dummy commandline for GLUT to be happy */ + char const *argv[2] = { "neutrino", 0 }; + lt_info("GLFB: GL thread starting x %d y %d\n", x, y); + glutInit(&argc, const_cast(argv)); + glutInitWindowSize(x, y); + glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); + glutCreateWindow("Neutrino"); + /* 32bit FB depth, *2 because tuxtxt uses a shadow buffer */ + int fbmem = x * y * 4 * 2; + osd_buf.resize(fbmem); + lt_info("GLFB: OSD buffer set to %d bytes at 0x%p\n", fbmem, osd_buf.data()); + glfb_priv->mInitDone = true; /* signal that setup is finished */ /* init the good stuff */ GLenum err = glewInit(); @@ -194,16 +232,15 @@ void GLFramebuffer::run() } else { - gThiz = this; glutSetCursor(GLUT_CURSOR_NONE); - glutDisplayFunc(GLFramebuffer::rendercb); - glutKeyboardFunc(GLFramebuffer::keyboardcb); - glutSpecialFunc(GLFramebuffer::specialcb); - glutReshapeFunc(GLFramebuffer::resizecb); - setupGLObjects(); /* needs GLEW prototypes */ + glutDisplayFunc(GLFbPC::rendercb); + glutKeyboardFunc(GLFbPC::keyboardcb); + glutSpecialFunc(GLFbPC::specialcb); + glutReshapeFunc(GLFbPC::resizecb); + glfb_priv->setupGLObjects(); /* needs GLEW prototypes */ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); glutMainLoop(); - releaseGLObjects(); + glfb_priv->releaseGLObjects(); } } else @@ -211,21 +248,20 @@ void GLFramebuffer::run() lt_info("GLFB: GL thread stopping\n"); } - -void GLFramebuffer::setupCtx() +#if 0 +void GLFbPC::setupCtx() { int argc = 1; /* some dummy commandline for GLUT to be happy */ char const *argv[2] = { "neutrino", 0 }; - lt_info("GLFB: GL thread starting\n"); + lt_info("GLFB: GL thread starting x %d y %d\n", mX[0], mY[0]); glutInit(&argc, const_cast(argv)); glutInitWindowSize(mX[0], mY[0]); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow("Neutrino"); - GLWinID = glXGetCurrentDrawable(); // this was the holy grail to get the right window handle for gstreamer :D } -void GLFramebuffer::setupOSDBuffer() +void GLFbPC::setupOSDBuffer() { /* the OSD buffer size can be decoupled from the actual window size since the GL can blit-stretch with no trouble at all, ah, the luxury of ignorance... */ @@ -234,12 +270,13 @@ void GLFramebuffer::setupOSDBuffer() { /* 32bit FB depth, *2 because tuxtxt uses a shadow buffer */ int fbmem = mState.width * mState.height * 4 * 2; - mOSDBuffer.resize(fbmem); - lt_info("GLFB: OSD buffer set to %d bytes\n", fbmem); + osd_buf->resize(fbmem); + lt_info("GLFB: OSD buffer set to %d bytes at 0x%p\n", fbmem, osd_buf->data()); } } +#endif -void GLFramebuffer::setupGLObjects() +void GLFbPC::setupGLObjects() { unsigned char buf[4] = { 0, 0, 0, 0 }; /* 1 black pixel */ glGenTextures(1, &mState.osdtex); @@ -267,7 +304,7 @@ void GLFramebuffer::setupGLObjects() } -void GLFramebuffer::releaseGLObjects() +void GLFbPC::releaseGLObjects() { glDeleteBuffers(1, &mState.pbo); glDeleteBuffers(1, &mState.displaypbo); @@ -276,56 +313,56 @@ void GLFramebuffer::releaseGLObjects() } -/* static */ void GLFramebuffer::rendercb() +/* static */ void GLFbPC::rendercb() { - gThiz->render(); + glfb_priv->render(); } -/* static */ void GLFramebuffer::keyboardcb(unsigned char key, int /*x*/, int /*y*/) +/* static */ void GLFbPC::keyboardcb(unsigned char key, int /*x*/, int /*y*/) { lt_debug_c("GLFB::%s: 0x%x\n", __func__, key); struct input_event ev; if (key == 'f') { - lt_info_c("GLFB::%s: toggle fullscreen %s\n", __func__, gThiz->mFullscreen?"off":"on"); - gThiz->mFullscreen = !(gThiz->mFullscreen); - gThiz->mReInit = true; + lt_info_c("GLFB::%s: toggle fullscreen %s\n", __func__, glfb_priv->mFullscreen?"off":"on"); + glfb_priv->mFullscreen = !(glfb_priv->mFullscreen); + glfb_priv->mReInit = true; return; } - std::map::const_iterator i = gThiz->mKeyMap.find(key); - if (i == gThiz->mKeyMap.end()) + std::map::const_iterator i = glfb_priv->mKeyMap.find(key); + if (i == glfb_priv->mKeyMap.end()) return; ev.code = i->second; ev.value = 1; /* key own */ ev.type = EV_KEY; gettimeofday(&ev.time, NULL); lt_debug_c("GLFB::%s: pushing 0x%x\n", __func__, ev.code); - write(gThiz->input_fd, &ev, sizeof(ev)); + write(glfb_priv->input_fd, &ev, sizeof(ev)); ev.value = 0; /* neutrino is stupid, so push key up directly after key down */ - write(gThiz->input_fd, &ev, sizeof(ev)); + write(glfb_priv->input_fd, &ev, sizeof(ev)); } -/* static */ void GLFramebuffer::specialcb(int key, int /*x*/, int /*y*/) +/* static */ void GLFbPC::specialcb(int key, int /*x*/, int /*y*/) { lt_debug_c("GLFB::%s: 0x%x\n", __func__, key); struct input_event ev; - std::map::const_iterator i = gThiz->mSpecialMap.find(key); - if (i == gThiz->mSpecialMap.end()) + std::map::const_iterator i = glfb_priv->mSpecialMap.find(key); + if (i == glfb_priv->mSpecialMap.end()) return; ev.code = i->second; ev.value = 1; ev.type = EV_KEY; gettimeofday(&ev.time, NULL); lt_debug_c("GLFB::%s: pushing 0x%x\n", __func__, ev.code); - write(gThiz->input_fd, &ev, sizeof(ev)); + write(glfb_priv->input_fd, &ev, sizeof(ev)); ev.value = 0; - write(gThiz->input_fd, &ev, sizeof(ev)); + write(glfb_priv->input_fd, &ev, sizeof(ev)); } int sleep_us = 30000; -void GLFramebuffer::render() +void GLFbPC::render() { if(mShutDown) glutLeaveMainLoop(); @@ -453,12 +490,12 @@ void GLFramebuffer::render() glutPostRedisplay(); } -/* static */ void GLFramebuffer::resizecb(int w, int h) +/* static */ void GLFbPC::resizecb(int w, int h) { - gThiz->checkReinit(w, h); + glfb_priv->checkReinit(w, h); } -void GLFramebuffer::checkReinit(int x, int y) +void GLFbPC::checkReinit(int x, int y) { static int last_x = 0, last_y = 0; @@ -478,7 +515,7 @@ void GLFramebuffer::checkReinit(int x, int y) last_y = y; } -void GLFramebuffer::drawSquare(float size, float x_factor) +void GLFbPC::drawSquare(float size, float x_factor) { GLfloat vertices[] = { 1.0f, 1.0f, @@ -534,11 +571,11 @@ void GLFramebuffer::drawSquare(float size, float x_factor) } -void GLFramebuffer::bltOSDBuffer() +void GLFbPC::bltOSDBuffer() { /* FIXME: copy each time */ glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mState.pbo); - glBufferData(GL_PIXEL_UNPACK_BUFFER, mOSDBuffer.size(), &mOSDBuffer[0], GL_STREAM_DRAW_ARB); + glBufferData(GL_PIXEL_UNPACK_BUFFER, osd_buf->size(), osd_buf->data(), GL_STREAM_DRAW_ARB); glBindTexture(GL_TEXTURE_2D, mState.osdtex); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mState.width, mState.height, GL_BGRA, GL_UNSIGNED_BYTE, 0); @@ -546,7 +583,7 @@ void GLFramebuffer::bltOSDBuffer() glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); } -void GLFramebuffer::bltDisplayBuffer() +void GLFbPC::bltDisplayBuffer() { if (!videoDecoder) /* cannot start yet */ return; @@ -554,7 +591,7 @@ void GLFramebuffer::bltDisplayBuffer() cVideo::SWFramebuffer *buf = videoDecoder->getDecBuf(); if (!buf) { if (warn) - lt_debug("GLFB::%s did not get a buffer...\n", __func__); + lt_info("GLFB::%s did not get a buffer...\n", __func__); warn = false; return; } @@ -607,9 +644,3 @@ void GLFramebuffer::bltDisplayBuffer() lt_debug("vpts: 0x%" PRIx64 " apts: 0x%" PRIx64 " diff: %6.3f sleep_us %d buf %d\n", buf->pts(), apts, (buf->pts() - apts)/90000.0, sleep_us, videoDecoder->buf_num); } - -void GLFramebuffer::clear() -{ - /* clears front and back buffer */ - memset(&mOSDBuffer[0], 0, mOSDBuffer.size()); -} diff --git a/generic-pc/glfb.h b/generic-pc/glfb_priv.h similarity index 82% rename from generic-pc/glfb.h rename to generic-pc/glfb_priv.h index bc7b9f5..a51545a 100644 --- a/generic-pc/glfb.h +++ b/generic-pc/glfb_priv.h @@ -14,12 +14,14 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . + + ******************************************************************** + private stuff of the GLFB thread that is only used inside libstb-hal + and not exposed to the application. */ -#ifndef __glthread__ -#define __glthread__ -#include -#include +#ifndef __glfb_priv__ +#define __glfb_priv__ #include #include #include @@ -32,28 +34,26 @@ #if USE_CLUTTER #include #endif +#include "glfb.h" extern "C" { #include } -class GLFramebuffer : public OpenThreads::Thread +class GLFbPC { public: - GLFramebuffer(int x, int y); - ~GLFramebuffer(); - void run(); - std::vector *getOSDBuffer() { return &mOSDBuffer; } /* pointer to OSD bounce buffer */ + GLFbPC(int x, int y, std::vector &buf); + ~GLFbPC(); + std::vector *getOSDBuffer() { return osd_buf; } /* pointer to OSD bounce buffer */ int getOSDWidth() { return mState.width; } int getOSDHeight() { return mState.height; } - void blit() { mState.blit = true; } - fb_var_screeninfo getScreenInfo() { return screeninfo; } + void blit() { mState.blit = true; }; + fb_var_screeninfo getScreenInfo() { return si; } void setOutputFormat(AVRational a, int h, int c) { mOA = a; *mY = h; mCrop = c; mReInit = true; } - - void clear(); - int getWindowID() { return GLWinID; } - +/* just make everything public for simplicity - this is only used inside libstb-hal anyway private: - fb_var_screeninfo screeninfo; +*/ + fb_var_screeninfo si; int *mX; int *mY; int _mX[2]; /* output window size */ @@ -65,7 +65,6 @@ private: float zoom; /* for cropping */ float xscale; /* and aspect ratio */ int mCrop; /* DISPLAY_AR_MODE */ - int GLWinID; bool mFullscreen; /* fullscreen? */ bool mReInit; /* setup things for GL */ @@ -75,7 +74,7 @@ private: // OpenThreads::Condition mInitCond; /* condition variable for init */ // mutable OpenThreads::Mutex mMutex; /* lock our data */ - std::vector mOSDBuffer; /* silly bounce buffer */ + std::vector *osd_buf; /* silly bounce buffer */ #if USE_OPENGL std::map mKeyMap; @@ -86,6 +85,7 @@ private: #endif int input_fd; int64_t last_apts; + void run(); static void rendercb(); /* callback for GLUT */ void render(); /* actual render function */ @@ -103,8 +103,10 @@ private: #endif void initKeys(); /* setup key bindings for window */ +#if 0 void setupCtx(); /* create the window and make the context current */ void setupOSDBuffer(); /* create the OSD buffer */ +#endif struct { int width; /* width and height, fixed for a framebuffer instance */ diff --git a/generic-pc/init.cpp b/generic-pc/init.cpp index b641fd8..fa2a01c 100644 --- a/generic-pc/init.cpp +++ b/generic-pc/init.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "init_td.h" diff --git a/generic-pc/video.cpp b/generic-pc/video.cpp index 8237305..be89bf2 100644 --- a/generic-pc/video.cpp +++ b/generic-pc/video.cpp @@ -49,7 +49,7 @@ extern "C" { #include "video_lib.h" #include "dmx_hal.h" -#include "glfb.h" +#include "glfb_priv.h" #include "lt_debug.h" #define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args) #define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args) @@ -57,7 +57,7 @@ extern "C" { cVideo *videoDecoder = NULL; extern cDemux *videoDemux; -extern GLFramebuffer *glfb; +extern GLFbPC *glfb_priv; int system_rev = 0; extern bool HAL_nodec; @@ -111,7 +111,7 @@ int cVideo::setAspectRatio(int vformat, int cropping) if (cropping >= 0) display_crop = (DISPLAY_AR_MODE) cropping; if (display_aspect < DISPLAY_AR_RAW && output_h > 0) /* don't know what to do with this */ - glfb->setOutputFormat(aspect_ratios[display_aspect], output_h, display_crop); + glfb_priv->setOutputFormat(aspect_ratios[display_aspect], output_h, display_crop); return 0; } @@ -222,7 +222,7 @@ int cVideo::SetVideoSystem(int system, bool) // v_std = (VIDEO_STD) system; output_h = h; if (display_aspect < DISPLAY_AR_RAW && output_h > 0) /* don't know what to do with this */ - glfb->setOutputFormat(aspect_ratios[display_aspect], output_h, display_crop); + glfb_priv->setOutputFormat(aspect_ratios[display_aspect], output_h, display_crop); return 0; } @@ -369,6 +369,7 @@ void cVideo::Pig(int x, int y, int w, int h, int /*osd_w*/, int /*osd_h*/, int / pig_y = y; pig_w = w; pig_h = h; + pig_changed = true; } void cVideo::getPictureInfo(int &width, int &height, int &rate) @@ -572,10 +573,18 @@ void cVideo::run(void) f->width(c->width); f->height(c->height); int64_t vpts = av_frame_get_best_effort_timestamp(frame); + /* a/v delay determined experimentally :-) */ +#if USE_OPENGL if (v_format == VIDEO_FORMAT_MPEG2) vpts += 90000*4/10; /* 400ms */ else vpts += 90000*3/10; /* 300ms */ +#endif +#if USE_CLUTTER + /* no idea why there's a difference between OpenGL and clutter rendering... */ + if (v_format == VIDEO_FORMAT_MPEG2) + vpts += 90000*3/10; /* 300ms */ +#endif f->pts(vpts); AVRational a = av_guess_sample_aspect_ratio(avfc, avfc->streams[0], frame); f->AR(a); @@ -675,8 +684,8 @@ bool cVideo::GetScreenImage(unsigned char * &data, int &xres, int &yres, bool ge std::vector *osd = NULL; std::vector s_osd; /* scaled OSD */ int vid_w = 0, vid_h = 0; - int osd_w = glfb->getOSDWidth(); - int osd_h = glfb->getOSDHeight(); + int osd_w = glfb_priv->getOSDWidth(); + int osd_h = glfb_priv->getOSDHeight(); xres = osd_w; yres = osd_h; if (get_video) { @@ -700,24 +709,26 @@ bool cVideo::GetScreenImage(unsigned char * &data, int &xres, int &yres, bool ge yres = osd_h; } if (get_osd) - osd = glfb->getOSDBuffer(); + osd = glfb_priv->getOSDBuffer(); unsigned int need = av_image_get_buffer_size(AV_PIX_FMT_RGB32, xres, yres, 1); data = (unsigned char *)realloc(data, need); /* will be freed by caller */ if (data == NULL) /* out of memory? */ return false; if (get_video) { - //memcpy dont work with copy BGR24 to RGB32 +#if USE_OPENGL //memcpy dont work with copy BGR24 to RGB32 if (vid_w != xres || vid_h != yres){ /* scale video into data... */ - bool ret = swscale(&video[0], data, vid_w, vid_h, xres, yres, AV_PIX_FMT_RGB32); +#endif + bool ret = swscale(&video[0], data, vid_w, vid_h, xres, yres,VDEC_PIXFMT); if(!ret){ free(data); return false; } - //memcpy dont work with copy BGR24 to RGB32 - } else { /* get_video and no fancy scaling needed */ +#if USE_OPENGL //memcpy dont work with copy BGR24 to RGB32 + }else{ /* get_video and no fancy scaling needed */ memcpy(data, &video[0], xres * yres * sizeof(uint32_t)); } +#endif } if (get_osd && (osd_w != xres || osd_h != yres)) { diff --git a/generic-pc/video_lib.h b/generic-pc/video_lib.h index 694965c..1bec147 100644 --- a/generic-pc/video_lib.h +++ b/generic-pc/video_lib.h @@ -120,10 +120,10 @@ typedef enum } VIDEO_CONTROL; -#define VDEC_MAXBUFS 0x30 +#define VDEC_MAXBUFS 0x40 class cVideo : public OpenThreads::Thread { - friend class GLFramebuffer; + friend class GLFbPC; friend class cDemux; private: /* called from GL thread */ diff --git a/include/glfb.h b/include/glfb.h index ea7addd..5b95ce6 100644 --- a/include/glfb.h +++ b/include/glfb.h @@ -1,10 +1,42 @@ -#include -#if HAVE_GENERIC_HARDWARE -#if BOXMODEL_RASPI -#include "../raspi/glfb.h" -#else -#include "../generic-pc/glfb.h" -#endif -#else -#error glfb.h only works with HAVE_GENERIC_HARDWARE defined +/* + Copyright 2010 Carsten Juttner + Copyright 2012,2013 Stefan Seyfried + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef __glfb__ +#define __glfb__ +#include +#include +#include /* for screeninfo etc. */ + +class GLFramebuffer : public OpenThreads::Thread +{ +public: + GLFramebuffer(int x, int y); + ~GLFramebuffer(); + std::vector *getOSDBuffer() { return &osd_buf; } /* pointer to OSD bounce buffer */ + void blit(); + fb_var_screeninfo getScreenInfo() { return si; } + +private: + fb_var_screeninfo si; + std::vector osd_buf; /* silly bounce buffer */ + void run(); /* for OpenThreads::Thread */ + void setup(); + void blit_osd(); + void *pdata; /* not yet used */ +}; #endif From 71fc76a551a079ea8dd7c5bf0ad12703c62bc0ee Mon Sep 17 00:00:00 2001 From: max_10 Date: Mon, 1 Oct 2018 21:59:46 +0200 Subject: [PATCH 25/59] fix segfault subtitles selection - but not yet ready Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/ec76737c0337bb73c05ff730f0eb6a780dec184b Author: max_10 Date: 2018-10-01 (Mon, 01 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/playback_libeplayer3.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libarmbox/playback_libeplayer3.cpp b/libarmbox/playback_libeplayer3.cpp index f5f5d21..12085b7 100644 --- a/libarmbox/playback_libeplayer3.cpp +++ b/libarmbox/playback_libeplayer3.cpp @@ -69,6 +69,7 @@ bool cPlayback::Open(playmode_t PlayMode) { player->output->Command(player, OUTPUT_ADD, (void *)"audio"); player->output->Command(player, OUTPUT_ADD, (void *)"video"); + player->output->Command(player, OUTPUT_ADD, (void *)"subtitle"); } return 0; @@ -249,6 +250,7 @@ bool cPlayback::Stop(void) { player->output->Command(player, OUTPUT_DEL, (void *)"audio"); player->output->Command(player, OUTPUT_DEL, (void *)"video"); + player->output->Command(player, OUTPUT_DEL, (void *)"subtitle"); } if (player && player->playback) From f70994740930b7bc1b53e9b5521141a216672f92 Mon Sep 17 00:00:00 2001 From: redblue-pkt Date: Mon, 1 Oct 2018 21:55:31 +0200 Subject: [PATCH 26/59] fix backward Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/87ffb80f3ddce1ebd999c28e4a2cd002dee65283 Author: redblue-pkt Date: 2018-10-01 (Mon, 01 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3-arm/playback/playback.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/libeplayer3-arm/playback/playback.c b/libeplayer3-arm/playback/playback.c index e2bfd7e..257fb67 100644 --- a/libeplayer3-arm/playback/playback.c +++ b/libeplayer3-arm/playback/playback.c @@ -304,7 +304,7 @@ static int PlaybackPlay(Context_t *context) context->playback->Speed = 0; if (context->container && context->container->selectedContainer) - context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL); + ret = context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL); } else { @@ -568,19 +568,29 @@ static int PlaybackFastBackward(Context_t *context, int *speed) return cERR_PLAYBACK_ERROR; } + PlaybackContinue(context); + if (*speed == 0) { - context->playback->BackWard = 0; - context->playback->Speed = 0; /* reverse end */ + context->playback->isPaused = 0; + //context->playback->isPlaying = 0; + context->playback->isForwarding = 0; + context->playback->BackWard = 0; + context->playback->SlowMotion = 0; + context->playback->Speed = 0; context->output->Command(context, OUTPUT_AUDIOMUTE, "0"); } else { - context->playback->isSeeking = 1; - context->playback->Speed = *speed; - context->playback->BackWard = 1; + context->playback->isPaused = 0; + //context->playback->isPlaying = 0; + context->playback->isForwarding = 0; + context->playback->BackWard = 1; + context->playback->SlowMotion = 0; + context->playback->Speed = *speed; + context->playback->isSeeking = 1; context->output->Command(context, OUTPUT_AUDIOMUTE, "1"); - playback_printf(1, "S %d B %d\n", context->playback->Speed, context->playback->BackWard); + playback_printf(1, "Speed: %d, Backward: %d\n", context->playback->Speed, context->playback->BackWard); } context->output->Command(context, OUTPUT_CLEAR, NULL); From 391fe0c88e0f3dae44b6909ec0d61b8b9db8785c Mon Sep 17 00:00:00 2001 From: TangoCash Date: Tue, 2 Oct 2018 21:25:41 +0200 Subject: [PATCH 27/59] silent output Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/d52aa714ce0bb0cd0a64b1d29b5d6ca8f417d58f Author: TangoCash Date: 2018-10-02 (Tue, 02 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- generic-pc/video.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic-pc/video.cpp b/generic-pc/video.cpp index be89bf2..a9b7550 100644 --- a/generic-pc/video.cpp +++ b/generic-pc/video.cpp @@ -327,7 +327,7 @@ void cVideo::ShowPicture(const char *fname) buf_in %= VDEC_MAXBUFS; buf_num++; if (buf_num > (VDEC_MAXBUFS - 1)) { - lt_info("%s: buf_num overflow\n", __func__); + lt_debug("%s: buf_num overflow\n", __func__); buf_out++; buf_out %= VDEC_MAXBUFS; buf_num--; @@ -604,7 +604,7 @@ void cVideo::run(void) c->time_base.num, c->time_base.den, c->ticks_per_frame, dec_r, av_frame_get_best_effort_timestamp(frame)); } else - lt_info("%s: got_frame: %d stillpicture: %d\n", __func__, got_frame, stillpicture); + lt_debug("%s: got_frame: %d stillpicture: %d\n", __func__, got_frame, stillpicture); still_m.unlock(); av_packet_unref(&avpkt); } From 53b56c3298a6ff6c586f3d314144023d332bf0ae Mon Sep 17 00:00:00 2001 From: TangoCash Date: Tue, 2 Oct 2018 21:29:26 +0200 Subject: [PATCH 28/59] silence ! Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/7a796b445b7a3f06a90be8af514f6639dda2cb29 Author: TangoCash Date: 2018-10-02 (Tue, 02 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- generic-pc/video.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic-pc/video.cpp b/generic-pc/video.cpp index a9b7550..ed0c32a 100644 --- a/generic-pc/video.cpp +++ b/generic-pc/video.cpp @@ -592,7 +592,7 @@ void cVideo::run(void) buf_in %= VDEC_MAXBUFS; buf_num++; if (buf_num > (VDEC_MAXBUFS - 1)) { - lt_info("%s: buf_num overflow\n", __func__); + lt_debug("%s: buf_num overflow\n", __func__); buf_out++; buf_out %= VDEC_MAXBUFS; buf_num--; From 7bcb115a05873780e23a7ce6956abc0c5e0fe309 Mon Sep 17 00:00:00 2001 From: Frankenstone Date: Tue, 2 Oct 2018 20:19:04 +0200 Subject: [PATCH 29/59] workaround arm hardware, timshift time in vfd - thx DBoxOldie Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/ccc243eafeb5f1d7792c014391e91c09c15c1a19 Author: Frankenstone Date: 2018-10-02 (Tue, 02 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/playback_libeplayer3.cpp | 11 +++++++++++ libarmbox/playback_libeplayer3.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/libarmbox/playback_libeplayer3.cpp b/libarmbox/playback_libeplayer3.cpp index 12085b7..b782ec2 100644 --- a/libarmbox/playback_libeplayer3.cpp +++ b/libarmbox/playback_libeplayer3.cpp @@ -42,6 +42,8 @@ bool cPlayback::Open(playmode_t PlayMode) } pm = PlayMode; + got_vpts_ts = false; + vpts_ts = 0; fn_ts = ""; fn_xml = ""; last_size = 0; @@ -448,6 +450,15 @@ bool cPlayback::GetPosition(int &position, int &duration) } else { + /* workaround for crazy vpts value during timeshift */ + if (!got_vpts_ts && pm == PLAYMODE_TS) + { + vpts_ts = vpts; + got_vpts_ts = true; + } + if (got_vpts_ts) + vpts -= vpts_ts; + /* end workaround */ /* len is in nanoseconds. we have 90 000 pts per second. */ position = vpts / 90; } diff --git a/libarmbox/playback_libeplayer3.h b/libarmbox/playback_libeplayer3.h index 29035b4..33a9471 100644 --- a/libarmbox/playback_libeplayer3.h +++ b/libarmbox/playback_libeplayer3.h @@ -20,10 +20,12 @@ class cPlayback bool enabled; bool playing, first; bool no_probe; + bool got_vpts_ts; int nPlaybackSpeed; int mAudioStream; int mSubtitleStream; int mTeletextStream; + int64_t vpts_ts; bool Stop(void); bool decoders_closed; playmode_t pm; From 2cb76a9232a6940087b66cfffc824ad04c227f2f Mon Sep 17 00:00:00 2001 From: BPanther Date: Sun, 2 Sep 2018 14:19:42 +0200 Subject: [PATCH 30/59] vusolo4k: more tuner Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/3a4cded5d8bf60eed04669c76f8d4d7398cdafbc Author: BPanther Date: 2018-09-02 (Sun, 02 Sep 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- common/ca_ci.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ include/ca_ci.h | 14 ++++++++++++++ include/dmx_hal.h | 4 ++++ libarmbox/dmx.cpp | 14 ++++++++++++++ 4 files changed, 74 insertions(+) diff --git a/common/ca_ci.cpp b/common/ca_ci.cpp index 0f6c05d..335c8c4 100644 --- a/common/ca_ci.cpp +++ b/common/ca_ci.cpp @@ -1011,6 +1011,44 @@ void cCA::setSource(eDVBCISlot* slot) case TUNER_D: fprintf(ci, "D"); break; +#if BOXMODEL_VUSOLO4K + case TUNER_E: + fprintf(ci, "E"); + break; + case TUNER_F: + fprintf(ci, "F"); + break; + case TUNER_G: + fprintf(ci, "G"); + break; + case TUNER_H: + fprintf(ci, "H"); + break; + case TUNER_I: + fprintf(ci, "I"); + break; + case TUNER_J: + fprintf(ci, "J"); + break; + case TUNER_K: + fprintf(ci, "K"); + break; + case TUNER_L: + fprintf(ci, "L"); + break; + case TUNER_M: + fprintf(ci, "M"); + break; + case TUNER_N: + fprintf(ci, "N"); + break; + case TUNER_O: + fprintf(ci, "O"); + break; + case TUNER_P: + fprintf(ci, "P"); + break; +#endif } fclose(ci); } @@ -1025,7 +1063,11 @@ void cCA::setInputs() char choices[64]; FILE * fd = 0; +#if BOXMODEL_VUSOLO4K + for (int number = 0; number < 16; number++) // tuner A to P, input 0 to 15 +#else for (int number = 0; number < 4; number++) // tuner A to D, input 0 to 3 +#endif { snprintf(choices, 64, "/proc/stb/tsmux/input%d_choices", number); if(access(choices, R_OK) < 0) diff --git a/include/ca_ci.h b/include/ca_ci.h index 5a75650..802f314 100644 --- a/include/ca_ci.h +++ b/include/ca_ci.h @@ -126,6 +126,20 @@ typedef enum { TUNER_B, TUNER_C, TUNER_D +#if BOXMODEL_VUSOLO4K + , TUNER_E + , TUNER_F + , TUNER_G + , TUNER_H + , TUNER_I + , TUNER_J + , TUNER_K + , TUNER_L + , TUNER_M + , TUNER_N + , TUNER_O + , TUNER_P +#endif } source_t; typedef enum { diff --git a/include/dmx_hal.h b/include/dmx_hal.h index 4463b70..c97d8cb 100644 --- a/include/dmx_hal.h +++ b/include/dmx_hal.h @@ -36,7 +36,11 @@ extern "C" { #include +#if BOXMODEL_VUSOLO4K +#define MAX_DMX_UNITS 16 +#else #define MAX_DMX_UNITS 4 +#endif typedef enum { diff --git a/libarmbox/dmx.cpp b/libarmbox/dmx.cpp index 10f2f32..8d973ba 100644 --- a/libarmbox/dmx.cpp +++ b/libarmbox/dmx.cpp @@ -75,7 +75,11 @@ static const char *DMX_T[] = { static int dmx_source[NUM_DEMUX] = { 0, 0, 0, 0 }; /* map the device numbers. */ +#if BOXMODEL_VUSOLO4K +#define NUM_DEMUXDEV 16 +#else #define NUM_DEMUXDEV 8 +#endif static const char *devname[NUM_DEMUXDEV] = { "/dev/dvb/adapter0/demux0", "/dev/dvb/adapter0/demux1", @@ -85,6 +89,16 @@ static const char *devname[NUM_DEMUXDEV] = { "/dev/dvb/adapter0/demux5", "/dev/dvb/adapter0/demux6", "/dev/dvb/adapter0/demux7" +#if BOXMODEL_VUSOLO4K + , "/dev/dvb/adapter0/demux8" + , "/dev/dvb/adapter0/demux9" + , "/dev/dvb/adapter0/demux10" + , "/dev/dvb/adapter0/demux11" + , "/dev/dvb/adapter0/demux12" + , "/dev/dvb/adapter0/demux13" + , "/dev/dvb/adapter0/demux14" + , "/dev/dvb/adapter0/demux15" +#endif }; /* did we already DMX_SET_SOURCE on that demux device? */ static bool init[NUM_DEMUXDEV] = { false, false, false, false, false, false, false, false }; From 4881a4a403a063708bae73bc5a2e07e4e31b973b Mon Sep 17 00:00:00 2001 From: BPanther Date: Sun, 2 Sep 2018 15:37:35 +0200 Subject: [PATCH 31/59] vusolo4k: more tuner fix Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/e962d40349bb66f3d6db1c9b00bb1f19f2b51e0f Author: BPanther Date: 2018-09-02 (Sun, 02 Sep 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- common/ca_ci.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/common/ca_ci.cpp b/common/ca_ci.cpp index 335c8c4..c608cdf 100644 --- a/common/ca_ci.cpp +++ b/common/ca_ci.cpp @@ -1128,6 +1128,44 @@ void cCA::setInputSource(eDVBCISlot* slot, bool ci) case TUNER_D: fprintf(input, "D"); break; +#if BOXMODEL_VUSOLO4K + case TUNER_E: + fprintf(input, "E"); + break; + case TUNER_F: + fprintf(input, "F"); + break; + case TUNER_G: + fprintf(input, "G"); + break; + case TUNER_H: + fprintf(input, "H"); + break; + case TUNER_I: + fprintf(input, "I"); + break; + case TUNER_J: + fprintf(input, "J"); + break; + case TUNER_K: + fprintf(input, "K"); + break; + case TUNER_L: + fprintf(input, "L"); + break; + case TUNER_M: + fprintf(input, "M"); + break; + case TUNER_N: + fprintf(input, "N"); + break; + case TUNER_O: + fprintf(input, "O"); + break; + case TUNER_P: + fprintf(input, "P"); + break; +#endif } } fclose(input); From be6a0f3452338d20d7c1b4b4f50eba2136b212f5 Mon Sep 17 00:00:00 2001 From: BPanther Date: Tue, 4 Sep 2018 01:10:04 +0200 Subject: [PATCH 32/59] fix vusolo4k Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/0a6d33c327b1f8080c1b47cde71fdc52a287dc3b Author: BPanther Date: 2018-09-04 (Tue, 04 Sep 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- include/ca_ci.h | 1 + include/dmx_hal.h | 1 + libarmbox/dmx.cpp | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/ca_ci.h b/include/ca_ci.h index 802f314..ee15f94 100644 --- a/include/ca_ci.h +++ b/include/ca_ci.h @@ -1,6 +1,7 @@ #ifndef __CA_H_ #define __CA_H_ +#include #include #include #include diff --git a/include/dmx_hal.h b/include/dmx_hal.h index c97d8cb..8ad5f3d 100644 --- a/include/dmx_hal.h +++ b/include/dmx_hal.h @@ -18,6 +18,7 @@ #ifndef __dmx_hal__ #define __dmx_hal__ +#include #include #include #include diff --git a/libarmbox/dmx.cpp b/libarmbox/dmx.cpp index 8d973ba..2db4b4c 100644 --- a/libarmbox/dmx.cpp +++ b/libarmbox/dmx.cpp @@ -20,6 +20,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -101,7 +102,7 @@ static const char *devname[NUM_DEMUXDEV] = { #endif }; /* did we already DMX_SET_SOURCE on that demux device? */ -static bool init[NUM_DEMUXDEV] = { false, false, false, false, false, false, false, false }; +static bool init[NUM_DEMUXDEV] = { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false }; typedef struct dmx_pdata { int last_source; From a48a2898954a11dfbfa00456463cd9d521138447 Mon Sep 17 00:00:00 2001 From: BPanther Date: Tue, 4 Sep 2018 01:46:38 +0200 Subject: [PATCH 33/59] fix vusolo4k Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/6cf28c8d10f557896646ad2bdc1251b3eb81fcf3 Author: BPanther Date: 2018-09-04 (Tue, 04 Sep 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/dmx.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libarmbox/dmx.cpp b/libarmbox/dmx.cpp index 2db4b4c..400303f 100644 --- a/libarmbox/dmx.cpp +++ b/libarmbox/dmx.cpp @@ -102,7 +102,11 @@ static const char *devname[NUM_DEMUXDEV] = { #endif }; /* did we already DMX_SET_SOURCE on that demux device? */ +#if BOXMODEL_VUSOLO4K static bool init[NUM_DEMUXDEV] = { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false }; +#else +static bool init[NUM_DEMUXDEV] = { false, false, false, false, false, false, false, false }; +#endif typedef struct dmx_pdata { int last_source; From a3837ba3df8d9b96e11206cc0be05442a6b2530e Mon Sep 17 00:00:00 2001 From: BPanther Date: Thu, 27 Sep 2018 01:09:27 +0200 Subject: [PATCH 34/59] sh4 hwcaps update Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/ad385ab6279689dadec071db1b856bf76b4e82e7 Author: BPanther Date: 2018-09-27 (Thu, 27 Sep 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libduckbox/hardware_caps.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libduckbox/hardware_caps.c b/libduckbox/hardware_caps.c index 8550149..643a963 100644 --- a/libduckbox/hardware_caps.c +++ b/libduckbox/hardware_caps.c @@ -48,6 +48,8 @@ hw_caps_t *get_hwcaps(void) caps.has_fan = 0; caps.has_CI = 2; caps.display_can_set_brightness = 1; + caps.display_type = HW_DISPLAY_LINE_TEXT; + caps.display_xres = 12; } else if (!strncmp(buf, "ufs912", 6)) { strcpy(caps.boxvendor, "DUCKBOX"); @@ -111,6 +113,8 @@ hw_caps_t *get_hwcaps(void) caps.has_fan = 0; caps.has_CI = 2; caps.display_can_set_brightness = 1; + caps.display_type = HW_DISPLAY_LINE_TEXT; + caps.display_xres = 12; } else if (!strncmp(buf, "octagon1008", 11)) { strcpy(caps.boxvendor, "DUCKBOX"); @@ -122,6 +126,8 @@ hw_caps_t *get_hwcaps(void) caps.has_fan = 0; caps.has_CI = 2; caps.display_can_set_brightness = 1; + caps.display_type = HW_DISPLAY_LINE_TEXT; + caps.display_xres = 8; } else if (!strncmp(buf, "hs7110", 6)) { strcpy(caps.boxvendor, "DUCKBOX"); @@ -188,6 +194,8 @@ hw_caps_t *get_hwcaps(void) caps.has_fan = 1; caps.has_CI = 2; caps.display_can_set_brightness = 1; + caps.display_type = HW_DISPLAY_LINE_TEXT; + caps.display_xres = 14; } else if (!strncmp(buf, "cuberevo-250hd", 4)) { strcpy(caps.boxvendor, "DUCKBOX"); From ffdc007b62929ae5da1762a899100c5eeaee5188 Mon Sep 17 00:00:00 2001 From: BPanther Date: Thu, 27 Sep 2018 13:11:39 +0200 Subject: [PATCH 35/59] update hwcaps for hl101 (thx sid8796) Signed-off-by: Thilo Graf I tryed to reduce the mess of commits. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/df7a030d062cd0a61ed4b5e01613c2d587daf4cc Author: BPanther Date: 2018-09-27 (Thu, 27 Sep 2018) ------------------ This commit was generated by Migit --- libduckbox/hardware_caps.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libduckbox/hardware_caps.c b/libduckbox/hardware_caps.c index 643a963..5382929 100644 --- a/libduckbox/hardware_caps.c +++ b/libduckbox/hardware_caps.c @@ -282,10 +282,14 @@ hw_caps_t *get_hwcaps(void) strcpy(caps.boxname, buf); caps.can_shutdown = 1; caps.has_HDMI = 1; - caps.has_SCART = 2; - caps.can_cec = 0; + caps.has_SCART = 1; + caps.has_SCART_input = 1; + caps.can_cec = 1; caps.has_fan = 0; caps.has_CI = 2; + caps.display_can_set_brightness = 1; + caps.display_type = HW_DISPLAY_LINE_TEXT; + caps.display_xres = 8; } else if (!strncmp(buf, "arivalink200", 12)) { strcpy(caps.boxvendor, "DUCKBOX"); From 351f411ec4195273e82d4206e69f406a9079bdc1 Mon Sep 17 00:00:00 2001 From: redblue-pkt Date: Thu, 4 Oct 2018 00:26:23 +0200 Subject: [PATCH 36/59] fix segfault in backward Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/e5724161b0b28392e33a6c876642d002bfcd29b5 Author: redblue-pkt Date: 2018-10-04 (Thu, 04 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- .gitignore | 3 +++ libeplayer3-arm/playback/playback.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 303dfee..a92a185 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ Makefile.in *.o *.Plo *.Po + +git-* +go_* diff --git a/libeplayer3-arm/playback/playback.c b/libeplayer3-arm/playback/playback.c index 257fb67..96566e0 100644 --- a/libeplayer3-arm/playback/playback.c +++ b/libeplayer3-arm/playback/playback.c @@ -578,7 +578,7 @@ static int PlaybackFastBackward(Context_t *context, int *speed) context->playback->BackWard = 0; context->playback->SlowMotion = 0; context->playback->Speed = 0; - context->output->Command(context, OUTPUT_AUDIOMUTE, "0"); + //context->output->Command(context, OUTPUT_AUDIOMUTE, "0"); } else { @@ -589,7 +589,7 @@ static int PlaybackFastBackward(Context_t *context, int *speed) context->playback->SlowMotion = 0; context->playback->Speed = *speed; context->playback->isSeeking = 1; - context->output->Command(context, OUTPUT_AUDIOMUTE, "1"); + //context->output->Command(context, OUTPUT_AUDIOMUTE, "1"); playback_printf(1, "Speed: %d, Backward: %d\n", context->playback->Speed, context->playback->BackWard); } From 5a102882372afc8894136447b2f8e0b895c033d5 Mon Sep 17 00:00:00 2001 From: redblue-pkt Date: Thu, 4 Oct 2018 00:45:42 +0200 Subject: [PATCH 37/59] fix fastforward Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/2cc698c3ecd0dbffdee9e267fbed03834cd1f5d6 Author: redblue-pkt Date: 2018-10-04 (Thu, 04 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3-arm/playback/playback.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libeplayer3-arm/playback/playback.c b/libeplayer3-arm/playback/playback.c index 96566e0..4ec98be 100644 --- a/libeplayer3-arm/playback/playback.c +++ b/libeplayer3-arm/playback/playback.c @@ -399,6 +399,7 @@ static int32_t PlaybackContinue(Context_t *context) if (context->playback->SlowMotion || context->playback->isForwarding || context->playback->BackWard) context->output->Command(context, OUTPUT_CLEAR, NULL); + context->output->Command(context, OUTPUT_PAUSE, NULL); context->output->Command(context, OUTPUT_CONTINUE, NULL); if (context->playback->BackWard) @@ -539,7 +540,7 @@ static int PlaybackFastForward(Context_t *context, int *speed) context->playback->Speed = *speed; playback_printf(20, "Speed: %d x {%d}\n", *speed, context->playback->Speed); context->output->Command(context, OUTPUT_FASTFORWARD, NULL); - context->output->Command(context, OUTPUT_CONTINUE, NULL); + //context->output->Command(context, OUTPUT_CONTINUE, NULL); } else { From a351a1a32f7294ce3ea4369242858b74d93f95ba Mon Sep 17 00:00:00 2001 From: redblue-pkt Date: Thu, 4 Oct 2018 00:55:37 +0200 Subject: [PATCH 38/59] fix mute, sound volume Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/5c733a1ac175472be9229ba1ddca185ddcd1a8ab Author: redblue-pkt Date: 2018-10-04 (Thu, 04 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/audio.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/libarmbox/audio.cpp b/libarmbox/audio.cpp index 8265447..c5d315c 100644 --- a/libarmbox/audio.cpp +++ b/libarmbox/audio.cpp @@ -67,6 +67,7 @@ void cAudio::closeDevice(void) int cAudio::do_mute(bool enable, bool remember) { lt_debug("%s(%d, %d)\n", __FUNCTION__, enable, remember); + char str[4]; if (remember) @@ -75,14 +76,12 @@ int cAudio::do_mute(bool enable, bool remember) sprintf(str, "%d", Muted); proc_put("/proc/stb/audio/j1_mute", str, strlen(str)); - if (!enable) + if (fd > 0) { - int f = open("/proc/stb/avs/0/volume", O_RDWR); - read(f, str, 4); - close(f); - str[3] = '\0'; - proc_put("/proc/stb/avs/0/volume", str, strlen(str)); + if (ioctl(fd, AUDIO_SET_MUTE, enable) < 0) + perror("AUDIO_SET_MUTE"); } + return 0; } @@ -102,23 +101,28 @@ int cAudio::setVolume(unsigned int left, unsigned int right) volume = (left + right) / 2; int v = map_volume(volume); -#if 0 - if (clipfd != -1 && mixer_fd != -1) { - int tmp = 0; - /* not sure if left / right is correct here, but it is always the same anyways ;-) */ - if (! Muted) - tmp = left << 8 | right; - int ret = ioctl(mixer_fd, MIXER_WRITE(mixer_num), &tmp); - if (ret == -1) - lt_info("%s: MIXER_WRITE(%d),%04x: %m\n", __func__, mixer_num, tmp); - return ret; + + // convert to -1dB steps + left = map_volume(volume); + right = map_volume(volume); + //now range is 63..0, where 0 is loudest + + audio_mixer_t mixer; + + mixer.volume_left = left; + mixer.volume_right = right; + + if (fd > 0) + { + if (ioctl(fd, AUDIO_SET_MIXER, &mixer) < 0) + perror("AUDIO_SET_MIXER"); } -#endif char str[4]; sprintf(str, "%d", v); proc_put("/proc/stb/avs/0/volume", str, strlen(str)); + return 0; } From f8bfc98cb0add73b41612da3e41ee940594773d4 Mon Sep 17 00:00:00 2001 From: redblue-pkt Date: Thu, 4 Oct 2018 01:00:45 +0200 Subject: [PATCH 39/59] try to fix slowly close internet radio/music player Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/42dc38f7c91a8e2b40275678695edb48b2855498 Author: redblue-pkt Date: 2018-10-04 (Thu, 04 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/audio.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libarmbox/audio.cpp b/libarmbox/audio.cpp index c5d315c..d1170f9 100644 --- a/libarmbox/audio.cpp +++ b/libarmbox/audio.cpp @@ -314,6 +314,7 @@ int cAudio::WriteClip(unsigned char *buffer, int size) int cAudio::StopClip() { lt_debug("%s\n", __FUNCTION__); +#if 0 if (clipfd < 0) { lt_info("%s: clipfd not yet opened\n", __FUNCTION__); return -1; @@ -325,6 +326,7 @@ int cAudio::StopClip() mixer_fd = -1; } setVolume(volume, volume); +#endif return 0; }; From 39b31fe607cf65c4a8cbeb54d45b19ee6b77dd9b Mon Sep 17 00:00:00 2001 From: redblue-pkt Date: Thu, 4 Oct 2018 01:13:39 +0200 Subject: [PATCH 40/59] update audio streamtype Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/18ee150d60a238fc5516df9279ca1a4f9f96297b Author: redblue-pkt Date: 2018-10-04 (Thu, 04 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/audio.cpp | 53 ++++++++++++++++++++----------------------- libarmbox/audio_lib.h | 29 +++++++++++------------ 2 files changed, 39 insertions(+), 43 deletions(-) diff --git a/libarmbox/audio.cpp b/libarmbox/audio.cpp index d1170f9..7bae671 100644 --- a/libarmbox/audio.cpp +++ b/libarmbox/audio.cpp @@ -150,41 +150,36 @@ void cAudio::SetSyncMode(AVSYNC_TYPE Mode) ioctl(fd, AUDIO_SET_AV_SYNC, Mode); } -#define AUDIO_STREAMTYPE_AC3 0 -#define AUDIO_STREAMTYPE_MPEG 1 -#define AUDIO_STREAMTYPE_DTS 2 -#define AUDIO_STREAMTYPE_AAC 8 -#define AUDIO_STREAMTYPE_AACHE 9 - void cAudio::SetStreamType(AUDIO_FORMAT type) { - int bypass = AUDIO_STREAMTYPE_MPEG; - lt_debug("%s %d\n", __FUNCTION__, type); - StreamType = type; + const char *AF[] = { + "AUDIO_STREAMTYPE_AC3", + "AUDIO_STREAMTYPE_MPEG", + "AUDIO_STREAMTYPE_DTS", + "AUDIO_STREAMTYPE_LPCM", + "AUDIO_STREAMTYPE_AAC", + "AUDIO_STREAMTYPE_AAC_HE", + "AUDIO_STREAMTYPE_MP3", + "AUDIO_STREAMTYPE_AAC_PLUS", + "AUDIO_STREAMTYPE_DTS_HD", + "AUDIO_STREAMTYPE_WMA", + "AUDIO_STREAMTYPE_WMA_PRO", + "AUDIO_STREAMTYPE_AC3_PLUS", + "AUDIO_STREAMTYPE_AMR", + "AUDIO_STREAMTYPE_RAW" + }; - switch (type) + lt_info("%s - type=%s\n", __FUNCTION__, AF[type]); + + if (ioctl(fd, AUDIO_SET_BYPASS_MODE, type) < 0) { - case AUDIO_FMT_DD_PLUS: - case AUDIO_FMT_DOLBY_DIGITAL: - bypass = AUDIO_STREAMTYPE_AC3; - break; - case AUDIO_FMT_AAC: - bypass = AUDIO_STREAMTYPE_AAC; - break; - case AUDIO_FMT_AAC_PLUS: - bypass = AUDIO_STREAMTYPE_AACHE; - break; - case AUDIO_FMT_DTS: - bypass = AUDIO_STREAMTYPE_DTS; - break; - default: - break; + perror("AUDIO_SET_BYPASS_MODE"); + return; } - // Normaly the encoding should be set using AUDIO_SET_ENCODING - // But as we implemented the behavior to bypass (cause of e2) this is correct here - if (ioctl(fd, AUDIO_SET_BYPASS_MODE, bypass) < 0) - lt_info("%s: AUDIO_SET_BYPASS_MODE failed (%m)\n", __func__); + StreamType = type; + + return; } int cAudio::setChannel(int channel) diff --git a/libarmbox/audio_lib.h b/libarmbox/audio_lib.h index 1fb896f..2bcd073 100644 --- a/libarmbox/audio_lib.h +++ b/libarmbox/audio_lib.h @@ -20,20 +20,21 @@ typedef enum { typedef enum { - AUDIO_FMT_AUTO = 0, - AUDIO_FMT_MPEG, - AUDIO_FMT_MP3, - AUDIO_FMT_DOLBY_DIGITAL, - AUDIO_FMT_BASIC = AUDIO_FMT_DOLBY_DIGITAL, - AUDIO_FMT_AAC, - AUDIO_FMT_AAC_PLUS, - AUDIO_FMT_DD_PLUS, - AUDIO_FMT_DTS, - AUDIO_FMT_AVS, - AUDIO_FMT_MLP, - AUDIO_FMT_WMA, - AUDIO_FMT_MPG1, // TD only. For Movieplayer / cPlayback - AUDIO_FMT_ADVANCED = AUDIO_FMT_MLP + AUDIO_FMT_UNKNOWN = -1, + AUDIO_FMT_DOLBY_DIGITAL = 0, + AUDIO_FMT_MPEG = 1, + AUDIO_FMT_DTS = 2, + AUDIO_FMT_LPCM = 6, + AUDIO_FMT_AAC = 8, + AUDIO_FMT_AAC_HE = 9, + AUDIO_FMT_MP3 = 0xa, + AUDIO_FMT_AAC_PLUS = 0xb, + AUDIO_FMT_DTS_HD = 0x10, + AUDIO_FMT_WMA = 0x20, + AUDIO_FMT_WMA_PRO = 0x21, + AUDIO_FMT_DD_PLUS = 0x22, + AUDIO_FMT_AMR = 0x23, + AUDIO_FMT_RAW = 0xf } AUDIO_FORMAT; class mixerVolume; From a8366a9d14a6b65bc024fc528d30ebd927c72b8f Mon Sep 17 00:00:00 2001 From: redblue-pkt Date: Thu, 4 Oct 2018 01:25:00 +0200 Subject: [PATCH 41/59] update video streamtype Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/a6614a7cdd32df002b441d96dd4bde3b30021a10 Author: redblue-pkt Date: 2018-10-04 (Thu, 04 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/video.cpp | 56 +++++++++++++------------------------------ libarmbox/video_lib.h | 25 ++++++++++++------- 2 files changed, 34 insertions(+), 47 deletions(-) diff --git a/libarmbox/video.cpp b/libarmbox/video.cpp index f9991d0..bbb860c 100644 --- a/libarmbox/video.cpp +++ b/libarmbox/video.cpp @@ -140,15 +140,6 @@ static const char *vid_modes[] = { "720p50" // VIDEO_STD_AUTO }; -#define VIDEO_STREAMTYPE_MPEG2 0 -#define VIDEO_STREAMTYPE_MPEG4_H264 1 -#define VIDEO_STREAMTYPE_VC1 3 -#define VIDEO_STREAMTYPE_MPEG4_Part2 4 -#define VIDEO_STREAMTYPE_VC1_SM 5 -#define VIDEO_STREAMTYPE_MPEG1 6 -#define VIDEO_STREAMTYPE_H265_HEVC 7 -#define VIDEO_STREAMTYPE_AVS 16 - ssize_t write_all(int fd, const void *buf, size_t count) { int retval; @@ -760,39 +751,26 @@ void cVideo::SetSyncMode(AVSYNC_TYPE mode) int cVideo::SetStreamType(VIDEO_FORMAT type) { - static const char *VF[] = { - "VIDEO_FORMAT_MPEG2", - "VIDEO_FORMAT_MPEG4", - "VIDEO_FORMAT_VC1", - "VIDEO_FORMAT_JPEG", - "VIDEO_FORMAT_GIF", - "VIDEO_FORMAT_PNG" + const char *VF[] = { + "VIDEO_STREAMTYPE_MPEG2", + "VIDEO_STREAMTYPE_MPEG4_H264", + "VIDEO_STREAMTYPE_MPEG4_H263", + "VIDEO_STREAMTYPE_VC1", + "VIDEO_STREAMTYPE_MPEG4_Part2", + "VIDEO_STREAMTYPE_VC1_SM", + "VIDEO_STREAMTYPE_MPEG1", + "VIDEO_STREAMTYPE_DIVX311" + "VIDEO_STREAMTYPE_H265_HEVC", + "VIDEO_STREAMTYPE_AVS" }; - int t; - lt_debug("#%d: %s type=%s\n", devnum, __func__, VF[type]); - switch (type) - { - case VIDEO_FORMAT_MPEG4_H264: - t = VIDEO_STREAMTYPE_MPEG4_H264; - break; - case VIDEO_FORMAT_MPEG4_H265: - t = VIDEO_STREAMTYPE_H265_HEVC; - break; - case VIDEO_FORMAT_AVS: - t = VIDEO_STREAMTYPE_AVS; - break; - case VIDEO_FORMAT_VC1: - t = VIDEO_STREAMTYPE_VC1; - break; - case VIDEO_FORMAT_MPEG2: - default: - t = VIDEO_STREAMTYPE_MPEG2; - break; - } + lt_info("%s - type=%s\n", __FUNCTION__, VF[type]); + + if (ioctl( fd, VIDEO_SET_STREAMTYPE, type) < 0) + perror("VIDEO_SET_STREAMTYPE"); + + StreamType = type; - if (ioctl(fd, VIDEO_SET_STREAMTYPE, t) < 0) - lt_info("%s VIDEO_SET_STREAMTYPE(%d) failed: %m\n", __func__, t); return 0; } diff --git a/libarmbox/video_lib.h b/libarmbox/video_lib.h index 7a914fe..3b2ea58 100644 --- a/libarmbox/video_lib.h +++ b/libarmbox/video_lib.h @@ -33,14 +33,23 @@ typedef enum { } COLOR_FORMAT; typedef enum { - VIDEO_FORMAT_MPEG2 = 0, - VIDEO_FORMAT_MPEG4_H264, - VIDEO_FORMAT_VC1, - VIDEO_FORMAT_JPEG, - VIDEO_FORMAT_GIF, - VIDEO_FORMAT_PNG, - VIDEO_FORMAT_MPEG4_H265, - VIDEO_FORMAT_AVS = 16 + VIDEO_STREAMTYPE_UNKNOWN = -1, + VIDEO_STREAMTYPE_MPEG2 = 0, + VIDEO_STREAMTYPE_MPEG4_H264 = 1, + VIDEO_STREAMTYPE_H263 = 2, + VIDEO_STREAMTYPE_VC1 = 3, + VIDEO_STREAMTYPE_MPEG4_Part2 = 4, + VIDEO_STREAMTYPE_VC1_SM = 5, + VIDEO_STREAMTYPE_MPEG1 = 6, + VIDEO_STREAMTYPE_MPEG4_H265 = 7, + VIDEO_STREAMTYPE_VB8 = 8, + VIDEO_STREAMTYPE_VB9 = 9, + VIDEO_STREAMTYPE_XVID = 10, + VIDEO_STREAMTYPE_DIVX311 = 13, + VIDEO_STREAMTYPE_DIVX4 = 14, + VIDEO_STREAMTYPE_DIVX5 = 15, + VIDEO_STREAMTYPE_VB6 = 18, + VIDEO_STREAMTYPE_SPARK = 21 } VIDEO_FORMAT; typedef enum { From 40df3accd7552faeaea77def7c4ab7eebf87705b Mon Sep 17 00:00:00 2001 From: redblue-pkt Date: Thu, 4 Oct 2018 01:39:50 +0200 Subject: [PATCH 42/59] update SetControl() Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/1e674880f394a4c6c42defc1fb5a19ebd3ac046f Author: redblue-pkt Date: 2018-10-04 (Thu, 04 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/video.cpp | 42 ++++++++++++++++++++++++++++++++++++++++-- libarmbox/video_lib.h | 17 +++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/libarmbox/video.cpp b/libarmbox/video.cpp index bbb860c..d0143cc 100644 --- a/libarmbox/video.cpp +++ b/libarmbox/video.cpp @@ -787,7 +787,8 @@ void cVideo::SetDemux(cDemux *) lt_debug("#%d %s not implemented yet\n", devnum, __func__); } -void cVideo::SetControl(int control, int value) { +void cVideo::SetControl(int control, int value) +{ const char *p = NULL; switch (control) { case VIDEO_CONTROL_BRIGHTNESS: @@ -806,10 +807,47 @@ void cVideo::SetControl(int control, int value) { hue = value; p = "/proc/stb/vmpeg/0/pep_hue"; break; + case VIDEO_CONTROL_SHARPNESS: + sharpness = value; + p = "/proc/stb/vmpeg/0/pep_sharpness"; + break; + case VIDEO_CONTROL_BLOCK_NOISE_REDUCTION: + block_noise_reduction = value; + p = "/proc/stb/vmpeg/0/pep_block_noise_reduction"; + break; + case VIDEO_CONTROL_MOSQUITO_NOISE_REDUCTION: + mosquito_noise_reduction = value; + p = "/proc/stb/vmpeg/0/pep_mosquito_noise_reduction"; + break; + case VIDEO_CONTROL_DIGITAL_CONTOUR_REMOVAL: + digital_contour_removal = value; + p = "/proc/stb/vmpeg/0/pep_digital_contour_removal"; + break; + case VIDEO_CONTROL_AUTO_FLESH: + auto_flesh = value; + p = "/proc/stb/vmpeg/0/pep_auto_flesh"; + break; + case VIDEO_CONTROL_GREEN_BOOST: + green_boost = value; + p = "/proc/stb/vmpeg/0/pep_green_boost"; + break; + case VIDEO_CONTROL_BLUE_BOOST: + blue_boost = value; + p = "/proc/stb/vmpeg/0/pep_blue_boost"; + break; + case VIDEO_CONTROL_DYNAMIC_CONTRAST: + dynamic_contrast = value; + p = "/proc/stb/vmpeg/0/pep_dynamic_contrast"; + break; + case VIDEO_CONTROL_SCALER_SHARPNESS: + scaler_sharpness = value; + p = "/proc/stb/vmpeg/0/pep_scaler_sharpness"; + break; } if (p) { char buf[20]; - int len = snprintf(buf, sizeof(buf), "%x00\n", value); + int fix_value = value * 256; + int len = snprintf(buf, sizeof(buf), "%0.8X", fix_value); if (len < (int) sizeof(buf)) proc_put(p, buf, len); } diff --git a/libarmbox/video_lib.h b/libarmbox/video_lib.h index 3b2ea58..3ec7cd1 100644 --- a/libarmbox/video_lib.h +++ b/libarmbox/video_lib.h @@ -144,6 +144,14 @@ typedef enum VIDEO_CONTROL_SATURATION, VIDEO_CONTROL_HUE, VIDEO_CONTROL_SHARPNESS, + VIDEO_CONTROL_BLOCK_NOISE_REDUCTION, + VIDEO_CONTROL_MOSQUITO_NOISE_REDUCTION, + VIDEO_CONTROL_DIGITAL_CONTOUR_REMOVAL, + VIDEO_CONTROL_AUTO_FLESH, + VIDEO_CONTROL_GREEN_BOOST, + VIDEO_CONTROL_BLUE_BOOST, + VIDEO_CONTROL_DYNAMIC_CONTRAST, + VIDEO_CONTROL_SCALER_SHARPNESS, VIDEO_CONTROL_MAX = VIDEO_CONTROL_SHARPNESS } VIDEO_CONTROL; @@ -191,6 +199,15 @@ class cVideo int contrast; int saturation; int hue; + int sharpness; + int block_noise_reduction; + int mosquito_noise_reduction; + int digital_contour_removal; + int auto_flesh; + int green_boost; + int blue_boost; + int dynamic_contrast; + int scaler_sharpness; /* used internally by dmx */ int64_t GetPTS(void); From 18b80cfebe9ec5f61714f8e37212bef68a423dda Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 5 Oct 2018 13:58:11 +0200 Subject: [PATCH 43/59] libarmbox/video.cpp: fix possible broken build possible error: "error: '0' flag ignored with precision and '%X' gnu_printf format [-Werror=format=]" Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/2a5d3d23f2aa5fe91f866055f8f67ee2d8c25647 Author: Thilo Graf Date: 2018-10-05 (Fri, 05 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/video.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libarmbox/video.cpp b/libarmbox/video.cpp index d0143cc..3cc7e6a 100644 --- a/libarmbox/video.cpp +++ b/libarmbox/video.cpp @@ -847,7 +847,7 @@ void cVideo::SetControl(int control, int value) if (p) { char buf[20]; int fix_value = value * 256; - int len = snprintf(buf, sizeof(buf), "%0.8X", fix_value); + int len = snprintf(buf, sizeof(buf), "%.8X", fix_value); if (len < (int) sizeof(buf)) proc_put(p, buf, len); } From 4d116d48be8ab56c4d8111ba018b38dc4a8cc71b Mon Sep 17 00:00:00 2001 From: redblue-pkt Date: Thu, 4 Oct 2018 01:46:27 +0200 Subject: [PATCH 44/59] update SetColorFormat() Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/4806fe87b07c5895c3a4d0a9a4c1bee632cb2a76 Author: redblue-pkt Date: 2018-10-04 (Thu, 04 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/video.cpp | 15 +++++++++++---- libarmbox/video_lib.h | 4 +++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libarmbox/video.cpp b/libarmbox/video.cpp index 3cc7e6a..ab5d7ff 100644 --- a/libarmbox/video.cpp +++ b/libarmbox/video.cpp @@ -853,7 +853,8 @@ void cVideo::SetControl(int control, int value) } } -void cVideo::SetColorFormat(COLOR_FORMAT color_format) { +void cVideo::SetColorFormat(COLOR_FORMAT color_format) +{ const char *p = NULL; switch(color_format) { case COLORFORMAT_RGB: @@ -868,14 +869,20 @@ void cVideo::SetColorFormat(COLOR_FORMAT color_format) { case COLORFORMAT_SVIDEO: p = "svideo"; break; + case COLORFORMAT_HDMI_AUTO: + p = "Edid(Auto)"; + break; case COLORFORMAT_HDMI_RGB: - p = "hdmi_rgb"; + p = "Hdmi_Rgb"; break; case COLORFORMAT_HDMI_YCBCR444: - p = "hdmi_yuv"; + p = "444"; break; case COLORFORMAT_HDMI_YCBCR422: - p = "hdmi_422"; + p = "422"; + break; + case COLORFORMAT_HDMI_YCBCR420: + p = "420"; break; } if (p) diff --git a/libarmbox/video_lib.h b/libarmbox/video_lib.h index 3ec7cd1..4cdc073 100644 --- a/libarmbox/video_lib.h +++ b/libarmbox/video_lib.h @@ -27,9 +27,11 @@ typedef enum { COLORFORMAT_YUV, COLORFORMAT_CVBS, COLORFORMAT_SVIDEO, + COLORFORMAT_HDMI_AUTO, COLORFORMAT_HDMI_RGB, COLORFORMAT_HDMI_YCBCR444, - COLORFORMAT_HDMI_YCBCR422 + COLORFORMAT_HDMI_YCBCR422, + COLORFORMAT_HDMI_YCBCR420 } COLOR_FORMAT; typedef enum { From e284757cbacbe8cf1a1674939cc6cf4cc7b1ed65 Mon Sep 17 00:00:00 2001 From: redblue-pkt Date: Thu, 4 Oct 2018 03:45:40 +0200 Subject: [PATCH 45/59] add codec info Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/dde77e1b5cd897762bb015512567c10a2d273fd7 Author: redblue-pkt Date: 2018-10-04 (Thu, 04 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/playback_libeplayer3.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libarmbox/playback_libeplayer3.cpp b/libarmbox/playback_libeplayer3.cpp index b782ec2..2cb61e4 100644 --- a/libarmbox/playback_libeplayer3.cpp +++ b/libarmbox/playback_libeplayer3.cpp @@ -553,7 +553,13 @@ void cPlayback::FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *nu ac3flags[j] = 0; //todo else ac3flags[j] = 0; //todo - language[j] = std::string(_lang); + std::string _language = ""; + _language += std::string(_lang); + _language += " - "; + _language += "("; + _language += TrackList[i + 1]; + _language += ")"; + language[j] = _language; } } free(TrackList[i]); From c6a0133803e99658814e0724050ccdffc9470cf7 Mon Sep 17 00:00:00 2001 From: redblue-pkt Date: Thu, 4 Oct 2018 03:50:48 +0200 Subject: [PATCH 46/59] fix no sound after play video Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/950f804f3fc494db7c43ecf9453bc74e0319f942 Author: redblue-pkt Date: 2018-10-04 (Thu, 04 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/audio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libarmbox/audio.cpp b/libarmbox/audio.cpp index 7bae671..d6af373 100644 --- a/libarmbox/audio.cpp +++ b/libarmbox/audio.cpp @@ -42,7 +42,7 @@ void cAudio::openDevice(void) if ((fd = open(AUDIO_DEVICE, O_RDWR)) < 0) lt_info("openDevice: open failed (%m)\n"); fcntl(fd, F_SETFD, FD_CLOEXEC); - do_mute(true, false); + //do_mute(true, false); } else lt_info("openDevice: already open (fd = %d)\n", fd); From 526f19c302593e67d168cf226874970522a83e8f Mon Sep 17 00:00:00 2001 From: max_10 Date: Sat, 6 Oct 2018 19:58:35 +0200 Subject: [PATCH 47/59] Revert "update video streamtype" This reverts commit d6b32edaa7d0cd1eb035e3404a12dee2359037ea. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/84fe2aa10c22275395604fc37a65f8fe1dc8159c Author: max_10 Date: 2018-10-06 (Sat, 06 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/video.cpp | 56 ++++++++++++++++++++++++++++++------------- libarmbox/video_lib.h | 25 +++++++------------ 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/libarmbox/video.cpp b/libarmbox/video.cpp index ab5d7ff..73fc02a 100644 --- a/libarmbox/video.cpp +++ b/libarmbox/video.cpp @@ -140,6 +140,15 @@ static const char *vid_modes[] = { "720p50" // VIDEO_STD_AUTO }; +#define VIDEO_STREAMTYPE_MPEG2 0 +#define VIDEO_STREAMTYPE_MPEG4_H264 1 +#define VIDEO_STREAMTYPE_VC1 3 +#define VIDEO_STREAMTYPE_MPEG4_Part2 4 +#define VIDEO_STREAMTYPE_VC1_SM 5 +#define VIDEO_STREAMTYPE_MPEG1 6 +#define VIDEO_STREAMTYPE_H265_HEVC 7 +#define VIDEO_STREAMTYPE_AVS 16 + ssize_t write_all(int fd, const void *buf, size_t count) { int retval; @@ -751,26 +760,39 @@ void cVideo::SetSyncMode(AVSYNC_TYPE mode) int cVideo::SetStreamType(VIDEO_FORMAT type) { - const char *VF[] = { - "VIDEO_STREAMTYPE_MPEG2", - "VIDEO_STREAMTYPE_MPEG4_H264", - "VIDEO_STREAMTYPE_MPEG4_H263", - "VIDEO_STREAMTYPE_VC1", - "VIDEO_STREAMTYPE_MPEG4_Part2", - "VIDEO_STREAMTYPE_VC1_SM", - "VIDEO_STREAMTYPE_MPEG1", - "VIDEO_STREAMTYPE_DIVX311" - "VIDEO_STREAMTYPE_H265_HEVC", - "VIDEO_STREAMTYPE_AVS" + static const char *VF[] = { + "VIDEO_FORMAT_MPEG2", + "VIDEO_FORMAT_MPEG4", + "VIDEO_FORMAT_VC1", + "VIDEO_FORMAT_JPEG", + "VIDEO_FORMAT_GIF", + "VIDEO_FORMAT_PNG" }; + int t; + lt_debug("#%d: %s type=%s\n", devnum, __func__, VF[type]); - lt_info("%s - type=%s\n", __FUNCTION__, VF[type]); - - if (ioctl( fd, VIDEO_SET_STREAMTYPE, type) < 0) - perror("VIDEO_SET_STREAMTYPE"); - - StreamType = type; + switch (type) + { + case VIDEO_FORMAT_MPEG4_H264: + t = VIDEO_STREAMTYPE_MPEG4_H264; + break; + case VIDEO_FORMAT_MPEG4_H265: + t = VIDEO_STREAMTYPE_H265_HEVC; + break; + case VIDEO_FORMAT_AVS: + t = VIDEO_STREAMTYPE_AVS; + break; + case VIDEO_FORMAT_VC1: + t = VIDEO_STREAMTYPE_VC1; + break; + case VIDEO_FORMAT_MPEG2: + default: + t = VIDEO_STREAMTYPE_MPEG2; + break; + } + if (ioctl(fd, VIDEO_SET_STREAMTYPE, t) < 0) + lt_info("%s VIDEO_SET_STREAMTYPE(%d) failed: %m\n", __func__, t); return 0; } diff --git a/libarmbox/video_lib.h b/libarmbox/video_lib.h index 4cdc073..d14354e 100644 --- a/libarmbox/video_lib.h +++ b/libarmbox/video_lib.h @@ -35,23 +35,14 @@ typedef enum { } COLOR_FORMAT; typedef enum { - VIDEO_STREAMTYPE_UNKNOWN = -1, - VIDEO_STREAMTYPE_MPEG2 = 0, - VIDEO_STREAMTYPE_MPEG4_H264 = 1, - VIDEO_STREAMTYPE_H263 = 2, - VIDEO_STREAMTYPE_VC1 = 3, - VIDEO_STREAMTYPE_MPEG4_Part2 = 4, - VIDEO_STREAMTYPE_VC1_SM = 5, - VIDEO_STREAMTYPE_MPEG1 = 6, - VIDEO_STREAMTYPE_MPEG4_H265 = 7, - VIDEO_STREAMTYPE_VB8 = 8, - VIDEO_STREAMTYPE_VB9 = 9, - VIDEO_STREAMTYPE_XVID = 10, - VIDEO_STREAMTYPE_DIVX311 = 13, - VIDEO_STREAMTYPE_DIVX4 = 14, - VIDEO_STREAMTYPE_DIVX5 = 15, - VIDEO_STREAMTYPE_VB6 = 18, - VIDEO_STREAMTYPE_SPARK = 21 + VIDEO_FORMAT_MPEG2 = 0, + VIDEO_FORMAT_MPEG4_H264, + VIDEO_FORMAT_VC1, + VIDEO_FORMAT_JPEG, + VIDEO_FORMAT_GIF, + VIDEO_FORMAT_PNG, + VIDEO_FORMAT_MPEG4_H265, + VIDEO_FORMAT_AVS = 16 } VIDEO_FORMAT; typedef enum { From fb33ddc2e69f00c500d4236ac24b28a9c7e12f50 Mon Sep 17 00:00:00 2001 From: max_10 Date: Sat, 6 Oct 2018 19:58:51 +0200 Subject: [PATCH 48/59] Revert "update audio streamtype" This reverts commit 803aa065fc6ff33f69a5cc9a6e420e7d80c5638c. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/9e9d4ca39b1fe202d1679554692b743d4daedce4 Author: max_10 Date: 2018-10-06 (Sat, 06 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/audio.cpp | 57 +++++++++++++++++++++++-------------------- libarmbox/audio_lib.h | 29 +++++++++++----------- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/libarmbox/audio.cpp b/libarmbox/audio.cpp index d6af373..809b594 100644 --- a/libarmbox/audio.cpp +++ b/libarmbox/audio.cpp @@ -150,36 +150,41 @@ void cAudio::SetSyncMode(AVSYNC_TYPE Mode) ioctl(fd, AUDIO_SET_AV_SYNC, Mode); } +#define AUDIO_STREAMTYPE_AC3 0 +#define AUDIO_STREAMTYPE_MPEG 1 +#define AUDIO_STREAMTYPE_DTS 2 +#define AUDIO_STREAMTYPE_AAC 8 +#define AUDIO_STREAMTYPE_AACHE 9 + void cAudio::SetStreamType(AUDIO_FORMAT type) { - const char *AF[] = { - "AUDIO_STREAMTYPE_AC3", - "AUDIO_STREAMTYPE_MPEG", - "AUDIO_STREAMTYPE_DTS", - "AUDIO_STREAMTYPE_LPCM", - "AUDIO_STREAMTYPE_AAC", - "AUDIO_STREAMTYPE_AAC_HE", - "AUDIO_STREAMTYPE_MP3", - "AUDIO_STREAMTYPE_AAC_PLUS", - "AUDIO_STREAMTYPE_DTS_HD", - "AUDIO_STREAMTYPE_WMA", - "AUDIO_STREAMTYPE_WMA_PRO", - "AUDIO_STREAMTYPE_AC3_PLUS", - "AUDIO_STREAMTYPE_AMR", - "AUDIO_STREAMTYPE_RAW" - }; - - lt_info("%s - type=%s\n", __FUNCTION__, AF[type]); - - if (ioctl(fd, AUDIO_SET_BYPASS_MODE, type) < 0) - { - perror("AUDIO_SET_BYPASS_MODE"); - return; - } - + int bypass = AUDIO_STREAMTYPE_MPEG; + lt_debug("%s %d\n", __FUNCTION__, type); StreamType = type; - return; + switch (type) + { + case AUDIO_FMT_DD_PLUS: + case AUDIO_FMT_DOLBY_DIGITAL: + bypass = AUDIO_STREAMTYPE_AC3; + break; + case AUDIO_FMT_AAC: + bypass = AUDIO_STREAMTYPE_AAC; + break; + case AUDIO_FMT_AAC_PLUS: + bypass = AUDIO_STREAMTYPE_AACHE; + break; + case AUDIO_FMT_DTS: + bypass = AUDIO_STREAMTYPE_DTS; + break; + default: + break; + } + + // Normaly the encoding should be set using AUDIO_SET_ENCODING + // But as we implemented the behavior to bypass (cause of e2) this is correct here + if (ioctl(fd, AUDIO_SET_BYPASS_MODE, bypass) < 0) + lt_info("%s: AUDIO_SET_BYPASS_MODE failed (%m)\n", __func__); } int cAudio::setChannel(int channel) diff --git a/libarmbox/audio_lib.h b/libarmbox/audio_lib.h index 2bcd073..1fb896f 100644 --- a/libarmbox/audio_lib.h +++ b/libarmbox/audio_lib.h @@ -20,21 +20,20 @@ typedef enum { typedef enum { - AUDIO_FMT_UNKNOWN = -1, - AUDIO_FMT_DOLBY_DIGITAL = 0, - AUDIO_FMT_MPEG = 1, - AUDIO_FMT_DTS = 2, - AUDIO_FMT_LPCM = 6, - AUDIO_FMT_AAC = 8, - AUDIO_FMT_AAC_HE = 9, - AUDIO_FMT_MP3 = 0xa, - AUDIO_FMT_AAC_PLUS = 0xb, - AUDIO_FMT_DTS_HD = 0x10, - AUDIO_FMT_WMA = 0x20, - AUDIO_FMT_WMA_PRO = 0x21, - AUDIO_FMT_DD_PLUS = 0x22, - AUDIO_FMT_AMR = 0x23, - AUDIO_FMT_RAW = 0xf + AUDIO_FMT_AUTO = 0, + AUDIO_FMT_MPEG, + AUDIO_FMT_MP3, + AUDIO_FMT_DOLBY_DIGITAL, + AUDIO_FMT_BASIC = AUDIO_FMT_DOLBY_DIGITAL, + AUDIO_FMT_AAC, + AUDIO_FMT_AAC_PLUS, + AUDIO_FMT_DD_PLUS, + AUDIO_FMT_DTS, + AUDIO_FMT_AVS, + AUDIO_FMT_MLP, + AUDIO_FMT_WMA, + AUDIO_FMT_MPG1, // TD only. For Movieplayer / cPlayback + AUDIO_FMT_ADVANCED = AUDIO_FMT_MLP } AUDIO_FORMAT; class mixerVolume; From f8ac182248efd8bc676599e71263dafa9e4cbd42 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Sat, 6 Oct 2018 18:43:59 +0200 Subject: [PATCH 49/59] arm another fix fastforward Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/c58e9b9eb7b8f149ce4ed3494acb6a2e87f65d45 Author: TangoCash Date: 2018-10-06 (Sat, 06 Oct 2018) ------------------ This commit was generated by Migit --- libeplayer3-arm/playback/playback.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libeplayer3-arm/playback/playback.c b/libeplayer3-arm/playback/playback.c index 4ec98be..b8fe5bb 100644 --- a/libeplayer3-arm/playback/playback.c +++ b/libeplayer3-arm/playback/playback.c @@ -399,9 +399,6 @@ static int32_t PlaybackContinue(Context_t *context) if (context->playback->SlowMotion || context->playback->isForwarding || context->playback->BackWard) context->output->Command(context, OUTPUT_CLEAR, NULL); - context->output->Command(context, OUTPUT_PAUSE, NULL); - context->output->Command(context, OUTPUT_CONTINUE, NULL); - if (context->playback->BackWard) context->output->Command(context, OUTPUT_AUDIOMUTE, "0"); @@ -411,6 +408,8 @@ static int32_t PlaybackContinue(Context_t *context) context->playback->BackWard = 0; context->playback->SlowMotion = 0; context->playback->Speed = 1; + + context->output->Command(context, OUTPUT_CONTINUE, NULL); } else { @@ -540,7 +539,7 @@ static int PlaybackFastForward(Context_t *context, int *speed) context->playback->Speed = *speed; playback_printf(20, "Speed: %d x {%d}\n", *speed, context->playback->Speed); context->output->Command(context, OUTPUT_FASTFORWARD, NULL); - //context->output->Command(context, OUTPUT_CONTINUE, NULL); + context->output->Command(context, OUTPUT_CONTINUE, NULL); } else { From 612f70a4890820034a046766b5b31382a8a7b502 Mon Sep 17 00:00:00 2001 From: Frankenstone Date: Sun, 7 Oct 2018 09:57:38 +0200 Subject: [PATCH 50/59] arm hardware: fast forward, mute audio when passthrough AC3 / DTS -thx DboxOldie Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/28201707768201541d9b70a5f740b3a36a034d30 Author: Frankenstone Date: 2018-10-07 (Sun, 07 Oct 2018) ------------------ This commit was generated by Migit --- libeplayer3-arm/playback/playback.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libeplayer3-arm/playback/playback.c b/libeplayer3-arm/playback/playback.c index b8fe5bb..781bf4f 100644 --- a/libeplayer3-arm/playback/playback.c +++ b/libeplayer3-arm/playback/playback.c @@ -399,7 +399,7 @@ static int32_t PlaybackContinue(Context_t *context) if (context->playback->SlowMotion || context->playback->isForwarding || context->playback->BackWard) context->output->Command(context, OUTPUT_CLEAR, NULL); - if (context->playback->BackWard) + if (context->playback->BackWard || context->playback->isForwarding) context->output->Command(context, OUTPUT_AUDIOMUTE, "0"); context->playback->isPaused = 0; @@ -539,6 +539,7 @@ static int PlaybackFastForward(Context_t *context, int *speed) context->playback->Speed = *speed; playback_printf(20, "Speed: %d x {%d}\n", *speed, context->playback->Speed); context->output->Command(context, OUTPUT_FASTFORWARD, NULL); + context->output->Command(context, OUTPUT_AUDIOMUTE, "1"); context->output->Command(context, OUTPUT_CONTINUE, NULL); } else From 756e97af160f9fc379e0237e7e93f65cb0668a49 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Sun, 7 Oct 2018 12:00:41 +0200 Subject: [PATCH 51/59] libarmbox: move hdmi_cec to own class, add basic cec-remote support cec-remote will print received commands in log for now Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/062162611961de655c47856ec36394eb26537172 Author: TangoCash Date: 2018-10-07 (Sun, 07 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/Makefile.am | 3 +- libarmbox/hdmi_cec.cpp | 495 +++++++++++++++++++++++++++++++++++++++++ libarmbox/hdmi_cec.h | 66 ++++++ libarmbox/video.cpp | 221 +----------------- libarmbox/video_lib.h | 23 -- 5 files changed, 570 insertions(+), 238 deletions(-) create mode 100644 libarmbox/hdmi_cec.cpp create mode 100644 libarmbox/hdmi_cec.h diff --git a/libarmbox/Makefile.am b/libarmbox/Makefile.am index 4d5c162..d8453df 100644 --- a/libarmbox/Makefile.am +++ b/libarmbox/Makefile.am @@ -20,7 +20,8 @@ libarmbox_la_SOURCES = \ video.cpp \ audio.cpp \ init.cpp \ - record.cpp + record.cpp \ + hdmi_cec.cpp if ENABLE_GSTREAMER_10 libarmbox_la_SOURCES += \ diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp new file mode 100644 index 0000000..5edf404 --- /dev/null +++ b/libarmbox/hdmi_cec.cpp @@ -0,0 +1,495 @@ +/* + Copyright (C) 2018 TangoCash + + License: GPLv2 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "linux-uapi-cec.h" +#include "hdmi_cec.h" +#include "lt_debug.h" + +#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args) +#define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args) +#define lt_debug_c(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, NULL, args) +#define lt_info_c(args...) _lt_info(TRIPLE_DEBUG_VIDEO, NULL, args) + +#define fop(cmd, args...) ({ \ + int _r; \ + if (fd >= 0) { \ + if ((_r = ::cmd(fd, args)) < 0) \ + lt_info(#cmd"(fd, "#args")\n"); \ + else \ + lt_debug(#cmd"(fd, "#args")\n");\ + } \ + else { _r = fd; } \ + _r; \ +}) + +#define CEC_DEVICE "/dev/cec0" + +hdmi_cec * hdmi_cec::hdmi_cec_instance = NULL; + +hdmi_cec::hdmi_cec() +{ + standby_cec_activ = autoview_cec_activ = false; + hdmiFd = -1; + if (hdmiFd == -1) + hdmiFd = open(CEC_DEVICE, O_RDWR | O_CLOEXEC); + Start(); +} + +hdmi_cec::~hdmi_cec() +{ + if (hdmiFd >= 0) + { + close(hdmiFd); + hdmiFd = -1; + } +} + +hdmi_cec* hdmi_cec::getInstance() +{ + if (hdmi_cec_instance == NULL) + hdmi_cec_instance = new hdmi_cec(); + return hdmi_cec_instance; +} + +bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) +{ + physicalAddress[0] = 0x10; + physicalAddress[1] = 0x00; + logicalAddress = 1; + + if (_deviceType == VIDEO_HDMI_CEC_MODE_OFF) + { + if (hdmiFd >= 0) + { + close(hdmiFd); + hdmiFd = -1; + Stop(); + } + return false; + } + else + deviceType = _deviceType; + + if (hdmiFd == -1) + { + hdmiFd = open(CEC_DEVICE, O_RDWR | O_CLOEXEC); + Start(); + } + + if (hdmiFd >= 0) + { + __u32 monitor = CEC_MODE_INITIATOR | CEC_MODE_FOLLOWER; + struct cec_caps caps = {}; + + if (ioctl(hdmiFd, CEC_ADAP_G_CAPS, &caps) < 0) + lt_info("%s: CEC get caps failed (%m)\n", __func__); + + if (caps.capabilities & CEC_CAP_LOG_ADDRS) + { + struct cec_log_addrs laddrs = {}; + + if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0) + lt_info("%s: CEC reset log addr failed (%m)\n", __func__); + + memset(&laddrs, 0, sizeof(laddrs)); + + /* + * NOTE: cec_version, osd_name and deviceType should be made configurable, + * CEC_ADAP_S_LOG_ADDRS delayed till the desired values are available + * (saves us some startup speed as well, polling for a free logical address + * takes some time) + */ + laddrs.cec_version = CEC_OP_CEC_VERSION_2_0; + strcpy(laddrs.osd_name, "neutrino"); + laddrs.vendor_id = CEC_VENDOR_ID_NONE; + + switch (deviceType) + { + case CEC_LOG_ADDR_TV: + laddrs.log_addr_type[laddrs.num_log_addrs] = CEC_LOG_ADDR_TYPE_TV; + laddrs.all_device_types[laddrs.num_log_addrs] = CEC_OP_ALL_DEVTYPE_TV; + laddrs.primary_device_type[laddrs.num_log_addrs] = CEC_OP_PRIM_DEVTYPE_TV; + break; + case CEC_LOG_ADDR_RECORD_1: + laddrs.log_addr_type[laddrs.num_log_addrs] = CEC_LOG_ADDR_TYPE_RECORD; + laddrs.all_device_types[laddrs.num_log_addrs] = CEC_OP_ALL_DEVTYPE_RECORD; + laddrs.primary_device_type[laddrs.num_log_addrs] = CEC_OP_PRIM_DEVTYPE_RECORD; + break; + case CEC_LOG_ADDR_TUNER_1: + laddrs.log_addr_type[laddrs.num_log_addrs] = CEC_LOG_ADDR_TYPE_TUNER; + laddrs.all_device_types[laddrs.num_log_addrs] = CEC_OP_ALL_DEVTYPE_TUNER; + laddrs.primary_device_type[laddrs.num_log_addrs] = CEC_OP_PRIM_DEVTYPE_TUNER; + break; + case CEC_LOG_ADDR_PLAYBACK_1: + laddrs.log_addr_type[laddrs.num_log_addrs] = CEC_LOG_ADDR_TYPE_PLAYBACK; + laddrs.all_device_types[laddrs.num_log_addrs] = CEC_OP_ALL_DEVTYPE_PLAYBACK; + laddrs.primary_device_type[laddrs.num_log_addrs] = CEC_OP_PRIM_DEVTYPE_PLAYBACK; + break; + case CEC_LOG_ADDR_AUDIOSYSTEM: + laddrs.log_addr_type[laddrs.num_log_addrs] = CEC_LOG_ADDR_TYPE_AUDIOSYSTEM; + laddrs.all_device_types[laddrs.num_log_addrs] = CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM; + laddrs.primary_device_type[laddrs.num_log_addrs] = CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM; + break; + default: + laddrs.log_addr_type[laddrs.num_log_addrs] = CEC_LOG_ADDR_TYPE_UNREGISTERED; + laddrs.all_device_types[laddrs.num_log_addrs] = CEC_OP_ALL_DEVTYPE_SWITCH; + laddrs.primary_device_type[laddrs.num_log_addrs] = CEC_OP_PRIM_DEVTYPE_SWITCH; + break; + } + laddrs.num_log_addrs++; + + if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0) + lt_info("%s: CEC set log addr failed (%m)\n", __func__); + } + + if (ioctl(hdmiFd, CEC_S_MODE, &monitor) < 0) + lt_info("%s: CEC monitor failed (%m)\n", __func__); + + GetCECAddressInfo(); + + if(autoview_cec_activ) + SetCECState(false); + + return true; + + } + return false; +} + +void hdmi_cec::GetCECAddressInfo() +{ + if (hdmiFd >= 0) + { + struct addressinfo addressinfo; + + __u16 phys_addr; + struct cec_log_addrs laddrs = {}; + + ::ioctl(hdmiFd, CEC_ADAP_G_PHYS_ADDR, &phys_addr); + addressinfo.physical[0] = (phys_addr >> 8) & 0xff; + addressinfo.physical[1] = phys_addr & 0xff; + + ::ioctl(hdmiFd, CEC_ADAP_G_LOG_ADDRS, &laddrs); + addressinfo.logical = laddrs.log_addr[0]; + + switch (laddrs.log_addr_type[0]) + { + case CEC_LOG_ADDR_TYPE_TV: + addressinfo.type = CEC_LOG_ADDR_TV; + break; + case CEC_LOG_ADDR_TYPE_RECORD: + addressinfo.type = CEC_LOG_ADDR_RECORD_1; + break; + case CEC_LOG_ADDR_TYPE_TUNER: + addressinfo.type = CEC_LOG_ADDR_TUNER_1; + break; + case CEC_LOG_ADDR_TYPE_PLAYBACK: + addressinfo.type = CEC_LOG_ADDR_PLAYBACK_1; + break; + case CEC_LOG_ADDR_TYPE_AUDIOSYSTEM: + addressinfo.type = CEC_LOG_ADDR_AUDIOSYSTEM; + break; + case CEC_LOG_ADDR_TYPE_UNREGISTERED: + default: + addressinfo.type = CEC_LOG_ADDR_UNREGISTERED; + break; + } + + deviceType = addressinfo.type; + logicalAddress = addressinfo.logical; + if (memcmp(physicalAddress, addressinfo.physical, sizeof(physicalAddress))) + { + lt_info("%s: detected physical address change: %02X%02X --> %02X%02X\n", __func__, physicalAddress[0], physicalAddress[1], addressinfo.physical[0], addressinfo.physical[1]); + memcpy(physicalAddress, addressinfo.physical, sizeof(physicalAddress)); + ReportPhysicalAddress(); + } + } +} + +void hdmi_cec::ReportPhysicalAddress() +{ + struct cec_message txmessage; + txmessage.address = 0x0f; /* broadcast */ + txmessage.data[0] = CEC_MSG_REPORT_PHYSICAL_ADDR; + txmessage.data[1] = physicalAddress[0]; + txmessage.data[2] = physicalAddress[1]; + txmessage.data[3] = deviceType; + txmessage.length = 4; + SendCECMessage(txmessage); +} + +void hdmi_cec::SendCECMessage(struct cec_message &txmessage) +{ + if (hdmiFd >= 0) + { + char str[txmessage.length*6]; + for (int i = 0; i < txmessage.length; i++) + { + sprintf(str+(i*6),"(0x%02X)", txmessage.data[i]); + } + lt_info("[CEC] send message %s\n",str); + struct cec_msg msg; + cec_msg_init(&msg, logicalAddress, txmessage.address); + memcpy(&msg.msg[1], txmessage.data, txmessage.length); + msg.len = txmessage.length + 1; + ioctl(hdmiFd, CEC_TRANSMIT, &msg); + } +} + +void hdmi_cec::SetCECAutoStandby(bool state) +{ + standby_cec_activ = state; +} + +void hdmi_cec::SetCECAutoView(bool state) +{ + autoview_cec_activ = state; +} + +void hdmi_cec::SetCECState(bool state) +{ + struct cec_message message; + + if ((standby_cec_activ) && state) + { + message.address = CEC_OP_PRIM_DEVTYPE_TV; + message.data[0] = CEC_MSG_STANDBY; + message.length = 1; + SendCECMessage(message); + } + + if ((autoview_cec_activ) && !state) + { + message.address = CEC_OP_PRIM_DEVTYPE_TV; + message.data[0] = CEC_MSG_IMAGE_VIEW_ON; + message.length = 1; + SendCECMessage(message); + usleep(10000); + message.address = 0x0f; /* broadcast */ + message.data[0] = CEC_MSG_ACTIVE_SOURCE; + message.data[1] = physicalAddress[0]; + message.data[2] = physicalAddress[1]; + message.length = 3; + SendCECMessage(message); + } + +} + +long hdmi_cec::translateKey(unsigned char code) +{ + long key = 0; + switch (code) + { + case 0x32: + key = 0x8b; + break; + case 0x20: + key = 0x0b; + break; + case 0x21: + key = 0x02; + break; + case 0x22: + key = 0x03; + break; + case 0x23: + key = 0x04; + break; + case 0x24: + key = 0x05; + break; + case 0x25: + key = 0x06; + break; + case 0x26: + key = 0x07; + break; + case 0x27: + key = 0x08; + break; + case 0x28: + key = 0x09; + break; + case 0x29: + key = 0x0a; + break; + case 0x30: + key = 0x192; + break; + case 0x31: + key = 0x193; + break; + case 0x44: + key = 0xcf; + break; + case 0x45: + key = 0x80; + break; + case 0x46: + key = 0x77; + break; + case 0x47: + key = 0xa7; + break; + case 0x48: + key = 0xa8; + break; + case 0x49: + key = 0xd0; + break; + case 0x53: + key = 0x166; + break; + case 0x54: + key = 0x16a; + break; + case 0x60: + key = 0xcf; + break; + case 0x61: + key = 0xa4; + break; + case 0x62: + key = 0xa7; + break; + case 0x64: + key = 0x80; + break; + case 0x00: + key = 0x160; + break; + case 0x03: + key = 0x69; + break; + case 0x04: + key = 0x6a; + break; + case 0x01: + key = 0x67; + break; + case 0x02: + key = 0x6c; + break; + case 0x0d: + key = 0xae; + break; + case 0x72: + key = 0x18e; + break; + case 0x71: + key = 0x191; + break; + case 0x73: + key = 0x18f; + break; + case 0x74: + key = 0x190; + break; + default: + key = 0x8b; + break; + } + return key; +} + +bool hdmi_cec::Start() +{ + if (running) + return false; + + if (hdmiFd == -1) + return false; + + running = true; + return (OpenThreads::Thread::start() == 0); +} + +bool hdmi_cec::Stop() +{ + if (!running) + return false; + + running = false; + + return (OpenThreads::Thread::join() == 0); +} + +void hdmi_cec::run() +{ + while (running) + { + Receive(); + } +} + +void hdmi_cec::Receive() +{ + bool hasdata = false; + struct cec_message rxmessage; + + struct cec_msg msg; + if (::ioctl(hdmiFd, CEC_RECEIVE, &msg) >= 0) + { + rxmessage.length = msg.len - 1; + memcpy(&rxmessage.data, &msg.msg[1], rxmessage.length); + hasdata = true; + } + + if (hasdata) + { + bool keypressed = false; + static unsigned char pressedkey = 0; + + char str[rxmessage.length*6]; + for (int i = 0; i < rxmessage.length; i++) + { + sprintf(str+(i*6),"(0x%02X)", rxmessage.data[i]); + } + lt_info("[CEC] received message %s\n", str); + + switch (rxmessage.data[0]) + { + case 0x44: /* key pressed */ + keypressed = true; + pressedkey = rxmessage.data[1]; + case 0x45: /* key released */ + { + long code = translateKey(pressedkey); + if (keypressed) + code |= 0x80000000; + lt_info("[CEC] received key %ld\n",code); + break; + } + } + } +} diff --git a/libarmbox/hdmi_cec.h b/libarmbox/hdmi_cec.h new file mode 100644 index 0000000..0dc97cb --- /dev/null +++ b/libarmbox/hdmi_cec.h @@ -0,0 +1,66 @@ +/* + Copyright (C) 2018 TangoCash + + License: GPLv2 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include +#include + +#include "video_lib.h" + +struct cec_message +{ + unsigned char address; + unsigned char length; + unsigned char data[256]; +} __attribute__((packed)); + +struct addressinfo +{ + unsigned char logical; + unsigned char physical[2]; + unsigned char type; +}; + +class hdmi_cec : public OpenThreads::Thread +{ +private: + hdmi_cec(); + static hdmi_cec *hdmi_cec_instance; + void run(); + bool Start(); + bool Stop(); + void Receive(); + unsigned char physicalAddress[2]; + bool autoview_cec_activ; + unsigned char deviceType, logicalAddress; + int hdmiFd; + long translateKey(unsigned char code); +protected: + bool running; +public: + ~hdmi_cec(); + static hdmi_cec* getInstance(); + bool SetCECMode(VIDEO_HDMI_CEC_MODE); + void SetCECAutoView(bool); + void SetCECAutoStandby(bool); + void GetCECAddressInfo(); + void SendCECMessage(struct cec_message &message); + void SetCECState(bool state); + void ReportPhysicalAddress(); + bool standby_cec_activ; +}; diff --git a/libarmbox/video.cpp b/libarmbox/video.cpp index 73fc02a..e05f3c3 100644 --- a/libarmbox/video.cpp +++ b/libarmbox/video.cpp @@ -36,7 +36,7 @@ #include #include "video_lib.h" #include "lt_debug.h" -#include "linux-uapi-cec.h" +#include "hdmi_cec.h" #include @@ -326,8 +326,6 @@ cVideo::cVideo(int, void *, void *, unsigned int unit) } else devnum = unit; fd = -1; - hdmiFd = -1; - standby_cec_activ = autoview_cec_activ = false; openDevice(); setAVInput(ENCODER); } @@ -336,8 +334,8 @@ cVideo::~cVideo(void) { if(fd >= 0) setAVInput(AUX); - if (standby_cec_activ && fd >= 0) - SetCECState(true); + if (hdmi_cec::getInstance()->standby_cec_activ && fd >= 0) + hdmi_cec::getInstance()->SetCECState(true); closeDevice(); } @@ -640,7 +638,7 @@ void cVideo::Standby(unsigned int bOn) setAVInput(ENCODER); } video_standby = bOn; - SetCECState(video_standby); + hdmi_cec::getInstance()->SetCECState(video_standby); } int cVideo::getBlank(void) @@ -1171,220 +1169,15 @@ bool cVideo::GetScreenImage(unsigned char * &out_data, int &xres, int &yres, boo bool cVideo::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) { - physicalAddress[0] = 0x10; - physicalAddress[1] = 0x00; - logicalAddress = 1; - - if (_deviceType == VIDEO_HDMI_CEC_MODE_OFF) - { - if (hdmiFd >= 0) { - close(hdmiFd); - hdmiFd = -1; - } - return false; - } - else - deviceType = _deviceType; - - if (hdmiFd == -1) - hdmiFd = open("/dev/cec0", O_RDWR | O_CLOEXEC); - - if (hdmiFd >= 0) - { - __u32 monitor = CEC_MODE_INITIATOR | CEC_MODE_FOLLOWER; - struct cec_caps caps = {}; - - if (ioctl(hdmiFd, CEC_ADAP_G_CAPS, &caps) < 0) - lt_info("%s: CEC get caps failed (%m)\n", __func__); - - if (caps.capabilities & CEC_CAP_LOG_ADDRS) - { - struct cec_log_addrs laddrs = {}; - - if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0) - lt_info("%s: CEC reset log addr failed (%m)\n", __func__); - - memset(&laddrs, 0, sizeof(laddrs)); - - /* - * NOTE: cec_version, osd_name and deviceType should be made configurable, - * CEC_ADAP_S_LOG_ADDRS delayed till the desired values are available - * (saves us some startup speed as well, polling for a free logical address - * takes some time) - */ - laddrs.cec_version = CEC_OP_CEC_VERSION_2_0; - strcpy(laddrs.osd_name, "neutrino"); - laddrs.vendor_id = CEC_VENDOR_ID_NONE; - - switch (deviceType) - { - case CEC_LOG_ADDR_TV: - laddrs.log_addr_type[laddrs.num_log_addrs] = CEC_LOG_ADDR_TYPE_TV; - laddrs.all_device_types[laddrs.num_log_addrs] = CEC_OP_ALL_DEVTYPE_TV; - laddrs.primary_device_type[laddrs.num_log_addrs] = CEC_OP_PRIM_DEVTYPE_TV; - break; - case CEC_LOG_ADDR_RECORD_1: - laddrs.log_addr_type[laddrs.num_log_addrs] = CEC_LOG_ADDR_TYPE_RECORD; - laddrs.all_device_types[laddrs.num_log_addrs] = CEC_OP_ALL_DEVTYPE_RECORD; - laddrs.primary_device_type[laddrs.num_log_addrs] = CEC_OP_PRIM_DEVTYPE_RECORD; - break; - case CEC_LOG_ADDR_TUNER_1: - laddrs.log_addr_type[laddrs.num_log_addrs] = CEC_LOG_ADDR_TYPE_TUNER; - laddrs.all_device_types[laddrs.num_log_addrs] = CEC_OP_ALL_DEVTYPE_TUNER; - laddrs.primary_device_type[laddrs.num_log_addrs] = CEC_OP_PRIM_DEVTYPE_TUNER; - break; - case CEC_LOG_ADDR_PLAYBACK_1: - laddrs.log_addr_type[laddrs.num_log_addrs] = CEC_LOG_ADDR_TYPE_PLAYBACK; - laddrs.all_device_types[laddrs.num_log_addrs] = CEC_OP_ALL_DEVTYPE_PLAYBACK; - laddrs.primary_device_type[laddrs.num_log_addrs] = CEC_OP_PRIM_DEVTYPE_PLAYBACK; - break; - case CEC_LOG_ADDR_AUDIOSYSTEM: - laddrs.log_addr_type[laddrs.num_log_addrs] = CEC_LOG_ADDR_TYPE_AUDIOSYSTEM; - laddrs.all_device_types[laddrs.num_log_addrs] = CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM; - laddrs.primary_device_type[laddrs.num_log_addrs] = CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM; - break; - default: - laddrs.log_addr_type[laddrs.num_log_addrs] = CEC_LOG_ADDR_TYPE_UNREGISTERED; - laddrs.all_device_types[laddrs.num_log_addrs] = CEC_OP_ALL_DEVTYPE_SWITCH; - laddrs.primary_device_type[laddrs.num_log_addrs] = CEC_OP_PRIM_DEVTYPE_SWITCH; - break; - } - laddrs.num_log_addrs++; - - if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0) - lt_info("%s: CEC set log addr failed (%m)\n", __func__); - } - - if (ioctl(hdmiFd, CEC_S_MODE, &monitor) < 0) - lt_info("%s: CEC monitor failed (%m)\n", __func__); - - GetCECAddressInfo(); - - if(autoview_cec_activ) - SetCECState(false); - - return true; - - } - return false; -} - -void cVideo::GetCECAddressInfo() -{ - if (hdmiFd >= 0) - { - struct addressinfo addressinfo; - - __u16 phys_addr; - struct cec_log_addrs laddrs = {}; - - ::ioctl(hdmiFd, CEC_ADAP_G_PHYS_ADDR, &phys_addr); - addressinfo.physical[0] = (phys_addr >> 8) & 0xff; - addressinfo.physical[1] = phys_addr & 0xff; - - ::ioctl(hdmiFd, CEC_ADAP_G_LOG_ADDRS, &laddrs); - addressinfo.logical = laddrs.log_addr[0]; - - switch (laddrs.log_addr_type[0]) - { - case CEC_LOG_ADDR_TYPE_TV: - addressinfo.type = CEC_LOG_ADDR_TV; - break; - case CEC_LOG_ADDR_TYPE_RECORD: - addressinfo.type = CEC_LOG_ADDR_RECORD_1; - break; - case CEC_LOG_ADDR_TYPE_TUNER: - addressinfo.type = CEC_LOG_ADDR_TUNER_1; - break; - case CEC_LOG_ADDR_TYPE_PLAYBACK: - addressinfo.type = CEC_LOG_ADDR_PLAYBACK_1; - break; - case CEC_LOG_ADDR_TYPE_AUDIOSYSTEM: - addressinfo.type = CEC_LOG_ADDR_AUDIOSYSTEM; - break; - case CEC_LOG_ADDR_TYPE_UNREGISTERED: - default: - addressinfo.type = CEC_LOG_ADDR_UNREGISTERED; - break; - } - - deviceType = addressinfo.type; - logicalAddress = addressinfo.logical; - if (memcmp(physicalAddress, addressinfo.physical, sizeof(physicalAddress))) - { - lt_info("%s: detected physical address change: %02X%02X --> %02X%02X", __func__, physicalAddress[0], physicalAddress[1], addressinfo.physical[0], addressinfo.physical[1]); - memcpy(physicalAddress, addressinfo.physical, sizeof(physicalAddress)); - ReportPhysicalAddress(); - // addressChanged((physicalAddress[0] << 8) | physicalAddress[1]); - } - } -} - -void cVideo::ReportPhysicalAddress() -{ - struct cec_message txmessage; - txmessage.address = 0x0f; /* broadcast */ - txmessage.data[0] = CEC_MSG_REPORT_PHYSICAL_ADDR; - txmessage.data[1] = physicalAddress[0]; - txmessage.data[2] = physicalAddress[1]; - txmessage.data[3] = deviceType; - txmessage.length = 4; - SendCECMessage(txmessage); -} - -void cVideo::SendCECMessage(struct cec_message &message) -{ - if (hdmiFd >= 0) - { - lt_info("[CEC] send message"); - for (int i = 0; i < message.length; i++) - { - lt_info(" %02X", message.data[i]); - } - lt_info("\n"); - struct cec_msg msg; - cec_msg_init(&msg, logicalAddress, message.address); - memcpy(&msg.msg[1], message.data, message.length); - msg.len = message.length + 1; - ioctl(hdmiFd, CEC_TRANSMIT, &msg); - } + return hdmi_cec::getInstance()->SetCECMode(_deviceType); } void cVideo::SetCECAutoStandby(bool state) { - standby_cec_activ = state; + hdmi_cec::getInstance()->SetCECAutoStandby(state); } void cVideo::SetCECAutoView(bool state) { - autoview_cec_activ = state; -} - -void cVideo::SetCECState(bool state) -{ - struct cec_message message; - - if ((standby_cec_activ) && state){ - message.address = CEC_OP_PRIM_DEVTYPE_TV; - message.data[0] = CEC_MSG_STANDBY; - message.length = 1; - SendCECMessage(message); - } - - if ((autoview_cec_activ) && !state){ - message.address = CEC_OP_PRIM_DEVTYPE_TV; - message.data[0] = CEC_MSG_IMAGE_VIEW_ON; - message.length = 1; - SendCECMessage(message); - usleep(10000); - message.address = 0x0f; /* broadcast */ - message.data[0] = CEC_MSG_ACTIVE_SOURCE; - //message.data[1] = ((((int)physicalAddress >> 12) & 0xf) << 4) + (((int)physicalAddress >> 8) & 0xf); - //message.data[2] = ((((int)physicalAddress >> 4) & 0xf) << 4) + (((int)physicalAddress >> 0) & 0xf); - message.data[1] = physicalAddress[0]; - message.data[2] = physicalAddress[1]; - message.length = 3; - SendCECMessage(message); - } - + hdmi_cec::getInstance()->SetCECAutoView(state); } diff --git a/libarmbox/video_lib.h b/libarmbox/video_lib.h index d14354e..edec65d 100644 --- a/libarmbox/video_lib.h +++ b/libarmbox/video_lib.h @@ -148,20 +148,6 @@ typedef enum VIDEO_CONTROL_MAX = VIDEO_CONTROL_SHARPNESS } VIDEO_CONTROL; -struct cec_message -{ - unsigned char address; - unsigned char length; - unsigned char data[256]; -}__attribute__((packed)); -#define cec_rx_message cec_message -struct addressinfo -{ - unsigned char logical; - unsigned char physical[2]; - unsigned char type; -}; - class cDemux; class cPlayback; @@ -205,11 +191,6 @@ class cVideo /* used internally by dmx */ int64_t GetPTS(void); - unsigned char physicalAddress[2]; - bool standby_cec_activ,autoview_cec_activ; - unsigned char deviceType, logicalAddress; - int hdmiFd; - public: /* constructor & destructor */ cVideo(int mode, void *, void *, unsigned int unit = 0); @@ -254,10 +235,6 @@ class cVideo bool SetCECMode(VIDEO_HDMI_CEC_MODE); void SetCECAutoView(bool); void SetCECAutoStandby(bool); - void GetCECAddressInfo(); - void SendCECMessage(struct cec_message &message); - void SetCECState(bool state); - void ReportPhysicalAddress(); void ShowPicture(const char * fname); void StopPicture(); void Standby(unsigned int bOn); From ab7f762bae9d325ab842f7fe0553b6e4ab994b4d Mon Sep 17 00:00:00 2001 From: TangoCash Date: Sun, 7 Oct 2018 18:43:31 +0200 Subject: [PATCH 52/59] libarmbox: fix hdmi_cec handling Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/d58558c82a078b49b2ceaeac353054a2cc3e0f3f Author: TangoCash Date: 2018-10-07 (Sun, 07 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index 5edf404..ddea9b6 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -60,9 +60,6 @@ hdmi_cec::hdmi_cec() { standby_cec_activ = autoview_cec_activ = false; hdmiFd = -1; - if (hdmiFd == -1) - hdmiFd = open(CEC_DEVICE, O_RDWR | O_CLOEXEC); - Start(); } hdmi_cec::~hdmi_cec() @@ -89,21 +86,18 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) if (_deviceType == VIDEO_HDMI_CEC_MODE_OFF) { - if (hdmiFd >= 0) - { - close(hdmiFd); - hdmiFd = -1; - Stop(); - } + Stop(); + lt_debug("CEC OFF %s\n", __func__); return false; } else deviceType = _deviceType; + lt_debug("CEC ON %s\n", __func__); + if (hdmiFd == -1) { - hdmiFd = open(CEC_DEVICE, O_RDWR | O_CLOEXEC); - Start(); + hdmiFd = open(CEC_DEVICE, O_RDWR | O_NONBLOCK); } if (hdmiFd >= 0) @@ -180,6 +174,7 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) if(autoview_cec_activ) SetCECState(false); + Start(); return true; } @@ -441,12 +436,18 @@ bool hdmi_cec::Stop() running = false; + if (hdmiFd >= 0) + { + close(hdmiFd); + hdmiFd = -1; + } + return (OpenThreads::Thread::join() == 0); } void hdmi_cec::run() { - while (running) + while (running && (hdmiFd >= 0)) { Receive(); } From 340c4a7fa584aeb8be675a435ac34040a97219dc Mon Sep 17 00:00:00 2001 From: TangoCash Date: Sun, 7 Oct 2018 22:21:38 +0200 Subject: [PATCH 53/59] libarmbox: hdmi_cec add some more output Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/97ca22c7fab2fdb9cf1677c74d6b8fab0b35d72f Author: TangoCash Date: 2018-10-07 (Sun, 07 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 26 +- libarmbox/hdmi_cec_types.h | 600 +++++++++++++++++++++++++++++++++++++ 2 files changed, 619 insertions(+), 7 deletions(-) create mode 100644 libarmbox/hdmi_cec_types.h diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index ddea9b6..a45597d 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -33,8 +33,12 @@ #include "linux-uapi-cec.h" #include "hdmi_cec.h" +#include "hdmi_cec_types.h" #include "lt_debug.h" +#define RED "\x1B[31m" +#define NORMAL "\x1B[0m" + #define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args) #define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args) #define lt_debug_c(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, NULL, args) @@ -250,9 +254,9 @@ void hdmi_cec::SendCECMessage(struct cec_message &txmessage) char str[txmessage.length*6]; for (int i = 0; i < txmessage.length; i++) { - sprintf(str+(i*6),"(0x%02X)", txmessage.data[i]); + sprintf(str+(i*6),"[0x%02X]", txmessage.data[i]); } - lt_info("[CEC] send message %s\n",str); + lt_info("[CEC] send message '%s' (%s)\n", ToString((cec_opcode)txmessage.data[0]), str); struct cec_msg msg; cec_msg_init(&msg, logicalAddress, txmessage.address); memcpy(&msg.msg[1], txmessage.data, txmessage.length); @@ -474,21 +478,29 @@ void hdmi_cec::Receive() char str[rxmessage.length*6]; for (int i = 0; i < rxmessage.length; i++) { - sprintf(str+(i*6),"(0x%02X)", rxmessage.data[i]); + sprintf(str+(i*6),"[0x%02X]", rxmessage.data[i]); } - lt_info("[CEC] received message %s\n", str); + lt_info("[CEC] received message '%s' (%s)\n", ToString((cec_opcode)rxmessage.data[0]), str); switch (rxmessage.data[0]) { - case 0x44: /* key pressed */ + case CEC_MSG_DEVICE_VENDOR_ID: + { + uint64_t iVendorId = ((uint64_t)rxmessage.data[1] << 16) + + ((uint64_t)rxmessage.data[2] << 8) + + (uint64_t)rxmessage.data[3]; + lt_info("[CEC] decoded message '%s' (%s)\n", ToString((cec_opcode)rxmessage.data[0]), ToString((cec_vendor_id)iVendorId)); + break; + } + case CEC_MSG_USER_CONTROL_PRESSED: /* key pressed */ keypressed = true; pressedkey = rxmessage.data[1]; - case 0x45: /* key released */ + case CEC_MSG_USER_CONTROL_RELEASED: /* key released */ { long code = translateKey(pressedkey); if (keypressed) code |= 0x80000000; - lt_info("[CEC] received key %ld\n",code); + lt_info("[CEC] decoded key %s (%ld)\n",ToString((cec_user_control_code)pressedkey), code); break; } } diff --git a/libarmbox/hdmi_cec_types.h b/libarmbox/hdmi_cec_types.h new file mode 100644 index 0000000..f5808af --- /dev/null +++ b/libarmbox/hdmi_cec_types.h @@ -0,0 +1,600 @@ +typedef enum cec_vendor_id +{ + CEC_VENDOR_TOSHIBA = 0x000039, + CEC_VENDOR_SAMSUNG = 0x0000F0, + CEC_VENDOR_DENON = 0x0005CD, + CEC_VENDOR_MARANTZ = 0x000678, + CEC_VENDOR_LOEWE = 0x000982, + CEC_VENDOR_ONKYO = 0x0009B0, + CEC_VENDOR_MEDION = 0x000CB8, + CEC_VENDOR_TOSHIBA2 = 0x000CE7, + CEC_VENDOR_PULSE_EIGHT = 0x001582, + CEC_VENDOR_HARMAN_KARDON2 = 0x001950, + CEC_VENDOR_GOOGLE = 0x001A11, + CEC_VENDOR_AKAI = 0x0020C7, + CEC_VENDOR_AOC = 0x002467, + CEC_VENDOR_PANASONIC = 0x008045, + CEC_VENDOR_PHILIPS = 0x00903E, + CEC_VENDOR_DAEWOO = 0x009053, + CEC_VENDOR_YAMAHA = 0x00A0DE, + CEC_VENDOR_GRUNDIG = 0x00D0D5, + CEC_VENDOR_PIONEER = 0x00E036, + CEC_VENDOR_LG = 0x00E091, + CEC_VENDOR_SHARP = 0x08001F, + CEC_VENDOR_SONY = 0x080046, + CEC_VENDOR_BROADCOM = 0x18C086, + CEC_VENDOR_SHARP2 = 0x534850, + CEC_VENDOR_VIZIO = 0x6B746D, + CEC_VENDOR_BENQ = 0x8065E9, + CEC_VENDOR_HARMAN_KARDON = 0x9C645E, + CEC_VENDOR_UNKNOWN = 0 +} cec_vendor_id; + +typedef enum cec_user_control_code +{ + CEC_USER_CONTROL_CODE_SELECT = 0x00, + CEC_USER_CONTROL_CODE_UP = 0x01, + CEC_USER_CONTROL_CODE_DOWN = 0x02, + CEC_USER_CONTROL_CODE_LEFT = 0x03, + CEC_USER_CONTROL_CODE_RIGHT = 0x04, + CEC_USER_CONTROL_CODE_RIGHT_UP = 0x05, + CEC_USER_CONTROL_CODE_RIGHT_DOWN = 0x06, + CEC_USER_CONTROL_CODE_LEFT_UP = 0x07, + CEC_USER_CONTROL_CODE_LEFT_DOWN = 0x08, + CEC_USER_CONTROL_CODE_ROOT_MENU = 0x09, + CEC_USER_CONTROL_CODE_SETUP_MENU = 0x0A, + CEC_USER_CONTROL_CODE_CONTENTS_MENU = 0x0B, + CEC_USER_CONTROL_CODE_FAVORITE_MENU = 0x0C, + CEC_USER_CONTROL_CODE_EXIT = 0x0D, + // reserved: 0x0E, 0x0F + CEC_USER_CONTROL_CODE_TOP_MENU = 0x10, + CEC_USER_CONTROL_CODE_DVD_MENU = 0x11, + // reserved: 0x12 ... 0x1C + CEC_USER_CONTROL_CODE_NUMBER_ENTRY_MODE = 0x1D, + CEC_USER_CONTROL_CODE_NUMBER11 = 0x1E, + CEC_USER_CONTROL_CODE_NUMBER12 = 0x1F, + CEC_USER_CONTROL_CODE_NUMBER0 = 0x20, + CEC_USER_CONTROL_CODE_NUMBER1 = 0x21, + CEC_USER_CONTROL_CODE_NUMBER2 = 0x22, + CEC_USER_CONTROL_CODE_NUMBER3 = 0x23, + CEC_USER_CONTROL_CODE_NUMBER4 = 0x24, + CEC_USER_CONTROL_CODE_NUMBER5 = 0x25, + CEC_USER_CONTROL_CODE_NUMBER6 = 0x26, + CEC_USER_CONTROL_CODE_NUMBER7 = 0x27, + CEC_USER_CONTROL_CODE_NUMBER8 = 0x28, + CEC_USER_CONTROL_CODE_NUMBER9 = 0x29, + CEC_USER_CONTROL_CODE_DOT = 0x2A, + CEC_USER_CONTROL_CODE_ENTER = 0x2B, + CEC_USER_CONTROL_CODE_CLEAR = 0x2C, + CEC_USER_CONTROL_CODE_NEXT_FAVORITE = 0x2F, + CEC_USER_CONTROL_CODE_CHANNEL_UP = 0x30, + CEC_USER_CONTROL_CODE_CHANNEL_DOWN = 0x31, + CEC_USER_CONTROL_CODE_PREVIOUS_CHANNEL = 0x32, + CEC_USER_CONTROL_CODE_SOUND_SELECT = 0x33, + CEC_USER_CONTROL_CODE_INPUT_SELECT = 0x34, + CEC_USER_CONTROL_CODE_DISPLAY_INFORMATION = 0x35, + CEC_USER_CONTROL_CODE_HELP = 0x36, + CEC_USER_CONTROL_CODE_PAGE_UP = 0x37, + CEC_USER_CONTROL_CODE_PAGE_DOWN = 0x38, + // reserved: 0x39 ... 0x3F + CEC_USER_CONTROL_CODE_POWER = 0x40, + CEC_USER_CONTROL_CODE_VOLUME_UP = 0x41, + CEC_USER_CONTROL_CODE_VOLUME_DOWN = 0x42, + CEC_USER_CONTROL_CODE_MUTE = 0x43, + CEC_USER_CONTROL_CODE_PLAY = 0x44, + CEC_USER_CONTROL_CODE_STOP = 0x45, + CEC_USER_CONTROL_CODE_PAUSE = 0x46, + CEC_USER_CONTROL_CODE_RECORD = 0x47, + CEC_USER_CONTROL_CODE_REWIND = 0x48, + CEC_USER_CONTROL_CODE_FAST_FORWARD = 0x49, + CEC_USER_CONTROL_CODE_EJECT = 0x4A, + CEC_USER_CONTROL_CODE_FORWARD = 0x4B, + CEC_USER_CONTROL_CODE_BACKWARD = 0x4C, + CEC_USER_CONTROL_CODE_STOP_RECORD = 0x4D, + CEC_USER_CONTROL_CODE_PAUSE_RECORD = 0x4E, + // reserved: 0x4F + CEC_USER_CONTROL_CODE_ANGLE = 0x50, + CEC_USER_CONTROL_CODE_SUB_PICTURE = 0x51, + CEC_USER_CONTROL_CODE_VIDEO_ON_DEMAND = 0x52, + CEC_USER_CONTROL_CODE_ELECTRONIC_PROGRAM_GUIDE = 0x53, + CEC_USER_CONTROL_CODE_TIMER_PROGRAMMING = 0x54, + CEC_USER_CONTROL_CODE_INITIAL_CONFIGURATION = 0x55, + CEC_USER_CONTROL_CODE_SELECT_BROADCAST_TYPE = 0x56, + CEC_USER_CONTROL_CODE_SELECT_SOUND_PRESENTATION = 0x57, + // reserved: 0x58 ... 0x5F + CEC_USER_CONTROL_CODE_PLAY_FUNCTION = 0x60, + CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION = 0x61, + CEC_USER_CONTROL_CODE_RECORD_FUNCTION = 0x62, + CEC_USER_CONTROL_CODE_PAUSE_RECORD_FUNCTION = 0x63, + CEC_USER_CONTROL_CODE_STOP_FUNCTION = 0x64, + CEC_USER_CONTROL_CODE_MUTE_FUNCTION = 0x65, + CEC_USER_CONTROL_CODE_RESTORE_VOLUME_FUNCTION = 0x66, + CEC_USER_CONTROL_CODE_TUNE_FUNCTION = 0x67, + CEC_USER_CONTROL_CODE_SELECT_MEDIA_FUNCTION = 0x68, + CEC_USER_CONTROL_CODE_SELECT_AV_INPUT_FUNCTION = 0x69, + CEC_USER_CONTROL_CODE_SELECT_AUDIO_INPUT_FUNCTION = 0x6A, + CEC_USER_CONTROL_CODE_POWER_TOGGLE_FUNCTION = 0x6B, + CEC_USER_CONTROL_CODE_POWER_OFF_FUNCTION = 0x6C, + CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION = 0x6D, + // reserved: 0x6E ... 0x70 + CEC_USER_CONTROL_CODE_F1_BLUE = 0x71, + CEC_USER_CONTROL_CODE_F2_RED = 0X72, + CEC_USER_CONTROL_CODE_F3_GREEN = 0x73, + CEC_USER_CONTROL_CODE_F4_YELLOW = 0x74, + CEC_USER_CONTROL_CODE_F5 = 0x75, + CEC_USER_CONTROL_CODE_DATA = 0x76, + // reserved: 0x77 ... 0xFF + CEC_USER_CONTROL_CODE_AN_RETURN = 0x91, // return (Samsung) + CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST = 0x96, // channels list (Samsung) + CEC_USER_CONTROL_CODE_MAX = 0x96, + CEC_USER_CONTROL_CODE_UNKNOWN = 0xFF +} cec_user_control_code; + +typedef enum cec_opcode +{ + CEC_OPCODE_ACTIVE_SOURCE = 0x82, + CEC_OPCODE_IMAGE_VIEW_ON = 0x04, + CEC_OPCODE_TEXT_VIEW_ON = 0x0D, + CEC_OPCODE_INACTIVE_SOURCE = 0x9D, + CEC_OPCODE_REQUEST_ACTIVE_SOURCE = 0x85, + CEC_OPCODE_ROUTING_CHANGE = 0x80, + CEC_OPCODE_ROUTING_INFORMATION = 0x81, + CEC_OPCODE_SET_STREAM_PATH = 0x86, + CEC_OPCODE_STANDBY = 0x36, + CEC_OPCODE_RECORD_OFF = 0x0B, + CEC_OPCODE_RECORD_ON = 0x09, + CEC_OPCODE_RECORD_STATUS = 0x0A, + CEC_OPCODE_RECORD_TV_SCREEN = 0x0F, + CEC_OPCODE_CLEAR_ANALOGUE_TIMER = 0x33, + CEC_OPCODE_CLEAR_DIGITAL_TIMER = 0x99, + CEC_OPCODE_CLEAR_EXTERNAL_TIMER = 0xA1, + CEC_OPCODE_SET_ANALOGUE_TIMER = 0x34, + CEC_OPCODE_SET_DIGITAL_TIMER = 0x97, + CEC_OPCODE_SET_EXTERNAL_TIMER = 0xA2, + CEC_OPCODE_SET_TIMER_PROGRAM_TITLE = 0x67, + CEC_OPCODE_TIMER_CLEARED_STATUS = 0x43, + CEC_OPCODE_TIMER_STATUS = 0x35, + CEC_OPCODE_CEC_VERSION = 0x9E, + CEC_OPCODE_GET_CEC_VERSION = 0x9F, + CEC_OPCODE_GIVE_PHYSICAL_ADDRESS = 0x83, + CEC_OPCODE_GET_MENU_LANGUAGE = 0x91, + CEC_OPCODE_REPORT_PHYSICAL_ADDRESS = 0x84, + CEC_OPCODE_SET_MENU_LANGUAGE = 0x32, + CEC_OPCODE_DECK_CONTROL = 0x42, + CEC_OPCODE_DECK_STATUS = 0x1B, + CEC_OPCODE_GIVE_DECK_STATUS = 0x1A, + CEC_OPCODE_PLAY = 0x41, + CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS = 0x08, + CEC_OPCODE_SELECT_ANALOGUE_SERVICE = 0x92, + CEC_OPCODE_SELECT_DIGITAL_SERVICE = 0x93, + CEC_OPCODE_TUNER_DEVICE_STATUS = 0x07, + CEC_OPCODE_TUNER_STEP_DECREMENT = 0x06, + CEC_OPCODE_TUNER_STEP_INCREMENT = 0x05, + CEC_OPCODE_DEVICE_VENDOR_ID = 0x87, + CEC_OPCODE_GIVE_DEVICE_VENDOR_ID = 0x8C, + CEC_OPCODE_VENDOR_COMMAND = 0x89, + CEC_OPCODE_VENDOR_COMMAND_WITH_ID = 0xA0, + CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A, + CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP = 0x8B, + CEC_OPCODE_SET_OSD_STRING = 0x64, + CEC_OPCODE_GIVE_OSD_NAME = 0x46, + CEC_OPCODE_SET_OSD_NAME = 0x47, + CEC_OPCODE_MENU_REQUEST = 0x8D, + CEC_OPCODE_MENU_STATUS = 0x8E, + CEC_OPCODE_USER_CONTROL_PRESSED = 0x44, + CEC_OPCODE_USER_CONTROL_RELEASE = 0x45, + CEC_OPCODE_GIVE_DEVICE_POWER_STATUS = 0x8F, + CEC_OPCODE_REPORT_POWER_STATUS = 0x90, + CEC_OPCODE_FEATURE_ABORT = 0x00, + CEC_OPCODE_ABORT = 0xFF, + CEC_OPCODE_GIVE_AUDIO_STATUS = 0x71, + CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D, + CEC_OPCODE_REPORT_AUDIO_STATUS = 0x7A, + CEC_OPCODE_SET_SYSTEM_AUDIO_MODE = 0x72, + CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST = 0x70, + CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS = 0x7E, + CEC_OPCODE_SET_AUDIO_RATE = 0x9A, + + /* CEC 1.4 */ + CEC_OPCODE_START_ARC = 0xC0, + CEC_OPCODE_REPORT_ARC_STARTED = 0xC1, + CEC_OPCODE_REPORT_ARC_ENDED = 0xC2, + CEC_OPCODE_REQUEST_ARC_START = 0xC3, + CEC_OPCODE_REQUEST_ARC_END = 0xC4, + CEC_OPCODE_END_ARC = 0xC5, + CEC_OPCODE_CDC = 0xF8, + /* when this opcode is set, no opcode will be sent to the device. this is one of the reserved numbers */ + CEC_OPCODE_NONE = 0xFD +} cec_opcode; + +static const char *ToString(const cec_opcode opcode) +{ + switch (opcode) + { + case CEC_OPCODE_ACTIVE_SOURCE: + return "active source"; + case CEC_OPCODE_IMAGE_VIEW_ON: + return "image view on"; + case CEC_OPCODE_TEXT_VIEW_ON: + return "text view on"; + case CEC_OPCODE_INACTIVE_SOURCE: + return "inactive source"; + case CEC_OPCODE_REQUEST_ACTIVE_SOURCE: + return "request active source"; + case CEC_OPCODE_ROUTING_CHANGE: + return "routing change"; + case CEC_OPCODE_ROUTING_INFORMATION: + return "routing information"; + case CEC_OPCODE_SET_STREAM_PATH: + return "set stream path"; + case CEC_OPCODE_STANDBY: + return "standby"; + case CEC_OPCODE_RECORD_OFF: + return "record off"; + case CEC_OPCODE_RECORD_ON: + return "record on"; + case CEC_OPCODE_RECORD_STATUS: + return "record status"; + case CEC_OPCODE_RECORD_TV_SCREEN: + return "record tv screen"; + case CEC_OPCODE_CLEAR_ANALOGUE_TIMER: + return "clear analogue timer"; + case CEC_OPCODE_CLEAR_DIGITAL_TIMER: + return "clear digital timer"; + case CEC_OPCODE_CLEAR_EXTERNAL_TIMER: + return "clear external timer"; + case CEC_OPCODE_SET_ANALOGUE_TIMER: + return "set analogue timer"; + case CEC_OPCODE_SET_DIGITAL_TIMER: + return "set digital timer"; + case CEC_OPCODE_SET_EXTERNAL_TIMER: + return "set external timer"; + case CEC_OPCODE_SET_TIMER_PROGRAM_TITLE: + return "set timer program title"; + case CEC_OPCODE_TIMER_CLEARED_STATUS: + return "timer cleared status"; + case CEC_OPCODE_TIMER_STATUS: + return "timer status"; + case CEC_OPCODE_CEC_VERSION: + return "cec version"; + case CEC_OPCODE_GET_CEC_VERSION: + return "get cec version"; + case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS: + return "give physical address"; + case CEC_OPCODE_GET_MENU_LANGUAGE: + return "get menu language"; + case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS: + return "report physical address"; + case CEC_OPCODE_SET_MENU_LANGUAGE: + return "set menu language"; + case CEC_OPCODE_DECK_CONTROL: + return "deck control"; + case CEC_OPCODE_DECK_STATUS: + return "deck status"; + case CEC_OPCODE_GIVE_DECK_STATUS: + return "give deck status"; + case CEC_OPCODE_PLAY: + return "play"; + case CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS: + return "give tuner status"; + case CEC_OPCODE_SELECT_ANALOGUE_SERVICE: + return "select analogue service"; + case CEC_OPCODE_SELECT_DIGITAL_SERVICE: + return "set digital service"; + case CEC_OPCODE_TUNER_DEVICE_STATUS: + return "tuner device status"; + case CEC_OPCODE_TUNER_STEP_DECREMENT: + return "tuner step decrement"; + case CEC_OPCODE_TUNER_STEP_INCREMENT: + return "tuner step increment"; + case CEC_OPCODE_DEVICE_VENDOR_ID: + return "device vendor id"; + case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID: + return "give device vendor id"; + case CEC_OPCODE_VENDOR_COMMAND: + return "vendor command"; + case CEC_OPCODE_VENDOR_COMMAND_WITH_ID: + return "vendor command with id"; + case CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN: + return "vendor remote button down"; + case CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP: + return "vendor remote button up"; + case CEC_OPCODE_SET_OSD_STRING: + return "set osd string"; + case CEC_OPCODE_GIVE_OSD_NAME: + return "give osd name"; + case CEC_OPCODE_SET_OSD_NAME: + return "set osd name"; + case CEC_OPCODE_MENU_REQUEST: + return "menu request"; + case CEC_OPCODE_MENU_STATUS: + return "menu status"; + case CEC_OPCODE_USER_CONTROL_PRESSED: + return "user control pressed"; + case CEC_OPCODE_USER_CONTROL_RELEASE: + return "user control release"; + case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS: + return "give device power status"; + case CEC_OPCODE_REPORT_POWER_STATUS: + return "report power status"; + case CEC_OPCODE_FEATURE_ABORT: + return "feature abort"; + case CEC_OPCODE_ABORT: + return "abort"; + case CEC_OPCODE_GIVE_AUDIO_STATUS: + return "give audio status"; + case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS: + return "give audio mode status"; + case CEC_OPCODE_REPORT_AUDIO_STATUS: + return "report audio status"; + case CEC_OPCODE_SET_SYSTEM_AUDIO_MODE: + return "set system audio mode"; + case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST: + return "system audio mode request"; + case CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS: + return "system audio mode status"; + case CEC_OPCODE_SET_AUDIO_RATE: + return "set audio rate"; + case CEC_OPCODE_START_ARC: + return "start ARC"; + case CEC_OPCODE_REPORT_ARC_STARTED: + return "report ARC started"; + case CEC_OPCODE_REPORT_ARC_ENDED: + return "report ARC ended"; + case CEC_OPCODE_REQUEST_ARC_START: + return "request ARC start"; + case CEC_OPCODE_REQUEST_ARC_END: + return "request ARC end"; + case CEC_OPCODE_END_ARC: + return "end ARC"; + case CEC_OPCODE_CDC: + return "CDC"; + case CEC_OPCODE_NONE: + return "poll"; + default: + return "UNKNOWN"; + } +} + +static const char *ToString(const cec_vendor_id vendor) +{ + switch (vendor) + { + case CEC_VENDOR_SAMSUNG: + return "Samsung"; + case CEC_VENDOR_LG: + return "LG"; + case CEC_VENDOR_PANASONIC: + return "Panasonic"; + case CEC_VENDOR_PIONEER: + return "Pioneer"; + case CEC_VENDOR_ONKYO: + return "Onkyo"; + case CEC_VENDOR_YAMAHA: + return "Yamaha"; + case CEC_VENDOR_PHILIPS: + return "Philips"; + case CEC_VENDOR_SONY: + return "Sony"; + case CEC_VENDOR_TOSHIBA: + case CEC_VENDOR_TOSHIBA2: + return "Toshiba"; + case CEC_VENDOR_AKAI: + return "Akai"; + case CEC_VENDOR_AOC: + return "AOC"; + case CEC_VENDOR_BENQ: + return "Benq"; + case CEC_VENDOR_DAEWOO: + return "Daewoo"; + case CEC_VENDOR_GRUNDIG: + return "Grundig"; + case CEC_VENDOR_MEDION: + return "Medion"; + case CEC_VENDOR_SHARP: + case CEC_VENDOR_SHARP2: + return "Sharp"; + case CEC_VENDOR_VIZIO: + return "Vizio"; + case CEC_VENDOR_BROADCOM: + return "Broadcom"; + case CEC_VENDOR_LOEWE: + return "Loewe"; + case CEC_VENDOR_DENON: + return "Denon"; + case CEC_VENDOR_MARANTZ: + return "Marantz"; + case CEC_VENDOR_HARMAN_KARDON: + case CEC_VENDOR_HARMAN_KARDON2: + return "Harman/Kardon"; + case CEC_VENDOR_PULSE_EIGHT: + return "Pulse Eight"; + case CEC_VENDOR_GOOGLE: + return "Google"; + default: + return "Unknown"; + } +} + +static const char *ToString(const cec_user_control_code key) +{ + switch (key) + { + case CEC_USER_CONTROL_CODE_SELECT: + return "select"; + case CEC_USER_CONTROL_CODE_UP: + return "up"; + case CEC_USER_CONTROL_CODE_DOWN: + return "down"; + case CEC_USER_CONTROL_CODE_LEFT: + return "left"; + case CEC_USER_CONTROL_CODE_RIGHT: + return "right"; + case CEC_USER_CONTROL_CODE_RIGHT_UP: + return "right+up"; + case CEC_USER_CONTROL_CODE_RIGHT_DOWN: + return "right+down"; + case CEC_USER_CONTROL_CODE_LEFT_UP: + return "left+up"; + case CEC_USER_CONTROL_CODE_LEFT_DOWN: + return "left+down"; + case CEC_USER_CONTROL_CODE_ROOT_MENU: + return "root menu"; + case CEC_USER_CONTROL_CODE_SETUP_MENU: + return "setup menu"; + case CEC_USER_CONTROL_CODE_CONTENTS_MENU: + return "contents menu"; + case CEC_USER_CONTROL_CODE_FAVORITE_MENU: + return "favourite menu"; + case CEC_USER_CONTROL_CODE_EXIT: + return "exit"; + case CEC_USER_CONTROL_CODE_TOP_MENU: + return "top menu"; + case CEC_USER_CONTROL_CODE_DVD_MENU: + return "dvd menu"; + case CEC_USER_CONTROL_CODE_NUMBER_ENTRY_MODE: + return "number entry mode"; + case CEC_USER_CONTROL_CODE_NUMBER11: + return "11"; + case CEC_USER_CONTROL_CODE_NUMBER12: + return "12"; + case CEC_USER_CONTROL_CODE_NUMBER0: + return "0"; + case CEC_USER_CONTROL_CODE_NUMBER1: + return "1"; + case CEC_USER_CONTROL_CODE_NUMBER2: + return "2"; + case CEC_USER_CONTROL_CODE_NUMBER3: + return "3"; + case CEC_USER_CONTROL_CODE_NUMBER4: + return "4"; + case CEC_USER_CONTROL_CODE_NUMBER5: + return "5"; + case CEC_USER_CONTROL_CODE_NUMBER6: + return "6"; + case CEC_USER_CONTROL_CODE_NUMBER7: + return "7"; + case CEC_USER_CONTROL_CODE_NUMBER8: + return "8"; + case CEC_USER_CONTROL_CODE_NUMBER9: + return "9"; + case CEC_USER_CONTROL_CODE_DOT: + return "."; + case CEC_USER_CONTROL_CODE_ENTER: + return "enter"; + case CEC_USER_CONTROL_CODE_CLEAR: + return "clear"; + case CEC_USER_CONTROL_CODE_NEXT_FAVORITE: + return "next favourite"; + case CEC_USER_CONTROL_CODE_CHANNEL_UP: + return "channel up"; + case CEC_USER_CONTROL_CODE_CHANNEL_DOWN: + return "channel down"; + case CEC_USER_CONTROL_CODE_PREVIOUS_CHANNEL: + return "previous channel"; + case CEC_USER_CONTROL_CODE_SOUND_SELECT: + return "sound select"; + case CEC_USER_CONTROL_CODE_INPUT_SELECT: + return "input select"; + case CEC_USER_CONTROL_CODE_DISPLAY_INFORMATION: + return "display information"; + case CEC_USER_CONTROL_CODE_HELP: + return "help"; + case CEC_USER_CONTROL_CODE_PAGE_UP: + return "page up"; + case CEC_USER_CONTROL_CODE_PAGE_DOWN: + return "page down"; + case CEC_USER_CONTROL_CODE_POWER: + return "power"; + case CEC_USER_CONTROL_CODE_VOLUME_UP: + return "volume up"; + case CEC_USER_CONTROL_CODE_VOLUME_DOWN: + return "volume down"; + case CEC_USER_CONTROL_CODE_MUTE: + return "mute"; + case CEC_USER_CONTROL_CODE_PLAY: + return "play"; + case CEC_USER_CONTROL_CODE_STOP: + return "stop"; + case CEC_USER_CONTROL_CODE_PAUSE: + return "pause"; + case CEC_USER_CONTROL_CODE_RECORD: + return "record"; + case CEC_USER_CONTROL_CODE_REWIND: + return "rewind"; + case CEC_USER_CONTROL_CODE_FAST_FORWARD: + return "Fast forward"; + case CEC_USER_CONTROL_CODE_EJECT: + return "eject"; + case CEC_USER_CONTROL_CODE_FORWARD: + return "forward"; + case CEC_USER_CONTROL_CODE_BACKWARD: + return "backward"; + case CEC_USER_CONTROL_CODE_STOP_RECORD: + return "stop record"; + case CEC_USER_CONTROL_CODE_PAUSE_RECORD: + return "pause record"; + case CEC_USER_CONTROL_CODE_ANGLE: + return "angle"; + case CEC_USER_CONTROL_CODE_SUB_PICTURE: + return "sub picture"; + case CEC_USER_CONTROL_CODE_VIDEO_ON_DEMAND: + return "video on demand"; + case CEC_USER_CONTROL_CODE_ELECTRONIC_PROGRAM_GUIDE: + return "electronic program guide"; + case CEC_USER_CONTROL_CODE_TIMER_PROGRAMMING: + return "timer programming"; + case CEC_USER_CONTROL_CODE_INITIAL_CONFIGURATION: + return "initial configuration"; + case CEC_USER_CONTROL_CODE_SELECT_BROADCAST_TYPE: + return "select broadcast type"; + case CEC_USER_CONTROL_CODE_SELECT_SOUND_PRESENTATION: + return "select sound presentation"; + case CEC_USER_CONTROL_CODE_PLAY_FUNCTION: + return "play (function)"; + case CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION: + return "pause play (function)"; + case CEC_USER_CONTROL_CODE_RECORD_FUNCTION: + return "record (function)"; + case CEC_USER_CONTROL_CODE_PAUSE_RECORD_FUNCTION: + return "pause record (function)"; + case CEC_USER_CONTROL_CODE_STOP_FUNCTION: + return "stop (function)"; + case CEC_USER_CONTROL_CODE_MUTE_FUNCTION: + return "mute (function)"; + case CEC_USER_CONTROL_CODE_RESTORE_VOLUME_FUNCTION: + return "restore volume"; + case CEC_USER_CONTROL_CODE_TUNE_FUNCTION: + return "tune"; + case CEC_USER_CONTROL_CODE_SELECT_MEDIA_FUNCTION: + return "select media"; + case CEC_USER_CONTROL_CODE_SELECT_AV_INPUT_FUNCTION: + return "select AV input"; + case CEC_USER_CONTROL_CODE_SELECT_AUDIO_INPUT_FUNCTION: + return "select audio input"; + case CEC_USER_CONTROL_CODE_POWER_TOGGLE_FUNCTION: + return "power toggle"; + case CEC_USER_CONTROL_CODE_POWER_OFF_FUNCTION: + return "power off"; + case CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION: + return "power on"; + case CEC_USER_CONTROL_CODE_F1_BLUE: + return "F1 (blue)"; + case CEC_USER_CONTROL_CODE_F2_RED: + return "F2 (red)"; + case CEC_USER_CONTROL_CODE_F3_GREEN: + return "F3 (green)"; + case CEC_USER_CONTROL_CODE_F4_YELLOW: + return "F4 (yellow)"; + case CEC_USER_CONTROL_CODE_F5: + return "F5"; + case CEC_USER_CONTROL_CODE_DATA: + return "data"; + case CEC_USER_CONTROL_CODE_AN_RETURN: + return "return (Samsung)"; + case CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST: + return "channels list (Samsung)"; + default: + return "unknown"; + } +} From 598319f3d8c24d92cdbd8f5093183f01100eb226 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Sun, 7 Oct 2018 23:00:29 +0200 Subject: [PATCH 54/59] libarmbox: hdmi_cec better readability Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/6427cf09a83d8688a46edeb2498388f8c209e108 Author: TangoCash Date: 2018-10-07 (Sun, 07 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 144 +++++++++++++++++++++-------------------- libarmbox/hdmi_cec.h | 20 ++++++ 2 files changed, 93 insertions(+), 71 deletions(-) diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index a45597d..195887e 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include "linux-uapi-cec.h" #include "hdmi_cec.h" #include "hdmi_cec_types.h" @@ -309,113 +311,113 @@ long hdmi_cec::translateKey(unsigned char code) long key = 0; switch (code) { - case 0x32: - key = 0x8b; + case CEC_USER_CONTROL_CODE_PREVIOUS_CHANNEL: + key = KEY_MENU; break; - case 0x20: - key = 0x0b; + case CEC_USER_CONTROL_CODE_NUMBER0: + key = KEY_0; break; - case 0x21: - key = 0x02; + case CEC_USER_CONTROL_CODE_NUMBER1: + key = KEY_1; break; - case 0x22: - key = 0x03; + case CEC_USER_CONTROL_CODE_NUMBER2: + key = KEY_2; break; - case 0x23: - key = 0x04; + case CEC_USER_CONTROL_CODE_NUMBER3: + key = KEY_3; break; - case 0x24: - key = 0x05; + case CEC_USER_CONTROL_CODE_NUMBER4: + key = KEY_4; break; - case 0x25: - key = 0x06; + case CEC_USER_CONTROL_CODE_NUMBER5: + key = KEY_5; break; - case 0x26: - key = 0x07; + case CEC_USER_CONTROL_CODE_NUMBER6: + key = KEY_6; break; - case 0x27: - key = 0x08; + case CEC_USER_CONTROL_CODE_NUMBER7: + key = KEY_7; break; - case 0x28: - key = 0x09; + case CEC_USER_CONTROL_CODE_NUMBER8: + key = KEY_8; break; - case 0x29: - key = 0x0a; + case CEC_USER_CONTROL_CODE_NUMBER9: + key = KEY_9; break; - case 0x30: - key = 0x192; + case CEC_USER_CONTROL_CODE_CHANNEL_UP: + key = KEY_CHANNELUP; break; - case 0x31: - key = 0x193; + case CEC_USER_CONTROL_CODE_CHANNEL_DOWN: + key = KEY_CHANNELDOWN; break; - case 0x44: - key = 0xcf; + case CEC_USER_CONTROL_CODE_PLAY: + key = KEY_PLAY; break; - case 0x45: - key = 0x80; + case CEC_USER_CONTROL_CODE_STOP: + key = KEY_STOP; break; - case 0x46: - key = 0x77; + case CEC_USER_CONTROL_CODE_PAUSE: + key = KEY_PAUSE; break; - case 0x47: - key = 0xa7; + case CEC_USER_CONTROL_CODE_RECORD: + key = KEY_RECORD; break; - case 0x48: - key = 0xa8; + case CEC_USER_CONTROL_CODE_REWIND: + key = KEY_REWIND; break; - case 0x49: - key = 0xd0; + case CEC_USER_CONTROL_CODE_FAST_FORWARD: + key = KEY_FASTFORWARD; break; - case 0x53: - key = 0x166; + case CEC_USER_CONTROL_CODE_ELECTRONIC_PROGRAM_GUIDE: + key = KEY_INFO; break; - case 0x54: - key = 0x16a; + case CEC_USER_CONTROL_CODE_TIMER_PROGRAMMING: + key = KEY_PROGRAM; break; - case 0x60: - key = 0xcf; + case CEC_USER_CONTROL_CODE_PLAY_FUNCTION: + key = KEY_PLAY; break; - case 0x61: - key = 0xa4; + case CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION: + key = KEY_PLAYPAUSE; break; - case 0x62: - key = 0xa7; + case CEC_USER_CONTROL_CODE_RECORD_FUNCTION: + key = KEY_RECORD; break; - case 0x64: - key = 0x80; + case CEC_USER_CONTROL_CODE_STOP_FUNCTION: + key = KEY_STOP; break; - case 0x00: - key = 0x160; + case CEC_USER_CONTROL_CODE_SELECT: + key = KEY_OK; break; - case 0x03: - key = 0x69; + case CEC_USER_CONTROL_CODE_LEFT: + key = KEY_LEFT; break; - case 0x04: - key = 0x6a; + case CEC_USER_CONTROL_CODE_RIGHT: + key = KEY_RIGHT; break; - case 0x01: - key = 0x67; + case CEC_USER_CONTROL_CODE_UP: + key = KEY_UP; break; - case 0x02: - key = 0x6c; + case CEC_USER_CONTROL_CODE_DOWN: + key = KEY_DOWN; break; - case 0x0d: - key = 0xae; + case CEC_USER_CONTROL_CODE_EXIT: + key = KEY_EXIT; break; - case 0x72: - key = 0x18e; + case CEC_USER_CONTROL_CODE_F2_RED: + key = KEY_RED; break; - case 0x71: - key = 0x191; + case CEC_USER_CONTROL_CODE_F3_GREEN: + key = KEY_GREEN; break; - case 0x73: - key = 0x18f; + case CEC_USER_CONTROL_CODE_F4_YELLOW: + key = KEY_YELLOW; break; - case 0x74: - key = 0x190; + case CEC_USER_CONTROL_CODE_F1_BLUE: + key = KEY_BLUE; break; default: - key = 0x8b; + key = KEY_MENU; break; } return key; diff --git a/libarmbox/hdmi_cec.h b/libarmbox/hdmi_cec.h index 0dc97cb..9654e73 100644 --- a/libarmbox/hdmi_cec.h +++ b/libarmbox/hdmi_cec.h @@ -22,6 +22,26 @@ #include "video_lib.h" +#ifndef KEY_OK +#define KEY_OK 0x160 +#endif + +#ifndef KEY_RED +#define KEY_RED 0x18e +#endif + +#ifndef KEY_GREEN +#define KEY_GREEN 0x18f +#endif + +#ifndef KEY_YELLOW +#define KEY_YELLOW 0x190 +#endif + +#ifndef KEY_BLUE +#define KEY_BLUE 0x191 +#endif + struct cec_message { unsigned char address; From 0c917e407b79307b6adc9d8b12caa0073e179274 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Mon, 8 Oct 2018 16:23:15 +0200 Subject: [PATCH 55/59] libarmbox: hdmi_cec fixx segfault on DDT, align log Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/ae74e313ef4c91cc69ad995cedd9c546c0d09d51 Author: TangoCash Date: 2018-10-08 (Mon, 08 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index 195887e..ef279f3 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -62,6 +62,9 @@ hdmi_cec * hdmi_cec::hdmi_cec_instance = NULL; +//hack to get an instance before first call +hdmi_cec * CEC = hdmi_cec::getInstance(); + hdmi_cec::hdmi_cec() { standby_cec_activ = autoview_cec_activ = false; @@ -80,7 +83,10 @@ hdmi_cec::~hdmi_cec() hdmi_cec* hdmi_cec::getInstance() { if (hdmi_cec_instance == NULL) + { hdmi_cec_instance = new hdmi_cec(); + lt_debug("[CEC] new instance created \n"); + } return hdmi_cec_instance; } @@ -93,13 +99,13 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) if (_deviceType == VIDEO_HDMI_CEC_MODE_OFF) { Stop(); - lt_debug("CEC OFF %s\n", __func__); + lt_debug("[CEC] switch off %s\n", __func__); return false; } else deviceType = _deviceType; - lt_debug("CEC ON %s\n", __func__); + lt_debug("[CEC] switch on %s\n", __func__); if (hdmiFd == -1) { @@ -112,14 +118,14 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) struct cec_caps caps = {}; if (ioctl(hdmiFd, CEC_ADAP_G_CAPS, &caps) < 0) - lt_info("%s: CEC get caps failed (%m)\n", __func__); + lt_info("[CEC] %s: get caps failed (%m)\n", __func__); if (caps.capabilities & CEC_CAP_LOG_ADDRS) { struct cec_log_addrs laddrs = {}; if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0) - lt_info("%s: CEC reset log addr failed (%m)\n", __func__); + lt_info("[CEC] %s: reset log addr failed (%m)\n", __func__); memset(&laddrs, 0, sizeof(laddrs)); @@ -169,11 +175,11 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) laddrs.num_log_addrs++; if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0) - lt_info("%s: CEC set log addr failed (%m)\n", __func__); + lt_info("[CEC] %s: et log addr failed (%m)\n", __func__); } if (ioctl(hdmiFd, CEC_S_MODE, &monitor) < 0) - lt_info("%s: CEC monitor failed (%m)\n", __func__); + lt_info("[CEC] %s: monitor failed (%m)\n", __func__); GetCECAddressInfo(); @@ -230,7 +236,7 @@ void hdmi_cec::GetCECAddressInfo() logicalAddress = addressinfo.logical; if (memcmp(physicalAddress, addressinfo.physical, sizeof(physicalAddress))) { - lt_info("%s: detected physical address change: %02X%02X --> %02X%02X\n", __func__, physicalAddress[0], physicalAddress[1], addressinfo.physical[0], addressinfo.physical[1]); + lt_info("[CEC] %s: detected physical address change: %02X%02X --> %02X%02X\n", __func__, physicalAddress[0], physicalAddress[1], addressinfo.physical[0], addressinfo.physical[1]); memcpy(physicalAddress, addressinfo.physical, sizeof(physicalAddress)); ReportPhysicalAddress(); } From a0f7c42d7739ac6285cda892c83ce18909a9b14e Mon Sep 17 00:00:00 2001 From: TangoCash Date: Mon, 8 Oct 2018 16:27:52 +0200 Subject: [PATCH 56/59] libarmbox: hdmi_cec typo Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/b047bcdcf22b9aa8345cb7970a0e04c8010acd16 Author: TangoCash Date: 2018-10-08 (Mon, 08 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index ef279f3..cc4db35 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -85,7 +85,7 @@ hdmi_cec* hdmi_cec::getInstance() if (hdmi_cec_instance == NULL) { hdmi_cec_instance = new hdmi_cec(); - lt_debug("[CEC] new instance created \n"); + lt_debug_c("[CEC] new instance created \n"); } return hdmi_cec_instance; } From fcf7f1881c1ae3ccee7aa1607d26d6a9c7d69bb0 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Tue, 9 Oct 2018 22:11:01 +0200 Subject: [PATCH 57/59] libarmbox: hmdi_cec emit received keys, report power status Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/08984d1c35541517ca4b5f66f7f17326c8069c8a Author: TangoCash Date: 2018-10-09 (Tue, 09 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 115 +++++++++++++++++++++++++++++++------ libarmbox/hdmi_cec.h | 36 +++++------- libarmbox/hdmi_cec_types.h | 68 ++++++++++++++++++++++ 3 files changed, 180 insertions(+), 39 deletions(-) diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index cc4db35..a30e115 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -59,6 +59,7 @@ }) #define CEC_DEVICE "/dev/cec0" +#define RC_DEVICE "/dev/input/event1" hdmi_cec * hdmi_cec::hdmi_cec_instance = NULL; @@ -67,7 +68,7 @@ hdmi_cec * CEC = hdmi_cec::getInstance(); hdmi_cec::hdmi_cec() { - standby_cec_activ = autoview_cec_activ = false; + standby_cec_activ = autoview_cec_activ = standby = false; hdmiFd = -1; } @@ -246,7 +247,8 @@ void hdmi_cec::GetCECAddressInfo() void hdmi_cec::ReportPhysicalAddress() { struct cec_message txmessage; - txmessage.address = 0x0f; /* broadcast */ + txmessage.initiator = logicalAddress; + txmessage.destination = CEC_LOG_ADDR_BROADCAST; txmessage.data[0] = CEC_MSG_REPORT_PHYSICAL_ADDR; txmessage.data[1] = physicalAddress[0]; txmessage.data[2] = physicalAddress[1]; @@ -264,9 +266,9 @@ void hdmi_cec::SendCECMessage(struct cec_message &txmessage) { sprintf(str+(i*6),"[0x%02X]", txmessage.data[i]); } - lt_info("[CEC] send message '%s' (%s)\n", ToString((cec_opcode)txmessage.data[0]), str); + lt_info("[CEC] send message 0x%02X >> 0x%02X '%s' (%s)\n", txmessage.initiator, txmessage.destination, ToString((cec_opcode)txmessage.data[0]), str); struct cec_msg msg; - cec_msg_init(&msg, logicalAddress, txmessage.address); + cec_msg_init(&msg, txmessage.initiator, txmessage.destination); memcpy(&msg.msg[1], txmessage.data, txmessage.length); msg.len = txmessage.length + 1; ioctl(hdmiFd, CEC_TRANSMIT, &msg); @@ -287,9 +289,12 @@ void hdmi_cec::SetCECState(bool state) { struct cec_message message; + standby = state; + if ((standby_cec_activ) && state) { - message.address = CEC_OP_PRIM_DEVTYPE_TV; + message.initiator = logicalAddress; + message.destination = CEC_OP_PRIM_DEVTYPE_TV; message.data[0] = CEC_MSG_STANDBY; message.length = 1; SendCECMessage(message); @@ -297,12 +302,22 @@ void hdmi_cec::SetCECState(bool state) if ((autoview_cec_activ) && !state) { - message.address = CEC_OP_PRIM_DEVTYPE_TV; + message.initiator = logicalAddress; + message.destination = CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM; + message.data[0] = CEC_MSG_GIVE_SYSTEM_AUDIO_MODE_STATUS; + message.length = 1; + SendCECMessage(message); + usleep(10000); + + message.initiator = logicalAddress; + message.destination = CEC_OP_PRIM_DEVTYPE_TV; message.data[0] = CEC_MSG_IMAGE_VIEW_ON; message.length = 1; SendCECMessage(message); usleep(10000); - message.address = 0x0f; /* broadcast */ + + message.initiator = logicalAddress; + message.destination = CEC_LOG_ADDR_BROADCAST; message.data[0] = CEC_MSG_ACTIVE_SOURCE; message.data[1] = physicalAddress[0]; message.data[2] = physicalAddress[1]; @@ -469,11 +484,15 @@ void hdmi_cec::Receive() { bool hasdata = false; struct cec_message rxmessage; + struct cec_message txmessage; struct cec_msg msg; if (::ioctl(hdmiFd, CEC_RECEIVE, &msg) >= 0) { rxmessage.length = msg.len - 1; + rxmessage.initiator = cec_msg_initiator(&msg); + rxmessage.destination = cec_msg_destination(&msg); + rxmessage.opcode = cec_msg_opcode(&msg); memcpy(&rxmessage.data, &msg.msg[1], rxmessage.length); hasdata = true; } @@ -488,29 +507,91 @@ void hdmi_cec::Receive() { sprintf(str+(i*6),"[0x%02X]", rxmessage.data[i]); } - lt_info("[CEC] received message '%s' (%s)\n", ToString((cec_opcode)rxmessage.data[0]), str); + lt_info("[CEC] received message 0x%02X << 0x%02X '%s' (%s)\n", rxmessage.destination, rxmessage.initiator, ToString((cec_opcode)rxmessage.opcode), str); - switch (rxmessage.data[0]) + switch (rxmessage.opcode) { - case CEC_MSG_DEVICE_VENDOR_ID: + case CEC_OPCODE_DEVICE_VENDOR_ID: + case CEC_OPCODE_VENDOR_COMMAND_WITH_ID: { uint64_t iVendorId = ((uint64_t)rxmessage.data[1] << 16) + - ((uint64_t)rxmessage.data[2] << 8) + - (uint64_t)rxmessage.data[3]; - lt_info("[CEC] decoded message '%s' (%s)\n", ToString((cec_opcode)rxmessage.data[0]), ToString((cec_vendor_id)iVendorId)); + ((uint64_t)rxmessage.data[2] << 8) + + (uint64_t)rxmessage.data[3]; + lt_info("[CEC] decoded message '%s' (%s)\n", ToString((cec_opcode)rxmessage.opcode), ToString((cec_vendor_id)iVendorId)); break; } - case CEC_MSG_USER_CONTROL_PRESSED: /* key pressed */ + case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS: + { + txmessage.destination = rxmessage.initiator; + txmessage.initiator = rxmessage.destination; + txmessage.data[0] = GetResponseOpcode((cec_opcode)rxmessage.opcode); + txmessage.data[1] = standby ? CEC_POWER_STATUS_STANDBY : CEC_POWER_STATUS_ON; + txmessage.length = 2; + SendCECMessage(txmessage); + break; + } + case CEC_OPCODE_USER_CONTROL_PRESSED: /* key pressed */ keypressed = true; pressedkey = rxmessage.data[1]; - case CEC_MSG_USER_CONTROL_RELEASED: /* key released */ + case CEC_OPCODE_USER_CONTROL_RELEASE: /* key released */ { long code = translateKey(pressedkey); - if (keypressed) - code |= 0x80000000; lt_info("[CEC] decoded key %s (%ld)\n",ToString((cec_user_control_code)pressedkey), code); + handleCode(code,keypressed); break; } } } } + +void hdmi_cec::handleCode(long code, bool keypressed) +{ + int evd = open(RC_DEVICE, O_RDWR); + if (evd < 0) + { + perror("opening " RC_DEVICE " failed"); + return; + } + if (keypressed) + { + if (rc_send(evd, code, KEY_PRESSED) < 0) + { + perror("writing 'KEY_PRESSED' event failed"); + close(evd); + return; + } + rc_sync(evd); + } + else + { + if (rc_send(evd, code, KEY_RELEASED) < 0) + { + perror("writing 'KEY_RELEASED' event failed"); + close(evd); + return; + } + rc_sync(evd); + } + close(evd); +} + +int hdmi_cec::rc_send(int fd, unsigned int code, unsigned int value) +{ + struct input_event ev; + + ev.type = EV_KEY; + ev.code = code; + ev.value = value; + return write(fd, &ev, sizeof(ev)); +} + +void hdmi_cec::rc_sync(int fd) +{ + struct input_event ev; + + gettimeofday(&ev.time, NULL); + ev.type = EV_SYN; + ev.code = SYN_REPORT; + ev.value = 0; + write(fd, &ev, sizeof(ev)); +} diff --git a/libarmbox/hdmi_cec.h b/libarmbox/hdmi_cec.h index 9654e73..65604d7 100644 --- a/libarmbox/hdmi_cec.h +++ b/libarmbox/hdmi_cec.h @@ -22,31 +22,13 @@ #include "video_lib.h" -#ifndef KEY_OK -#define KEY_OK 0x160 -#endif - -#ifndef KEY_RED -#define KEY_RED 0x18e -#endif - -#ifndef KEY_GREEN -#define KEY_GREEN 0x18f -#endif - -#ifndef KEY_YELLOW -#define KEY_YELLOW 0x190 -#endif - -#ifndef KEY_BLUE -#define KEY_BLUE 0x191 -#endif - struct cec_message { - unsigned char address; - unsigned char length; + unsigned char initiator; + unsigned char destination; + unsigned char opcode; unsigned char data[256]; + unsigned char length; } __attribute__((packed)); struct addressinfo @@ -56,6 +38,12 @@ struct addressinfo unsigned char type; }; +enum { + KEY_RELEASED = 0, + KEY_PRESSED, + KEY_AUTOREPEAT +}; + class hdmi_cec : public OpenThreads::Thread { private: @@ -70,6 +58,10 @@ private: unsigned char deviceType, logicalAddress; int hdmiFd; long translateKey(unsigned char code); + void handleCode(long code, bool keypressed); + int rc_send(int fd, unsigned int code, unsigned int value); + void rc_sync(int fd); + bool standby; protected: bool running; public: diff --git a/libarmbox/hdmi_cec_types.h b/libarmbox/hdmi_cec_types.h index f5808af..beb3e4f 100644 --- a/libarmbox/hdmi_cec_types.h +++ b/libarmbox/hdmi_cec_types.h @@ -207,6 +207,37 @@ typedef enum cec_opcode CEC_OPCODE_NONE = 0xFD } cec_opcode; +typedef enum cec_logical_address +{ + CECDEVICE_UNKNOWN = -1, //not a valid logical address + CECDEVICE_TV = 0, + CECDEVICE_RECORDINGDEVICE1 = 1, + CECDEVICE_RECORDINGDEVICE2 = 2, + CECDEVICE_TUNER1 = 3, + CECDEVICE_PLAYBACKDEVICE1 = 4, + CECDEVICE_AUDIOSYSTEM = 5, + CECDEVICE_TUNER2 = 6, + CECDEVICE_TUNER3 = 7, + CECDEVICE_PLAYBACKDEVICE2 = 8, + CECDEVICE_RECORDINGDEVICE3 = 9, + CECDEVICE_TUNER4 = 10, + CECDEVICE_PLAYBACKDEVICE3 = 11, + CECDEVICE_RESERVED1 = 12, + CECDEVICE_RESERVED2 = 13, + CECDEVICE_FREEUSE = 14, + CECDEVICE_UNREGISTERED = 15, + CECDEVICE_BROADCAST = 15 +} cec_logical_address; + +typedef enum cec_power_status +{ + CEC_POWER_STATUS_ON = 0x00, + CEC_POWER_STATUS_STANDBY = 0x01, + CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON = 0x02, + CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY = 0x03, + CEC_POWER_STATUS_UNKNOWN = 0x99 +} cec_power_status; + static const char *ToString(const cec_opcode opcode) { switch (opcode) @@ -598,3 +629,40 @@ static const char *ToString(const cec_user_control_code key) return "unknown"; } } + +static cec_opcode GetResponseOpcode(cec_opcode opcode) +{ + switch (opcode) + { + case CEC_OPCODE_REQUEST_ACTIVE_SOURCE: + return CEC_OPCODE_ACTIVE_SOURCE; + case CEC_OPCODE_GET_CEC_VERSION: + return CEC_OPCODE_CEC_VERSION; + case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS: + return CEC_OPCODE_REPORT_PHYSICAL_ADDRESS; + case CEC_OPCODE_GET_MENU_LANGUAGE: + return CEC_OPCODE_SET_MENU_LANGUAGE; + case CEC_OPCODE_GIVE_DECK_STATUS: + return CEC_OPCODE_DECK_STATUS; + case CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS: + return CEC_OPCODE_TUNER_DEVICE_STATUS; + case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID: + return CEC_OPCODE_DEVICE_VENDOR_ID; + case CEC_OPCODE_GIVE_OSD_NAME: + return CEC_OPCODE_SET_OSD_NAME; + case CEC_OPCODE_MENU_REQUEST: + return CEC_OPCODE_MENU_STATUS; + case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS: + return CEC_OPCODE_REPORT_POWER_STATUS; + case CEC_OPCODE_GIVE_AUDIO_STATUS: + return CEC_OPCODE_REPORT_AUDIO_STATUS; + case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS: + return CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS; + case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST: + return CEC_OPCODE_SET_SYSTEM_AUDIO_MODE; + default: + break; + } + + return CEC_OPCODE_NONE; +} From 117802822201e7a4305a1368066b09257130e6e6 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Tue, 9 Oct 2018 23:10:21 +0200 Subject: [PATCH 58/59] libarmbox: hdmi_cec fix device Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/7c40bbf4f1abc16543192e415b41cb6c149a055e Author: TangoCash Date: 2018-10-09 (Tue, 09 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index a30e115..5d45bc9 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -110,7 +111,7 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) if (hdmiFd == -1) { - hdmiFd = open(CEC_DEVICE, O_RDWR | O_NONBLOCK); + hdmiFd = open(CEC_DEVICE, O_RDWR | O_CLOEXEC); } if (hdmiFd >= 0) @@ -462,6 +463,8 @@ bool hdmi_cec::Stop() return false; running = false; + + OpenThreads::Thread::cancel(); if (hdmiFd >= 0) { @@ -474,9 +477,16 @@ bool hdmi_cec::Stop() void hdmi_cec::run() { - while (running && (hdmiFd >= 0)) + OpenThreads::Thread::setCancelModeAsynchronous(); + struct pollfd pfd; + + pfd.fd = hdmiFd; + pfd.events = (POLLIN | POLLPRI); + + while (running) { - Receive(); + if (poll(&pfd, 1, 0) > 0) + Receive(); } } From 629a3132956830140e95b61e840d200b2d3e5b47 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Wed, 10 Oct 2018 23:45:51 +0200 Subject: [PATCH 59/59] libarmbox: hdmi_cec switch debug log to INIT (not used by armbox elsewhere), to debug hdmi_cec separatly from video Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/53f752a014611ce349e68f538375d9ef3a7f05f0 Author: TangoCash Date: 2018-10-10 (Wed, 10 Oct 2018) ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index 5d45bc9..0eed4ab 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -42,10 +42,10 @@ #define RED "\x1B[31m" #define NORMAL "\x1B[0m" -#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args) -#define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args) -#define lt_debug_c(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, NULL, args) -#define lt_info_c(args...) _lt_info(TRIPLE_DEBUG_VIDEO, NULL, args) +#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_INIT, this, args) +#define lt_info(args...) _lt_info(TRIPLE_DEBUG_INIT, this, args) +#define lt_debug_c(args...) _lt_debug(TRIPLE_DEBUG_INIT, NULL, args) +#define lt_info_c(args...) _lt_info(TRIPLE_DEBUG_INIT, NULL, args) #define fop(cmd, args...) ({ \ int _r; \ @@ -120,14 +120,14 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) struct cec_caps caps = {}; if (ioctl(hdmiFd, CEC_ADAP_G_CAPS, &caps) < 0) - lt_info("[CEC] %s: get caps failed (%m)\n", __func__); + lt_debug("[CEC] %s: get caps failed (%m)\n", __func__); if (caps.capabilities & CEC_CAP_LOG_ADDRS) { struct cec_log_addrs laddrs = {}; if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0) - lt_info("[CEC] %s: reset log addr failed (%m)\n", __func__); + lt_debug("[CEC] %s: reset log addr failed (%m)\n", __func__); memset(&laddrs, 0, sizeof(laddrs)); @@ -177,11 +177,11 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) laddrs.num_log_addrs++; if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0) - lt_info("[CEC] %s: et log addr failed (%m)\n", __func__); + lt_debug("[CEC] %s: et log addr failed (%m)\n", __func__); } if (ioctl(hdmiFd, CEC_S_MODE, &monitor) < 0) - lt_info("[CEC] %s: monitor failed (%m)\n", __func__); + lt_debug("[CEC] %s: monitor failed (%m)\n", __func__); GetCECAddressInfo(); @@ -527,7 +527,7 @@ void hdmi_cec::Receive() uint64_t iVendorId = ((uint64_t)rxmessage.data[1] << 16) + ((uint64_t)rxmessage.data[2] << 8) + (uint64_t)rxmessage.data[3]; - lt_info("[CEC] decoded message '%s' (%s)\n", ToString((cec_opcode)rxmessage.opcode), ToString((cec_vendor_id)iVendorId)); + lt_debug("[CEC] decoded message '%s' (%s)\n", ToString((cec_opcode)rxmessage.opcode), ToString((cec_vendor_id)iVendorId)); break; } case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS: @@ -546,7 +546,7 @@ void hdmi_cec::Receive() case CEC_OPCODE_USER_CONTROL_RELEASE: /* key released */ { long code = translateKey(pressedkey); - lt_info("[CEC] decoded key %s (%ld)\n",ToString((cec_user_control_code)pressedkey), code); + lt_debug("[CEC] decoded key %s (%ld)\n",ToString((cec_user_control_code)pressedkey), code); handleCode(code,keypressed); break; } @@ -559,14 +559,14 @@ void hdmi_cec::handleCode(long code, bool keypressed) int evd = open(RC_DEVICE, O_RDWR); if (evd < 0) { - perror("opening " RC_DEVICE " failed"); + lt_debug("[CEC] opening " RC_DEVICE " failed"); return; } if (keypressed) { if (rc_send(evd, code, KEY_PRESSED) < 0) { - perror("writing 'KEY_PRESSED' event failed"); + lt_debug("[CEC] writing 'KEY_PRESSED' event failed"); close(evd); return; } @@ -576,7 +576,7 @@ void hdmi_cec::handleCode(long code, bool keypressed) { if (rc_send(evd, code, KEY_RELEASED) < 0) { - perror("writing 'KEY_RELEASED' event failed"); + lt_debug("[CEC] writing 'KEY_RELEASED' event failed"); close(evd); return; }