Skip to content

Commit b5af486

Browse files
Merge pull request #261 from wep21/add-some-image-transport
feat: add some image transport for linux and osx
2 parents cba02f1 + ed270a0 commit b5af486

File tree

5 files changed

+70
-0
lines changed

5 files changed

+70
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
diff --git a/src/decoder.cpp b/src/decoder.cpp
2+
index 0a12d25..10834e3 100644
3+
--- a/src/decoder.cpp
4+
+++ b/src/decoder.cpp
5+
@@ -38,7 +38,11 @@ Decoder::~Decoder() { reset(); }
6+
void Decoder::reset()
7+
{
8+
if (codecContext_) {
9+
+#if LIBAVFORMAT_VERSION_MAJOR < 59
10+
avcodec_close(codecContext_);
11+
+#else
12+
+ avcodec_free_context(&codecContext_);
13+
+#endif
14+
av_free(codecContext_);
15+
codecContext_ = NULL;
16+
}
17+
diff --git a/src/encoder.cpp b/src/encoder.cpp
18+
index a4b6de6..2e1d4a2 100644
19+
--- a/src/encoder.cpp
20+
+++ b/src/encoder.cpp
21+
@@ -54,7 +54,11 @@ static void free_frame(AVFrame ** frame)
22+
void Encoder::closeCodec()
23+
{
24+
if (codecContext_) {
25+
+#if LIBAVFORMAT_VERSION_MAJOR < 59
26+
avcodec_close(codecContext_);
27+
+#else
28+
+ avcodec_free_context(&codecContext_);
29+
+#endif
30+
codecContext_ = nullptr;
31+
}
32+
free_frame(&frame_);
33+
diff --git a/src/utils.cpp b/src/utils.cpp
34+
index da089e4..01e8eea 100644
35+
--- a/src/utils.cpp
36+
+++ b/src/utils.cpp
37+
@@ -104,8 +104,15 @@ enum AVPixelFormat get_preferred_pixel_format(
38+
std::vector<enum AVPixelFormat> get_encoder_formats(const AVCodec * c)
39+
{
40+
std::vector<enum AVPixelFormat> formats;
41+
- if (c && c->pix_fmts) {
42+
- for (const auto * p = c->pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
43+
+#if LIBAVUTIL_VERSION_MAJOR > 59 || (LIBAVUTIL_VERSION_MAJOR == 59 && LIBAVUTIL_VERSION_MINOR >= 39)
44+
+ const enum AVPixelFormat *pix_fmts = NULL;
45+
+ avcodec_get_supported_config(NULL, c, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void **) &pix_fmts, NULL);
46+
+ if (c && pix_fmts) {
47+
+#else
48+
+ const enum AVPixelFormat *pix_fmts = c->pix_fmts;
49+
+ if (c && pix_fmts) {
50+
+#endif
51+
+ for (const auto * p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
52+
formats.push_back(*p);
53+
}
54+
}

vinca_linux_64.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ packages_select_by_deps:
189189

190190
- open3d_conversions
191191

192+
- ffmpeg_image_transport
193+
194+
- foxglove_compressed_image_transport
195+
192196
# ----- end of package support -----
193197

194198
# - rtabmap

vinca_linux_aarch64.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ packages_select_by_deps:
118118

119119
- open3d_conversions
120120

121+
- ffmpeg_image_transport
122+
123+
- foxglove_compressed_image_transport
124+
121125
# Used to work, now needs fixes
122126
# - rtabmap
123127
# - webots-ros2

vinca_osx.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,9 @@ packages_select_by_deps:
135135

136136
- open3d_conversions
137137

138+
- ffmpeg_image_transport
139+
140+
- foxglove_compressed_image_transport
141+
138142
patch_dir: patch
139143
rosdistro_snapshot: rosdistro_snapshot.yaml

vinca_osx_arm64.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,9 @@ packages_select_by_deps:
125125

126126
- open3d_conversions
127127

128+
- ffmpeg_image_transport
129+
130+
- foxglove_compressed_image_transport
131+
128132
patch_dir: patch
129133
rosdistro_snapshot: rosdistro_snapshot.yaml

0 commit comments

Comments
 (0)