我已经被困在一个问题上一段时间了,我无处可去。愿你们中的一个人怜悯并帮助我。
我已经用 c2nim 转录了一些头文件。调试和许多方法似乎工作正常,但有一个部分我无法到达任何地方。我要映射的部分看起来像
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;
尼姆
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
-> 如何以数组形式访问 Streams ??? 我可以理解 C 的基础知识和大部分内存布局,但在这里我达到了我的极限。
我尝试以某些方式进行投射。例子:
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[][])
如您所见,我尝试了很多事情,因为我只是不知道该怎么做... -> 如何在 nim 中将 ptr ptr 作为数组访问?
谢谢帮助