static int dvb_open(stream_t *stream, int mode, void *opts, int *file_format) { // I don't force the file format bacause, although it's almost always TS, // there are some providers that stream an IP multicast with M$ Mpeg4 inside struct stream_priv_s* p = (struct stream_priv_s*)opts; dvb_priv_t *priv; char *progname; int tuner_type = 0, i; if(mode != STREAM_READ) return STREAM_UNSUPPORTED; stream->priv = calloc(1, sizeof(dvb_priv_t)); if(stream->priv == NULL) return STREAM_ERROR; priv = (dvb_priv_t *)stream->priv; priv->stream = stream; dvb_config = dvb_get_config(); if(dvb_config == NULL) { free(priv); mp_msg(MSGT_DEMUX, MSGL_ERR, "DVB CONFIGURATION IS EMPTY, exit\n"); return STREAM_ERROR; } dvb_config->priv = priv; priv->config = dvb_config; priv->card = -1; for(i=0; i<priv->config->count; i++) { if(priv->config->cards[i].devno+1 == p->card) { priv->card = i; break; } } if(priv->card == -1) { free(priv); mp_msg(MSGT_DEMUX, MSGL_ERR, "NO CONFIGURATION FOUND FOR CARD N. %d, exit\n", p->card); return STREAM_ERROR; } priv->timeout = p->timeout; tuner_type = priv->config->cards[priv->card].type; if(tuner_type == 0) { free(priv); mp_msg(MSGT_DEMUX, MSGL_V, "OPEN_DVB: UNKNOWN OR UNDETECTABLE TUNER TYPE, EXIT\n"); return STREAM_ERROR; } priv->tuner_type = tuner_type; mp_msg(MSGT_DEMUX, MSGL_V, "OPEN_DVB: prog=%s, card=%d, type=%d, vid=%d, aid=%d\n", p->prog, priv->card+1, priv->tuner_type, p->vid, p->aid); priv->list = priv->config->cards[priv->card].list; if((! strcmp(p->prog, "")) && (priv->list != NULL)) progname = priv->list->channels[0].name; else progname = p->prog; if(! dvb_streaming_start(priv, p, tuner_type, progname)) { free(stream->priv); stream->priv = NULL; return STREAM_ERROR; } stream->type = STREAMTYPE_DVB; stream->fill_buffer = dvb_streaming_read; stream->close = dvbin_close; m_struct_free(&stream_opts, opts); *file_format = DEMUXER_TYPE_MPEG_TS; return STREAM_OK; }
static int dvb_open(stream_t *stream, int mode) { // I don't force the file format bacause, although it's almost always TS, // there are some providers that stream an IP multicast with M$ Mpeg4 inside dvb_priv_t *priv = stream->priv; dvb_priv_t *p = priv; char *progname; int tuner_type = 0, i; if(mode != STREAM_READ) return STREAM_UNSUPPORTED; priv->fe_fd = priv->sec_fd = priv->dvr_fd = -1; priv->config = dvb_get_config(); if(priv->config == NULL) { free(priv); mp_msg(MSGT_DEMUX, MSGL_ERR, "DVB CONFIGURATION IS EMPTY, exit\n"); return STREAM_ERROR; } priv->card = -1; for(i=0; i<priv->config->count; i++) { if(priv->config->cards[i].devno+1 == p->cfg_card) { priv->card = i; break; } } if(priv->card == -1) { free(priv); mp_msg(MSGT_DEMUX, MSGL_ERR, "NO CONFIGURATION FOUND FOR CARD N. %d, exit\n", p->cfg_card); return STREAM_ERROR; } priv->timeout = p->cfg_timeout; tuner_type = priv->config->cards[priv->card].type; if(tuner_type == 0) { free(priv); mp_msg(MSGT_DEMUX, MSGL_V, "OPEN_DVB: UNKNOWN OR UNDETECTABLE TUNER TYPE, EXIT\n"); return STREAM_ERROR; } priv->tuner_type = tuner_type; mp_msg(MSGT_DEMUX, MSGL_V, "OPEN_DVB: prog=%s, card=%d, type=%d\n", p->cfg_prog, priv->card+1, priv->tuner_type); priv->list = priv->config->cards[priv->card].list; if((! strcmp(p->cfg_prog, "")) && (priv->list != NULL)) progname = priv->list->channels[0].name; else progname = p->cfg_prog; if(! dvb_streaming_start(stream, tuner_type, progname)) { free(stream->priv); stream->priv = NULL; return STREAM_ERROR; } stream->type = STREAMTYPE_DVB; stream->fill_buffer = dvb_streaming_read; stream->close = dvbin_close; stream->demuxer = "lavf"; stream->lavf_type = "mpegts"; return STREAM_OK; }
static int dvb_open(stream_t *stream) { // I don't force the file format because, although it's almost always TS, // there are some providers that stream an IP multicast with M$ Mpeg4 inside dvb_priv_t *priv = stream->priv; priv->log = stream->log; dvb_priv_t *p = priv; char *progname; int tuner_type = 0, i; pthread_mutex_lock(&global_dvb_state_lock); if (global_dvb_state && global_dvb_state->stream_used) { MP_ERR(stream, "DVB stream already in use, only one DVB stream can exist at a time!"); pthread_mutex_unlock(&global_dvb_state_lock); return STREAM_ERROR; } dvb_state_t* state = dvb_get_state(stream); priv->state = state; if (state == NULL) { MP_ERR(stream, "DVB CONFIGURATION IS EMPTY, exit\n"); pthread_mutex_unlock(&global_dvb_state_lock); return STREAM_ERROR; } state->stream_used = true; pthread_mutex_unlock(&global_dvb_state_lock); if (state->is_on != 1) { // State could be already initialized, for example, we just did a channel switch. // The following setup only has to be done once. state->card = -1; for (i = 0; i < state->count; i++) { if (state->cards[i].devno + 1 == p->cfg_card) { state->card = i; break; } } if (state->card == -1) { MP_ERR(stream, "NO CONFIGURATION FOUND FOR CARD N. %d, exit\n", p->cfg_card); return STREAM_ERROR; } state->timeout = p->cfg_timeout; tuner_type = state->cards[state->card].type; if (tuner_type == 0) { MP_VERBOSE(stream, "OPEN_DVB: UNKNOWN OR UNDETECTABLE TUNER TYPE, EXIT\n"); return STREAM_ERROR; } state->tuner_type = tuner_type; MP_VERBOSE(stream, "OPEN_DVB: prog=%s, card=%d, type=%d\n", p->cfg_prog, state->card + 1, state->tuner_type); state->list = state->cards[state->card].list; if ((!strcmp(p->cfg_prog, "")) && (state->list != NULL)) { progname = state->list->channels[0].name; } else { progname = p->cfg_prog; } if (!dvb_streaming_start(stream, tuner_type, progname)) return STREAM_ERROR; } stream->type = STREAMTYPE_DVB; stream->fill_buffer = dvb_streaming_read; stream->close = dvbin_close; stream->control = dvbin_stream_control; stream->streaming = true; stream->demuxer = "lavf"; stream->lavf_type = "mpegts"; return STREAM_OK; }