]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9267 #resolve [Raw decoded image from vpx codec is corrupted by video media bugs...
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 16 Jun 2016 02:08:46 +0000 (21:08 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 16 Jun 2016 02:09:02 +0000 (21:09 -0500)
src/include/switch_types.h
src/mod/applications/mod_cv/mod_cv.cpp
src/switch_core_media.c
src/switch_vpx.c

index 8279e10a7f463d31b4c329c8ad2abf9f41c2a0c9..527f6e597c07b77c35d2fd687c91959ba515ee2b 100644 (file)
@@ -1627,7 +1627,8 @@ typedef enum {
        SWITCH_CODEC_FLAG_AAL2 = (1 << 6),
        SWITCH_CODEC_FLAG_PASSTHROUGH = (1 << 7),
        SWITCH_CODEC_FLAG_READY = (1 << 8),
-       SWITCH_CODEC_FLAG_HAS_PLC = (1 << 15)
+       SWITCH_CODEC_FLAG_HAS_PLC = (1 << 15),
+       SWITCH_CODEC_FLAG_VIDEO_PATCHING = (1 << 16)
 } switch_codec_flag_enum_t;
 typedef uint32_t switch_codec_flag_t;
 
@@ -1769,7 +1770,8 @@ typedef enum {
        SMBF_WRITE_VIDEO_STREAM = (1 << 20),
        SMBF_VIDEO_PATCH = (1 << 21),
        SMBF_SPY_VIDEO_STREAM = (1 << 22),
-       SMBF_SPY_VIDEO_STREAM_BLEG = (1 << 23)
+       SMBF_SPY_VIDEO_STREAM_BLEG = (1 << 23),
+       SMBF_READ_VIDEO_PATCH = (1 << 24)
 } switch_media_bug_flag_enum_t;
 typedef uint32_t switch_media_bug_flag_t;
 
index 76cf155a6ecd73c2a1670155d7efb4df0e9526cc..ac643a3ff6dd176444c63caab0ee07f61bfaa301 100644 (file)
@@ -1167,7 +1167,7 @@ SWITCH_STANDARD_APP(cv_bug_start_function)
     int x, n;
     char *argv[25] = { 0 };
     int argc;
-       switch_media_bug_flag_t flags = SMBF_READ_VIDEO_PING;
+       switch_media_bug_flag_t flags = SMBF_READ_VIDEO_PING | SMBF_READ_VIDEO_PATCH;
        const char *function = "mod_cv";
 
     if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_cv_bug_"))) {
@@ -1228,7 +1228,7 @@ SWITCH_STANDARD_API(cv_bug_api_function)
     char *nested_cascade_path = NULL;
     char *lbuf = NULL;
     int x, n, i;
-       switch_media_bug_flag_t flags = SMBF_READ_VIDEO_PING;
+       switch_media_bug_flag_t flags = SMBF_READ_VIDEO_PING | SMBF_READ_VIDEO_PATCH;
        const char *function = "mod_cv";
 
     if (zstr(cmd)) {
index 9bed078a58c5fc9a578a7d776059d9a673161394..d909c09ce2c66a8136c01fd5026ffb5bbe7454be 100644 (file)
@@ -11524,6 +11524,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
        switch_io_event_hook_video_read_frame_t *ptr;
        uint32_t loops = 0;
        switch_media_handle_t *smh;
+       int patchers = 0;
                
        switch_assert(session != NULL);
 
@@ -11679,7 +11680,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
                                
 
                                if (bp->callback && switch_test_flag(bp, SMBF_READ_VIDEO_PING)) {
+                                       if (switch_test_flag(bp, SMBF_READ_VIDEO_PATCH)) {
+                                               patchers++;
+                                       }
+
                                        bp->video_ping_frame = *frame;
+
                                        if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ_VIDEO_PING) == SWITCH_FALSE
                                                || (bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL))) {
                                                ok = SWITCH_FALSE;
@@ -11705,7 +11711,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
                }
        }
 
-
+       if (patchers) {
+               switch_set_flag((*frame)->codec, SWITCH_CODEC_FLAG_VIDEO_PATCHING);
+       } else {
+               switch_clear_flag((*frame)->codec, SWITCH_CODEC_FLAG_VIDEO_PATCHING);
+       }
 
        if (status == SWITCH_STATUS_SUCCESS) {
                switch_core_session_video_read_callback(session, *frame);
index ebfe51da9736a9e50b2723928141032881adb959..a6a475f5779cc79d028fb352c8895814851613f1 100644 (file)
@@ -299,6 +299,7 @@ struct vpx_context {
        switch_memory_pool_t *pool;
        switch_buffer_t *pbuffer;
        switch_time_t start_time;
+       switch_image_t *patch_img;
 };
 typedef struct vpx_context vpx_context_t;
 
@@ -1264,6 +1265,12 @@ end:
                switch_set_flag(frame, SFF_WAIT_KEY_FRAME);
        }
 
+       if (frame->img && (codec->flags & SWITCH_CODEC_FLAG_VIDEO_PATCHING)) {
+               switch_img_free(&context->patch_img);
+               switch_img_copy(frame->img, &context->patch_img);
+               frame->img = context->patch_img;
+       }
+
        return status;
 }
 
@@ -1326,6 +1333,9 @@ static switch_status_t switch_vpx_destroy(switch_codec_t *codec)
        vpx_context_t *context = (vpx_context_t *)codec->private_info;
 
        if (context) {
+               
+               switch_img_free(&context->patch_img);
+
                if ((codec->flags & SWITCH_CODEC_FLAG_ENCODE)) {
                        vpx_codec_destroy(&context->encoder);
                }