decoupled the muxer from the service link.
This commit is contained in:
parent
dcfaad1a41
commit
0cbaa02441
6 changed files with 26 additions and 24 deletions
|
@ -327,7 +327,7 @@ dvr_rec_start(dvr_entry_t *de, const streaming_start_t *ss)
|
|||
int i;
|
||||
dvr_config_t *cfg = dvr_config_find_by_name_default(de->de_config_name);
|
||||
|
||||
de->de_mux = muxer_create(de->de_s->ths_service, de->de_mc);
|
||||
de->de_mux = muxer_create(de->de_mc);
|
||||
if(!de->de_mux) {
|
||||
dvr_rec_fatal_error(de, "Unable to create muxer");
|
||||
return;
|
||||
|
|
|
@ -163,11 +163,11 @@ muxer_container_txt2type(const char *str)
|
|||
* Create a new muxer
|
||||
*/
|
||||
muxer_t*
|
||||
muxer_create(service_t *s, muxer_container_type_t mc)
|
||||
muxer_create(muxer_container_type_t mc)
|
||||
{
|
||||
muxer_t *m;
|
||||
|
||||
m = pass_muxer_create(s, mc);
|
||||
m = pass_muxer_create(mc);
|
||||
|
||||
if(!m)
|
||||
m = tvh_muxer_create(mc);
|
||||
|
|
|
@ -63,7 +63,7 @@ const char* muxer_container_mimetype(muxer_container_type_t mc, int v
|
|||
const char* muxer_container_suffix (muxer_container_type_t mc, int video);
|
||||
|
||||
// Muxer factory
|
||||
muxer_t *muxer_create(struct service *s, muxer_container_type_t mc);
|
||||
muxer_t *muxer_create(muxer_container_type_t mc);
|
||||
|
||||
// Wrapper functions
|
||||
int muxer_open_file (muxer_t *m, const char *filename);
|
||||
|
|
|
@ -51,7 +51,6 @@ typedef struct pass_muxer {
|
|||
/* TS muxing */
|
||||
uint8_t *pm_pat;
|
||||
uint8_t *pm_pmt;
|
||||
uint16_t pm_pmt_pid;
|
||||
uint32_t pm_ic; // Injection counter
|
||||
uint32_t pm_pc; // Packet counter
|
||||
} pass_muxer_t;
|
||||
|
@ -66,8 +65,10 @@ pass_muxer_mime(muxer_t* m, const struct streaming_start *ss)
|
|||
int i;
|
||||
int has_audio;
|
||||
int has_video;
|
||||
muxer_container_type_t mc;
|
||||
const streaming_start_component_t *ssc;
|
||||
|
||||
const source_info_t *si = &ss->ss_si;
|
||||
|
||||
has_audio = 0;
|
||||
has_video = 0;
|
||||
|
||||
|
@ -81,10 +82,17 @@ pass_muxer_mime(muxer_t* m, const struct streaming_start *ss)
|
|||
has_audio |= SCT_ISAUDIO(ssc->ssc_type);
|
||||
}
|
||||
|
||||
if(si->si_type == S_MPEG_TS)
|
||||
mc = MC_MPEGTS;
|
||||
else if(si->si_type == S_MPEG_PS)
|
||||
mc = MC_MPEGPS;
|
||||
else
|
||||
mc = MC_UNKNOWN;
|
||||
|
||||
if(has_video)
|
||||
return muxer_container_mimetype(m->m_container, 1);
|
||||
return muxer_container_mimetype(mc, 1);
|
||||
else if(has_audio)
|
||||
return muxer_container_mimetype(m->m_container, 0);
|
||||
return muxer_container_mimetype(mc, 0);
|
||||
else
|
||||
return muxer_container_mimetype(MC_UNKNOWN, 0);
|
||||
}
|
||||
|
@ -97,16 +105,16 @@ static int
|
|||
pass_muxer_reconfigure(muxer_t* m, const struct streaming_start *ss)
|
||||
{
|
||||
pass_muxer_t *pm = (pass_muxer_t*)m;
|
||||
const source_info_t *si = &ss->ss_si;
|
||||
|
||||
if(pm->m_container == MC_MPEGTS) {
|
||||
|
||||
if(si->si_type == S_MPEG_TS) {
|
||||
memset(pm->pm_pat, 0xff, 188);
|
||||
pm->pm_pat[0] = 0x47;
|
||||
pm->pm_pat[1] = 0x40;
|
||||
pm->pm_pat[2] = 0x00;
|
||||
pm->pm_pat[3] = 0x10;
|
||||
pm->pm_pat[4] = 0x00;
|
||||
if(psi_build_pat(NULL, pm->pm_pat+5, 183, pm->pm_pmt_pid) < 0) {
|
||||
if(psi_build_pat(NULL, pm->pm_pat+5, 183, ss->ss_pmt_pid) < 0) {
|
||||
pm->m_errors++;
|
||||
tvhlog(LOG_ERR, "pass", "%s: Unable to build pat", pm->pm_filename);
|
||||
return -1;
|
||||
|
@ -114,8 +122,8 @@ pass_muxer_reconfigure(muxer_t* m, const struct streaming_start *ss)
|
|||
|
||||
memset(pm->pm_pmt, 0xff, 188);
|
||||
pm->pm_pmt[0] = 0x47;
|
||||
pm->pm_pmt[1] = 0x40 | (pm->pm_pmt_pid >> 8);
|
||||
pm->pm_pmt[2] = 0x00 | (pm->pm_pmt_pid >> 0);
|
||||
pm->pm_pmt[1] = 0x40 | (ss->ss_pmt_pid >> 8);
|
||||
pm->pm_pmt[2] = 0x00 | (ss->ss_pmt_pid >> 0);
|
||||
pm->pm_pmt[3] = 0x10;
|
||||
pm->pm_pmt[4] = 0x00;
|
||||
if(psi_build_pmt(ss, pm->pm_pmt+5, 183, ss->ss_pcr_pid) < 0) {
|
||||
|
@ -305,7 +313,7 @@ pass_muxer_destroy(muxer_t *m)
|
|||
* Create a new passthrough muxer
|
||||
*/
|
||||
muxer_t*
|
||||
pass_muxer_create(service_t *s, muxer_container_type_t mc)
|
||||
pass_muxer_create(muxer_container_type_t mc)
|
||||
{
|
||||
pass_muxer_t *pm;
|
||||
|
||||
|
@ -323,14 +331,8 @@ pass_muxer_create(service_t *s, muxer_container_type_t mc)
|
|||
pm->m_close = pass_muxer_close;
|
||||
pm->m_destroy = pass_muxer_destroy;
|
||||
|
||||
if(s->s_type == SERVICE_TYPE_V4L) {
|
||||
pm->m_container = MC_MPEGPS;
|
||||
} else {
|
||||
pm->m_container = MC_MPEGTS;
|
||||
pm->pm_pmt_pid = s->s_pmt_pid;
|
||||
pm->pm_pat = malloc(188);
|
||||
pm->pm_pmt = malloc(188);
|
||||
}
|
||||
pm->pm_pat = malloc(188);
|
||||
pm->pm_pmt = malloc(188);
|
||||
|
||||
return (muxer_t *)pm;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,6 @@
|
|||
|
||||
#include "muxer.h"
|
||||
|
||||
muxer_t* pass_muxer_create(struct service *s, muxer_container_type_t mc);
|
||||
muxer_t* pass_muxer_create(muxer_container_type_t mc);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -153,7 +153,7 @@ http_stream_run(http_connection_t *hc, streaming_queue_t *sq,
|
|||
socklen_t errlen = sizeof(err);
|
||||
const char *name;
|
||||
|
||||
mux = muxer_create(s->ths_service, mc);
|
||||
mux = muxer_create(mc);
|
||||
if(muxer_open_stream(mux, hc->hc_fd))
|
||||
run = 0;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue