webrtc-streamer 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +316 -240
  2. package/docs/api.md +11 -0
  3. package/html/admin.html +2 -2
  4. package/html/help.html +3 -3
  5. package/html/index.html +2 -2
  6. package/html/{janusvideoroom.json → janusconfig.js} +0 -0
  7. package/html/janustest.html +2 -2
  8. package/html/janusvideoroom.html +10 -21
  9. package/html/jitsiroom.html +1 -1
  10. package/html/jitsitest.html +2 -2
  11. package/html/libs/adapter.min.js +40 -6
  12. package/html/libs/blazeface +17 -0
  13. package/html/libs/lib-jitsi-meet.min.js +2 -25
  14. package/html/map.html +1 -1
  15. package/html/sendstream.html +17 -22
  16. package/html/tensorflow.js +45 -12
  17. package/html/webrtc-streamer-algo-element.js +1 -0
  18. package/html/webrtc-streamer-element.html +1 -0
  19. package/html/webrtc-streamer-element.js +23 -9
  20. package/html/webrtc-streamer-footer-element.js +1 -1
  21. package/html/{webrtcstreamer.json → webrtcconfig.js} +0 -0
  22. package/html/webrtcstreamer.html +1 -1
  23. package/html/webrtcstreamer.js +34 -40
  24. package/html/whipclient.html +76 -0
  25. package/html/{xmppvideoroom.json → xmppconfig.js} +0 -0
  26. package/html/xmppvideoroom.html +2 -2
  27. package/libv4l2cpp/README.md +6 -6
  28. package/libv4l2cpp/inc/V4l2Access.h +8 -9
  29. package/libv4l2cpp/inc/V4l2Capture.h +2 -2
  30. package/libv4l2cpp/inc/V4l2Device.h +20 -12
  31. package/libv4l2cpp/inc/V4l2MmapDevice.h +2 -2
  32. package/libv4l2cpp/inc/V4l2Output.h +4 -4
  33. package/libv4l2cpp/main.cpp +118 -0
  34. package/libv4l2cpp/src/V4l2Capture.cpp +4 -4
  35. package/libv4l2cpp/src/V4l2Device.cpp +7 -7
  36. package/libv4l2cpp/src/V4l2MmapDevice.cpp +2 -2
  37. package/libv4l2cpp/src/V4l2Output.cpp +6 -6
  38. package/package.json +1 -1
@@ -28,16 +28,22 @@
28
28
  #define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C')
29
29
  #endif
30
30
 
31
+ enum V4l2IoType
32
+ {
33
+ IOTYPE_READWRITE,
34
+ IOTYPE_MMAP
35
+ };
36
+
31
37
  // ---------------------------------
32
38
  // V4L2 Device parameters
33
39
  // ---------------------------------
34
40
  struct V4L2DeviceParameters
35
41
  {
36
- V4L2DeviceParameters(const char* devname, const std::list<unsigned int> & formatList, unsigned int width, unsigned int height, int fps, int verbose = 0, int openFlags = O_RDWR | O_NONBLOCK) :
37
- m_devName(devname), m_formatList(formatList), m_width(width), m_height(height), m_fps(fps), m_verbose(verbose), m_openFlags(openFlags) {}
42
+ V4L2DeviceParameters(const char* devname, const std::list<unsigned int> & formatList, unsigned int width, unsigned int height, int fps, V4l2IoType ioType = IOTYPE_MMAP, int verbose = 0, int openFlags = O_RDWR | O_NONBLOCK) :
43
+ m_devName(devname), m_formatList(formatList), m_width(width), m_height(height), m_fps(fps), m_iotype(ioType), m_verbose(verbose), m_openFlags(openFlags) {}
38
44
 
39
- V4L2DeviceParameters(const char* devname, unsigned int format, unsigned int width, unsigned int height, int fps, int verbose = 0, int openFlags = O_RDWR | O_NONBLOCK) :
40
- m_devName(devname), m_width(width), m_height(height), m_fps(fps), m_verbose(verbose), m_openFlags(openFlags) {
45
+ V4L2DeviceParameters(const char* devname, unsigned int format, unsigned int width, unsigned int height, int fps, V4l2IoType ioType = IOTYPE_MMAP, int verbose = 0, int openFlags = O_RDWR | O_NONBLOCK) :
46
+ m_devName(devname), m_width(width), m_height(height), m_fps(fps), m_iotype(ioType), m_verbose(verbose), m_openFlags(openFlags) {
41
47
  if (format) {
42
48
  m_formatList.push_back(format);
43
49
  }
@@ -48,6 +54,7 @@ struct V4L2DeviceParameters
48
54
  unsigned int m_width;
49
55
  unsigned int m_height;
50
56
  int m_fps;
57
+ V4l2IoType m_iotype;
51
58
  int m_verbose;
52
59
  int m_openFlags;
53
60
  };
@@ -69,12 +76,12 @@ class V4l2Device
69
76
  int configureFormat(int fd, unsigned int format, unsigned int width, unsigned int height);
70
77
  int configureParam(int fd, int fps);
71
78
 
72
- virtual bool init(unsigned int mandatoryCapabilities);
73
- virtual size_t writeInternal(char*, size_t) { return -1; }
74
- virtual bool startPartialWrite(void) { return false; }
75
- virtual size_t writePartialInternal(char*, size_t) { return -1; }
76
- virtual bool endPartialWrite(void) { return false; }
77
- virtual size_t readInternal(char*, size_t) { return -1; }
79
+ virtual bool init(unsigned int mandatoryCapabilities);
80
+ virtual size_t writeInternal(char*, size_t) { return -1; }
81
+ virtual bool startPartialWrite() { return false; }
82
+ virtual size_t writePartialInternal(char*, size_t) { return -1; }
83
+ virtual bool endPartialWrite() { return false; }
84
+ virtual size_t readInternal(char*, size_t) { return -1; }
78
85
 
79
86
  public:
80
87
  V4l2Device(const V4L2DeviceParameters& params, v4l2_buf_type deviceType);
@@ -88,8 +95,9 @@ class V4l2Device
88
95
  unsigned int getFormat() { return m_format; }
89
96
  unsigned int getWidth() { return m_width; }
90
97
  unsigned int getHeight() { return m_height; }
91
- int getFd() { return m_fd; }
92
- void queryFormat();
98
+ int getFd() { return m_fd; }
99
+ void queryFormat();
100
+
93
101
  int setFormat(unsigned int format, unsigned int width, unsigned int height) {
94
102
  return this->configureFormat(m_fd, format, width, height);
95
103
  }
@@ -21,9 +21,9 @@ class V4l2MmapDevice : public V4l2Device
21
21
  {
22
22
  protected:
23
23
  size_t writeInternal(char* buffer, size_t bufferSize);
24
- bool startPartialWrite(void);
24
+ bool startPartialWrite();
25
25
  size_t writePartialInternal(char*, size_t);
26
- bool endPartialWrite(void);
26
+ bool endPartialWrite();
27
27
  size_t readInternal(char* buffer, size_t bufferSize);
28
28
 
29
29
  public:
@@ -24,14 +24,14 @@ class V4l2Output : public V4l2Access
24
24
  V4l2Output(V4l2Device* device);
25
25
 
26
26
  public:
27
- static V4l2Output* create(const V4L2DeviceParameters & param, IoType iotype = V4l2Access::IOTYPE_MMAP);
27
+ static V4l2Output* create(const V4L2DeviceParameters & param);
28
28
  virtual ~V4l2Output();
29
29
 
30
30
  size_t write(char* buffer, size_t bufferSize);
31
- int isWritable(timeval* tv);
32
- bool startPartialWrite(void);
31
+ bool isWritable(timeval* tv);
32
+ bool startPartialWrite();
33
33
  size_t writePartial(char* buffer, size_t bufferSize);
34
- bool endPartialWrite(void);
34
+ bool endPartialWrite();
35
35
  };
36
36
 
37
37
  #endif
@@ -0,0 +1,118 @@
1
+ /* ---------------------------------------------------------------------------
2
+ ** This software is in the public domain, furnished "as is", without technical
3
+ ** support, and with no warranty, express or implied, as to its usefulness for
4
+ ** any purpose.
5
+ **
6
+ ** main.cpp
7
+ **
8
+ ** test V4L2 capture device
9
+ **
10
+ ** -------------------------------------------------------------------------*/
11
+
12
+ #include <unistd.h>
13
+ #include <string.h>
14
+ #include <errno.h>
15
+ #include <signal.h>
16
+
17
+ #include "logger.h"
18
+ #include "V4l2Capture.h"
19
+
20
+ int stop=0;
21
+
22
+ /* ---------------------------------------------------------------------------
23
+ ** SIGINT handler
24
+ ** -------------------------------------------------------------------------*/
25
+ void sighandler(int)
26
+ {
27
+ printf("SIGINT\n");
28
+ stop =1;
29
+ }
30
+
31
+ /* ---------------------------------------------------------------------------
32
+ ** main
33
+ ** -------------------------------------------------------------------------*/
34
+ int main(int argc, char* argv[])
35
+ {
36
+ int verbose = 0;
37
+ const char *in_devname = "/dev/video0";
38
+ V4l2IoType ioTypeIn = IOTYPE_MMAP;
39
+ int format = 0;
40
+ int width = 0;
41
+ int height = 0;
42
+ int fps = 0;
43
+
44
+ int c = 0;
45
+ while ((c = getopt (argc, argv, "hv:" "G:f:r")) != -1)
46
+ {
47
+ switch (c)
48
+ {
49
+ case 'v': verbose = 1; if (optarg && *optarg=='v') verbose++; break;
50
+ case 'r': ioTypeIn = IOTYPE_READWRITE ; break;
51
+ case 'G': sscanf(optarg,"%dx%dx%d", &width, &height, &fps) ; break;
52
+ case 'f': format = V4l2Device::fourcc(optarg) ; break;
53
+ case 'h':
54
+ {
55
+ std::cout << argv[0] << " [-v[v]] [-G <width>x<height>x<fps>] [-f format] [device] [-r]" << std::endl;
56
+ std::cout << "\t -v : verbose " << std::endl;
57
+ std::cout << "\t -vv : very verbose " << std::endl;
58
+ std::cout << "\t -r : V4L2 capture using read interface (default use memory mapped buffers)" << std::endl;
59
+ std::cout << "\t device : V4L2 capture device (default "<< in_devname << ")" << std::endl;
60
+ exit(0);
61
+ }
62
+ }
63
+ }
64
+ if (optind<argc)
65
+ {
66
+ in_devname = argv[optind];
67
+ optind++;
68
+ }
69
+
70
+ // initialize log4cpp
71
+ initLogger(verbose);
72
+
73
+ // init V4L2 capture interface
74
+ V4L2DeviceParameters param(in_devname, format, width, height, fps, ioTypeIn, verbose);
75
+ V4l2Capture* videoCapture = V4l2Capture::create(param);
76
+
77
+ if (videoCapture == NULL)
78
+ {
79
+ LOG(WARN) << "Cannot reading from V4L2 capture interface for device:" << in_devname;
80
+ }
81
+ else
82
+ {
83
+ timeval tv;
84
+
85
+ LOG(NOTICE) << "Start reading from " << in_devname;
86
+ signal(SIGINT,sighandler);
87
+ while (!stop)
88
+ {
89
+ tv.tv_sec=1;
90
+ tv.tv_usec=0;
91
+ int ret = videoCapture->isReadable(&tv);
92
+ if (ret == 1)
93
+ {
94
+ char buffer[videoCapture->getBufferSize()];
95
+ int rsize = videoCapture->read(buffer, sizeof(buffer));
96
+ if (rsize == -1)
97
+ {
98
+ LOG(NOTICE) << "stop " << strerror(errno);
99
+ stop=1;
100
+ }
101
+ else
102
+ {
103
+ LOG(NOTICE) << "size:" << rsize;
104
+ }
105
+ }
106
+ else if (ret == -1)
107
+ {
108
+ LOG(NOTICE) << "stop " << strerror(errno);
109
+ stop=1;
110
+ }
111
+ }
112
+
113
+
114
+ delete videoCapture;
115
+ }
116
+
117
+ return 0;
118
+ }
@@ -23,12 +23,12 @@
23
23
  // -----------------------------------------
24
24
  // create video capture interface
25
25
  // -----------------------------------------
26
- V4l2Capture* V4l2Capture::create(const V4L2DeviceParameters & param, IoType iotype)
26
+ V4l2Capture* V4l2Capture::create(const V4L2DeviceParameters & param)
27
27
  {
28
28
  V4l2Capture* videoCapture = NULL;
29
29
  V4l2Device* videoDevice = NULL;
30
30
  int caps = V4L2_CAP_VIDEO_CAPTURE;
31
- switch (iotype)
31
+ switch (param.m_iotype)
32
32
  {
33
33
  case IOTYPE_MMAP:
34
34
  videoDevice = new V4l2MmapDevice(param, V4L2_BUF_TYPE_VIDEO_CAPTURE);
@@ -70,13 +70,13 @@ V4l2Capture::~V4l2Capture()
70
70
  // -----------------------------------------
71
71
  // check readability
72
72
  // -----------------------------------------
73
- int V4l2Capture::isReadable(timeval* tv)
73
+ bool V4l2Capture::isReadable(timeval* tv)
74
74
  {
75
75
  int fd = m_device->getFd();
76
76
  fd_set fdset;
77
77
  FD_ZERO(&fdset);
78
78
  FD_SET(fd, &fdset);
79
- return select(fd+1, &fdset, NULL, NULL, tv);
79
+ return (select(fd+1, &fdset, NULL, NULL, tv) == 1);
80
80
  }
81
81
 
82
82
  // -----------------------------------------
@@ -75,9 +75,9 @@ void V4l2Device::queryFormat()
75
75
  // intialize the V4L2 connection
76
76
  bool V4l2Device::init(unsigned int mandatoryCapabilities)
77
77
  {
78
- struct stat sb;
79
- if ( (stat(m_params.m_devName.c_str(), &sb)==0) && ((sb.st_mode & S_IFMT) == S_IFCHR) )
80
- {
78
+ struct stat sb;
79
+ if ( (stat(m_params.m_devName.c_str(), &sb)==0) && ((sb.st_mode & S_IFMT) == S_IFCHR) )
80
+ {
81
81
  if (initdevice(m_params.m_devName.c_str(), mandatoryCapabilities) == -1)
82
82
  {
83
83
  LOG(ERROR) << "Cannot init device:" << m_params.m_devName;
@@ -85,8 +85,8 @@ bool V4l2Device::init(unsigned int mandatoryCapabilities)
85
85
  }
86
86
  else
87
87
  {
88
- // open a normal file
89
- m_fd = open(m_params.m_devName.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
88
+ // open a normal file
89
+ m_fd = open(m_params.m_devName.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
90
90
  }
91
91
  return (m_fd!=-1);
92
92
  }
@@ -187,8 +187,8 @@ int V4l2Device::configureFormat(int fd, unsigned int format, unsigned int width,
187
187
  struct v4l2_format fmt;
188
188
  memset(&(fmt), 0, sizeof(fmt));
189
189
  fmt.type = m_deviceType;
190
- if (ioctl(m_fd,VIDIOC_G_FMT,&fmt) == -1)
191
- {
190
+ if (ioctl(m_fd,VIDIOC_G_FMT,&fmt) == -1)
191
+ {
192
192
  LOG(ERROR) << m_params.m_devName << ": Cannot get format " << strerror(errno);
193
193
  return -1;
194
194
  }
@@ -245,7 +245,7 @@ size_t V4l2MmapDevice::writeInternal(char* buffer, size_t bufferSize)
245
245
  return size;
246
246
  }
247
247
 
248
- bool V4l2MmapDevice::startPartialWrite(void)
248
+ bool V4l2MmapDevice::startPartialWrite()
249
249
  {
250
250
  if (n_buffers <= 0)
251
251
  return false;
@@ -287,7 +287,7 @@ size_t V4l2MmapDevice::writePartialInternal(char* buffer, size_t bufferSize)
287
287
  return size;
288
288
  }
289
289
 
290
- bool V4l2MmapDevice::endPartialWrite(void)
290
+ bool V4l2MmapDevice::endPartialWrite()
291
291
  {
292
292
  if (!m_partialWriteInProgress)
293
293
  return false;
@@ -24,12 +24,12 @@
24
24
  // -----------------------------------------
25
25
  // create video output interface
26
26
  // -----------------------------------------
27
- V4l2Output* V4l2Output::create(const V4L2DeviceParameters & param, IoType iotype)
27
+ V4l2Output* V4l2Output::create(const V4L2DeviceParameters & param)
28
28
  {
29
29
  V4l2Output* videoOutput = NULL;
30
30
  V4l2Device* videoDevice = NULL;
31
31
  int caps = V4L2_CAP_VIDEO_OUTPUT;
32
- switch (iotype)
32
+ switch (param.m_iotype)
33
33
  {
34
34
  case IOTYPE_MMAP:
35
35
  videoDevice = new V4l2MmapDevice(param, V4L2_BUF_TYPE_VIDEO_OUTPUT);
@@ -71,13 +71,13 @@ V4l2Output::~V4l2Output()
71
71
  // -----------------------------------------
72
72
  // check writability
73
73
  // -----------------------------------------
74
- int V4l2Output::isWritable(timeval* tv)
74
+ bool V4l2Output::isWritable(timeval* tv)
75
75
  {
76
76
  int fd = m_device->getFd();
77
77
  fd_set fdset;
78
78
  FD_ZERO(&fdset);
79
79
  FD_SET(fd, &fdset);
80
- return select(fd+1, NULL, &fdset, NULL, tv);
80
+ return (select(fd+1, NULL, &fdset, NULL, tv) == 1);
81
81
  }
82
82
 
83
83
  // -----------------------------------------
@@ -89,7 +89,7 @@ size_t V4l2Output::write(char* buffer, size_t bufferSize)
89
89
  }
90
90
 
91
91
 
92
- bool V4l2Output::startPartialWrite(void)
92
+ bool V4l2Output::startPartialWrite()
93
93
  {
94
94
  return m_device->startPartialWrite();
95
95
  }
@@ -99,7 +99,7 @@ size_t V4l2Output::writePartial(char* buffer, size_t bufferSize)
99
99
  return m_device->writePartialInternal(buffer, bufferSize);
100
100
  }
101
101
 
102
- bool V4l2Output::endPartialWrite(void)
102
+ bool V4l2Output::endPartialWrite()
103
103
  {
104
104
  return m_device->endPartialWrite();
105
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webrtc-streamer",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "",
5
5
  "main": "joinjanusvideoroom.js",
6
6
  "dependencies": {