Started to rejig the mux/service creation code.
This commit is contained in:
parent
7e9b78aa24
commit
fe5cb96036
6 changed files with 115 additions and 31 deletions
|
@ -140,6 +140,18 @@ struct mpegts_network
|
|||
*/
|
||||
mpegts_mux_list_t mn_muxes;
|
||||
|
||||
/*
|
||||
* Functions
|
||||
*/
|
||||
mpegts_mux_t* (*mn_create_mux)
|
||||
(mpegts_mux_t*, uint16_t onid, uint16_t tsid, void *aux);
|
||||
mpegts_service_t* (*mn_create_service)
|
||||
(mpegts_mux_t*, uint16_t sid, uint16_t pmt_pid);
|
||||
|
||||
// Note: the above are slightly odd in that they take mux instead of
|
||||
// network as initial param. This is intentional as we need to
|
||||
// know the mux and can easily get to network from there
|
||||
|
||||
#if 0 // TODO: FIXME
|
||||
int dn_fe_type; // Frontend types for this network (FE_QPSK, etc)
|
||||
#endif
|
||||
|
@ -208,6 +220,7 @@ struct mpegts_mux
|
|||
int (*mm_start) ( mpegts_mux_t *mm, const char *reason, int weight );
|
||||
void (*mm_open_table) (mpegts_mux_t*,mpegts_table_t*);
|
||||
void (*mm_close_table) (mpegts_mux_t*,mpegts_table_t*);
|
||||
|
||||
|
||||
#if 0
|
||||
dvb_mux_conf_t dm_conf;
|
||||
|
@ -311,14 +324,6 @@ struct mpegts_service
|
|||
|
||||
};
|
||||
|
||||
/* Create */
|
||||
mpegts_service_t * mpegts_service_create0
|
||||
( size_t alloc, const idclass_t *class, const char *uuid );
|
||||
#define mpegts_service_create(uuid)\
|
||||
mpegts_service_create0(sizeof(mpegts_service_t), &mpegts_service_class, uuid)
|
||||
#define mpegts_service_create1(type, uuid)\
|
||||
(type##_t*)mpegts_service_create0(sizeof(type##_t), &type##_class, uuid)
|
||||
|
||||
/* **************************************************************************
|
||||
* Physical Network
|
||||
* *************************************************************************/
|
||||
|
@ -433,6 +438,14 @@ void mpegts_table_flush_all
|
|||
(mpegts_mux_t *mm);
|
||||
void mpegts_table_destroy ( mpegts_table_t *mt );
|
||||
|
||||
mpegts_service_t *mpegts_service_create0
|
||||
( size_t alloc, const idclass_t *class, const char *uuid,
|
||||
mpegts_mux_t *mm, uint16_t sid, uint16_t pmt_pid );
|
||||
|
||||
/* Create */
|
||||
#define mpegts_service_create(t, u, m, s, p)\
|
||||
(struct t*)mpegts_service_create0(sizeof(struct t), &t##_class, u, m, s, p)
|
||||
|
||||
mpegts_service_t *mpegts_service_find ( mpegts_mux_t *mm, uint16_t sid, uint16_t pmt_pid, const char *uuid, int *save );
|
||||
|
||||
|
||||
|
|
|
@ -204,34 +204,17 @@ mpegts_service_setsourceinfo(service_t *t, source_info_t *si)
|
|||
}
|
||||
|
||||
/*
|
||||
* Find service
|
||||
* Create service
|
||||
*/
|
||||
mpegts_service_t *
|
||||
mpegts_service_find
|
||||
( mpegts_mux_t *mm, uint16_t sid, uint16_t pmt_pid, const char *uuid, int *save )
|
||||
mpegts_service_create0
|
||||
( size_t alloc, const idclass_t *class, const char *uuid,
|
||||
mpegts_mux_t *mm, uint16_t sid, uint16_t pmt_pid )
|
||||
{
|
||||
mpegts_service_t *s;
|
||||
|
||||
/* Validate */
|
||||
lock_assert(&global_lock);
|
||||
|
||||
/* Find existing service */
|
||||
LIST_FOREACH(s, &mm->mm_services, s_dvb_mux_link)
|
||||
if (s->s_dvb_service_id == sid) {
|
||||
if (pmt_pid && pmt_pid != s->s_pmt_pid) {
|
||||
s->s_pmt_pid = pmt_pid;
|
||||
if (save) *save = 1;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/* Ignore */
|
||||
if (!pmt_pid)
|
||||
return NULL;
|
||||
mpegts_service_t *s = (mpegts_service_t*)idnode_create0(alloc, class, uuid);
|
||||
|
||||
/* Create */
|
||||
tvhlog(LOG_DEBUG, "mpegts", "Add service %04X on %s", sid, "TODO");
|
||||
s = service_create(mpegts_service, uuid, S_MPEG_TS);
|
||||
|
||||
sbuf_init(&s->s_tsbuf);
|
||||
|
||||
|
@ -254,6 +237,40 @@ mpegts_service_find
|
|||
pthread_mutex_lock(&s->s_stream_mutex);
|
||||
// TODO: nice name
|
||||
pthread_mutex_unlock(&s->s_stream_mutex);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find service
|
||||
*/
|
||||
mpegts_service_t *
|
||||
mpegts_service_find
|
||||
( mpegts_mux_t *mm, uint16_t sid, uint16_t pmt_pid,
|
||||
const char *uuid, int *save )
|
||||
{
|
||||
mpegts_service_t *s;
|
||||
|
||||
/* Validate */
|
||||
lock_assert(&global_lock);
|
||||
|
||||
/* Find existing service */
|
||||
LIST_FOREACH(s, &mm->mm_services, s_dvb_mux_link)
|
||||
if (s->s_dvb_service_id == sid) {
|
||||
if (pmt_pid && pmt_pid != s->s_pmt_pid) {
|
||||
s->s_pmt_pid = pmt_pid;
|
||||
if (save) *save = 1;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/* Ignore */
|
||||
if (!pmt_pid)
|
||||
return NULL;
|
||||
|
||||
/* Create */
|
||||
s = mm->mm_network->mn_create_service(mm, sid, pmt_pid);
|
||||
if (save) *save = 1;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -17,12 +17,38 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "input.h"
|
||||
#include "tsfile.h"
|
||||
#include "tsfile_private.h"
|
||||
|
||||
extern const idclass_t mpegts_service_class;
|
||||
|
||||
static mpegts_network_t *tsfile_network;
|
||||
LIST_HEAD(,mpegts_input) tsfile_inputs;
|
||||
|
||||
/*
|
||||
* Cannot create muxes
|
||||
*/
|
||||
static mpegts_mux_t *
|
||||
tsfile_network_create_mux
|
||||
( mpegts_mux_t *src, uint16_t onid, uint16_t tsid, void *aux )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Service creation
|
||||
*/
|
||||
static mpegts_service_t *
|
||||
tsfile_network_create_service
|
||||
( mpegts_mux_t *mm, uint16_t sid, uint16_t pmt_pid )
|
||||
{
|
||||
mpegts_service_t *s = mpegts_service_create0(sizeof(mpegts_service_t),
|
||||
&mpegts_service_class,
|
||||
NULL, mm, sid, pmt_pid);
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise
|
||||
*/
|
||||
|
@ -33,6 +59,8 @@ void tsfile_init ( int tuners )
|
|||
|
||||
/* Shared network */
|
||||
tsfile_network = mpegts_network_create0(NULL, "tsfile network");
|
||||
tsfile_network->mn_create_mux = tsfile_network_create_mux;
|
||||
tsfile_network->mn_create_service = tsfile_network_create_service;
|
||||
|
||||
/* Create inputs */
|
||||
for (i = 0; i < tuners; i++) {
|
||||
|
@ -52,7 +80,7 @@ void tsfile_add_file ( const char *path )
|
|||
printf("tsfile_add_file(%s)\n", path);
|
||||
|
||||
/* Create logical instance */
|
||||
mm = mpegts_mux_create0(NULL, tsfile_network, MM_ONID_NONE, MM_TSID_NONE);
|
||||
mm = tsfile_mux_create0(NULL, tsfile_network, MM_ONID_NONE, MM_TSID_NONE);
|
||||
|
||||
/* Create physical instance (for each tuner) */
|
||||
LIST_FOREACH(mi, &tsfile_inputs, mi_global_link)
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
#ifndef __TVH_TSFILE_H__
|
||||
#define __TVH_TSFILE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct mpegts_mux;
|
||||
struct mpegts_network;
|
||||
|
||||
/* Initialise system (with N tuners) */
|
||||
void tsfile_init ( int tuners );
|
||||
|
||||
|
|
|
@ -17,8 +17,12 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "tsfile.h"
|
||||
#include "tsfile_private.h"
|
||||
|
||||
extern const idclass_t mpegts_mux_class;
|
||||
extern const idclass_t mpegts_service_class;
|
||||
|
||||
tsfile_mux_instance_t *
|
||||
tsfile_mux_instance_create
|
||||
( const char *path, mpegts_input_t *mi, mpegts_mux_t *mm )
|
||||
|
@ -31,6 +35,14 @@ tsfile_mux_instance_create
|
|||
return mmi;
|
||||
}
|
||||
|
||||
mpegts_mux_t *
|
||||
tsfile_mux_create0
|
||||
( const char *uuid, mpegts_network_t *mn, uint16_t onid, uint16_t tsid )
|
||||
{
|
||||
mpegts_mux_t *mm = mpegts_mux_create0(NULL, mn, onid, tsid);
|
||||
return mm;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Editor Configuration
|
||||
|
|
|
@ -34,6 +34,11 @@ struct tsfile_mux_instance
|
|||
{
|
||||
mpegts_mux_instance_t; ///< Parent obj
|
||||
|
||||
/*
|
||||
* Timing
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* File input
|
||||
*/
|
||||
|
@ -50,6 +55,10 @@ mpegts_input_t *tsfile_input_create ( void );
|
|||
tsfile_mux_instance_t *tsfile_mux_instance_create
|
||||
( const char *path, mpegts_input_t *mi, mpegts_mux_t *mm );
|
||||
|
||||
struct mpegts_mux *
|
||||
tsfile_mux_create0
|
||||
( const char *uuid, struct mpegts_network *mn, uint16_t onid, uint16_t tsid );
|
||||
|
||||
#endif /* __TVH_TSFILE_PRIVATE_H__ */
|
||||
|
||||
/******************************************************************************
|
||||
|
|
Loading…
Add table
Reference in a new issue