Project

General

Profile

Feature #2596 » patch_3.4.diff

Patch based on tvheadend 3.4 - M H, 2015-01-05 23:06

View differences:

src/config2.c
87 87
{
88 88
  return _config_set_str("muxconfpath", path);
89 89
}
90

91
const char *config_get_subscript_pre_command ( void )
92
{
93
  return htsmsg_get_str(config, "subpreproccommand");
94
}
95

96
int config_set_subscript_pre_command ( const char *str )
97
{
98
  return _config_set_str("subpreproccommand", str);
99
}
100

101
const char *config_get_subscript_post_command ( void )
102
{
103
  return htsmsg_get_str(config, "subpostproccommand");
104
}
105

106
int config_set_subscript_post_command ( const char *str )
107
{
108
  return _config_set_str("subpostproccommand", str);
109
}
src/config2.h
36 36
int         config_set_language    ( const char *str )
37 37
  __attribute__((warn_unused_result));
38 38

39
const char *config_get_subscript_pre_command  ( void );
40
int         config_set_subscript_pre_command  ( const char *str )
41
  __attribute__((warn_unused_result));
42

43
const char *config_get_subscript_post_command  ( void );
44
int         config_set_subscript_post_command  ( const char *str )
45
  __attribute__((warn_unused_result));
46

39 47
#endif /* __TVH_CONFIG__H__ */
src/subscriptions.c
1 1
/*
2 2
 *  tvheadend, transport and subscription functions
3
 *  Copyright (C) 2007 Andreas ?man
3
 *  Copyright (C) 2007 Andreas man
4 4
 *
5 5
 *  This program is free software: you can redistribute it and/or modify
6 6
 *  it under the terms of the GNU General Public License as published by
......
41 41
#include "atomic.h"
42 42
#include "dvb/dvb.h"
43 43

44
#include "config2.h"
45

46
#include "htsstr.h"
47
#include "spawn.h"
48

44 49
struct th_subscription_list subscriptions;
45 50
static gtimer_t subscription_reschedule_timer;
46 51

......
106 111
    streaming_target_deliver(s->ths_output, sm);
107 112
  }
108 113

114
  // process pre-command
115
  do_pre_command(s);
116

109 117
  pthread_mutex_unlock(&t->s_stream_mutex);
110 118
}
111 119

......
116 124
void
117 125
subscription_unlink_service(th_subscription_t *s, int reason)
118 126
{
127
  tvhlog(LOG_INFO, "subscription_unlink_service", "subscription_unlink_service");
128

119 129
  streaming_message_t *sm;
120 130
  service_t *t = s->ths_service;
121 131

......
134 144
  pthread_mutex_unlock(&t->s_stream_mutex);
135 145

136 146
  LIST_REMOVE(s, ths_service_link);
147

148
  do_post_command(s);
149

137 150
  s->ths_service = NULL;
138 151
}
139 152

153
/*
154
 * Process pre-command before linking subscription
155
 */
156
void do_pre_command(th_subscription_t *s) {
157
	if (subscriptions_active() && config_get_subscript_pre_command()) {
158
		char **args = htsstr_argsplit(config_get_subscript_pre_command());
159
		spawnv(args[0], (void *) args);
160
	}
161
}
162

163
/*
164
 * Process post-command after unlinking subscription
165
 */
166
void do_post_command(th_subscription_t *s) {
167
	tvhlog(LOG_INFO, "do_post_command", "do_post_command");
168
	if (!subscriptions_active() && config_get_subscript_post_command()) {
169
		char **args = htsstr_argsplit(config_get_subscript_post_command());
170
		spawnv(args[0], (void *) args);
171
	}
172
}
140 173

141 174
/**
142 175
 *
......
203 236
void 
204 237
subscription_unsubscribe(th_subscription_t *s)
205 238
{
239
  tvhlog(LOG_INFO, "subscription_unsubscribe", "subscription_unsubscribe");
240

206 241
  service_t *t = s->ths_service;
207 242

208 243
  lock_assert(&global_lock);
src/subscriptions.h
1 1
/*
2 2
 *  tvheadend, subscription functions
3
 *  Copyright (C) 2007 Andreas ?man
3
 *  Copyright (C) 2007 Andreas man
4 4
 *
5 5
 *  This program is free software: you can redistribute it and/or modify
6 6
 *  it under the terms of the GNU General Public License as published by
......
125 125

126 126
int subscriptions_active(void);
127 127

128
void do_pre_command(th_subscription_t *s);
129

130
void do_post_command(th_subscription_t *s);
131

128 132
struct htsmsg;
129 133
struct htsmsg *subscription_create_msg(th_subscription_t *s);
130 134

src/webui/extjs.c
2006 2006
      save |= config_set_muxconfpath(str);
2007 2007
    if ((str = http_arg_get(&hc->hc_req_args, "language")))
2008 2008
      save |= config_set_language(str);
2009
    if ((str = http_arg_get(&hc->hc_req_args, "subpreproccommand")))
2010
      save |= config_set_subscript_pre_command(str);
2011
    if ((str = http_arg_get(&hc->hc_req_args, "subpostproccommand")))
2012
      save |= config_set_subscript_post_command(str);
2013
    if (save)
2014

2009 2015
    if (save)
2010 2016
      config_save();
2011 2017

src/webui/static/app/config.js
41 41
       'imagecache_enabled', 'imagecache_ok_period',
42 42
       'imagecache_fail_period', 'imagecache_ignore_sslcert',
43 43
       'tvhtime_update_enabled', 'tvhtime_ntp_enabled',
44
       'tvhtime_tolerance']);
44
       'tvhtime_tolerance',
45
        'subpreproccommand',
46
        'subpostproccommand'
47
       ]);
45 48

46 49
	/* ****************************************************************
47 50
	 * Form Fields
......
134 137
    items : [ imagecacheEnabled, imagecacheOkPeriod, imagecacheFailPeriod,
135 138
              imagecacheIgnoreSSLCert ]
136 139
  });
140
  
137 141
  if (tvheadend.capabilities.indexOf('imagecache') == -1)
138 142
    imagecachePanel.hide();
143
      
144
  var preProcCommand = new Ext.form.TextField({
145
    name: 'subpreproccommand',
146
    fieldLabel: 'Command to process before new subscription starts<br/>(e.g. /home/user/preprocess.sh)',
147
    width: 400
148
  });
139 149

140
	/* ****************************************************************
150
  var postProcCommand = new Ext.form.TextField({
151
    name: 'subpostproccommand',
152
    fieldLabel: 'Command to process after last subscription ends<br/>(e.g. /home/user/postprocess.sh)',
153
    width: 400
154
  });
155

156
  var subProcessPanel = new Ext.form.FieldSet({
157
    title: 'Extra processing for subscriptions',
158
    width: 700,
159
    autoHeight: true,
160
    collapsible: true,
161
    animCollapse: true,
162
    items: [preProcCommand, postProcCommand]
163
  });
164

165
  var subProcessPanel_form = new Ext.form.FormPanel({
166
    border: false,
167
    labelAlign: 'left',
168
    labelWidth: 200,
169
    waitMsgTarget: true,
170
    layout: 'form',
171
    defaultType: 'textfield',
172
    autoHeight: true,
173
    items: [subProcessPanel]
174
  });
175
  
176
 	/* ****************************************************************
141 177
	 * Form
142 178
	 * ***************************************************************/
143 179

......
167 203
		layout : 'form',
168 204
		defaultType : 'textfield',
169 205
		autoHeight : true,
170
		items : [ language, dvbscanPath,
206
		items : [ language, dvbscanPath, subProcessPanel, 
171 207
              imagecachePanel, tvhtimePanel ],
172 208
		tbar : [ saveButton, '->', helpButton ]
173 209
	});
(1-1/4)