EasyCVR接入华为视频云系统如何实现实时预览?【附代码】
【摘要】 EasyCVR接入华为视频云系统如何实现实时预览?本文来分享下实现过程。
一、通过摄像机编码开启实时浏览:
IVS_INT32 IVS_SDK_StartRealPlay(
IVS_INT32 iSessionID,
IVS_REALPLAY_PARAM *pRealplayPara,
const IVS_CHAR *pCameraCode,
HWND hWnd,
IVS_ULONG *pHandle);
//cpp code
IVS_REALPLAY_PARAM RealplayPara = {0};
RealplayPara.uiProtocolType = 1;//协议类型,此处1代表UDP
RealplayPara.uiStreamType = STREAM_TYPE_MAIN;//码流类型
IVS_ULONG ulRealPlayHandle = 0;
IVS_INT32 iRet = IVS_SDK_StartRealPlay(iSessionID, &RealplayPara, strCameraCode, m_ShowBox.GetSafeHwnd(), &ulRealPlayHandle);
// m_ShowBox是MFC中Edit Control控件的关联对象
if (IVS_SUCCEED == iRet)
{
//播放成功,可在此处控制声音和音量等
IVS_SDK_PlaySound(iSessionID, ulRealPlayHandle);
IVS_SDK_SetVolume(iSessionID, ulRealPlayHandle, 60);
}
二、通过摄像机编码开启实时浏览,以回调方式输出拼帧后的裸码流:
IVS_INT32 IVS_SDK_StartRealPlayCBRaw(
IVS_INT32 iSessionID,
IVS_REALPLAY_PARAM *pRealplayPara,
const IVS_CHAR *pCameraCode,
RealPlayCallBackRaw fRealPlayCallBackRaw,
IVS_VOID *pUserData,
IVS_ULONG *pHandle);
//cpp code
//实况裸码流回调函数,定义必须与RealPlayCallBackRaw保持一致
void __SDK_CALL RealPlayCallBackRawFunc(IVS_ULONG ulHandle, IVS_RAW_FRAME_INFO* pRawFrameInfo, IVS_VOID* pBuf, IVS_UINT32 uiBufSize, IVS_VOID* pUserData)
{
//回调码流处理
}
IVS_REALPLAY_PARAM RealplayPara = {0};//实况播放参数
RealplayPara.bDirectFirst = 0;
RealplayPara.bMultiCast = 1;
RealplayPara.uiProtocolType = 1;
RealplayPara.uiStreamType = STREAM_TYPE_MAIN;
//设置回调函数
IVS_INT32 iRet = IVS_SDK_StartRealPlayCBRaw(iSessionID, &RealplayPara, strCameraCode, RealPlayCallBackRawFunc, "test", &ulRealPlayHandle);if (IVS_SUCCEED == iRet)
{
//成功
}
三、开始实时浏览,将媒体流发送到目的IP、PORT。目前只支持UDP、主码流、中转方式。
//cpp code
IVS_INT32 IVS_SDK_StartRealPlayByIP(
IVS_INT32 iSessionID,
const IVS_CHAR *pCameraCode,
const IVS_MEDIA_ADDR *pMediaAddrDst,
IVS_MEDIA_ADDR *pMediaAddrSrc,
IVS_ULONG *pHandle);
//cpp code
IVS_MEDIA_ADDR MediaAddrDst = {0};//目标地址
IVS_MEDIA_ADDR MediaAddrSrc = {0};//视屏流源地址
MediaAddrDst.stIP.uiIPType = IP_V4;
strncpy(MediaAddrDst.stIP.cIP, "10.170.54.142", IVS_IP_LEN);
MediaAddrDst.uiAudioPort = 2048;
MediaAddrDst.uiVideoPort = 2050;
iRet = IVS_SDK_StartRealPlayByIP(iSessionID, strCameraCode, &MediaAddrDst, &MediaAddrSrc, &ulHandle);
if (IVS_SUCCEED == iRet)
{
//成功
}
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)