diff --git a/.gitignore b/.gitignore index 06adf81..c7078cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,16 @@ *.o *.yuv device/cmake-build-debug/ +device/mpp/sample/venc/su.IAD +device/mpp/sample/venc/su.IAB +device/mpp/sample/venc/stream_chn2.h264 +device/mpp/sample/venc/stream_chn1.h264 +device/mpp/sample/venc/stream_chn0.h264 +device/mpp/sample/venc/su.PO +device/mpp/sample/venc/su.PFI +device/mpp/sample/venc/su.IMD +device/mpp/sample/venc/su.IMB +device/mpp/sample/venc/su.WK3 +device/mpp/sample/venc/su.PS +device/mpp/sample/venc/su.PRI +device/mpp/sample/venc/su.PR diff --git a/device/mpp/sample/common/sample_comm_venc.c b/device/mpp/sample/common/sample_comm_venc.c index 356f478..b6a94d2 100644 --- a/device/mpp/sample/common/sample_comm_venc.c +++ b/device/mpp/sample/common/sample_comm_venc.c @@ -28,6 +28,7 @@ extern "C"{ #include #include "sample_comm.h" +#include "librtsp.h" const HI_U8 g_SOI[2] = {0xFF, 0xD8}; const HI_U8 g_EOI[2] = {0xFF, 0xD9}; @@ -318,9 +319,26 @@ HI_S32 SAMPLE_COMM_VENC_SaveH264(FILE* fpH264File, VENC_STREAM_S *pstStream) for (i = 0; i < pstStream->u32PackCount; i++) { - fwrite(pstStream->pstPack[i].pu8Addr+pstStream->pstPack[i].u32Offset, - pstStream->pstPack[i].u32Len-pstStream->pstPack[i].u32Offset, 1, fpH264File); - + if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_PSLICE) + printf("pslice "); + if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_PPS) + printf("pps "); + if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_ISLICE) + printf("islice "); + if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_SEI) + printf("sei "); + if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_SPS) + printf("sps "); + if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_IPSLICE) + printf("ipslice "); + fwrite(pstStream->pstPack[i].pu8Addr + pstStream->pstPack[i].u32Offset , + pstStream->pstPack[i].u32Len - pstStream->pstPack[i].u32Offset, 1, fpH264File); + unsigned char *p = pstStream->pstPack[i].pu8Addr; + printf("h264 header file %d length %d nal count %d offset %x %x %x %x %x %x %x %x\r\n", + pstStream->pstPack[i].u32Len - pstStream->pstPack[i].u32Offset, + i, + pstStream->pstPack[i].u32Offset, + p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]); fflush(fpH264File); } @@ -466,7 +484,7 @@ HI_S32 SAMPLE_COMM_VENC_Start(VENC_CHN VencChn, PAYLOAD_TYPE_E enType, VIDEO_NOR if(SAMPLE_RC_CBR == enRcMode) { stVencChnAttr.stRcAttr.enRcMode = VENC_RC_MODE_H264CBR; - stH264Cbr.u32Gop = (VIDEO_ENCODING_MODE_PAL== enNorm)?25:30; + stH264Cbr.u32Gop = (VIDEO_ENCODING_MODE_PAL== enNorm)?24:30; stH264Cbr.u32StatTime = 1; /* stream rate statics time(s) */ stH264Cbr.u32SrcFrmRate = (VIDEO_ENCODING_MODE_PAL== enNorm)?25:30;/* input (vi) frame rate */ stH264Cbr.fr32DstFrmRate = (VIDEO_ENCODING_MODE_PAL== enNorm)?25:30;/* target frame rate */ @@ -1453,12 +1471,12 @@ HI_VOID *SAMPLE_COMM_VENC_GetVencStreamProc_Svc_t(void *p) BASE_PSLICE_REFBYBASE == stStream.stH264Info.enRefType || BASE_PSLICE_REFBYENHANCE== stStream.stH264Info.enRefType) { - s32Ret = SAMPLE_COMM_VENC_SaveStream(enPayLoadType[i], pFile[i+s32Cnt], &stStream); + //s32Ret = SAMPLE_COMM_VENC_SaveStream(enPayLoadType[i], pFile[i+s32Cnt], &stStream); } break; case 2: - s32Ret = SAMPLE_COMM_VENC_SaveStream(enPayLoadType[i], pFile[i+s32Cnt], &stStream); + //s32Ret = SAMPLE_COMM_VENC_SaveStream(enPayLoadType[i], pFile[i+s32Cnt], &stStream); break; } diff --git a/device/mpp/sample/hisi_rtsp_demo-master/log b/device/mpp/sample/hisi_rtsp_demo-master/log new file mode 100644 index 0000000..ffc0aa3 --- /dev/null +++ b/device/mpp/sample/hisi_rtsp_demo-master/log @@ -0,0 +1,137 @@ +GetConfig 623 +GetConfig 652 +0,0,0,0 +[INFO rtsp_demo.c:281:rtsp_new_demo] rtsp server demo starting on port 5544 +[DEBUG rtsp_demo.c:481:rtsp_new_session] add session path: /live.sdp +s32ChnNum = 3 +=============SAMPLE_COMM_VI_SetMipiAttr enWDRMode: 0 +linear mode +Aptina AR0130 sensor 720P30fps init success! +[OSD_Handle_Init]-217: HI_MPI_RGN_Create (1) failed with 0xa0038003! +please press twice ENTER to exit this sample +[DEBUG utils.c:160:rtsp_codec_data_parse_from_user_h264] sps 14 +[DEBUG utils.c:168:rtsp_codec_data_parse_from_user_h264] pps 4 +[INFO rtsp_demo.c:409:rtsp_new_client_connection] new rtsp client 192.168.2.100:50622 comming +[DEBUG rtsp_msg.c:865:rtsp_msg_parse_from_array] +DESCRIBE rtsp://192.168.2.109:5544/live.sdp RTSP/1.0 +CSeq: 1 +User-Agent: zrtsp-cli +Accept: application/sdp + +[DEBUG rtsp_demo.c:733:rtsp_handle_DESCRIBE] +[DEBUG rtsp_msg.c:998:rtsp_msg_build_to_array] +RTSP/1.0 200 OK +CSeq: 1 +Date: Thu Jan 1 03:43:10 1970 +Server: rtsp_demo +Content-Type: application/sdp +Content-Length: 311 + +v=0 +o=- 0 0 IN IP4 0.0.0.0 +s=rtsp_demo +t=0 0 +a=control:rtsp://192.168.2.109:5544/live.sdp +a=range:npt=0- +m=video 0 RTP/AVP 96 +c=IN IP4 0.0.0.0 +a=rtpmap:96 H264/90000 +a=fmtp:96 packetization-mode=1;sprop-parameter-sets=Z0IAHpWoKA9puAgICBA=,aM48gA== +a=control:rtsp://192.168.2.109:5544/live.sdp/track1 +[DEBUG rtsp_msg.c:865:rtsp_msg_parse_from_array] +SETUP rtsp://192.168.2.109:5544/live.sdp/track1 RTSP/1.0 +CSeq: 3 +User-Agent: zrtsp-cli +Transport: RTP/AVP;unicast;client_port=61334-61335 + +[DEBUG rtsp_demo.c:937:rtsp_handle_SETUP] +[INFO rtsp_demo.c:894:rtsp_new_rtp_connection] new rtp over udp for video ssrc:22345678 local_port:49152-49153 peer_addr:192.168.2.100 peer_port:61334-61335 +[DEBUG rtsp_msg.c:998:rtsp_msg_build_to_array] +RTSP/1.0 200 OK +CSeq: 3 +Date: Thu Jan 1 03:43:11 1970 +Session: 12345678 +Transport: RTP/AVP;ssrc=22345678;unicast;client_port=61334-61335;server_port=49152-49153 +Server: rtsp_demo + +[DEBUG rtsp_msg.c:865:rtsp_msg_parse_from_array] +PLAY rtsp://192.168.2.109:5544/live.sdp/track1 RTSP/1.0 +CSeq: 5 +User-Agent: zrtsp-cli +Range: npt=0.000- +Session: 12345678 +Transport: RTP/AVP;ssrc=22345678;unicast;client_port=61334-61335 + +[DEBUG rtsp_demo.c:1024:rtsp_handle_PLAY] +[DEBUG rtsp_msg.c:998:rtsp_msg_build_to_array] +RTSP/1.0 200 OK +CSeq: 5 +Date: Thu Jan 1 03:43:11 1970 +Session: 12345678 +Server: rtsp_demo + +[ERROR rtsp_demo.c:1150:rtsp_recv_msg] recv data failed: Connection reset by peer +[INFO rtsp_demo.c:428:rtsp_del_client_connection] delete client 21 from 192.168.2.100 +[INFO rtsp_demo.c:409:rtsp_new_client_connection] new rtsp client 192.168.2.100:51836 comming +[DEBUG rtsp_msg.c:865:rtsp_msg_parse_from_array] +DESCRIBE rtsp://192.168.2.109:5544/live.sdp RTSP/1.0 +CSeq: 1 +User-Agent: zrtsp-cli +Accept: application/sdp + +[DEBUG rtsp_demo.c:733:rtsp_handle_DESCRIBE] +[DEBUG rtsp_msg.c:998:rtsp_msg_build_to_array] +RTSP/1.0 200 OK +CSeq: 1 +Date: Thu Jan 1 07:01:31 1970 +Server: rtsp_demo +Content-Type: application/sdp +Content-Length: 311 + +v=0 +o=- 0 0 IN IP4 0.0.0.0 +s=rtsp_demo +t=0 0 +a=control:rtsp://192.168.2.109:5544/live.sdp +a=range:npt=0- +m=video 0 RTP/AVP 96 +c=IN IP4 0.0.0.0 +a=rtpmap:96 H264/90000 +a=fmtp:96 packetization-mode=1;sprop-parameter-sets=Z0IAHpWoKA9puAgICBA=,aM48gA== +a=control:rtsp://192.168.2.109:5544/live.sdp/track1 +[DEBUG rtsp_msg.c:865:rtsp_msg_parse_from_array] +SETUP rtsp://192.168.2.109:5544/live.sdp/track1 RTSP/1.0 +CSeq: 3 +User-Agent: zrtsp-cli +Transport: RTP/AVP;unicast;client_port=61334-61335 + +[DEBUG rtsp_demo.c:937:rtsp_handle_SETUP] +[INFO rtsp_demo.c:894:rtsp_new_rtp_connection] new rtp over udp for video ssrc:22345679 local_port:49152-49153 peer_addr:192.168.2.100 peer_port:61334-61335 +[DEBUG rtsp_msg.c:998:rtsp_msg_build_to_array] +RTSP/1.0 200 OK +CSeq: 3 +Date: Thu Jan 1 07:01:31 1970 +Session: 12345679 +Transport: RTP/AVP;ssrc=22345679;unicast;client_port=61334-61335;server_port=49152-49153 +Server: rtsp_demo + +[DEBUG rtsp_msg.c:865:rtsp_msg_parse_from_array] +PLAY rtsp://192.168.2.109:5544/live.sdp/track1 RTSP/1.0 +CSeq: 5 +User-Agent: zrtsp-cli +Range: npt=0.000- +Session: 12345679 +Transport: RTP/AVP;ssrc=22345679;unicast;client_port=61334-61335 + +[DEBUG rtsp_demo.c:1024:rtsp_handle_PLAY] +[DEBUG rtsp_msg.c:998:rtsp_msg_build_to_array] +RTSP/1.0 200 OK +CSeq: 5 +Date: Thu Jan 1 07:01:31 1970 +Session: 12345679 +Server: rtsp_demo + +[DEBUG rtsp_demo.c:1145:rtsp_recv_msg] peer closed +[INFO rtsp_demo.c:428:rtsp_del_client_connection] delete client 21 from 192.168.2.100 +program termination abnormally! +[DEBUG rtsp_demo.c:629:rtsp_del_session] del session path: /live.sdp diff --git a/device/mpp/sample/venc/librtsp.c b/device/mpp/sample/venc/librtsp.c new file mode 100644 index 0000000..e7af32d --- /dev/null +++ b/device/mpp/sample/venc/librtsp.c @@ -0,0 +1,170 @@ +#include "librtsp.h" + +RtspClient *ConectRtsp(char *ip,int port,char *desc){ + if(0 == ip || 0 == desc){ + return 0; + } + RtspClient *ret = (RtspClient*)malloc(sizeof(RtspClient)); + ret->sock = Connect(ip,port); + if(ret->sock < 0){ + return 0; + } + strcpy(ret->hostIp,ip); + ret->port = port; + ret->cesq = 1; + strcpy(ret->despcrtion,desc); + return ret; +} + +int SendOption(RtspClient*p,CallBack *c){ + char pRecv[500]; + char buf[500]; + sprintf(buf,"OPTIONS rtsp://%s:%d/%s RTSP/1.0\r\nCSeq: %d\r\nUser-Agent: Lavf57.71.100\r\n\r\n",p->hostIp,p->port, + p->despcrtion,p->cesq); + int ret = Send(p->sock,buf,strlen(buf)); + printf("send %d \r\ndata is:\r\n%s\r\n",ret,buf); + if(0 > ret){ + closesocket(p->sock); + p->conn = FALSE; + return -1; + } + if(Recv(p->sock,pRecv,500) > 0) { + printf("recv: %s\r\n",pRecv); + } else{ + printf("error recv "); + return -1; + } +} +/* +ANNOUNCE rtsp://118.24.238.198:554/Sword RTSP/1.0 +CSeq: 1 +User-Agent: EasyPusher v1.2.16.1105 +Content-Type: application/sdp +Content-Length: 384 + +v=0 +o=- 0 0 IN IP4 127.0.0.1 +s=EasyDarwin +i=EasyDarwin +c=IN IP4 127.0.0.1 +t=0 0 +a=x-qt-text-nam:EasyDarwin +a=x-qt-text-inf:EasyDarwin +a=x-qt-text-cmt:source application::EasyDarwin +a=x-qt-text-aut: +a=x-qt-text-cpy: +m=video 0 RTP/AVP 96 +a=rtpmap:96 H264/90000 +a=fmtp:96 packetization-mode=1;sprop-parameter-sets=,2QAKKy0A8ARPywgAAADACAAAAMD0eMGVA== +a=control:streamid=0 + +*/ +int SendAnnounce(RtspClient *p,CallBack callback){ + char content[] ="v=0\r\n" + "o=- 0 0 IN IP4 127.0.0.1\r\n" + "s=EasyDarwin\r\n" + "i=EasyDarwin\r\n" + "c=IN IP4 127.0.0.1\r\n" + "t=0 0\r\n" + "a=x-qt-text-nam:EasyDarwin\r\n" + "a=x-qt-text-inf:EasyDarwin\r\n" + "a=x-qt-text-cmt:source application::EasyDarwin\r\n" + "a=x-qt-text-aut:\r\n" + "a=x-qt-text-cpy:\r\n" + "m=video 0 RTP/AVP 96\r\n" + "a=rtpmap:96 H264/90000\r\n" + "a=fmtp:96 packetization-mode=1;sprop-parameter-sets=,2QAKKy0A8ARPywgAAADACAAAAMD0eMGVA==\r\n" + "a=control:streamid=0\r\n"; + char pRecv[500] = {0}; + char length[10] = {0}; + char buf[500] = {0}; + sprintf(buf,"ANNOUNCE rtsp://%s:%d/%s RTSP/1.0\r\nCSeq: %d\r\nUser-Agent: EasyPusher v1.2.16.1105\r\n" + "Content-Type: application/sdp\r\n" + "Content-Length: ",p->hostIp,p->port,p->despcrtion,p->cesq++); + sprintf(length,"%d",strlen(content)); + strcat(buf,length); + strcat(buf,"\r\n\r\n"); + strcat(buf,content); + + int ret = Send(p->sock,buf,strlen(buf)); + printf("send %d \r\ndata is:\r\n%s\r\n",ret,buf); + if(0 > ret){ + closesocket(p->sock); + p->conn = FALSE; + return -1; + } + if(Recv(p->sock,pRecv,500) > 0) { + printf("recv: %s\r\n",pRecv); + } else{ + printf("error recv "); + return -1; + } +} + +int SendSetup(RtspClient *p,CallBack *c){ + char pRecv[500] = {0}; + char buf[500] = {0}; + sprintf(buf,"SETUP rtsp://%s:%d/%s/streamid=0 RTSP/1.0\r\nTransport: RTP/AVP/TCP;unicast;mode=record;interleaved=0-1\r\n" + "CSeq: %d\r\nUser-Agent: EasyPusher v1.2.16.1105\r\n\r\n",p->hostIp,p->port,p->despcrtion,p->cesq++); + int ret = Send(p->sock,buf,strlen(buf)); + printf("send %d \r\ndata is:\r\n%s\r\n",ret,buf); + if(0 > ret){ + closesocket(p->sock); + p->conn = FALSE; + return -1; + } + int recv = Recv(p->sock,pRecv,500); + if(ret > 0) { + printf("recv: %s\r\n",pRecv); + if(NULL != c){ + c(p,pRecv,recv); + } + } else{ + printf("error recv "); + return -1; + } + return 0; +} +/* +RECORD rtsp://118.24.238.198:554/Sword RTSP/1.0 +Range: npt=0.000- +CSeq: 4 +User-Agent: EasyPusher v1.2.16.1105 +Session: BktDfYuIH + */ +int SendRecord(RtspClient *p,CallBack *c){ + char pRecv[500] = {0}; + char buf[500] = {0}; + sprintf(buf,"RECORD rtsp://%s:%d/%s RTSP/1.0\r\nRange: npt=0.000-\r\n" + "CSeq: %d\r\nUser-Agent: Lavf57.71.100\r\nSession:%s\r\n\r\n",p->hostIp,p->port,p->despcrtion,p->cesq++,p->session); + int ret = Send(p->sock,buf,strlen(buf)); + printf("send %d \r\ndata is:\r\n%s\r\n",ret,buf); + if(0 > ret){ + closesocket(p->sock); + p->conn = FALSE; + return -1; + } + if(Recv(p->sock,pRecv,500) > 0) { + printf("recv: %s\r\n",pRecv); + } else{ + printf("error recv "); + return -1; + } +} + +int SendRtpPackage(RtspClient *p,unsigned char *buf,int length){ + int ret = Send(p->sock,(char*)buf,length); + printf("request send %d ,send rtp pack %d \r\ndata is:\r\n%s\r\n",length,ret,buf); + if(0 > ret){ + closesocket(p->sock); + p->conn = FALSE; + return -1; + } +} + +int CallBackSetup(RtspClient *client, const char *data, int len){ + char *session = strstr(data,"Session: "); + if(NULL != session){ + sscanf(session,"Session: %s\r\n",client->session); + } +} diff --git a/device/mpp/sample/venc/librtsp.h b/device/mpp/sample/venc/librtsp.h new file mode 100644 index 0000000..0f0576f --- /dev/null +++ b/device/mpp/sample/venc/librtsp.h @@ -0,0 +1,65 @@ +// +// Created by 29019 on 2019/9/11. +// + +#ifndef LIBRTSP_C_LIBRTSP_H +#define LIBRTSP_C_LIBRTSP_H + +#include "sock.h" +#include "stdio.h" +#include +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef linux +typedef int bool; +#define TRUE 1 +#define FALSE 0 +#endif +typedef struct _T_Param { + char key[50]; + char value[140]; +} Params; + +typedef struct _T_RtspClientCtx { + char hostIp[30]; + int port; + char despcrtion[50]; + Sock sock; + int cesq; + bool conn; + char session[50]; +} RtspClient; + +// callback function that receive data. +typedef int (CallBack)(RtspClient *client, const char *data, int len); + +typedef enum _E_Method { + E_OPTIONS = 0, + E_POST, + E_ANNOUNCE, + E_SETUP, + E_RECORD +} Methods; + +RtspClient *ConectRtsp(char *ip, int port, char *desc); + +int GenPayload(Methods method, char *data); + +int SendOption(RtspClient *p, CallBack *c); + +int SendSetup(RtspClient *p, CallBack *c); + +int SendRecord(RtspClient *p, CallBack *c); + +int SendAnnounce(RtspClient *p, CallBack); + +int SendRtpPackage(RtspClient *p, unsigned char *buf, int length); + + +int CallBackSetup(RtspClient *client, const char *data, int len); +#ifdef __cplusplus +} +#endif +#endif //LIBRTSP_C_LIBRTSP_H diff --git a/device/mpp/sample/venc/rtp.h b/device/mpp/sample/venc/rtp.h new file mode 100644 index 0000000..070dd0a --- /dev/null +++ b/device/mpp/sample/venc/rtp.h @@ -0,0 +1,47 @@ +#ifndef __RTP_PACK__ +#define __RTP_PACK__ + +#pragma pack(1)//设定为1字节对齐 + +#include +#include +#include +#include "thirdparty/librtsp_c/librtsp.h" +#include "rtsp.h" +typedef struct { + unsigned char cc:4; /* CSRC count */ + unsigned char x:1; /* header extension flag */ + unsigned char p:1; /* padding flag */ + unsigned char version:2; /* protocol version */ + unsigned char pt:7; /* payload type */ + unsigned char m:1; /* marker bit */ + unsigned short seq; /* sequence number */ + unsigned int ts; /* timestamp */ + unsigned int ssrc; /* synchronization source */ +} CRtpHeader; +typedef struct { + unsigned char FUType:5; + unsigned char NRI:2; + unsigned char F:1; +}FuIdentifier; +typedef struct { + unsigned char NALUnitType:5; + unsigned char Forbid:1; + unsigned char End:1; + unsigned char Start:1; +}FuHeader; +typedef struct { + FuIdentifier Identifier; + FuHeader Header; +} CH264NalUnit; + +#pragma pack(4)//设定为4字节对齐 +#define MAX_RTP_LEN 1001 + +typedef struct{ + unsigned char *data; + int length; +}Vector; + +int Pack264(unsigned char *frame,int, Vector **outbuf); +#endif \ No newline at end of file diff --git a/device/mpp/sample/venc/sample_venc b/device/mpp/sample/venc/sample_venc index 4891b4f..d9c5ad2 100644 Binary files a/device/mpp/sample/venc/sample_venc and b/device/mpp/sample/venc/sample_venc differ diff --git a/device/mpp/sample/venc/sock.c b/device/mpp/sample/venc/sock.c new file mode 100644 index 0000000..7abb38c --- /dev/null +++ b/device/mpp/sample/venc/sock.c @@ -0,0 +1,82 @@ +#include "sock.h" +#pragma comment(lib, "ws2_32.lib") +#ifdef WIN32 +Sock Connect(char *ip,int port){ + if(0 == ip){ + return -1; + } + WORD wVersionRequested; + WSADATA wsaData; + int err; + wVersionRequested = MAKEWORD(2,0); + err = WSAStartup(wVersionRequested,&wsaData);// + SOCKET ret = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);//create socket + if(ret < 0){ + printf("error malloc socket%d\r\n",ret); + exit(0); + } + SOCKADDR_IN addrSrv; + addrSrv.sin_addr.S_un.S_addr = inet_addr(ip);//"49.152.49.84"); + addrSrv.sin_family = AF_INET; + addrSrv.sin_port = htons(port); + if(SOCKET_ERROR==connect(ret,(SOCKADDR*)&addrSrv,sizeof(SOCKADDR))){ + closesocket(ret); + DWORD gle = WSAGetLastError(); + printf("connect socket error code %ld\r\n",gle); + return -1; + } + return ret; +} + +int Send(Sock s,char*dat, int len){ + fd_set wFds; + FD_ZERO(&wFds); + FD_SET(s,&wFds); + + int ret = select(s + 1,0,&wFds,0,0); + // time expire + if(ret == 0){ + return 0; + }else if(ret > 0){ + if(FD_ISSET(s,&wFds)){ + int recv = send(s,dat,len,0); + if(recv < 0) + { + closesocket(s); + return -2; + } + return recv; + } + }else{ + printf("error code %d\r\n",ret); + return -1; + } +} +int Recv(Sock s,char *rec,int len){ + fd_set rFds; + fd_set eFds; + FD_ZERO(&rFds); + FD_SET(s,&rFds); + + int ret = select(s + 1,&rFds,0,0,0); + // time expire + if(ret == 0){ + return 0; + }else if(ret > 0){ + if(FD_ISSET(s,&rFds)){ + int recvDat = recv(s,rec,len,0); + if(recvDat <0) + { + closesocket(s); + return -1; + } + return recvDat; + } + if(FD_ISSET(s,&eFds)){ + closesocket(s); + return -3; + } + } + return -1; +} +#endif diff --git a/device/mpp/sample/venc/sock.h b/device/mpp/sample/venc/sock.h new file mode 100644 index 0000000..a972a60 --- /dev/null +++ b/device/mpp/sample/venc/sock.h @@ -0,0 +1,64 @@ +#ifndef __SOCK__ +#define __SOCK__ + +#include "stdio.h" +#ifdef linux +typedef int Sock; +#endif + +#ifdef WIN32 +#include +#include +typedef SOCKET Sock; +#endif +Sock Connect(char *ip,int port); +int Send(Sock s,char*dat, int len); +int Recv(Sock s,char *rec,int len); +/* +ANNOUNCE rtsp://118.24.238.198:554/Sword RTSP/1.0 +CSeq: 1 +User-Agent: EasyPusher v1.2.16.1105 +Content-Type: application/sdp + Content-Length: 384 + +v=0 +o=- 0 0 IN IP4 127.0.0.1 +s=EasyDarwin +i=EasyDarwin +c=IN IP4 127.0.0.1 +t=0 0 +a=x-qt-text-nam:EasyDarwin + a=x-qt-text-inf:EasyDarwin + a=x-qt-text-cmt:source application::EasyDarwin +a=x-qt-text-aut: +a=x-qt-text-cpy: +m=video 0 RTP/AVP 96 +a=rtpmap:96 H264/90000 +a=fmtp:96 packetization-mode=1;sprop-parameter-sets=,2QAKKy0A8ARPywgAAADACAAAAMD0eMGVA== +a=control:streamid=0 + +ANNOUNCE rtsp://118.24.238.198:554/Sword RTSP/1.0 +CSeq: 1 +User-Agent: EasyPusher v1.2.16.1105 +Content-Type: application/sdp +Content-Length: 384 + +v=0 +o=- 0 0 IN IP4 127.0.0.1 +s=EasyDarwin +i=EasyDarwin +c=IN IP4 127.0.0.1 +t=0 0 +a=x-qt-text-nam:EasyDarwin +a=x-qt-text-inf:EasyDarwin +a=x-qt-text-cmt:source application::EasyDarwin +a=x-qt-text-aut: +a=x-qt-text-cpy: +m=video 0 RTP/AVP 96 +a=rtpmap:96 H264/90000 +a=fmtp:96 packetization-mode=1;sprop-parameter-sets=,2QAKKy0A8ARPywgAAADACAAAAMD0eMGVA== +a=control:streamid=0 + +*/ + +#endif \ No newline at end of file diff --git a/device/mpp/sample/venc/su.IAB b/device/mpp/sample/venc/su.IAB deleted file mode 100644 index e247b84..0000000 Binary files a/device/mpp/sample/venc/su.IAB and /dev/null differ diff --git a/device/mpp/sample/venc/su.IAD b/device/mpp/sample/venc/su.IAD deleted file mode 100644 index 1d127c0..0000000 Binary files a/device/mpp/sample/venc/su.IAD and /dev/null differ diff --git a/device/mpp/sample/venc/su.IMB b/device/mpp/sample/venc/su.IMB deleted file mode 100644 index b6ca0c5..0000000 Binary files a/device/mpp/sample/venc/su.IMB and /dev/null differ diff --git a/device/mpp/sample/venc/su.IMD b/device/mpp/sample/venc/su.IMD deleted file mode 100644 index 1146b0c..0000000 Binary files a/device/mpp/sample/venc/su.IMD and /dev/null differ diff --git a/device/mpp/sample/venc/su.PFI b/device/mpp/sample/venc/su.PFI deleted file mode 100644 index 7910bd0..0000000 Binary files a/device/mpp/sample/venc/su.PFI and /dev/null differ diff --git a/device/mpp/sample/venc/su.PO b/device/mpp/sample/venc/su.PO deleted file mode 100644 index fffca12..0000000 Binary files a/device/mpp/sample/venc/su.PO and /dev/null differ diff --git a/device/mpp/sample/venc/su.PR b/device/mpp/sample/venc/su.PR deleted file mode 100644 index b7d14bc..0000000 Binary files a/device/mpp/sample/venc/su.PR and /dev/null differ diff --git a/device/mpp/sample/venc/su.PRI b/device/mpp/sample/venc/su.PRI deleted file mode 100644 index abff1c3..0000000 Binary files a/device/mpp/sample/venc/su.PRI and /dev/null differ diff --git a/device/mpp/sample/venc/su.PS b/device/mpp/sample/venc/su.PS deleted file mode 100644 index 0f36bf7..0000000 Binary files a/device/mpp/sample/venc/su.PS and /dev/null differ diff --git a/device/mpp/sample/venc/su.WK3 b/device/mpp/sample/venc/su.WK3 deleted file mode 100644 index cf96a41..0000000 Binary files a/device/mpp/sample/venc/su.WK3 and /dev/null differ