static int mpegts_write_section1(MpegTSSection *s, int tid, int id,

                                 int version, int sec_num, int last_sec_num,

                                 uint8_t *buf, int len)

{

    uint8_t section[1024], *q;

    unsigned int tot_len;

    /* reserved_future_use field must be set to 1 for SDT */

    unsigned int flags = tid == SDT_TID ? 0xf000 : 0xb000;



    tot_len = 3 + 5 + len + 4;

    /* check if not too big */

    if (tot_len > 1024)

        return -1;



    q    = section;

    *q++ = tid;

    put16(&q, flags | (len + 5 + 4)); /* 5 byte header + 4 byte CRC */

    put16(&q, id);

    *q++ = 0xc1 | (version << 1); /* current_next_indicator = 1 */

    *q++ = sec_num;

    *q++ = last_sec_num;

    memcpy(q, buf, len);



    mpegts_write_section(s, section, tot_len);

    return 0;

}

static int mpegts_write_section1(MpegTSSection *s, int tid, int id,

                                 int version, int sec_num, int last_sec_num,

                                 uint8_t *buf, int len)

{

    uint8_t section[1024], *q;

    unsigned int tot_len;

    

    unsigned int flags = tid == SDT_TID ? 0xf000 : 0xb000;



    tot_len = 3 + 5 + len + 4;

    

    if (tot_len > 1024)

        return -1;



    q    = section;

    *q++ = tid;

    put16(&q, flags | (len + 5 + 4)); 

    put16(&q, id);

    *q++ = 0xc1 | (version << 1); 

    *q++ = sec_num;

    *q++ = last_sec_num;

    memcpy(q, buf, len);



    mpegts_write_section(s, section, tot_len);

    return 0;

}

static int FUNC_0(MpegTSSection *VAR_0, int VAR_1, int VAR_2,

                                 int VAR_3, int VAR_4, int VAR_5,

                                 uint8_t *VAR_6, int VAR_7)

{

    uint8_t section[1024], *q;

    unsigned int VAR_8;

    

    unsigned int VAR_9 = VAR_1 == SDT_TID ? 0xf000 : 0xb000;



    VAR_8 = 3 + 5 + VAR_7 + 4;

    

    if (VAR_8 > 1024)

        return -1;



    q    = section;

    *q++ = VAR_1;

    put16(&q, VAR_9 | (VAR_7 + 5 + 4)); 

    put16(&q, VAR_2);

    *q++ = 0xc1 | (VAR_3 << 1); 

    *q++ = VAR_4;

    *q++ = VAR_5;

    memcpy(q, VAR_6, VAR_7);



    mpegts_write_section(VAR_0, section, VAR_8);

    return 0;

}

static int FUNC_0(MpegTSSection *VAR_0, int VAR_1, int VAR_2,
int VAR_3, int VAR_4, int VAR_5,
uint8_t *VAR_6, int VAR_7)
{ uint8_t section[1024], *q; unsigned int VAR_8; unsigned int VAR_9 = VAR_1 == SDT_TID ? 0xf000 : 0xb000; VAR_8 = 3 + 5 + VAR_7 + 4; if (VAR_8 > 1024)
return -1; q    = section; *q++ = VAR_1; put16(&q, VAR_9 | (VAR_7 + 5 + 4)); put16(&q, VAR_2); *q++ = 0xc1 | (VAR_3 << 1); *q++ = VAR_4; *q++ = VAR_5; memcpy(q, VAR_6, VAR_7); mpegts_write_section(VAR_0, section, VAR_8); return 0; }