FS-9267 #resolve [Raw decoded image from vpx codec is corrupted by video media bugs that modify the image]
This commit is contained in:
parent
dd5c4a539c
commit
b0be5d6737
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue