Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
subscription: cleanup for the subscription type selection
  • Loading branch information
perexg committed Mar 13, 2015
1 parent 0eb8587 commit 19e1ae1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/htsp_server.c
Expand Up @@ -2025,6 +2025,7 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in)
htsp->htsp_logname, channel_get_name(ch), pro->pro_name ?: "");
hs->hs_s = subscription_create_from_channel(&hs->hs_prch, NULL, weight,
htsp->htsp_logname,
SUBSCRIPTION_PACKET |
SUBSCRIPTION_STREAMING,
htsp->htsp_peername,
htsp->htsp_username,
Expand Down
8 changes: 6 additions & 2 deletions src/profile.c
Expand Up @@ -735,7 +735,7 @@ profile_chain_raw_open(profile_chain_t *prch, void *id, size_t qsize, int muxer)

memset(prch, 0, sizeof(*prch));
prch->prch_id = id;
prch->prch_flags = SUBSCRIPTION_RAW_MPEGTS;
prch->prch_flags = SUBSCRIPTION_MPEGTS;
streaming_queue_init(&prch->prch_sq, SMT_PACKET, qsize);
prch->prch_sq_used = 1;
prch->prch_st = &prch->prch_sq.sq_st;
Expand Down Expand Up @@ -833,6 +833,7 @@ profile_htsp_work(profile_chain_t *prch,
prsh->prsh_tsfix = tsfix_create(&prsh->prsh_input);

prch->prch_share = prsh->prsh_tsfix;
prch->prch_flags = SUBSCRIPTION_PACKET;
streaming_target_init(&prch->prch_input, profile_input, prch, 0);
prch->prch_st = &prch->prch_input;
return 0;
Expand Down Expand Up @@ -915,7 +916,7 @@ static int
profile_mpegts_pass_open(profile_chain_t *prch,
muxer_config_t *m_cfg, int flags, size_t qsize)
{
prch->prch_flags = SUBSCRIPTION_RAW_MPEGTS;
prch->prch_flags = SUBSCRIPTION_MPEGTS;

prch->prch_sq.sq_st.st_reject_filter = SMT_PACKET;
prch->prch_sq.sq_maxsize = qsize;
Expand Down Expand Up @@ -994,6 +995,7 @@ profile_matroska_open(profile_chain_t *prch,
{
streaming_target_t *dst;

prch->prch_flags = SUBSCRIPTION_PACKET;
prch->prch_sq.sq_maxsize = qsize;

dst = prch->prch_gh = globalheaders_create(&prch->prch_sq.sq_st);
Expand Down Expand Up @@ -1066,6 +1068,7 @@ profile_libav_mpegts_open(profile_chain_t *prch,
{
int r;

prch->prch_flags = SUBSCRIPTION_PACKET;
prch->prch_sq.sq_maxsize = qsize;

r = profile_htsp_work(prch, &prch->prch_sq.sq_st, 0, 0);
Expand Down Expand Up @@ -1146,6 +1149,7 @@ profile_libav_matroska_open(profile_chain_t *prch,
{
int r;

prch->prch_flags = SUBSCRIPTION_PACKET;
prch->prch_sq.sq_maxsize = qsize;

r = profile_htsp_work(prch, &prch->prch_sq.sq_st, 0, 0);
Expand Down
4 changes: 3 additions & 1 deletion src/service_mapper.c
Expand Up @@ -375,7 +375,9 @@ service_mapper_thread ( void *aux )
/* Subscribe */
tvhinfo("service_mapper", "checking %s", s->s_nicename);
prch.prch_id = s;
sub = subscription_create_from_service(&prch, NULL, SUBSCRIPTION_PRIO_MAPPER,
sub = subscription_create_from_service(&prch, NULL,
SUBSCRIPTION_PACKET |
SUBSCRIPTION_PRIO_MAPPER,
"service_mapper",
0, NULL, NULL, "service_mapper",
NULL);
Expand Down
15 changes: 11 additions & 4 deletions src/subscriptions.c
Expand Up @@ -584,12 +584,19 @@ subscription_create

TAILQ_INIT(&s->ths_instances);

if(flags & SUBSCRIPTION_NONE)
reject |= (SMT_TO_MASK(SMT_PACKET) | SMT_TO_MASK(SMT_MPEGTS));
else if(flags & SUBSCRIPTION_RAW_MPEGTS)
assert(flags & (SUBSCRIPTION_NONE|SUBSCRIPTION_MPEGTS|SUBSCRIPTION_PACKET));

switch (flags & SUBSCRIPTION_TYPE_MASK) {
default:
reject |= SMT_TO_MASK(SMT_PACKET) | SMT_TO_MASK(SMT_MPEGTS);
break;
case SUBSCRIPTION_MPEGTS:
reject |= SMT_TO_MASK(SMT_PACKET); // Reject parsed frames
else
break;
case SUBSCRIPTION_PACKET:
reject |= SMT_TO_MASK(SMT_MPEGTS); // Reject raw mpegts
break;
}

if (!cb) cb = subscription_input_direct;
if (!st) {
Expand Down
22 changes: 12 additions & 10 deletions src/subscriptions.h
Expand Up @@ -25,16 +25,18 @@ struct profile_chain;

extern struct th_subscription_list subscriptions;

#define SUBSCRIPTION_RAW_MPEGTS 0x001
#define SUBSCRIPTION_NONE 0x002
#define SUBSCRIPTION_STREAMING 0x004
#define SUBSCRIPTION_RESTART 0x008
#define SUBSCRIPTION_ONESHOT 0x010
#define SUBSCRIPTION_TABLES 0x020
#define SUBSCRIPTION_INITSCAN 0x040 ///< for mux subscriptions
#define SUBSCRIPTION_IDLESCAN 0x080 ///< for mux subscriptions
#define SUBSCRIPTION_USERSCAN 0x100 ///< for mux subscriptions
#define SUBSCRIPTION_EPG 0x200 ///< for mux subscriptions
#define SUBSCRIPTION_NONE 0x000
#define SUBSCRIPTION_MPEGTS 0x001
#define SUBSCRIPTION_PACKET 0x002
#define SUBSCRIPTION_TYPE_MASK 0x00f
#define SUBSCRIPTION_STREAMING 0x010
#define SUBSCRIPTION_RESTART 0x020
#define SUBSCRIPTION_ONESHOT 0x040
#define SUBSCRIPTION_TABLES 0x080
#define SUBSCRIPTION_INITSCAN 0x100 ///< for mux subscriptions
#define SUBSCRIPTION_IDLESCAN 0x200 ///< for mux subscriptions
#define SUBSCRIPTION_USERSCAN 0x400 ///< for mux subscriptions
#define SUBSCRIPTION_EPG 0x800 ///< for mux subscriptions

/* Some internal priorities */
#define SUBSCRIPTION_PRIO_KEEP 1 ///< Keep input rolling
Expand Down

0 comments on commit 19e1ae1

Please sign in to comment.