Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
transcoding: copy transcoding paramaters from a playlist GET request …
…to the url inside the generated m3u8 file
  • Loading branch information
john-tornblom committed Jul 17, 2013
1 parent f7da029 commit b7e4f3f
Showing 1 changed file with 84 additions and 42 deletions.
126 changes: 84 additions & 42 deletions src/webui/webui.c
Expand Up @@ -46,6 +46,7 @@
#include "dvb/dvb_support.h"
#include "imagecache.h"
#include "tcp.h"
#include "config2.h"

#if defined(PLATFORM_LINUX)
#include <sys/sendfile.h>
Expand Down Expand Up @@ -76,6 +77,61 @@ is_client_simple(http_connection_t *hc)



#if ENABLE_LIBAV
static int
http_get_transcoder_properties(struct http_arg_list *args,
transcoder_props_t *props)
{
int transcode;
const char *s;

memset(props, 0, sizeof(transcoder_props_t));

if ((s = http_arg_get(args, "transcode")))
transcode = atoi(s);
else
transcode = 0;

if ((s = http_arg_get(args, "resolution")))
props->tp_resolution = atoi(s);
else
props->tp_resolution = 384;

if ((s = http_arg_get(args, "channels")))
props->tp_channels = atoi(s);
else
props->tp_channels = 0; //same as source

if ((s = http_arg_get(args, "bandwidth")))
props->tp_bandwidth = atoi(s);
else
props->tp_bandwidth = 0; //same as source

if ((s = http_arg_get(args, "language")))
strncpy(props->tp_language, s, 3);
else
strncpy(props->tp_language, config_get_language(), 3);

if ((s = http_arg_get(args, "vcodec")))
props->tp_vcodec = streaming_component_txt2type(s);
else
props->tp_vcodec = SCT_UNKNOWN;

if ((s = http_arg_get(args, "acodec")))
props->tp_acodec = streaming_component_txt2type(s);
else
props->tp_acodec = SCT_UNKNOWN;

if ((s = http_arg_get(args, "scodec")))
props->tp_scodec = streaming_component_txt2type(s);
else
props->tp_scodec = SCT_UNKNOWN;

return transcode && transcoding_enabled;
}
#endif


/**
* Root page, we direct the client to different pages depending
* on if it is a full blown browser or just some mobile app
Expand Down Expand Up @@ -296,6 +352,11 @@ http_channel_playlist(http_connection_t *hc, channel_t *channel)
htsbuf_queue_t *hq;
char buf[255];
const char *host;
muxer_container_type_t mc;

mc = muxer_container_txt2type(http_arg_get(&hc->hc_req_args, "mux"));
if(mc == MC_UNKNOWN)
mc = dvr_config_find_by_name_default("")->dvr_mc;

hq = &hc->hc_reply;
host = http_arg_get(&hc->hc_args, "Host");
Expand All @@ -304,9 +365,31 @@ http_channel_playlist(http_connection_t *hc, channel_t *channel)

htsbuf_qprintf(hq, "#EXTM3U\n");
htsbuf_qprintf(hq, "#EXTINF:-1,%s\n", channel->ch_name);
htsbuf_qprintf(hq, "http://%s%s?ticket=%s\n", host, buf,
htsbuf_qprintf(hq, "http://%s%s?ticket=%s", host, buf,
access_ticket_create(buf));

#if ENABLE_LIBAV
transcoder_props_t props;
if(http_get_transcoder_properties(&hc->hc_req_args, &props)) {
htsbuf_qprintf(hq, "&transcode=1");
if(props.tp_resolution)
htsbuf_qprintf(hq, "&resolution=%d", props.tp_resolution);
if(props.tp_channels)
htsbuf_qprintf(hq, "&channels=%d", props.tp_channels);
if(props.tp_bandwidth)
htsbuf_qprintf(hq, "&bandwidth=%d", props.tp_bandwidth);
if(props.tp_language[0])
htsbuf_qprintf(hq, "&language=%s", props.tp_language);
if(props.tp_vcodec)
htsbuf_qprintf(hq, "&vcodec=%s", streaming_component_type2txt(props.tp_vcodec));
if(props.tp_acodec)
htsbuf_qprintf(hq, "&acodec=%s", streaming_component_type2txt(props.tp_acodec));
if(props.tp_scodec)
htsbuf_qprintf(hq, "&scodec=%s", streaming_component_type2txt(props.tp_scodec));
}
#endif
htsbuf_qprintf(hq, "&mux=%s\n", muxer_container_type2txt(mc));

http_output_content(hc, "audio/x-mpegurl");

return 0;
Expand Down Expand Up @@ -556,47 +639,6 @@ page_http_playlist(http_connection_t *hc, const char *remain, void *opaque)
}


#if ENABLE_LIBAV
static int
http_get_transcoder_properties(struct http_arg_list *args,
transcoder_props_t *props)
{
int transcode;
const char *s;

memset(props, 0, sizeof(transcoder_props_t));

if ((s = http_arg_get(args, "transcode")))
transcode = atoi(s);
else
transcode = 0;

if ((s = http_arg_get(args, "resolution")))
props->tp_resolution = atoi(s);

if ((s = http_arg_get(args, "channels")))
props->tp_channels = atoi(s);

if ((s = http_arg_get(args, "bandwidth")))
props->tp_bandwidth = atoi(s);

if ((s = http_arg_get(args, "language")))
strncpy(props->tp_language, s, 3);

if ((s = http_arg_get(args, "vcodec")))
props->tp_vcodec = streaming_component_txt2type(s);

if ((s = http_arg_get(args, "acodec")))
props->tp_acodec = streaming_component_txt2type(s);

if ((s = http_arg_get(args, "scodec")))
props->tp_scodec = streaming_component_txt2type(s);

return transcode && transcoding_enabled;
}
#endif


/**
* Subscribes to a service and starts the streaming loop
*/
Expand Down

1 comment on commit b7e4f3f

@andyb2000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still getting compile errors due to new transcoding code:

src/plumbing/transcoding.c: In function ‘transcoder_stream_video’:
src/plumbing/transcoding.c:617:9: error: type of formal parameter 4 is incomplete
src/plumbing/transcoding.c:617:9: error: type of formal parameter 7 is incomplete
make: *** [/usr/src/tvheadend-andyb2000/tvheadend-master/tvheadend.dev/build.linux/src/plumbing/transcoding.o] Error 1

https://tvheadend.org/issues/1732

Please sign in to comment.