@@ -318,24 +318,13 @@ int build_advance_av_capture_sys(capture_sys_t *capture_sys)
318318 return 0 ;
319319}
320320
321- int read_all_frames (capture_sys_t * capture_sys , bool dual_sink , int timeout )
321+ void read_with_timeout (capture_sys_t * capture_sys , bool dual_sink , int timeout )
322322{
323323 capture_run_result_t * res = & capture_sys -> run_result ;
324324 memset (res , 0 , sizeof (capture_run_result_t ));
325325 uint32_t start_time = esp_timer_get_time () / 1000 ;
326326 uint32_t cur_time = start_time ;
327327 int sink_num = dual_sink ? 2 : 1 ;
328- if (capture_sys -> capture_sink [0 ]) {
329- esp_capture_sink_enable (capture_sys -> capture_sink [0 ], ESP_CAPTURE_RUN_MODE_ALWAYS );
330- }
331- if (dual_sink && capture_sys -> capture_sink [1 ]) {
332- esp_capture_sink_enable (capture_sys -> capture_sink [1 ], ESP_CAPTURE_RUN_MODE_ALWAYS );
333- }
334- int ret = esp_capture_start (capture_sys -> capture );
335- if (ret != 0 ) {
336- ESP_LOGE (TAG , "Fail to start capture" );
337- return -1 ;
338- }
339328 while (cur_time < start_time + timeout ) {
340329 // Following code acquire frame without wait for all supported sink
341330 for (int i = 0 ; i < sink_num ; i ++ ) {
@@ -345,7 +334,7 @@ int read_all_frames(capture_sys_t *capture_sys, bool dual_sink, int timeout)
345334 while (esp_capture_sink_acquire_frame (capture_sys -> capture_sink [i ], & frame , true) == ESP_CAPTURE_ERR_OK ) {
346335 res -> audio_frame_count [i ]++ ;
347336 if (res -> audio_frame_count [i ] == 1 ) {
348- ESP_LOGI (TAG , "[%d] First audio frame received" , i );
337+ ESP_LOGI (TAG , "[%d] First audio frame received pts %d " , i , ( int ) frame . pts );
349338 }
350339 res -> audio_frame_size [i ] += frame .size ;
351340 res -> audio_pts [i ] = frame .pts ;
@@ -355,7 +344,7 @@ int read_all_frames(capture_sys_t *capture_sys, bool dual_sink, int timeout)
355344 while (esp_capture_sink_acquire_frame (capture_sys -> capture_sink [i ], & frame , true) == ESP_CAPTURE_ERR_OK ) {
356345 res -> video_frame_count [i ]++ ;
357346 if (res -> video_frame_count [i ] == 1 ) {
358- ESP_LOGI (TAG , "[%d] First video frame received" , i );
347+ ESP_LOGI (TAG , "[%d] First video frame received pts %d " , i , ( int ) frame . pts );
359348 }
360349 res -> video_frame_size [i ] += frame .size ;
361350 res -> video_pts [i ] = frame .pts ;
@@ -365,7 +354,7 @@ int read_all_frames(capture_sys_t *capture_sys, bool dual_sink, int timeout)
365354 while (esp_capture_sink_acquire_frame (capture_sys -> capture_sink [i ], & frame , true) == ESP_CAPTURE_ERR_OK ) {
366355 res -> muxer_frame_count [i ]++ ;
367356 if (res -> muxer_frame_count [i ] == 1 ) {
368- ESP_LOGI (TAG , "[%d] First muxed frame received" , i );
357+ ESP_LOGI (TAG , "[%d] First muxed frame received pts %d " , i , ( int ) frame . pts );
369358 }
370359 res -> muxer_frame_size [i ] += frame .size ;
371360 res -> muxer_pts [i ] = frame .pts ;
@@ -375,23 +364,39 @@ int read_all_frames(capture_sys_t *capture_sys, bool dual_sink, int timeout)
375364 vTaskDelay (10 / portTICK_PERIOD_MS );
376365 cur_time = esp_timer_get_time () / 1000 ;
377366 }
378- esp_capture_stop (capture_sys -> capture );
379367
380368 // Show capture results
381369 for (int i = 0 ; i < sink_num ; i ++ ) {
382370 if (res -> audio_frame_count [i ]) {
383- ESP_LOGI (TAG , "Audio Path %d frame_count:%d frame_size:%d pts:%d" , i ,
371+ ESP_LOGW (TAG , "Audio Path %d frame_count:%d frame_size:%d pts:%d" , i ,
384372 res -> audio_frame_count [i ], res -> audio_frame_size [i ], res -> audio_pts [i ]);
385373 }
386374 if (res -> video_frame_count [i ]) {
387- ESP_LOGI (TAG , "Video Path %d frame_count:%d frame_size:%d pts:%d" , i ,
375+ ESP_LOGW (TAG , "Video Path %d frame_count:%d frame_size:%d pts:%d" , i ,
388376 res -> video_frame_count [i ], res -> video_frame_size [i ], res -> video_pts [i ]);
389377 }
390378 if (res -> muxer_frame_count [i ]) {
391- ESP_LOGI (TAG , "Muxer Path %d frame_count:%d frame_size:%d pts:%d" , i ,
379+ ESP_LOGW (TAG , "Muxer Path %d frame_count:%d frame_size:%d pts:%d" , i ,
392380 res -> muxer_frame_count [i ], res -> muxer_frame_size [i ], res -> muxer_pts [i ]);
393381 }
394382 }
383+ }
384+
385+ int read_all_frames (capture_sys_t * capture_sys , bool dual_sink , int timeout )
386+ {
387+ if (capture_sys -> capture_sink [0 ]) {
388+ esp_capture_sink_enable (capture_sys -> capture_sink [0 ], ESP_CAPTURE_RUN_MODE_ALWAYS );
389+ }
390+ if (dual_sink && capture_sys -> capture_sink [1 ]) {
391+ esp_capture_sink_enable (capture_sys -> capture_sink [1 ], ESP_CAPTURE_RUN_MODE_ALWAYS );
392+ }
393+ int ret = esp_capture_start (capture_sys -> capture );
394+ if (ret != 0 ) {
395+ ESP_LOGE (TAG , "Fail to start capture" );
396+ return -1 ;
397+ }
398+ read_with_timeout (capture_sys , dual_sink , timeout );
399+ esp_capture_stop (capture_sys -> capture );
395400 return 0 ;
396401}
397402
0 commit comments