EMIPLIB

mipv4l2input.h

Go to the documentation of this file.
00001 /*
00002     
00003   This file is a part of EMIPLIB, the EDM Media over IP Library.
00004   
00005   Copyright (C) 2006-2011  Hasselt University - Expertise Centre for
00006                       Digital Media (EDM) (http://www.edm.uhasselt.be)
00007 
00008   This library is free software; you can redistribute it and/or
00009   modify it under the terms of the GNU Lesser General Public
00010   License as published by the Free Software Foundation; either
00011   version 2.1 of the License, or (at your option) any later version.
00012 
00013   This library is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016   Lesser General Public License for more details.
00017 
00018   You should have received a copy of the GNU Lesser General Public
00019   License along with this library; if not, write to the Free Software
00020   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  
00021   USA
00022 
00023 */
00024 
00029 #ifndef MIPV4L2INPUT_H
00030 
00031 #define MIPV4L2INPUT_H
00032 
00033 #include "mipconfig.h"
00034 
00035 #ifdef MIPCONFIG_SUPPORT_VIDEO4LINUX
00036 
00037 #include "mipcomponent.h"
00038 #include "mipsignalwaiter.h"
00039 #include "miptime.h"
00040 #include <jthread/jthread.h>
00041 
00042 class MIPVideoMessage;
00043 
00051 class EMIPLIB_IMPORTEXPORT MIPV4L2Input : public MIPComponent, private jthread::JThread
00052 {
00053 public:
00054         MIPV4L2Input();
00055         ~MIPV4L2Input();
00056 
00058         bool open(int width, int height, const std::string &device = std::string("/dev/video0"));
00059 
00061         bool close();
00062 
00064         int getWidth() const                                                                    { if (m_device != -1) return m_width; return -1; }
00065 
00067         int getHeight() const                                                                   { if (m_device != -1) return m_height; return -1; }
00068         
00070         void setSourceID(uint64_t srcID)                                                        { m_sourceID = srcID; }
00071 
00073         uint64_t getSourceID() const                                                            { return m_sourceID; }
00074 
00076         bool getCompressed() const                                                              { return m_compressed; }
00077         
00079         uint32_t getFrameSubtype() const                                                        { return m_subType; }
00080 
00081         bool push(const MIPComponentChain &chain, int64_t iteration, MIPMessage *pMsg);
00082         bool pull(const MIPComponentChain &chain, int64_t iteration, MIPMessage **pMsg);
00083 private:
00084         void *Thread();
00085         void cleanUp();
00086 
00087         int m_device;
00088         int m_width, m_height;
00089         bool m_streaming, m_userPtr;
00090         bool m_compressed;
00091         uint8_t *m_pCurFrame;
00092         uint8_t *m_pFullFrame;
00093         uint8_t *m_pMsgFrame;
00094         size_t m_frameSize;
00095         MIPVideoMessage *m_pVideoMsg;
00096         jthread::JMutex m_frameMutex;
00097         jthread::JMutex m_stopMutex;
00098         MIPSignalWaiter m_sigWait;
00099         bool m_gotMsg, m_stopLoop;
00100         bool m_gotFrame;
00101         MIPTime m_captureTime;
00102         uint64_t m_sourceID;
00103         uint32_t m_subType;
00104 };
00105 
00106 #endif // MIPCONFIG_SUPPORT_VIDEO4LINUX
00107 
00108 #endif // MIPV4L2INPUT_H
00109