예제 #1
0
/**
 * @brief Create the ts_sc_comp object
 *
 * @param ts_sc              The ts_sc_comp object to create
 * @param wlsb_window_width  The width of the W-LSB sliding window to use
 *                           for TS_STRIDE (must be > 0)
 * @param trace_cb           The trace callback
 * @param trace_cb_priv      An optional private context for the trace
 *                           callback, may be NULL
 * @return                   true if creation is successful, false otherwise
 */
bool c_create_sc(struct ts_sc_comp *const ts_sc,
                 const size_t wlsb_window_width,
                 rohc_trace_callback2_t trace_cb,
                 void *const trace_cb_priv)
{
	assert(ts_sc != NULL);
	assert(wlsb_window_width > 0);

	ts_sc->ts_stride = 0;
	ts_sc->ts_scaled = 0;
	ts_sc->ts_offset = 0;
	ts_sc->old_ts = 0;
	ts_sc->ts = 0;
	ts_sc->ts_delta = 0;
	ts_sc->old_sn = 0;
	ts_sc->sn = 0;
	ts_sc->is_deducible = false;
	ts_sc->state = INIT_TS;
	ts_sc->are_old_val_init = false;
	ts_sc->nr_init_stride_packets = 0;

	ts_sc->trace_callback = trace_cb;
	ts_sc->trace_callback_priv = trace_cb_priv;

	/* W-LSB context for TS_SCALED */
	ts_sc->ts_scaled_wlsb = c_create_wlsb(32, wlsb_window_width,
	                                      ROHC_LSB_SHIFT_RTP_TS);
	if(ts_sc->ts_scaled_wlsb == NULL)
	{
		rohc_error(ts_sc, ROHC_TRACE_COMP, ROHC_PROFILE_GENERAL,
		           "cannot create a W-LSB window for TS_SCALED");
		goto error;
	}

	/* W-LSB context for unscaled TS */
	ts_sc->ts_unscaled_wlsb = c_create_wlsb(32, wlsb_window_width,
	                                        ROHC_LSB_SHIFT_RTP_TS);
	if(ts_sc->ts_unscaled_wlsb == NULL)
	{
		rohc_error(ts_sc, ROHC_TRACE_COMP, ROHC_PROFILE_GENERAL,
		           "cannot create a W-LSB window for unscaled TS");
		goto free_ts_scaled_wlsb;
	}

	return true;

free_ts_scaled_wlsb:
	c_destroy_wlsb(ts_sc->ts_scaled_wlsb);
error:
	return false;
}
예제 #2
0
//----------------------------------------------------------------------------------------------------------------------------------
// Create and allocate a new context with profile specific data
// Param state: pointer to decompressor
// Param with_cid: context-id (not used for now)
// Param profile: profile to be assigned with context
// Return: pointer to new context if allocatable, else NULL
//----------------------------------------------------------------------------------------------------------------------------------
struct sd_context * context_create(struct sd_rohc * state, int with_cid, struct s_profile * profile)
{
	struct sd_context * pnew = (struct sd_context*)kmalloc(sizeof(struct sd_context), GFP_ATOMIC);
	if(!pnew) {
		rohc_debugf(0,"[ERROR] context_create(): unable to allocate memory!\n");
		return(NULL);
	}
	pnew->profile = profile;
	pnew->mode = ROHC_U_MODE;
	pnew->state = ROHC_NO_CONTEXT;
	pnew->data = profile->allocate_decode_data();
	if(!pnew->data) {
		kfree(pnew);
		return(NULL);
	}
	pnew->curval = 0;

	pnew->num_recv_packets = 0;
	pnew->total_uncompressed_size = 0;
	pnew->total_compressed_size = 0;
	pnew->header_uncompressed_size = 0;
	pnew->header_compressed_size = 0;
	pnew->num_recv_ir = 0;
	pnew->num_recv_ir_dyn = 0;
	pnew->num_sent_feedbacks = 0;
	pnew->num_decomp_failures = 0;
	pnew->num_decomp_repairs = 0;

	pnew->first_used = get_milliseconds();
	pnew->latest_used = get_milliseconds();

	pnew->total_16_uncompressed = c_create_wlsb(32, 16, 0); // create a window with 16 entries..
	pnew->total_16_compressed = c_create_wlsb(32, 16, 0);
	pnew->header_16_uncompressed = c_create_wlsb(32, 16, 0);
	pnew->header_16_compressed = c_create_wlsb(32, 16, 0);

	return(pnew);
}