📄 ietf.h
字号:
/* * GPAC - Multimedia Framework C SDK * * Copyright (c) Jean Le Feuvre 2000-2005 * All rights reserved * * This file is part of GPAC / IETF RTP/RTSP/SDP sub-project * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */#ifndef _GF_IETF_H_#define _GF_IETF_H_#ifdef __cplusplusextern "C" {#endif#include <gpac/list.h>#include <gpac/bitstream.h>#include <gpac/sync_layer.h>#include <gpac/network.h>/**************************************************************************** RTSP VERSION 1.0 LIBRARY EXPORTS****************************************************************************/#define GF_RTSP_VERSION "RTSP/1.0"/* * RTSP NOTIF CODES */enum{ NC_RTSP_Continue = 100, NC_RTSP_OK = 200, NC_RTSP_Created = 201, NC_RTSP_Low_on_Storage_Space = 250, NC_RTSP_Multiple_Choice = 300, NC_RTSP_Moved_Permanently = 301, NC_RTSP_Moved_Temporarily = 302, NC_RTSP_See_Other = 303, NC_RTSP_Use_Proxy = 305, NC_RTSP_Bad_Request = 400, NC_RTSP_Unauthorized = 401, NC_RTSP_Payment_Required = 402, NC_RTSP_Forbidden = 403, NC_RTSP_Not_Found = 404, NC_RTSP_Method_Not_Allowed = 405, NC_RTSP_Not_Acceptable = 406, NC_RTSP_Proxy_Authentication_Required = 407, NC_RTSP_Request_Timeout = 408, NC_RTSP_Gone = 410, NC_RTSP_Length_Required = 411, NC_RTSP_Precondition_Failed = 412, NC_RTSP_Request_Entity_Too_Large = 413, NC_RTSP_Request_URI_Too_Long = 414, NC_RTSP_Unsupported_Media_Type = 415, NC_RTSP_Invalid_parameter = 451, NC_RTSP_Illegal_Conference_Identifier = 452, NC_RTSP_Not_Enough_Bandwidth = 453, NC_RTSP_Session_Not_Found = 454, NC_RTSP_Method_Not_Valid_In_This_State = 455, NC_RTSP_Header_Field_Not_Valid = 456, NC_RTSP_Invalid_Range = 457, NC_RTSP_Parameter_Is_ReadOnly = 458, NC_RTSP_Aggregate_Operation_Not_Allowed = 459, NC_RTSP_Only_Aggregate_Operation_Allowed = 460, NC_RTSP_Unsupported_Transport = 461, NC_RTSP_Destination_Unreachable = 462, NC_RTSP_Internal_Server_Error = 500, NC_RTSP_Not_Implemented = 501, NC_RTSP_Bad_Gateway = 502, NC_RTSP_Service_Unavailable = 503, NC_RTSP_Gateway_Timeout = 504, NC_RTSP_RTSP_Version_Not_Supported = 505, NC_RTSP_Option_not_support = 551,};const char *gf_rtsp_nc_to_string(u32 ErrCode);/* Common structures between commands and responses*//* RTSP Range information - RTSP Session level only (though this is almost the same format as an SDP range, this is not used in the SDP lib as "a=range" is not part of SDP but part of RTSP*/typedef struct { /* start and end range. If end is -1, the range is open (from start to unknown) */ Double start, end; /* use SMPTE range (Start and End specify the number of frames) (currently not supported) */ u32 UseSMPTE; /* framerate for SMPTE range */ Double FPS;} GF_RTSPRange;/*parses a Range line and returns range header structure. can be used for RTSP extension of SDPNB: Only support for npt for now*/GF_RTSPRange *gf_rtsp_range_parse(char *range_buf);GF_RTSPRange *gf_rtsp_range_new();void gf_rtsp_range_del(GF_RTSPRange *range);/* Transport structure contains all network info for RTSP sessions (ports, uni/multi-cast, ...)*//* Transport Profiles as defined in RFC 2326*/#define GF_RTSP_PROFILE_RTP_AVP "RTP/AVP"#define GF_RTSP_PROFILE_RTP_AVP_TCP "RTP/AVP/TCP"#define GF_RTSP_PROFILE_UDP "udp"typedef struct{ /* set to 1 if unicast */ Bool IsUnicast; /* for multicast */ char *destination; /* for redirections internal to servers */ char *source; /*IsRecord is usually 0 (PLAY) . If set, Append specify that the stream should be concatenated to existing resources */ Bool IsRecord, Append; /* in case transport is on TCP/RTSP, If only 1 ID is specified, it is stored in rtpID (this is not RTP interleaving) */ Bool IsInterleaved, rtpID, rtcpID; /* Multicast specific */ u32 MulticastLayers; u8 TTL; /*RTP specific*/ /*port for multicast*/ /*server port in unicast - RTP implies low is even , and last is low+1*/ u16 port_first, port_last; /*client port in unicast - RTP implies low is even , and last is low+1*/ u16 client_port_first, client_port_last; u32 SSRC; /*Transport protocol. In this version we only support RTP/AVP, the following flag tells us if this is RTP/AVP/TCP or RTP/AVP (default)*/ char *Profile;} GF_RTSPTransport;GF_RTSPTransport *gf_rtsp_transport_clone(GF_RTSPTransport *original);void gf_rtsp_transport_del(GF_RTSPTransport *transp);/* RTSP Command the RTSP Response is sent by a client / recieved by a server text Allocation is done by the lib when parsing a command, and is automatically freed when calling reset / delete. Therefore you must set/allocate the fields yourself when writing a command (client)*//*ALL RTSP METHODS - all other methods will be ignored*/#define GF_RTSP_DESCRIBE "DESCRIBE"#define GF_RTSP_SETUP "SETUP"#define GF_RTSP_PLAY "PLAY"#define GF_RTSP_PAUSE "PAUSE"#define GF_RTSP_RECORD "RECORD"#define GF_RTSP_TEARDOWN "TEARDOWN"#define GF_RTSP_GET_PARAMETER "GET_PARAMETER"#define GF_RTSP_SET_PARAMETER "SET_PARAMETER"#define GF_RTSP_OPTIONS "OPTIONS"#define GF_RTSP_ANNOUNCE "ANNOUNCE"#define GF_RTSP_REDIRECTE "REDIRECT"typedef struct{ char *Accept; char *Accept_Encoding; char *Accept_Language; char *Authorization; u32 Bandwidth; u32 Blocksize; char *Cache_Control; char *Conference; char *Connection; u32 Content_Length; u32 CSeq; char *From; char *Proxy_Authorization; char *Proxy_Require; GF_RTSPRange *Range; char *Referer; Double Scale; char *Session; Double Speed; /*nota : RTSP allows several configurations for a single channel (multicast and unicast , ...). Usually only 1*/ GF_List *Transports; char *User_Agent; /*type of the command, one of the described above*/ char *method; /*Header extensions*/ GF_List *Xtensions; /*body of the command, size is Content-Length (auto computed when sent). It is not terminated by a NULL char*/ char *body; /* Specify ControlString if your request targets a specific media stream in the service. If null, the service name only will be used for control (for ex, both A and V streams in a single file) If the request is GF_RTSP_OPTIONS, you must provide a control string containing the options you want to query */ char *ControlString; /*user data: this is never touched by the lib, its intend is to help stacking RTSP commands in your app*/ void *user_data; /* Server side Extensions */ /*full URL of the command. Not used at client side, as the URL is ALWAYS relative to the server / service of the RTSP session On the server side however redirections are up to the server, so we cannot decide for it */ char *service_name; /*RTSP status code of the command as parsed. One of the above RTSP StatusCode*/ u32 StatusCode;} GF_RTSPCommand;GF_RTSPCommand *gf_rtsp_command_new();void gf_rtsp_command_del(GF_RTSPCommand *com);void gf_rtsp_command_reset(GF_RTSPCommand *com);/* RTSP Response the RTSP Response is recieved by a client / sent by a server text Allocation is done by the lib when parsing a response, and is automatically freed when calling reset / delete. Therefore you must allocate the fields yourself when writing a response (server)*//* RTP-Info for RTP channels. There may be several RTP-Infos in one response based on the server implementation (DSS/QTSS begaves this way)*/typedef struct{ /*control string of the channel*/ char *url; /*seq num for asociated rtp_time*/ u32 seq; /*rtp TimeStamp corresponding to the Range start specified in the PLAY request*/ u32 rtp_time; /*ssrc of sender if known, 0 otherwise*/ u32 ssrc;} GF_RTPInfo;/* RTSP Response*/typedef struct{ /* response code*/ u32 ResponseCode; /* comment from the server */ char *ResponseInfo; /* Header Fields */ char *Accept; char *Accept_Encoding; char *Accept_Language; char *Allow; char *Authorization; u32 Bandwidth; u32 Blocksize; char *Cache_Control; char *Conference; char *Connection; char *Content_Base; char *Content_Encoding; char *Content_Language; u32 Content_Length; char *Content_Location; char *Content_Type; u32 CSeq; char *Date; char *Expires; char *From; char *Host; char *If_Match; char *If_Modified_Since; char *Last_Modified; char *Location; char *Proxy_Authenticate; char *Proxy_Require; char *Public; GF_RTSPRange *Range; char *Referer; char *Require; char *Retry_After; GF_List *RTP_Infos; Double Scale; char *Server; char *Session; u32 SessionTimeOut; Double Speed; char *Timestamp; /*nota : RTSP allows several configurations for a single channel (multicast and unicast , ...). Usually only 1*/ GF_List *Transports; char *Unsupported; char *User_Agent; char *Vary; char *Via; char *WWW_Authenticate; /*Header extensions*/ GF_List *Xtensions; /*body of the response, size is Content-Length (auto computed when sent). It is not terminated by a NULL char when response is parsed but must be null-terminated when response is being sent*/ char *body;} GF_RTSPResponse;GF_RTSPResponse *gf_rtsp_response_new();void gf_rtsp_response_del(GF_RTSPResponse *rsp);void gf_rtsp_response_reset(GF_RTSPResponse *rsp);typedef struct _tag_rtsp_session GF_RTSPSession;GF_RTSPSession *gf_rtsp_session_new(char *sURL, u16 DefaultPort);void gf_rtsp_session_del(GF_RTSPSession *sess);GF_Err gf_rtsp_set_buffer_size(GF_RTSPSession *sess, u32 BufferSize);/*Reset state machine, invalidate SessionIDNOTE: RFC2326 requires that the session is reseted when all RTP streamsare closed. As this lib doesn't maintain the number of valid streamsyou MUST call reset when all your streams are shutdown (either requested throughTEARDOWN or signaled through RTCP BYE packets for RTP, or any other signaling meansfor other protocols)reset connection will destroy the socket - this is isefull in case of timeouts, becausesome servers do not restart with the right CSeq...*/void gf_rtsp_session_reset(GF_RTSPSession *sess, Bool ResetConnection);u32 gf_rtsp_is_my_session(GF_RTSPSession *sess, char *url);const char *gf_rtsp_get_last_session_id(GF_RTSPSession *sess);char *gf_rtsp_get_server_name(GF_RTSPSession *sess);char *gf_rtsp_get_service_name(GF_RTSPSession *sess);u16 gf_rtsp_get_session_port(GF_RTSPSession *sess);/*Fetch an RTSP response from the server the GF_RTSPResponse will be reseted before fetch*/GF_Err gf_rtsp_get_response(GF_RTSPSession *sess, GF_RTSPResponse *rsp);/*RTSP State Machine. The only non blocking mode is GF_RTSP_STATE_WAIT_FOR_CONTROL*/enum{ /*Initialized (connection might be off, but all structures are in place) This is the default state between # requests (aka, DESCRIBE and SETUP or SETUP and PLAY ...)*/ GF_RTSP_STATE_INIT = 0, /*Waiting*/ GF_RTSP_STATE_WAITING, /*PLAY, PAUSE, RECORD. Aggregation is allowed for the same type, you can send several command in a row. However the session will return GF_SERVICE_ERROR if you do not have a valid SessionID in the command You cannot issue a SETUP / DESCRIBE while in this state*/ GF_RTSP_STATE_WAIT_FOR_CONTROL, /*FATAL ERROR: session is invalidated by server. Call reset and restart from SETUP if needed*/ GF_RTSP_STATE_INVALIDATED};u32 gf_rtsp_get_session_state(GF_RTSPSession *sess);/*aggregate command state-machine: the PLAY/PAUSE can be aggregated (sent before the reply is recieved). This function gets the last command sent*/char *gf_rtsp_get_last_request(GF_RTSPSession *sess);/*foce a reset in case of pbs*/void gf_rtsp_reset_aggregation(GF_RTSPSession *sess);/* Send an RTSP request to the server.*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -