+static int open_fec_client(struct fec_client *fc)
+{
+ int ret;
+ struct fec_client_parms *fcp;
+
+ ret = fc->sender->open(fc->private_data, &fc->fcp);
+ if (ret < 0) {
+ fc->fcp = NULL;
+ return ret;
+ }
+ fcp = fc->fcp;
+ if (fcp->max_slice_bytes < FEC_HEADER_SIZE + fcp->data_slices_per_group)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ ret = fec_new(fcp->data_slices_per_group, fcp->slices_per_group,
+ &fc->parms);
+ if (ret < 0)
+ goto err;
+ fc->first_stream_chunk = -1; /* stream not yet started */
+ fc->src_data = para_malloc(fc->fcp->slices_per_group * sizeof(char *));
+ fc->enc_buf = para_calloc(fc->fcp->max_slice_bytes);
+ fc->num_extra_slices = 0;
+ fc->extra_src_buf = para_calloc(fc->fcp->max_slice_bytes);
+ fc->next_header_time.tv_sec = 0;
+ return 1;
+err:
+ fec_free(fc->parms);
+ return ret;
+}
+