1 // Copyright 2020-2022 Rockchip Electronics Co., Ltd. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef __RTSP_DEMO_H__ 6 #define __RTSP_DEMO_H__ 7 /* 8 * a simple RTSP server demo 9 * RTP over UDP/TCP H264/G711a 10 * */ 11 12 #include <stdint.h> 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 enum rtsp_codec_id { 19 RTSP_CODEC_ID_NONE = 0, 20 RTSP_CODEC_ID_VIDEO_H264 = 0x0001, /*codec_data is SPS + PPS frames*/ 21 RTSP_CODEC_ID_VIDEO_H265, /*codec_data is VPS + SPS + PPS frames*/ 22 RTSP_CODEC_ID_VIDEO_MPEG4, /*now not support*/ 23 RTSP_CODEC_ID_AUDIO_G711A = 0x4001, /*codec_data is NULL*/ 24 RTSP_CODEC_ID_AUDIO_G711U, /*codec_data is NULL*/ 25 RTSP_CODEC_ID_AUDIO_G726, /*codec_data is bitrate (int)*/ 26 RTSP_CODEC_ID_AUDIO_MP3, /*codec_data is audio specific config (2bytes). frame 27 type is MP3*/ 28 }; 29 30 typedef void *rtsp_demo_handle; 31 typedef void *rtsp_session_handle; 32 33 rtsp_demo_handle rtsp_new_demo(int port); 34 rtsp_demo_handle create_rtsp_demo(int port); 35 int rtsp_do_event(rtsp_demo_handle demo); 36 rtsp_session_handle rtsp_new_session(rtsp_demo_handle demo, const char *path); 37 rtsp_session_handle create_rtsp_session(rtsp_demo_handle demo, const char *path); 38 int rtsp_set_video(rtsp_session_handle session, int codec_id, const uint8_t *codec_data, 39 int data_len); 40 41 int rtsp_set_audio(rtsp_session_handle session, int codec_id, const uint8_t *codec_data, 42 int data_len); 43 int rtsp_set_audio_sample_rate (rtsp_session_handle session,int sample_rate); 44 int rtsp_set_audio_channels (rtsp_session_handle session,int channels); 45 46 int rtsp_sever_tx_video(rtsp_demo_handle demo, rtsp_session_handle session, const uint8_t *frame, 47 int len, uint64_t ts); 48 int rtsp_tx_video(rtsp_session_handle session, const uint8_t *frame, int len, uint64_t ts); 49 int rtsp_tx_audio(rtsp_session_handle session, const uint8_t *frame, int len, uint64_t ts); 50 void rtsp_del_session(rtsp_session_handle session); 51 void rtsp_del_demo(rtsp_demo_handle demo); 52 53 uint64_t rtsp_get_reltime(void); 54 uint64_t rtsp_get_ntptime(void); 55 int rtsp_sync_video_ts(rtsp_session_handle session, uint64_t ts, uint64_t ntptime); 56 int rtsp_sync_audio_ts(rtsp_session_handle session, uint64_t ts, uint64_t ntptime); 57 58 #ifdef __cplusplus 59 } 60 #endif 61 #endif