Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
caclient: initial code to move cwc,capmt to idnode
  • Loading branch information
perexg committed Sep 30, 2014
1 parent ecb2d76 commit d307001
Show file tree
Hide file tree
Showing 17 changed files with 1,098 additions and 851 deletions.
4 changes: 3 additions & 1 deletion Makefile
Expand Up @@ -157,7 +157,8 @@ SRCS += \
src/api/api_esfilter.c \
src/api/api_intlconv.c \
src/api/api_access.c \
src/api/api_dvr.c
src/api/api_dvr.c \
src/api/api_caclient.c

SRCS += \
src/parsers/parsers.c \
Expand Down Expand Up @@ -203,6 +204,7 @@ SRCS += src/muxer.c \
# MPEGTS core
SRCS-$(CONFIG_MPEGTS) += \
src/descrambler/descrambler.c \
src/descrambler/caclient.c \
src/input/mpegts.c \
src/input/mpegts/mpegts_input.c \
src/input/mpegts/mpegts_network.c \
Expand Down
1 change: 1 addition & 0 deletions src/api.c
Expand Up @@ -133,6 +133,7 @@ void api_init ( void )
api_intlconv_init();
api_access_init();
api_dvr_init();
api_caclient_init();
}

void api_done ( void )
Expand Down
2 changes: 1 addition & 1 deletion src/api.h
Expand Up @@ -62,7 +62,6 @@ void api_init ( void );
void api_done ( void );
void api_idnode_init ( void );
void api_input_init ( void );
void api_input_satip_init ( void );
void api_service_init ( void );
void api_channel_init ( void );
void api_mpegts_init ( void );
Expand All @@ -74,6 +73,7 @@ void api_esfilter_init ( void );
void api_intlconv_init ( void );
void api_access_init ( void );
void api_dvr_init ( void );
void api_caclient_init ( void );

/*
* IDnode
Expand Down
105 changes: 105 additions & 0 deletions src/api/api_caclient.c
@@ -0,0 +1,105 @@
/*
* tvheadend - API access to Conditional Access Clients
*
* Copyright (C) 2014 Jaroslav Kysela
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "tvheadend.h"
#include "access.h"
#include "htsmsg.h"
#include "api.h"
#include "descrambler/caclient.h"

/*
*
*/
static int
api_caclient_list
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
{
caclient_t *cac;
htsmsg_t *l, *e;

l = htsmsg_create_list();
TAILQ_FOREACH(cac, &caclients, cac_link) {
e = htsmsg_create_map();
htsmsg_add_str(e, "key", idnode_uuid_as_str(&cac->cac_id));
htsmsg_add_str(e, "val", idnode_get_title(&cac->cac_id));
htsmsg_add_msg(l, NULL, e);
}
*resp = htsmsg_create_map();
htsmsg_add_msg(*resp, "entries", l);
return 0;
}

static int
api_caclient_builders
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
{
const idclass_t **r;
htsmsg_t *l, *e;

/* List of available builder classes */
l = htsmsg_create_list();
for (r = caclient_classes; *r; r++)
if ((e = idclass_serialize(*r)))
htsmsg_add_msg(l, NULL, e);

/* Output */
*resp = htsmsg_create_map();
htsmsg_add_msg(*resp, "entries", l);

return 0;
}

static int
api_caclient_create
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
{
int err = 0;
const char *clazz;
htsmsg_t *conf;

if (!(clazz = htsmsg_get_str(args, "class")))
return EINVAL;
if (!(conf = htsmsg_get_map(args, "conf")))
return EINVAL;
htsmsg_set_str(conf, "class", clazz);

pthread_mutex_lock(&global_lock);
if (caclient_create(NULL, conf, 1) == NULL)
err = -EINVAL;
pthread_mutex_unlock(&global_lock);

return err;
}

/*
* Init
*/
void
api_caclient_init ( void )
{
static api_hook_t ah[] = {
{ "caclient/list", ACCESS_ADMIN, api_caclient_list, NULL },
{ "caclient/class", ACCESS_ADMIN, api_idnode_class, (void*)&caclient_class },
{ "caclient/builders", ACCESS_ADMIN, api_caclient_builders, NULL },
{ "caclient/create", ACCESS_ADMIN, api_caclient_create, NULL },
{ NULL },
};

api_register_all(ah);
}

0 comments on commit d307001

Please sign in to comment.