static void test_limit_overflow_no_realloc(void) { hp = make_encoder(0, -1, &static_alloc); CHECK_RES(retval, LEN, hpack_limit, &hp, UINT16_MAX + 1); hpack_free(&hp); }
static void test_limit_realloc_failure(void) { hp = make_encoder(4096, 2048, &oom_alloc); CHECK_RES(retval, OK, hpack_encode, hp, &basic_encoding, 0); CHECK_RES(retval, OOM, hpack_limit, &hp, 4096); hpack_free(&hp); }
static void test_trim_to_limit(void) { hp = make_encoder(512, -1, hpack_default_alloc); CHECK_RES(retval, OK, hpack_limit, &hp, 256); CHECK_RES(retval, OK, hpack_encode, hp, &basic_encoding, 0); CHECK_RES(retval, OK, hpack_trim, &hp); hpack_free(&hp); }
static void test_limit_null_realloc(void) { hp = make_encoder(4096, 0, &static_alloc); CHECK_RES(retval, OK, hpack_encode, hp, &basic_encoding, 0); CHECK_RES(retval, ARG, hpack_limit, &hp, 4096); hpack_free(&hp); }
static void test_limit_between_two_resizes(void) { hp = make_encoder(512, -1, &static_alloc); CHECK_RES(retval, OK, hpack_limit, &hp, 256); CHECK_RES(retval, OK, hpack_resize, &hp, 1024); CHECK_RES(retval, OK, hpack_encode, hp, &basic_encoding, 0); CHECK_RES(retval, OK, hpack_resize, &hp, 2048); hpack_free(&hp); }
static void test_use_busy_encoder(void) { hp = make_encoder(0, -1, hpack_default_alloc); CHECK_RES(retval, BLK, hpack_encode, hp, &basic_encoding, 1); CHECK_RES(retval, BSY, hpack_resize, &hp, 0); CHECK_RES(retval, BSY, hpack_limit, &hp, 0); CHECK_RES(retval, BSY, hpack_trim, &hp); CHECK_RES(retval, BSY, hpack_dynamic, hp, noop_cb, NULL); hpack_free(&hp); }
static void test_use_defunct_encoder(void) { hp = make_encoder(4096, -1, hpack_default_alloc); /* break the decoder */ CHECK_RES(retval, ARG, hpack_encode, hp, &unknown_encoding, 0); /* try using it again */ CHECK_RES(retval, ARG, hpack_encode, hp, &unknown_encoding, 0); /* try resizing it */ CHECK_RES(retval, ARG, hpack_resize, &hp, 0); /* try trimming it */ CHECK_RES(retval, ARG, hpack_trim, &hp); hpack_free(&hp); }
static void test_encode_null_args(void) { struct hpack_encoding enc; hp = make_encoder(512, -1, hpack_default_alloc); CHECK_RES(retval, ARG, hpack_encode, hp, NULL, 0); /* make null members and populate them one by one */ memset(&enc, 0, sizeof enc); CHECK_RES(retval, ARG, hpack_encode, hp, &enc, 0); enc.fld = basic_field; CHECK_RES(retval, ARG, hpack_encode, hp, &enc, 0); enc.fld_cnt = 1; CHECK_RES(retval, ARG, hpack_encode, hp, &enc, 0); enc.buf = wrk_buf; CHECK_RES(retval, ARG, hpack_encode, hp, &enc, 0); enc.buf_len = sizeof wrk_buf; CHECK_RES(retval, ARG, hpack_encode, hp, &enc, 0); hpack_free(&hp); }
/* * We generate: * * audiotestsrc ! <audiocaps> ! output-selector ! [enc1 .. enc3] ! input-selector * select-all = true ! fakesink * * <audiocaps> makes sure we only produce one format from the audiotestsrc. * * Each encX element consists of: * * audioresample ! <enccaps> ! identity ! * * This way we can simply switch encoders without having to renegotiate. */ static GstElement * make_pipeline (void) { GstElement *result; GstElement *audiotestsrc; GstElement *audiocaps; GstElement *outputselect; GstElement *inputselect; GstElement *sink; GstCaps *caps; GstCaps *capslist[3]; gint i; /* create result pipeline */ result = gst_pipeline_new (NULL); g_assert (result); /* create various elements */ audiotestsrc = gst_element_factory_make ("audiotestsrc", NULL); g_object_set (audiotestsrc, "num-buffers", 1000, NULL); g_assert (audiotestsrc); audiocaps = gst_element_factory_make ("capsfilter", NULL); g_assert (audiocaps); caps = gst_caps_from_string ("audio/x-raw-int,signed=true,width=16,depth=16,rate=48000,channels=1"); g_object_set (audiocaps, "caps", caps, NULL); gst_caps_unref (caps); outputselect = gst_element_factory_make ("output-selector", "select"); g_assert (outputselect); inputselect = gst_element_factory_make ("input-selector", NULL); g_assert (inputselect); g_object_set (inputselect, "select-all", TRUE, NULL); sink = gst_element_factory_make ("fakesink", NULL); g_object_set (sink, "sync", TRUE, NULL); g_object_set (sink, "silent", TRUE, NULL); g_assert (sink); /* add elements */ gst_bin_add (GST_BIN (result), audiotestsrc); gst_bin_add (GST_BIN (result), audiocaps); gst_bin_add (GST_BIN (result), outputselect); gst_bin_add (GST_BIN (result), inputselect); gst_bin_add (GST_BIN (result), sink); /* link elements */ gst_element_link_pads (audiotestsrc, "src", audiocaps, "sink"); gst_element_link_pads (audiocaps, "src", outputselect, "sink"); gst_element_link_pads (inputselect, "src", sink, "sink"); /* make caps */ capslist[0] = gst_caps_from_string ("audio/x-raw-int,signed=true,width=16,depth=16,rate=48000,channels=1"); capslist[1] = gst_caps_from_string ("audio/x-raw-int,signed=true,width=16,depth=16,rate=16000,channels=1"); capslist[2] = gst_caps_from_string ("audio/x-raw-int,signed=true,width=16,depth=16,rate=8000,channels=1"); /* create encoder elements */ for (i = 0; i < 3; i++) { GstElement *encoder; GstPad *srcpad, *sinkpad; encoder = make_encoder (capslist[i]); g_assert (encoder); gst_bin_add (GST_BIN (result), encoder); srcpad = gst_element_get_request_pad (outputselect, "src%d"); sinkpad = gst_element_get_static_pad (encoder, "sink"); gst_pad_link (srcpad, sinkpad); gst_object_unref (srcpad); gst_object_unref (sinkpad); srcpad = gst_element_get_static_pad (encoder, "src"); sinkpad = gst_element_get_request_pad (inputselect, "sink%d"); gst_pad_link (srcpad, sinkpad); gst_object_unref (srcpad); gst_object_unref (sinkpad); } return result; }