Instrument Neutral Distributed Interface INDI  2.0.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)
70  {
71  m_FPS = FPS;
72  return true;
73  }
74  virtual bool open(const char *filename, char *errmsg) = 0;
75  virtual bool close() = 0;
76  // when frame is in known encoding format
77  virtual bool writeFrame(const uint8_t *frame, uint32_t nbytes, uint64_t timestamp) = 0;
78  // If streaming is enabled, then any subframing is already done by the stream recorder
79  // and no need to do any further subframing operations. Otherwise, subframing must be done.
80  // This is to reduce process time and save memory for a dedicated subframe buffer
81  virtual void setStreamEnabled(bool enable) = 0;
82 
83  protected:
84  const char *name;
85  float m_FPS = 1;
86 };
87 
88 }
The RecorderInterface class is the base class for recorders.
virtual bool writeFrame(const uint8_t *frame, uint32_t nbytes, uint64_t timestamp)=0
virtual const char * getName()
virtual bool setSize(uint16_t width, uint16_t height)=0
virtual ~RecorderInterface()=default
virtual bool open(const char *filename, char *errmsg)=0
virtual bool close()=0
virtual const char * getExtension()=0
virtual bool setPixelFormat(INDI_PIXEL_FORMAT pixelFormat, uint8_t pixelDepth=8)=0
virtual bool setFPS(float FPS)
virtual void setStreamEnabled(bool enable)=0
INDI_PIXEL_FORMAT
Definition: indibasetypes.h:70
Interface to the reference INDI C API device implementation on the Device Driver side.
Namespace to encapsulate INDI client, drivers, and mediator classes.