|
|
@ -285,8 +285,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) |
|
|
|
(LPARAM) videostream_cb); |
|
|
|
(LPARAM) videostream_cb); |
|
|
|
if(!ret) { |
|
|
|
if(!ret) { |
|
|
|
av_log(s, AV_LOG_ERROR, "Could not set video stream callback.\n"); |
|
|
|
av_log(s, AV_LOG_ERROR, "Could not set video stream callback.\n"); |
|
|
|
vfw_read_close(s); |
|
|
|
goto fail_io; |
|
|
|
return AVERROR_IO; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) ctx); |
|
|
|
SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) ctx); |
|
|
@ -300,8 +299,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) |
|
|
|
/* Set video format */ |
|
|
|
/* Set video format */ |
|
|
|
bisize = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0); |
|
|
|
bisize = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0); |
|
|
|
if(!bisize) { |
|
|
|
if(!bisize) { |
|
|
|
vfw_read_close(s); |
|
|
|
goto fail_io; |
|
|
|
return AVERROR_IO; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
bi = av_malloc(bisize); |
|
|
|
bi = av_malloc(bisize); |
|
|
|
if(!bi) { |
|
|
|
if(!bi) { |
|
|
@ -311,8 +309,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) |
|
|
|
ret = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi); |
|
|
|
ret = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi); |
|
|
|
if(!ret) { |
|
|
|
if(!ret) { |
|
|
|
av_free(bi); |
|
|
|
av_free(bi); |
|
|
|
vfw_read_close(s); |
|
|
|
goto fail_io; |
|
|
|
return AVERROR_IO; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dump_bih(s, &bi->bmiHeader); |
|
|
|
dump_bih(s, &bi->bmiHeader); |
|
|
@ -326,8 +323,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) |
|
|
|
if(!ret) { |
|
|
|
if(!ret) { |
|
|
|
av_log(s, AV_LOG_ERROR, "Could not set Video Format.\n"); |
|
|
|
av_log(s, AV_LOG_ERROR, "Could not set Video Format.\n"); |
|
|
|
av_free(bi); |
|
|
|
av_free(bi); |
|
|
|
vfw_read_close(s); |
|
|
|
goto fail_io; |
|
|
|
return AVERROR_IO; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
biCompression = bi->bmiHeader.biCompression; |
|
|
|
biCompression = bi->bmiHeader.biCompression; |
|
|
@ -339,8 +335,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) |
|
|
|
ret = SendMessage(ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP, sizeof(cparms), |
|
|
|
ret = SendMessage(ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP, sizeof(cparms), |
|
|
|
(LPARAM) &cparms); |
|
|
|
(LPARAM) &cparms); |
|
|
|
if(!ret) { |
|
|
|
if(!ret) { |
|
|
|
vfw_read_close(s); |
|
|
|
goto fail_io; |
|
|
|
return AVERROR_IO; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dump_captureparms(s, &cparms); |
|
|
|
dump_captureparms(s, &cparms); |
|
|
@ -356,8 +351,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) |
|
|
|
ret = SendMessage(ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP, sizeof(cparms), |
|
|
|
ret = SendMessage(ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP, sizeof(cparms), |
|
|
|
(LPARAM) &cparms); |
|
|
|
(LPARAM) &cparms); |
|
|
|
if(!ret) { |
|
|
|
if(!ret) { |
|
|
|
vfw_read_close(s); |
|
|
|
goto fail_io; |
|
|
|
return AVERROR_IO; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
codec = st->codec; |
|
|
|
codec = st->codec; |
|
|
@ -382,24 +376,25 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) |
|
|
|
ctx->mutex = CreateMutex(NULL, 0, NULL); |
|
|
|
ctx->mutex = CreateMutex(NULL, 0, NULL); |
|
|
|
if(!ctx->mutex) { |
|
|
|
if(!ctx->mutex) { |
|
|
|
av_log(s, AV_LOG_ERROR, "Could not create Mutex.\n" ); |
|
|
|
av_log(s, AV_LOG_ERROR, "Could not create Mutex.\n" ); |
|
|
|
vfw_read_close(s); |
|
|
|
goto fail_io; |
|
|
|
return AVERROR_IO; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
ctx->event = CreateEvent(NULL, 1, 0, NULL); |
|
|
|
ctx->event = CreateEvent(NULL, 1, 0, NULL); |
|
|
|
if(!ctx->event) { |
|
|
|
if(!ctx->event) { |
|
|
|
av_log(s, AV_LOG_ERROR, "Could not create Event.\n" ); |
|
|
|
av_log(s, AV_LOG_ERROR, "Could not create Event.\n" ); |
|
|
|
vfw_read_close(s); |
|
|
|
goto fail_io; |
|
|
|
return AVERROR_IO; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ret = SendMessage(ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0); |
|
|
|
ret = SendMessage(ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0); |
|
|
|
if(!ret) { |
|
|
|
if(!ret) { |
|
|
|
av_log(s, AV_LOG_ERROR, "Could not start capture sequence.\n" ); |
|
|
|
av_log(s, AV_LOG_ERROR, "Could not start capture sequence.\n" ); |
|
|
|
vfw_read_close(s); |
|
|
|
goto fail_io; |
|
|
|
return AVERROR_IO; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fail_io: |
|
|
|
|
|
|
|
vfw_read_close(s); |
|
|
|
|
|
|
|
return AVERROR_IO; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
|
static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
|