📄 librtsp.h
字号:
#ifndef LIBRTSP_H#define LIBRTSP_H 1#ifdef __cplusplusextern "C" {#endif#include <stdio.h>#include <sys/socket.h>#include <netinet/in.h>#include "afi.h" /** * An rtspcontext_t identifies an RTSP context, or session * with the server. */ typedef void * rtspcontext_t; /** * Create an rtsp context for the given destination URL. * * @param url is the RTSP url. use rtsp:// for TCP * and rtspu:// for udp. * * @return the rtspcontext_t identifying the session. */ extern rtspcontext_t RTSP_Create(const char *url); /** * Destroy an RTSP context associated with a session. * removes any datastructure associated with it. */ extern void RTSP_Destroy(rtspcontext_t c); /** * Describe a given RTSP session, returns the SDP of the * session from the server. */ char *RTSP_Describe(rtspcontext_t c); /** * Open an RTSP stream for play or record mode. This establishes a * TCP connection with the RTSP server sends SETUP message as * appropriate, and thus opens the RTSP session with the server. * * @param url gives the RTSP URL of the destination. * * @param media gives the IP and port for media for receiving * rtp packets. rtcp port is rtp+1. The port and IP address * are in network byte order. IP address can be IPv4 or * IPv6, distinguished by media->ss_family which must be set. * * @param mode can be either "play" or "record". * * @return 0 for success and < 0 for failure. */ extern int RTSP_Setup(rtspcontext_t c, const char *mode, const struct sockaddr_storage *media, const char *body); /** * Close the RTSP stream by sending a TEARDOWN message to * the server. * * @return 0 for success and < 0 for failure. */ extern int RTSP_Teardown(rtspcontext_t c); /** * Play an rtsp stream. * * @return 0 for success and < 0 for failure. */ extern int RTSP_Play(rtspcontext_t c); /** * Play the rtsp stream on a given timerange. * * @param starttime and endtime can be from a variety of * different time values. * * @return 0 for success and < 0 for failure. */ extern int RTSP_PlayRange(rtspcontext_t c, const char * starttime, const char * endtime); /** * Start recording of an rtsp stream. * * @return 0 for success and < 0 for failure. */ extern int RTSP_Record(rtspcontext_t c, long maxsize); /** * Pause an RTSP stream, either for play or record. * * @return 0 for success and < 0 for failure. */ extern int RTSP_Pause(rtspcontext_t c); /** * Set the destination address in SETUP message. */ extern void RTSP_SetDestinationAddress(rtspcontext_t c, const char *addr); /** * Set the client port for SETUP. */ extern void RTSP_SetClientPort(rtspcontext_t c, unsigned short port); /** * Get the server address for recording purpose. * The caller should free the memory of the returned string. * @return server address of the RTSP server is a null terminated * string. If error, returns NULL. */ extern char * RTSP_GetServerAddress(rtspcontext_t c); /** * Get the server port for recording. */ extern unsigned short RTSP_GetServerPort(rtspcontext_t c); /** * Seek into the RTSP play stream. */ extern int RTSP_Seek(rtspcontext_t c, const char *seektime); /** * Get the RTSP session id if you want to associate it with * other part of the protocol e.g., with SIP callid. * The caller should free the returned null terminated * session id string. */ extern char * RTSP_GetSessionId(rtspcontext_t c); /** * Get the duration */ extern float RTSP_GetDuration(rtspcontext_t c);#ifdef __cplusplus}#endif#endif#ifndef RTSPClose_H#define RTSPClose_H#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -