Instrument Neutral Distributed Interface INDI  1.9.2
recorderinterface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 by geehalel <geehalel@gmail.com>
3 
4  V4L2 Record
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 */
21 
22 #pragma once
23 
24 #include "indidevapi.h"
25 #include "indibasetypes.h"
26 
27 #include <stdio.h>
28 #include <cstdlib>
29 #include <stdint.h>
30 
31 #include <vector>
32 
33 #if 0
34 #ifdef OSX_EMBEDED_MODE
35 #define v4l2_fourcc(a, b, c, d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
36 
37 #define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */
38 #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */
39 #define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */
40 #define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */
41 #define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3') /* 24 BGR-8-8-8 */
42 #define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') /* 24 RGB-8-8-8 */
43 #define V4L2_PIX_FMT_SRGGB8 v4l2_fourcc('R', 'G', 'G', 'B') /* 8 RGRG.. GBGB.. */
44 #define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */
45 
46 #else
47 #include <linux/videodev2.h>
48 #endif
49 #endif
50 
51 namespace INDI
52 {
57 {
58  public:
59  RecorderInterface() = default;
60  virtual ~RecorderInterface() = default;
61 
62  virtual const char *getName();
63  virtual const char *getExtension() = 0;
64  // true when direct encoding of pixel format
65  virtual bool setPixelFormat(INDI_PIXEL_FORMAT pixelFormat, uint8_t pixelDepth=8) = 0;
66  // set full image size in pixels
67  virtual bool setSize(uint16_t width, uint16_t height) = 0;
68  // Set FPS
69  virtual bool setFPS(float FPS) { m_FPS = FPS; return true; }
70  virtual bool open(const char *filename, char *errmsg) = 0;
71  virtual bool close() = 0;
72  // when frame is in known encoding format
73  virtual bool writeFrame(const uint8_t *frame, uint32_t nbytes) = 0;
74  // If streaming is enabled, then any subframing is already done by the stream recorder
75  // and no need to do any further subframing operations. Otherwise, subframing must be done.
76  // This is to reduce process time and save memory for a dedicated subframe buffer
77  virtual void setStreamEnabled(bool enable) = 0;
78 
79  protected:
80  const char *name;
81  float m_FPS = 1;
82 };
83 
84 }
INDI::RecorderInterface::setFPS
virtual bool setFPS(float FPS)
Definition: recorderinterface.h:69
INDI::RecorderInterface::setStreamEnabled
virtual void setStreamEnabled(bool enable)=0
INDI::RecorderInterface::~RecorderInterface
virtual ~RecorderInterface()=default
INDI::RecorderInterface::getName
virtual const char * getName()
Definition: recorderinterface.cpp:33
INDI::RecorderInterface::setSize
virtual bool setSize(uint16_t width, uint16_t height)=0
INDI::RecorderInterface::name
const char * name
Definition: recorderinterface.h:80
INDI::RecorderInterface::setPixelFormat
virtual bool setPixelFormat(INDI_PIXEL_FORMAT pixelFormat, uint8_t pixelDepth=8)=0
INDI::RecorderInterface::open
virtual bool open(const char *filename, char *errmsg)=0
indidevapi.h
Interface to the reference INDI C API device implementation on the Device Driver side.
INDI::RecorderInterface::getExtension
virtual const char * getExtension()=0
indibasetypes.h
INDI::RecorderInterface::close
virtual bool close()=0
INDI::RecorderInterface::m_FPS
float m_FPS
Definition: recorderinterface.h:81
INDI::RecorderInterface::writeFrame
virtual bool writeFrame(const uint8_t *frame, uint32_t nbytes)=0
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::RecorderInterface
The RecorderInterface class is the base class for recorders.
Definition: recorderinterface.h:56
INDI::RecorderInterface::RecorderInterface
RecorderInterface()=default
INDI_PIXEL_FORMAT
INDI_PIXEL_FORMAT
Definition: indibasetypes.h:63