1 /* This is an include file for the rtsp over rtp demo programs. It is not part of the official release of NetXDuo RTSP Server or RTP Sender.
2    It is simply a convenience for the user to have a simple demo program to use as a starting point for their application.
3    Please be carefully to read the Note! below and execute the corresponding actions before using this demo program. */
4 
5 #ifndef DEMO_RTSP_OVER_RTP_H
6 #define DEMO_RTSP_OVER_RTP_H
7 
8 /* Determine if a C++ compiler is being used.  If so, ensure that standard
9    C is used to process the API information.  */
10 
11 #ifdef   __cplusplus
12 
13 /* Yes, C++ compiler is present.  Use standard C.  */
14 extern   "C" {
15 #endif
16 
17 #include "tx_api.h"
18 #include "nx_api.h"
19 
20 
21 /* Note!: declare demo events to use in the threads.
22    1. For event triggered RTP sending, user can use below example codes to trigger audio/video data reading and sending by rtp:
23       1) Video data: tx_event_flags_set(&demo_test_events, DEMO_AUDIO_DATA_READY_EVENT, TX_OR);
24       2) Audio data: tx_event_flags_set(&demo_test_events, DEMO_VIDEO_DATA_READY_EVENT, TX_OR);
25    2. For timer timeout trigger RTP sending, user can define the macro DEMO_PLAY_BY_TIMER by uncomment it below.
26 */
27 extern TX_EVENT_FLAGS_GROUP demo_test_events;
28 
29 #define DEMO_ALL_EVENTS                   ((ULONG)0xFFFFFFFF)
30 #define DEMO_PLAY_EVENT                   ((ULONG)0x00000001)
31 #define DEMO_TEARDOWN_EVENT               ((ULONG)0x00000002)
32 #define DEMO_VIDEO_DATA_READY_EVENT       ((ULONG)0x00000004)
33 #define DEMO_AUDIO_DATA_READY_EVENT       ((ULONG)0x00000008)
34 
35 /* Define user defined macros. */
36 /* Using unicast by default, if DEMO_MULTICAST_ENABLED is defined, using multicast. */
37 /*
38 #define DEMO_MULTICAST_ENABLED
39 */
40 
41 /* Using user triggered playing by default, if DEMO_PLAY_BY_TIMER is define, using timer timeout event to play medias. */
42 /*
43 #define DEMO_PLAY_BY_TIMER
44 */
45 
46 /* Define audio format options. */
47 #define DEMO_AUDIO_FORMAT_PCM             0
48 #define DEMO_AUDIO_FORMAT_AAC             1
49 
50 /* Define video format options. */
51 #define DEMO_VIDEO_FORMAT_MJPEG           0
52 #define DEMO_VIDEO_FORMAT_H264            1
53 
54 /* Using AAC by default, user can re-define this macro to one of the audio format options above. */
55 #ifndef DEMO_AUDIO_FORMAT
56 #define DEMO_AUDIO_FORMAT                 DEMO_AUDIO_FORMAT_AAC
57 #endif /* DEMO_AUDIO_FORMAT */
58 
59 /* Using H.264 by default, user can re-define this macro to one of the video format options above. */
60 #ifndef DEMO_VIDEO_FORMAT
61 #define DEMO_VIDEO_FORMAT                 DEMO_VIDEO_FORMAT_H264
62 #endif /* DEMO_VIDEO_FORMAT */
63 
64 
65 /* Note!: Below are user implemented callback functions corresponding declarations. The program uses macros
66       DEMO_MEDIA_DATA_INIT, DEMO_VIDEO_DATA_READ and DEMO_AUDIO_DATA_READ as default callback functions
67       for media data initialization, video data reading and audio data reading separately.
68 
69    1. DEMO_MEDIA_DATA_INIT could be its default value NX_NULL if user does not need to execute any code after RTSP PLAY command is received.
70       Otherwise, user can define a callback with the prototype "VOID (*demo_media_data_init_callback)(VOID)" and implement the callback function.
71 
72    2. DEMO_VIDEO_DATA_READ could be its default value NX_NULL if user does not implement video data reading and transmitting.
73       Otherwise, user MUST! define a callback with the prototype "UINT (*demo_video_data_read_callback)(ULONG *ntp_msw, ULONG *ntp_lsw, UCHAR **data_ptr, ULONG *data_size)"
74       and implement the callback function.
75       Both MJPEG and H264 video formats are frame based, so the callback function should return a complete frame data each time.
76 
77    3. DEMO_AUDIO_DATA_READ could be its default value NX_NULL if user does not implement audio data reading and transmitting.
78       Otherwise, user MUST! define a callback with the prototype "UINT (*demo_audio_data_read_callback)(ULONG *ntp_msw, ULONG *ntp_lsw, UCHAR **data_ptr, ULONG *data_size)"
79       and implement the callback function.
80       By default, PCM audio format is data based, so there is no limitation for the data size returned by the callback function.
81       If the macro DEMO_AAC_ENABLED is enabled, the callback function should return a complete AAC frame data each time.
82 */
83 #ifndef DEMO_MEDIA_DATA_INIT
84 #define DEMO_MEDIA_DATA_INIT  NX_NULL
85 #endif /* DEMO_MEDIA_DATA_INIT */
86 
87 #ifndef DEMO_VIDEO_DATA_READ
88 #define DEMO_VIDEO_DATA_READ  NX_NULL
89 #endif /* DEMO_VIDEO_DATA_READ */
90 
91 #ifndef DEMO_AUDIO_DATA_READ
92 #define DEMO_AUDIO_DATA_READ  NX_NULL
93 #endif /* DEMO_AUDIO_DATA_READ */
94 
95 #endif /* DEMO_RTSP_OVER_RTP_H */
96