ORTP库局域网图传和VLC实时预览

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wangdapao12138/article/details/82535028

1.ORTP的引入

1.1、视频网络传输的2种方式

(1)基于下载:http or ftp

(2)基于实时:RTP/RTSP/RTCP

1.2ORTP的介绍

(1)openRTP,用C实现的一个RTP库(其实还有C++实现的,JAVA等实现的)

(2)实质是一个视频服务器,工作时客户端和服务器实时传递视频数据

(3)一般认为RTP工作在传输层,但是其实RTP比TCP/UDP高一个层次

(4)RTP(及RTCP)的实现有国际标准RFC3550规定,只要符合协议谁都可以自己写一个

(5)本季课程重点在于使用ORTP来实现局域网视频实时传输

2.ORTP库的移植

2.1、准备源码

(1)下载ortp源码:https://github.com/dmonakhov/ortp

(2)存放到临时工作目录并解压

2.2、源码修改

(1)增加H.264的payload支持。

在src/avprofile.c中357行添加:

rtp_profile_set_payload(profile,96,&payload_type_h264);

2.3、配置和编译、安装

(1)进入ortp目录执行./autogen.sh

(2)错误1:./autogen.sh: line 44: libtoolize: command not found

   解决:sudo apt-get install libtool*

(2)错误2:libtoolize:   error: Please install GNU M4, or 'export M4=/path/to/gnu/m4'.

   解决:sudo apt-get install m4

(3)错误3:Automake - aclocal: command not found

   解决:sudo apt-get install automake

(4)继续执行./configure --prefix=/tmp/ortp --host=arm-hisiv300-linux

(5)make && make install

2.4、到/tmp/ortp目录下查看移植好的库和头文件

3.RTP传输视频实战

3.1、在官方SDKsample中添加rtp传输代码

(1)venc/sample_venc.c中,添加:s32ChnNum = 1;强制限制为1路,用来网络播放。

(2)common/sample_common_venc.c中,改了很多

#define ORTP_ENABLE  1

RtpSession * rtpInit( char  * ipStr, int  port)

int  rtpExit(RtpSession *session)

int  rtpSend(RtpSession *session, char  *buffer,  int  len)

/******************************************************************************

* funciton : save H264 stream

******************************************************************************/

HI_S32 SAMPLE_COMM_VENC_SaveH264(FILE* fpH264File, VENC_STREAM_S *pstStream)

{

    HI_S32 i;

   

    for (i = 0; i < pstStream->u32PackCount; i++)

    {

        #if ORTP_ENABLE

        rtpSend(pRtpSession,pstStream->pstPack[i].pu8Addr, pstStream->pstPack[i].u32Len);

       #else

            fwrite(pstStream->pstPack[i].pu8Addr+pstStream->pstPack[i].u32Offset,

               pstStream->pstPack[i].u32Len-pstStream->pstPack[i].u32Offset, 1, fpH264File);

            fflush(fpH264File);

        #endif

    }

    return HI_SUCCESS;

}

#if ORTP_ENABLE

    /***rtp init****/

    pRtpSession = rtpInit( LOCAL_HOST_IP ,8080); 

    if (pRtpSession==NULL)  

    {  

        printf( "error rtpInit" );

        exit(-1); 

        return  0;  

    }

    #endif

3.2、重新编译sample

  1. 复制ortp头文件,到mpp文件夹里面的include文件夹中

修改sample/vencMakefile,添加libortp的链接支持,添加-lortp -L/tmp/ortp/lib

  1. 最后执行make,生成我们需要的sample_venc

3.3、开发板中部署并运行测试

       搭建好网络环境,用开发板ping 虚拟机和windows都要能通,这里要注意一点,由于测试代码固定成192.168.1.20,所以windows的网卡地址要设置成这个。

 将之前编译好的lib库拷贝到nfs文件系统里面。

然后在串口终端那边拷贝到开发板文件系统/usr/lib中。

(1)部署libortp.so到开发板中/usr/lib目录下
(2)检查开发板中原有配置是否正确,譬如sensor是否对应
(3)nfs中运行新的sample程序
(4)vlc中打开配置好的sdp文件,看到实时图像就证明整个实验完成了

 

猜你喜欢

转载自blog.csdn.net/wangdapao12138/article/details/82535028