资源简介
用C语言编写的RTSP的客户端,在海思平台经过数据验证。
代码片段和文件信息
/*=============================================================================
# FileName: rtspRequest.c
# Desc: client connect to RTSP server
# Author: licaibiao
# LastChange: 2017-04-19
=============================================================================*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define MAXBUF 1024
void Handel_OPTION(char *inbuffer);
void Handel_DESCRIBE(char *inbuffer int sockfd);
void Handel_SETUP(char *inbuffer int sockfd);
void Handel_PLAY(char *inbuffer int sockfdchar *sessionId);
void Handle_PAUSE(char *inbufferint sockfd char *sessionId);
void Handel_Teardown(char *inbuffer int sockfdchar *sessionId);
int intsearch(char * buf char * searchStr int len);
int strsearch(char * buf char * searchStr int lenchar *dest);
int init_udpsocket(int port struct sockaddr_in *servaddr char *mcast_addr);
void release_udpsocket(int socket_fd char *mcast_addr);
void proc_udpsocket(int socket_fd struct sockaddr_in servaddrint flag);
char sendOPTRequstStr[] = “OPTIONS rtsp://192.168.0.6:8554/testStream RTSP/1.0\r\n“;
char userAgentStr[] = “virtual client player\r\n“;
char successfullyReplyStr[] = “RTSP/1.0 200 OK\r\n“;
char sendDESRequstStr[] = “DESCRIBE rtsp://192.168.0.6:8554/testStream RTSP/1.0\r\n“;
char sendSETUPRequstStr[] = “SETUP rtsp://192.168.0.6:8554/testStream/track1 RTSP/1.0\r\n“;
char sendPLAYRequstStr[] = “PLAY rtsp://192.168.0.6:8554/testStream/ RTSP/1.0\r\n“;
char sendTeardownRequestStr[]=“TEARDOWN rtsp://192.168.0.6:8554/testStream/ RTSP/1.0\r\n“;
char sendPauseRequestStr[]=“PAUSE rtsp://192.168.0.6:8554/testStream/ RTSP/1.0\r\n“;
char CseqHeadStr[] = “Cseq: “;
char UserHeadStr[] = “User-Agent: “;
char ApplicationHeadStr[] = “Accept: “;
char TransportHeadStr[] = “Transport: “;
char SessionHeadStr[] = “Session: “;
char RangeHeadStr[] = “Range: “;
int cseqCount=0;
int main(int argc char **argv)
{
int sockfdrtpsockfdrtcpsockfd len;
struct sockaddr_in dest;
struct sockaddr_in RTPAddr;
struct sockaddr_in RTCPAddr;
char serverIP[]=“192.168.0.6“;
char mcast_addr[] = “232.231.110.2“;
char buffer[MAXBUF + 1] = {0};
int serverPort=8554;
int udpPort=0;
cseqCount=0;
/* creat socket for rtsp */
if ((sockfd = socket(AF_INET SOCK_STREAM 0)) < 0) {
perror(“Socket“);
exit(errno);
}
printf(“socket created\n“);
/* init server add and port */
bzero(&dest sizeof(dest));
dest.sin_family = AF_INET;
dest.sin_port = htons(serverPort);
if (inet_pton(AF_INET serverIP &dest.sin_addr) < 0 ) {
perror(serverIP);
exit(errno);
}
printf(“address created\n“);
/* connect to server */
- 上一篇:单片机C语言实现流水灯,跑马灯仿真程序
- 下一篇:简单文本编辑器C++
相关资源
- RTSP请求客户端
- 最小RTSP服务器,C语言代码
- linux下最小RTSP服务器实现
- HisiGpio.cpp
- RTSP流媒体协议实现源代码 含客户端和
- RTSPRTP服务器+客户端 C++ 源代码
- DSS中的RTSPclientLib程序
- RTSPRTP C++ 源代码
- 将音视频文件转换为rtsp流(live555 媒
- 用opencv处理RTSP视频流,其中视频流的
-
超值QT5之mediapla
yer实现RTSP以及本地 - QT+opencv打开RTSP视频流多线程
- QT写成的远程视频监控系统 -RTSPTool
- ffmpeg获取RTSP视频流信息
- web 播放rtsp视频流(含服务端以及使用
- C++ RTSP/RTP流媒体服务器源码
评论
共有 条评论