forked from unispeech/swig-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUniMRCP-wrapper.h
2001 lines (1779 loc) · 84.1 KB
/
UniMRCP-wrapper.h
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
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2014 SpeechTech, s.r.o. http://www.speechtech.cz/en
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id$
*/
#ifndef UNIMRCP_WRAPPER_H
#define UNIMRCP_WRAPPER_H
/**
* @file UniMRCP-wrapper.h
* @brief UniMRCP Client high-level interface.
*/
#include <cstddef> // For NULL
#include <cstdarg> // For va_list
#ifdef DOXYGEN
/**
* @brief Define if building a (wrapper) library and want to export the C++ methods.
*/
#define UNIMRCP_WRAPPER_EXPORT
/**
* @brief Define if you want to use the C++ methods from a library built usign UNIMRCP_WRAPPER_EXPORT.
*
* This may not be necessary.
*/
#define UNIMRCP_WRAPPER_IMPORT
/**
* @brief Defined when building wrapper library (i.e. included from UniMRCP-wrapper.cpp)
*/
#define UNIMRCP_WRAPPER_CPP
/**
* @brief Defined when building the library wrapped by SWIG
*/
#define WRAPPER
/**
* @brief When building the wrapper, define to platform name, e.g. "Python" (for logging purposes).
*/
#define TARGET_PLATFORM "cpp"
/**
* @brief Define to trace/log media frames flow
*/
#define UW_TRACE_BUFFERS
#endif // ifdef DOXYGEN
/**
* @brief Declarator to export C++ methods if wanted.
*/
#if defined(WRAPPER_DECL)
// User-defined declarator
#elif defined(SWIG) || defined(DOXYGEN)
# define WRAPPER_DECL
#elif defined(UNIMRCP_WRAPPER_EXPORT)
# if defined(_MSC_VER)
# define WRAPPER_DECL __declspec(dllexport)
# elif defined(__GNUC__) && (__GNUC__ >= 4)
# define WRAPPER_DECL __attribute__((visibility("default")))
# endif
#elif defined(UNIMRCP_WRAPPER_IMPORT)
# if defined(_MSC_VER)
# define WRAPPER_DECL __declspec(dllimport)
# endif
#endif
#ifndef WRAPPER_DECL
# define WRAPPER_DECL
#endif
/**
* @mainpage Documentation
* This is UniMRCP (http://unimrcp.org/) client C++ interface
* which can also be wrapped by SWIG (http://swig.org/)
* currently for .NET, Python and Java languages.
* Binaries are built using CMake (http://cmake.org/).
*
* UniMRCP client application must first call UniMRCPClient::StaticInitialize
* to initialize the platform. Then UniMRCPClient object is created.
* UniMRCP client sessions are esteblished creating UniMRCPClientSession objects.
* For each session UniMRCPAudioTermination objects are created to handle media streams.
* To each session (and for media termination) UniMRCPClientChannel objects are added
* to handle signaling. But do not use UniMRCPClientChannel directly, use specialized
* resource channels, e.g. #UniMRCPRecognizerChannel (UniMRCPClientResourceChannel\<#MRCP_RECOGNIZER\>),
* #UniMRCPSynthesizerChannel (UniMRCPClientResourceChannel\<#MRCP_SYNTHESIZER\>)
* and #UniMRCPRecorderChannel (UniMRCPClientResourceChannel\<#MRCP_RECORDER\>)
* to handle signaling for above specified resources.
*
* To implement/customize methods of terminations, streams, sessions and channels, just
* override their virtual methods. See this documentation for further details.
*
*
* @section sec-MRCP MRCP in a Nutshell
* For specifications, see
* <a href="http://tools.ietf.org/html/rfc4463">RFC4463</a> (MRCPv1) and
* <a href="http://tools.ietf.org/html/rfc6787">RFC6787</a> (MRCPv2).
*
* MRCPv1 uses RTSP (TCP-based) protocol to setup media session (via SDP) and
* for signaling as well.
*
* MRCPv2 uses SIP (UDP or TCP-based) to setup media session and MRCP signaling.
* Both media formats, connection endpoints and MRCP endpoint are described in
* SDP answer. The client then connects to the MRCP TCP IP/port contained in
* the answer.
*
* See below for some typical message flow examples.
*
*
* @section sec-UniMRCP UniMRCP in a Nutshell
* UniMRCP is an excellent MRCP stack written in C that transparently works with
* both versions of the protocol. Protocol version, connection details and other
* settings are specified in configuration proviles. We will focus on client use case only.
* Its binary distribution assumes following subdirectories in its root directory:
* - @c bin/ -- contains executables,
* - @c conf/ -- contains configurations (unimrcpclient.xml),
* - @c data/ -- contains data files (sounds, grammars etc.) used by examples,
* - @c log/ -- default location for logging.
*
* After client initialization, sessions are created. The session is associated with
* a media termination and channels are added to it. Media terminations manage
* streams and channels send and receive messages.
*
*
* @section sec-using-wrapper Using the Wrapper
* See examples (UniSynth).
*
* The application using UniMRCPWrapper is event-driven. Main processing starts in
* UniMRCPClientChannel::OnAdd.
* -# Initialize the platform first by UniMRCPClient::StaticInitialize.
* - You can initialize the platform to use the directory structure described
* above or you can use variant independent of filesystem.
* -# Create UniMRCPClient object.
* -# Create UniMRCPClientSession object using specified profile.
* - Several methods (events) may be overriden, e.g.
* UniMRCPClientSession::OnTerminate, UniMRCPClientSession::OnTerminateEvent.
* -# Create UniMRCPAudioTermination, set its options and add desired capabilities
* using UniMRCPAudioTermination::AddCapability.
* - Override at least UniMRCPAudioTermination::OnStreamOpenRx
* or UniMRCPAudioTermination::OnStreamOpenTx to create outgoing or incoming
* streams respectively (the direction is from the server's point of view).
* - In the methods check negotiated stream parameters and return instances
* of UniMRCPStreamRx (UniMRCPStreamRxBuffered) or UniMRCPStreamTx, override
* their UniMRCPStreamRx::ReadFrame or UniMRCPStreamTx::WriteFrame to use
* UniMRCPStreamRx::SetData or UniMRCPStreamTx::GetData to transmit
* or receive data respectively.
* - Remember, sending or receiving data should be synchronized (started)
* with MRCP synchronization, i.e. after receiving @c IN-PROGRESS response
* to @c SPEAK or @c RECOGNIZE etc.
* -# Create specialized UniMRCPClientResourceChannel (#UniMRCPSynthesizerChannel,
* #UniMRCPRecognizerChannel or #UniMRCPRecorderChannel).
* It is automatically added to the session.
* - Override UniMRCPClientChannel::OnAdd and if the #UniMRCPSigStatusCode
* parameter is #MRCP_SIG_STATUS_CODE_SUCCESS, start sending messages
* and return @c true (@c false causes disconnection).
* - Override UniMRCPClientResourceChannel::OnMessageReceive to get responses and events
* from the server.
* -# When done, call UniMRCPClientSession::Terminate.
* In UniMRCPClientSession::OnTerminate you can UniMRCPClientSession::Destroy
* the session and thus free all the memory used during the session.
*
*
* @section sec-mrcp-flow MRCP Message Flow Examples
* Few typical MRCP message flow examples.
*
*
* @subsection sec-synth Simple Synthesis
* Bundled UniSynth example.
* <pre>
* C>S: Send SPEAK message with Content-Type header and body.
* UniMRCPClientChannel::OnAdd
* C<S: Receive IN-PROGRESS response.
* UniMRCPSynthesizerChannel::OnMessageReceive
* (Client now consumes incoming media.) UniMRCPStreamTx::WriteFrame
* C<S: Receive SPEAK-COMPLETE event.
* UniMRCPSynthesizerChannel::OnMessageReceive
* </pre>
*
*
* @subsection sec-recog1 Simple Recognition
* <pre>
* C>S: Send RECOGNIZE message with Content-Type header and body with grammar.
* UniMRCPClientChannel::OnAdd
* C<S: Receive IN-PROGRESS response.
* UniMRCPRecognizerChannel::OnMessageReceive
* (Client now sends audio and/or DTMF to recognize.) UniMRCPStreamRx::ReadFrame
* C<S: May receive START-OF-INPUT event.
* UniMRCPRecognizerChannel::OnMessageReceive
* C<S: Receive RECOGNITION-COMPLETE event.
* UniMRCPRecognizerChannel::OnMessageReceive
* </pre>
*
*
* @subsection sec-recog2 Recognition with Extra Grammar(s)
* <pre>
* C>S: Send DEFINE-GRAMMAR message with Content-Type, body, and
* Content-Id set to grammar ID.
* UniMRCPClientChannel::OnAdd
* C<S: Receive DEFINE-GRAMMAR response.
* UniMRCPRecognizerChannel::OnMessageReceive
* C>S: Send RECOGNIZE message with
* Content-Type=text/uri-list and
* body with one grammar ID per line.
* C<S: Receive IN-PROGRESS response.
* UniMRCPRecognizerChannel::OnMessageReceive
* (Client now sends audio and/or DTMF to recognize.) UniMRCPStreamRx::ReadFrame
* C<S: May receive START-OF-INPUT event.
* UniMRCPRecognizerChannel::OnMessageReceive
* C<S: Receive RECOGNITION-COMPLETE event.
* UniMRCPRecognizerChannel::OnMessageReceive
* </pre>
*/
/** @brief Helper macro for declaring exceptions so that it can be disabled */
#ifndef THROWS
# define THROWS throw
#endif
#ifdef _MSC_VER
# pragma warning (disable: 4290)
#endif
/*
* Environment setup:
* - If ENUM_MEM is defined as NAME_PREFIXED, all enum members have full prefix and
* are unique througout entire wrapper. Necessary for e.g. C++.
* - If ENUM_MEM is defined as NAME_NOPREFIX, enum members are as short as possible. Useful for e.g. C#.
* - TARGET platform defined to target platform name.
*/
/**
* @def ENUM_MEM
* @brief Depending on binding platform expands to NAME_PREFIXED or NAME_NOPREFIX or NAME_UWPREFIXED
*/
#if defined(DOXYGEN)
# define ENUM_MEM(pre, name) NAME_PREFIXED(pre, name)
#elif !defined(SWIG)
# ifdef UNIMRCP_WRAPPER_CPP
# define TARGET_PLATFORM "cpp"
# define ENUM_MEM(pre, name) NAME_UWPREFIXED(pre, name)
# else
# define ENUM_MEM(pre, name) NAME_PREFIXED(pre, name)
# endif
#elif defined(SWIGCSHARP)
# define TARGET_PLATFORM "CSharp"
# define ENUM_MEM(pre, name) NAME_NOPREFIX(pre, name)
#elif defined(SWIGPYTHON)
# define TARGET_PLATFORM "Python"
# define ENUM_MEM(pre, name) NAME_PREFIXED(pre, name)
#elif defined(SWIGJAVA)
# define TARGET_PLATFORM "Java"
# define ENUM_MEM(pre, name) NAME_NOPREFIX(pre, name)
#elif defined(SWIGLUA)
# define TARGET_PLATFORM "Lua"
# define ENUM_MEM(pre, name) NAME_PREFIXED(pre, name)
#elif defined(SWIGOCTAVE)
# define TARGET_PLATFORM "Octave"
# define ENUM_MEM(pre, name) NAME_PREFIXED(pre, name)
#elif defined(SWIGPERL)
# define TARGET_PLATFORM "PERL"
# define ENUM_MEM(pre, name) NAME_PREFIXED(pre, name)
#elif defined(SWIGPHP)
# define TARGET_PLATFORM "PHP"
# define ENUM_MEM(pre, name) NAME_PREFIXED(pre, name)
#else
# warning "Unknown SWIG target platform. Some functions may not work!"
# define TARGET_PLATFORM "unknown"
# define ENUM_MEM(pre, name) NAME_PREFIXED(pre, name)
#endif
/** @brief NAME_UWPREFIXED(AAA, BBB) expands to UW_AAABBB to distinguish constants defined in UniMRCP headers */
#define NAME_UWPREFIXED(pre, name) UW_ ## pre ## name
/** @brief NAME_PREFIXED(AAA, BBB) expands to AAABBB */
#define NAME_PREFIXED(pre, name) pre ## name
/** @brief NAME_NOPREFIX(AAA, BBB) expands to BBB */
#define NAME_NOPREFIX(pre, name) name
#if defined(TARGET_PLATFORM) && (defined(SWIG) || (defined(UNIMRCP_WRAPPER_CPP) && !defined(WRAPPER)))
#ifdef SWIG
%inline {
#endif
/** @brief Target platform name, e.g. CSharp, Python, ... */
extern "C" char const* const swig_target_platform = TARGET_PLATFORM;
/** @brief MRCP client application name */
extern "C" char const* const unimrcp_client_app_name = "UniMRCPClient-" TARGET_PLATFORM;
/** @brief MRCP client log file name (if used) */
extern "C" char const* const unimrcp_client_log_name = "unimrcpclient-" TARGET_PLATFORM;
#ifdef SWIG
}
#endif
#else // TARGET_PLATFORM
/** @brief Target platform name, e.g. CSharp, Python, ... */
extern "C" WRAPPER_DECL char const* const swig_target_platform;
/** @brief MRCP client application name */
extern "C" WRAPPER_DECL char const* const unimrcp_client_app_name;
/** @brief MRCP client log file name (if used) */
extern "C" WRAPPER_DECL char const* const unimrcp_client_log_name;
#endif
/* Opaque structures */
struct apr_pool_t; //< APR memory pool opaque C structure
struct apr_thread_mutex_t; //< APR mutex opaque C structure
struct apr_file_t; //< APR file opaque C structure
struct apr_mmap_t; //< APR memory mapping opaque C structure
struct mrcp_client_t; //< MRCP client opaque C structure
struct mrcp_application_t; //< MRCP application opaque C structure
struct mrcp_app_message_t; //< MRCP application message opaque C structure
struct mrcp_session_t; //< MRCP session opaque C structure
struct mrcp_channel_t; //< MRCP client channel opaque C structure
struct mrcp_session_descriptor_t; //< MRCP session descriptor opaque C structure
struct mrcp_message_t; //< MRCP message opaque C structure
struct mrcp_generic_header_t; //< MRCP message generic header opaque C structure
struct mrcp_synth_header_t; //< MRCP message synthesizer header opaque C structure
struct mrcp_recog_header_t; //< MRCP message recognizer header opaque C structure
struct mrcp_recorder_header_t; //< MRCP message recorder header opaque C structure
struct mpf_termination_t; //< Media termination opaque C structure
struct mpf_stream_capabilities_t; //< Media stream capabilities opaque C structure
struct mpf_audio_stream_t; //< Audio stream opaque C structure
struct mpf_codec_t; //< Media codec opaque C structure
struct mpf_frame_t; //< Media frame opaque C structure
struct mpf_dtmf_generator_t; //< DTMF generator opaque C structure
struct mpf_dtmf_detector_t; //< DTMF detector opaque C structure
/** @brief MRCP request ID */
typedef unsigned long long UniMRCPRequestId;
/* Forward declarations */
class UniMRCPException;
class UniMRCPClient;
class UniMRCPClientSession;
class UniMRCPStreamRx;
class UniMRCPStreamTx;
class UniMRCPAudioTermination;
class UniMRCPClientChannel;
class UniMRCPMessage;
/*
* Following types copied from various headers for SWIG interface generation.
* Keep them up-to-date!
* When compiling, actual headers are included.
*/
/** @brief DTMF generator/detector band */
// From /libs/mpf/include/mpf_dtmf_generator.h
// or /libs/mpf/include/mpf_dtmf_detector.h
enum UniMRCPDTMFBand {
ENUM_MEM(DTMF_, AUTO) = 0x0,
ENUM_MEM(DTMF_, INBAND) = 0x1,
ENUM_MEM(DTMF_, OUTBAND) = 0x2,
ENUM_MEM(DTMF_, BAND_BOTH) = 0x1 | 0x2
};
// From /libs/mrcp/include/mrcp_types.h
/** @brief Enumeration of MRCP resource types */
enum UniMRCPResource {
MRCP_SYNTHESIZER, /**< Synthesizer resource */
MRCP_RECOGNIZER, /**< Recognizer resource */
MRCP_RECORDER /**< Recorder resource */
};
// From /libs/mrcp/resources/include/mrcp_synth_resource
/** @brief MRCP synthesizer methods */
enum UniMRCPSynthesizerMethod {
SYNTHESIZER_SET_PARAMS,
SYNTHESIZER_GET_PARAMS,
SYNTHESIZER_SPEAK,
SYNTHESIZER_STOP,
SYNTHESIZER_PAUSE,
SYNTHESIZER_RESUME,
SYNTHESIZER_BARGE_IN_OCCURRED,
SYNTHESIZER_CONTROL,
SYNTHESIZER_DEFINE_LEXICON
};
// From /libs/mrcp/resources/include/mrcp_recog_resource
/** @brief MRCP recognizer methods */
enum UniMRCPRecognizerMethod {
RECOGNIZER_SET_PARAMS,
RECOGNIZER_GET_PARAMS,
RECOGNIZER_DEFINE_GRAMMAR,
RECOGNIZER_RECOGNIZE,
RECOGNIZER_GET_RESULT,
RECOGNIZER_START_INPUT_TIMERS,
RECOGNIZER_STOP
};
// From /libs/mrcp/resources/include/mrcp_recorder_resource
/** @brief MRCP recorder methods */
enum UniMRCPRecorderMethod {
RECORDER_SET_PARAMS,
RECORDER_GET_PARAMS,
RECORDER_RECORD,
RECORDER_STOP,
RECORDER_START_INPUT_TIMERS
};
// From /libs/mrcp/resources/include/mrcp_synth_resource
/** @brief MRCP synthesizer events */
enum UniMRCPSynthesizerEvent {
SYNTHESIZER_SPEECH_MARKER_EVENT,
SYNTHESIZER_SPEAK_COMPLETE
};
// From /libs/mrcp/resources/include/mrcp_recog_resource
/** @brief MRCP recognizer events */
enum UniMRCPRecognizerEvent {
RECOGNIZER_START_OF_INPUT_EVENT,
RECOGNIZER_RECOGNITION_COMPLETE
};
// From /libs/mrcp/resources/include/mrcp_recorder_resource
/** @brief MRCP recorder events */
enum UniMRCPRecorderEvent {
RECORDER_START_OF_INPUT_EVENT,
RECORDER_RECORD_COMPLETE
};
// From /libs/apr-toolkit/include/apt_log.h
/** @brief Priority of log messages ordered from highest priority to lowest (rfc3164) */
enum UniMRCPLogPriority{
ENUM_MEM(APT_PRIO_, EMERGENCY), /**< system is unusable */
ENUM_MEM(APT_PRIO_, ALERT), /**< action must be taken immediately */
ENUM_MEM(APT_PRIO_, CRITICAL), /**< critical condition */
ENUM_MEM(APT_PRIO_, ERROR), /**< error condition */
ENUM_MEM(APT_PRIO_, WARNING), /**< warning condition */
ENUM_MEM(APT_PRIO_, NOTICE), /**< normal, but significant condition */
ENUM_MEM(APT_PRIO_, INFO), /**< informational message */
ENUM_MEM(APT_PRIO_, DEBUG) /**< debug-level message */
};
// From /libs/apr-toolkit/include/apt_log.h
/** @brief Mode of log output */
enum UniMRCPLogOutput{
ENUM_MEM(APT_LOG_, OUTPUT_NONE) = 0x00, /**< disable logging */
ENUM_MEM(APT_LOG_, OUTPUT_CONSOLE) = 0x01, /**< enable console output */
ENUM_MEM(APT_LOG_, OUTPUT_FILE) = 0x02, /**< enable log file output */
ENUM_MEM(APT_LOG_, OUTPUT_BOTH) = 0x03, /**< enable log file output */
};
// From /libs/mrcp-client/include/mrcp_application.h
/** @brief Enumeration of MRCP signaling status codes */
enum UniMRCPSigStatusCode {
ENUM_MEM(MRCP_SIG_STATUS_CODE_, SUCCESS), /**< indicates success */
ENUM_MEM(MRCP_SIG_STATUS_CODE_, FAILURE), /**< request failed */
ENUM_MEM(MRCP_SIG_STATUS_CODE_, TERMINATE), /**< request failed, session/channel/connection unexpectedly terminated */
ENUM_MEM(MRCP_SIG_STATUS_CODE_, CANCEL) /**< request cancelled */
};
// From /libs/mpf/include/mpf_stream_descriptor.h
/** @brief Stream directions (none, send, receive, duplex) */
enum UniMRCPStreamDirection {
ENUM_MEM(STREAM_DIRECTION_, NONE) = 0x0, /**< none */
ENUM_MEM(STREAM_DIRECTION_, SEND) = 0x1, /**< send (sink) */
ENUM_MEM(STREAM_DIRECTION_, RECEIVE) = 0x2, /**< receive (source) */
ENUM_MEM(STREAM_DIRECTION_, DUPLEX) =
0x1 | 0x2 /**< duplex */
};
// From /libs/mpf/include/mpf_codec_descriptor.h
/** @brief Codec frame time base in msec */
#define UNIMRCP_FRAME_TIME_BASE 10
/** @brief Bytes per sample for linear pcm */
#define UNIMRCP_BYTES_PER_SAMPLE 2
/** @brief Bits per sample for linear pcm */
#define UNIMRCP_BITS_PER_SAMPLE 16
/** @brief Supported sampling rates */
enum UniMRCPSampleRate {
SAMPLE_RATE_NONE = 0x00,
SAMPLE_RATE_8000 = 0x01,
SAMPLE_RATE_16000 = 0x02,
SAMPLE_RATE_32000 = 0x04,
SAMPLE_RATE_48000 = 0x08,
SAMPLE_RATE_11025 = 0x10,
SAMPLE_RATE_22050 = 0x20,
SAMPLE_RATE_44100 = 0x40,
SAMPLE_RATE_SUPPORTED = 0x01 | 0x02 |
0x04 | 0x08 |
0x10 | 0x20 |
0x40
};
// From /libs/mrcp/message/include/mrcp_start_line.h
/** @brief Request-states used in MRCP response message */
enum UniMRCPRequestState {
/** The request was processed to completion and there will be no
more events from that resource to the client with that request-id */
ENUM_MEM(MRCP_REQUEST_, STATE_COMPLETE),
/** Indicate that further event messages will be delivered with that request-id */
ENUM_MEM(MRCP_REQUEST_, STATE_INPROGRESS),
/** The job has been placed on a queue and will be processed in first-in-first-out order */
ENUM_MEM(MRCP_REQUEST_, STATE_PENDING),
/** Unknown request state */
ENUM_MEM(MRCP_REQUEST_, STATE_UNKNOWN)
};
// From /libs/mrcp/message/include/mrcp_start_line.h
/** @brief Status codes */
enum UniMRCPStatusCode {
ENUM_MEM(MRCP_STATUS_, CODE_UNKNOWN) = 0,
/* success codes (2xx) */
ENUM_MEM(MRCP_STATUS_, CODE_SUCCESS) = 200,
ENUM_MEM(MRCP_STATUS_, CODE_SUCCESS_WITH_IGNORE) = 201,
/* failure codes (4xx) */
ENUM_MEM(MRCP_STATUS_, CODE_METHOD_NOT_ALLOWED) = 401,
ENUM_MEM(MRCP_STATUS_, CODE_METHOD_NOT_VALID) = 402,
ENUM_MEM(MRCP_STATUS_, CODE_UNSUPPORTED_PARAM) = 403,
ENUM_MEM(MRCP_STATUS_, CODE_ILLEGAL_PARAM_VALUE) = 404,
ENUM_MEM(MRCP_STATUS_, CODE_NOT_FOUND) = 405,
ENUM_MEM(MRCP_STATUS_, CODE_MISSING_PARAM) = 406,
ENUM_MEM(MRCP_STATUS_, CODE_METHOD_FAILED) = 407,
ENUM_MEM(MRCP_STATUS_, CODE_UNRECOGNIZED_MESSAGE) = 408,
ENUM_MEM(MRCP_STATUS_, CODE_UNSUPPORTED_PARAM_VALUE) = 409,
ENUM_MEM(MRCP_STATUS_, CODE_OUT_OF_ORDER) = 410,
ENUM_MEM(MRCP_STATUS_, CODE_RESOURCE_SPECIFIC_FAILURE) = 421
};
// From /libs/mrcp/message/include/mrcp_start_line.h
/** @brief MRCP message types */
enum UniMRCPMessageType {
ENUM_MEM(MRCP_MESSAGE_TYPE_, UNKNOWN_TYPE),
ENUM_MEM(MRCP_MESSAGE_TYPE_, REQUEST),
ENUM_MEM(MRCP_MESSAGE_TYPE_, RESPONSE),
ENUM_MEM(MRCP_MESSAGE_TYPE_, EVENT)
};
// From /libs/mrcp/message/include/mrcp_generic_header.h
/** @brief Enumeration of MRCP generic header fields */
enum UniMRCPGenericHeaderId {
ENUM_MEM(HEADER_, GENERIC_ACTIVE_REQUEST_ID_LIST),
ENUM_MEM(HEADER_, GENERIC_PROXY_SYNC_ID),
ENUM_MEM(HEADER_, GENERIC_ACCEPT_CHARSET),
ENUM_MEM(HEADER_, GENERIC_CONTENT_TYPE),
ENUM_MEM(HEADER_, GENERIC_CONTENT_ID),
ENUM_MEM(HEADER_, GENERIC_CONTENT_BASE),
ENUM_MEM(HEADER_, GENERIC_CONTENT_ENCODING),
ENUM_MEM(HEADER_, GENERIC_CONTENT_LOCATION),
ENUM_MEM(HEADER_, GENERIC_CONTENT_LENGTH),
ENUM_MEM(HEADER_, GENERIC_CACHE_CONTROL),
ENUM_MEM(HEADER_, GENERIC_LOGGING_TAG),
ENUM_MEM(HEADER_, GENERIC_VENDOR_SPECIFIC_PARAMS),
/* Additional header fields for MRCP v2 */
ENUM_MEM(HEADER_, GENERIC_ACCEPT),
ENUM_MEM(HEADER_, GENERIC_FETCH_TIMEOUT),
ENUM_MEM(HEADER_, GENERIC_SET_COOKIE),
ENUM_MEM(HEADER_, GENERIC_SET_COOKIE2)
};
// From /libs/mrcp/resources/include/mrcp_recog_header.h
/** @brief MRCP recognizer header fields */
enum UniMRCPRecognizerHeaderId {
ENUM_MEM(HEADER_, RECOGNIZER_CONFIDENCE_THRESHOLD),
ENUM_MEM(HEADER_, RECOGNIZER_SENSITIVITY_LEVEL),
ENUM_MEM(HEADER_, RECOGNIZER_SPEED_VS_ACCURACY),
ENUM_MEM(HEADER_, RECOGNIZER_N_BEST_LIST_LENGTH),
ENUM_MEM(HEADER_, RECOGNIZER_NO_INPUT_TIMEOUT),
ENUM_MEM(HEADER_, RECOGNIZER_RECOGNITION_TIMEOUT),
ENUM_MEM(HEADER_, RECOGNIZER_WAVEFORM_URI),
ENUM_MEM(HEADER_, RECOGNIZER_COMPLETION_CAUSE),
ENUM_MEM(HEADER_, RECOGNIZER_RECOGNIZER_CONTEXT_BLOCK),
ENUM_MEM(HEADER_, RECOGNIZER_START_INPUT_TIMERS_HDR), /* To disambiguate from method */
ENUM_MEM(HEADER_, RECOGNIZER_SPEECH_COMPLETE_TIMEOUT),
ENUM_MEM(HEADER_, RECOGNIZER_SPEECH_INCOMPLETE_TIMEOUT),
ENUM_MEM(HEADER_, RECOGNIZER_DTMF_INTERDIGIT_TIMEOUT),
ENUM_MEM(HEADER_, RECOGNIZER_DTMF_TERM_TIMEOUT),
ENUM_MEM(HEADER_, RECOGNIZER_DTMF_TERM_CHAR),
ENUM_MEM(HEADER_, RECOGNIZER_FAILED_URI),
ENUM_MEM(HEADER_, RECOGNIZER_FAILED_URI_CAUSE),
ENUM_MEM(HEADER_, RECOGNIZER_SAVE_WAVEFORM),
ENUM_MEM(HEADER_, RECOGNIZER_NEW_AUDIO_CHANNEL),
ENUM_MEM(HEADER_, RECOGNIZER_SPEECH_LANGUAGE),
/* Additional header fields for MRCP v2 */
ENUM_MEM(HEADER_, RECOGNIZER_INPUT_TYPE),
ENUM_MEM(HEADER_, RECOGNIZER_INPUT_WAVEFORM_URI),
ENUM_MEM(HEADER_, RECOGNIZER_COMPLETION_REASON),
ENUM_MEM(HEADER_, RECOGNIZER_MEDIA_TYPE),
ENUM_MEM(HEADER_, RECOGNIZER_VER_BUFFER_UTTERANCE),
ENUM_MEM(HEADER_, RECOGNIZER_RECOGNITION_MODE),
ENUM_MEM(HEADER_, RECOGNIZER_CANCEL_IF_QUEUE),
ENUM_MEM(HEADER_, RECOGNIZER_HOTWORD_MAX_DURATION),
ENUM_MEM(HEADER_, RECOGNIZER_HOTWORD_MIN_DURATION),
ENUM_MEM(HEADER_, RECOGNIZER_INTERPRET_TEXT),
ENUM_MEM(HEADER_, RECOGNIZER_DTMF_BUFFER_TIME),
ENUM_MEM(HEADER_, RECOGNIZER_CLEAR_DTMF_BUFFER),
ENUM_MEM(HEADER_, RECOGNIZER_EARLY_NO_MATCH)
};
// From /libs/mrcp/resources/include/mrcp_recog_header.h
/** @brief MRCP recognizer completion-cause */
enum UniMRCPRecogCompletionCause {
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_SUCCESS) = 0,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_NO_MATCH) = 1,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_NO_INPUT_TIMEOUT) = 2,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_RECOGNITION_TIMEOUT) = 3,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_GRAM_LOAD_FAILURE) = 4,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_GRAM_COMP_FAILURE) = 5,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_ERROR) = 6,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_SPEECH_TOO_EARLY) = 7,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_TOO_MUCH_SPEECH_TIMEOUT) = 8,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_URI_FAILURE) = 9,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_LANGUAGE_UNSUPPORTED) = 10,
/* Additional completion-cause for MRCP v2 */
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_CANCELLED) = 11,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_SEMANTICS_FAILURE) = 12,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_PARTIAL_MATCH) = 13,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_PARTIAL_MATCH_MAXTIME) = 14,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_NO_MATCH_MAXTIME) = 15,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_GRAM_DEFINITION_FAILURE) = 16,
ENUM_MEM(COMPLETION_, RECOGNIZER_CAUSE_UNKNOWN) = 17
};
// From /libs/mrcp/resources/include/mrcp_recorder_header.h
/** @brief MRCP recorder header fields */
enum UniMRCPRecorderHeaderId {
ENUM_MEM(HEADER_, RECORDER_SENSITIVITY_LEVEL),
ENUM_MEM(HEADER_, RECORDER_NO_INPUT_TIMEOUT),
ENUM_MEM(HEADER_, RECORDER_COMPLETION_CAUSE),
ENUM_MEM(HEADER_, RECORDER_COMPLETION_REASON),
ENUM_MEM(HEADER_, RECORDER_FAILED_URI),
ENUM_MEM(HEADER_, RECORDER_FAILED_URI_CAUSE),
ENUM_MEM(HEADER_, RECORDER_RECORD_URI),
ENUM_MEM(HEADER_, RECORDER_MEDIA_TYPE),
ENUM_MEM(HEADER_, RECORDER_MAX_TIME),
ENUM_MEM(HEADER_, RECORDER_TRIM_LENGTH),
ENUM_MEM(HEADER_, RECORDER_FINAL_SILENCE),
ENUM_MEM(HEADER_, RECORDER_CAPTURE_ON_SPEECH),
ENUM_MEM(HEADER_, RECORDER_VER_BUFFER_UTTERANCE),
ENUM_MEM(HEADER_, RECORDER_START_INPUT_TIMERS_HDR), /* To disambiguate from method */
ENUM_MEM(HEADER_, RECORDER_NEW_AUDIO_CHANNEL)
};
// From /libs/mrcp/resources/include/mrcp_recorder_header.h
/** @brief MRCP recorder completion-cause */
enum UniMRCPRecorderCompletionCause {
ENUM_MEM(COMPLETION_, RECORDER_CAUSE_SUCCESS_SILENCE) = 0,
ENUM_MEM(COMPLETION_, RECORDER_CAUSE_SUCCESS_MAXTIME) = 1,
ENUM_MEM(COMPLETION_, RECORDER_CAUSE_NO_INPUT_TIMEOUT) = 2,
ENUM_MEM(COMPLETION_, RECORDER_CAUSE_URI_FAILURE) = 3,
ENUM_MEM(COMPLETION_, RECORDER_CAUSE_ERROR) = 4,
ENUM_MEM(COMPLETION_, RECORDER_CAUSE_UNKNOWN) = 5
};
// From /libs/mrcp/resources/include/mrcp_synth_header.h
/** @brief MRCP synthesizer header fields */
enum UniMRCPSynthesizerHeaderId {
ENUM_MEM(HEADER_, SYNTHESIZER_JUMP_SIZE),
ENUM_MEM(HEADER_, SYNTHESIZER_KILL_ON_BARGE_IN),
ENUM_MEM(HEADER_, SYNTHESIZER_SPEAKER_PROFILE),
ENUM_MEM(HEADER_, SYNTHESIZER_COMPLETION_CAUSE),
ENUM_MEM(HEADER_, SYNTHESIZER_COMPLETION_REASON),
ENUM_MEM(HEADER_, SYNTHESIZER_VOICE_GENDER),
ENUM_MEM(HEADER_, SYNTHESIZER_VOICE_AGE),
ENUM_MEM(HEADER_, SYNTHESIZER_VOICE_VARIANT),
ENUM_MEM(HEADER_, SYNTHESIZER_VOICE_NAME),
ENUM_MEM(HEADER_, SYNTHESIZER_PROSODY_VOLUME),
ENUM_MEM(HEADER_, SYNTHESIZER_PROSODY_RATE),
ENUM_MEM(HEADER_, SYNTHESIZER_SPEECH_MARKER),
ENUM_MEM(HEADER_, SYNTHESIZER_SPEECH_LANGUAGE),
ENUM_MEM(HEADER_, SYNTHESIZER_FETCH_HINT),
ENUM_MEM(HEADER_, SYNTHESIZER_AUDIO_FETCH_HINT),
ENUM_MEM(HEADER_, SYNTHESIZER_FAILED_URI),
ENUM_MEM(HEADER_, SYNTHESIZER_FAILED_URI_CAUSE),
ENUM_MEM(HEADER_, SYNTHESIZER_SPEAK_RESTART),
ENUM_MEM(HEADER_, SYNTHESIZER_SPEAK_LENGTH),
ENUM_MEM(HEADER_, SYNTHESIZER_LOAD_LEXICON),
ENUM_MEM(HEADER_, SYNTHESIZER_LEXICON_SEARCH_ORDER)
};
// From /libs/mrcp/resources/include/mrcp_synth_header.h
/** @brief Synthesizer completion-cause specified in SPEAK-COMPLETE event */
enum UniMRCPSynthesizerCompletionCause {
ENUM_MEM(COMPLETION_, SYNTHESIZER_CAUSE_NORMAL) = 0,
ENUM_MEM(COMPLETION_, SYNTHESIZER_CAUSE_BARGE_IN) = 1,
ENUM_MEM(COMPLETION_, SYNTHESIZER_CAUSE_PARSE_FAILURE) = 2,
ENUM_MEM(COMPLETION_, SYNTHESIZER_CAUSE_URI_FAILURE) = 3,
ENUM_MEM(COMPLETION_, SYNTHESIZER_CAUSE_ERROR) = 4,
ENUM_MEM(COMPLETION_, SYNTHESIZER_CAUSE_LANGUAGE_UNSUPPORTED) = 5,
ENUM_MEM(COMPLETION_, SYNTHESIZER_CAUSE_LEXICON_LOAD_FAILURE) = 6,
ENUM_MEM(COMPLETION_, SYNTHESIZER_CAUSE_CANCELLED) = 7,
ENUM_MEM(COMPLETION_, SYNTHESIZER_CAUSE_UNKNOWN) = 8
};
// From /libs/mrcp/resources/include/mrcp_synth_header.h
/** @brief MRCP voice-gender */
enum UniMRCPVoiceGender {
ENUM_MEM(VOICE_, GENDER_MALE),
ENUM_MEM(VOICE_, GENDER_FEMALE),
ENUM_MEM(VOICE_, GENDER_NEUTRAL),
ENUM_MEM(VOICE_, GENDER_UNKNOWN)
};
// From /libs/mrcp/resources/include/mrcp_synth_header.h
/** @brief Speech-length types */
enum UniMRCPSpeechLengthType {
ENUM_MEM(SPEECH_, LENGTH_TYPE_TEXT) = 0,
ENUM_MEM(SPEECH_, LENGTH_TYPE_NUMERIC) = 1,
ENUM_MEM(SPEECH_, LENGTH_TYPE_UNKNOWN) = 3
};
// From /libs/mrcp/resources/include/mrcp_synth_header.h
/** @brief Speech-units */
enum UniMRCPSpeechUnit {
ENUM_MEM(SPEECH_UNIT_, SECOND),
ENUM_MEM(SPEECH_UNIT_, WORD),
ENUM_MEM(SPEECH_UNIT_, SENTENCE),
ENUM_MEM(SPEECH_UNIT_, PARAGRAPH),
};
// From /libs/mrcp/resources/include/mrcp_synth_header.h
/** @brief Prosody-rate type */
enum UniMRCPProsodyRateType {
ENUM_MEM(PROSODY_, RATE_TYPE_LABEL),
ENUM_MEM(PROSODY_, RATE_TYPE_RELATIVE),
ENUM_MEM(PROSODY_, RATE_TYPE_UNKNOWN)
};
// From /libs/mrcp/resources/include/mrcp_synth_header.h
/** @brief Prosody-rate */
enum UniMRCPProsodyRateLabel {
ENUM_MEM(PROSODY_, RATE_XSLOW),
ENUM_MEM(PROSODY_, RATE_SLOW),
ENUM_MEM(PROSODY_, RATE_MEDIUM),
ENUM_MEM(PROSODY_, RATE_FAST),
ENUM_MEM(PROSODY_, RATE_XFAST),
ENUM_MEM(PROSODY_, RATE_DEFAULT),
ENUM_MEM(PROSODY_, RATE_UNKNOWN)
};
// From /libs/mrcp/resources/include/mrcp_synth_header.h
/** @brief Prosody-volume type */
enum UniMRCPProsodyVolumeType {
ENUM_MEM(PROSODY_, VOLUME_TYPE_LABEL),
ENUM_MEM(PROSODY_, VOLUME_TYPE_NUMERIC),
ENUM_MEM(PROSODY_, VOLUME_TYPE_RELATIVE),
ENUM_MEM(PROSODY_, VOLUME_TYPE_UNKNOWN)
};
// From /libs/mrcp/resources/include/mrcp_synth_header.h
/** @brief Prosody-volume */
enum UniMRCPProsodyVolumeLabel {
ENUM_MEM(PROSODY_, VOLUME_SILENT),
ENUM_MEM(PROSODY_, VOLUME_XSOFT),
ENUM_MEM(PROSODY_, VOLUME_SOFT),
ENUM_MEM(PROSODY_, VOLUME_MEDIUM),
ENUM_MEM(PROSODY_, VOLUME_LOUD),
ENUM_MEM(PROSODY_, VOLUME_XLOUD),
ENUM_MEM(PROSODY_, VOLUME_DEFAULT),
ENUM_MEM(PROSODY_, VOLUME_UNKNOWN)
};
/**
* @brief The only exception thrown directly by the wrapper.
*/
#ifdef _MSC_VER
# pragma warning (push)
# pragma warning (disable: 4512)
#endif
class UniMRCPException {
public:
UniMRCPException(char const* _file, unsigned _line, char const* _msg) :
file(_file), line(_line), msg(_msg)
{};
char const* const file;
unsigned const line;
char const* const msg;
};
#ifdef _MSC_VER
# pragma warning (pop)
#endif
/**
* @brief Logger object for user-implemented logging.
*/
class UniMRCPLogger {
public:
/** @brief Receives the messages. Must be overriden. */
virtual bool Log(char const* file, unsigned line, UniMRCPLogPriority priority, char const* message) = 0;
inline UniMRCPLogger() {};
WRAPPER_DECL virtual ~UniMRCPLogger();
private:
/** @brief Called by APT logger instance, calls Log method */
static int LogExtHandler(char const* file, int line, char const* id, UniMRCPLogPriority priority, char const* format, va_list arg_ptr);
/** @brief Only one logger used at a time */
static UniMRCPLogger* logger;
friend class UniMRCPClient;
};
/**
* @brief UniMRCP client object and static methods to initialize the platform
*/
class UniMRCPClient {
/** @name Version getters */
/** @{ */
public:
WRAPPER_DECL static void UniMRCPVersion(unsigned short& major, unsigned short& minor, unsigned short& patch);
WRAPPER_DECL static void WrapperVersion(unsigned short& major, unsigned short& minor, unsigned short& patch);
WRAPPER_DECL static void APRVersion(unsigned short& major, unsigned short& minor, unsigned short& patch);
WRAPPER_DECL static void APRUtilVersion(unsigned short& major, unsigned short& minor, unsigned short& patch);
WRAPPER_DECL static char const* SofiaSIPVersion();
/** @} */
public:
/**
* @brief Initialize UniMRCP platform with default UniMRCP (APT) logger.
*
* Must be called first before any clients are created.
*
* @param root_dir UniMRCP directory structure root
* @param log_prio Priority of log messages to write to log
* @param log_out Where to write log
* @param log_fname Log file name; default unimrcpclient-PLATFORM
* @param max_log_fsize Max log file size
* @param max_log_fcount Max log files for rotation
*/
WRAPPER_DECL static void StaticInitialize(char const* root_dir,
UniMRCPLogPriority log_prio = ENUM_MEM(APT_PRIO_, NOTICE),
UniMRCPLogOutput log_out = ENUM_MEM(APT_LOG_OUTPUT_, FILE),
char const* log_fname = NULL,
unsigned max_log_fsize = 8 * 1024 * 1024,
unsigned max_log_fcount = 10) THROWS(UniMRCPException);
/**
* @brief Initialize UniMRCP platform with user-defined logger.
*
* Must be called first before any clients are created.
*
* @param logger User logger object.
* @param log_prio Priority of messages to send to the logger.
*/
WRAPPER_DECL static void StaticInitialize(UniMRCPLogger* logger,
UniMRCPLogPriority log_prio = ENUM_MEM(APT_PRIO_, NOTICE)) THROWS(UniMRCPException);
/**
* @brief Deinitialize UniMRCP platform. Can be called after all client instances are destroyed.
*/
WRAPPER_DECL static void StaticDeinitialize() THROWS(UniMRCPException);
public:
/**
* @brief Create UniMRCP client instance.
*
* @param config Client framework root dir or inline XML configuration (see below)
* @param dir If true, above parameter is the root dir, otherwise it is XML string
*/
WRAPPER_DECL UniMRCPClient(char const* config, bool dir = false) THROWS(UniMRCPException);
/** @brief Calls Destroy if not already destroyed */
WRAPPER_DECL ~UniMRCPClient();
/** @brief Destroy the client immediately (blocking call) */
WRAPPER_DECL void Destroy();
private:
mrcp_client_t* client; ///< The client opaque object
mrcp_application_t* app; ///< Application opaque object
bool terminated; ///< Destroying
unsigned sess_id; ///< Sessions counter
static unsigned instances; ///< How many clients there are
static unsigned staticInitialized; ///< How many times static initialized
static apr_pool_t* staticPool; ///< Memory pool for common things (very small)
/** @brief Common static pre-initialization steps with possible file descriptor hack */
static void StaticPreinitialize(int& fd_stdin, int& fd_stdout, int& fd_stderr) THROWS(UniMRCPException);
/** @brief Common static post-initialization steps with possible file descriptor hack */
static void StaticPostinitialize(int fd_stdin, int fd_stdout, int fd_stderr);
private:
/** @brief Called by UniMRCP client task */
static int AppMessageHandler(const mrcp_app_message_t* msg);
friend class UniMRCPClientSession;
};
/**
* @brief MRCP session. Contains media streams and signaling channels.
*/
class UniMRCPClientSession {
public:
/** @brief Create an MRCP session using specified profile */
WRAPPER_DECL UniMRCPClientSession(UniMRCPClient* client, char const* profile) THROWS(UniMRCPException);
/** @brief Calls Destroy */
WRAPPER_DECL virtual ~UniMRCPClientSession();
WRAPPER_DECL void ResourceDiscover();
/** @brief Terminate the session. It must still be destroyed after termination. */
WRAPPER_DECL void Terminate();
/** @brief Destroy and terminate the session if not terminated yet */
WRAPPER_DECL void Destroy();
/** @brief Get MRCP session ID */
WRAPPER_DECL char const* GetID() const;
/** @brief Session updated (SDP renegotiated?) */
WRAPPER_DECL virtual bool OnUpdate(UniMRCPSigStatusCode status);
/** @brief Session terminated gracefully */
WRAPPER_DECL virtual bool OnTerminate(UniMRCPSigStatusCode status);
/** @brief Session terminated unexpectedly */
WRAPPER_DECL virtual bool OnTerminateEvent();
// apt_bool_t (*on_resource_discover)(mrcp_application_t* application, mrcp_session_t* session, mrcp_session_descriptor_t* descriptor, mrcp_sig_status_code_e status);
private:
static int AppOnSessionUpdate(mrcp_application_t* application, mrcp_session_t* session, UniMRCPSigStatusCode status);
static int AppOnSessionTerminate(mrcp_application_t* application, mrcp_session_t* session, UniMRCPSigStatusCode status);
static int AppOnTerminateEvent(mrcp_application_t* application, mrcp_session_t* session, mrcp_channel_t* channel);
static int AppOnResourceDiscover(mrcp_application_t* application, mrcp_session_t* session, mrcp_session_descriptor_t* descriptor, UniMRCPSigStatusCode status);
private:
mrcp_session_t* sess; ///< Opaque C object
UniMRCPClient* client; ///< Owner of the session
bool terminated; ///< Has it been terminated
bool destroyOnTerminate; ///< Destroy as soon as terminated
friend class UniMRCPClient;
friend class UniMRCPAudioTermination;
friend class UniMRCPClientChannel;
};
/**
* @brief Outgoing media stream (RX from the point of view of server)
*/
class UniMRCPStreamRx {
public:
/** @brief Create in UniMRCPAudioTermination::OnStreamOpenRx() */
WRAPPER_DECL UniMRCPStreamRx();
WRAPPER_DECL virtual ~UniMRCPStreamRx();
/** @brief Enqueue DTMF digit for transmission */
WRAPPER_DECL bool SendDTMF(char digit);
/** @brief Frame size in bytes */
WRAPPER_DECL size_t GetDataSize() const;
/**
* @brief Send data to the server (should be used in ReadFrame())
* @param buf Pointer to the buffer to send
* @param len Length of the buffer, but at most GetDataSize() bytes will be sent
*/
WRAPPER_DECL void SetData(void const* buf, size_t len);
/** @brief Called when stream is being closed */
WRAPPER_DECL virtual void OnClose();
/** @brief Called whenever a frame is needed */
WRAPPER_DECL virtual bool ReadFrame();
private:
/** @brief Initialize internal data after user-defined creation procedure */
WRAPPER_DECL virtual bool OnOpenInternal(UniMRCPAudioTermination const* term, mpf_audio_stream_t const* stm);
/** @brief Clean-up after OnClose() event handled */
WRAPPER_DECL virtual void OnCloseInternal();
private:
mpf_frame_t* frm; ///< Single media frame
mpf_dtmf_generator_t* dtmf_gen; ///< DTMF generator C opaque object
UniMRCPAudioTermination* term; ///< Owning audio termination
friend class UniMRCPAudioTermination;
friend class UniMRCPStreamRxBuffered;
friend class UniMRCPStreamRxMemory;
friend class UniMRCPStreamRxFile;
};
/**
* @brief Thread-safe buffered outgoing stream (RX from the point of view of server).
*
* User can add data any time and they are continually transmitted.
* @see UniMRCPStreamRx