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 "BltDecoder.h"
00018 #include "BltTime.h"
00019 #include "BltDecoderServer.h"
00020
00021
00022
00023
00024 class BLT_DecoderClient_MessageHandler
00025 {
00026 public:
00027
00028 virtual ~BLT_DecoderClient_MessageHandler() {}
00029
00030 virtual void OnAckNotification(BLT_DecoderServer_Message::CommandId ) {}
00031 virtual void OnNackNotification(BLT_DecoderServer_Message::CommandId ,
00032 BLT_Result ) {}
00033 virtual void OnPongNotification(const void* ) {}
00034 virtual void OnDecoderStateNotification(BLT_DecoderServer::State ) {}
00035 virtual void OnStreamTimeCodeNotification(BLT_TimeCode ) {}
00036 virtual void OnStreamPositionNotification(BLT_StreamPosition& ) {}
00037 virtual void OnStreamInfoNotification(BLT_Mask ,
00038 BLT_StreamInfo& ) {}
00039 };
00040
00041
00042
00043
00044 class BLT_DecoderClient_Message : public NPT_Message
00045 {
00046 public:
00047
00048 static NPT_Message::Type MessageType;
00049 NPT_Message::Type GetType() {
00050 return MessageType;
00051 }
00052
00053
00054 virtual NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) = 0;
00055 virtual NPT_Result Dispatch(NPT_MessageHandler* handler) {
00056 BLT_DecoderClient_MessageHandler* specific =
00057 dynamic_cast<BLT_DecoderClient_MessageHandler*>(handler);
00058 if (specific) {
00059 return Deliver(specific);
00060 } else {
00061 return DefaultDeliver(handler);
00062 }
00063 }
00064 };
00065
00066
00067
00068
00069 class BLT_DecoderClient_AckNotificationMessage :
00070 public BLT_DecoderClient_Message
00071 {
00072 public:
00073
00074 BLT_DecoderClient_AckNotificationMessage(
00075 BLT_DecoderServer_Message::CommandId id) :
00076 m_Id(id) {}
00077 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00078 handler->OnAckNotification(m_Id);
00079 return NPT_SUCCESS;
00080 }
00081
00082 private:
00083
00084 BLT_DecoderServer_Message::CommandId m_Id;
00085 };
00086
00087
00088
00089
00090 class BLT_DecoderClient_NackNotificationMessage :
00091 public BLT_DecoderClient_Message
00092 {
00093 public:
00094
00095 BLT_DecoderClient_NackNotificationMessage(
00096 BLT_DecoderServer_Message::CommandId id, BLT_Result result) :
00097 m_Id(id), m_Result(result) {}
00098 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00099 handler->OnNackNotification(m_Id, m_Result);
00100 return NPT_SUCCESS;
00101 }
00102
00103 private:
00104
00105 BLT_DecoderServer_Message::CommandId m_Id;
00106 BLT_Result m_Result;
00107 };
00108
00109
00110
00111
00112 class BLT_DecoderClient_PongNotificationMessage :
00113 public BLT_DecoderClient_Message
00114 {
00115 public:
00116
00117 BLT_DecoderClient_PongNotificationMessage(const void* cookie) :
00118 m_Cookie(cookie) {}
00119 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00120 handler->OnPongNotification(m_Cookie);
00121 return NPT_SUCCESS;
00122 }
00123
00124 private:
00125
00126 const void* m_Cookie;
00127 };
00128
00129
00130
00131
00132 class BLT_DecoderClient_DecoderStateNotificationMessage :
00133 public BLT_DecoderClient_Message
00134 {
00135 public:
00136
00137 BLT_DecoderClient_DecoderStateNotificationMessage(
00138 BLT_DecoderServer::State state) :
00139 m_State(state) {}
00140 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00141 handler->OnDecoderStateNotification(m_State);
00142 return NPT_SUCCESS;
00143 }
00144
00145 private:
00146
00147 BLT_DecoderServer::State m_State;
00148 };
00149
00150
00151
00152
00153 class BLT_DecoderClient_StreamTimeCodeNotificationMessage :
00154 public BLT_DecoderClient_Message
00155 {
00156 public:
00157
00158 BLT_DecoderClient_StreamTimeCodeNotificationMessage(BLT_TimeCode time):
00159 m_TimeCode(time) {}
00160 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00161 handler->OnStreamTimeCodeNotification(m_TimeCode);
00162 return NPT_SUCCESS;
00163 }
00164
00165 private:
00166
00167 BLT_TimeCode m_TimeCode;
00168 };
00169
00170
00171
00172
00173 class BLT_DecoderClient_StreamPositionNotificationMessage :
00174 public BLT_DecoderClient_Message
00175 {
00176 public:
00177
00178 BLT_DecoderClient_StreamPositionNotificationMessage(
00179 BLT_StreamPosition& position): m_Position(position) {}
00180 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00181 handler->OnStreamPositionNotification(m_Position);
00182 return NPT_SUCCESS;
00183 }
00184
00185 private:
00186
00187 BLT_StreamPosition m_Position;
00188 };
00189
00190
00191
00192
00193 class BLT_DecoderClient_StreamInfoNotificationMessage :
00194 public BLT_DecoderClient_Message
00195 {
00196 public:
00197
00198 BLT_DecoderClient_StreamInfoNotificationMessage(BLT_Mask update_mask,
00199 BLT_StreamInfo& info):
00200 m_UpdateMask(update_mask), m_StreamInfo(info) {}
00201 NPT_Result Deliver(BLT_DecoderClient_MessageHandler* handler) {
00202 handler->OnStreamInfoNotification(m_UpdateMask, m_StreamInfo);
00203 return NPT_SUCCESS;
00204 }
00205
00206 private:
00207
00208 BLT_Mask m_UpdateMask;
00209 BLT_StreamInfo m_StreamInfo;
00210 };
00211
00212
00213
00214
00215 class BLT_DecoderClient : public NPT_MessageReceiver,
00216 public NPT_MessageHandler,
00217 public BLT_DecoderClient_MessageHandler
00218 {
00219 public:
00220
00221 BLT_DecoderClient(NPT_MessageQueue* queue = NULL,
00222 NPT_MessageHandler* handler = NULL);
00223 virtual ~BLT_DecoderClient();
00224
00225 protected:
00226
00227 NPT_MessageQueue* m_MessageQueue;
00228 bool m_MessageQueueIsLocal;
00229 };
00230
00231 #endif