00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef URBI_UBINARY_HH
00016 # define URBI_UBINARY_HH
00017
00018 namespace urbi
00019 {
00020
00022 enum USoundFormat
00023 {
00024 SOUND_RAW,
00025 SOUND_WAV,
00026 SOUND_MP3,
00027 SOUND_OGG,
00028 SOUND_UNKNOWN
00029 };
00030
00031 enum USoundSampleFormat
00032 {
00033 SAMPLE_SIGNED=1,
00034 SAMPLE_UNSIGNED=2
00035 };
00036
00037 enum UImageFormat
00038 {
00039 IMAGE_RGB=1,
00040 IMAGE_YCbCr=2,
00041 IMAGE_JPEG=3,
00042 IMAGE_PPM=4,
00043 IMAGE_UNKNOWN
00044 };
00045
00046 enum UBinaryType
00047 {
00048 BINARY_NONE,
00049 BINARY_UNKNOWN,
00050 BINARY_IMAGE,
00051 BINARY_SOUND
00052 };
00053
00054
00055
00056
00057
00058
00063 class USound
00064 {
00065 public:
00066 char *data;
00067 size_t size;
00068 int channels;
00069 int rate;
00070 int sampleSize;
00071
00072 USoundFormat soundFormat;
00073
00074 const char* format_string () const;
00075
00076 enum SampleFormat
00077 {
00078 SAMPLE_SIGNED=1,
00079 SAMPLE_UNSIGNED=2
00080 };
00081 USoundSampleFormat sampleFormat;
00082
00083 bool operator ==(const USound &b) const
00084 {
00085 return !memcmp(this, &b, sizeof(USound));
00086 }
00087 };
00088
00089
00090
00091
00092
00093
00098 class UImage
00099 {
00100 public:
00101 unsigned char *data;
00102 size_t size;
00103 size_t width, height;
00104
00105 UImageFormat imageFormat;
00106
00108 const char* format_string () const;
00109 };
00110
00111
00112
00113
00114
00115
00116
00117 class BinaryData
00118 {
00119 public:
00120 BinaryData()
00121 : data (0), size (0)
00122 {}
00123 BinaryData(void *d, int s)
00124 : data(d), size(s)
00125 {}
00126 void* data;
00127 size_t size;
00128 };
00129
00130
00131
00132
00133
00134
00135
00139 class UBinary
00140 {
00141 public:
00142
00143 UBinaryType type;
00144 union
00145 {
00146 struct
00147 {
00148 void* data;
00149 size_t size;
00150 } common;
00151 UImage image;
00152 USound sound;
00153 };
00155 std::string message;
00156
00157 UBinary();
00159 UBinary(const UBinary &b);
00160 explicit UBinary(const UImage &);
00161 explicit UBinary(const USound &);
00163 UBinary & operator = (const UBinary &b);
00165 void buildMessage();
00167 std::string getMessage() const;
00169 ~UBinary();
00170 int parse(const char* message, int pos,
00171 std::list<BinaryData> &bins,
00172 std::list<BinaryData>::iterator &binpos);
00173 };
00174
00175 }
00176
00177 #endif // ! URBI_UBINARY_HH