|
From: <me...@us...> - 2008-03-03 11:33:48
|
Revision: 944
http://gmyth.svn.sourceforge.net/gmyth/?rev=944&view=rev
Author: melunko
Date: 2008-03-03 03:33:49 -0800 (Mon, 03 Mar 2008)
Log Message:
-----------
Now add/cancel a schedule recording while livetv is running is finnaly working fine.
Modified Paths:
--------------
trunk/gmyth/gmyth/gmyth_scheduler.c
trunk/gmyth/gmyth/gmyth_scheduler.h
trunk/gmyth/gmyth/gmyth_util.c
Modified: trunk/gmyth/gmyth/gmyth_scheduler.c
===================================================================
--- trunk/gmyth/gmyth/gmyth_scheduler.c 2008-03-01 23:15:42 UTC (rev 943)
+++ trunk/gmyth/gmyth/gmyth_scheduler.c 2008-03-03 11:33:49 UTC (rev 944)
@@ -61,6 +61,10 @@
GMythProgramInfo *prog_info,
gchar *new_group);
+static gint
+gmyth_scheduler_query_schedule_list (GMythScheduler * scheduler,
+ GList ** schedule_list,
+ gchar *filter);
static gboolean update_backend(GMythScheduler * scheduler, gint record_id);
@@ -225,25 +229,62 @@
* @return The amount of schedules retrieved from database, or -1 if error.
*/
gint
-gmyth_scheduler_get_schedule_list(GMythScheduler * scheduler,
- GList ** schedule_list)
+gmyth_scheduler_get_schedule_list (GMythScheduler * scheduler,
+ GList ** schedule_list)
{
+ return gmyth_scheduler_query_schedule_list (scheduler, schedule_list, NULL);
+}
+
+ScheduleInfo*
+gmyth_scheduler_get_schedule (GMythScheduler * scheduler, gint sched_id)
+{
+ GList *sched_list = NULL;
+ ScheduleInfo *schedule = NULL;
+ gchar *filter;
+ gint count;
+
+ filter = g_strdup_printf ("WHERE recordid=%d", sched_id);
+
+ count = gmyth_scheduler_query_schedule_list (scheduler, &sched_list, filter);
+ if ((count > 0) && (sched_list != NULL)) {
+ schedule = (ScheduleInfo*) sched_list->data;
+ g_list_free (sched_list);
+ }
+
+ g_free (filter);
+ return schedule;
+}
+
+static gint
+gmyth_scheduler_query_schedule_list (GMythScheduler * scheduler,
+ GList ** schedule_list,
+ gchar *filter)
+{
+
ScheduleInfo *schedule;
MYSQL_RES *msql_res;
GString *query_str = g_string_new("");
gchar *date_time = NULL;
assert(scheduler);
-
- g_string_printf(query_str,
- "SELECT recordid,programid,chanid,starttime,startdate,"
- "endtime,enddate,title,subtitle,description,category,type,parentid,seriesid FROM record;");
-
if (scheduler->msqlquery == NULL) {
g_warning("[%s] Scheduler db connection not initialized",
__FUNCTION__);
return -1;
}
+
+ if (filter == NULL) {
+ g_string_printf(query_str,
+ "SELECT recordid,programid,chanid,starttime,startdate,"
+ "endtime,enddate,title,subtitle,description,category,type,parentid,seriesid FROM record;");
+ } else {
+ g_string_printf(query_str,
+ "SELECT recordid,programid,chanid,starttime,startdate,"
+ "endtime,enddate,title,subtitle,description,category,type,parentid,seriesid FROM record "
+ "%s;", filter);
+
+ }
+
msql_res =
gmyth_query_process_statement(scheduler->msqlquery,
query_str->str);
@@ -496,7 +537,7 @@
ScheduleInfo * schedule_info, GMythScheduleType type)
{
MYSQL_RES *msql_res;
- gchar *query_str = "INSERT record (recordid) VALUE (0);";
+ gchar *query_str = NULL;
gchar *station = NULL;
gulong rec_id;
@@ -521,9 +562,9 @@
gint recorder_num =
gmyth_scheduler_is_program_live_recorded (scheduler, schedule_info,
&prog_info);
- if (recorder_num > 0) {
- g_debug ("Recording already found in livetv... setting live record");
+ if ((recorder_num > 0) && (prog_info != NULL)) {
gmyth_scheduler_change_record_group (scheduler, prog_info, "Default");
+ schedule_info->schedule_id = prog_info->recordid;
return gmyth_scheduler_set_live_record (scheduler, schedule_info,
recorder_num, TRUE);
@@ -532,7 +573,8 @@
msql_res =
gmyth_query_process_statement_with_increment(scheduler->msqlquery,
- query_str, &rec_id);
+ "INSERT record (recordid) VALUE (0);",
+ &rec_id);
mysql_free_result(msql_res);
// Retrieves the station info
@@ -665,13 +707,12 @@
GList *iter = list;
while (iter) {
GMythRecorder *recorder = GMYTH_RECORDER ( iter->data );
- g_debug ("XXXX verifying the recorder %d", recorder->recorder_num);
if (gmyth_recorder_is_recording (recorder)) {
GMythProgramInfo *pinfo = gmyth_recorder_get_current_program_info (recorder);
if (pinfo != NULL) {
- if ((schedule_info->channel_id == pinfo->channel_id)) {
- g_debug ("XXXXXX recorder %d is recording the program", recorder->recorder_num);
+ if ((schedule_info->channel_id == pinfo->channel_id) &&
+ (schedule_info->start_time->tv_sec == pinfo->startts->tv_sec)) {
recorder_num = recorder->recorder_num;
*prog_info = pinfo;
break;
@@ -708,7 +749,6 @@
socket = gmyth_backend_info_get_connected_socket (scheduler->backend_info);
if (socket != NULL) {
- g_debug ("XXXX sending command for live recording");
ret = (gmyth_socket_sendreceive_stringlist(socket, strlist) > 0);
g_object_unref (socket);
} else {
@@ -734,10 +774,8 @@
return FALSE;
}
- //prog_info->recstartts->tv_sec += 60*60*2;
startts = gmyth_util_time_to_string_from_time_val (prog_info->recstartts);
- g_debug ("\n\n%s\n\n", startts);
query_str = g_strdup_printf("UPDATE recorded SET recgroup = \"%s\" "
"WHERE chanid = \"%d\" AND starttime = \"%s\"",
new_group, prog_info->channel_id, startts);
@@ -759,12 +797,11 @@
* @return gboolean TRUE if success, FALSE if error
*/
gboolean
-gmyth_scheduler_delete_schedule(GMythScheduler * scheduler, gint schedule_id)
+gmyth_scheduler_delete_schedule (GMythScheduler * scheduler, gint schedule_id)
{
+ MYSQL_RES *msql_res;
+ GString *query_str = NULL;
- MYSQL_RES *msql_res;
- GString *query_str = NULL;
-
g_return_val_if_fail (scheduler != NULL, FALSE);
@@ -774,6 +811,28 @@
return FALSE;
}
+ {
+ /* Before adding the schedule, we need to check if program is been played */
+ GMythProgramInfo *prog_info = NULL;
+ ScheduleInfo *sched_info = NULL;
+
+ sched_info = gmyth_scheduler_get_schedule (scheduler, schedule_id);
+ if (sched_info != NULL) {
+ gint recorder_num =
+ gmyth_scheduler_is_program_live_recorded (scheduler, sched_info,
+ &prog_info);
+ if ((recorder_num > 0) && (prog_info != NULL)) {
+ gboolean ret;
+ gmyth_scheduler_change_record_group (scheduler, prog_info, "LiveTV");
+
+ ret = gmyth_scheduler_set_live_record (scheduler, sched_info,
+ recorder_num, FALSE);
+ gmyth_schedule_info_free (sched_info);
+ return ret;
+ }
+ }
+ }
+
query_str = g_string_new("");
g_string_printf(query_str,
"DELETE FROM record WHERE recordid=%d", schedule_id);
@@ -883,175 +942,6 @@
return FALSE;
}
-
-gboolean gmyth_scheduler_reactivate_schedule(GMythScheduler* scheduler, gint channel_id,
- time_t start_time)
-
-{
- MYSQL_RES *msql_res;
- GString *query_str = g_string_new("");
-
- assert(scheduler);
- g_string_printf(query_str, "SELECT callsign FROM channel "
- "WHERE chanid = \"%d\"", channel_id);
-
- msql_res = gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
- if (msql_res) {
- MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
- if (msql_row) {
- GString* callsign = g_string_new(msql_row[0]);
- GString* startts = gmyth_util_time_to_string(start_time);
- g_string_printf(query_str, "UPDATE oldrecorded SET reactivate = 1 "
- "WHERE station = \"%s\" AND starttime = \"%s\"",
- callsign->str, startts->str);
- gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
- g_string_free(callsign, TRUE);
- g_string_free(startts, TRUE);
- g_string_free(query_str, TRUE);
- return TRUE;
- }
-
- }
-
- return FALSE;
-}
-
-
-/*
- * This should only be used in special situations. We do not know the time that
- * the recording was set. We just know that it is an "ongoing" record and then
- * we have to use this to get it's info. It's always the oldest one -> first on list
- *
- */
-GMythProgramInfo*
-gmyth_scheduler_get_recorded_on_time(GMythScheduler* scheduler,
- guint channel_id)
-{
- MYSQL_RES *msql_res;
- GMythProgramInfo *proginfo = NULL;
- GString *query_str = g_string_new("");
-
- assert(scheduler);
-
- g_string_printf(query_str,
- "SELECT recorded.chanid,starttime,endtime,title,"
- "subtitle,description,channel.channum,"
- "channel.callsign,channel.name,channel.commfree,"
- "channel.outputfilters,seriesid,programid,filesize,"
- "lastmodified,stars,previouslyshown,originalairdate,"
- "hostname,recordid,transcoder,playgroup,"
- "recorded.recpriority,progstart,progend,basename,recgroup,"
- "category,findid,duplicate "
- "FROM recorded " "LEFT JOIN channel "
- "ON recorded.chanid = channel.chanid "
- "WHERE recorded.chanid = %d "
- "ORDER BY starttime DESC", channel_id);
-
- msql_res =
- gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
-
- if (msql_res) {
- MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
-
- if (msql_row) {
- proginfo = gmyth_program_info_new();
-
- proginfo->channel_id = (gint) g_ascii_strtoull (msql_row[0], NULL, 10);
- proginfo->recstartts = gmyth_util_string_to_time_val(msql_row[1]);
- proginfo->recendts = gmyth_util_string_to_time_val(msql_row[2]);
-
- proginfo->title = g_string_new(msql_row[3]);
- proginfo->subtitle = g_string_new(msql_row[4]);
- proginfo->description = g_string_new(msql_row[5]);
-
- proginfo->chanstr = g_string_new(msql_row[6]);
- proginfo->chansign = g_string_new(msql_row[7]);
- proginfo->channame = g_string_new(msql_row[8]);
- proginfo->chancommfree = (gint) g_ascii_strtoull(msql_row[9], NULL, 10);
- proginfo->chanOutputFilters = g_string_new(msql_row[10]);
- proginfo->seriesid = g_string_new(msql_row[11]);
- proginfo->program_id = g_string_new(msql_row[12]);
- proginfo->filesize = g_ascii_strtoull(msql_row[13], NULL, 10);
-
- proginfo->lastmodified = gmyth_util_string_to_time_val(msql_row[14]);
- proginfo->stars = g_ascii_strtod(msql_row[15], NULL);
- proginfo->repeat = (gint)g_ascii_strtoull(msql_row[16], NULL, 10);
-
- if (msql_row[17] == NULL) {
- proginfo->originalAirDate = 0;
- proginfo->hasAirDate = FALSE;
- } else {
- proginfo->originalAirDate = gmyth_util_string_to_time_val(msql_row[17]);
- proginfo->hasAirDate = TRUE;
- }
-
- proginfo->hostname = g_string_new(msql_row[18]);
- proginfo->recordid = (gint) g_ascii_strtoull(msql_row[19], NULL, 10);
- proginfo->transcoder = (gint) g_ascii_strtoull(msql_row[20], NULL, 10);
-
- proginfo->playgroup = g_string_new(msql_row[21]);
- proginfo->recpriority = (gint) g_ascii_strtoull(msql_row[22], NULL, 10);
-
- proginfo->startts = gmyth_util_string_to_time_val(msql_row[23]);
- proginfo->endts = gmyth_util_string_to_time_val(msql_row[24]);
- proginfo->pathname = g_string_new(g_strdup(msql_row[25]));
- proginfo->recgroup = g_string_new(msql_row[26]);
- proginfo->category = g_string_new(msql_row[27]);
- proginfo->findid = (gint) g_ascii_strtoull(msql_row[28], NULL, 10);
-
- proginfo->recpriority2 = 0;
-
- g_string_printf(query_str,
- "SELECT dupmethod,dupin,parentid,type "
- "FROM record WHERE recordid = \"%d\"", proginfo->recordid);
-
- msql_res =
- gmyth_query_process_statement(scheduler->msqlquery,
- query_str->str);
-
- if (msql_res) {
- MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
-
- if (msql_row) {
- proginfo->dupmethod = (gint) g_ascii_strtoull(msql_row[0], NULL, 10);
- proginfo->dupin = (gint) g_ascii_strtoull(msql_row[1], NULL, 10);
- proginfo->parentid = (gint) g_ascii_strtoull(msql_row[2], NULL, 10);
- proginfo->rectype = 0;
- }
- }
-
-
- g_string_printf(query_str,
- "SELECT sourceid,cardid,cardinputid,shareable "
- "FROM cardinput");
-
- msql_res =
- gmyth_query_process_statement(scheduler->msqlquery,
- query_str->str);
-
- if (msql_res) {
- MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
-
- if (msql_row) {
- proginfo->sourceid = 0;
- proginfo->cardid = 0;
- proginfo->inputid = 0;
- if (msql_row[3] != NULL && g_ascii_strcasecmp("Y", msql_row[3]) == 0)
- proginfo->shareable = 1;
- else
- proginfo->shareable = 0;
- }
- }
-
-
-
- }
- }
-
- g_string_free(query_str, TRUE);
- return proginfo;
-}
-
/** Retrieves an existing recorded item information from database. The information
* is used to fill the returned GMythProgramInfo.
*
@@ -1167,115 +1057,7 @@
return proginfo;
}
-gboolean
-gmyth_scheduler_stop_recording (GMythScheduler * scheduler,
- gint channel_id)
-{
- GMythProgramInfo *program;
- GMythSocket *socket;
- gboolean res = FALSE;
- GMythStringList *slist;
- socket = gmyth_backend_info_get_connected_socket (scheduler->backend_info);
- program = gmyth_scheduler_get_recorded_on_time (scheduler, channel_id);
-
- if (program) {
- slist = gmyth_string_list_new();
- gmyth_string_list_append_char_array(slist, "STOP_RECORDING");
-
- gmyth_string_list_append_string(slist, program->title); /* 0 */
- gmyth_string_list_append_string(slist, program->subtitle); /* 1 */
- gmyth_string_list_append_string(slist, program->description); /* 2 */
- gmyth_string_list_append_string(slist, program->category); /* 3 */
- gmyth_string_list_append_int(slist, program->channel_id); /* 4 */
- gmyth_string_list_append_string(slist, program->chanstr); /* 5 */
- gmyth_string_list_append_string(slist, program->chansign); /* 6 */
- gmyth_string_list_append_string(slist, program->channame); /* 7 */
- gmyth_string_list_append_string(slist, program->pathname); /* 8 */
- gmyth_string_list_append_int64(slist, program->filesize); /* 9 */
-
- if (program->startts)
- gmyth_string_list_append_int(slist, program->startts->tv_sec); /* 10 */
- else
- gmyth_string_list_append_int(slist, 0);
-
- if (program->endts)
- gmyth_string_list_append_int(slist, program->endts->tv_sec); /* 11 */
- else
- gmyth_string_list_append_int(slist, 0);
-
- gmyth_string_list_append_int(slist, program->duplicate); /* 12 */
- gmyth_string_list_append_int(slist, program->shareable); /* 13 */
- gmyth_string_list_append_int(slist, program->findid); /* 14 */
- gmyth_string_list_append_string(slist, program->hostname); /* 15 */
- gmyth_string_list_append_int(slist, program->sourceid); /* 16 */
- gmyth_string_list_append_int(slist, program->cardid); /* 17 */
- gmyth_string_list_append_int(slist, program->inputid); /* 18 */
- gmyth_string_list_append_int(slist, program->recpriority); /* 19 */
-
- // recstatus == recording
- gmyth_string_list_append_int(slist, -3); /* 20 */
-
- gmyth_string_list_append_int(slist, program->recordid); /* 21 */
- gmyth_string_list_append_int(slist, program->rectype); /* 22 */
- gmyth_string_list_append_int(slist, program->dupin); /* 23 */
- gmyth_string_list_append_int(slist, program->dupmethod); /* 24 */
-
-
- //fixme
- program->recstartts->tv_sec -= (60*60);
-
- gmyth_string_list_append_int(slist,
- program->recstartts != NULL ?
- program->recstartts->tv_sec : 0); /* 26 */
-
- gmyth_string_list_append_int(slist,
- program->recendts != NULL ?
- program->recendts->tv_sec : 0); /* 27 */
-
- gmyth_string_list_append_int(slist, program->repeat); /* 28 */
- gmyth_string_list_append_int(slist, program->programflags); /* 29 */
-
- gmyth_string_list_append_char_array(slist,
- program->recgroup != NULL ?
- program->recgroup->str : "Default"); /* 30 */
-
- gmyth_string_list_append_int(slist, program->chancommfree); /* 31 */
- gmyth_string_list_append_string(slist, program->chanOutputFilters); /* 32 */
- gmyth_string_list_append_string(slist, program->seriesid); /* 33 */
- gmyth_string_list_append_string(slist, program->program_id); /* 34 */
-
- gmyth_string_list_append_int(slist,
- program->lastmodified != NULL ?
- program->lastmodified->tv_sec : 0); /* 35 */
-
- gmyth_string_list_append_float(slist, program->stars); /* 36 */
-
- gmyth_string_list_append_int(slist,
- program->originalAirDate != NULL ?
- program->originalAirDate->tv_sec : 0); /* 37 */
-
- gmyth_string_list_append_int(slist, program->hasAirDate); /* 38 */
-
- gmyth_string_list_append_char_array(slist,
- program->playgroup != NULL ?
- program->playgroup->str : "Default"); /* 39 */
-
- gmyth_string_list_append_int(slist, program->recpriority2); /* 40 */
- gmyth_string_list_append_int(slist, program->recpriority2); /* 40 */
-
- gmyth_socket_sendreceive_stringlist(socket, slist);
- res = (gmyth_string_list_get_int(slist, 0) == 1);
-
- g_object_unref (program);
- g_object_unref (slist);
- }
-
- g_object_unref (socket);
- return res;
-}
-
-
/** Notifies the backend of an update in the db.
*
* @param record_id the id of the modified recording.
Modified: trunk/gmyth/gmyth/gmyth_scheduler.h
===================================================================
--- trunk/gmyth/gmyth/gmyth_scheduler.h 2008-03-01 23:15:42 UTC (rev 943)
+++ trunk/gmyth/gmyth/gmyth_scheduler.h 2008-03-03 11:33:49 UTC (rev 944)
@@ -149,18 +149,12 @@
gboolean gmyth_scheduler_disconnect (GMythScheduler * scheduler);
gint gmyth_scheduler_get_schedule_list (GMythScheduler * scheduler,
GList ** sched_list);
+ScheduleInfo* gmyth_scheduler_get_schedule (GMythScheduler * scheduler,
+ gint schedule_id);
gint gmyth_scheduler_get_recorded_list (GMythScheduler * scheduler,
GList ** rec_list);
RecordedInfo* gmyth_scheduler_get_recorded_info (GMythScheduler *scheduler,
const char *basename);
-gboolean gmyth_scheduler_was_recorded_before (GMythScheduler* scheduler,
- gint channel_id,
- time_t start_time);
-gboolean gmyth_scheduler_reactivate_schedule (GMythScheduler* scheduler,
- gint channel_id,
- time_t start_time);
-GMythProgramInfo* gmyth_scheduler_get_recorded_on_time (GMythScheduler* scheduler,
- guint channel_id);
GMythProgramInfo* gmyth_scheduler_get_recorded (GMythScheduler * scheduler,
GString * channel,
GTimeVal * starttime);
@@ -179,8 +173,6 @@
gint record_id);
gint gmyth_scheduler_delete_recorded (GMythScheduler * scheduler,
gint record_id);
-gboolean gmyth_scheduler_stop_recording (GMythScheduler * scheduler,
- gint channel_id);
void gmyth_scheduler_recorded_info_get_preview(RecordedInfo * info,
GByteArray * data);
Modified: trunk/gmyth/gmyth/gmyth_util.c
===================================================================
--- trunk/gmyth/gmyth/gmyth_util.c 2008-03-01 23:15:42 UTC (rev 943)
+++ trunk/gmyth/gmyth/gmyth_util.c 2008-03-03 11:33:49 UTC (rev 944)
@@ -95,7 +95,7 @@
* @param time_value the GTimeValue to be converted
* @return GString* the converted isoformat string
*/
-gchar *
+gchar*
gmyth_util_time_to_isoformat_from_time_val_fmt(const gchar * fmt_string,
const GTimeVal * time_val)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|