Remove FEC parameter max_slice_bytes.
authorAndre Noll <maan@systemlinux.org>
Sat, 24 Jul 2010 18:11:08 +0000 (20:11 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 31 Oct 2010 11:06:57 +0000 (12:06 +0100)
It is no longer a FEC parameter as its value is determined at runtime
from the MPS of the connection.

So replace ->max_slice_bytes of struct fec_client_parms by the new
->mps field of struct fec_client.

send.h
udp_send.c
vss.c

diff --git a/send.h b/send.h
index 5f87452..2201beb 100644 (file)
--- a/send.h
+++ b/send.h
@@ -131,8 +131,6 @@ struct fec_client_parms {
        uint8_t slices_per_group;
        /** Number of slices minus number of redundant slices. */
        uint8_t data_slices_per_group;
-       /** Maximal number of bytes per slice, initially zero. */
-       uint16_t max_slice_bytes;
        /**
         * Transport-layer initialisation for FEC support.
         *
index adf2339..0343feb 100644 (file)
@@ -342,7 +342,6 @@ static int udp_com_add(struct sender_command_data *scd)
        sc = ut->sc = para_calloc(sizeof(*sc));
        ut->fcp.slices_per_group      = scd->slices_per_group;
        ut->fcp.data_slices_per_group = scd->data_slices_per_group;
-       ut->fcp.max_slice_bytes       = scd->max_slice_bytes;
        ut->fcp.init_fec              = udp_init_fec;
        ut->fcp.send_fec              = udp_send_fec;
 
@@ -381,9 +380,8 @@ static char *udp_info(void)
 
        list_for_each_entry(sc, &targets, node) {
                struct udp_target *ut = sc->private_data;
-               char *tmp = make_message("%s%s/%u:%u:%u ",
+               char *tmp = make_message("%s%s/%u:%u ",
                        tgts ? : "", sc->name,
-                       ut->fcp.max_slice_bytes,
                        ut->fcp.data_slices_per_group,
                        ut->fcp.slices_per_group
                );
diff --git a/vss.c b/vss.c
index eae0d58..30b03c6 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -169,6 +169,8 @@ struct fec_client {
        int num_extra_slices;
        /** Contains the FEC-encoded data. */
        unsigned char *enc_buf;
+       /** Maximal packet size. */
+       int mps;
 };
 
 /**
@@ -207,7 +209,7 @@ static void write_fec_header(struct fec_client *fc, struct vss_task *vsst)
        write_u32(buf + 14, g->bytes);
 
        write_u8(buf + 18, fc->current_slice_num);
-       write_u16(buf + 20, p->max_slice_bytes - FEC_HEADER_SIZE);
+       write_u16(buf + 20, fc->mps - FEC_HEADER_SIZE);
        write_u8(buf + 22, g->first_chunk? 0 : 1);
        write_u8(buf + 23, vsst->header_len? 1 : 0);
        memset(buf + 24, 0, 7);
@@ -304,7 +306,7 @@ static int initialize_fec_client(struct fec_client *fc, struct vss_task *vsst)
        fc->extra_src_buf = para_realloc(fc->extra_src_buf, mps);
        memset(fc->extra_src_buf, 0, mps);
 
-       fc->fcp->max_slice_bytes = mps;
+       fc->mps = mps;
        fc->state = FEC_STATE_READY_TO_RUN;
        fc->next_header_time.tv_sec = 0;
        fc->stream_start = *now;
@@ -346,14 +348,13 @@ static int setup_next_fec_group(struct fec_client *fc, struct vss_task *vsst)
                g->first_chunk += g->num_chunks;
                g->num++;
        }
-       slice_bytes = fc->fcp->max_slice_bytes - FEC_HEADER_SIZE;
+       slice_bytes = fc->mps - FEC_HEADER_SIZE;
        PARA_CRIT_LOG("slice_bytes: %d\n", slice_bytes);
        k = fc->fcp->data_slices_per_group + fc->num_extra_slices;
        n = fc->fcp->slices_per_group + fc->num_extra_slices;
        PARA_CRIT_LOG("k: %d, n: %d\n", k, n);
        if (need_audio_header(fc, vsst)) {
-               ret = num_slices(vsst->header_len, fc->fcp->max_slice_bytes,
-                       n - k);
+               ret = num_slices(vsst->header_len, slice_bytes, n - k);
                if (ret < 0)
                        return ret;
                g->num_header_slices = ret;
@@ -432,8 +433,7 @@ static int compute_next_fec_slice(struct fec_client *fc, struct vss_task *vsst)
        }
        write_fec_header(fc, vsst);
        fec_encode(fc->parms, fc->src_data, fc->enc_buf + FEC_HEADER_SIZE,
-               fc->current_slice_num,
-               fc->fcp->max_slice_bytes - FEC_HEADER_SIZE);
+               fc->current_slice_num, fc->mps - FEC_HEADER_SIZE);
        return 1;
 }
 
@@ -884,9 +884,8 @@ static void vss_send(struct vss_task *vsst)
                if (compute_next_fec_slice(fc, vsst) <= 0)
                        continue;
                PARA_DEBUG_LOG("sending %d:%d (%u bytes)\n", fc->group.num,
-                       fc->current_slice_num, fc->fcp->max_slice_bytes);
-               fc->fcp->send_fec(fc->sc, (char *)fc->enc_buf,
-                                 fc->fcp->max_slice_bytes);
+                       fc->current_slice_num, fc->mps);
+               fc->fcp->send_fec(fc->sc, (char *)fc->enc_buf, fc->mps);
                fc->current_slice_num++;
                fec_active = 1;
        }