Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
profile, transcode: move transcode config to profiles, add new profil…
…e type
  • Loading branch information
perexg committed Oct 9, 2014
1 parent 2481881 commit 811191c
Show file tree
Hide file tree
Showing 9 changed files with 382 additions and 154 deletions.
56 changes: 15 additions & 41 deletions src/htsp_server.c
Expand Up @@ -34,9 +34,6 @@
#if ENABLE_TIMESHIFT
#include "timeshift.h"
#endif
#if ENABLE_LIBAV
#include "plumbing/transcoding.h"
#endif

#include <pthread.h>
#include <assert.h>
Expand Down Expand Up @@ -193,9 +190,8 @@ typedef struct htsp_subscription {
streaming_target_t *hs_tshift;
#endif

#if ENABLE_LIBAV
streaming_target_t *hs_transcoder;
#endif
streaming_target_t *hs_work;
void (*hs_work_destroy)(streaming_target_t *);

htsp_msg_q_t hs_q;

Expand Down Expand Up @@ -340,10 +336,8 @@ htsp_subscription_destroy(htsp_connection_t *htsp, htsp_subscription_t *hs)
if(hs->hs_tsfix != NULL)
tsfix_destroy(hs->hs_tsfix);

#if ENABLE_LIBAV
if(hs->hs_transcoder != NULL)
transcoder_destroy(hs->hs_transcoder);
#endif
if(hs->hs_work != NULL)
hs->hs_work_destroy(hs->hs_work);

#if ENABLE_TIMESHIFT
if(hs->hs_tshift)
Expand Down Expand Up @@ -1763,27 +1757,13 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in)
#endif

#if ENABLE_LIBAV
if (transcoding_enabled) {
transcoder_props_t props;

props.tp_vcodec = streaming_component_txt2type(htsmsg_get_str(in, "videoCodec"));
props.tp_acodec = streaming_component_txt2type(htsmsg_get_str(in, "audioCodec"));
props.tp_scodec = streaming_component_txt2type(htsmsg_get_str(in, "subtitleCodec"));

props.tp_resolution = htsmsg_get_u32_or_default(in, "maxResolution", 0);
props.tp_channels = htsmsg_get_u32_or_default(in, "channels", 0);
props.tp_bandwidth = htsmsg_get_u32_or_default(in, "bandwidth", 0);

if ((str = htsmsg_get_str(in, "language")))
strncpy(props.tp_language, str, 3);

if(props.tp_vcodec != SCT_UNKNOWN ||
props.tp_acodec != SCT_UNKNOWN ||
props.tp_scodec != SCT_UNKNOWN) {
st = hs->hs_transcoder = transcoder_create(st);
transcoder_set_properties(st, &props);
normts = 1;
}
const char *profile_id = htsmsg_get_str(in, "profile");
profile_t *pro = profile_find_by_uuid(profile_id) ?: profile_find_by_name(profile_id);

hs->hs_work = profile_work(pro, st, &hs->hs_work_destroy);
if (hs->hs_work) {
st = hs->hs_work;
normts = 1;
}
#endif

Expand Down Expand Up @@ -2142,27 +2122,23 @@ htsp_method_file_seek(htsp_connection_t *htsp, htsmsg_t *in)
return rep;
}


#if ENABLE_LIBAV
/**
*
*/
static htsmsg_t *
htsp_method_getCodecs(htsp_connection_t *htsp, htsmsg_t *in)
htsp_method_getProfiles(htsp_connection_t *htsp, htsmsg_t *in)
{
htsmsg_t *out, *l;

l = htsmsg_create_list();
transcoder_get_capabilities(l);
profile_get_htsp_list(l);

out = htsmsg_create_map();

htsmsg_add_msg(out, "encoders", l);
htsmsg_add_msg(out, "profiles", l);

return out;
}
#endif


/**
* HTSP methods
Expand Down Expand Up @@ -2198,9 +2174,7 @@ struct {
{ "subscriptionSpeed", htsp_method_speed, ACCESS_STREAMING},
{ "subscriptionLive", htsp_method_live, ACCESS_STREAMING},
{ "subscriptionFilterStream", htsp_method_filter_stream, ACCESS_STREAMING},
#if ENABLE_LIBAV
{ "getCodecs", htsp_method_getCodecs, ACCESS_STREAMING},
#endif
{ "getProfiles", htsp_method_getProfiles, ACCESS_STREAMING},
{ "fileOpen", htsp_method_file_open, ACCESS_RECORDER},
{ "fileRead", htsp_method_file_read, ACCESS_RECORDER},
{ "fileClose", htsp_method_file_close, ACCESS_RECORDER},
Expand Down
3 changes: 0 additions & 3 deletions src/main.c
Expand Up @@ -147,9 +147,6 @@ const tvh_caps_t tvheadend_capabilities[] = {
#if ENABLE_SATIP_CLIENT
{ "satip_client", NULL },
#endif
#if ENABLE_LIBAV
{ "transcoding", &transcoding_enabled },
#endif
#if ENABLE_IMAGECACHE
{ "imagecache", (uint32_t*)&imagecache_conf.enabled },
#endif
Expand Down
10 changes: 5 additions & 5 deletions src/plumbing/transcoding.c
Expand Up @@ -1321,12 +1321,12 @@ transcoder_destroy(streaming_target_t *st)
/**
*
*/
void
transcoder_get_capabilities(htsmsg_t *array)
htsmsg_t *
transcoder_get_capabilities(void)
{
AVCodec *p = NULL;
const char *name;
streaming_component_type_t sct;
htsmsg_t *array = htsmsg_create_list();

while ((p = av_codec_next(p))) {

Expand All @@ -1340,9 +1340,9 @@ transcoder_get_capabilities(htsmsg_t *array)
if (sct == SCT_NONE)
continue;

name = streaming_component_type2txt(sct);
htsmsg_add_str(array, NULL, name);
htsmsg_add_s32(array, NULL, sct);
}
return array;
}


Expand Down
2 changes: 1 addition & 1 deletion src/plumbing/transcoding.h
Expand Up @@ -36,7 +36,7 @@ extern uint32_t transcoding_enabled;
streaming_target_t *transcoder_create (streaming_target_t *output);
void transcoder_destroy(streaming_target_t *tr);

void transcoder_get_capabilities(htsmsg_t *array);
htsmsg_t *transcoder_get_capabilities(void);
void transcoder_set_properties (streaming_target_t *tr,
transcoder_props_t *prop);

Expand Down

0 comments on commit 811191c

Please sign in to comment.