1/*---------------------------------------------------------------------------*
2 *  SR_EventLogImpl.h  *
3 *                                                                           *
4 *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
5 *                                                                           *
6 *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7 *  you may not use this file except in compliance with the License.         *
8 *                                                                           *
9 *  You may obtain a copy of the License at                                  *
10 *      http://www.apache.org/licenses/LICENSE-2.0                           *
11 *                                                                           *
12 *  Unless required by applicable law or agreed to in writing, software      *
13 *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 *  See the License for the specific language governing permissions and      *
16 *  limitations under the License.                                           *
17 *                                                                           *
18 *---------------------------------------------------------------------------*/
19
20#ifndef __SR_EventLogIMPL_H
21#define __SR_EventLogIMPL_H
22
23
24
25#include <stdlib.h>
26#include "ESR_ReturnCode.h"
27#include "ESR_SessionTypeListener.h"
28
29#define TOK_BUFLEN (2*P_PATH_MAX)
30#define MAX_LOG_RECORD (16*1024)
31
32/**
33 * EventLog implementation.
34 */
35
36typedef enum
37{
38  FILE_OK,
39  SPACE_SETTING,
40  UNINITIALIZED,
41  NO_FILE,
42  FILE_ERROR,
43  SEEK_ERROR
44} EventLogFileState;
45
46typedef struct SR_EventLogImpl_t
47{
48  /**
49   * Interface functions that must be implemented.
50   */
51  SR_EventLog Interface;
52
53  LCHAR tokenBuf[MAX_LOG_RECORD];
54
55  long serviceStartUserCPU;
56  long serviceStartKernelCPU;
57
58  EventLogFileState logFile_state;
59  ESR_SessionTypeListener sessionListener;
60  ESR_SessionTypeListenerPair sessionListenerPair;
61
62  PFile* logFile;
63  size_t logLevel;
64  LCHAR logFilename[P_PATH_MAX];
65  LCHAR waveformFilename[P_PATH_MAX];
66  PFile* waveformFile;
67  size_t waveformCounter;
68  size_t waveform_num_bytes;
69  size_t waveform_sample_rate;
70  size_t waveform_bytes_per_sample;
71}
72SR_EventLogImpl;
73
74SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_Destroy(SR_EventLog* self);
75
76SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_Token(SR_EventLog* self, const LCHAR* token, const LCHAR *value);
77
78SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_TokenInt(SR_EventLog* self, const LCHAR* token, int value);
79
80SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_TokenPointer(SR_EventLog* self, const LCHAR* token, void* value);
81
82SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_TokenUint16_t(SR_EventLog* self, const LCHAR* token, asr_uint16_t value);
83
84SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_TokenSize_t(SR_EventLog* self, const LCHAR* token, size_t value);
85
86SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_TokenBool(SR_EventLog* self, const LCHAR* token, ESR_BOOL value);
87
88SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_TokenFloat(SR_EventLog* self, const LCHAR* token, float value);
89
90SREC_EVENTLOG_API ESR_ReturnCode SR_EventLogEventSessionImpl(SR_EventLog* self);
91
92SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_Event(SR_EventLog* self, const LCHAR* eventName);
93
94SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_AudioOpen(SR_EventLog* self, const LCHAR* audio_type, size_t sample_rate, size_t sample_size);
95
96SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_AudioClose(SR_EventLog* self);
97
98SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_AudioWrite(SR_EventLog* self, void* buffer, size_t num_bytes);
99
100SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_AudioGetFilename(SR_EventLog* self, LCHAR* waveformFilename, size_t* len);
101
102#endif /* __SR_EventLogIMPL_H */
103