service = ts->services[0]; #ifdef DEBUG_SI printf("tuning to '%s'\n", service->name); #endif
static int mpegts_read_header(AVFormatContext *s,                              AVFormatParameters *ap){    MpegTSContext *ts = s->priv_data;    ByteIOContext *pb = &s->pb;    uint8_t buf[1024];    int len;    int64_t pos;    MpegTSService *service;        /* read the first 1024 bytes to get packet size */    pos = url_ftell(pb);    len = get_buffer(pb, buf, sizeof(buf));    if (len != sizeof(buf))        goto fail;    ts->raw_packet_size = get_packet_size(buf, sizeof(buf));    if (ts->raw_packet_size <= 0)        goto fail;    ts->auto_guess = 0;        if (!ts->auto_guess) {        /* first do a scaning to get all the services */        url_fseek(pb, pos, SEEK_SET);        mpegts_scan_sdt(ts);                handle_packets(s, MAX_SCAN_PACKETS);                /* if no service found, no need to do anything */        if (ts->nb_services <= 0)            return -1;                /* now find the info for the first service */                url_fseek(pb, pos, SEEK_SET);        service = ts->services[0];#ifdef DEBUG_SI        printf("tuning to '%s'\n", service->name);#endif        /* tune to first service found */        ts->stream = s;        mpegts_set_service(ts, service->sid, set_service_cb, ts);                handle_packets(s, MAX_SCAN_PACKETS);        /* if could not find service, exit */        if (ts->set_service_ret != 0)            return -1;#ifdef DEBUG_SI        printf("tuning done\n");#endif    }    url_fseek(pb, pos, SEEK_SET);    return 0; fail:    return -1;}