send the packet type to muxer along with the actual packet so we can check if the cast is correct

This commit is contained in:
John Törnblom 2012-10-24 15:25:43 +02:00
parent deea444c86
commit dcfaad1a41
6 changed files with 20 additions and 11 deletions

View file

@ -445,7 +445,7 @@ dvr_thread(void *aux)
if(dispatch_clock > de->de_start - (60 * de->de_start_extra)) {
dvr_rec_set_state(de, DVR_RS_RUNNING, 0);
muxer_write_pkt(de->de_mux, sm->sm_data);
muxer_write_pkt(de->de_mux, sm->sm_type, sm->sm_data);
sm->sm_data = NULL;
}
break;

View file

@ -308,12 +308,12 @@ muxer_write_meta(muxer_t *m, struct epg_broadcast *eb)
* sanity wrapper arround m_write_pkt()
*/
int
muxer_write_pkt(muxer_t *m, void *data)
muxer_write_pkt(muxer_t *m, streaming_message_type_t smt, void *data)
{
if(!m || !data)
return -1;
return m->m_write_pkt(m, data);
return m->m_write_pkt(m, smt, data);
}

View file

@ -47,7 +47,9 @@ typedef struct muxer {
int (*m_close) (struct muxer *); // Close the muxer
void (*m_destroy) (struct muxer *); // Free the memory
int (*m_write_meta) (struct muxer *, struct epg_broadcast *); // Append epg data
int (*m_write_pkt) (struct muxer *, void *); // Append a media packet
int (*m_write_pkt) (struct muxer *, // Append a media packet
streaming_message_type_t,
void *);
int m_errors; // Number of errors
muxer_container_type_t m_container; // The type of the container
@ -71,7 +73,7 @@ int muxer_reconfigure (muxer_t *m, const struct streaming_start *ss);
int muxer_close (muxer_t *m);
int muxer_destroy (muxer_t *m);
int muxer_write_meta (muxer_t *m, struct epg_broadcast *eb);
int muxer_write_pkt (muxer_t *m, void *data);
int muxer_write_pkt (muxer_t *m, streaming_message_type_t smt, void *data);
const char* muxer_mime (muxer_t *m, const struct streaming_start *ss);
const char* muxer_suffix (muxer_t *m, const struct streaming_start *ss);

View file

@ -19,6 +19,7 @@
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
#include "tvheadend.h"
#include "streaming.h"
@ -227,17 +228,19 @@ pass_muxer_write_ts(muxer_t *m, pktbuf_t *pb)
* Write a packet directly to the file descriptor
*/
static int
pass_muxer_write_pkt(muxer_t *m, void *data)
pass_muxer_write_pkt(muxer_t *m, streaming_message_type_t smt, void *data)
{
pktbuf_t *pb = (pktbuf_t*)data;
pass_muxer_t *pm = (pass_muxer_t*)m;
switch(pm->m_container) {
case MC_MPEGTS:
assert(smt == SMT_MPEGTS);
switch(smt) {
case SMT_MPEGTS:
pass_muxer_write_ts(m, pb);
break;
default:
//NOP
//TODO: add support for v4l (MPEG-PS)
break;
}

View file

@ -16,6 +16,8 @@
* along with this program. If not, see <htmlui://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include "tvheadend.h"
#include "streaming.h"
#include "epg.h"
@ -132,11 +134,13 @@ tvh_muxer_open_file(muxer_t *m, const char *filename)
* Write a packet to the muxer
*/
static int
tvh_muxer_write_pkt(muxer_t *m, void *data)
tvh_muxer_write_pkt(muxer_t *m, streaming_message_type_t smt, void *data)
{
th_pkt_t *pkt = (th_pkt_t*)data;
tvh_muxer_t *tm = (tvh_muxer_t*)m;
assert(smt == SMT_PACKET);
if(mk_mux_write_pkt(tm->tm_ref, pkt)) {
tm->m_errors++;
return -1;

View file

@ -199,7 +199,7 @@ http_stream_run(http_connection_t *hc, streaming_queue_t *sq,
switch(sm->sm_type) {
case SMT_MPEGTS:
case SMT_PACKET:
muxer_write_pkt(mux, sm->sm_data);
muxer_write_pkt(mux, sm->sm_type, sm->sm_data);
sm->sm_data = NULL;
break;