海思Hi3559a音视频同时播放的例子

在mpp/sample下新建av目录

(1)编写Makefile,如下:

# Hisilicon Hi35xx sample Makefile
include ../Makefile.param
SRCS := $(wildcard *.c)
TARGET := $(SRCS:%.c=%)
SRCS += $(wildcard $(PWD)/adp/*.c)
#compile linux or HuaweiLite
include $(PWD)/../$(OSTYPE).mak
print:
	@echo "os is $(OSTYPE)"

(2)把mpp/sample/audio的adp目录拷贝到新建的av目录下

(3)编写sample_av.c文件,音视频同时播放的流程如下:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include "sample_comm.h"
#include "acodec.h"
#include "audio_aac_adp.h"
HI_S32 main(int argc, char* argv[])
{
    HI_S32 s32Ret = HI_SUCCESS;
    signal(SIGINT, SAMPLE_AUDIO_HandleSig);
    signal(SIGTERM, SAMPLE_AUDIO_HandleSig);
    s32Ret = SAMPLE_H265_VDEC_VPSS_VO();
    return s32Ret;
}

(4)在sample_av.c中,把sample_audio.c的下列函数拷贝过来

SAMPLE_DBG
SAMPLE_AUDIO_HandleSig
SAMPLE_AUDIO_Pt2Str
SAMPLE_AUDIO_OpenAdecFile
SAMPLE_AUDIO_AdecAo

(5)将音频播放流程整合为一个函数:

HI_S32 SAMPLE_AUDIO_AdecAO_SetRun(HI_VOID)//dong add audio set and run.
{
        HI_S32 s32Ret = HI_SUCCESS;
        HI_MPI_AENC_AacInit();
        HI_MPI_ADEC_AacInit();
        /* Set audio clksel, Non-required code. */
        AUDIO_MOD_PARAM_S stModParam;
        stModParam.enClkSel = AUDIO_CLKSEL_BASE;
        HI_MPI_AUDIO_SetModParam(&stModParam);
        SAMPLE_AUDIO_AdecAo();
        return s32Ret;
}

(6)在sample_av.c中,把sample_vdec.c的下列函数拷贝过来

SAMPLE_STREAM_PATH
g_enIntfSync
SAMPLE_H265_VDEC_VPSS_VO

(7)将音频播放整合到视频播放函数中

 //SAMPLE_COMM_VDEC_CmdCtrl(u32VdecChnNum, &stVdecSend[0], &VdecThread[0]);
    SAMPLE_AUDIO_AdecAO_SetRun();
  //

将之前的SAMPLE_COMM_VDEC_CmdCtrl函数注释掉,添加第5步编写的音频播放函数。

(8)如果显示器的分辨率较低,在SAMPLE_H265_VDEC_VPSS_VO函数中可以修改为720P输出

g_enIntfSync = VO_OUTPUT_720P60;
if(VO_OUTPUT_3840x2160_30 == g_enIntfSync)
{
        enDispPicSize = PIC_3840x2160;
        enIntfSync    = VO_OUTPUT_3840x2160_30;
}
else
{
      //  enDispPicSize = PIC_1080P;
       // enIntfSync    = VO_OUTPUT_1080P30;
            enDispPicSize = PIC_720P;
            enIntfSync    = VO_OUTPUT_720P50;
}

最后make,可以得到sampe_av在hisi开发板运行,同时播放音视频。

你可能感兴趣的:(c++)