From: Jaroslav Kysela Date: Tue, 6 Mar 2018 17:24:46 +0000 (+0100) Subject: move streaming defines from tvheadend.h to streaming.h X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e70323aa999784700419be56ae7c2bcd2e8440f;p=thirdparty%2Ftvheadend.git move streaming defines from tvheadend.h to streaming.h --- diff --git a/src/esstream.h b/src/esstream.h index 4113479d7..63209999b 100644 --- a/src/esstream.h +++ b/src/esstream.h @@ -26,13 +26,61 @@ /** * */ - 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. */ diff --git a/src/input.h b/src/input.h index 595980f98..516f850ef 100644 --- a/src/input.h +++ b/src/input.h @@ -21,6 +21,7 @@ #include "idnode.h" #include "queue.h" +#include "streaming.h" struct htsmsg; diff --git a/src/input/mpegts.h b/src/input/mpegts.h index 6473b373f..e9fb8c070 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -25,6 +25,7 @@ #endif #include "atomic.h" +#include "sbuf.h" #include "input.h" #include "service.h" #include "mpegts/dvb.h" diff --git a/src/libav.h b/src/libav.h index fbe4b3acd..ea9af5169 100644 --- a/src/libav.h +++ b/src/libav.h @@ -25,7 +25,7 @@ #include #include -#include "tvheadend.h" +#include "esstream.h" /* Older versions of ffmpeg/libav don't have the AV_* prefix diff --git a/src/muxer.h b/src/muxer.h index aa4b17d32..9b3ba408c 100644 --- a/src/muxer.h +++ b/src/muxer.h @@ -19,6 +19,7 @@ #ifndef MUXER_H_ #define MUXER_H_ +#include "streaming.h" #include "htsmsg.h" #define MC_IS_EOS_ERROR(e) ((e) == EPIPE || (e) == ECONNRESET) diff --git a/src/packet.c b/src/packet.c index 3ad2569e1..58f841956 100644 --- a/src/packet.c +++ b/src/packet.c @@ -18,6 +18,7 @@ #include "tvheadend.h" +#include "streaming.h" #include "packet.h" #include "string.h" #include "atomic.h" diff --git a/src/packet.h b/src/packet.h index ec6239541..25a3c0431 100644 --- a/src/packet.h +++ b/src/packet.h @@ -19,6 +19,8 @@ #ifndef PACKET_H_ #define PACKET_H_ +#include "esstream.h" + struct memoryinfo; /** diff --git a/src/parsers.h b/src/parsers.h index 54136f6cc..f247e743f 100644 --- a/src/parsers.h +++ b/src/parsers.h @@ -20,6 +20,7 @@ #define PARSERS_H #include "tvheadend.h" +#include "sbuf.h" #include "streaming.h" #include "subscriptions.h" #include "packet.h" @@ -91,7 +92,7 @@ struct parser { 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 */ }; diff --git a/src/parsers/parser_teletext.c b/src/parsers/parser_teletext.c index c0bd51248..268f78b72 100644 --- a/src/parsers/parser_teletext.c +++ b/src/parsers/parser_teletext.c @@ -1036,7 +1036,7 @@ teletext_rundown_scan(parser_t *prs, tt_private_t *ttp) 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; diff --git a/src/service.h b/src/service.h index 760aded59..d9c69363c 100644 --- a/src/service.h +++ b/src/service.h @@ -20,11 +20,13 @@ #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; @@ -32,27 +34,19 @@ extern struct service_queue service_all; 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; /** @@ -61,25 +55,19 @@ typedef TAILQ_HEAD(service_instance_list, service_instance) service_instance_lis 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]; @@ -272,7 +260,7 @@ typedef struct service { /** * 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 */ /** @@ -382,7 +370,7 @@ typedef struct service { 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. @@ -437,7 +425,7 @@ static inline service_t *service_find_by_uuid0(tvh_uuid_t *uuid) 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, diff --git a/src/streaming.c b/src/streaming.c index 4ea670c66..e47dcfa25 100644 --- a/src/streaming.c +++ b/src/streaming.c @@ -613,6 +613,20 @@ streaming_component_audio_type2desc(int audio_type) 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; +} + /* * */ diff --git a/src/streaming.h b/src/streaming.h index 549e7ca1d..bdff51b2a 100644 --- a/src/streaming.h +++ b/src/streaming.h @@ -21,10 +21,373 @@ #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]; @@ -47,11 +410,10 @@ typedef struct streaming_start_component { int ssc_frameduration; -} streaming_start_component_t; +}; - -typedef struct streaming_start { +struct streaming_start { int ss_refcount; int ss_num_components; @@ -64,8 +426,7 @@ typedef struct streaming_start { streaming_start_component_t ss_components[0]; -} streaming_start_t; - +}; /** * @@ -91,7 +452,7 @@ void streaming_target_disconnect(streaming_pad_t *sp, streaming_target_t *st); 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); diff --git a/src/timeshift.h b/src/timeshift.h index 27e313d43..a97621cb5 100644 --- a/src/timeshift.h +++ b/src/timeshift.h @@ -20,6 +20,7 @@ #define __TVH_TIMESHIFT_H__ #include "idnode.h" +#include "streaming.h" #include "memoryinfo.h" typedef struct timeshift_conf { diff --git a/src/transcoding/transcode.h b/src/transcoding/transcode.h index 0d528f778..4708919bc 100644 --- a/src/transcoding/transcode.h +++ b/src/transcoding/transcode.h @@ -23,6 +23,7 @@ #include "tvheadend.h" +#include "streaming.h" /* TVHTranscoder ============================================================ */ diff --git a/src/transcoding/transcode/transcoder.c b/src/transcoding/transcode/transcoder.c index ad185c788..3a6a4c632 100644 --- a/src/transcoding/transcode/transcoder.c +++ b/src/transcoding/transcode/transcoder.c @@ -20,6 +20,7 @@ #include "internals.h" #include "../codec/internals.h" +#include "service.h" static TVHCodecProfile _codec_profile_copy = { .name = (char *)"copy" }; diff --git a/src/tvheadend.h b/src/tvheadend.h index eeb61f66a..310a0bc3c 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -119,16 +119,6 @@ typedef struct { } tvh_cond_t; -/* - * Commercial status - */ -typedef enum { - COMMERCIAL_UNKNOWN, - COMMERCIAL_YES, - COMMERCIAL_NO, -} th_commercial_advice_t; - - /* * */ @@ -262,7 +252,6 @@ TAILQ_HEAD(th_muxpkt_queue, th_muxpkt); 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); /** * @@ -276,373 +265,6 @@ 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; @@ -666,8 +288,6 @@ int tvh_str_update(char **strp, const char *src); 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) \