#ifndef MPP_H264_SOURCE_H
#define MPP_H264_SOURCE_H

#include <glib.h>
#include <stddef.h>
#include <stdint.h>

typedef struct MppH264Source MppH264Source;

/* video_device: "auto" | /dev/videoN | "test" (videotestsrc) */
MppH264Source *mpp_h264_source_start(const char *video_device, char **error_message);
void mpp_h264_source_stop(MppH264Source *src);

/* 拉一帧 Annex-B AU；数据在下次 pull 前有效。timeout_ms：appsink 等待毫秒。 */
gboolean mpp_h264_source_pull(MppH264Source *src, gboolean force_idr,
                              const uint8_t **data, size_t *size,
                              gboolean *is_idr, guint64 *pts_ns,
                              gint timeout_ms);

void mpp_h264_source_set_bitrate(MppH264Source *src, guint bitrate_bps);
void mpp_h264_source_request_keyframe(MppH264Source *src);

gboolean mpp_h264_source_is_mpp_encoder(const MppH264Source *src);

const gchar *mpp_h264_source_get_sprop(const MppH264Source *src);

/* 管道无帧时尝试 NULL→PLAYING 恢复 */
gboolean mpp_h264_source_recover(MppH264Source *src);

#endif
