Skip to content

Commit 9c25f94

Browse files
committed
initial commit
0 parents  commit 9c25f94

File tree

19 files changed

+1936
-0
lines changed

19 files changed

+1936
-0
lines changed

.clang-format

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
5+
AccessModifierOffset: -2
6+
AlignAfterOpenBracket: AlwaysBreak
7+
BraceWrapping:
8+
AfterClass: true
9+
AfterFunction: true
10+
AfterNamespace: true
11+
AfterStruct: true
12+
BreakBeforeBraces: Custom
13+
ColumnLimit: 100
14+
ConstructorInitializerIndentWidth: 0
15+
ContinuationIndentWidth: 2
16+
DerivePointerAlignment: false
17+
PointerAlignment: Middle
18+
ReflowComments: false
19+
...
20+

.github/workflows/ci.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# continuous integration workflow
3+
#
4+
name: build repo
5+
6+
on:
7+
push:
8+
branches: [master]
9+
pull_request:
10+
branches: [master]
11+
workflow_dispatch:
12+
branches: [master]
13+
14+
jobs:
15+
build_ros2:
16+
uses: ros-misc-utilities/ros_build_scripts/.github/workflows/ros2_ci.yml@master
17+
with:
18+
repo: ${{ github.event.repository.name }}
19+
# vcs_url: https://raw.githubusercontent.com/${{ github.repository }}/master/${{ github.event.repository.name }}.repos

CMakeLists.txt

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#
2+
# Copyright 2024 Bernd Pfrommer <[email protected]>
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
cmake_minimum_required(VERSION 3.16)
17+
project(ffmpeg_encoder_decoder)
18+
19+
add_compile_options(-Wall -Wextra -Wpedantic -Werror)
20+
21+
# find dependencies
22+
find_package(ament_cmake REQUIRED)
23+
find_package(cv_bridge REQUIRED)
24+
find_package(rclcpp REQUIRED)
25+
find_package(sensor_msgs REQUIRED)
26+
find_package(std_msgs REQUIRED)
27+
find_package(OpenCV REQUIRED imgproc)
28+
29+
if(${cv_bridge_VERSION} GREATER "3.3.0")
30+
add_definitions(-DUSE_CV_BRIDGE_HPP)
31+
endif()
32+
33+
set(FFMPEG_PKGCONFIG "" CACHE STRING "extra path to pkgconfig")
34+
if("${FFMPEG_PKGCONFIG}" STREQUAL "")
35+
else()
36+
message(WARNING "using FFMPEG package from ${FFMPEG_PKGCONFIG}")
37+
endif()
38+
39+
set(ENV{PKG_CONFIG_PATH} ${FFMPEG_PKGCONFIG})
40+
find_package(PkgConfig REQUIRED)
41+
42+
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET
43+
libavcodec
44+
libswresample
45+
libswscale
46+
libavutil)
47+
48+
49+
set(FFMPEG_PKGCONFIG "" CACHE STRING "extra path to pkgconfig")
50+
if("${FFMPEG_PKGCONFIG}" STREQUAL "")
51+
else()
52+
message(WARNING "using FFMPEG package from ${FFMPEG_PKGCONFIG}")
53+
endif()
54+
55+
set(ENV{PKG_CONFIG_PATH} ${FFMPEG_PKGCONFIG})
56+
find_package(PkgConfig REQUIRED)
57+
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET
58+
libavcodec
59+
libswresample
60+
libswscale
61+
libavutil)
62+
63+
if(LIBAV_libavcodec_VERSION VERSION_GREATER_EQUAL 60.0.0)
64+
add_definitions(-DUSE_AV_FLAGS)
65+
endif()
66+
67+
68+
#
69+
# --------- encoding/decoding library
70+
#
71+
add_library(${PROJECT_NAME}
72+
SHARED
73+
src/encoder.cpp
74+
src/decoder.cpp
75+
src/utils.cpp
76+
src/tdiff.cpp)
77+
78+
target_include_directories(${PROJECT_NAME}
79+
PUBLIC
80+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
81+
$<INSTALL_INTERFACE:include>)
82+
83+
ament_target_dependencies(${PROJECT_NAME}
84+
PUBLIC
85+
cv_bridge
86+
rclcpp
87+
sensor_msgs)
88+
89+
target_link_libraries(${PROJECT_NAME}
90+
PUBLIC
91+
opencv_imgproc
92+
PkgConfig::LIBAV)
93+
94+
95+
ament_export_targets(${PROJECT_NAME}Targets HAS_LIBRARY_TARGET)
96+
97+
ament_export_dependencies(
98+
OpenCV
99+
LIBAV
100+
cv_bridge
101+
rclcpp
102+
sensor_msgs
103+
std_msgs)
104+
105+
install(
106+
DIRECTORY include/
107+
DESTINATION include
108+
)
109+
110+
install(
111+
TARGETS ${PROJECT_NAME}
112+
EXPORT ${PROJECT_NAME}Targets
113+
LIBRARY DESTINATION lib
114+
ARCHIVE DESTINATION lib
115+
RUNTIME DESTINATION bin
116+
INCLUDES DESTINATION include)
117+
118+
if(BUILD_TESTING)
119+
find_package(ament_cmake REQUIRED)
120+
find_package(ament_cmake_copyright REQUIRED)
121+
find_package(ament_cmake_cppcheck REQUIRED)
122+
find_package(ament_cmake_cpplint REQUIRED)
123+
find_package(ament_cmake_clang_format REQUIRED)
124+
find_package(ament_cmake_flake8 REQUIRED)
125+
find_package(ament_cmake_lint_cmake REQUIRED)
126+
find_package(ament_cmake_pep257 REQUIRED)
127+
find_package(ament_cmake_xmllint REQUIRED)
128+
129+
ament_copyright()
130+
ament_cppcheck(LANGUAGE c++)
131+
ament_cpplint(FILTERS "-build/include,-runtime/indentation_namespace")
132+
ament_clang_format(CONFIG_FILE .clang-format)
133+
ament_flake8()
134+
ament_lint_cmake()
135+
ament_pep257()
136+
ament_xmllint()
137+
138+
find_package(ament_cmake_gtest REQUIRED)
139+
ament_add_gtest(${PROJECT_NAME}_encoder_test test/encoder_test.cpp
140+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test)
141+
target_include_directories(${PROJECT_NAME}_encoder_test PUBLIC
142+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
143+
$<INSTALL_INTERFACE:include>)
144+
target_link_libraries(${PROJECT_NAME}_encoder_test ${PROJECT_NAME})
145+
endif()
146+
147+
ament_export_include_directories(include)
148+
ament_export_libraries(${PROJECT_NAME})
149+
ament_export_targets(${PROJECT_NAME}Targets HAS_LIBRARY_TARGET)
150+
151+
ament_package(CONFIG_EXTRAS cmake/${PROJECT_NAME}-extras.cmake.in)

CONTRIBUTING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Any contribution that you make to this repository will
2+
be under the Apache 2 License, as dictated by that
3+
[license](http://www.apache.org/licenses/LICENSE-2.0.html):
4+
5+
~~~
6+
5. Submission of Contributions. Unless You explicitly state otherwise,
7+
any Contribution intentionally submitted for inclusion in the Work
8+
by You to the Licensor shall be under the terms and conditions of
9+
this License, without any additional terms or conditions.
10+
Notwithstanding the above, nothing herein shall supersede or modify
11+
the terms of any separate license agreement you may have executed
12+
with Licensor regarding such Contributions.
13+
~~~
14+
15+
Contributors must sign-off each commit by adding a `Signed-off-by: ...`
16+
line to commit messages to certify that they have the right to submit
17+
the code they are contributing to the project according to the
18+
[Developer Certificate of Origin (DCO)](https://developercertificate.org/).

0 commit comments

Comments
 (0)