00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _BLT_DECODER_CLIENT_H_
00011 #define _BLT_DECODER_CLIENT_H_
00012
00013
00014
00015
00016 #include "Neptune.h"
00017 #include "Atomix.h"
00018 #include "BltDecoder.h"
00019 #include "BltTime.h"
00020 #include "BltDecoderServer.h"
00021
00022
00023
00024
00025 class BLT_DecoderClient_MessageHandler
00026 {
00027 public:
00028
00029 virtual ~BLT_DecoderClient_MessageHandler() {}
00030
00031 virtual void OnAckNotification(BLT_DecoderServer_Message::CommandId ) {}
00032 virtual void OnNackNotification(BLT_DecoderServer_Message::CommandId ,
00033 BLT_Result ) {}
00034 virtual void OnPongNotification(const void* ) {}
00035 virtual void OnDecoderStateNotification(BLT_DecoderServer::State ) {}
00036 virtual void OnStreamTimeCodeNotification(BLT_TimeCode ) {}
00037 virtual void OnStreamPositionNotification(BLT_StreamPosition& ) {}
00038 virtual void OnStreamInfoNotification(BLT_Mask ,
00039 BLT_StreamInfo& ) {}
00040 virtual void OnPropertyNotification(BLT_PropertyScope ,
00041 const char* ,
00042 const char* ,
00043 const ATX_PropertyValue* ) {}
00044 };
00045
00046
00047
00048
00049 class BLT_DecoderClient_Message : public NPT_Message
00050 {
00051 public:
00052
00053 static NPT_Message::Type MessageType;
00054 NPT_Message::Type GetType() {
00055 return MessageType;
00056 }
00057
00058
00059 virtual NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) = 0;
00060 virtual NPT_Result Dispatch(NPT_MessageHandler* handler) {
00061 BLT_DecoderClient_MessageHandler* specific =
00062 dynamic_cast<BLT_DecoderClient_MessageHandler*>(handler);
00063 if (specific) {
00064 return Deliver(specific);
00065 } else {
00066 return DefaultDeliver(handler);
00067 }
00068 }
00069 };
00070
00071
00072
00073
00074 class BLT_DecoderClient_AckNotificationMessage :
00075 public BLT_DecoderClient_Message
00076 {
00077 public:
00078
00079 BLT_DecoderClient_AckNotificationMessage(
00080 BLT_DecoderServer_Message::CommandId id) :
00081 m_Id(id) {}
00082 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00083 handler->OnAckNotification(m_Id);
00084 return NPT_SUCCESS;
00085 }
00086
00087 private:
00088
00089 BLT_DecoderServer_Message::CommandId m_Id;
00090 };
00091
00092
00093
00094
00095 class BLT_DecoderClient_NackNotificationMessage :
00096 public BLT_DecoderClient_Message
00097 {
00098 public:
00099
00100 BLT_DecoderClient_NackNotificationMessage(
00101 BLT_DecoderServer_Message::CommandId id, BLT_Result result) :
00102 m_Id(id), m_Result(result) {}
00103 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00104 handler->OnNackNotification(m_Id, m_Result);
00105 return NPT_SUCCESS;
00106 }
00107
00108 private:
00109
00110 BLT_DecoderServer_Message::CommandId m_Id;
00111 BLT_Result m_Result;
00112 };
00113
00114
00115
00116
00117 class BLT_DecoderClient_PongNotificationMessage :
00118 public BLT_DecoderClient_Message
00119 {
00120 public:
00121
00122 BLT_DecoderClient_PongNotificationMessage(const void* cookie) :
00123 m_Cookie(cookie) {}
00124 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00125 handler->OnPongNotification(m_Cookie);
00126 return NPT_SUCCESS;
00127 }
00128
00129 private:
00130
00131 const void* m_Cookie;
00132 };
00133
00134
00135
00136
00137 class BLT_DecoderClient_DecoderStateNotificationMessage :
00138 public BLT_DecoderClient_Message
00139 {
00140 public:
00141
00142 BLT_DecoderClient_DecoderStateNotificationMessage(
00143 BLT_DecoderServer::State state) :
00144 m_State(state) {}
00145 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00146 handler->OnDecoderStateNotification(m_State);
00147 return NPT_SUCCESS;
00148 }
00149
00150 private:
00151
00152 BLT_DecoderServer::State m_State;
00153 };
00154
00155
00156
00157
00158 class BLT_DecoderClient_StreamTimeCodeNotificationMessage :
00159 public BLT_DecoderClient_Message
00160 {
00161 public:
00162
00163 BLT_DecoderClient_StreamTimeCodeNotificationMessage(BLT_TimeCode time):
00164 m_TimeCode(time) {}
00165 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00166 handler->OnStreamTimeCodeNotification(m_TimeCode);
00167 return NPT_SUCCESS;
00168 }
00169
00170 private:
00171
00172 BLT_TimeCode m_TimeCode;
00173 };
00174
00175
00176
00177
00178 class BLT_DecoderClient_StreamPositionNotificationMessage :
00179 public BLT_DecoderClient_Message
00180 {
00181 public:
00182
00183 BLT_DecoderClient_StreamPositionNotificationMessage(
00184 BLT_StreamPosition& position): m_Position(position) {}
00185 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00186 handler->OnStreamPositionNotification(m_Position);
00187 return NPT_SUCCESS;
00188 }
00189
00190 private:
00191
00192 BLT_StreamPosition m_Position;
00193 };
00194
00195
00196
00197
00198 class BLT_DecoderClient_StreamInfoNotificationMessage :
00199 public BLT_DecoderClient_Message
00200 {
00201 public:
00202
00203 BLT_DecoderClient_StreamInfoNotificationMessage(BLT_Mask update_mask,
00204 BLT_StreamInfo& info):
00205 m_UpdateMask(update_mask), m_StreamInfo(info) {}
00206 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00207 handler->OnStreamInfoNotification(m_UpdateMask, m_StreamInfo);
00208 return NPT_SUCCESS;
00209 }
00210
00211 private:
00212
00213 BLT_Mask m_UpdateMask;
00214 BLT_StreamInfo m_StreamInfo;
00215 };
00216
00217
00218
00219
00220 class BLT_DecoderClient_PropertyNotificationMessage :
00221 public BLT_DecoderClient_Message
00222 {
00223 public:
00224
00225 BLT_DecoderClient_PropertyNotificationMessage(BLT_PropertyScope scope,
00226 const char* source,
00227 const char* name,
00228 const ATX_PropertyValue* value) :
00229 m_Scope(scope),
00230 m_Source(source),
00231 m_Name(name),
00232 m_PropertyValueWarpper(value) {}
00233 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00234 handler->OnPropertyNotification(m_Scope,
00235 m_Source,
00236 m_Name,
00237 m_PropertyValueWarpper.m_Value);
00238 return NPT_SUCCESS;
00239 }
00240
00241 private:
00242
00243 BLT_PropertyScope m_Scope;
00244 NPT_String m_Source;
00245 NPT_String m_Name;
00246 BLT_DecoderServer_PropertyValueWrapper m_PropertyValueWarpper;
00247 };
00248
00249
00250
00251
00252 class BLT_DecoderClient : public NPT_MessageReceiver,
00253 public NPT_MessageHandler,
00254 public BLT_DecoderClient_MessageHandler
00255 {
00256 public:
00257
00258 BLT_DecoderClient(NPT_MessageQueue* queue = NULL,
00259 NPT_MessageHandler* handler = NULL);
00260 virtual ~BLT_DecoderClient();
00261
00262 protected:
00263
00264 NPT_MessageQueue* m_MessageQueue;
00265 bool m_MessageQueueIsLocal;
00266 };
00267
00268 #endif