Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
htsp: updateDvrEntry: add support for updating channel.
  • Loading branch information
ksooo authored and perexg committed Jul 1, 2015
1 parent 54b799d commit 568d0ef
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/dvr/dvr.h
Expand Up @@ -447,7 +447,7 @@ dvr_entry_create_htsp( const char *dvr_config_uuid,
const char *comment );

dvr_entry_t *
dvr_entry_update( dvr_entry_t *de,
dvr_entry_update( dvr_entry_t *de, channel_t *ch,
const char *title, const char *subtitle,
const char *desc, const char *lang,
time_t start, time_t stop,
Expand Down
23 changes: 15 additions & 8 deletions src/dvr/dvr_db.c
Expand Up @@ -928,9 +928,10 @@ dvr_timer_expire(void *aux)
}

static dvr_entry_t *_dvr_entry_update
( dvr_entry_t *de, epg_broadcast_t *e, const char *title, const char *subtitle,
const char *desc, const char *lang, time_t start, time_t stop,
time_t start_extra, time_t stop_extra, dvr_prio_t pri, int retention )
( dvr_entry_t *de, epg_broadcast_t *e, channel_t *ch, const char *title,
const char *subtitle, const char *desc, const char *lang, time_t start,
time_t stop, time_t start_extra, time_t stop_extra, dvr_prio_t pri,
int retention )
{
char buf[40];
int save = 0, updated = 0;
Expand All @@ -953,6 +954,12 @@ static dvr_entry_t *_dvr_entry_update
goto dosave;
}

/* Channel */
if (ch && (ch != de->de_channel)) {
de->de_channel = ch;
save = 1;
}

/* Start/Stop */
if (e) {
start = e->start;
Expand Down Expand Up @@ -1073,14 +1080,14 @@ static dvr_entry_t *_dvr_entry_update
*/
dvr_entry_t *
dvr_entry_update
( dvr_entry_t *de,
( dvr_entry_t *de, channel_t *ch,
const char *title, const char *subtitle,
const char *desc, const char *lang,
time_t start, time_t stop,
time_t start_extra, time_t stop_extra,
dvr_prio_t pri, int retention )
{
return _dvr_entry_update(de, NULL, title, subtitle, desc, lang,
return _dvr_entry_update(de, NULL, ch, title, subtitle, desc, lang,
start, stop, start_extra, stop_extra,
pri, retention);
}
Expand Down Expand Up @@ -1129,7 +1136,7 @@ dvr_event_replaced(epg_broadcast_t *e, epg_broadcast_t *new_e)
channel_get_name(e->channel),
e->start, e->stop);
dvr_entry_assign_broadcast(de, e);
_dvr_entry_update(de, e, NULL, NULL, NULL, NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0);
_dvr_entry_update(de, e, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0);
return;
}
}
Expand All @@ -1143,7 +1150,7 @@ void dvr_event_updated ( epg_broadcast_t *e )
dvr_entry_t *de;
de = dvr_entry_find_by_event(e);
if (de)
_dvr_entry_update(de, e, NULL, NULL, NULL, NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0);
_dvr_entry_update(de, e, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0);
else {
LIST_FOREACH(de, &dvrentries, de_global_link) {
if (de->de_sched_state != DVR_SCHEDULED) continue;
Expand All @@ -1158,7 +1165,7 @@ void dvr_event_updated ( epg_broadcast_t *e )
channel_get_name(e->channel),
e->start, e->stop);
dvr_entry_assign_broadcast(de, e);
_dvr_entry_update(de, e, NULL, NULL, NULL, NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0);
_dvr_entry_update(de, e, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0);
break;
}
}
Expand Down
18 changes: 12 additions & 6 deletions src/htsp_server.c
Expand Up @@ -65,7 +65,7 @@

static void *htsp_server, *htsp_server_2;

#define HTSP_PROTO_VERSION 21
#define HTSP_PROTO_VERSION 22

#define HTSP_ASYNC_OFF 0x00
#define HTSP_ASYNC_ON 0x01
Expand Down Expand Up @@ -1581,11 +1581,12 @@ static htsmsg_t *
htsp_method_updateDvrEntry(htsp_connection_t *htsp, htsmsg_t *in)
{
htsmsg_t *out;
uint32_t dvrEntryId;
uint32_t dvrEntryId, u32;
dvr_entry_t *de;
time_t start, stop, start_extra, stop_extra, priority, retention;
const char *title, *subtitle, *desc, *lang;

channel_t *channel = NULL;

if(htsmsg_get_u32(in, "id", &dvrEntryId))
return htsp_error("Missing argument 'id'");

Expand All @@ -1595,9 +1596,14 @@ htsp_method_updateDvrEntry(htsp_connection_t *htsp, htsmsg_t *in)
if(dvr_entry_verify(de, htsp->htsp_granted_access, 1))
return htsp_error("User does not have access");

if(!htsmsg_get_u32(in, "channelId", &u32))
channel = channel_find_by_id(u32);
if (!channel)
channel = de->de_channel;

/* Check access */
if (!htsp_user_access_channel(htsp, de->de_channel))
return htsp_error("User does not have access");
if (!htsp_user_access_channel(htsp, channel))
return htsp_error("User does not have access to channel");

start = htsmsg_get_s64_or_default(in, "start", 0);
stop = htsmsg_get_s64_or_default(in, "stop", 0);
Expand All @@ -1610,7 +1616,7 @@ htsp_method_updateDvrEntry(htsp_connection_t *htsp, htsmsg_t *in)
desc = htsmsg_get_str(in, "description");
lang = htsmsg_get_str(in, "language") ?: htsp->htsp_language;

de = dvr_entry_update(de, title, subtitle, desc, lang, start, stop,
de = dvr_entry_update(de, channel, title, subtitle, desc, lang, start, stop,
start_extra, stop_extra, priority, retention);

//create response
Expand Down

0 comments on commit 568d0ef

Please sign in to comment.