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