static void issue_calls (Sess *sess, Sess_Private_Data *priv) { int i, to_create, retval; Call *call; /* Mimic browser behavior of fetching html object, then a couple of embedded objects: */ to_create = 1; if (priv->num_calls_in_this_burst > 0) to_create = param.burst_len - priv->num_calls_in_this_burst; priv->num_calls_in_this_burst += to_create; for (i = 0; i < to_create; ++i) { call = call_new (); if (!call) { sess_failure (sess); return; } retval = session_issue_call (sess, call); call_dec_ref (call); if (retval < 0) return; } }
static void check_add_bytes(LLVidDSPContext c, int width) { uint8_t *src0 = av_mallocz(width); uint8_t *src1 = av_mallocz(width); uint8_t *dst0 = av_mallocz(width); uint8_t *dst1 = av_mallocz(width); declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, ptrdiff_t w); if (!src0 || !src1 || !dst0 || !dst1) fail(); randomize_buffers(src0, width); memcpy(src1, src0, width); if (check_func(c.add_bytes, "add_bytes")) { call_ref(dst0, src0, width); call_new(dst1, src1, width); if (memcmp(dst0, dst1, width)) fail(); bench_new(dst1, src1, width); } av_free(src0); av_free(src1); av_free(dst0); av_free(dst1); }
static void check_pred8x8l(H264PredContext *h, uint8_t *buf0, uint8_t *buf1, int codec, int chroma_format, int bit_depth) { if (chroma_format == 1 && codec_ids[codec] == AV_CODEC_ID_H264) { int pred_mode; for (pred_mode = 0; pred_mode < 12; pred_mode++) { if (check_pred_func(h->pred8x8l[pred_mode], "8x8l", pred4x4_modes[codec][pred_mode])) { int neighbors; for (neighbors = 0; neighbors <= 0xc000; neighbors += 0x4000) { int has_topleft = neighbors & 0x8000; int has_topright = neighbors & 0x4000; if ((pred_mode == DIAG_DOWN_RIGHT_PRED || pred_mode == VERT_RIGHT_PRED) && !has_topleft) continue; /* Those aren't allowed according to the spec */ randomize_buffers(); call_ref(src0, has_topleft, has_topright, (ptrdiff_t)24*SIZEOF_PIXEL); call_new(src1, has_topleft, has_topright, (ptrdiff_t)24*SIZEOF_PIXEL); if (memcmp(buf0, buf1, BUF_SIZE)) fail(); bench_new(src1, has_topleft, has_topright, (ptrdiff_t)24*SIZEOF_PIXEL); } } } } }
static void check_add_res(HEVCDSPContext h, int bit_depth) { int i; LOCAL_ALIGNED(32, int16_t, res0, [32 * 32]); LOCAL_ALIGNED(32, int16_t, res1, [32 * 32]); LOCAL_ALIGNED(32, uint8_t, dst0, [32 * 32 * 2]); LOCAL_ALIGNED(32, uint8_t, dst1, [32 * 32 * 2]); for (i = 2; i <= 5; i++) { int block_size = 1 << i; int size = block_size * block_size; ptrdiff_t stride = block_size << (bit_depth > 8); declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t *res, ptrdiff_t stride); randomize_buffers(res0, size); randomize_buffers2(dst0, size); memcpy(res1, res0, sizeof(*res0) * size); memcpy(dst1, dst0, size); if (check_func(h.add_residual[i - 2], "add_res_%dx%d_%d", block_size, block_size, bit_depth)) { call_ref(dst0, res0, stride); call_new(dst1, res1, stride); if (memcmp(dst0, dst1, size)) fail(); bench_new(dst1, res1, stride); } } }
int callback_invite(void *toxav_inst, MSICall *call) { ToxAV *toxav = toxav_inst; pthread_mutex_lock(toxav->mutex); ToxAVCall *av_call = call_new(toxav, call->friend_number, NULL); if (av_call == NULL) { LOGGER_WARNING("Failed to initialize call..."); pthread_mutex_unlock(toxav->mutex); return -1; } call->av_call = av_call; av_call->msi_call = call; if (toxav->ccb.first) toxav->ccb.first(toxav, call->friend_number, call->peer_capabilities & msi_CapSAudio, call->peer_capabilities & msi_CapSVideo, toxav->ccb.second); else { /* No handler to capture the call request, send failure */ pthread_mutex_unlock(toxav->mutex); return -1; } pthread_mutex_unlock(toxav->mutex); return 0; }
static void issue_calls (Sess *sess, Sess_Private_Data *priv) { int i, to_create, retval, n; const char *method_str; Call *call; REQ *req; /* Mimic browser behavior of fetching html object, then a couple of embedded objects: */ to_create = 1; if (priv->num_calls_in_this_burst > 0) to_create = priv->current_burst->num_reqs - priv->num_calls_in_this_burst; n = session_max_qlen (sess) - session_current_qlen (sess); if (n < to_create) to_create = n; priv->num_calls_in_this_burst += to_create; for (i = 0; i < to_create; ++i) { call = call_new (); if (!call) { sess_failure (sess); return; } /* fill in the new call: */ req = priv->current_req; if (req == NULL) panic ("%s: internal error, requests ran past end of burst\n", prog_name); method_str = call_method_name[req->method]; call_set_method (call, method_str, strlen (method_str)); call_set_uri (call, req->uri, req->uri_len); if (req->contents_len > 0) { /* add "Content-length:" header and contents, if necessary: */ call_append_request_header (call, req->extra_hdrs, req->extra_hdrs_len); call_set_contents (call, req->contents, req->contents_len); } priv->current_req = req->next; if (DBG > 0) fprintf (stderr, "%s: accessing URI `%s'\n", prog_name, req->uri); retval = session_issue_call (sess, call); call_dec_ref (call); if (retval < 0) return; } }
int http_request_parse(array_queue *equeue, int err, void *arg, call *next) { http_request *req = (http_request*)arg; next->arg = req; if (req->input_buffer_read) { memset(&req->input_buffer, 0, 40000); } int last_read = read(req->client_sockfd, &req->input_buffer[req->input_buffer_read], 40000); if (last_read > 0) req->input_buffer_read += last_read; if ((last_read == -1 && errno == EAGAIN) || (last_read > 0 && strchr(req->input_buffer, '\r') == NULL)) { array_queue_push(equeue, call_new(&http_request_parse, req, next)); return 1; } else if (last_read == -1) { perror("Parse"); if (errno == EBADF) return -3; return -2; } char payload_delim[] = " "; char *playload_parts; char *method = strtok_r(req->input_buffer, payload_delim, &playload_parts); if (method == NULL) return -1; strncpy(req->method, method, HTTP_METHOD_MAX_LENGTH); char *path = strtok_r(NULL, payload_delim, &playload_parts); if (path == NULL) return -1; char *http_ver = strtok_r(NULL, payload_delim, &playload_parts); if (http_ver != NULL) strncpy(req->http_version_str, http_ver, HTTP_VERSION_STR_MAX_LENGTH); else strcpy(req->http_version_str, DEFAULT_HTTP_VERSION_STR); http_request_parse_uri(req, path); return 0; }
static void issue_calls (Sess *sess, Sess_Private_Data *priv) { int i, to_create, retval, embedded = 0; Call_Private_Data *cpriv; struct uri_list *el; Call *call; /* Mimic browser behavior of fetching html object, then a couple of embedded objects: */ to_create = 1; if (priv->num_created > 0) { to_create = session_max_qlen (sess) - session_current_qlen (sess); embedded = 1; } for (i = 0; i < to_create && (!embedded || priv->uri_list); ++i) { ++priv->num_created; call = call_new (); if (!call) { sess_failure (sess); return; } if (embedded) { el = priv->uri_list; priv->uri_list = el->next; cpriv = CALL_PRIVATE_DATA (call); cpriv->to_free = el; call_set_uri (call, el->uri, el->uri_len); } if (verbose > 1) printf ("%s: fetching `%s'\n", prog_name, (char *)call->req.iov[IE_URI].iov_base); retval = session_issue_call (sess, call); call_dec_ref (call); if (retval < 0) return; } }
static void check_pred8x8(H264PredContext *h, uint8_t *buf0, uint8_t *buf1, int codec, int chroma_format, int bit_depth) { int pred_mode; for (pred_mode = 0; pred_mode < 11; pred_mode++) { if (check_pred_func(h->pred8x8[pred_mode], (chroma_format == 2) ? "8x16" : "8x8", pred8x8_modes[codec][pred_mode])) { randomize_buffers(); call_ref(src0, (ptrdiff_t)24*SIZEOF_PIXEL); call_new(src1, (ptrdiff_t)24*SIZEOF_PIXEL); if (memcmp(buf0, buf1, BUF_SIZE)) fail(); bench_new(src1, (ptrdiff_t)24*SIZEOF_PIXEL); } } }
static void check_pred16x16(H264PredContext *h, uint8_t *buf0, uint8_t *buf1, int codec, int chroma_format, int bit_depth) { if (chroma_format == 1) { int pred_mode; for (pred_mode = 0; pred_mode < 9; pred_mode++) { if (check_pred_func(h->pred16x16[pred_mode], "16x16", pred16x16_modes[codec][pred_mode])) { randomize_buffers(); call_ref(src0, (ptrdiff_t)48); call_new(src1, (ptrdiff_t)48); if (memcmp(buf0, buf1, BUF_SIZE)) fail(); bench_new(src1, (ptrdiff_t)48); } } } }
static void check_pred4x4(H264PredContext *h, uint8_t *buf0, uint8_t *buf1, int codec, int chroma_format, int bit_depth) { if (chroma_format == 1) { uint8_t *topright = buf0 + 2*16; int pred_mode; for (pred_mode = 0; pred_mode < 15; pred_mode++) { if (check_pred_func(h->pred4x4[pred_mode], "4x4", pred4x4_modes[codec][pred_mode])) { randomize_buffers(); call_ref(src0, topright, (ptrdiff_t)12*SIZEOF_PIXEL); call_new(src1, topright, (ptrdiff_t)12*SIZEOF_PIXEL); if (memcmp(buf0, buf1, BUF_SIZE)) fail(); bench_new(src1, topright, (ptrdiff_t)12*SIZEOF_PIXEL); } } } }
bool toxav_call(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, TOXAV_ERR_CALL *error) { TOXAV_ERR_CALL rc = TOXAV_ERR_CALL_OK; pthread_mutex_lock(av->mutex); if ((audio_bit_rate && audio_bit_rate_invalid(audio_bit_rate)) || (video_bit_rate && video_bit_rate_invalid(video_bit_rate))) { rc = TOXAV_ERR_CALL_INVALID_BIT_RATE; goto END; } ToxAVCall *call = call_new(av, friend_number, error); if (call == NULL) { rc = TOXAV_ERR_CALL_MALLOC; goto END; } call->audio_bit_rate = audio_bit_rate; call->video_bit_rate = video_bit_rate; call->previous_self_capabilities = msi_CapRAudio | msi_CapRVideo; call->previous_self_capabilities |= audio_bit_rate > 0 ? msi_CapSAudio : 0; call->previous_self_capabilities |= video_bit_rate > 0 ? msi_CapSVideo : 0; if (msi_invite(av->msi, &call->msi_call, friend_number, call->previous_self_capabilities) != 0) { call_remove(call); rc = TOXAV_ERR_CALL_SYNC; goto END; } call->msi_call->av_call = call; END: pthread_mutex_unlock(av->mutex); if (error) *error = rc; return rc == TOXAV_ERR_CALL_OK; }
static void check_qpel(HEVCDSPContext *h, int16_t *dst0, int16_t *dst1, uint8_t *src, int16_t *mcbuffer, int bit_depth) { int i, j, k, l, mx, my; declare_func(void, int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my, int16_t *mcbuffer); randomize_buffers(src, BUF_SIZE, bit_depth); memset(dst0, 0, BUF_SIZE * sizeof(*dst0)); memset(dst1, 0, BUF_SIZE * sizeof(*dst1)); for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { for (k = 0; k < FF_ARRAY_ELEMS(h->put_hevc_qpel[i][j]); k++) { int width = pred_widths[k]; int dststride = FFALIGN(width, 16) * sizeof(*dst0); int srcstride = FFALIGN(width + 7, 8) * PIXEL_SIZE(bit_depth); if (!check_func(h->put_hevc_qpel[i][j][k], "qpel_%s_%d_%d", interp_names[i][j], width, bit_depth)) continue; for (l = 0; l < FF_ARRAY_ELEMS(pred_heights[0]); l++) { int height = pred_heights[width][l]; if (!height) continue; for (my = i; my < (i ? 2 : 1); my++) for (mx = j; mx < (j ? 2 : 1); mx++) { call_ref(dst0, dststride, src + 3 * srcstride + 3 * PIXEL_SIZE(bit_depth), srcstride, height, mx, my, mcbuffer); call_new(dst1, dststride, src + 3 * srcstride + 3 * PIXEL_SIZE(bit_depth), srcstride, height, mx, my, mcbuffer); if (memcmp(dst0, dst1, dststride * height * sizeof(*dst0))) fail(); bench_new(dst1, dststride, src + 3 * srcstride + 3 * PIXEL_SIZE(bit_depth), srcstride, height, mx, my, mcbuffer); } } } } } }
void sipomatic_process_event(Sipomatic *obj,eXosip_event_t *ev) { Call *call; switch(ev->type){ case EXOSIP_CALL_INVITE: call_new(obj,ev); break; case EXOSIP_CALL_CLOSED: case EXOSIP_CALL_CANCELLED: call=sipomatic_find_call(obj,ev->did); if (call==NULL){ ms_warning("Could not find call with did %i !",ev->did); } call_release(call); call_destroy(call); break; default: break; } eXosip_event_free(ev); }
static void issue_calls (Sess *sess, Sess_Private_Data *priv) { int retval; const char *method_str; Call *call; REQ *req; call = call_new (); if (!call) { sess_failure (sess); return; } req = priv->current_req; if (req == NULL) panic ("%s: internal error, requests ran past end of session\n", prog_name); method_str = call_method_name[req->method]; call_set_method (call, method_str, strlen (method_str)); call_set_uri (call, req->uri, req->uri_len); if (req->contents_len > 0) { /* add "Content-length:" header and contents, if necessary: */ call_append_request_header (call, req->extra_hdrs, req->extra_hdrs_len); call_set_contents (call, req->contents, req->contents_len); } if (DBG > 0) fprintf (stderr, "%s: accessing URI `%s'\n", prog_name, req->uri); retval = session_issue_call (sess, call); call_dec_ref (call); if (retval < 0) return; }
int http_response_write(array_queue *equeue, int err, void *arg, call *next) { http_response *res = (http_response*)arg; next->arg = res; if (res->output_buffer_written == 0) { sprintf(res->output_buffer, "%s %d Raccoon\r\n", res->http_version_str, res->status_code); list_iterator *it = list_get_iterator(&res->headers); http_header *header; while ((header = list_iterate(it)) != NULL) { strcat(res->output_buffer, header->name); strcat(res->output_buffer, ":"); strcat(res->output_buffer, header->value); strcat(res->output_buffer, "\r\n"); } strcat(res->output_buffer, "\r\n"); } int output_buffer_len = strlen(res->output_buffer); int witten = write(res->client_sockfd, res->output_buffer, output_buffer_len); if (witten > 0) res->output_buffer_written += witten; if ((witten == -1 && errno == EAGAIN) || (witten > 0 && res->output_buffer_written < output_buffer_len)) { array_queue_push(equeue, call_new(&http_response_write, res, next)); return 1; } else if (witten == -1) { return -2; } if (res->body_data != NULL && &res->response_body_writer != NULL) res->response_body_writer(res->client_sockfd, res->body_data); return 0; }
static void check_idct_dc(HEVCDSPContext h, int bit_depth) { int i; LOCAL_ALIGNED(32, int16_t, coeffs0, [32 * 32]); LOCAL_ALIGNED(32, int16_t, coeffs1, [32 * 32]); for (i = 2; i <= 5; i++) { int block_size = 1 << i; int size = block_size * block_size; declare_func_emms(AV_CPU_FLAG_MMXEXT, void, int16_t *coeffs); randomize_buffers(coeffs0, size); memcpy(coeffs1, coeffs0, sizeof(*coeffs0) * size); if (check_func(h.idct_dc[i - 2], "idct_%dx%d_dc_%d", block_size, block_size, bit_depth)) { call_ref(coeffs0); call_new(coeffs1); if (memcmp(coeffs0, coeffs1, sizeof(*coeffs0) * size)) fail(); bench_new(coeffs1); } } }
static void test_fcmul_add(const float *src0, const float *src1, const float *src2) { LOCAL_ALIGNED_32(float, cdst, [LEN*2+8]); LOCAL_ALIGNED_32(float, odst, [LEN*2+8]); int i; declare_func(void, float *sum, const float *t, const float *c, ptrdiff_t len); memcpy(cdst, src0, (LEN*2+8) * sizeof(float)); memcpy(odst, src0, (LEN*2+8) * sizeof(float)); call_ref(cdst, src1, src2, LEN); call_new(odst, src1, src2, LEN); for (i = 0; i <= LEN*2; i++) { if (!float_near_abs_eps(cdst[i], odst[i], FLT_EPSILON)) { fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", i, cdst[i], odst[i], cdst[i] - odst[i]); fail(); break; } } memcpy(odst, src0, (LEN*2+8) * sizeof(float)); bench_new(odst, src1, src2, LEN); }
static void issue_calls (Sess *sess, Sess_Private_Data *priv) { int i, to_create, retval, n; const char *method_str; Call *call; REQ *req; /* Mimic browser behavior of fetching html object, then a couple of embedded objects: */ to_create = 1; if (priv->num_calls_in_this_burst > 0) { to_create = priv->current_burst->num_reqs - priv->num_calls_in_this_burst; } n = session_max_qlen (sess) - session_current_qlen (sess); if (n < to_create) { to_create = n; } priv->num_calls_in_this_burst += to_create; for (i = 0; i < to_create; ++i) { call = call_new (); if (!call) { sess_failure (sess); return; } /* fill in the new call: */ req = priv->current_req; if (req == NULL) { panic ("%s: internal error, requests ran past end of burst\n",prog_name); } call_set_version (call, priv->http_version); method_str = call_method_name[req->method]; call_set_method (call, method_str, strlen (method_str)); call_set_uri (call, req->uri, req->uri_len); #ifdef UW_DYNOUT call->timelimit = req->timelimit; #endif /* UW_DYNOUT */ /* used for call stats */ call->file_size = req->file_size; if (req->cookie_len > 0) { /* add "Cookie:" header if necessary: */ call_append_request_header (call, req->cookie, req->cookie_len); } #ifdef WSESSLOG_HEADERS if (req->contents_len > 0 || req->extra_hdrs_len > 0) { /* add "Content-length:" header and contents, if necessary: */ call_append_request_header (call, req->extra_hdrs, req->extra_hdrs_len); if (req->contents_len > 0) { call_set_contents(call, req->contents, req->contents_len); } } #else if (req->extra_hdrs_len > 0) { /* add "Content-length:" header and contents, if necessary: */ call_append_request_header (call, req->extra_hdrs, req->extra_hdrs_len); call_set_contents (call, req->contents, req->contents_len); } #endif /* WSESSLOG_HEADERS */ #ifdef UW_CALL_STATS if (param.client.id >= 0) { sprintf (call->id_hdr, "Client-Id: %d %d\r\n", param.client.id, (int) call->id); call_append_request_header (call, call->id_hdr, strlen(call->id_hdr)); } #endif /* UW_CALL_STATS */ priv->current_req = req->next; if (DBG > 0) { fprintf (stderr, "%s: accessing URI `%s'\n", prog_name, req->uri); } retval = session_issue_call (sess, call); call_dec_ref (call); if (retval < 0) { return; } } }