F:\qt_projects\QtScrcpy\decoder\decoder.cpp:224: error: cannot convert 'AVPacket' to 'AVPacket**' for argument '1' to 'void av_packet_free(AVPacket**)' av_packet_free(packet); ^是什么意思
时间: 2024-03-31 18:36:33 浏览: 22
这个错误提示的意思是无法将AVPacket类型的packet变量转换为AVPacket**类型的指针。av_packet_free函数的参数需要传递AVPacket类型的指针的指针,而你传递的是AVPacket类型的指针。可能是因为你的代码中调用了错误的函数,或者传递的参数类型不匹配。如果你想要释放AVPacket变量,可以使用av_packet_unref()函数,该函数的参数为AVPacket指针类型。
相关问题
qt报错 F:\qt_projects\QtScrcpy\videoform.cpp:143: error: no matching function for call to 'VideoForm::connect(QList<Decoder*>&, void (Decoder::*)(devicessocket*), VideoForm*, VideoForm::VideoForm(const QString&, QWidget*)::<lambda(devicessocket*)>)' }); ^
这个错误是因为 `connect` 函数中的第三个参数不匹配。根据你提供的代码,第三个参数应该是 `this`,即当前 `VideoForm` 对象的指针。但是,在 lambda 表达式中,你又重新创建了一个 `VideoForm` 对象,并且将其传递给了 `decoder->recv_frame` 方法。这样会导致 `connect` 函数中的第三个参数与 lambda 表达式中的 `VideoForm` 对象类型不匹配。
要解决这个问题,你可以将 lambda 表达式中的 `VideoForm` 对象指针改为 `this`,如下所示:
```cpp
connect(decoders, &QList<Decoder*>::finished, this, [this](devicessocket *socket) {
if (socket == current_socket) {
ui->video->update();
}
});
for (auto decoder : *decoders) {
connect(decoder, &Decoder::recv_frame, this, [this](devicessocket *socket) {
if (socket == current_socket) {
ui->video->update();
}
});
}
```
这样,`connect` 函数中的第三个参数就与 lambda 表达式中的 `this` 相匹配了。
qt报错 F:\qt_projects\QtScrcpy\videoform.cpp:131: error: 'onNewFrame' is not a member of 'QList<Decoder*>' connect(m_decoderList,QList<Decoder*>::onNewFrame,this,[this](devicessocket* devicesSocket){ ^~~~~~~~~~
这个错误是因为 QList 没有 onNewFrame 方法。根据你的代码,我猜测你的意图是监听 m_decoderList 中 Decoder 对象的 onNewFrame 信号,然后调用 lambda 表达式中的代码。那么正确的连接方式应该是:
```
connect(m_decoderList, &QList<Decoder*>::objectAdded, this, [this](Decoder* decoder) {
connect(decoder, &Decoder::onNewFrame, this, [this](devicessocket* devicesSocket) {
// TODO: 处理新帧数据
});
});
```
这样,当向 m_decoderList 中添加 Decoder 对象时,就会触发 objectAdded 信号,然后调用连接的 lambda 表达式,然后在 lambda 表达式中连接 Decoder 对象的 onNewFrame 信号。注意,这里需要将 Decoder* 作为参数传递给 lambda 表达式中的代码块,这样才能访问到具体的 Decoder 对象。