Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef __JAUS_EXTRAS_VIDEO_VIDEO_SUBSCRIBER__H
00041 #define __JAUS_EXTRAS_VIDEO_VIDEO_SUBSCRIBER__H
00042
00043 #include "jaus/core/management/management.h"
00044 #include "jaus/extras/video/reportimage.h"
00045 #include "jaus/extras/video/queryimage.h"
00046 #include <cxutils/images/image.h>
00047
00048 namespace JAUS
00049 {
00050 typedef CxUtils::Image Image;
00051
00052 class SharedImage;
00053
00061 class JAUS_EXTRAS_DLL VideoSubscriber : public Management::Child
00062 {
00063 public:
00070 class JAUS_EXTRAS_DLL Callback : public AccessControl::Callback
00071 {
00072 public:
00073 typedef std::set<Callback* > Set;
00074 Callback() {}
00075 virtual ~Callback() {}
00076 virtual void ProcessCompressedVideo(const Address& source,
00077 const Byte camera,
00078 const Image::Format format,
00079 const unsigned char* compressedImage,
00080 const unsigned int compressedImageSize,
00081 const unsigned int frameNumber) {}
00082 virtual void ProcessRawImage(const Address& source,
00083 const Byte camera,
00084 const Image& image,
00085 const unsigned int frameNumber) {}
00086 };
00087 const static std::string Name;
00088
00089 VideoSubscriber();
00090
00091 ~VideoSubscriber();
00092
00093 virtual void Shutdown();
00094
00095 bool CreateVideoSubscription(const Address& id,
00096 const Byte cameraID = 0,
00097 const unsigned int waitTimeMs = Service::DefaultWaitMs);
00098 bool GetCameraCount(const Address& id,
00099 unsigned int& count,
00100 const unsigned int waitTimeMs = Service::DefaultWaitMs*3) const;
00101 bool GetCameraList(const Address& id,
00102 std::vector<Byte>& list,
00103 const unsigned int waitTimeMs = Service::DefaultWaitMs*3) const;
00104
00105 bool HaveVideoSubscription(const Address& id, const int cameraID = -1) const;
00106
00107 bool CancelVideoSubscription(const Address& id = Address(), const int cameraID = -1);
00108
00109 void RegisterCallback(Callback* callback, const bool rawImage, const bool add = true);
00110
00111 virtual bool GenerateEvent(const Events::Subscription& info) const { return false; }
00112
00113 virtual bool IsEventSupported(const Events::Type type,
00114 const double requestedPeriodicRate,
00115 const Message* queryMessage,
00116 double& confirmedPeriodicRate,
00117 std::string& errorMessage) const { return false; }
00118
00119 virtual bool IsDiscoverable() const { return false; }
00120
00121 virtual void Receive(const Message* message);
00122
00123 virtual Message* CreateMessage(const UShort messageCode) const;
00124
00125 virtual bool Resume() { return true; }
00126
00127 virtual bool Reset() { return true; }
00128
00129 virtual bool Standby() { return true; }
00130
00131 virtual bool SetEmergency() { return true; }
00132
00133 virtual bool ClearEmergency() { return true; }
00134
00135 virtual bool ReleaseControl() { return true; }
00136 private:
00137 static void SharedImageCallback(const Address& source,
00138 const Byte cameraID,
00139 const Image& img,
00140 const unsigned int frameNumber,
00141 void* fargs);
00142 Mutex mVideoCallbacksMutex;
00143 Mutex mSharedImagesMutex;
00144 Callback::Set mRawCallbacks;
00145 Callback::Set mCompressedCallbacks;
00146 std::vector<SharedImage*> mSharedImages;
00147 };
00148 }
00149
00150 #endif
00151