BltDecoderClient.h

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