Skip to content

Commit 1121f83

Browse files
committed
Video out code defined in terms of abstract class
1 parent ea5205e commit 1121f83

File tree

7 files changed

+24
-13
lines changed

7 files changed

+24
-13
lines changed

base.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ class FrameMetaData
4444

4545
};
4646

47-
// **********************************************************************
48-
4947
class Base_Video_In
5048
{
5149
public:
50+
Base_Video_In() {};
51+
virtual ~Base_Video_In() {};
5252
virtual void Stop() {};
5353
virtual void WaitForStop() {};
5454
virtual void OpenDevice() {};
@@ -59,5 +59,15 @@ class Base_Video_In
5959
virtual int GetFrame(unsigned char **buffOut, class FrameMetaData *metaOut) {return 0;};
6060
};
6161

62+
// **********************************************************************
63+
64+
class Base_Video_Out
65+
{
66+
public:
67+
virtual void SendFrame(const char *imgIn, unsigned imgLen, const char *pxFmt, int width, int height) {};
68+
virtual void Stop() {};
69+
virtual int WaitForStop() {return 1;};
70+
};
71+
6272
#endif //BASE_H
6373

libvideolive.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ static PyObject *Device_manager_open(Device_manager *self, PyObject *args)
128128
Py_RETURN_NONE;
129129
}
130130

131-
132131
static PyObject *Device_manager_set_format(Device_manager *self, PyObject *args)
133132
{
134133
int size_x;

v4l2capture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int my_ioctl(int fd, int request, void *arg, int utimeout = -1)
8484

8585
// **************************************************************************
8686

87-
Video_in_Manager::Video_in_Manager(const char *devNameIn)
87+
Video_in_Manager::Video_in_Manager(const char *devNameIn) : Base_Video_In()
8888
{
8989
stop = 0;
9090
stopped = 1;

v4l2out.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ void print_format(struct v4l2_format*vid_format) {
3434
printf(" vid_format->fmt.pix.colorspace =%d\n", vid_format->fmt.pix.colorspace );
3535
}
3636

37-
//*******************************************************************
38-
3937
class SendFrameArgs
4038
{
4139
public:
@@ -66,7 +64,9 @@ class SendFrameArgs
6664
}
6765
};
6866

69-
Video_out::Video_out(const char *devNameIn)
67+
//*******************************************************************
68+
69+
Video_out::Video_out(const char *devNameIn) : Base_Video_Out()
7070
{
7171
this->fdwr = 0;
7272
framesize = 0;

v4l2out.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
#include <map>
55
#include <vector>
66
#include <string>
7+
#include "base.h"
78

8-
class Video_out
9+
class Video_out : public Base_Video_Out
910
{
1011
public:
1112
std::string devName;

videoout.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
int Video_out_manager_init(Video_out_manager *self, PyObject *args,
66
PyObject *kwargs)
77
{
8-
self->threads = new std::map<std::string, class Video_out *>;
8+
self->threads = new std::map<std::string, class Base_Video_Out *>;
99
return 0;
1010
}
1111

1212
void Video_out_manager_dealloc(Video_out_manager *self)
1313
{
1414
//Stop high level threads
15-
for(std::map<std::string, class Video_out *>::iterator it = self->threads->begin();
15+
for(std::map<std::string, class Base_Video_Out *>::iterator it = self->threads->begin();
1616
it != self->threads->end(); it++)
1717
{
1818
it->second->Stop();
@@ -85,7 +85,7 @@ PyObject *Video_out_manager_Send_frame(Video_out_manager *self, PyObject *args)
8585
PyObject *pyHeight = PyTuple_GetItem(args, 4);
8686
heightIn = PyInt_AsLong(pyHeight);
8787

88-
std::map<std::string, class Video_out *>::iterator it = self->threads->find(devarg);
88+
std::map<std::string, class Base_Video_Out *>::iterator it = self->threads->find(devarg);
8989

9090
if(it != self->threads->end())
9191
{
@@ -111,7 +111,7 @@ PyObject *Video_out_manager_close(Video_out_manager *self, PyObject *args)
111111
}
112112

113113
//Stop worker thread
114-
std::map<std::string, class Video_out *>::iterator it = self->threads->find(devarg);
114+
std::map<std::string, class Base_Video_Out *>::iterator it = self->threads->find(devarg);
115115

116116
if(it != self->threads->end())
117117
{

videoout.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
#include <Python.h>
66
#include <map>
77
#include <string>
8+
#include "base.h"
89

910
class Video_out_manager_cl{
1011
public:
1112
PyObject_HEAD
12-
std::map<std::string, class Video_out *> *threads;
13+
std::map<std::string, class Base_Video_Out *> *threads;
1314
};
1415
typedef Video_out_manager_cl Video_out_manager;
1516

0 commit comments

Comments
 (0)