/* scIpcu.h */
#include "AsyncRingOut.h" /* FunRingCb */
class scIpcu
{
private:
AsyncRingOut *pRingOut;
FunRingCb BindSetBufCb();
};
/* scIpcu.cpp */
scIpcu::scIpcu(): pRingOut(NULL),
{
pRingOut = new AsyncRingOut();
}
XAG_VOID scIpcu::IpcuCapStreamRecvCallback(XAG_U8 id, XAG_U32 pdata, XAG_U32 length, XAG_U32 cont, XAG_U32 total_length)
{
CIF_STREAM_HEADER_S *send_data = NULL;
send_data = (CIF_STREAM_HEADER_S *)pdata;
pRingOut->RingSet((XAG_VOID *)send_data, BindSetBufCb());
}
FunRingCb scIpcu::BindSetBufCb()
{
// std::bind看作通用的函数适配器,它接受一个可调用对象,生成一个新的可调用对象来"适应"原对象的参数列表。
return ( std::bind(&scIpcu::StreamMemorySaveCb, this, std::placeholders::_1, std::placeholders::_2) );
}
XAG_VOID scIpcu::StreamMemorySaveCb(XAG_VOID *pVoid, XAG_VOID *pRingBuf)
{
case E_COMMAND_STREAM_JPG:
pstJpegDcf = (JPEG_STREAM_DCF *)pVoid;
dcf_exif_set_createtime(&pstJpegDcf->DcfData);
}
/* AysncRingOut.h */
typedef std::function<void(XAG_VOID *, XAG_VOID *)> FunRingCb;
/* AysncRingOut.cpp */
XAG_S32 AsyncRingOut::RingSet(XAG_VOID *pVoid, FunRingCb cbfunRingset)
{
cbfunRingset(pVoid, stRingbuf.pRingBuf[u8Pos]); // 此处调用了 scIpcu::StreamMemorySaveCb()
OutputNotice();
return XAG_SUCCESS;
}