Red5Pro IOS Client SDK

 7.3.0
Core SDK for IOS
global.h
1 //
2 // global.h
3 // Red5Pro
4 //
5 // Created by Andy Zupko on 9/15/14.
6 // Copyright (c) 2014 Infrared5. All rights reserved.
7 //
8 
9 #ifndef Red5Pro_global_h
10 #define Red5Pro_global_h
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #include <stdlib.h>
17 #ifdef IS_IOS
18 #include <pthread.h>
19 #endif
20 
21 #define STRINGIFY_(s) #s
22 #define STRINGIFY(s) STRINGIFY_(s)
23 
24 #define R5PRO_MAJOR_VERSION 7
25 #define R5PRO_MINOR_VERSION 3
26 #define R5PRO_REVISION 0
27 #define R5PRO_BUILD 0
28 
29 
30 #define R5PRO_VERSION STRINGIFY(R5PRO_MAJOR_VERSION.R5PRO_MINOR_VERSION.R5PRO_REVISION.R5PRO_BUILD)
31 #define R5PRO_VERSION_ISRELEASE 0
32 #define R5PRO_VERSION_CHECK(maj, min) ((maj==MYLIB_MAJOR_VERSION) && (min<=MYLIB_MINOR_VERSION))
33 
34 #define SEC_TO_NANO 1e9
35 #define SEC_TO_MS 1e3
36 
37 #define SW_DECODE_YUV 1
38 
39 #if defined(__APPLE__) && defined(__MACH__)
40 /* Apple OSX and iOS (Darwin). ------------------------------ */
41 #include <TargetConditionals.h>
42 #if TARGET_IPHONE_SIMULATOR == 1
43 /* iOS in Xcode simulator */
44 
45 #elif TARGET_OS_IPHONE == 1
46 /* iOS on iPhone, iPad, etc. */
47 
48 #elif TARGET_OS_MAC == 1
49 /* OSX */
50 
51 #endif
52 #endif
53 
54 #if TARGET_OS_IPHONE == 1
55 #define LOG(...) fprintf(stdout, __VA_ARGS__);
56 #define LOGD(M, ...) if(r5_get_log_level() <= (int)r5_log_level_debug) fprintf(stderr, "[R5 DEBUG]" M "\n", ##__VA_ARGS__)
57 #define LOGI(M, ...) if(r5_get_log_level() <= (int)r5_log_level_info) fprintf(stderr, "[R5 INFO] " M "\n", ##__VA_ARGS__)
58 #define LOGW(M, ...) if(r5_get_log_level() <= (int)r5_log_level_warn) fprintf(stderr, "[R5 WARNING] " M "\n", ##__VA_ARGS__);
59 #define LOGE(M, ...) if(r5_get_log_level() <= (int)r5_log_level_error) fprintf(stderr, "[R5 ERROR] " M "\n", ##__VA_ARGS__);
60 
61 #else
62 #include <android/log.h>
63 #define LOG(...) __android_log_print(ANDROID_LOG_INFO, "r5pro", __VA_ARGS__);
64 #define LOGD(M, ...) if(r5_get_log_level() <= (int)r5_log_level_debug) LOG(M, ##__VA_ARGS__)
65 #define LOGI(M, ...) if(r5_get_log_level() <= (int)r5_log_level_info) LOG( M, ##__VA_ARGS__)
66 #define LOGW(M, ...) if(r5_get_log_level() <= (int)r5_log_level_warn) LOG( M, ##__VA_ARGS__);
67 #define LOGE(M, ...) if(r5_get_log_level() <= (int)r5_log_level_error) LOG(M, ##__VA_ARGS__);
68 #endif
69 
70 #define check_mem(A) check((A), "Out of memory.")
71 
82  r5_log_level_debug,
83  r5_log_level_info,
84  r5_log_level_warn,
85  r5_log_level_error
86  };
87 
92  enum r5_status {
114  };
115 
120  typedef enum r5_stream_mode{
121  r5_stream_mode_stop,
122  r5_stream_mode_subscribe,
123  r5_stream_mode_publish
125 
131  r5_buffer_state_buffered,
132  r5_buffer_state_needs_rebuffer,
133  r5_buffer_state_flush_buffer,
134  r5_buffer_state_rebuffering
135  };
136 
141  typedef enum r5_scale_mode{
142  r5_scale_to_fill, //scale to fill and maintain aspect ratio (cropping will occur)
143  r5_scale_to_fit, //scale to fit inside view (letterboxing will occur)
144  r5_scale_fill //scale to fill view (will not respect aspect ratio of video)
145  }r5_scale_mode;
146 
151  typedef enum r5_media_type{
156  } r5_media_type;
157 
162  typedef enum r5_stream_format {
163  r5_stream_format_unknown,
168 
173  enum r5_protocol {
174  r5_rtsp = 1, //Basic flow
175  r5_srtp = 2, //rtsp with encrypted payloads and hash authentication
176  r5_null_srtp = 3 //srtp without encryption
177  };
178 
179 
183  typedef struct client_ctx client_ctx;
184 
185 
194  const char * r5_string_for_status(int status);
195 
196 
203  void r5_set_log_level(int level);
204 
210  int requires_sdk_license(void);
211 
216  int r5_get_log_level(void);
217 
221  double now_ms(void);
222 
223 
227  typedef struct r5_stats{
228 
234  long pkts_sent;
238 
248 
249  }r5_stats;
250 
258  r5_stats *r5_client_stats(client_ctx* client);
259 
260 
261 #ifdef __cplusplus
262 }
263 #endif
264 
265 #endif
There was an error with the connection.
Definition: global.h:95
int nb_video_frames
Number of queued video frames to be played.
Definition: global.h:232
The license key provided for the SDK is deemed valid.
Definition: global.h:106
r5_media_type
Definition: global.h:151
Standard video using R5Camera.
Definition: global.h:152
r5_log_level
Definition: global.h:81
r5_stream_mode
Definition: global.h:120
Subscriber has rendered first video frame.
Definition: global.h:109
The connection with the server has been lost.
Definition: global.h:94
long total_bytes_sent
total bytes sent by stream
Definition: global.h:240
long pkts_audio_dropped
Incoming audio packets dropped.
Definition: global.h:236
float buffered_time
Length of content that has been received on socket.
Definition: global.h:229
r5_scale_mode
Definition: global.h:141
Publisher has unmuted their video stream.
Definition: global.h:104
r5_status
Definition: global.h:92
long pkts_video_dropped
Incoming video packets dropped.
Definition: global.h:235
int subscribe_queue_size
Number of audio/video frames waiting for decode.
Definition: global.h:230
An error in validating the SDK license.
Definition: global.h:105
Standard audio using R5Microphone.
Definition: global.h:153
Non-hardware accelerated RGB. Uses SW Scalar for decode.
Definition: global.h:164
long socket_queue_size
Num Packets queued to be sent out.
Definition: global.h:243
Publisher has started flushing queued packets post-broadcast.
Definition: global.h:107
Streaming content has begun as a publisher or subscriber.
Definition: global.h:98
Publisher has unmuted their audio stream.
Definition: global.h:102
Definition: global.h:227
int nb_audio_frames
Number of queued audio frames to be played.
Definition: global.h:231
Publisher has completed flushing queued packets post-broadcast.
Definition: global.h:108
The connection is fully closed. Wait for this before releasing assets.
Definition: global.h:97
ABR Publisher has changed broadcast level.
Definition: global.h:110
long total_bytes_received
Total bytes received by stream.
Definition: global.h:239
r5_stream_format
Definition: global.h:162
void r5_set_log_level(int level)
r5_buffer_state
Definition: global.h:130
Publisher has muted their video stream.
Definition: global.h:103
float bitrate_sent_smoothed
Smoothed outgoing bitrate.
Definition: global.h:244
Non-hardware accelerated YUV. Parses frames into YUV 3 planes.
Definition: global.h:165
A connection with the server has been established. Streaming has not started yet. ...
Definition: global.h:93
float subscribe_latency
How far behind subscriber clock the stream is arriving.
Definition: global.h:246
Custom audio source.
Definition: global.h:155
Custom video source.
Definition: global.h:154
long pkts_sent
Num Sent packets.
Definition: global.h:234
const char * r5_string_for_status(int status)
float publish_bitrate
Publishing bitrate (not smoothed)
Definition: global.h:242
Streaming content has stopped.
Definition: global.h:99
float subscribe_bitrate
Subscribing bitrate (not smoothed)
Definition: global.h:241
There was a problem generating a key on this device.
Definition: global.h:111
A netstatus event has been received from the server.
Definition: global.h:100
r5_protocol
Definition: global.h:173
There was a problem using hardware acceleration to start decode of incoming stream.
Definition: global.h:113
There was a problem in the key exchange with the server.
Definition: global.h:112
The connection has failed due to timeout.
Definition: global.h:96
Non-hardware accelerated YUV. Parses frame to YUV bi-planar format.
Definition: global.h:166
float video_decode_smoothed
How long it takes to decode video packet.
Definition: global.h:247
Publisher has muted their audio stream.
Definition: global.h:101
enum r5_stream_mode r5_stream_mode_t
float bitrate_received_smoothed
Smoothed incoming bitrate.
Definition: global.h:245
long pkts_received
Num Received packets.
Definition: global.h:233
long publish_pkts_dropped
Total audio/video packets dropped due to latency.
Definition: global.h:237
int r5_get_log_level(void)