chenqiyang
2021-08-20 7b95fb4d4549d3452ee17165236186afc1f2b393
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
/*
 * Copyright (c) 2010-2019 Belledonne Communications SARL.
 *
 * This file is part of mediastreamer2.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef mscommon_h
#define mscommon_h
 
#include <bctoolbox/port.h>
#include <bctoolbox/list.h>
#include <bctoolbox/logging.h>
#include <ortp/port.h>
#include <ortp/str_utils.h>
#include <ortp/payloadtype.h>
#include <time.h>
#if defined(__APPLE__)
#include "TargetConditionals.h"
#endif
 
#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM)
#define MS_HAS_ARM 1
#endif
#if defined(__ARM_NEON__) || defined(__ARM_NEON)
#define MS_HAS_ARM_NEON 1
#endif
#if MS_HAS_ARM_NEON && !(defined(__arm64__) || defined(__aarch64__))
#define MS_HAS_ARM_NEON_32 1
#endif
 
#ifndef MS2_DEPRECATED
#if defined(_MSC_VER)
#define MS2_DEPRECATED __declspec(deprecated)
#else
#define MS2_DEPRECATED __attribute__ ((deprecated))
#endif
#endif
#define MS_UNUSED(x) ((void)(x))
 
#define ms_malloc    ortp_malloc
#define ms_malloc0    ortp_malloc0
#define ms_realloc    ortp_realloc
#define ms_new        ortp_new
#define ms_new0        ortp_new0
#define ms_free        ortp_free
#define ms_strdup    ortp_strdup
#define ms_strndup    ortp_strndup
#define ms_strdup_printf    ortp_strdup_printf
#define ms_strcat_printf    ortp_strcat_printf
 
#define ms_mutex_t        ortp_mutex_t
#define ms_mutex_init        ortp_mutex_init
#define ms_mutex_destroy    ortp_mutex_destroy
#define ms_mutex_lock        ortp_mutex_lock
#define ms_mutex_unlock        ortp_mutex_unlock
 
#define ms_cond_t        ortp_cond_t
#define ms_cond_init        ortp_cond_init
#define ms_cond_wait        ortp_cond_wait
#define ms_cond_signal        ortp_cond_signal
#define ms_cond_broadcast    ortp_cond_broadcast
#define ms_cond_destroy        ortp_cond_destroy
 
#define MS_DEFAULT_MAX_PAYLOAD_SIZE 1440
 
#define MS2_INLINE ORTP_INLINE
 
#ifdef _WIN32
#if defined(__MINGW32__) || !defined(WINAPI_FAMILY_PARTITION) || !defined(WINAPI_PARTITION_DESKTOP)
#define MS2_WINDOWS_DESKTOP 1
#elif defined(WINAPI_FAMILY_PARTITION)
#if defined(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#define MS2_WINDOWS_DESKTOP 1
#elif defined(WINAPI_PARTITION_PHONE_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
#define MS2_WINDOWS_PHONE 1
#elif defined(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
#define MS2_WINDOWS_DESKTOP 1
#endif
#endif
 
#ifdef ENABLE_MICROSOFT_STORE_APP
_Check_return_ WINOLEAPI
CoCreateInstanceFromApp(
    _In_ REFCLSID Clsid,
    _In_opt_ IUnknown* punkOuter,
    _In_ DWORD dwClsCtx,
    _In_opt_ PVOID reserved,
    _In_ DWORD dwCount,
    _Inout_updates_(dwCount) MULTI_QI* pResults
    );
#endif
__inline _Check_return_ HRESULT CoCreateInstanceBT(
    _In_     REFCLSID rclsid,
    _In_opt_ LPUNKNOWN pUnkOuter,
    _In_     DWORD dwClsContext,
    _In_     REFIID riid,
    _COM_Outptr_ _At_(*ppv, _Post_readable_size_(_Inexpressible_(varies))) LPVOID FAR* ppv)
{
#ifdef ENABLE_MICROSOFT_STORE_APP
    MULTI_QI    OneQI;
    HRESULT     hr;
 
    OneQI.pItf = NULL;
 
#ifdef __cplusplus
    OneQI.pIID = &riid;
#else
    OneQI.pIID = riid;
#endif
 
    hr = CoCreateInstanceFromApp( rclsid, pUnkOuter, dwClsContext, NULL, 1, &OneQI );
 
#ifdef _PREFAST_
    if (SUCCEEDED(hr) && SUCCEEDED(OneQI.hr))
    _Analysis_assume_(OneQI.pItf != NULL);
    else
    _Analysis_assume_(OneQI.pItf == NULL);
#endif
 
    *ppv = OneQI.pItf;
    return FAILED(hr) ? hr : OneQI.hr;
#else
    return CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv );
#endif //ENABLE_MICROSOFT_STORE_APP
}
 
__inline _Check_return_ HRESULT CoCreateInstanceExBT(
    _In_ REFCLSID                      Clsid,
    _In_opt_ IUnknown     *            punkOuter,
    _In_ DWORD                         dwClsCtx,
    _In_opt_ COSERVERINFO *            pServerInfo,
    _In_ DWORD                         dwCount,
    _Inout_updates_(dwCount) MULTI_QI *pResults )
{
#ifdef ENABLE_MICROSOFT_STORE_APP
    return CoCreateInstanceFromApp(Clsid, punkOuter, dwClsCtx, pServerInfo, dwCount, pResults);
#else
    return CoCreateInstanceEx(Clsid, punkOuter, dwClsCtx, pServerInfo, dwCount, pResults);
#endif //ENABLE_MICROSOFT_STORE_APP
}
#endif
 
#if defined(_MSC_VER)
#ifdef MS2_STATIC
#define MS2_PUBLIC
#define MS2_VAR_PUBLIC extern
#else
#ifdef MS2_EXPORTS
#define MS2_PUBLIC    __declspec(dllexport)
#define MS2_VAR_PUBLIC extern __declspec(dllexport)
#else
#define MS2_PUBLIC    __declspec(dllimport)
#define MS2_VAR_PUBLIC extern __declspec(dllimport)
#endif
#endif
#else
#define MS2_PUBLIC
#define MS2_VAR_PUBLIC extern
#endif
 
#if defined(_WIN32_WCE)
time_t ms_time (time_t *t);
#else
#define ms_time time
#endif
 
#ifdef DEBUG
static MS2_INLINE void ms_debug(const char *fmt,...)
{
  va_list args;
  va_start (args, fmt);
  bctbx_logv(BCTBX_LOG_DOMAIN, BCTBX_LOG_DEBUG, fmt, args);
  va_end (args);
}
#else
#define ms_debug(fmt, ...)
#endif
 
#define ms_message    bctbx_message
#define ms_warning    bctbx_warning
#define ms_error    bctbx_error
#define ms_fatal    bctbx_fatal
 
#define ms_return_val_if_fail(_expr_,_ret_)\
    if (!(_expr_)) { ms_fatal("assert "#_expr_ "failed"); return (_ret_);}
 
#define ms_return_if_fail(_expr_) \
    if (!(_expr_)){ ms_fatal("assert "#_expr_ "failed"); return ;}
 
#define ms_thread_t        ortp_thread_t
#define ms_thread_create     ortp_thread_create
#define ms_thread_join        ortp_thread_join
#define ms_thread_self        ortp_thread_self
 
typedef ortpTimeSpec MSTimeSpec;
 
#define ms_get_cur_time ortp_get_cur_time
#define ms_get_cur_time_ms ortp_get_cur_time_ms
 
typedef bctbx_compare_func MSCompareFunc;
typedef void (*MSIterateFunc)(void *a);
typedef void (*MSIterate2Func)(void *a, void *b);
typedef void (*MSIterate3Func)(void *a, void *b, void *c);
 
#ifdef __cplusplus
extern "C"{
#endif
/*for stun*/
typedef struct { unsigned char octet[12]; } UInt96;
typedef struct { unsigned char octet[16]; } UInt128;
 
MS2_PUBLIC void ms_thread_exit(void* ret_val);
 
 
#define MSList bctbx_list_t
 
/**
 * @addtogroup ms_list
 * @{
**/
 
/** Inserts a new element containing data to the end of a given list
 * @param list list where data should be added. If NULL, a new list will be created.
 * @param data data to insert into the list
 * @return first element of the list
 * @deprecated Use bctbx_list_append() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_append(MSList *list, void * data);
 
/** Inserts given element to the end of a given list
 * @param list list where data should be added. If NULL, a new list will be created.
 * @param new_elem element to append
 * @return first element of the list
 * @deprecated Use bctbx_list_append_link() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_append_link(MSList *list, MSList *new_elem);
 
/** Inserts a new element containing data to the start of a given list
 * @param list list where data should be added. If NULL, a new list will be created.
 * @param data data to insert into the list
 * @return first element of the list - the one which was just created.
 * @deprecated Use bctbx_list_prepend() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_prepend(MSList *list, void * data);
 
/** Frees all elements of a given list
 * Note that data contained in each element will not be freed. If you need to clean
 * them, consider using @ms_list_free_with_data
 * @param list object to free.
 * @return NULL
 * @deprecated Use bctbx_list_free() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_free(MSList *list);
 
/** Frees all elements of a given list after having called freefunc on each element
 * @param list object to free.
 * @param freefunc function to invoke on each element data before destroying the element
 * @return NULL
 * @deprecated Use bctbx_list_free_with_data() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_free_with_data(MSList *list, void (*freefunc)(void*));
 
/** Concatenates second list to the end of first list
 * @param first First list
 * @param second Second list to append at the end of first list.
 * @return first element of the merged list
 * @deprecated Use bctbx_list_concat() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_concat(MSList *first, MSList *second);
 
/** Finds and remove the first element containing the given data. Nothing is done if element is not found.
 * @param list List in which data must be removed
 * @param data Data to remove
 * @return first element of the modified list
 * @deprecated Use bctbx_list_remove() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_remove(MSList *list, void *data);
 
/** Finds and remove any elements according to the given predicate function
 * @param list List in which data must be removed
 * @param compare_func Function to invoke on each element. If it returns TRUE, the given element will be deleted.
 * @param user_data User data to pass to compare_func function
 * @return first element of the modified list
 * @deprecated Use bctbx_list_remove_custom() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList * ms_list_remove_custom(MSList *list, MSCompareFunc compare_func, const void *user_data);
 
/** Returns size of a given list
 * @param list List to measure
 * @return Size of list
 * @deprecated Use bctbx_list_size() instead
**/
MS2_PUBLIC MS2_DEPRECATED int ms_list_size(const MSList *list);
 
/** Invoke function on each element of the list
 * @param list List object
 * @param iterate_func Function to invoke on each element.
 * @deprecated Use bctbx_list_for_each() instead
**/
MS2_PUBLIC MS2_DEPRECATED void ms_list_for_each(const MSList *list, MSIterateFunc iterate_func);
 
/** Invoke function on each element of the list
 * @param list List object
 * @param iterate_func Function to invoke on each element.
 * @param user_data User data to pass to iterate_func function.
 * @deprecated Use bctbx_list_for_each2() instead
**/
MS2_PUBLIC MS2_DEPRECATED void ms_list_for_each2(const MSList *list, MSIterate2Func iterate_func, void *user_data);
    
MS2_PUBLIC MS2_DEPRECATED void ms_list_for_each3(const MSList *list, MSIterate3Func iterate_func, void *user_data, void *factory);
 
/** Finds and remove given element in list.
 * @param list List in which element must be removed
 * @param element element to remove
 * @return first element of the modified list
 * @deprecated Use bctbx_list_remove_link() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_remove_link(MSList *list, MSList *elem);
 
/** Finds first element containing data in the given list.
 * @param list List in which element must be found
 * @param data data to find
 * @return element containing data, or NULL if not found
 * @deprecated Use bctbx_list_find() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_find(MSList *list, void *data);
 
/** Finds first element according to the given predicate function
 * @param list List in which element must be found
 * @param compare_func Function to invoke on each element. If it returns TRUE, the given element will be returned.
 * @param user_data User data to pass to compare_func function
 * @return Element matching the predicate, or NULL if none is found.
 * @deprecated Use bctbx_list_find_custom() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_find_custom(MSList *list, MSCompareFunc compare_func, const void *user_data);
 
/** Returns the nth element data of the list
 * @param list List object
 * @param index data index which must be returned.
 * @return Element at the given index. NULL if index is invalid (negative or greater or equal to ms_list_size).
 * @deprecated Use bctbx_list_nth_data() instead
**/
MS2_PUBLIC MS2_DEPRECATED void * ms_list_nth_data(const MSList *list, int index);
 
/** Returns the index of the given element
 * @param list List object
 * @param elem Element to search for.
 * @return Index of the given element. -1 if not found.
 * @deprecated Use bctbx_list_position() instead
**/
MS2_PUBLIC MS2_DEPRECATED int ms_list_position(const MSList *list, MSList *elem);
 
/** Returns the index of the first element containing data
 * @param list List object
 * @param data Data to search for.
 * @return Index of the element containing data. -1 if not found.
 * @deprecated Use bctbx_list_index() instead
**/
MS2_PUBLIC MS2_DEPRECATED int ms_list_index(const MSList *list, void *data);
 
/** Inserts a new element containing data at the place given by compare_func
 * @param list list where data should be added. If NULL, a new list will be created.
 * @param data data to insert into the list
 * @param compare_func function determining where should the new element be placed
 * @return first element of the list.
 * @deprecated Use bctbx_list_insert_sorted() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_insert_sorted(MSList *list, void *data, MSCompareFunc compare_func);
 
/** Inserts a new element containing data before the given element
 * @param list list where data should be added. If NULL, a new list will be created.
 * @param before element parent to the one we will insert.
 * @param data data to insert into the list
 * @return first element of the modified list.
 * @deprecated Use bctbx_list_insert() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_insert(MSList *list, MSList *before, void *data);
 
/** Copies a list in another one, duplicating elements but not data
 * @param list list to copy
 * @return Newly created list
 * @deprecated Use bctbx_list_copy() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_copy(const MSList *list);
 
/** Copies a list in another one, duplicating elements according to the given function
 * @param list list to copy
 * @param copyfunc function to invoke on each element which will return the new list data value
 * @return Newly created list
 * @deprecated Use bctbx_list_copy_with_data() instead
**/
MS2_PUBLIC MS2_DEPRECATED MSList *ms_list_copy_with_data(const MSList *list, void *(*copyfunc)(void *));
 
/**
 * @deprecated @deprecated Use bctbx_list_next() instead
 */
MS2_PUBLIC MS2_DEPRECATED MSList* ms_list_next(const MSList *list);
 
/** @} */
 
MS2_PUBLIC char * ms_tags_list_as_string(const MSList *list);
MS2_PUBLIC bool_t ms_tags_list_contains_tag(const MSList *list, const char *tag);
 
#undef MIN
#define MIN(a,b)    ((a)>(b) ? (b) : (a))
#undef MAX
#define MAX(a,b)    ((a)>(b) ? (a) : (b))
 
/**
 * @file mscommon.h
 * @brief mediastreamer2 mscommon.h include file
 *
 * This file provide the API needed to initialize
 * and reset the mediastreamer2 library.
 *
 */
 
/**
 * @addtogroup mediastreamer2_init
 * @{
 */
 
 
/**
 * Helper macro for backward compatibility.
 * Use ms_base_init() and ms_voip_init() instead.
 */
#define ms_init()    ms_base_init(), ms_voip_init(), ms_plugins_init()
 
/**
 * Helper macro for backward compatibility.
 * Use ms_base_exit() and ms_voip_exit() instead.
 */
#define ms_exit()    ms_voip_exit(), ms_plugins_exit(), ms_base_exit()
 
/**
 * Initialize the mediastreamer2 base library.
 *
 * This must be called once before calling any other API.
 * @deprecated use ms_factory_new()
 */
MS2_PUBLIC MS2_DEPRECATED void ms_base_init(void);
 
/**
 * Initialize the mediastreamer2 VoIP library.
 *
 * This must be called one before calling any other API.
 * @deprecated use ms_factory_new_with_voip().
 */
MS2_PUBLIC MS2_DEPRECATED void ms_voip_init(void);
 
/**
 * Load the plugins from the default plugin directory.
 *
 * This is just a wrapper around ms_load_plugins().
 * This must be called after ms_base_init() and after ms_voip_init().
 * @deprecated use ms_factory_init_plugins(), or ms_factory_new_with_voip() that does it automatically.
 */
MS2_PUBLIC MS2_DEPRECATED void ms_plugins_init(void);
 
/**
 * Set the directory from where the plugins are to be loaded when calling ms_plugins_init().
 * @param[in] path The path to the plugins directory.
 * @deprecated use ms_factory_set_plugins_dir().
 */
MS2_PUBLIC MS2_DEPRECATED void ms_set_plugins_dir(const char *path);
 
/**
 * Load plugins from a specific directory.
 * This method basically loads all libraries in the specified directory and attempts to call a C function called
 * \<libraryname\>_init. For example if a library 'libdummy.so' or 'libdummy.dll' is found, then the loader tries to locate
 * a C function called 'libdummy_init()' and calls it if it exists.
 * ms_load_plugins() can be used to load non-mediastreamer2 plugins as it does not expect mediastreamer2 specific entry points.
 *
 * @param directory   A directory where plugins library are available.
 *
 * @return >0 if successfull, 0 if not plugins loaded, -1 otherwise.
 * @deprecated use ms_factory_load_plugins().
 */
MS2_PUBLIC MS2_DEPRECATED int ms_load_plugins(const char *directory);
 
/**
 * Release resource allocated in the mediastreamer2 base library.
 *
 * This must be called once before closing program.
 * @deprecated use ms_factory_destroy().
 */
MS2_PUBLIC MS2_DEPRECATED void  ms_base_exit(void);
 
/**
 * Release resource allocated in the mediastreamer2 VoIP library.
 *
 * This must be called once before closing program.
 * @deprecated use ms_factory_destroy().
 */
MS2_PUBLIC MS2_DEPRECATED void ms_voip_exit(void);
 
/**
 * Unload the plugins loaded by ms_plugins_init().
 * @deprecated use ms_factory_destroy().
 */
MS2_PUBLIC MS2_DEPRECATED void ms_plugins_exit(void);
 
struct _MSSndCardDesc;
 
MS2_PUBLIC void ms_sleep(int seconds);
 
MS2_PUBLIC void ms_usleep(uint64_t usec);
 
/**
 * The max payload size allowed.
 * Filters that generate data that can be sent through RTP should make packets
 * whose size is below ms_get_payload_max_size().
 * The default value is 1440 computed as the standard internet MTU minus IPv6 header,
 * UDP header and RTP header. As IPV4 header is smaller than IPv6 header, this
 * value works for both.
 * @deprecated use ms_factory_get_payload_max_size().
**/
MS2_PUBLIC MS2_DEPRECATED int ms_get_payload_max_size(void);
 
/**
 * Set the maximum payload size allowed.
 * @deprecated use ms_factory_set_payload_max_size().
**/
MS2_PUBLIC MS2_DEPRECATED void ms_set_payload_max_size(int size);
 
/**
 * Returns the network Max Transmission Unit to reach destination_host.
 * This will attempt to send one or more big packets to destination_host, to a random port.
 * Those packets are filled with zeroes.
**/
MS2_PUBLIC int ms_discover_mtu(const char *destination_host);
 
/**
 * Set mediastreamer default mtu, used to compute the default RTP max payload size.
 * This function will call ms_set_payload_max_size(mtu-[ipv6 header size]).
 * @deprecated use ms_factory_set_mtu()
**/
MS2_PUBLIC MS2_DEPRECATED void ms_set_mtu(int mtu);
 
/**
 * Get mediastreamer default mtu, used to compute the default RTP max payload size.
 * @deprecated use ms_factory_get_mtu().
**/
MS2_PUBLIC MS2_DEPRECATED int ms_get_mtu(void);
 
/**
 * Declare how many cpu (cores) are available on the platform
 * @deprecated use ms_factory_set_cpu_count().
 */
MS2_PUBLIC MS2_DEPRECATED void ms_set_cpu_count(unsigned int c);
 
/**
 * @deprecated use ms_factory_get_cpu_count().
**/
MS2_PUBLIC MS2_DEPRECATED unsigned int ms_get_cpu_count(void);
 
/**
 * Adds a new entry in the SoundDeviceDescription table
 */
MS2_PUBLIC void ms_sound_device_description_add(const char *manufacturer, const char *model, const char *platform, unsigned int flags, int delay, int recommended_rate);
 
/**
 * @return TRUE if address is ipv6
 */
MS2_PUBLIC bool_t ms_is_ipv6(const char *address);
 
/**
 * @return TRUE if address is multicast
 */
bool_t ms_is_multicast_addr(const struct sockaddr *address);
/**
 * @return TRUE if address is multicast
 */
MS2_PUBLIC bool_t ms_is_multicast(const char *address);
 
/**
 * Utility function to load a file into memory.
 * @param file a FILE handle
 * @param nbytes (optional) number of bytes read
**/
MS2_PUBLIC char *ms_load_file_content(FILE *file, size_t *nbytes);
 
/**
 * Utility function to load a file into memory.
 * @param path a FILE handle
 * @param nbytes (optional) number of bytes read
**/
MS2_PUBLIC char *ms_load_path_content(const char *path, size_t *nbytes);
/** @} */
 
#ifdef __cplusplus
}
#endif
 
#ifdef MS2_INTERNAL
#  ifdef HAVE_CONFIG_H
#  include "mediastreamer-config.h" /*necessary to know if ENABLE_NLS is there*/
#  endif
 
#ifdef _WIN32
#include <malloc.h> //for alloca
#ifdef _MSC_VER
#define alloca _alloca
#endif
#endif
 
#  if defined(ENABLE_NLS)
 
#ifdef _MSC_VER
// prevent libintl.h from re-defining fprintf and vfprintf
#ifndef fprintf
#define fprintf fprintf
#endif
#ifndef vfprintf
#define vfprintf vfprintf
#endif
#define _GL_STDIO_H
#endif
 
#    include <libintl.h>
#    define _(String) dgettext (GETTEXT_PACKAGE, String)
#  else
#    define _(String) (String)
#  endif // ENABLE_NLS
#define N_(String) (String)
 
/*
 * Used by audio encoders in case no default standardized maxptime defined.
 */
#ifndef MS_DEFAULT_MAX_PTIME
    #define MS_DEFAULT_MAX_PTIME 140
#endif
 
#endif // MS2_INTERNAL
 
#ifdef __ANDROID__
#include "mediastreamer2/msjava.h"
#endif
#endif