# octopus_rtsp_client_api **Repository Path**: hetbsoft/octopus_rtsp_client_api ## Basic Information - **Project Name**: octopus_rtsp_client_api - **Description**: No description available - **Primary Language**: C - **License**: 0BSD - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-10-09 - **Last Updated**: 2022-09-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # octopus_rtsp_client_api #### 介绍 rtsp协议拉流库 #### 调用流程 ![输入图片说明](frame.png) #### 使用说明 ``` /** * @brief RTSP客户端事件回调 * * @note 调用者调用octopus_rtsp_client_open_stream,out_rtp_packet 设置为1时(输出RTP),RTP包格式如下 * 4个字节 + rtp头 + 负载 * 4个字节 = 1个字节($) + 1个字节(流类型) + 2个字节(rtp头 + 负载长度) * 设计思路: * 1、 rtp over rtsp模式下,rtsp打包标准的要求,底层替换第二个字节interleaved为流类型 * 2、 rtp over udp模式下,底层在RTP头前添加了这4个字节(为了支持rtp over rtsp) * 3、 流媒体也会调用这个动态库做转发(支持RTSP协议转发),减少内存拷贝,提高转发性能 */ typedef SInt32 (*rtsp_client_event_call_back)(RTSPClientHandle handle, UInt32 event, void *data, UInt32 len, void *context); #ifdef __cplusplus extern "C" { #endif // 初始化 SInt32 octopus_rtsp_client_init(const char *local_ip, UInt32 base_port, UInt32 range, rtsp_client_event_call_back cb); /** * @brief 打开流 * * @param rtspUrl rtsp url * @param conn_type 连接类型,OCTOPUS_RTP_OVER_RTSP_TCP、OCTOPUS_RTP_OVER_UDP * @param media_type 媒体类型,OCTOPUS_MEDIA_TYPE_VIDEO、OCTOPUS_MEDIA_TYPE_AUDIO * @param out_rtp_packet 0:回调输出完整的帧 * 1:输出RTP包 * @param heart_beat_type 0x00:不发送心跳 * 0x01:OPTIONS * 0x02:GET_PARAMETER * @param context 用户指针 * @note 1、同步接口 * 2、不支持重连 */ RTSPClientHandle octopus_rtsp_client_open_stream(const char *rtspUrl, UInt8 rtp_transport_type, UInt8 media_type, UInt8 out_rtp_packet = 0, UInt8 heart_beat_type = 0x01, void *context = NULL); // 获取媒体信息 SInt32 octopus_rtsp_client_get_mediaInfo(RTSPClientHandle handle, OctopusMediaInfo* media_info); /** * @brief 关闭流 * * @note 1、当事件回调里结束到流断开事件时,必须调用octopus_rtsp_client_close_stream释放底层资源 * 2、不要在回调接口里调用octopus_rtsp_client_close_stream */ SInt32 octopus_rtsp_client_close_stream(RTSPClientHandle handle); // 反初始化 SInt32 octopus_rtsp_client_deinit(); #ifdef __cplusplus } #endif ``` #### 参与贡献 ![输入图片说明](weixin.png)