/**
*
*/
-
typedef struct service service_t;
typedef struct streaming_start streaming_start_t;
+typedef enum streaming_component_type streaming_component_type_t;
typedef struct elementary_stream elementary_stream_t;
typedef struct elementary_set elementary_set_t;
+/**
+ * Stream component types
+ */
+enum streaming_component_type {
+ SCT_NONE = -1,
+ SCT_UNKNOWN = 0,
+ SCT_RAW = 1,
+ SCT_PCR, /* MPEG-TS PCR data */
+ SCT_CAT, /* MPEG-TS CAT (EMM) data */
+ SCT_CA, /* MPEG-TS ECM data */
+ SCT_HBBTV, /* HBBTV info */
+ /* standard codecs */
+ SCT_MPEG2VIDEO,
+ SCT_MPEG2AUDIO,
+ SCT_H264,
+ SCT_AC3,
+ SCT_TELETEXT,
+ SCT_DVBSUB,
+ SCT_AAC, /* AAC-LATM in MPEG-TS, ADTS + AAC in packet form */
+ SCT_MPEGTS,
+ SCT_TEXTSUB,
+ SCT_EAC3,
+ SCT_MP4A, /* ADTS + AAC in MPEG-TS and packet form */
+ SCT_VP8,
+ SCT_VORBIS,
+ SCT_HEVC,
+ SCT_VP9,
+ SCT_THEORA,
+ SCT_OPUS,
+ SCT_FLAC,
+ SCT_LAST = SCT_FLAC
+};
+
+#define SCT_MASK(t) (1 << (t))
+
+#define SCT_ISVIDEO(t) ((t) == SCT_MPEG2VIDEO || (t) == SCT_H264 || \
+ (t) == SCT_VP8 || (t) == SCT_HEVC || \
+ (t) == SCT_VP9 || (t) == SCT_THEORA)
+
+#define SCT_ISAUDIO(t) ((t) == SCT_MPEG2AUDIO || (t) == SCT_AC3 || \
+ (t) == SCT_AAC || (t) == SCT_MP4A || \
+ (t) == SCT_EAC3 || (t) == SCT_VORBIS || \
+ (t) == SCT_OPUS || (t) == SCT_FLAC)
+
+#define SCT_ISAV(t) (SCT_ISVIDEO(t) || SCT_ISAUDIO(t))
+
+#define SCT_ISSUBTITLE(t) ((t) == SCT_TEXTSUB || (t) == SCT_DVBSUB)
+
/**
* Stream, one media component for a service.
*/
#include "idnode.h"
#include "queue.h"
+#include "streaming.h"
struct htsmsg;
#endif
#include "atomic.h"
+#include "sbuf.h"
#include "input.h"
#include "service.h"
#include "mpegts/dvb.h"
#include <libavformat/avformat.h>
#include <libavfilter/avfilter.h>
-#include "tvheadend.h"
+#include "esstream.h"
/*
Older versions of ffmpeg/libav don't have the AV_* prefix
#ifndef MUXER_H_
#define MUXER_H_
+#include "streaming.h"
#include "htsmsg.h"
#define MC_IS_EOS_ERROR(e) ((e) == EPIPE || (e) == ECONNRESET)
#include "tvheadend.h"
+#include "streaming.h"
#include "packet.h"
#include "string.h"
#include "atomic.h"
#ifndef PACKET_H_
#define PACKET_H_
+#include "esstream.h"
+
struct memoryinfo;
/**
#define PARSERS_H
#include "tvheadend.h"
+#include "sbuf.h"
#include "streaming.h"
#include "subscriptions.h"
#include "packet.h"
uint8_t prs_current_pcr_guess;
/* Teletext */
- th_commercial_advice_t prs_tt_commercial_advice;
+ commercial_advice_t prs_tt_commercial_advice;
time_t prs_tt_clock; /* Network clock as determined by teletext decoder */
};
uint8_t *l;
mpegts_service_t *t;
time_t now = prs->prs_tt_clock, start, stop;
- th_commercial_advice_t ca;
+ commercial_advice_t ca;
if(ttp->ttp_rundown_valid == 0)
return;
#define SERVICE_H__
#include "esstream.h"
-#include "sbuf.h"
+#include "streaming.h"
#include "htsmsg.h"
#include "idnode.h"
-#include "profile.h"
+/**
+ *
+ */
extern const idclass_t service_class;
extern const idclass_t service_raw_class;
extern struct service_queue service_raw_all;
extern struct service_queue service_raw_remove;
+/**
+ *
+ */
struct channel;
struct tvh_input;
struct mpegts_apids;
+struct profile_chain;
+struct source_info;
+struct descramble_info;
/**
- * Source information
+ *
*/
-typedef struct source_info {
- tvh_uuid_t si_adapter_uuid;
- tvh_uuid_t si_network_uuid;
- tvh_uuid_t si_mux_uuid;
- char *si_adapter;
- char *si_network;
- char *si_network_type;
- char *si_satpos;
- char *si_mux;
- char *si_provider;
- char *si_service;
- int si_type;
-} source_info_t;
-
typedef TAILQ_HEAD(service_instance_list, service_instance) service_instance_list_t;
/**
typedef struct service_instance {
TAILQ_ENTRY(service_instance) si_link;
-
- int si_prio;
-
- struct service *si_s; // A reference is held
- int si_instance; // Discriminator when having multiple adapters, etc
-
- int si_error; /* Set if subscription layer deem this cand
- to be broken. We typically set this if we
- have not seen any demuxed packets after
- the grace period has expired.
- The actual value is current time
- */
-
+ struct service *si_s; /* A reference is held */
+
+ int si_prio; /* Priority (higher value has more weight) */
+ int si_instance; /* Discriminator when having multiple adapters, etc */
+ int si_error; /* Set if subscription layer deem this cand
+ * to be broken. We typically set this if we
+ * have not seen any demuxed packets after
+ * the grace period has expired.
+ * The actual value is current time
+ */
time_t si_error_time;
-
-
- int si_weight; // Highest weight that holds this cand
-
- int si_mark; // For mark & sweep
+ int si_weight; /* Highest weight that holds this cand */
+ int si_mark; /* For mark & sweep */
char si_source[128];
/**
* Teletext...
*/
- th_commercial_advice_t s_tt_commercial_advice;
+ commercial_advice_t s_tt_commercial_advice;
time_t s_tt_clock; /* Network clock as determined by teletext decoder */
/**
uint8_t s_scrambled_pass;
th_descrambler_runtime_t *s_descramble;
void *s_descrambler; /* last active descrambler */
- descramble_info_t *s_descramble_info;
+ struct descramble_info *s_descramble_info;
/**
* Set of all and filtered components.
service_instance_t *service_find_instance(struct service *s,
struct channel *ch,
struct tvh_input *source,
- profile_chain_t *prch,
+ struct profile_chain *prch,
service_instance_list_t *sil,
int *error, int weight,
int flags, int timeout,
return N_("Reserved");
}
+static struct strtab signal_statetab[] = {
+ { "GOOD", SIGNAL_GOOD },
+ { "BAD", SIGNAL_BAD },
+ { "FAINT", SIGNAL_FAINT },
+ { "NONE", SIGNAL_NONE },
+};
+
+const char *signal2str(signal_state_t st)
+{
+ const char *r = val2str(st, signal_statetab);
+ if (!r) r = "UNKNOWN";
+ return r;
+}
+
/*
*
*/
#include "packet.h"
#include "htsmsg.h"
-#include "service.h"
+/**
+ *
+ */
+struct service;
+
+/**
+ *
+ */
+typedef enum commercial_advice commercial_advice_t;
+typedef enum signal_status_scale signal_status_scale_t;
+typedef struct signal_status signal_status_t;
+typedef struct descramble_info descramble_info_t;
+typedef struct timeshift_status timeshift_status_t;
+typedef struct streaming_skip streaming_skip_t;
+typedef struct streaming_pad streaming_pad_t;
+typedef enum streaming_message_type streaming_message_type_t;
+typedef enum signal_state signal_state_t;
+typedef struct streaming_message streaming_message_t;
+typedef struct streaming_ops streaming_ops_t;
+typedef struct streaming_queue streaming_queue_t;
+typedef struct source_info source_info_t;
+typedef struct streaming_start_component streaming_start_component_t;
+typedef struct streaming_start streaming_start_t;
+
+/**
+ *
+ */
+LIST_HEAD(streaming_target_list, streaming_target);
+TAILQ_HEAD(streaming_message_queue, streaming_message);
+
+/*
+ * Commercial status
+ */
+enum commercial_advice {
+ COMMERCIAL_UNKNOWN,
+ COMMERCIAL_YES,
+ COMMERCIAL_NO,
+};
+
+/*
+ * Scales for signal status values
+ */
+enum signal_status_scale {
+ SIGNAL_STATUS_SCALE_UNKNOWN = 0,
+ SIGNAL_STATUS_SCALE_RELATIVE, // value is unsigned, where 0 means 0% and 65535 means 100%
+ SIGNAL_STATUS_SCALE_DECIBEL // value is measured in dB * 1000
+};
+
+/**
+ * The signal status of a tuner
+ */
+struct signal_status {
+ const char *status_text; /* adapter status text */
+ int snr; /* signal/noise ratio */
+ signal_status_scale_t snr_scale;
+ int signal; /* signal strength */
+ signal_status_scale_t signal_scale;
+ int ber; /* bit error rate */
+ int unc; /* uncorrected blocks */
+ int ec_bit; /* error bit count */
+ int tc_bit; /* total bit count */
+ int ec_block; /* error block count */
+ int tc_block; /* total block count */
+};
+
+/**
+ * Descramble info
+ */
+struct descramble_info {
+ uint16_t pid;
+ uint16_t caid;
+ uint32_t provid;
+ uint32_t ecmtime;
+ uint16_t hops;
+ char cardsystem[128];
+ char reader [128];
+ char from [128];
+ char protocol [128];
+};
+
+/**
+ *
+ */
+struct timeshift_status
+{
+ int full;
+ int64_t shift;
+ int64_t pts_start;
+ int64_t pts_end;
+};
+
+/**
+ * Streaming skip
+ */
+struct streaming_skip
+{
+ enum {
+ SMT_SKIP_ERROR,
+ SMT_SKIP_REL_TIME,
+ SMT_SKIP_ABS_TIME,
+ SMT_SKIP_REL_SIZE,
+ SMT_SKIP_ABS_SIZE,
+ SMT_SKIP_LIVE
+ } type;
+ union {
+ off_t size;
+ int64_t time;
+ };
+#if ENABLE_TIMESHIFT
+ timeshift_status_t timeshift;
+#endif
+};
+
+
+/**
+ * A streaming pad generates data.
+ * It has one or more streaming targets attached to it.
+ *
+ * We support two different streaming target types:
+ * One is callback driven and the other uses a queue + thread.
+ *
+ * Targets which already has a queueing intrastructure in place (such
+ * as HTSP) does not need any interim queues so it would be a waste. That
+ * is why we have the callback target.
+ *
+ */
+struct streaming_pad {
+ struct streaming_target_list sp_targets;
+ int sp_ntargets;
+ int sp_reject_filter;
+};
+
+/**
+ * Streaming messages types
+ */
+enum streaming_message_type {
+
+ /**
+ * Packet with data.
+ *
+ * sm_data points to a th_pkt. th_pkt will be unref'ed when
+ * the message is destroyed
+ */
+ SMT_PACKET,
+
+ /**
+ * Stream grace period
+ *
+ * sm_code contains number of seconds to settle things down
+ */
+
+ SMT_GRACE,
+
+ /**
+ * Stream start
+ *
+ * sm_data points to a stream_start struct.
+ * See transport_build_stream_start()
+ */
+
+ SMT_START,
+
+ /**
+ * Service status
+ *
+ * Notification about status of source, see TSS_ flags
+ */
+ SMT_SERVICE_STATUS,
+
+ /**
+ * Signal status
+ *
+ * Notification about frontend signal status
+ */
+ SMT_SIGNAL_STATUS,
+
+ /**
+ * Descrambler info message
+ *
+ * Notification about descrambler
+ */
+ SMT_DESCRAMBLE_INFO,
+
+ /**
+ * Streaming stop.
+ *
+ * End of streaming. If sm_code is 0 this was a result to an
+ * unsubscription. Otherwise the reason was external and the
+ * subscription scheduler will attempt to start a new streaming
+ * session.
+ */
+ SMT_STOP,
+
+ /**
+ * Streaming unable to start.
+ *
+ * sm_code indicates reason. Scheduler will try to restart
+ */
+ SMT_NOSTART,
+
+ /**
+ * Streaming unable to start (non-fatal).
+ *
+ * sm_code indicates reason. Scheduler will try to restart
+ */
+ SMT_NOSTART_WARN,
+
+ /**
+ * Raw MPEG TS data
+ */
+ SMT_MPEGTS,
+
+ /**
+ * Internal message to exit receiver
+ */
+ SMT_EXIT,
+
+ /**
+ * Set stream speed
+ */
+ SMT_SPEED,
+
+ /**
+ * Skip the stream
+ */
+ SMT_SKIP,
+
+ /**
+ * Timeshift status
+ */
+ SMT_TIMESHIFT_STATUS,
+
+};
+
+#define SMT_TO_MASK(x) (1 << ((unsigned int)x))
+
+/**
+ * Streaming codes
+ */
+#define SM_CODE_OK 0
+
+#define SM_CODE_UNDEFINED_ERROR 1
+
+#define SM_CODE_FORCE_OK 10
+
+#define SM_CODE_SOURCE_RECONFIGURED 100
+#define SM_CODE_BAD_SOURCE 101
+#define SM_CODE_SOURCE_DELETED 102
+#define SM_CODE_SUBSCRIPTION_OVERRIDDEN 103
+#define SM_CODE_INVALID_TARGET 104
+#define SM_CODE_USER_ACCESS 105
+#define SM_CODE_USER_LIMIT 106
+#define SM_CODE_WEAK_STREAM 107
+#define SM_CODE_USER_REQUEST 108
+#define SM_CODE_PREVIOUSLY_RECORDED 109
+
+#define SM_CODE_NO_FREE_ADAPTER 200
+#define SM_CODE_MUX_NOT_ENABLED 201
+#define SM_CODE_NOT_FREE 202
+#define SM_CODE_TUNING_FAILED 203
+#define SM_CODE_SVC_NOT_ENABLED 204
+#define SM_CODE_BAD_SIGNAL 205
+#define SM_CODE_NO_SOURCE 206
+#define SM_CODE_NO_SERVICE 207
+#define SM_CODE_NO_VALID_ADAPTER 208
+#define SM_CODE_NO_ADAPTERS 209
+#define SM_CODE_INVALID_SERVICE 210
+#define SM_CODE_CHN_NOT_ENABLED 211
+
+#define SM_CODE_ABORTED 300
+
+#define SM_CODE_NO_DESCRAMBLER 400
+#define SM_CODE_NO_ACCESS 401
+#define SM_CODE_NO_INPUT 402
+#define SM_CODE_NO_SPACE 403
+
+/**
+ * Signal
+ */
+enum signal_state
+{
+ SIGNAL_UNKNOWN,
+ SIGNAL_GOOD,
+ SIGNAL_BAD,
+ SIGNAL_FAINT,
+ SIGNAL_NONE
+};
+
+const char * signal2str ( signal_state_t st );
+
+/**
+ * Streaming messages are sent from the pad to its receivers
+ */
+struct streaming_message {
+ TAILQ_ENTRY(streaming_message) sm_link;
+ streaming_message_type_t sm_type;
+#if ENABLE_TIMESHIFT
+ int64_t sm_time;
+#endif
+ union {
+ void *sm_data;
+ int sm_code;
+ };
+};
+
+/**
+ * A streaming target receives data.
+ */
+typedef void (st_callback_t)(void *opaque, streaming_message_t *sm);
+
+struct streaming_ops {
+ st_callback_t *st_cb;
+ htsmsg_t *(*st_info)(void *opaque, htsmsg_t *list);
+};
-typedef struct streaming_start_component {
+typedef struct streaming_target {
+ LIST_ENTRY(streaming_target) st_link;
+ streaming_pad_t *st_pad; /* Source we are linked to */
+ streaming_ops_t st_ops;
+ void *st_opaque;
+ int st_reject_filter;
+} streaming_target_t;
+
+/**
+ *
+ */
+struct streaming_queue {
+
+ streaming_target_t sq_st;
+
+ pthread_mutex_t sq_mutex; /* Protects sp_queue */
+ tvh_cond_t sq_cond; /* Condvar for signalling new packets */
+
+ size_t sq_maxsize; /* Max queue size (bytes) */
+ size_t sq_size; /* Actual queue size (bytes) - only data */
+
+ struct streaming_message_queue sq_queue;
+
+};
+
+streaming_component_type_t streaming_component_txt2type(const char *str);
+const char *streaming_component_type2txt(streaming_component_type_t s);
+streaming_component_type_t streaming_component_txt2type(const char *s);
+const char *streaming_component_audio_type2desc(int audio_type);
+
+/**
+ * Source information
+ */
+struct source_info {
+ tvh_uuid_t si_adapter_uuid;
+ tvh_uuid_t si_network_uuid;
+ tvh_uuid_t si_mux_uuid;
+ char *si_adapter;
+ char *si_network;
+ char *si_network_type;
+ char *si_satpos;
+ char *si_mux;
+ char *si_provider;
+ char *si_service;
+ int si_type;
+};
+
+/**
+ *
+ */
+struct streaming_start_component {
int ssc_index;
int ssc_type;
char ssc_lang[4];
int ssc_frameduration;
-} streaming_start_component_t;
+};
-
-typedef struct streaming_start {
+struct streaming_start {
int ss_refcount;
int ss_num_components;
streaming_start_component_t ss_components[0];
-} streaming_start_t;
-
+};
/**
*
void streaming_pad_deliver(streaming_pad_t *sp, streaming_message_t *sm);
-void streaming_service_deliver(service_t *t, streaming_message_t *sm);
+void streaming_service_deliver(struct service *t, streaming_message_t *sm);
void streaming_msg_free(streaming_message_t *sm);
#define __TVH_TIMESHIFT_H__
#include "idnode.h"
+#include "streaming.h"
#include "memoryinfo.h"
typedef struct timeshift_conf {
#include "tvheadend.h"
+#include "streaming.h"
/* TVHTranscoder ============================================================ */
#include "internals.h"
#include "../codec/internals.h"
+#include "service.h"
static TVHCodecProfile _codec_profile_copy = { .name = (char *)"copy" };
} tvh_cond_t;
-/*
- * Commercial status
- */
-typedef enum {
- COMMERCIAL_UNKNOWN,
- COMMERCIAL_YES,
- COMMERCIAL_NO,
-} th_commercial_advice_t;
-
-
/*
*
*/
LIST_HEAD(dvr_autorec_entry_list, dvr_autorec_entry);
LIST_HEAD(dvr_timerec_entry_list, dvr_timerec_entry);
TAILQ_HEAD(th_pktref_queue, th_pktref);
-LIST_HEAD(streaming_target_list, streaming_target);
/**
*
int tvh_kill_to_sig(int tvh_kill);
-/**
- * Stream component types
- */
-typedef enum {
- SCT_NONE = -1,
- SCT_UNKNOWN = 0,
- SCT_RAW = 1,
- SCT_PCR, /* MPEG-TS PCR data */
- SCT_CAT, /* MPEG-TS CAT (EMM) data */
- SCT_CA, /* MPEG-TS ECM data */
- SCT_HBBTV, /* HBBTV info */
- /* standard codecs */
- SCT_MPEG2VIDEO,
- SCT_MPEG2AUDIO,
- SCT_H264,
- SCT_AC3,
- SCT_TELETEXT,
- SCT_DVBSUB,
- SCT_AAC, /* AAC-LATM in MPEG-TS, ADTS + AAC in packet form */
- SCT_MPEGTS,
- SCT_TEXTSUB,
- SCT_EAC3,
- SCT_MP4A, /* ADTS + AAC in MPEG-TS and packet form */
- SCT_VP8,
- SCT_VORBIS,
- SCT_HEVC,
- SCT_VP9,
- SCT_THEORA,
- SCT_OPUS,
- SCT_FLAC,
- SCT_LAST = SCT_FLAC
-} streaming_component_type_t;
-
-#define SCT_MASK(t) (1 << (t))
-
-#define SCT_ISVIDEO(t) ((t) == SCT_MPEG2VIDEO || (t) == SCT_H264 || \
- (t) == SCT_VP8 || (t) == SCT_HEVC || \
- (t) == SCT_VP9 || (t) == SCT_THEORA)
-
-#define SCT_ISAUDIO(t) ((t) == SCT_MPEG2AUDIO || (t) == SCT_AC3 || \
- (t) == SCT_AAC || (t) == SCT_MP4A || \
- (t) == SCT_EAC3 || (t) == SCT_VORBIS || \
- (t) == SCT_OPUS || (t) == SCT_FLAC)
-
-#define SCT_ISAV(t) (SCT_ISVIDEO(t) || SCT_ISAUDIO(t))
-
-#define SCT_ISSUBTITLE(t) ((t) == SCT_TEXTSUB || (t) == SCT_DVBSUB)
-
-/*
- * Scales for signal status values
- */
-typedef enum {
- SIGNAL_STATUS_SCALE_UNKNOWN = 0,
- SIGNAL_STATUS_SCALE_RELATIVE, // value is unsigned, where 0 means 0% and 65535 means 100%
- SIGNAL_STATUS_SCALE_DECIBEL // value is measured in dB * 1000
-} signal_status_scale_t;
-
-/**
- * The signal status of a tuner
- */
-typedef struct signal_status {
- const char *status_text; /* adapter status text */
- int snr; /* signal/noise ratio */
- signal_status_scale_t snr_scale;
- int signal; /* signal strength */
- signal_status_scale_t signal_scale;
- int ber; /* bit error rate */
- int unc; /* uncorrected blocks */
- int ec_bit; /* error bit count */
- int tc_bit; /* total bit count */
- int ec_block; /* error block count */
- int tc_block; /* total block count */
-} signal_status_t;
-
-/**
- * Descramble info
- */
-typedef struct descramble_info {
- uint16_t pid;
- uint16_t caid;
- uint32_t provid;
- uint32_t ecmtime;
- uint16_t hops;
- char cardsystem[128];
- char reader [128];
- char from [128];
- char protocol [128];
-} descramble_info_t;
-
-/**
- *
- */
-typedef struct timeshift_status
-{
- int full;
- int64_t shift;
- int64_t pts_start;
- int64_t pts_end;
-} timeshift_status_t;
-
-/**
- * Streaming skip
- */
-typedef struct streaming_skip
-{
- enum {
- SMT_SKIP_ERROR,
- SMT_SKIP_REL_TIME,
- SMT_SKIP_ABS_TIME,
- SMT_SKIP_REL_SIZE,
- SMT_SKIP_ABS_SIZE,
- SMT_SKIP_LIVE
- } type;
- union {
- off_t size;
- int64_t time;
- };
-#if ENABLE_TIMESHIFT
- timeshift_status_t timeshift;
-#endif
-} streaming_skip_t;
-
-
-/**
- * A streaming pad generates data.
- * It has one or more streaming targets attached to it.
- *
- * We support two different streaming target types:
- * One is callback driven and the other uses a queue + thread.
- *
- * Targets which already has a queueing intrastructure in place (such
- * as HTSP) does not need any interim queues so it would be a waste. That
- * is why we have the callback target.
- *
- */
-typedef struct streaming_pad {
- struct streaming_target_list sp_targets;
- int sp_ntargets;
- int sp_reject_filter;
-} streaming_pad_t;
-
-
-TAILQ_HEAD(streaming_message_queue, streaming_message);
-
-/**
- * Streaming messages types
- */
-typedef enum {
-
- /**
- * Packet with data.
- *
- * sm_data points to a th_pkt. th_pkt will be unref'ed when
- * the message is destroyed
- */
- SMT_PACKET,
-
- /**
- * Stream grace period
- *
- * sm_code contains number of seconds to settle things down
- */
-
- SMT_GRACE,
-
- /**
- * Stream start
- *
- * sm_data points to a stream_start struct.
- * See transport_build_stream_start()
- */
-
- SMT_START,
-
- /**
- * Service status
- *
- * Notification about status of source, see TSS_ flags
- */
- SMT_SERVICE_STATUS,
-
- /**
- * Signal status
- *
- * Notification about frontend signal status
- */
- SMT_SIGNAL_STATUS,
-
- /**
- * Descrambler info message
- *
- * Notification about descrambler
- */
- SMT_DESCRAMBLE_INFO,
-
- /**
- * Streaming stop.
- *
- * End of streaming. If sm_code is 0 this was a result to an
- * unsubscription. Otherwise the reason was external and the
- * subscription scheduler will attempt to start a new streaming
- * session.
- */
- SMT_STOP,
-
- /**
- * Streaming unable to start.
- *
- * sm_code indicates reason. Scheduler will try to restart
- */
- SMT_NOSTART,
-
- /**
- * Streaming unable to start (non-fatal).
- *
- * sm_code indicates reason. Scheduler will try to restart
- */
- SMT_NOSTART_WARN,
-
- /**
- * Raw MPEG TS data
- */
- SMT_MPEGTS,
-
- /**
- * Internal message to exit receiver
- */
- SMT_EXIT,
-
- /**
- * Set stream speed
- */
- SMT_SPEED,
-
- /**
- * Skip the stream
- */
- SMT_SKIP,
-
- /**
- * Timeshift status
- */
- SMT_TIMESHIFT_STATUS,
-
-} streaming_message_type_t;
-
-#define SMT_TO_MASK(x) (1 << ((unsigned int)x))
-
-
-#define SM_CODE_OK 0
-
-#define SM_CODE_UNDEFINED_ERROR 1
-
-#define SM_CODE_FORCE_OK 10
-
-#define SM_CODE_SOURCE_RECONFIGURED 100
-#define SM_CODE_BAD_SOURCE 101
-#define SM_CODE_SOURCE_DELETED 102
-#define SM_CODE_SUBSCRIPTION_OVERRIDDEN 103
-#define SM_CODE_INVALID_TARGET 104
-#define SM_CODE_USER_ACCESS 105
-#define SM_CODE_USER_LIMIT 106
-#define SM_CODE_WEAK_STREAM 107
-#define SM_CODE_USER_REQUEST 108
-#define SM_CODE_PREVIOUSLY_RECORDED 109
-
-#define SM_CODE_NO_FREE_ADAPTER 200
-#define SM_CODE_MUX_NOT_ENABLED 201
-#define SM_CODE_NOT_FREE 202
-#define SM_CODE_TUNING_FAILED 203
-#define SM_CODE_SVC_NOT_ENABLED 204
-#define SM_CODE_BAD_SIGNAL 205
-#define SM_CODE_NO_SOURCE 206
-#define SM_CODE_NO_SERVICE 207
-#define SM_CODE_NO_VALID_ADAPTER 208
-#define SM_CODE_NO_ADAPTERS 209
-#define SM_CODE_INVALID_SERVICE 210
-#define SM_CODE_CHN_NOT_ENABLED 211
-
-#define SM_CODE_ABORTED 300
-
-#define SM_CODE_NO_DESCRAMBLER 400
-#define SM_CODE_NO_ACCESS 401
-#define SM_CODE_NO_INPUT 402
-#define SM_CODE_NO_SPACE 403
-
-typedef enum
-{
- SIGNAL_UNKNOWN,
- SIGNAL_GOOD,
- SIGNAL_BAD,
- SIGNAL_FAINT,
- SIGNAL_NONE
-} signal_state_t;
-
-static struct strtab signal_statetab[] = {
- { "GOOD", SIGNAL_GOOD },
- { "BAD", SIGNAL_BAD },
- { "FAINT", SIGNAL_FAINT },
- { "NONE", SIGNAL_NONE },
-};
-
-static inline const char * signal2str ( signal_state_t st )
-{
- const char *r = val2str(st, signal_statetab);
- if (!r) r = "UNKNOWN";
- return r;
-}
-
-/**
- * Streaming messages are sent from the pad to its receivers
- */
-typedef struct streaming_message {
- TAILQ_ENTRY(streaming_message) sm_link;
- streaming_message_type_t sm_type;
-#if ENABLE_TIMESHIFT
- int64_t sm_time;
-#endif
- union {
- void *sm_data;
- int sm_code;
- };
-} streaming_message_t;
-
-/**
- * A streaming target receives data.
- */
-
-typedef void (st_callback_t)(void *opaque, streaming_message_t *sm);
-
-typedef struct {
- st_callback_t *st_cb;
- htsmsg_t *(*st_info)(void *opaque, htsmsg_t *list);
-} streaming_ops_t;
-
-typedef struct streaming_target {
- LIST_ENTRY(streaming_target) st_link;
- streaming_pad_t *st_pad; /* Source we are linked to */
- streaming_ops_t st_ops;
- void *st_opaque;
- int st_reject_filter;
-} streaming_target_t;
-
-
-/**
- *
- */
-typedef struct streaming_queue {
-
- streaming_target_t sq_st;
-
- pthread_mutex_t sq_mutex; /* Protects sp_queue */
- tvh_cond_t sq_cond; /* Condvar for signalling new packets */
-
- size_t sq_maxsize; /* Max queue size (bytes) */
- size_t sq_size; /* Actual queue size (bytes) - only data */
-
- struct streaming_message_queue sq_queue;
-
-} streaming_queue_t;
-
-
-streaming_component_type_t streaming_component_txt2type(const char *str);
-const char *streaming_component_type2txt(streaming_component_type_t s);
-streaming_component_type_t streaming_component_txt2type(const char *s);
-const char *streaming_component_audio_type2desc(int audio_type);
-
static inline unsigned int tvh_strhash(const char *s, unsigned int mod)
{
unsigned int v = 5381;
int sri_to_rate(int sri);
int rate_to_sri(int rate);
-extern struct service_list all_transports;
-
extern void scopedunlock(pthread_mutex_t **mtxp);
#define scopedlock(mtx) \