Code Monkey home page Code Monkey logo

jankammerath / iptvx Goto Github PK

View Code? Open in Web Editor NEW
80.0 10.0 37.0 10.02 MB

IPTV player and streamer for Linux that allows to play any stream that LibVLC can play, offers an overlay based on WebKit using HTML5, JavaScript and CSS and uses XMLTV data for EPG information. It allows the playback of URLs, files and can grab URLs from shell scripts. XMLTV EPG data can be downloaded from URLs or grabbed from shell scripts.

Home Page: http://iptvx.org

License: Apache License 2.0

C 74.00% HTML 1.29% C++ 5.23% CSS 3.97% JavaScript 13.92% Makefile 1.37% Shell 0.21%
streamer linux iptv-player xmltv-data iptv c xmltv overlay-menu television tv

iptvx's Introduction

๐Ÿ‘‹ Hi, Iโ€™m Jan and I like programming ๐Ÿ˜Š My GitHub repositories are here to keep some of my fun projects. My favourite programming languages are Go, Swift, C and C++. I stopped using Windows around 20 years ago when I switched to Unix systems such as Linux and macOS ๐Ÿฆ. All my projects are here for educational purposes.

iptvx's People

Contributors

jankammerath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iptvx's Issues

Fix potential SegFault scenarios

A lot of code sections have the probability of SegFaults and should be fixed to ensure they handle misbehavior and difficult circumstances properly.

Grab multiple daily EPG files during runtime

EPG files are only grabbed initially on startup for the current day. As the evening passes, the files become outdated and there should be a new bunch of EPG files parsed. Ideally also there should be a config to allow parsing up to 7 days of epg.

build issues?

Hi,

Thanks for your work on this. I look forward to see the final product. I have the following issue on Ubuntu. When trying to do the ./build.sh I get the following errors:

osboxes@osboxes:~/iptvx$ ./build.sh
src/config.c:32:23: fatal error: libconfig.h: No such file or directory
#include <libconfig.h>
^
compilation terminated.
src/epg.c:23:23: fatal error: libconfig.h: No such file or directory
#include <libconfig.h>
^
compilation terminated.
src/main.c:24:23: fatal error: libconfig.h: No such file or directory
#include <libconfig.h>
^
compilation terminated.
src/util.c:32:23: fatal error: curl/curl.h: No such file or directory
#include <curl/curl.h>
^
compilation terminated.
src/video.c:19:21: fatal error: vlc/vlc.h: No such file or directory
#include <vlc/vlc.h>
^
compilation terminated.
src/window.c:25:27: fatal error: SDL/SDL_image.h: No such file or directory
#include <SDL/SDL_image.h>
^
compilation terminated.

Can you please help?

Many thanks Dorin

Server/daemon backend for EPG and recording

A server backend running as a daemon will provide a JSON API interface through HTTP. A switch allows to set the application into server-mode and the client will be able to use the server instead of its local files.

Daemon server process

By default the application will launch a daemon running in the background that operates epg data and also controls the scheduled recordings.

JSON HTTP API

The following methods will be available on the server's API:

  • Query all epg data or per channel
  • List all scheduled and stored recordings
  • Schedule new recordings, delete scheduled recordings
  • Delete stored recordings
  • Download stored recordings

The json-c lib is already linked and in use. For the server it is potentially interesting to use libmicrohttpd which is a GNU project and provides a reasonable HTTP server.

Follow proper naming convention

Everything needs to follow the naming convention! Words in functions and variables are separated by underscore "" and globally used variables as well as functions begin with "iptvx". Everything is lowercase!

Mem leak in iptvx_config_get_data_dir (config.c)

==31875== 10 bytes in 1 blocks are definitely lost in loss record 349 of 7,856
==31875== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0x9F73490: g_malloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8C62D: g_strjoin (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x403D94: iptvx_config_get_data_dir (config.c:127)
==31875== by 0x403EFF: iptvx_config_init (config.c:169)
==31875== by 0x4057AC: main (main.c:232)
==31875==
==31875== 10 bytes in 1 blocks are definitely lost in loss record 350 of 7,856
==31875== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0x9F73490: g_malloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8C62D: g_strjoin (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x403D94: iptvx_config_get_data_dir (config.c:127)
==31875== by 0x405819: main (main.c:245)
==31875==
==31875== 11 bytes in 1 blocks are definitely lost in loss record 376 of 7,856
==31875== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0x9F73490: g_malloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8C62D: g_strjoin (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x403DB8: iptvx_config_get_data_dir (config.c:128)
==31875== by 0x403EFF: iptvx_config_init (config.c:169)
==31875== by 0x4057AC: main (main.c:232)
==31875==
==31875== 11 bytes in 1 blocks are definitely lost in loss record 377 of 7,856
==31875== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0x9F73490: g_malloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8C62D: g_strjoin (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x403DB8: iptvx_config_get_data_dir (config.c:128)
==31875== by 0x405819: main (main.c:245)

argp segfaults

Check the argp implementation. It used to work, but now segfaults and is commented out.

Midnight EPG pull results in empty data

EPG pulls up until 3am might result in issues that there is no current programme as the schedule was defined in an XMLTV for the previous day. Solution should be to grab the previous day's EPG until 5am in the morning.

Mem leak video_init (video.c)

==31753== 2,328 (296 direct, 2,032 indirect) bytes in 1 blocks are definitely lost in loss record 10,785 of 11,162
==31753== at 0x4C2B200: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31753== by 0x13477151: input_item_NewWithType (in /usr/lib64/libvlccore.so.8.0.0)
==31753== by 0x1347748F: input_item_NewExt (in /usr/lib64/libvlccore.so.8.0.0)
==31753== by 0xA44EAB0: libvlc_media_new_location (in /usr/lib64/libvlc.so.5.5.0)
==31753== by 0x406002: iptvx_video_init (video.c:44)
==31753== by 0x405531: channel_video_play (main.c:83)
==31753== by 0x405714: epg_status_update (main.c:190)
==31753== by 0x404C7E: iptvx_epg_load (epg.c:484)
==31753== by 0xAE6B687: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)
==31753== by 0xAEAAE68: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)
==31753== by 0xB0F90A3: start_thread (in /lib64/libpthread-2.19.so)
==31753== by 0xB5FE02C: clone (in /lib64/libc-2.19.so)

Possible mem leak in iptvx_epg_get_programmelist (epg.c)

==31875== 14 bytes in 7 blocks are possibly lost in loss record 423 of 7,856
==31875== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0xA97F048: xmlStrndup (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA9D2C0C: ??? (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA9D3B65: xmlSAX2Characters (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA91EE51: xmlParseContent (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA91F7A2: xmlParseElement (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA91FDD9: xmlParseDocument (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA923AEB: xmlSAXParseDoc (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0x40464A: iptvx_epg_get_programmelist (epg.c:313)
==31875== by 0x404AF5: iptvx_epg_load_channel (epg.c:447)
==31875== by 0x404BE9: iptvx_epg_load (epg.c:474)
==31875== by 0xAE6B687: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)

Test drive beta version in different scenarios

Beta version needs to be fit to handle a number of corrupt configurations, misconfigurations, non-existent EPG files, non-existent URLs etc. pp. The alpha version expects a clean lab environment, but the beta needs to be capable of running in the real world and in dirty environments.

WebKit overlay implementation

Each stream also needs to webkit instance creating the overlay which is then being captured and drawn over the actual image/frame from FFmpeg.

Here already is a sample code for that:
https://github.com/clopez/wksnap/blob/master/wksnap.c

Here is the full WebKit doc:
https://webkitgtk.org/reference/webkit2gtk/stable/

Background can be made transparent:
WEBKIT_SNAPSHOT_OPTIONS_TRANSPARENT_BACKGROUND

WebKit's JS world can be accessed through:
https://webkitgtk.org/reference/webkit2gtk/stable/WebKitScriptWorld.html

Search functionality

There should be a search functionality that allows to search for channels and programmes.

Recording functionality

Recordings can be activated instantly or scheduled from the EPG. This is to be done in combination with the server backend daemon process defined in #48

Mem leak in iptvx_epg_config_get_string (epg.c)

==31875== 84 (72 direct, 12 indirect) bytes in 3 blocks are definitely lost in loss record 5,559 of 7,856
==31875== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0x9F73490: g_malloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8916D: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8D042: g_string_sized_new (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x404DD5: iptvx_epg_config_get_string (epg.c:529)
==31875== by 0x404F29: iptvx_epg_init (epg.c:585)
==31875== by 0x405848: main (main.c:250)
==31875==
==31875== 84 (72 direct, 12 indirect) bytes in 3 blocks are definitely lost in loss record 5,560 of 7,856
==31875== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0x9F73490: g_malloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8916D: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8D042: g_string_sized_new (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x404DD5: iptvx_epg_config_get_string (epg.c:529)
==31875== by 0x404F68: iptvx_epg_init (epg.c:588)
==31875== by 0x405848: main (main.c:250)
==31875==
==31875== 84 (72 direct, 12 indirect) bytes in 3 blocks are definitely lost in loss record 5,561 of 7,856
==31875== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0x9F73490: g_malloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8916D: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8D042: g_string_sized_new (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x404DD5: iptvx_epg_config_get_string (epg.c:529)
==31875== by 0x404FA7: iptvx_epg_init (epg.c:591)
==31875== by 0x405848: main (main.c:250)

Check GString usage and fix it

There are a lot of different usage styles of GStrings which seem to be candidates for segfaults. Sometimes it casts them to char pointers, sometimes uses the "str" struct field etc. That is prone to errors and needs a fix.

Enter key (13) event causes an error in WebKit

Error is Syntax Error - Unexpected EOF and is propably caused by the KeyEvent inserted. Can be reproduced by calling the following function with parameter KeyCode being 13.

void iptvx_js_sendkey(int keyCode){
char scriptKeyEvent[512];
char keyName[2];
keyName[0] = (char)keyCode;
keyName[1] = '\0';
sprintf(scriptKeyEvent,"var e = new Event(\"keydown\");"
"e.key=\"%s\";e.keyCode=%d;"
"e.which=%d;e.altKey=false;e.ctrlKey=false;"
"e.shiftKey=false;e.metaKey=false;e.bubbles=true;"
"window.dispatchEvent(e);",keyName,keyCode,keyCode);
webkit_web_view_run_javascript(js_view,scriptKeyEvent,NULL,NULL,NULL);
}

Mem leak in epg_get_programmelist (epg.c)

==31875== 620 bytes in 1 blocks are possibly lost in loss record 7,480 of 7,856
==31875== at 0x4C2B41E: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0xA9D3C51: xmlSAX2Characters (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA914ED9: ??? (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA91EE51: xmlParseContent (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA91F7A2: xmlParseElement (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA91EF27: xmlParseContent (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA91F7A2: xmlParseElement (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA91EF27: xmlParseContent (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA91F7A2: xmlParseElement (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA91FDD9: xmlParseDocument (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0xA923AEB: xmlSAXParseDoc (in /usr/lib64/libxml2.so.2.9.1)
==31875== by 0x40464A: iptvx_epg_get_programmelist (epg.c:313)

Mem leak in file_get_contents (util.c)

==31875== 1,523,712 bytes in 20 blocks are definitely lost in loss record 7,853 of 7,856
==31875== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0x4C2B4AF: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0x9F7352E: g_realloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8D023: ??? (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8D071: g_string_sized_new (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8D692: g_string_new (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x405CEA: file_get_contents (util.c:136)
==31875== by 0x404AE5: iptvx_epg_load_channel (epg.c:443)
==31875== by 0x404BE9: iptvx_epg_load (epg.c:474)
==31875== by 0xAE6B687: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)
==31875== by 0xAEAAE68: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)
==31875== by 0xB0F90A3: start_thread (in /lib64/libpthread-2.19.so)

Search directories for config file and make directories configurable

Data directories for the app and the data need to be configurable in the config file. The config file should be searched for in the following directories and the following order.

  • /etc/iptvx/iptvx.conf
  • ~user/.iptvx/iptvx.conf
  • cfg/iptvx.conf
  • ./iptvx.conf

A "--config=FILE" argument should optionally also take the configuration file.

Window and UI should use GTK+

As the WebKit widget already links GTK+ it also should be used for the main application window. This will make the application significantly more flexible.

Mem leak in config_init (config.c)

==31875== 32 (24 direct, 8 indirect) bytes in 1 blocks are definitely lost in loss record 3,415 of 7,856
==31875== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0x9F73490: g_malloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8916D: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8D042: g_string_sized_new (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8D692: g_string_new (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x403F0F: iptvx_config_init (config.c:170)
==31875== by 0x4057AC: main (main.c:232)

Handle playback errors

Currently the error status is not handled properly and the loading indicator just keeps on going. There should be an error icon indicating an issue.

Mem leak in epg_load_channel (epg.c)

==31875== 460 bytes in 21 blocks are definitely lost in loss record 7,423 of 7,856
==31875== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0x9F73490: g_malloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x9F8C62D: g_strjoin (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x404A00: iptvx_epg_load_channel (epg.c:413)
==31875== by 0x404BE9: iptvx_epg_load (epg.c:474)
==31875== by 0xAE6B687: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)
==31875== by 0xAEAAE68: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)
==31875== by 0xB0F90A3: start_thread (in /lib64/libpthread-2.19.so)
==31875== by 0xB5FE02C: clone (in /lib64/libc-2.19.so)

Channel up and down not implemented

It's calling the wrong core command and should not call any at all, but use the JS EPG implementation to tell the core to which channel to switch to.

WebKit overlay's excessive memory consumption

The WebKit overlay has excessive memory consumption. It seems to pinpoint to the snapshot functionality and even grows enormously when only one snapshot is being made. May also relate to the threading in there.

Mem leak in webkit_start (webkit.c)

==31875== 32 bytes in 1 blocks are definitely lost in loss record 3,416 of 7,856
==31875== at 0x4C2B200: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31875== by 0xBCD263F: _dlerror_run (in /lib64/libdl-2.19.so)
==31875== by 0xBCD20C0: dlopen@@GLIBC_2.2.5 (in /lib64/libdl-2.19.so)
==31875== by 0xD202DC5: g_module_open (in /usr/lib64/libgmodule-2.0.so.0.4400.1)
==31875== by 0x740DEF8: ??? (in /usr/lib64/libgtk-3.so.0.1600.7)
==31875== by 0x73E66C1: ??? (in /usr/lib64/libgtk-3.so.0.1600.7)
==31875== by 0x9F78A2E: g_option_context_parse (in /usr/lib64/libglib-2.0.so.0.4400.1)
==31875== by 0x73E6B9D: gtk_parse_args (in /usr/lib64/libgtk-3.so.0.1600.7)
==31875== by 0x73E6BF7: gtk_init_check (in /usr/lib64/libgtk-3.so.0.1600.7)
==31875== by 0x73E6C38: gtk_init (in /usr/lib64/libgtk-3.so.0.1600.7)
==31875== by 0x40635C: iptvx_webkit_start (webkit.c:135)
==31875== by 0xAE6B687: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)

Mem leaks in JS API (js.c)

==32027== 16 bytes in 1 blocks are definitely lost in loss record 2,959 of 11,729
==32027== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==32027== by 0x9F73490: g_malloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==32027== by 0x9F8916D: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==32027== by 0x9F896AD: g_slice_alloc0 (in /usr/lib64/libglib-2.0.so.0.4400.1)
==32027== by 0x9F6ABD9: ??? (in /usr/lib64/libglib-2.0.so.0.4400.1)
==32027== by 0x9F6CE98: g_main_current_source (in /usr/lib64/libglib-2.0.so.0.4400.1)
==32027== by 0x8E96B23: g_task_new (in /usr/lib64/libgio-2.0.so.0.4400.1)
==32027== by 0x551DD49: webkit_web_view_run_javascript (in /usr/lib64/libwebkit2gtk-4.0.so.37.11.10)
==32027== by 0x40522A: iptvx_js_update_state (js.c:110)
==32027== by 0x40575B: update (main.c:213)
==32027== by 0xAE6B687: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)
==32027== by 0xAEAAE68: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.