I've been stuck on a problem for some time now and I'm not getting anywhere.
May one of you have mercy and help me.
I have transcribed some header files with c2nim. Debugging and many methods
seem to work fine, but there is one section where I just can't get anywhere.
The section I want to map looks like
__C__
typedef struct AVFormatContext {
...
AVStream **streams;
...
}
...
AVFormatContext *pFormatCtxInCam = NULL;
...
pFormatCtxInCam = avformat_alloc_context();
ret = avformat_open_input(&pFormatCtxInCam, "video=Venus USB2.0 Camera",
inFrmt, &inOptions);
for (i = 0; i < pFormatCtxInCam->nb_streams; i++)
if (pFormatCtxInCam->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
video_stream_idx_cam = i;
Run
__Nim__
type AVFormatContext* {.bycopy.} = object
...
streams*: ptr ptr AVStream
...
var pFormatCtxInCam: ptr AVCodecContext = nil
pFormatCtxInCam = avformat_alloc_context()
ret = avformat_open_input(pFormatCtxInCam.addr, "video=Venus USB2.0
Camera", inFrmt, inOptions.addr)
-> Problem
Run
* * *
-> How can I access Streams as array ??? I can understand the basics in C and
most of the memory layout, but here I reach my limits.
I try to cast in some ways. Examples:
var streams = cast[array[0..0, ptr
AVStream]](pFormatCtxInCam[].streams[].addr)
var streams = cast[array[0..0, AVStream]](pFormatCtxInCam[].streams[].addr)
var streams = cast[ref array[0..0, ptr AVStream]](pFormatCtxInCam[].streams)
var streams = cast[array[0..5, AVStream]](pFormatCtxInCam[].streams)
var streams = cast[ptr UncheckedArray[ptr
AVStream]](pFormatCtxInCam[].streams)
var streams = cast[ptr UncheckedArray[ptr
AVStream]](pFormatCtxInCam[].streams[])
var streams = cast[ptr UncheckedArray[ptr
AVStream]](pFormatCtxInCam[].streams[][])
Run
As you can see, I've tried a lot of things because I just don't know what to
do... -> How can I access ptr ptr in nim as an array?
Thx for help