Skip to content
Permalink
Browse files

playback without epg in the client core works now

  • Loading branch information...
jankammerath committed Jan 11, 2018
1 parent 836c3a0 commit 677e1e6e904aa5246919e0c0120c9bbe73c879d9
Showing with 97 additions and 0 deletions.
  1. BIN bin/iptvx
  2. +5 −0 cfg/iptvx.conf
  3. +36 −0 src/daemon.c
  4. +44 −0 src/epg.c
  5. +7 −0 src/epg.h
  6. +5 −0 src/main.c
BIN +1.02 KB (100%) bin/iptvx
Binary file not shown.
@@ -68,5 +68,10 @@ daemon_port = 8085
# client to reach the daemon
daemon_url = "http://127.0.0.1:8085/app/app.html"

# url of the json channel list
# to be used for the client to
# play channels from
daemon_list = "http://127.0.0.1:8085/list.json"

# include channels
@include "/etc/iptvx/channels.conf"
@@ -173,6 +173,39 @@ GString* iptvx_daemon_get_recordlist_json(){
return result;
}

/*
Returns a json string with the channel list
*/
GString* iptvx_daemon_get_channel_list_json(){
json_object* j_chan_array = json_object_new_array();

if(iptvx_daemon_epg_data != NULL){
int c = 0;
for(c = 0; c < iptvx_daemon_epg_data->len; c++){
channel* chan = &g_array_index(iptvx_daemon_epg_data,channel,c);

json_object* j_chan = json_object_new_object();
json_object_object_add(j_chan,"default",
json_object_new_boolean(chan->isDefault));
json_object_object_add(j_chan,"name",
json_object_new_string(chan->name->str));
json_object_object_add(j_chan,"url",
json_object_new_string(chan->url->str));

/* add the channel to the result json array */
json_object_array_add(j_chan_array,j_chan);
}
}
/* finally pass j_object to result string */
char* json_result_buf = (char*)json_object_to_json_string(j_chan_array);
GString* result = g_string_new(json_result_buf);

/* free the json object */
json_object_put(j_chan_array);

return result;
}

/*
Returns the url for a given channel
@param channel_name name of the channel
@@ -324,6 +357,9 @@ GString* iptvx_daemon_get_response(char* request_url, struct MHD_Connection* con
if(g_strcmp0(request_url,"/")==0){
/* current epg status is requested */
result = iptvx_daemon_get_status_json();
}if(g_strcmp0(request_url,"/list.json")==0){
/* channel list is requested */
result = iptvx_daemon_get_channel_list_json();
}if(g_strcmp0(request_url,"/epg.json")==0){
/* full epg in json is requested */
if(iptvx_daemon_epg_json != NULL){
@@ -721,6 +721,50 @@ GString* iptvx_epg_config_get_string(config_setting_t* element, char* setting_na
return result;
}

/*
Initialises the epg with a url identifying the channel json from a daemon
@param url url to hold json data with channel information
@return bool with true when initialised otherwise false
*/
bool iptvx_epg_init_client(char* url){
bool result = true;

/* create a new empty list */
list = g_array_new (false,false,sizeof(channel));

/* download the json data for parsing */
GString* json_list = util_download_string(url);

/* parse input to json object */
json_object* list_obj = json_tokener_parse(json_list->str);

if(list_obj != NULL){
/* parsing went fine */
int i = 0;
for(i = 0; i < json_object_array_length(list_obj); i++){
/* get the channel object from the array */
json_object* chan_obj = json_object_array_get_idx(list_obj, i);

/* create the new channel object */
channel chan;
chan.isDefault = json_object_get_boolean
(json_object_object_get(chan_obj,"default"));
chan.name = g_string_new(json_object_get_string
(json_object_object_get(chan_obj,"name")));
chan.url = g_string_new(json_object_get_string
(json_object_object_get(chan_obj,"url")));

g_array_append_val(list,chan);
}
}else{
/* parsing failed, that's a no */
result = false;
}


return result;
}

/*
Initialises EPG and loads XMLTV files
@param cfg Config struct from libconfig holding channel config
@@ -79,6 +79,13 @@ void iptvx_epg_set_current_channel_id(int channelId);
*/
channel* iptvx_epg_get_current_channel();

/*
Initialises the epg with a url identifying the channel json from a daemon
@param url url to hold json data with channel information
@return bool with true when initialised otherwise false
*/
bool iptvx_epg_init_client(char* url);

/*
Initialises EPG and loads XMLTV files
@param cfg Config struct from libconfig holding channel config
@@ -343,6 +343,11 @@ void start_window(){
void* overlay_rendering = iptvx_get_overlay_rendering_ptr();
iptvx_window_set_overlay(overlay_data,overlay_ready,overlay_rendering);

/* initialise the client with the epg */
char* listUrl = iptvx_config_get_setting_string("daemon_list",
"http://127.0.0.1:8085/list.json");
iptvx_epg_init_client(listUrl);

/* start the webkit thread */
char* overlayUrl = iptvx_config_get_setting_string("daemon_url",
"http://127.0.0.1:8085/app/app.html");

0 comments on commit 677e1e6

Please sign in to comment.
You can’t perform that action at this time.