Red5Pro IOS Client SDK

 10.0.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
13extern "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 10
25#define R5PRO_MINOR_VERSION 0
26#define R5PRO_REVISION 0
27#define R5PRO_BUILD b826
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)
146
151 typedef enum r5_media_type{
157
162 typedef enum r5_stream_format {
163 r5_stream_format_unknown,
168
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
217
221 double now_ms(void);
222
223
227 typedef struct r5_stats{
228
238
248
249 }r5_stats;
250
258 r5_stats *r5_client_stats(client_ctx* client);
259
260void freeEndPause(void);
261
262
263#ifdef __cplusplus
264}
265#endif
266
267#endif
r5_buffer_state
Definition: global.h:130
const char * r5_string_for_status(int status)
r5_status
Definition: global.h:92
r5_protocol
Definition: global.h:173
void r5_set_log_level(int level)
int r5_get_log_level(void)
r5_scale_mode
Definition: global.h:141
r5_stream_mode
Definition: global.h:120
enum r5_stream_mode r5_stream_mode_t
r5_media_type
Definition: global.h:151
r5_stream_format
Definition: global.h:162
r5_log_level
Definition: global.h:81
@ r5_status_hardware_decode_error
There was a problem using hardware acceleration to start decode of incoming stream.
Definition: global.h:113
@ r5_status_license_error
An error in validating the SDK license.
Definition: global.h:105
@ r5_status_stop_streaming
Streaming content has stopped.
Definition: global.h:99
@ r5_status_video_mute
Publisher has muted their video stream.
Definition: global.h:103
@ r5_status_audio_mute
Publisher has muted their audio stream.
Definition: global.h:101
@ r5_status_buffer_flush_empty
Publisher has completed flushing queued packets post-broadcast.
Definition: global.h:108
@ r5_status_buffer_flush_start
Publisher has started flushing queued packets post-broadcast.
Definition: global.h:107
@ r5_status_abr_level_change
ABR Publisher has changed broadcast level.
Definition: global.h:110
@ r5_status_audio_unmute
Publisher has unmuted their audio stream.
Definition: global.h:102
@ r5_status_connection_error
There was an error with the connection.
Definition: global.h:95
@ r5_status_video_unmute
Publisher has unmuted their video stream.
Definition: global.h:104
@ r5_status_license_valid
The license key provided for the SDK is deemed valid.
Definition: global.h:106
@ r5_status_start_streaming
Streaming content has begun as a publisher or subscriber.
Definition: global.h:98
@ r5_status_srtp_key_handle_error
There was a problem in the key exchange with the server.
Definition: global.h:112
@ r5_status_connected
A connection with the server has been established. Streaming has not started yet.
Definition: global.h:93
@ r5_status_netstatus
A netstatus event has been received from the server.
Definition: global.h:100
@ r5_status_disconnected
The connection with the server has been lost.
Definition: global.h:94
@ r5_status_video_render_start
Subscriber has rendered first video frame.
Definition: global.h:109
@ r5_status_connection_close
The connection is fully closed. Wait for this before releasing assets.
Definition: global.h:97
@ r5_status_srtp_key_gen_error
There was a problem generating a key on this device.
Definition: global.h:111
@ r5_status_connection_timeout
The connection has failed due to timeout.
Definition: global.h:96
@ r5_media_type_audio_custom
Custom audio source.
Definition: global.h:155
@ r5_media_type_video_custom
Custom video source.
Definition: global.h:154
@ r5_media_type_video
Standard video using R5Camera.
Definition: global.h:152
@ r5_media_type_audio
Standard audio using R5Microphone.
Definition: global.h:153
@ r5_stream_format_yuv_planar
Non-hardware accelerated YUV. Parses frames into YUV 3 planes.
Definition: global.h:165
@ r5_stream_format_rgb
Non-hardware accelerated RGB. Uses SW Scalar for decode.
Definition: global.h:164
@ r5_stream_format_yuv_biplanar
Non-hardware accelerated YUV. Parses frame to YUV bi-planar format.
Definition: global.h:166
Definition: global.h:227
long socket_queue_size
Num Packets queued to be sent out.
Definition: global.h:243
long pkts_audio_dropped
Incoming audio packets dropped.
Definition: global.h:236
int nb_video_frames
Number of queued video frames to be played.
Definition: global.h:232
float buffered_time
Length of content that has been received on socket.
Definition: global.h:229
float video_decode_smoothed
How long it takes to decode video packet.
Definition: global.h:247
int subscribe_queue_size
Number of audio/video frames waiting for decode.
Definition: global.h:230
long total_bytes_sent
total bytes sent by stream
Definition: global.h:240
float subscribe_bitrate
Subscribing bitrate (not smoothed)
Definition: global.h:241
long total_bytes_received
Total bytes received by stream.
Definition: global.h:239
float bitrate_received_smoothed
Smoothed incoming bitrate.
Definition: global.h:245
long publish_pkts_dropped
Total audio/video packets dropped due to latency.
Definition: global.h:237
long pkts_video_dropped
Incoming video packets dropped.
Definition: global.h:235
float subscribe_latency
How far behind subscriber clock the stream is arriving.
Definition: global.h:246
float publish_bitrate
Publishing bitrate (not smoothed)
Definition: global.h:242
float bitrate_sent_smoothed
Smoothed outgoing bitrate.
Definition: global.h:244
long pkts_received
Num Received packets.
Definition: global.h:233
long pkts_sent
Num Sent packets.
Definition: global.h:234
int nb_audio_frames
Number of queued audio frames to be played.
Definition: global.h:231