GstBuffer *buf = GST_PAD_PROBE_INFO_BUFFER (info); GstH264NalUnitType nal_type = GST_H264_NAL_UNIT_TYPE (GST_BUFFER_DATA (buf)[0]);提示error: subscripted value is neither array nor pointer nor vector 表示 (buf)[0]的用法存在问题
时间: 2024-03-06 07:47:55 浏览: 115
你需要将 `(GST_BUFFER_DATA (buf)[0])` 改为 `GST_BUFFER_DATA (buf)[0]`,这个错误通常是因为你在使用 `GST_BUFFER_DATA (buf)` 时,将其视为了一个指针或数组,但实际上它是一个 `guint8*` 类型的指针,所以当你尝试使用 `[]` 运算符时,就会发生错误。修改后的代码示例如下:
```c
static GstPadProbeReturn
sps_pps_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
GstBuffer *buf = GST_PAD_PROBE_INFO_BUFFER (info);
guint8 *data = GST_BUFFER_DATA (buf);
GstH264NalUnitType nal_type = GST_H264_NAL_UNIT_TYPE (data[0]);
if (nal_type == GST_H264_NAL_SPS) {
// This is an SPS unit
guint8 *sps = data;
guint sps_len = GST_BUFFER_SIZE (buf);
// Do something with the SPS data
} else if (nal_type == GST_H264_NAL_PPS) {
// This is a PPS unit
guint8 *pps = data;
guint pps_len = GST_BUFFER_SIZE (buf);
// Do something with the PPS data
}
return GST_PAD_PROBE_OK;
}
```
请注意,你还需要确保在代码中包含了正确的头文件和库文件。
阅读全文