27 #include <UnitTest++/UnitTest++.h> 41 #include <libcjson/cJSON.h> 43 #include <libavcodec/avcodec.h> 44 #include <libavutil/opt.h> 45 #include <libavutil/imgutils.h> 46 #include <libmediaprocsutils/log.h> 47 #include <libmediaprocsutils/check_utils.h> 48 #include <libmediaprocsutils/stat_codes.h> 49 #include <libmediaprocsutils/fifo.h> 50 #include <libmediaprocs/proc_if.h> 51 #include <libmediaprocs/procs.h> 52 #include <libmediaprocs/procs_api_http.h> 53 #include <libmediaprocs/proc.h> 54 #include "../src/ffmpeg_x264.h" 55 #include "../src/ffmpeg_m2v.h" 56 #include "../src/ffmpeg_mp3.h" 57 #include "../src/ffmpeg_lhe.h" 60 #define SQR(x) ((x)*(x)) 62 #define LISTENING_PORT "8088" 63 #define LISTENING_HOST "127.0.0.1" 64 #define TEST_DURATION_SEC 8 65 #define MIN_PSNR_VAL 40 66 #define OUTPUT_FILE_VIDEO "/tmp/out.yuv" 67 #define OUTPUT_FILE_AUDIO "/tmp/out.wav" 68 #define MEDIA_TYPE_VIDEO 0 69 #define MEDIA_TYPE_AUDIO 1 71 #define VIDEO_WIDTH "352" 72 #define VIDEO_HEIGHT "288" 74 #define SETTINGS_SAMPLE_RATE "44100" // [samples/second] 75 #define SETTINGS_AUDIO_BITRATE "128000" // [bits/second] 77 #define RESPONSE_BUF_SIZE 512*1024 93 static const char *test_settings_patterns[][2][2]=
98 "bit_rate_output=500000" 99 "&frame_rate_output=25" 100 "&width_output="VIDEO_WIDTH
"&height_output="VIDEO_HEIGHT
102 "&conf_preset=medium" 105 "\"bit_rate_output\":500000," 106 "\"frame_rate_output\":25," 107 "\"width_output\":"VIDEO_WIDTH
"," 108 "\"height_output\":"VIDEO_HEIGHT
"," 110 "\"conf_preset\":\"medium\"" 113 "bit_rate_output=64000" 114 "&sample_rate_output=44100" 116 "\"bit_rate_output\":64000," 117 "\"sample_rate_output\":44100" 122 "bit_rate_output=300000" 123 "&frame_rate_output=25" 124 "&width_output="VIDEO_WIDTH
"&height_output="VIDEO_HEIGHT
128 "\"bit_rate_output\":300000," 129 "\"frame_rate_output\":25," 130 "\"width_output\":"VIDEO_WIDTH
"," 131 "\"height_output\":"VIDEO_HEIGHT
"," 133 "\"conf_preset\":\"fast\"" 136 "bit_rate_output=80000" 137 "&sample_rate_output=44100" 139 "\"bit_rate_output\":80000," 140 "\"sample_rate_output\":44100" 145 "bit_rate_output=700000" 146 "&frame_rate_output=25" 147 "&width_output="VIDEO_WIDTH
"&height_output="VIDEO_HEIGHT
149 "&conf_preset=medium" 151 "\"bit_rate_output\":700000," 152 "\"frame_rate_output\":25," 153 "\"width_output\":"VIDEO_WIDTH
"," 154 "\"height_output\":"VIDEO_HEIGHT
"," 156 "\"conf_preset\":\"medium\"" 159 "bit_rate_output=64000" 160 "&sample_rate_output=48000" 162 "\"bit_rate_output\":64000," 163 "\"sample_rate_output\":48000" 177 volatile int flag_exit;
178 volatile int flag_http_server_running;
179 int enc_proc_id, dec_proc_id;
186 volatile int flag_exit;
187 const char *ref_response_str;
191 static void http_client_event_handler(
struct mg_connection *nc,
int ev,
193 struct http_message *hm= (
struct http_message*)ev_data;
199 connect_status= *(
int*)ev_data;
200 if (connect_status!= 0) {
201 printf(
"Error in HTTP connection: %s\n", strerror(connect_status));
205 case MG_EV_HTTP_REPLY:
206 if(hm->body.len> 0 && hm->body.p!= NULL) {
209 if(hm->body.len< RESPONSE_BUF_SIZE) {
210 memcpy((
void*)data->ref_response_str, hm->body.p, hm->body.len);
212 fprintf(stderr,
"Message too big!'%s()'\n", __FUNCTION__);
216 nc->flags|= MG_F_SEND_AND_CLOSE;
227 static char* http_client_request(
const char *method,
const char *url,
228 const char *qstring,
const char *content)
232 struct mg_connection *nc;
233 struct mg_connect_opts opts;
234 const char *error_str= NULL;
235 char response_buf[RESPONSE_BUF_SIZE]= {0};
241 if(method== NULL || url== NULL) {
242 fprintf(stderr,
"Bad argument '%s()'\n", __FUNCTION__);
246 memset(&opts, 0,
sizeof(opts));
247 opts.error_string= &error_str;
248 opts.user_data= &ev_user_data;
250 mg_mgr_init(&mgr, NULL);
251 nc= mg_connect_opt(&mgr, LISTENING_HOST
":"LISTENING_PORT,
252 http_client_event_handler, opts);
254 fprintf(stderr,
"mg_connect(%s:%s) failed: %s\n", LISTENING_HOST,
255 LISTENING_PORT, error_str);
258 mg_set_protocol_http_websocket(nc);
260 mg_printf(nc,
"%s %s%s%s HTTP/1.0\r\n", method, url, qstring?
"?":
"",
261 qstring? qstring:
"");
262 if(content!= NULL && (content_size= strlen(content))> 0) {
263 mg_printf(nc,
"Content-Length: %d\r\n", (
int)content_size);
264 mg_printf(nc,
"\r\n");
265 mg_printf(nc,
"%s", content);
267 mg_printf(nc,
"\r\n");
270 while(ev_user_data.flag_exit== 0)
271 mg_mgr_poll(&mgr, 1000);
277 return strlen(response_buf)> 0? strdup(response_buf): NULL;
280 static void http_event_handler(
struct mg_connection *c,
int ev,
void *p)
282 if(ev== MG_EV_RECV) {
283 mg_printf(c,
"%s",
"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
285 }
else if(ev == MG_EV_HTTP_REQUEST) {
286 register size_t uri_len= 0, method_len= 0, qs_len= 0, body_len= 0;
287 const char *uri_p, *method_p, *qs_p, *body_p;
288 struct http_message *hm= (
struct http_message*)p;
289 char *url_str= NULL, *method_str= NULL, *str_response= NULL,
290 *qstring_str= NULL, *body_str= NULL;
293 if((uri_p= hm->uri.p)!= NULL && (uri_len= hm->uri.len)> 0) {
294 url_str= (
char*)calloc(1, uri_len+ 1);
295 memcpy(url_str, uri_p, uri_len);
297 if((method_p= hm->method.p)!= NULL && (method_len= hm->method.len)> 0) {
298 method_str= (
char*)calloc(1, method_len+ 1);
299 memcpy(method_str, method_p, method_len);
301 if((qs_p= hm->query_string.p)!= NULL &&
302 (qs_len= hm->query_string.len)> 0) {
303 qstring_str= (
char*)calloc(1, qs_len+ 1);
304 memcpy(qstring_str, qs_p, qs_len);
306 if((body_p= hm->body.p)!= NULL && (body_len= hm->body.len)> 0) {
307 body_str= (
char*)calloc(1, body_len+ 1);
308 memcpy(body_str, body_p, body_len);
313 method_str, body_str, body_len, &str_response);
316 mg_printf(c,
"%s",
"HTTP/1.1 200 OK\r\n");
317 if(str_response!= NULL && strlen(str_response)> 0) {
320 mg_printf(c,
"Content-Length: %d\r\n", (
int)strlen(str_response));
321 mg_printf(c,
"\r\n");
322 mg_printf(c,
"%s", str_response);
324 mg_printf(c,
"Content-Length: %d\r\n", 0);
327 if(str_response!= NULL)
331 if(method_str!= NULL)
333 if(qstring_str!= NULL)
346 struct mg_connection *c;
348 const char *listening_port= LISTENING_PORT;
349 struct mg_bind_opts opts;
350 const char *error_str= NULL;
354 fprintf(stderr,
"Bad argument 'enc_dec_thr()'\n");
359 mg_mgr_init(&mgr, NULL);
361 memset(&opts, 0,
sizeof(opts));
362 opts.error_string= &error_str;
363 opts.user_data= thr_ctx;
364 c= mg_bind_opt(&mgr, listening_port, http_event_handler, opts);
366 fprintf(stderr,
"mg_bind_opt(%s:%s) failed: %s\n", LISTENING_HOST,
367 LISTENING_PORT, error_str);
370 mg_set_protocol_http_websocket(c);
374 fprintf(stderr,
"Bad argument 'enc_dec_thr()'\n");
378 while(thr_ctx->flag_exit== 0) {
379 mg_mgr_poll(&mgr, 1000);
380 thr_ctx->flag_http_server_running= 1;
397 fprintf(stderr,
"Bad argument '%s()'\n", __FUNCTION__);
401 while(thr_ctx->flag_exit== 0) {
405 if(proc_frame_ctx!= NULL)
409 if(ret_code!= STAT_SUCCESS) {
410 if(ret_code== STAT_EAGAIN)
413 fprintf(stderr,
"Error while encoding frame'\n");
418 CHECK(proc_frame_ctx!= NULL);
421 if(ret_code!= STAT_SUCCESS) {
422 if(ret_code== STAT_EAGAIN)
425 fprintf(stderr,
"Error while decoding frame'\n");
430 if(proc_frame_ctx!= NULL)
435 static void check_psnr(
int width,
int height, uint8_t *frame_original,
436 uint8_t *frame_processed,
int min_psnr_val)
438 int i, y, x, pos_offset= 0;
439 int size= height* width;
440 double signal=0.0, noise=0.0, peak=0.0, mse;
443 if(frame_original== NULL || frame_processed== NULL) {
449 for(i= 0; i< 3; i++) {
450 int w= width>>(i!= 0), h= height>>(i!= 0);
451 for(y= 0; y< h; y++) {
452 for(x= 0; x< w; x++) {
453 int pos= pos_offset+ y* w+ x;
454 signal+= SQR((
double)frame_original[pos]);
455 noise+= SQR((
double)frame_original[pos]-
456 (
double)frame_processed[pos]);
457 if(peak< (
double)frame_original[pos])
458 peak= (double)frame_original[pos];
464 mse= noise/(double)size;
465 psnr1= 10.0*log10(SQR(255.0)/mse);
468 CHECK(psnr1> min_psnr_val);
469 if(psnr1<= min_psnr_val)
470 printf(
"PSNR(max=255): %lf (dB)\n", psnr1);
475 FILE **ref_file,
int min_psnr_val)
478 int w_Y, h_Y, i, y, x, pos_dst_offset= 0;
479 uint8_t *frame_original= NULL, *frame_encdec= NULL;
482 if(proc_frame_ctx== NULL || ref_file== NULL)
485 w_Y= proc_frame_ctx->
width[0];
486 h_Y= proc_frame_ctx->
height[0];
487 frame_original= (uint8_t*)malloc((w_Y* h_Y* 3)>> 1);
488 frame_encdec= (uint8_t*)malloc((w_Y* h_Y* 3)>> 1);
489 if(frame_original== NULL || frame_encdec== NULL)
492 pts= proc_frame_ctx->
pts;
493 for(i= 0; i< 3; i++) {
494 int w= proc_frame_ctx->
width[i];
495 int h= proc_frame_ctx->
height[i];
496 int stride= proc_frame_ctx->
linesize[i];
497 for(y= 0; y< h; y++) {
498 for(x= 0; x< w; x++) {
499 int pos_src= y* stride+ x;
500 int pos_dst= pos_dst_offset+ y* w+ x;
501 int dec_val= proc_frame_ctx->
p_data[i][pos_src];
502 int orig_val= (i== 0)? (x+ y+ pts* 3)& 0xFF:
503 (i== 1)? (128+ y+ pts* 2)& 0xFF:
504 (64+ x+ pts* 5)& 0xFF;
507 frame_original[pos_dst]= orig_val;
508 frame_encdec[pos_dst]= dec_val;
511 pos_dst_offset+= h* w;
514 check_psnr(proc_frame_ctx->
width[0], proc_frame_ctx->
height[0],
515 frame_original, frame_encdec, min_psnr_val);
518 static FILE *file_raw= NULL;
519 if(file_raw== NULL) {
520 if((file_raw= fopen(
"/tmp/out_raw.yuv",
"wb"))== NULL) {
521 fprintf(stderr,
"Could not open %s\n",
"/tmp/out_raw.yuv");
525 fwrite(frame_original, 1, pos_dst_offset, file_raw);
527 if(*ref_file== NULL) {
528 if((*ref_file= fopen(OUTPUT_FILE_VIDEO,
"wb"))== NULL) {
529 fprintf(stderr,
"Could not open %s\n", OUTPUT_FILE_VIDEO);
533 fwrite(frame_encdec, 1, pos_dst_offset, *ref_file);
537 if(frame_original!= NULL) {
538 free(frame_original);
539 frame_original= NULL;
541 if(frame_encdec!= NULL) {
548 FILE **ref_file,
int min_psnr_val)
551 if(proc_frame_ctx== NULL || ref_file== NULL)
556 if(*ref_file== NULL) {
557 if((*ref_file= fopen(OUTPUT_FILE_AUDIO,
"wb"))== NULL) {
558 fprintf(stderr,
"Could not open %s\n", OUTPUT_FILE_AUDIO);
563 fwrite(proc_frame_ctx->
p_data[0], 1, proc_frame_ctx->
width[0], *ref_file);
567 static void* consumer_thr(
void *t)
576 fprintf(stderr,
"Bad argument 'consumer_thr()'\n");
581 switch(thr_ctx->media_type) {
582 case MEDIA_TYPE_VIDEO:
583 treat_output_frame= treat_output_frame_video;
585 case MEDIA_TYPE_AUDIO:
586 treat_output_frame= treat_output_frame_audio;
593 while(thr_ctx->flag_exit== 0) {
597 if(proc_frame_ctx!= NULL)
601 if(ret_code!= STAT_SUCCESS) {
602 if(ret_code== STAT_EAGAIN)
605 fprintf(stderr,
"Error while receiving decoded frame'\n");
608 CHECK(proc_frame_ctx!= NULL);
611 if(proc_frame_ctx!= NULL && treat_output_frame!= NULL)
612 treat_output_frame(proc_frame_ctx, &file, thr_ctx->min_psnr_val);
615 if(proc_frame_ctx!= NULL)
622 static void prepare_and_send_raw_video_data(
procs_ctx_t *procs_ctx,
623 int enc_proc_id,
volatile int *ref_flag_exit)
625 uint8_t *p_data_y, *p_data_cr, *p_data_cb;
626 int64_t frame_period_usec, frame_period_90KHz;
628 const int width= atoi(VIDEO_WIDTH), height= atoi(VIDEO_HEIGHT);
631 const char *fps_cstr=
"30";
634 buf= (uint8_t*)malloc((width* height* 3)/ 2);
639 proc_frame_ctx.
data= buf;
640 proc_frame_ctx.
p_data[0]= buf;
641 proc_frame_ctx.
p_data[1]= proc_frame_ctx.
p_data[0]+ (width* height);
642 proc_frame_ctx.
p_data[2]= proc_frame_ctx.
p_data[1]+ ((width* height)/4);
644 proc_frame_ctx.
width[1]= proc_frame_ctx.
linesize[1]= width>> 1;
645 proc_frame_ctx.
width[2]= proc_frame_ctx.
linesize[2]= width>> 1;
646 proc_frame_ctx.
height[0]= height;
647 proc_frame_ctx.
height[1]= height>> 1;
648 proc_frame_ctx.
height[2]= height>> 1;
652 p_data_y= (uint8_t*)proc_frame_ctx.
p_data[0];
653 p_data_cr= (uint8_t*)proc_frame_ctx.
p_data[1];
654 p_data_cb= (uint8_t*)proc_frame_ctx.
p_data[2];
655 frame_period_usec= 1000000/ atoi(fps_cstr);
656 frame_period_90KHz= (frame_period_usec/1000)*
658 for(; *ref_flag_exit== 0;) {
660 usleep((
unsigned int)frame_period_usec);
661 proc_frame_ctx.
pts+= frame_period_90KHz;
664 for(y= 0; y< height; y++)
665 for(x= 0; x< width; x++)
666 p_data_y[y* proc_frame_ctx.
linesize[0]+ x]= x+ y+
667 proc_frame_ctx.
pts* 3;
669 for(y= 0; y< height>> 1; y++) {
670 for(x= 0; x< width>> 1; x++) {
671 p_data_cr[y* proc_frame_ctx.
linesize[1]+ x]= 128+ y+
672 proc_frame_ctx.
pts* 2;
673 p_data_cb[y* proc_frame_ctx.
linesize[2]+ x]= 64+ x+
674 proc_frame_ctx.
pts* 5;
689 static void prepare_and_send_raw_audio_data(
procs_ctx_t *procs_ctx,
690 int enc_proc_id,
volatile int *ref_flag_exit)
692 float sin_time, tincr;
693 int64_t frame_period_usec, frame_period_90KHz;
694 int frame_size_bytes, frame_size_samples, ret_code;
695 char *rest_str= NULL;
696 cJSON *cjson_rest= NULL, *cjson_aux= NULL;
699 const char *sample_rate_cstr= SETTINGS_SAMPLE_RATE;
704 ret_code=
procs_opt(procs_ctx,
"PROCS_ID_GET", enc_proc_id, &rest_str);
705 if(ret_code!= STAT_SUCCESS || rest_str== NULL) {
710 if((cjson_rest= cJSON_Parse(rest_str))== NULL) {
714 if((cjson_aux= cJSON_GetObjectItem(cjson_rest,
715 "expected_frame_size_iput"))== NULL) {
719 CHECK((frame_size_bytes= cjson_aux->valuedouble*
sizeof(uint16_t))>= 0);
720 free(rest_str); rest_str= NULL;
721 cJSON_Delete(cjson_rest); cjson_rest= NULL;
724 buf= (uint8_t*)malloc(frame_size_bytes* 2);
726 fprintf(stderr,
"Could not allocate raw image buffer\n");
730 frame_size_samples= frame_size_bytes>> 1;
731 proc_frame_ctx.
data= buf;
732 proc_frame_ctx.
p_data[0]= buf;
733 proc_frame_ctx.
p_data[1]= buf+ frame_size_bytes;
734 proc_frame_ctx.
width[0]= proc_frame_ctx.
linesize[0]= frame_size_bytes;
735 proc_frame_ctx.
width[1]= proc_frame_ctx.
linesize[1]= frame_size_bytes;
736 proc_frame_ctx.
height[0]= 1;
737 proc_frame_ctx.
height[1]= 1;
739 proc_frame_ctx.
pts= 0;
742 frame_period_usec= (1000000* frame_size_samples)/
743 atoi(sample_rate_cstr);
744 frame_period_90KHz= (frame_period_usec/1000)*
747 tincr= 2* M_PI* 440.0/ atoi(sample_rate_cstr);
748 for(; *ref_flag_exit== 0;) {
750 uint16_t *samples= (uint16_t*)proc_frame_ctx.
data;
752 usleep((
unsigned int)frame_period_usec);
753 proc_frame_ctx.
pts+= frame_period_90KHz;
755 for(j= 0; j< frame_size_samples; j++, sin_time+= tincr) {
756 int sample_val= (int)(sin(sin_time)* 10000);
757 samples[j]= sample_val;
758 samples[j+ frame_size_samples]= sample_val;
767 if(cjson_rest!= NULL)
768 cJSON_Delete(cjson_rest);
775 static void* producer_thr(
void *t)
778 void(*prepare_and_send_raw_data)(
procs_ctx_t *procs_ctx,
int enc_proc_id,
779 volatile int *ref_flag_exit)= NULL;
783 fprintf(stderr,
"Bad argument 'consumer_thr()'\n");
788 switch(thr_ctx->media_type) {
789 case MEDIA_TYPE_VIDEO:
790 prepare_and_send_raw_data= prepare_and_send_raw_video_data;
792 case MEDIA_TYPE_AUDIO:
793 prepare_and_send_raw_data= prepare_and_send_raw_audio_data;
800 while(thr_ctx->flag_exit== 0) {
802 prepare_and_send_raw_data(thr_ctx->procs_ctx, thr_ctx->enc_proc_id,
803 &thr_ctx->flag_exit);
809 static void encdec_loopback(
const proc_if_t *proc_if_enc,
810 const proc_if_t *proc_if_dec,
int media_type,
int min_psnr_val)
812 pthread_t producer_thread, enc_dec_thread, consumer_thread,
814 int ret_code, enc_proc_id= -1, dec_proc_id= -1;
816 char *rest_str= NULL, *settings_str= NULL;
817 cJSON *cjson_rest= NULL, *cjson_aux= NULL;
820 if(proc_if_enc== NULL || proc_if_dec== NULL) {
821 fprintf(stderr,
"%s %d Bad arguments.\n", __FILE__, __LINE__);
829 avcodec_register_all();
833 if(ret_code!= STAT_SUCCESS) {
840 if(ret_code!= STAT_SUCCESS) {
845 if(ret_code!= STAT_SUCCESS) {
852 if(procs_ctx== NULL) {
860 if(ret_code!= STAT_SUCCESS || rest_str== NULL) {
866 if((cjson_rest= cJSON_Parse(rest_str))== NULL) {
870 if((cjson_aux= cJSON_GetObjectItem(cjson_rest,
"proc_id"))== NULL) {
874 CHECK((enc_proc_id= cjson_aux->valuedouble)>= 0);
875 free(rest_str); rest_str= NULL;
876 cJSON_Delete(cjson_rest); cjson_rest= NULL;
881 if(ret_code!= STAT_SUCCESS || rest_str== NULL) {
887 if((cjson_rest= cJSON_Parse(rest_str))== NULL) {
891 if((cjson_aux= cJSON_GetObjectItem(cjson_rest,
"proc_id"))== NULL) {
895 CHECK((dec_proc_id= cjson_aux->valuedouble)>= 0);
896 free(rest_str); rest_str= NULL;
897 cJSON_Delete(cjson_rest); cjson_rest= NULL;
900 thr_ctx.flag_exit= 0;
901 thr_ctx.flag_http_server_running= 0;
902 thr_ctx.enc_proc_id= enc_proc_id;
903 thr_ctx.dec_proc_id= dec_proc_id;
904 thr_ctx.media_type= media_type;
905 thr_ctx.min_psnr_val= min_psnr_val;
906 thr_ctx.procs_ctx= procs_ctx;
907 ret_code= pthread_create(&producer_thread, NULL, producer_thr, &thr_ctx);
912 ret_code= pthread_create(&enc_dec_thread, NULL,
enc_dec_thr, &thr_ctx);
917 ret_code= pthread_create(&consumer_thread, NULL, consumer_thr, &thr_ctx);
930 while(thr_ctx.flag_http_server_running!= 1) {
935 for(
int i= 0; test_settings_patterns[i][media_type][0]!= NULL; i++) {
936 char *settings_str_p;
937 const char *query_str= test_settings_patterns[i][media_type][0];
938 const char *json_str= test_settings_patterns[i][media_type][1];
943 printf(
"\nNew settings\n");
944 printf(
"//------------------------//\n"); fflush(stdout);
945 rest_str= http_client_request(
"PUT",
"/procs/0.json", query_str, NULL);
946 if(ret_code!= STAT_SUCCESS) {
950 if(rest_str!= NULL) {
951 free(rest_str); rest_str= NULL;
955 rest_str= http_client_request(
"GET",
"/procs/0.json", NULL,
957 if(ret_code!= STAT_SUCCESS || rest_str== NULL) {
961 if((cjson_rest= cJSON_Parse(rest_str))== NULL) {
965 if((cjson_aux= cJSON_GetObjectItem(cjson_rest,
"data"))== NULL) {
969 if((cjson_aux= cJSON_GetObjectItem(cjson_aux,
"settings"))== NULL) {
973 if(settings_str!= NULL) {
977 if((settings_str= cJSON_PrintUnformatted(cjson_aux))== NULL) {
981 printf(
"Response (settings): '%s'\n", settings_str);
988 settings_str_p= strstr(settings_str,
"\"bit_rate_output\"");
989 CHECK(strncmp(settings_str_p, json_str, strlen(json_str))== 0);
990 free(rest_str); rest_str= NULL;
991 cJSON_Delete(cjson_rest); cjson_rest= NULL;
993 usleep(1000*1000*TEST_DURATION_SEC);
997 thr_ctx.flag_exit= 1;
998 ret_code=
procs_opt(procs_ctx,
"PROCS_ID_DELETE",
1000 CHECK(ret_code== STAT_SUCCESS);
1001 ret_code=
procs_opt(procs_ctx,
"PROCS_ID_DELETE", dec_proc_id);
1002 CHECK(ret_code== STAT_SUCCESS);
1003 pthread_join(producer_thread, NULL);
1004 pthread_join(enc_dec_thread, NULL);
1005 pthread_join(consumer_thread, NULL);
1006 pthread_join(http_server_thread, NULL);
1009 if(procs_ctx!= NULL)
1015 if(settings_str!= NULL)
1017 if(cjson_rest!= NULL)
1018 cJSON_Delete(cjson_rest);
1021 SUITE(UTESTS_ENCODE_DECODE_1)
1023 TEST(ENCODE_DECODE_X264)
1026 MEDIA_TYPE_VIDEO, MIN_PSNR_VAL);
1028 TEST(ENCODE_DECODE_MPEG2_VIDEO)
1031 MEDIA_TYPE_VIDEO, MIN_PSNR_VAL);
1033 TEST(ENCODE_DECODE_MLHE)
1042 TEST(ENCODE_DECODE_MP3)
1045 MEDIA_TYPE_AUDIO, MIN_PSNR_VAL);
size_t width[PROC_FRAME_NUM_DATA_POINTERS]
const proc_if_t proc_if_ffmpeg_mp3_dec
void proc_frame_ctx_release(proc_frame_ctx_t **ref_proc_frame_ctx)
int linesize[PROC_FRAME_NUM_DATA_POINTERS]
struct thr_ctx_s thr_ctx_t
SUITE(UTESTS_LIVE555_RTSP)
int procs_opt(procs_ctx_t *procs_ctx, const char *tag,...)
const proc_if_t proc_if_ffmpeg_x264_enc
const proc_if_t proc_if_ffmpeg_m2v_enc
const proc_if_t proc_if_ffmpeg_mp3_enc
int procs_module_open(log_ctx_t *log_ctx)
int procs_module_opt(const char *tag,...)
int procs_recv_frame(procs_ctx_t *procs_ctx, int proc_id, proc_frame_ctx_t **ref_proc_frame_ctx)
void procs_module_close()
static void * http_server_thr(void *t)
int procs_send_frame(procs_ctx_t *procs_ctx, int proc_id, const proc_frame_ctx_t *proc_frame_ctx)
Planar YUV 4:2:0 with 12bpp (video)
int procs_api_http_req_handler(procs_ctx_t *procs_ctx, const char *url, const char *query_string, const char *request_method, char *content, size_t content_len, char **ref_str_response)
const proc_if_t proc_if_ffmpeg_x264_dec
const proc_if_t proc_if_ffmpeg_m2v_dec
Planar signed 16 bits (typically audio)
size_t height[PROC_FRAME_NUM_DATA_POINTERS]
void procs_close(procs_ctx_t **ref_procs_ctx)
const uint8_t * p_data[PROC_FRAME_NUM_DATA_POINTERS]
procs_ctx_t * procs_open(log_ctx_t *log_ctx, size_t max_procs_num, const char *prefix_name, const char *procs_href)
static void * enc_dec_thr(void *t)