Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

XmlVideo.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_IDash_XmlVideo_h
00002 #define Impala_Core_IDash_XmlVideo_h
00003 
00004 #include "Util/XmlDoc.h"
00005 #include "Persistency/XmlFileReader.h"
00006 #include "Link/Curl/CurlFuncs.h"
00007 #include "Core/IDash/Href.h"
00008 
00009 namespace Impala
00010 {
00011 namespace Core
00012 {
00013 namespace IDash
00014 {
00015 
00016 
00017 class XmlVideo : public Util::XmlDoc
00018 {
00019 public:
00020 
00021     XmlVideo(String href) : mHref(href)
00022     {
00023         Link::Curl::Memory mem = Link::Curl::Get(href);
00024         Util::IOBuffer ioBuf(mem.size, (unsigned char*) mem.data);
00025         ReadData(href, &ioBuf);
00026     }
00027 
00028     virtual
00029     ~XmlVideo()
00030     {
00031     }
00032 
00033     bool
00034     Valid() const
00035     {
00036         return mValid;
00037     }
00038 
00039     String
00040     GetLink() const
00041     {
00042         return mHref.AsString();
00043     }
00044 
00045     String
00046     GetId() const
00047     {
00048         return mId;
00049     }
00050 
00051     String
00052     GetCaseLink() const
00053     {
00054         return mCaseLink;
00055     }
00056 
00057     String
00058     GetCaseId() const
00059     {
00060         return mHref.GetCaseId();
00061     }
00062 
00063     String
00064     GetFileName() const
00065     {
00066         return mFileName;
00067     }
00068 
00069     bool
00070     IsProcessed() const
00071     {
00072         return mStatus == "Processed";
00073     }
00074 
00075     int
00076     GetFrames() const
00077     {
00078         return mFrames;
00079     }
00080 
00081     int
00082     GetShots() const
00083     {
00084         return mShots;
00085     }
00086 
00087     String
00088     GetShotLinkImage(int shot) const
00089     {
00090         return GetCaseLink() + "/videos/" + GetId() + "/shots/"
00091             + MakeString(shot) + "/PNG";
00092     }
00093 
00094     String
00095     GetShotLinkXml(int shot) const
00096     {
00097         return GetCaseLink() + "/videos/" + GetId() + "/shots/"
00098             + MakeString(shot) + "/XML";
00099     }
00100 
00101 private:
00102 
00103     /* sample file:
00104 
00105 <?xml version="1.0" encoding="utf-8"?>
00106 <video xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.i-dash.eu/MetaData http://www.i-dash.eu/Schemas/MetaData/MetaData.xsd" xmlns="http://www.i-dash.eu/MetaData">
00107   <id>17</id>
00108   <entityType>Video</entityType>
00109   <memo />
00110   <case xlink:type="simple" xlink:href="http://146.50.22.23:7878/services/vds/cases/16" entityType="Case" />
00111   <fileName>1-01.mpg</fileName>
00112   <fileSize>358124647</fileSize>
00113   <fileDate>2007-07-25T08:39:47</fileDate>
00114   <duration>20159213445</duration>
00115   <containerName />
00116   <MD5>DFA0BCF35A89766C88BA3C498A903DB8</MD5>
00117   <SHA1>627C16ACC1E6F8134315B3FA68EAEC18EF92F635</SHA1>
00118   <videoFileStatus>Processed</videoFileStatus>
00119   <frames>50398</frames>
00120   <keyFrames>2336</keyFrames>
00121   <shots>296</shots>
00122   <framesURL xlink:type="simple" xlink:href="http://146.50.22.23:7878/services/vds/cases/16/videos/17/frames/" />
00123 </video>
00124 
00125     */
00126 
00127     void
00128     ReadData(String docName, Util::IOBuffer* ioBuf)
00129     {
00130         mValid = false;
00131         Persistency::XmlFileReader reader;
00132         DOMDocument* doc = reader.Read(docName, ioBuf);
00133         if (!doc)
00134             return;
00135         DOMNode* video = GetChildNode(doc, "video", true);
00136         DOMNode* id = GetChildNode(video, "id", true);
00137         mId = GetElementValue(id);
00138         ILOG_DEBUG("id = " << mId);
00139 
00140         DOMNode* casee = GetChildNode(video, "case", true);
00141         mCaseLink = GetAttributeValue(casee, "xlink:href");
00142         ILOG_DEBUG("case = " << mCaseLink);
00143 
00144         DOMNode* fname = GetChildNode(video, "fileName", true);
00145         mFileName = GetElementValue(fname);
00146         ILOG_DEBUG("fileName = " << mFileName);
00147 
00148         DOMNode* status = GetChildNode(video, "videoFileStatus", true);
00149         mStatus = GetElementValue(status);
00150         ILOG_DEBUG("status = " << mStatus);
00151 
00152         DOMNode* shot = GetChildNode(video, "shots", true);
00153         mShots = Impala::atol(GetElementValue(shot));
00154         ILOG_DEBUG("shots = " << mShots);
00155 
00156         DOMNode* frame = GetChildNode(video, "frames", true);
00157         mFrames = Impala::atol(GetElementValue(frame));
00158         ILOG_DEBUG("frames = " << mFrames);
00159         mValid = true;
00160     }
00161 
00162     // data
00163 
00164     Href   mHref;
00165     String mId;
00166     String mCaseLink;
00167     String mFileName;
00168     String mStatus;
00169     int    mFrames;
00170     int    mShots;
00171     bool   mValid;
00172 
00173     ILOG_VAR_DEC;
00174 
00175 };
00176 
00177 ILOG_VAR_INIT(XmlVideo, Impala.Core.IDash);
00178 
00179 } // namespace IDash
00180 } // namespace Core
00181 } // namespace Impala
00182 
00183 #endif

Generated on Fri Mar 19 09:31:11 2010 for ImpalaSrc by  doxygen 1.5.1