Skip to content

Commit b827a41

Browse files
committed
Merge branch 'ros1' into ros_compressed_dynamic
2 parents 0c44d51 + d6eaa8f commit b827a41

File tree

13 files changed

+107
-56
lines changed

13 files changed

+107
-56
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- ros1*
8+
pull_request:
9+
branches:
10+
- ros1*
11+
12+
jobs:
13+
industrial_ci:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
ROS_DISTRO: [noetic]
19+
ROS_REPO: [testing, main]
20+
env:
21+
ROS_DISTRO: ${{ matrix.ROS_DISTRO }}
22+
ROS_REPO: ${{ matrix.ROS_REPO }}
23+
steps:
24+
- name: Checkout repo
25+
uses: actions/checkout@v4
26+
- name: Source tests
27+
uses: "ros-industrial/industrial_ci@master"

.travis.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
Changelog for package web_video_server
33
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5+
0.2.2 (2021-07-23)
6+
------------------
7+
* fix vp9 and h264, support for opencv4 and ffmpeg 4 (`#103 <https://github.com/RobotWebTools/web_video_server/issues/103>`_)
8+
* add a mention of mjpegcanvasjs in the readme (`#100 <https://github.com/RobotWebTools/web_video_server/issues/100>`_)
9+
* fix multipart_stream.cpp HttpHeader values in order to solve DOMException(cross origin) CORS issue (`#92 <https://github.com/RobotWebTools/web_video_server/issues/92>`_)
10+
* Contributors: Gady, okapi1125, randoms
11+
512
0.2.1 (2019-06-05)
613
------------------
714
* Restream buffered frames with minimum publish rate (`#88 <https://github.com/RobotWebTools/web_video_server/issues/88>`_)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ This node combines the capabilities of [ros_web_video](https://github.com/RobotW
77
For full documentation, see [the ROS wiki](http://ros.org/wiki/web_video_server).
88

99
[Doxygen](http://docs.ros.org/indigo/api/web_video_server/html/) files can be found on the ROS wiki.
10+
[mjpegcanvasjs](https://github.com/rctoris/mjpegcanvasjs) can be used to display a MJPEG stream from the ROS web_video_server
1011

11-
This project is released as part of the [Robot Web Tools](http://robotwebtools.org/) effort.
12+
This project is released as part of the [Robot Web Tools](https://robotwebtools.github.io/) effort.
1213

1314
### License
1415
web_video_server is released with a BSD license. For full terms and conditions, see the [LICENSE](LICENSE) file.

include/web_video_server/jpeg_streamers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define JPEG_STREAMERS_H_
33

44
#include <image_transport/image_transport.h>
5+
#include <opencv2/imgcodecs.hpp>
56
#include "web_video_server/image_streamer.h"
67
#include "async_web_server_cpp/http_request.hpp"
78
#include "async_web_server_cpp/http_connection.hpp"

include/web_video_server/png_streamers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define PNG_STREAMERS_H_
33

44
#include <image_transport/image_transport.h>
5+
#include <opencv2/imgcodecs.hpp>
56
#include "web_video_server/image_streamer.h"
67
#include "async_web_server_cpp/http_request.hpp"
78
#include "async_web_server_cpp/http_connection.hpp"

package.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<?xml version="1.0"?>
2-
<package format="2">
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
34
<name>web_video_server</name>
4-
<version>0.2.1</version>
5+
<version>0.2.2</version>
56
<description>HTTP Streaming of ROS Image Topics in Multiple Formats</description>
67

7-
<maintainer email="[email protected]">Russell Toris</maintainer>
8-
<author email="[email protected]">Mitchell Wills</author>
8+
<maintainer email="[email protected]">Błażej Sowa</maintainer>
99

1010
<license>BSD</license>
1111

1212
<url type="website">http://ros.org/wiki/web_video_server</url>
1313
<url type="bugtracker">https://github.com/RobotWebTools/web_video_server/issues</url>
1414
<url type="repository">https://github.com/RobotWebTools/web_video_server</url>
1515

16+
<author email="[email protected]">Mitchell Wills</author>
17+
1618
<buildtool_depend>catkin</buildtool_depend>
1719

1820
<build_depend>roscpp</build_depend>

src/image_streamer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ void ImageTransportImageStreamer::imageCallback(const sensor_msgs::ImageConstPtr
144144
}
145145

146146
last_frame = ros::Time::now();
147-
sendImage(output_size_image, last_frame );
148-
147+
sendImage(output_size_image, msg->header.stamp);
149148
}
150149
catch (cv_bridge::Exception &e)
151150
{

src/jpeg_streamers.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ MjpegStreamer::~MjpegStreamer()
2121
void MjpegStreamer::sendImage(const cv::Mat &img, const ros::Time &time)
2222
{
2323
std::vector<int> encode_params;
24+
#if CV_VERSION_MAJOR >= 3
25+
encode_params.push_back(cv::IMWRITE_JPEG_QUALITY);
26+
#else
2427
encode_params.push_back(CV_IMWRITE_JPEG_QUALITY);
28+
#endif
2529
encode_params.push_back(quality_);
2630

2731
std::vector<uchar> encoded_buffer;
@@ -63,7 +67,11 @@ JpegSnapshotStreamer::~JpegSnapshotStreamer()
6367
void JpegSnapshotStreamer::sendImage(const cv::Mat &img, const ros::Time &time)
6468
{
6569
std::vector<int> encode_params;
70+
#if CV_VERSION_MAJOR >= 3
71+
encode_params.push_back(cv::IMWRITE_JPEG_QUALITY);
72+
#else
6673
encode_params.push_back(CV_IMWRITE_JPEG_QUALITY);
74+
#endif
6775
encode_params.push_back(quality_);
6876

6977
std::vector<uchar> encoded_buffer;

src/libav_streamer.cpp

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,24 @@ LibavStreamer::LibavStreamer(const async_web_server_cpp::HttpRequest &request,
6060
bitrate_ = request.get_query_param_value_or_default<int>("bitrate", 100000);
6161
qmin_ = request.get_query_param_value_or_default<int>("qmin", 10);
6262
qmax_ = request.get_query_param_value_or_default<int>("qmax", 42);
63-
gop_ = request.get_query_param_value_or_default<int>("gop", 250);
63+
gop_ = request.get_query_param_value_or_default<int>("gop", 25);
6464

65+
#if ( LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,9,100) )
6566
av_lockmgr_register(&ffmpeg_boost_mutex_lock_manager);
6667
av_register_all();
68+
#endif
6769
}
6870

6971
LibavStreamer::~LibavStreamer()
7072
{
7173
if (codec_context_)
74+
{
75+
#if ( LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,9,100) )
7276
avcodec_close(codec_context_);
77+
#else
78+
avcodec_free_context(&codec_context_);
79+
#endif
80+
}
7381
if (frame_)
7482
{
7583
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,28,1)
@@ -134,6 +142,7 @@ void LibavStreamer::initialize(const cv::Mat &img)
134142
}
135143
io_ctx->seekable = 0; // no seeking, it's a stream
136144
format_context_->pb = io_ctx;
145+
format_context_->max_interleave_delta = 0;
137146
output_format_->flags |= AVFMT_FLAG_CUSTOM_IO;
138147
output_format_->flags |= AVFMT_NOFILE;
139148

@@ -157,7 +166,11 @@ void LibavStreamer::initialize(const cv::Mat &img)
157166
NULL, NULL);
158167
throw std::runtime_error("Error creating video stream");
159168
}
169+
#if ( LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,9,100) )
160170
codec_context_ = video_stream_->codec;
171+
#else
172+
codec_context_ = avcodec_alloc_context3(codec_);
173+
#endif
161174

162175
// Set options
163176
avcodec_get_context_defaults3(codec_context_, codec_);
@@ -182,11 +195,14 @@ void LibavStreamer::initialize(const cv::Mat &img)
182195
codec_context_->qmin = qmin_;
183196
codec_context_->qmax = qmax_;
184197

198+
#if ( LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,9,100) )
199+
avcodec_parameters_from_context(video_stream_->codecpar, codec_context_);
200+
#endif
201+
185202
initializeEncoder();
186203

187-
// Some formats want stream headers to be separate
188-
if (format_context_->oformat->flags & AVFMT_GLOBALHEADER)
189-
codec_context_->flags |= CODEC_FLAG_GLOBAL_HEADER;
204+
codec_context_->flags |= AV_CODEC_FLAG_LOW_DELAY;
205+
codec_context_->max_b_frames = 0;
190206

191207
// Open Codec
192208
if (avcodec_open2(codec_context_, codec_, NULL) < 0)
@@ -306,15 +322,29 @@ void LibavStreamer::sendImage(const cv::Mat &img, const ros::Time &time)
306322
throw std::runtime_error("Error encoding video frame");
307323
}
308324
#else
309-
pkt.data = NULL; // packet data will be allocated by the encoder
310-
pkt.size = 0;
311-
if (avcodec_send_frame(codec_context_, frame_) < 0)
325+
ret = avcodec_send_frame(codec_context_, frame_);
326+
if (ret == AVERROR_EOF)
327+
{
328+
ROS_DEBUG_STREAM("avcodec_send_frame() encoder flushed");
329+
}
330+
else if (ret == AVERROR(EAGAIN))
331+
{
332+
ROS_DEBUG_STREAM("avcodec_send_frame() need output read out");
333+
}
334+
if (ret < 0)
312335
{
313336
throw std::runtime_error("Error encoding video frame");
314337
}
315-
if (avcodec_receive_packet(codec_context_, &pkt) < 0)
338+
ret = avcodec_receive_packet(codec_context_, &pkt);
339+
got_packet = pkt.size > 0;
340+
if (ret == AVERROR_EOF)
341+
{
342+
ROS_DEBUG_STREAM("avcodec_recieve_packet() encoder flushed");
343+
}
344+
else if (ret == AVERROR(EAGAIN))
316345
{
317-
throw std::runtime_error("Error retrieving encoded packet");
346+
ROS_DEBUG_STREAM("avcodec_recieve_packet() need more input");
347+
got_packet = 0;
318348
}
319349
#endif
320350

0 commit comments

Comments
 (0)