# HG changeset patch # User morphbr # Date 1172870750 0 # Node ID 4071ea7f32e6393227e83c68dc44aef8ca5e0922 # Parent 438858a187f955a05a260210b13fd370e99dd5df [svn r388] - Created gmyth_recprofile class - Updated gmyth_transcode and gmyth_http to use gmyth_recprofile diff -r 438858a187f9 -r 4071ea7f32e6 gmyth/src/Makefile.am --- a/gmyth/src/Makefile.am Thu Mar 01 20:07:46 2007 +0000 +++ b/gmyth/src/Makefile.am Fri Mar 02 21:25:50 2007 +0000 @@ -18,16 +18,17 @@ gmyth_query.c \ gmyth_socket.c \ gmyth_stringlist.c \ - gmyth_monitor_handler.c \ - gmyth_file_transfer.c \ + gmyth_monitor_handler.c \ + gmyth_file_transfer.c \ gmyth_livetv.c \ gmyth_backendinfo.c \ gmyth_programinfo.c \ - gmyth_uri.c \ + gmyth_uri.c \ gmyth_http.c \ - gmyth_vlc.c \ + gmyth_vlc.c \ gmyth_jobqueue.c \ gmyth_transcode.c \ + gmyth_recprofile.c \ $(BUILT_SOURCES) @@ -44,16 +45,16 @@ mv gmyth_marshal.c.tmp gmyth_marshal.c libgmyth_la_CFLAGS = \ - -DDATADIR=\"$(pkgdatadir)\" \ + -DDATADIR=\"$(pkgdatadir)\" \ $(GLIB_CFLAGS) \ $(GOBJECT_CFLAGS) \ $(GST_CFLAGS) \ $(GSTBASE_CFLAGS) \ - $(GSTPLUGINSBASE_CFLAGS) \ + $(GSTPLUGINSBASE_CFLAGS) \ $(MYSQL_CFLAGS) \ $(LIBXML_CFLAGS) -libgmyth_la_LDFLAGS = \ +libgmyth_la_LDFLAGS = \ -export-dynamic \ $(MYSQL_LIBS) \ $(GST_LIBS) \ @@ -65,7 +66,7 @@ $(pkgincludedir) libgmyth_include_HEADERS = \ - gmyth.h \ + gmyth.h \ gmyth_common.h \ gmyth_debug.h \ gmyth_epg.h \ @@ -77,15 +78,16 @@ gmyth_socket.h \ gmyth_remote_util.h \ gmyth_stringlist.h \ - gmyth_monitor_handler.h \ - gmyth_file_transfer.h \ + gmyth_monitor_handler.h \ + gmyth_file_transfer.h \ gmyth_livetv.h \ gmyth_backendinfo.h \ gmyth_programinfo.h \ - gmyth_uri.h \ + gmyth_uri.h \ gmyth_http.h \ - gmyth_vlc.h \ + gmyth_vlc.h \ gmyth_jobqueue.h \ - gmyth_transcode.h + gmyth_transcode.h \ + gmyth_recprofile.h CLEANFILES = $(BUILT_SOURCES) diff -r 438858a187f9 -r 4071ea7f32e6 gmyth/src/gmyth.h --- a/gmyth/src/gmyth.h Thu Mar 01 20:07:46 2007 +0000 +++ b/gmyth/src/gmyth.h Fri Mar 02 21:25:50 2007 +0000 @@ -50,5 +50,6 @@ #include #include #include +#include #endif /* _GMYTH_H_ */ diff -r 438858a187f9 -r 4071ea7f32e6 gmyth/src/gmyth_http.c --- a/gmyth/src/gmyth_http.c Thu Mar 01 20:07:46 2007 +0000 +++ b/gmyth/src/gmyth_http.c Fri Mar 02 21:25:50 2007 +0000 @@ -38,7 +38,6 @@ #include "gmyth_debug.h" #include "gmyth_socket.h" - xmlXPathObjectPtr getnodeset(xmlDocPtr doc, xmlChar *xpath) { @@ -90,38 +89,38 @@ GSList* get_Program_List(xmlNodePtr node) { GSList* program_list = NULL; - + while (node != NULL) { if (g_ascii_strcasecmp((char *)node->name, "text") != 0) { - GMythProgram* program = (GMythProgram*)\ - g_malloc(sizeof(struct _GMythProgram)); - - program->title = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"title")); + GMythProgram* program = (GMythProgram*)\ + g_malloc(sizeof(struct _GMythProgram)); + + program->title = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"title")); + + program->subtitle = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"subtitle")); + + program->catType = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"catType")); + + program->category = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"category")); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"repeat"),\ + "%d", &(program->repeat)); + + program->startTime = gmyth_util_string_to_time_val \ + ((char *)xmlGetProp(node,(xmlChar *)"startTime")); + + program->endTime = gmyth_util_string_to_time_val \ + ((char *)xmlGetProp(node,(xmlChar *)"endTime")); + + program_list = g_slist_append(program_list, program); + } - program->subtitle = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"subtitle")); - - program->catType = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"catType")); - - program->category = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"category")); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"repeat"),\ - "%d", &(program->repeat)); - - program->startTime = gmyth_util_string_to_time_val \ - ((char *)xmlGetProp(node,(xmlChar *)"startTime")); - - program->endTime = gmyth_util_string_to_time_val \ - ((char *)xmlGetProp(node,(xmlChar *)"endTime")); - - program_list = g_slist_append(program_list, program); - } - node = node->next; } @@ -137,33 +136,33 @@ void get_Channel_List (xmlNodePtr node, GMythEpg* epg) { epg->channelList = NULL; - + while (node != NULL) { - + if (g_ascii_strcasecmp((char *)node->name, "text") != 0) { GMythChannel* channel = (GMythChannel*)g_malloc\ - (sizeof(struct _GMythChannel)); - + (sizeof(struct _GMythChannel)); + channel->channelName = g_string_new((char *)\ - xmlGetProp(node,\ - (xmlChar *)"channelName")); - + xmlGetProp(node,\ + (xmlChar *)"channelName")); + channel->chanNum = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"chanNum")); - + xmlGetProp(node, (xmlChar *)"chanNum")); + sscanf ((char *)xmlGetProp(node, (xmlChar *)"chanId"),\ - "%d", &(channel->chanId)); - + "%d", &(channel->chanId)); + sscanf ((char *)xmlGetProp(node, (xmlChar *)"callSign"),\ - "%d", &(channel->callSign)); - + "%d", &(channel->callSign)); + channel->programList = get_Program_List(node->children); - + epg->channelList = g_slist_append(epg->channelList, channel); - + } - + node=node->next; } } @@ -176,26 +175,26 @@ */ void get_ProgramGuide_Properties (xmlNodePtr nodeTab, GMythEpg* epg) { - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"startChanId"), "%d", &(epg->startChanId)); - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"endChanId"), "%d", &(epg->endChanId)); - - epg->version = g_string_new((char *)xmlGetProp(nodeTab, (xmlChar *)"version")); - - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"protoVer"), "%d", &(epg->protoVer)); - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"totalCount"), "%d", &(epg->totalCount)); - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"numOfChannels"), "%d", &(epg->numOfChannels)); - - epg->asOf = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"asOf")); - epg->startTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"startTime")); - epg->endTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"endTime")); - - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"details"), "%d", &(epg->details)); - - // go to Channel section and retrieve Channels and Programs - if ( epg->numOfChannels > 0 ) - get_Channel_List(nodeTab->children->next->children->next, epg); - else - epg->channelList = NULL; + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"startChanId"), "%d", &(epg->startChanId)); + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"endChanId"), "%d", &(epg->endChanId)); + + epg->version = g_string_new((char *)xmlGetProp(nodeTab, (xmlChar *)"version")); + + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"protoVer"), "%d", &(epg->protoVer)); + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"totalCount"), "%d", &(epg->totalCount)); + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"numOfChannels"), "%d", &(epg->numOfChannels)); + + epg->asOf = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"asOf")); + epg->startTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"startTime")); + epg->endTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"endTime")); + + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"details"), "%d", &(epg->details)); + + // go to Channel section and retrieve Channels and Programs + if ( epg->numOfChannels > 0 ) + get_Channel_List(nodeTab->children->next->children->next, epg); + else + epg->channelList = NULL; } /** Aux function to retrieve the Eletronic Program Guide @@ -216,14 +215,14 @@ { nodeset = result->nodesetval; for (i=0; i < nodeset->nodeNr; i++) - { - keyword = (xmlChar*)nodeset->nodeTab[i]->name; - if (g_ascii_strcasecmp((char *)keyword, "ProgramGuide") == 0) - { - get_ProgramGuide_Properties(nodeset->nodeTab[i], epg); - break; - } - } + { + keyword = (xmlChar*)nodeset->nodeTab[i]->name; + if (g_ascii_strcasecmp((char *)keyword, "ProgramGuide") == 0) + { + get_ProgramGuide_Properties(nodeset->nodeTab[i], epg); + break; + } + } xmlXPathFreeObject (result); } @@ -237,104 +236,103 @@ * @return The epg */ GMythEpg gmyth_http_retrieve_epg (GMythBackendInfo *backend_info, \ - GTimeVal* StartTime, GTimeVal* EndTime, \ - gint StartChanId, gint NumOfChannels, \ - gchar* Details) + GTimeVal* StartTime, GTimeVal* EndTime, \ + gint StartChanId, gint NumOfChannels, \ + gchar* Details) { - GMythEpg epg; - MemoryStruct chunk; - - chunk.memory=NULL; /* we expect realloc(NULL, size) to work */ - chunk.size = 0; /* no data at this point */ - - gchar* starttime = (gchar*)g_malloc(sizeof(gchar)*20); - starttime = gmyth_util_time_to_mythformat_from_time_val(StartTime); - - gchar* endtime = (gchar*)g_malloc(sizeof(gchar)*20); - endtime = gmyth_util_time_to_mythformat_from_time_val(EndTime); - - GString* command = g_string_new(""); - g_string_printf(command, "getProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d" - "&NumOfChannels=%d&Details=%s", starttime, endtime, \ - StartChanId, NumOfChannels, Details); - - chunk = gmyth_http_request(backend_info, command); - if (chunk.memory != NULL) - { - xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory)); - getEpg(doc, &epg); - free(chunk.memory); - } - - return epg; + GMythEpg epg; + MemoryStruct chunk; + + chunk.memory=NULL; /* we expect realloc(NULL, size) to work */ + chunk.size = 0; /* no data at this point */ + + gchar* starttime = (gchar*)g_malloc(sizeof(gchar)*20); + starttime = gmyth_util_time_to_mythformat_from_time_val(StartTime); + + gchar* endtime = (gchar*)g_malloc(sizeof(gchar)*20); + endtime = gmyth_util_time_to_mythformat_from_time_val(EndTime); + + GString* command = g_string_new(""); + g_string_printf(command, "getProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d" + "&NumOfChannels=%d&Details=%s", starttime, endtime, \ + StartChanId, NumOfChannels, Details); + + chunk = gmyth_http_request(backend_info, command); + if (chunk.memory != NULL) + { + xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory)); + getEpg(doc, &epg); + free(chunk.memory); + } + + return epg; } GMythRecorded_Recording retrieve_recorded_recording (xmlNodePtr node) { - GMythRecorded_Recording recording; - - if (g_ascii_strcasecmp((char *)node->name, "text") != 0) - { - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"dupInType"),\ - "%d", &(recording.dupInType)); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"dupMethod"),\ - "%d", &(recording.dupMethod)); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"preRollSeconds"),\ - "%d", &(recording.preRollSeconds)); - - recording.playGroup = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"playGroup")); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"recPriority"),\ - "%d", &(recording.recPriority)); - - recording.recStartTs = gmyth_util_string_to_time_val\ - ((char *)xmlGetProp(node, (xmlChar *)"recStartTs")); - } - - return recording; + GMythRecorded_Recording recording; + + if (g_ascii_strcasecmp((char *)node->name, "text") != 0) + { + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"dupInType"),\ + "%d", &(recording.dupInType)); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"dupMethod"),\ + "%d", &(recording.dupMethod)); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"preRollSeconds"),\ + "%d", &(recording.preRollSeconds)); + + recording.playGroup = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"playGroup")); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"recPriority"),\ + "%d", &(recording.recPriority)); + + recording.recStartTs = gmyth_util_string_to_time_val\ + ((char *)xmlGetProp(node, (xmlChar *)"recStartTs")); + } + + return recording; } -GMythRecorded_Channel retrieve_recorded_channel (xmlNodePtr node) +GMythRecorded_Channel retrieve_recorded_channel (xmlNodePtr node) { - GMythRecorded_Channel channel; - - if (g_ascii_strcasecmp((char *)node->name, "text") != 0) - { + GMythRecorded_Channel channel; + if (g_ascii_strcasecmp((char *)node->name, "text") != 0) + { - channel.chanFilters = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"chanFilters")); - - channel.channelName = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"channelName")); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"chanNum"),\ - "%d", &(channel.chanNum)); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"sourceId"),\ - "%d", &(channel.sourceId)); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"commFree"),\ - "%d", &(channel.commFree)); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"inputId"),\ - "%d", &(channel.inputId)); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"chanId"),\ - "%d", &(channel.chanId)); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"callSign"),\ - "%d", &(channel.callSign)); - } - - return channel; + channel.chanFilters = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"chanFilters")); + + channel.channelName = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"channelName")); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"chanNum"),\ + "%d", &(channel.chanNum)); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"sourceId"),\ + "%d", &(channel.sourceId)); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"commFree"),\ + "%d", &(channel.commFree)); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"inputId"),\ + "%d", &(channel.inputId)); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"chanId"),\ + "%d", &(channel.chanId)); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"callSign"),\ + "%d", &(channel.callSign)); + } + + return channel; } @@ -347,78 +345,77 @@ */ GSList* get_Recorded_Programs(xmlNodePtr node) { - GSList* programList = NULL; - - while (node != NULL) { + GSList* programList = NULL; - if (g_ascii_strcasecmp((char *)node->name, "text") != 0) - { - - GMythRecorded_Program* program = (GMythRecorded_Program*)g_malloc\ - (sizeof(struct _GMythRecorded_Program)); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"programFlags"),\ - "%d", &(program->programFlags)); - - program->title = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"title")); - - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"programId"),\ - "%d", &(program->programId)); - - program->catType = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"catType")); - - program->category = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"category")); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"seriesId"),\ - "%d", &(program->seriesId)); - - - program->startTime = gmyth_util_string_to_time_val\ - ((char *)xmlGetProp(node, (xmlChar *)"startTime")); - - program->endTime = gmyth_util_string_to_time_val\ - ((char *)xmlGetProp(node, (xmlChar *)"endTime")); - - program->lastModified = gmyth_util_string_to_time_val\ - ((char *)xmlGetProp(node, (xmlChar *)"lastModified")); - - /* TODO: FIX ME at gmyth_util - program->asOf = gmyth_util_string_to_time_val\ - ((char *)xmlGetProp(node, (xmlChar *)"airdate"));*/ - - - program->subTitle = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"subTitle")); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"stars"),\ - "%d", &(program->stars)); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"repeat"),\ - "%d", &(program->repeat)); - - sscanf ((char *)xmlGetProp(node, (xmlChar *)"fileSize"),\ - "%d", &(program->repeat)); - - program->hostname = g_string_new((char *)\ - xmlGetProp(node, (xmlChar *)"hostname")); - - program->channel = retrieve_recorded_channel(node->children); - - // Skip the \n - program->recording = retrieve_recorded_recording(node->children->next->next); - - // add to the list - programList = g_slist_append(programList, program); + while (node != NULL) { + + if (g_ascii_strcasecmp((char *)node->name, "text") != 0) + { + + GMythRecorded_Program* program = (GMythRecorded_Program*)g_malloc\ + (sizeof(struct _GMythRecorded_Program)); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"programFlags"),\ + "%d", &(program->programFlags)); + + program->title = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"title")); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"programId"),\ + "%d", &(program->programId)); + + program->catType = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"catType")); + + program->category = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"category")); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"seriesId"),\ + "%d", &(program->seriesId)); + + + program->startTime = gmyth_util_string_to_time_val\ + ((char *)xmlGetProp(node, (xmlChar *)"startTime")); + + program->endTime = gmyth_util_string_to_time_val\ + ((char *)xmlGetProp(node, (xmlChar *)"endTime")); + + program->lastModified = gmyth_util_string_to_time_val\ + ((char *)xmlGetProp(node, (xmlChar *)"lastModified")); + + /* TODO: FIX ME at gmyth_util + program->asOf = gmyth_util_string_to_time_val\ + ((char *)xmlGetProp(node, (xmlChar *)"airdate"));*/ + + + program->subTitle = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"subTitle")); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"stars"),\ + "%d", &(program->stars)); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"repeat"),\ + "%d", &(program->repeat)); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)"fileSize"),\ + "%d", &(program->repeat)); + + program->hostname = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"hostname")); + + program->channel = retrieve_recorded_channel(node->children); + + // Skip the \n + program->recording = retrieve_recorded_recording(node->children->next->next); + + // add to the list + programList = g_slist_append(programList, program); + } + + node = node->next; } - - node = node->next; - } - - return programList; + + return programList; } /** Retrieves the properties from Recorded XML @@ -429,21 +426,21 @@ */ void get_Recorded_Properties (xmlNodePtr nodeTab, GMythRecorded* recorded) { - recorded->version = g_string_new((char *)\ - xmlGetProp(nodeTab, (xmlChar *)"version")); - - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)\ - "protoVer"), "%d", &(recorded->protoVer)); - - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)\ - "totalCount"), "%d", &(recorded->totalCount)); - - - recorded->asOf = gmyth_util_string_to_time_val \ - ((char *)xmlGetProp(nodeTab, (xmlChar *)"asOf")); - - if ( recorded->totalCount > 0) - recorded->programList = get_Recorded_Programs(nodeTab->children->next); + recorded->version = g_string_new((char *)\ + xmlGetProp(nodeTab, (xmlChar *)"version")); + + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)\ + "protoVer"), "%d", &(recorded->protoVer)); + + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)\ + "totalCount"), "%d", &(recorded->totalCount)); + + + recorded->asOf = gmyth_util_string_to_time_val \ + ((char *)xmlGetProp(nodeTab, (xmlChar *)"asOf")); + + if ( recorded->totalCount > 0) + recorded->programList = get_Recorded_Programs(nodeTab->children->next); } @@ -466,14 +463,14 @@ { nodeset = result->nodesetval; for (i=0; i < nodeset->nodeNr; i++) - { - keyword = (xmlChar*)nodeset->nodeTab[i]->name; - if (g_ascii_strcasecmp((char *)keyword, "Recorded") == 0) - { - get_Recorded_Properties(nodeset->nodeTab[i], recorded); - break; - } - } + { + keyword = (xmlChar*)nodeset->nodeTab[i]->name; + if (g_ascii_strcasecmp((char *)keyword, "Recorded") == 0) + { + get_Recorded_Properties(nodeset->nodeTab[i], recorded); + break; + } + } xmlXPathFreeObject (result); } @@ -485,25 +482,24 @@ */ GMythRecorded gmyth_http_retrieve_recorded (GMythBackendInfo *backend_info) { - GMythRecorded recorded; - MemoryStruct chunk; + GMythRecorded recorded; + MemoryStruct chunk; - chunk.memory = NULL; - chunk.size = 0; + chunk.memory = NULL; + chunk.size = 0; - GString* command = g_string_new(""); - g_string_printf(command, "getRecorded"); - - chunk = gmyth_http_request(backend_info, command); - if (chunk.memory != NULL) - { - xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory)); - getRecorded(doc, &recorded); - free(chunk.memory); - } + GString* command = g_string_new(""); + g_string_printf(command, "getRecorded"); + chunk = gmyth_http_request(backend_info, command); + if (chunk.memory != NULL) + { + xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory)); + getRecorded(doc, &recorded); + free(chunk.memory); + } - return recorded; + return recorded; } /** Function to retrieve settings on the backend @@ -521,7 +517,7 @@ xmlChar *keyword; MemoryStruct chunk; gchar* value = NULL; - + chunk.memory = NULL; chunk.size = 0; @@ -555,6 +551,171 @@ return value; } +/** Common steps for rec_profile's functions + * + * @param backend_info infos about the backend + * @param id the profile's id that you want to delete + * @return 0 if OK + */ +gint rec_profile_common(GMythBackendInfo *backend_info, + GString* command) +{ + xmlXPathObjectPtr result; + xmlNodeSetPtr nodeset; + xmlChar *keyword; + MemoryStruct chunk; + + chunk.memory = NULL; + chunk.size = 0; + + int ret = -1; + + chunk = gmyth_http_request(backend_info, command); + + if (chunk.memory != NULL) + { + xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory)); + + result = getXPath((xmlChar *)"/*", doc); + + if (result) + { + nodeset = result->nodesetval; + keyword = (xmlChar*)nodeset->nodeTab[0]->name; + + if (g_ascii_strcasecmp((char *)keyword, "Success") == 0) + ret = 0; + + xmlXPathFreeObject (result); + } + + free(chunk.memory); + } + + return ret; +} + + +/** Function to delete recording profiles + * + * @param backend_info infos about the backend + * @param id the profile's id that you want to delete + * @return 0 if OK + */ +gint gmyth_http_del_rec_profile (GMythBackendInfo *backend_info, + gint id) +{ + int ret = -1; + + GString* command = g_string_new(""); + g_string_printf(command, "delRecProfiles?id=%d", id); + + + return rec_profile_common(backend_info, command); +} + +/** Function to create recording profiles + * + * @param backend_info infos about the backend + * @param profilename the name of profile you want to use + * @param groupname the name of groupname you want to use + * @param vcodec the name of the video codec you want to use + * @param acodec the name of the audo codec you want to use + * @return 0 if OK + */ +gint gmyth_http_create_rec_profile (GMythBackendInfo *backend_info, + GMythRecProfile* profile) +{ + + if (profile->name != NULL && profile->group != NULL && + profile->vcodec && profile->acodec) + { + GString* command = g_string_new(""); + g_string_printf(command, "createRecProfiles?profilename=%s&"\ + "groupname=%s&vcodec=%s&acodec=%s", + profile->name->str, profile->group->str, + profile->vcodec->str, profile->acodec->str); + + + return rec_profile_common(backend_info, command); + } + else + return -1; +} + +/** Function to retrieve recording profiles + * + * @param backend_info infos about the backend + * @param groupname the name of group you want to retrieve + * @return the list of profiles + */ +GSList* gmyth_http_retrieve_rec_profiles (GMythBackendInfo *backend_info,\ + gchar* groupname) +{ + xmlXPathObjectPtr result; + xmlNodeSetPtr nodeset; + xmlChar *keyword; + MemoryStruct chunk; + GSList* profiles = NULL; + + chunk.memory = NULL; + chunk.size = 0; + + GString* command = g_string_new(""); + g_string_printf(command, "getRecProfiles?groupname=%s", groupname); + + chunk = gmyth_http_request(backend_info, command); + + if (chunk.memory != NULL) + { + xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory)); + + result = getXPath((xmlChar *)"/*", doc); + + if (result) + { + nodeset = result->nodesetval; + keyword = (xmlChar*)nodeset->nodeTab[0]->name; + + if (g_ascii_strcasecmp((char *)keyword, "Profiles") == 0) + { + xmlNodePtr node = nodeset->nodeTab[0]->children->next; + GMythRecProfile* profile; + + while (node != NULL) + { + if (g_ascii_strcasecmp((char *)node->name, "text") != 0) + { + profile = gmyth_recprofile_new(); + + sscanf ((char *)xmlGetProp(node, (xmlChar *)\ + "id"), "%d", &(profile->id)); + + profile->name = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"name")); + + profile->vcodec = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"vcodec")); + + profile->acodec = g_string_new((char *)\ + xmlGetProp(node, (xmlChar *)"acodec")); + + profile->group = g_string_new(groupname); + + profiles = g_slist_append(profiles, profile); + } + node = node->next; + } + + } + xmlXPathFreeObject (result); + } + + free(chunk.memory); + } + + return profiles; +} @@ -572,18 +733,18 @@ size_t WriteMemoryCallback (void *ptr, size_t size, size_t nmemb, void *data) { - size_t realsize = size * nmemb; - MemoryStruct *mem = (struct _MemoryStruct *)data; + size_t realsize = size * nmemb; + MemoryStruct *mem = (struct _MemoryStruct *)data; - mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1); - if (mem->memory) - { - memcpy(&(mem->memory[mem->size]), ptr, realsize); - mem->size += realsize; - mem->memory[mem->size] = 0; - } + mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1); + if (mem->memory) + { + memcpy(&(mem->memory[mem->size]), ptr, realsize); + mem->size += realsize; + mem->memory[mem->size] = 0; + } - return realsize; + return realsize; } /** Create a String containing the URL with the command @@ -634,9 +795,9 @@ gchar *URL = (gchar *)g_malloc(sizeof(gchar)*size); g_snprintf(URL, size, "http://%s:%d/%s", \ - backend_info->hostname, \ - backend_info->status_port, \ - command->str); + backend_info->hostname, \ + backend_info->status_port, \ + command->str); CURL *curl_handle; diff -r 438858a187f9 -r 4071ea7f32e6 gmyth/src/gmyth_http.h --- a/gmyth/src/gmyth_http.h Thu Mar 01 20:07:46 2007 +0000 +++ b/gmyth/src/gmyth_http.h Fri Mar 02 21:25:50 2007 +0000 @@ -39,6 +39,7 @@ #include "gmyth_backendinfo.h" #include "gmyth_util.h" +#include "gmyth_recprofile.h" #include #include @@ -49,8 +50,8 @@ #define MYTH_PORT_STATUS 6544 typedef struct _GMythRecorded_Recording GMythRecorded_Recording; -typedef struct _GMythRecorded_Channel GMythRecorded_Channel; -typedef struct _GMythRecorded_Program GMythRecorded_Program; +typedef struct _GMythRecorded_Channel GMythRecorded_Channel; +typedef struct _GMythRecorded_Program GMythRecorded_Program; typedef struct _GMythRecorded GMythRecorded; typedef struct _GMythProgram GMythProgram; typedef struct _GMythChannel GMythChannel; @@ -63,7 +64,6 @@ size_t size; }; - struct _GMythProgram { GString* title; @@ -156,7 +156,7 @@ gchar* gmyth_http_retrieve_setting (GMythBackendInfo *backend_info,\ - gchar* key, gchar* hostname); + gchar* key, gchar* hostname); GMythEpg gmyth_http_retrieve_epg(GMythBackendInfo *backend_info, \ GTimeVal* StartTime, GTimeVal* EndTime, \ @@ -164,6 +164,15 @@ GMythRecorded gmyth_http_retrieve_recorded (GMythBackendInfo *backend_info); +GSList* gmyth_http_retrieve_rec_profiles (GMythBackendInfo *backend_info,\ + gchar* groupname); + +gint gmyth_http_create_rec_profile (GMythBackendInfo *backend_info,\ + GMythRecProfile* profile); + +gint gmyth_http_del_rec_profile (GMythBackendInfo *backend_info, + gint id); + MemoryStruct gmyth_http_request (GMythBackendInfo *backend_info, GString *command); G_END_DECLS diff -r 438858a187f9 -r 4071ea7f32e6 gmyth/src/gmyth_recprofile.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/src/gmyth_recprofile.c Fri Mar 02 21:25:50 2007 +0000 @@ -0,0 +1,153 @@ +/** + * GMyth Library + * + * @file gmyth/gmyth_recprofile.c + * + * @brief

This file contains the recprofile class. + * + * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia. + * @author Artur Duque de Souza + * + */ +/* + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include "gmyth_recprofile.h" +#include "gmyth_util.h" +#include "gmyth_debug.h" +#include "gmyth_http.h" + +static void gmyth_recprofile_class_init (GMythRecProfileClass *klass); +static void gmyth_recprofile_init (GMythRecProfile *object); + +static void gmyth_recprofile_dispose (GObject *object); +static void gmyth_recprofile_finalize (GObject *object); + +G_DEFINE_TYPE(GMythRecProfile, gmyth_recprofile, G_TYPE_OBJECT) + +static void +gmyth_recprofile_class_init (GMythRecProfileClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + gobject_class->dispose = gmyth_recprofile_dispose; + gobject_class->finalize = gmyth_recprofile_finalize; +} + +static void +gmyth_recprofile_init (GMythRecProfile *recprofile) +{ +} + +static void +gmyth_recprofile_dispose (GObject *object) +{ + GMythRecProfile *recprofile = GMYTH_RECPROFILE(object); + + if (recprofile->name) + g_free(recprofile->name); + + if (recprofile->group) + g_free(recprofile->group); + + if (recprofile->vcodec) + g_free(recprofile->vcodec); + + if (recprofile->acodec) + g_free(recprofile->acodec); + + G_OBJECT_CLASS (gmyth_recprofile_parent_class)->dispose (object); +} + +static void +gmyth_recprofile_finalize (GObject *object) +{ + g_signal_handlers_destroy (object); + G_OBJECT_CLASS (gmyth_recprofile_parent_class)->finalize (object); +} + +/** + * Creates a new instance of GMythRecProfile. + * + * @return a new instance of GMythRecProfile. + **/ +GMythRecProfile* +gmyth_recprofile_new (void) +{ + GMythRecProfile *recprofile = GMYTH_RECPROFILE\ + (g_object_new(GMYTH_RECPROFILE_TYPE, NULL)); + + recprofile->id = 0; + recprofile->name = NULL; + recprofile->group = NULL; + recprofile->vcodec = NULL; + recprofile->acodec = NULL; + + return recprofile; +} + + +/** + * + * gmyth_recprofile_get_profile_list + * @brief get profile list from the backend + * @param backend_info GMythBackendInfo* + * @return GSList + * + **/ +GSList* gmyth_recprofile_get_profile_list (GMythBackendInfo *backend_info) +{ + return gmyth_http_retrieve_rec_profiles(backend_info, "Transcoders"); +} + +/** + * + * gmyth_recprofile_create_profile + * @brief get profile list from the backend + * @param backend_info GMythBackendInfo* + * @param profile GMythRecProfile* + * @return gint representing the result + * + **/ +gint gmyth_recprofile_create_profile (GMythBackendInfo *backend_info, + GMythRecProfile* profile) +{ + return gmyth_http_create_rec_profile (backend_info, profile); +} + +/** + * + * gmyth_recprofile_del_profile + * @brief del profile from the backend + * @param backend_info GMythBackendInfo* + * @param id profile's id + * @return gint representing the result + * + **/ +gint gmyth_recprofile_del_profile_list (GMythBackendInfo *backend_info, + gint id) +{ + return gmyth_http_del_rec_profile(backend_info, id); +} \ No newline at end of file diff -r 438858a187f9 -r 4071ea7f32e6 gmyth/src/gmyth_recprofile.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/src/gmyth_recprofile.h Fri Mar 02 21:25:50 2007 +0000 @@ -0,0 +1,83 @@ +/** + * GMyth Library + * + * @file gmyth/gmyth_recprofile.h + * + * @brief

This file contains the recprofile class. + * + * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia. + * @author Artur Duque de Souza + * + */ +/* + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GMYTH_RECPROFILE_H +#define _GMYTH_RECPROFILE_H + +#include +#include + +#include "gmyth_stringlist.h" +#include "gmyth_backendinfo.h" +#include "gmyth_socket.h" + +G_BEGIN_DECLS + +#define GMYTH_RECPROFILE_TYPE (gmyth_recprofile_get_type ()) +#define GMYTH_RECPROFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_RECPROFILE_TYPE, GMythRecProfile)) +#define GMYTH_RECPROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_RECPROFILE_TYPE, GMythRecProfileClass)) +#define IS_GMYTH_RECPROFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_RECPROFILE_TYPE)) +#define IS_GMYTH_RECPROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_RECPROFILE_TYPE)) +#define GMYTH_RECPROFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_RECPROFILE_TYPE, GMythRecProfileClass)) + +typedef struct _GMythRecProfile GMythRecProfile; +typedef struct _GMythRecProfileClass GMythRecProfileClass; + +struct _GMythRecProfileClass +{ + GObjectClass parent_class; + + /* callbacks */ +}; + +struct _GMythRecProfile +{ + gint id; + GString* name; + GString* group; + GString* vcodec; + GString* acodec; +}; + + + +GType gmyth_recprofile_type (void); + +GMythRecProfile* gmyth_recprofile_new (void); + +GSList* gmyth_recprofile_get_profile_list (GMythBackendInfo *backend_info); + +gint gmyth_recprofile_create_profile (GMythBackendInfo *backend_info,\ + GMythRecProfile* profile); + +gint gmyth_recprofile_del_profile_list (GMythBackendInfo *backend_info,\ + gint id); + +G_END_DECLS + +#endif /*_GMYTH_RECPROFILE_H*/ diff -r 438858a187f9 -r 4071ea7f32e6 gmyth/src/gmyth_transcode.c --- a/gmyth/src/gmyth_transcode.c Thu Mar 01 20:07:46 2007 +0000 +++ b/gmyth/src/gmyth_transcode.c Fri Mar 02 21:25:50 2007 +0000 @@ -58,14 +58,6 @@ static void gmyth_transcode_init (GMythTranscode *transcode) { - transcode->backend_info = NULL; - transcode->output_filename = NULL; - transcode->filename = NULL; - transcode->profile = NULL; - transcode->starttime = NULL; - - transcode->cutlist = FALSE; - transcode->output = FALSE; } static void @@ -105,6 +97,7 @@ { GMythTranscode *transcode = GMYTH_TRANSCODE\ (g_object_new(GMYTH_TRANSCODE_TYPE, NULL)); + return transcode; } @@ -194,31 +187,3 @@ transcode->filename = g_string_new(file); } } - -/** - * - * gmyth_transcode_get_profile_list - * @brief get profile list from the backend - * @param backend_info GMythBackendInfo* - * @return GSList - * - **/ -GSList* gmyth_transcode_get_profile_list (GMythBackendInfo *backend_info) -{ - //TODO: CODE THIS - return NULL; -} - -/** - * - * gmyth_transcode_create_profile - * @brief get profile list from the backend - * @param backend_info GMythBackendInfo* - * @return gint representing the result - * - **/ -gint gmyth_transcode_create_profile (GMythBackendInfo *backend_info) -{ - //TODO: CODE THIS - return 0; -} diff -r 438858a187f9 -r 4071ea7f32e6 gmyth/src/gmyth_transcode.h --- a/gmyth/src/gmyth_transcode.h Thu Mar 01 20:07:46 2007 +0000 +++ b/gmyth/src/gmyth_transcode.h Fri Mar 02 21:25:50 2007 +0000 @@ -35,6 +35,8 @@ #include "gmyth_stringlist.h" #include "gmyth_backendinfo.h" #include "gmyth_socket.h" +#include "gmyth_http.h" +#include "gmyth_recprofile.h" G_BEGIN_DECLS