Panda3D
webcamVideoCursorV4L.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file webcamVideoCursorV4L.h
10  * @author rdb
11  * @date 2010-06-11
12  */
13 
14 #ifndef WEBCAMVIDEOCURSORV4L_H
15 #define WEBCAMVIDEOCURSORV4L_H
16 
17 #include "pandabase.h"
18 
19 #if defined(HAVE_VIDEO4LINUX) && !defined(CPPPARSER)
20 
21 #include "webcamVideo.h"
22 #include "movieVideoCursor.h"
23 
24 #include <linux/videodev2.h>
25 
26 #ifdef HAVE_JPEG
27 // jconfig.h overrides our INLINE definition.
28 #ifdef __GNUC__
29 #pragma push_macro("INLINE")
30 #endif
31 
32 extern "C" {
33  #include <jpeglib.h>
34 }
35 
36 #ifdef __GNUC__
37 #pragma pop_macro("INLINE")
38 #endif
39 #endif
40 
41 class WebcamVideoV4L;
42 
43 /**
44  * The Video4Linux implementation of webcams.
45  */
46 class WebcamVideoCursorV4L : public MovieVideoCursor {
47 public:
48  WebcamVideoCursorV4L(WebcamVideoV4L *src);
49  virtual ~WebcamVideoCursorV4L();
50  virtual PT(Buffer) fetch_buffer();
51 
52 private:
53  int _fd;
54  void **_buffers;
55  size_t *_buflens;
56  size_t _bufcount;
57  struct v4l2_format _format;
58 #ifdef HAVE_JPEG
59  struct jpeg_decompress_struct _cinfo;
60 #endif
61 
62 public:
63  static TypeHandle get_class_type() {
64  return _type_handle;
65  }
66  static void init_type() {
67  MovieVideoCursor::init_type();
68  register_type(_type_handle, "WebcamVideoCursorV4L",
69  MovieVideoCursor::get_class_type());
70  }
71  virtual TypeHandle get_type() const {
72  return get_class_type();
73  }
74  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
75 
76 private:
77  static TypeHandle _type_handle;
78 };
79 
80 #endif // HAVE_VIDEO4LINUX
81 
82 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Definition: buffer.h:24
A MovieVideo is actually any source that provides a sequence of video frames.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81