Vesna
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SoundParser.h
Go to the documentation of this file.
1 #ifndef _SOUND_PARSER_H_
2 #define _SOUND_PARSER_H_
3 
4 #include "commondevices/playerdriver/EPlayerDefines.h"
5 
6 #include <stdio.h>
7 #include <string>
8 
9 #include <sys/types.h>
10 
11 // v pripade potreby doplnit dalsie udalosti podla DEFINE-ov z mijoly (z HlasicDefine.h)
13 {
15  DepartureFromBusStop = 2, // same as next bus stop
30 };
31 
32 struct HEADER
33 {
34  u_int32_t m_Test; // cislo 0x5a5a5a5a
35  u_int32_t m_VelkostSuboru; // celkova velkost (1)+(2)+(3)+(4)+(5)+(6)
36  u_int32_t m_AdrCfgSTA; // absolutna adresa zaciatku (2)
37  int16_t m_VelkostCfgSTA;
38  u_int32_t m_PocetZvukov;
39  u_int32_t m_AdrOffset; // absolutna adresa zaciatku (3)
40  u_int32_t m_UdaOffset; // absolutna adresa zaciatku (4)
41  u_int32_t m_ZvuOffset; // absolutna adresa zaciatku (5)
42  u_int32_t m_AdrData; // absolutna adresa zaciatku (6)
43  u_int32_t m_AdrProgPIC; // absolutna adresa zaciatku (7),ak neexistuje, vyplnit 0
44  u_int32_t m_ZvukON; // cislo zvuku, ktory sa prehra po zapnuti, alebo skonceni prenosu dat (nejaky gong)
45 }__attribute__ ( ( packed ) );
46 
47 struct CONFIG
48 {
49  u_int8_t m_Number1;
50  u_int8_t m_Number2;
51 }__attribute__ ( ( packed ) );
52 
53 struct OFFSET
54 {
55  u_int32_t m_SoundAdr;
56  u_int32_t m_SoundSize;
57 }__attribute__ ( ( packed ) );
58 
60 {
61  u_int8_t m_TypUdalosti;
62  u_int8_t m_TypZvuku; // 0 - konstanta alebo 1 - premenna
63  u_int8_t m_Kanal;
64  u_int8_t m_Rezerva;
65  int32_t m_CisloZvuku;
66 }__attribute__ ( ( packed ) );
67 
69 {
70  int32_t m_CisloLinky;
71  u_int8_t m_SmerLinky; // SMER TAM - Hodnota 1, SMER SPAT - Hodnota 2, SMER OBA - Hodnota 0
72  u_int8_t m_Rezerva;
73  int32_t m_CisloSpoja;
74  int32_t m_CisloZastavky;
75  int16_t m_CisloZvuku;
76 }__attribute__ ( ( packed ) );
77 
78 #define TMP_MP3 "001.mp3"
79 
81 {
82 public:
83  SoundParser ();
84  virtual ~SoundParser();
85 
91  long Init( const std::string &soundFileName );
92 
96  unsigned char WriteOutFile( unsigned char soundEvent, long lineNumber, short direction, long tripNumber, long busStop );
97  std::string GetOutputMp3Path();
98 
99 private:
100  class ECpSoundEventData
101  {
102  public:
103  unsigned char ucUdalost;
104  long ulLinka;
105  short sSmer; // 'Spat' - hodnota 2 (Vynimka vo funkcii WriteOutFile), 'Tam' - hodnota 1
106  long ulSpoj;
107  long ulZastavka;
108  };
109 
110  class ESoundEventData
111  {
112  public:
113  ESoundEventData()
114  {
115  iFirstUdalost = -1;
116  iLastUdalost = -1;
117  bRightOffsets = NULL;
118  i = 0;
119  lOffCount = 0;
120  lUdalostNaviac = 0 ; // ak najdem ku jednej udalosti viacej offsetov ktore sa maju prehrat
121  }
122 
123  long iFirstUdalost;
124  long iLastUdalost;
125  OFFSET *bRightOffsets;
126  OFFSET bPomOffsets[100];
127  long i;
128  long lOffCount;
129  long lUdalostNaviac;
130  };
131 
132  void ReadFromFile( FILE *inputSoundFile );
133 
138  bool GetBeginAndEndOfSoundsForLine( long &firstMatchingLineBusStopSoundIndex, long &lastMatchingLineBusStopSoundIndex, bool &lastMatchingIndexWasFound, long lineNumber );
139  long GetEventRange( ESoundEventData *soundEventData, unsigned char eventType );
140  bool ParseBS( long begin, long end, ESoundEventData *soundEventData, ECpSoundEventData timeTableSoundEventData );
141 
144  bool ParseLineBusStopSoundsByTripNumber( ESoundEventData *soundEventData, ECpSoundEventData timeTableSoundEventData );
146  bool ParseLineBusStopSoundsByLineDirection( ESoundEventData *soundEventData, ECpSoundEventData timeTableSoundEventData );
148  bool ParseLineBusStopSoundsByLineNumber( ESoundEventData *soundEventData, ECpSoundEventData timeTableSoundEventData );
150  bool ParseBusStopSounds( ESoundEventData *soundEventData, ECpSoundEventData timeTableSoundEventData );
151  long WriteFile( ESoundEventData *soundEventData );
152 
153  std::string GetIncFilePath();
154 
155  int mFileNumberCounter;
156  std::string mOutputMp3Path;
157  HEADER mHeader;
158  OFFSET *mOffsetSound;
159  long mOffsetCount;
160  TRAFIC_EVENTS *mEvents;
161  long mTrafficEventCount;
162  LINKA_ZASTAVKA_ZVUK *mLineBusStopSound;
163  long mLineBusStopSoundCount;
164  FILE *mSoundFile;
165  FILE *mFileSoundParser;
166 };
167 
168 #endif // _SOUND_PARSER_H_
u_int8_t m_Number1
Definition: SoundParser.h:49
u_int32_t m_PocetZvukov
Definition: SoundParser.h:38
Definition: SoundParser.h:29
Definition: SoundParser.h:28
Definition: SoundParser.h:25
int16_t m_VelkostCfgSTA
Definition: SoundParser.h:37
Definition: SoundParser.h:22
u_int32_t m_SoundSize
Definition: SoundParser.h:56
long Init(const std::string &soundFileName)
Definition: SoundParser.cpp:227
Definition: SoundParser.h:16
Definition: SoundParser.h:32
std::string GetOutputMp3Path()
Definition: SoundParser.cpp:588
Definition: SoundParser.h:19
u_int8_t m_TypUdalosti
Definition: SoundParser.h:61
SoundEvent
Definition: SoundParser.h:12
u_int32_t m_AdrProgPIC
Definition: SoundParser.h:43
Definition: SoundParser.h:20
u_int8_t m_Number2
Definition: SoundParser.h:50
u_int32_t m_AdrOffset
Definition: SoundParser.h:39
u_int32_t m_ZvuOffset
Definition: SoundParser.h:41
Definition: SoundParser.h:68
int32_t m_CisloSpoja
Definition: SoundParser.h:73
u_int8_t m_TypZvuku
Definition: SoundParser.h:62
u_int32_t m_UdaOffset
Definition: SoundParser.h:40
int16_t m_CisloZvuku
Definition: SoundParser.h:75
virtual ~SoundParser()
Definition: SoundParser.cpp:63
u_int8_t m_SmerLinky
Definition: SoundParser.h:71
Definition: SoundParser.h:26
Definition: SoundParser.h:59
u_int32_t m_Test
Definition: SoundParser.h:34
class SoundParser __attribute__
Definition: SoundParser.h:23
SoundParser()
Definition: SoundParser.cpp:41
Definition: SoundParser.h:14
Definition: SoundParser.h:47
Definition: SoundParser.h:21
Definition: SoundParser.h:27
Definition: SoundParser.h:15
unsigned char WriteOutFile(unsigned char soundEvent, long lineNumber, short direction, long tripNumber, long busStop)
Definition: SoundParser.cpp:158
int32_t m_CisloZastavky
Definition: SoundParser.h:74
u_int32_t m_ZvukON
Definition: SoundParser.h:44
u_int32_t m_SoundAdr
Definition: SoundParser.h:55
Definition: SoundParser.h:80
Definition: SoundParser.h:18
Definition: SoundParser.h:24
u_int8_t m_Rezerva
Definition: SoundParser.h:72
int32_t m_CisloZvuku
Definition: SoundParser.h:65
Definition: SoundParser.h:17
u_int32_t m_AdrCfgSTA
Definition: SoundParser.h:36
u_int32_t m_AdrData
Definition: SoundParser.h:42
Definition: SoundParser.h:53
u_int32_t m_VelkostSuboru
Definition: SoundParser.h:35
u_int8_t m_Rezerva
Definition: SoundParser.h:64
u_int8_t m_Kanal
Definition: SoundParser.h:63
int32_t m_CisloLinky
Definition: SoundParser.h:70