profile: added htsp profile for the htsp protocol

- also added alternate default lookups for profiles (not defined) for
  * DVR               : 'dvr'
  * Channel streaming : 'channel'
  * Service streaming : 'service'
This commit is contained in:
Jaroslav Kysela 2014-10-16 12:37:18 +02:00
parent b72ad69e66
commit b1edb29e83
5 changed files with 93 additions and 23 deletions

View file

@ -171,7 +171,7 @@ dvr_config_create(const char *name, const char *uuid, htsmsg_t *conf)
tvhinfo("dvr", "Creating new configuration '%s'", cfg->dvr_config_name);
if (cfg->dvr_profile == NULL) {
cfg->dvr_profile = profile_find_by_name(NULL);
cfg->dvr_profile = profile_find_by_name("dvr", NULL);
assert(cfg->dvr_profile);
LIST_INSERT_HEAD(&cfg->dvr_profile->pro_dvr_configs, cfg, profile_link);
}
@ -343,7 +343,7 @@ dvr_config_class_profile_set(void *o, const void *v)
profile_t *pro;
pro = v ? profile_find_by_uuid(v) : NULL;
pro = pro ?: profile_find_by_name(v);
pro = pro ?: profile_find_by_name(v, "dvr");
if (pro == NULL) {
if (cfg->dvr_profile) {
LIST_REMOVE(cfg, profile_link);
@ -707,7 +707,7 @@ dvr_config_destroy_by_profile(profile_t *pro, int delconf)
while((cfg = LIST_FIRST(&pro->pro_dvr_configs)) != NULL) {
LIST_REMOVE(cfg, profile_link);
cfg->dvr_profile = profile_find_by_name(NULL);
cfg->dvr_profile = profile_find_by_name(NULL, "dvr");
}
}

View file

@ -1785,17 +1785,22 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in)
#if ENABLE_LIBAV
const char *profile_id = htsmsg_get_str(in, "profile");
profile_t *pro = profile_find_by_uuid(profile_id) ?: profile_find_by_name(profile_id);
profile_t *pro = NULL;
if (profile_id) {
pro = profile_find_by_uuid(profile_id);
if (pro == NULL)
pro = profile_find_by_name(profile_id, "htsp");
}
#else
profile_t *pro = profile_find_by_name("htsp", NULL);
#endif
hs->hs_work = profile_work(pro, st, &hs->hs_work_destroy);
if (hs->hs_work) {
st = hs->hs_work;
normts = 1;
}
#else
profile_t *pro = NULL;
#endif
if(normts)
st = hs->hs_tsfix = tsfix_create(st);

View file

@ -293,12 +293,17 @@ profile_get_name(profile_t *pro)
*
*/
profile_t *
profile_find_by_name(const char *name)
profile_find_by_name(const char *name, const char *alt)
{
profile_t *pro;
lock_assert(&global_lock);
if (!name && alt) {
name = alt;
alt = NULL;
}
if (!name)
return profile_default;
@ -307,6 +312,13 @@ profile_find_by_name(const char *name)
return pro;
}
if (alt) {
TAILQ_FOREACH(pro, &profiles, pro_link) {
if (!strcmp(pro->pro_name, alt))
return pro;
}
}
return profile_default;
}
@ -401,6 +413,35 @@ profile_chain_close(profile_chain_t *prch)
streaming_queue_deinit(&prch->prch_sq);
}
/*
* HTSP Profile Class
*/
const idclass_t profile_htsp_class =
{
.ic_super = &profile_class,
.ic_class = "profile-htsp",
.ic_caption = "HTSP Stream Profile",
.ic_properties = (const property_t[]){
/* Ready for future extensions */
{ }
}
};
static muxer_container_type_t
profile_htsp_get_mc(profile_t *_pro)
{
return MC_UNKNOWN;
}
static profile_t *
profile_htsp_builder(void)
{
profile_t *pro = calloc(1, sizeof(*pro));
pro->pro_open = NULL;
pro->pro_get_mc = profile_htsp_get_mc;
return pro;
}
/*
* MPEG-TS passthrough muxer
*/
@ -412,7 +453,7 @@ typedef struct profile_mpegts {
const idclass_t profile_mpegts_pass_class =
{
.ic_super = &profile_class,
.ic_super = &profile_class,
.ic_class = "profile-mpegts",
.ic_caption = "MPEG-TS Pass-through",
.ic_properties = (const property_t[]){
@ -483,7 +524,7 @@ typedef struct profile_matroska {
const idclass_t profile_matroska_class =
{
.ic_super = &profile_class,
.ic_super = &profile_class,
.ic_class = "profile-matroska",
.ic_caption = "Matroska (mkv)",
.ic_properties = (const property_t[]){
@ -705,7 +746,7 @@ profile_class_scodec_list(void *o)
const idclass_t profile_transcode_class =
{
.ic_super = &profile_class,
.ic_super = &profile_class,
.ic_class = "profile-transcode",
.ic_caption = "Transcode",
.ic_properties = (const property_t[]){
@ -878,12 +919,15 @@ profile_init(void)
{
htsmsg_t *c, *e;
htsmsg_field_t *f;
profile_t *pro;
const char *name;
LIST_INIT(&profile_builders);
TAILQ_INIT(&profiles);
profile_register(&profile_mpegts_pass_class, profile_mpegts_pass_builder);
profile_register(&profile_matroska_class, profile_matroska_builder);
profile_register(&profile_htsp_class, profile_htsp_builder);
#if ENABLE_LIBAV
profile_transcode_experimental_codecs =
getenv("TVHEADEND_LIBAV_NO_EXPERIMENTAL_CODECS") ? 0 : 1;
@ -899,37 +943,58 @@ profile_init(void)
htsmsg_destroy(c);
}
if (TAILQ_EMPTY(&profiles)) {
name = "pass";
pro = profile_find_by_name(name, NULL);
if (pro == NULL || strcmp(pro->pro_name, name)) {
htsmsg_t *conf;
conf = htsmsg_create_map();
htsmsg_add_str (conf, "class", "profile-mpegts");
htsmsg_add_bool(conf, "enabled", 1);
htsmsg_add_bool(conf, "default", 1);
htsmsg_add_str (conf, "name", "pass");
htsmsg_add_str (conf, "name", name);
htsmsg_add_str (conf, "comment", "MPEG-TS Pass-through");
htsmsg_add_bool(conf, "rewrite_pmt", 1);
htsmsg_add_bool(conf, "rewrite_pat", 1);
htsmsg_add_bool(conf, "shield", 1);
(void)profile_create(NULL, conf, 1);
htsmsg_destroy(conf);
}
name = "matroska";
pro = profile_find_by_name(name, NULL);
if (pro == NULL || strcmp(pro->pro_name, name)) {
htsmsg_t *conf;
conf = htsmsg_create_map();
htsmsg_add_str (conf, "class", "profile-matroska");
htsmsg_add_bool(conf, "enabled", 1);
htsmsg_add_str (conf, "name", "matroska");
htsmsg_add_str (conf, "name", name);
htsmsg_add_str (conf, "comment", "Matroska");
htsmsg_add_bool(conf, "shield", 1);
(void)profile_create(NULL, conf, 1);
htsmsg_destroy(conf);
}
name = "htsp";
pro = profile_find_by_name(name, NULL);
if (pro == NULL || strcmp(pro->pro_name, name)) {
htsmsg_t *conf;
conf = htsmsg_create_map();
htsmsg_add_str (conf, "class", "profile-htsp");
htsmsg_add_bool(conf, "enabled", 1);
htsmsg_add_str (conf, "name", name);
htsmsg_add_str (conf, "comment", "HTSP Default Stream Settings");
htsmsg_add_bool(conf, "shield", 1);
(void)profile_create(NULL, conf, 1);
htsmsg_destroy(conf);
}
#if ENABLE_LIBAV
profile_t *pro;
const char *name;
name = "webtv-vp8-vorbis-webm";
pro = profile_find_by_name(name);
pro = profile_find_by_name(name, NULL);
if (pro == NULL || strcmp(pro->pro_name, name)) {
htsmsg_t *conf;
@ -948,7 +1013,7 @@ profile_init(void)
htsmsg_destroy(conf);
}
name = "webtv-h264-aac-mpegts";
pro = profile_find_by_name(name);
pro = profile_find_by_name(name, NULL);
if (pro == NULL || strcmp(pro->pro_name, name)) {
htsmsg_t *conf;
@ -967,7 +1032,7 @@ profile_init(void)
htsmsg_destroy(conf);
}
name = "webtv-h264-aac-matroska";
pro = profile_find_by_name(name);
pro = profile_find_by_name(name, NULL);
if (pro == NULL || strcmp(pro->pro_name, name)) {
htsmsg_t *conf;

View file

@ -103,7 +103,7 @@ void profile_chain_close(profile_chain_t *prch);
static inline profile_t *profile_find_by_uuid(const char *uuid)
{ return (profile_t*)idnode_find(uuid, &profile_class, NULL); }
profile_t *profile_find_by_name(const char *name);
profile_t *profile_find_by_name(const char *name, const char *alt);
htsmsg_t * profile_class_get_list(void *o);

View file

@ -719,7 +719,7 @@ http_stream_service(http_connection_t *hc, service_t *service, int weight)
if(http_access_verify(hc, ACCESS_ADVANCED_STREAMING))
return HTTP_STATUS_UNAUTHORIZED;
if(!(pro = profile_find_by_name(http_arg_get(&hc->hc_req_args, "profile"))))
if(!(pro = profile_find_by_name(http_arg_get(&hc->hc_req_args, "profile"), "service")))
return HTTP_STATUS_NOT_ALLOWED;
if((tcp_id = http_stream_preop(hc)) == NULL)
@ -831,7 +831,7 @@ http_stream_channel(http_connection_t *hc, channel_t *ch, int weight)
if (http_access_verify_channel(hc, ACCESS_STREAMING, ch, 1))
return HTTP_STATUS_UNAUTHORIZED;
if(!(pro = profile_find_by_name(http_arg_get(&hc->hc_req_args, "profile"))))
if(!(pro = profile_find_by_name(http_arg_get(&hc->hc_req_args, "profile"), "channel")))
return HTTP_STATUS_NOT_ALLOWED;
if((tcp_id = http_stream_preop(hc)) == NULL)