Skip to content

Commit

Permalink
Merge branch 'ign-common3' into ports/3_to_4
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Oct 6, 2022
2 parents 6107606 + 4f2ae91 commit d72650b
Show file tree
Hide file tree
Showing 292 changed files with 11,460 additions and 9,918 deletions.
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ign_export_header(

public_headers_no_gen = glob([
"include/ignition/common/*.hh",
"include/ignition/common/detail/*.hh",
"include/gz/common/detail/*.hh"
])

private_headers = [
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ set(IGN_CMAKE_VER ${ignition-cmake2_VERSION_MAJOR})
#============================================================================
# Configure the project
#============================================================================
ign_configure_project()
ign_configure_project(
REPLACE_IGNITION_INCLUDE_PATH gz/common
)

#============================================================================
# Set project-specific options
Expand Down
9 changes: 7 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@

## Gazebo Common 3.x

## Gazebo Common 3.15.0 (2022-10-06)

1. ign -> gz Migrate Ignition Headers
* [Pull request #418](https://github.com/gazebosim/gz-common/pull/418)

## Gazebo Common 3.14.2 (2022-08-16)

1. Fix deprecation warning from new `ffmpeg`
Expand Down Expand Up @@ -412,7 +417,7 @@

## Ignition Common 3.8.0 (2020-12-08)

1. Call ignition::common::load() from Video constructor
1. Call gz::common::load() from Video constructor
* [Pull Request 111](https://github.com/ignitionrobotics/ign-common/pull/111)

1. Cleanup
Expand Down Expand Up @@ -569,7 +574,7 @@

## Ignition Common 3.2.0 (2019-08-07)

1. Allow ignLogInit to use an absolute path. Added a timeToIso that converts a given time to an ISO string. Some console timestamps were using `IGN_SYSTEM_TIME_NS()` and others `ignition::common::systemTimeISO()`. Switched all to use `ignition::common::systemTimeISO()`.
1. Allow ignLogInit to use an absolute path. Added a timeToIso that converts a given time to an ISO string. Some console timestamps were using `IGN_SYSTEM_TIME_NS()` and others `gz::common::systemTimeISO()`. Switched all to use `gz::common::systemTimeISO()`.
* [BitBucket pull request 203](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-common/pull-requests/203)

1. Port ColladaLoader fix: use default value of 1 for stride parameter when unset.
Expand Down
2 changes: 2 additions & 0 deletions av/include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(gz)
install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL})
File renamed without changes.
76 changes: 76 additions & 0 deletions av/include/gz/common/AudioDecoder.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (C) 2016 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GZ_COMMON_AUDIO_DECODER_HH_
#define GZ_COMMON_AUDIO_DECODER_HH_

#include <stdint.h>
#include <string>
#include <memory>

#include <gz/common/av/Export.hh>
#include <gz/common/SuppressWarning.hh>

namespace ignition
{
namespace common
{
/// \brief Forward declaration of private data class
class AudioDecoderPrivate;

/// \class AudioDecoder AudioDecoder.hh ignition/common/common.hh
/// \brief An audio decoder based on FFMPEG.
class IGNITION_COMMON_AV_VISIBLE AudioDecoder
{
/// \brief Constructor.
public: AudioDecoder();

/// \brief Destructor.
public: virtual ~AudioDecoder();

/// \brief Set the file to decode.
/// \param[in] _filename Path to an audio file.
/// \return True if the file was successfull opened.
public: bool SetFile(const std::string &_filename);

/// \brief Get the audio filename that was set.
/// \return The name of the set audio file.
/// \sa AudioDecoder::SetFile
public: std::string File() const;

/// \brief Decode the loaded audio file.
/// \sa AudioDecoder::SetFile
/// \param[out] _outBuffer Buffer that holds the decoded audio data.
/// \param[out] _outBufferSize Size of the _outBuffer.
/// \return True if decoding was succesful.
public: bool Decode(uint8_t **_outBuffer, unsigned int *_outBufferSize);

/// \brief Get the sample rate from the latest decoded file.
/// \return Integer sample rate, such as 44100.
/// If no file is decoded, -1 is returned.
public: int SampleRate();

/// \brief Free audio object, close files, streams.
private: void Cleanup();

IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief Private data pointer
private: std::unique_ptr<AudioDecoderPrivate> data;
IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
};
}
}
#endif
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#include <string>
#include <optional>

#include <ignition/common/FlagSet.hh>
#include <ignition/common/av/Export.hh>
#include <ignition/common/SuppressWarning.hh>
#include <ignition/common/HWVideo.hh>
#include <ignition/common/ffmpeg_inc.hh>
#include <gz/common/FlagSet.hh>
#include <gz/common/av/Export.hh>
#include <gz/common/SuppressWarning.hh>
#include <gz/common/HWVideo.hh>
#include <gz/common/ffmpeg_inc.hh>

/// This is an internal-use only class encapsulating HW video encoding. All
/// symbols defined here are hidden from the public API.
Expand Down
56 changes: 56 additions & 0 deletions av/include/gz/common/HWVideo.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2020 Martin Pecka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IGNITION_COMMON_HWVIDEO_HH
#define IGNITION_COMMON_HWVIDEO_HH

#include <gz/common/EnumIface.hh>

namespace ignition::common
{
enum class IGNITION_COMMON_AV_VISIBLE HWEncoderType
{
NONE,
NVENC, // Linux device is /dev/nvidia*
// Windows is the same (even though such file doesn't exist)
VAAPI, // Linux device /dev/dri/renderD* or display number (e.g. :0)
VDPAU, // Not supported (probably only for decoding?)
QSV, // Win device is 0-based GPU index,
// Linux uses /dev/dri/renderD* or display number (e.g. :0)
VIDEOTOOLBOX, // Not yet suported
AMF, // Not yet suported
OMX, // Not yet suported
V4L2M2M, // Not yet suported
DXVA2, // Not yet suported
_ // For FlagSet to work.
};

IGN_ENUM(HWEncoderTypeParser, HWEncoderType,
HWEncoderType::NONE, HWEncoderType::_,
"NONE",
"NVENC",
"VAAPI",
"VDPAU",
"QSV",
"VIDEOTOOLBOX",
"AMF",
"OMX",
"V4L2M2M",
"DXVA2",
"INVALID"
)
}

#endif
86 changes: 86 additions & 0 deletions av/include/gz/common/Video.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright (C) 2016 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GZ_COMMON_VIDEO_HH_
#define GZ_COMMON_VIDEO_HH_

#include <string>
#include <memory>

#include <gz/common/av/Export.hh>
#include <gz/common/SuppressWarning.hh>

struct AVFormatContext;
struct AVCodecContext;
struct AVFrame;
struct AVPicture;
struct SwsContext;

namespace ignition
{
namespace common
{
// Forward declare private data class
class VideoPrivate;

/// \brief Handle video encoding and decoding using libavcodec
class IGNITION_COMMON_AV_VISIBLE Video
{
/// \brief Constructor
public: Video();

/// \brief Destructor
public: virtual ~Video();

/// \brief Load a video file
/// \param[in] _filename Full path of the video file
/// \return false if a video stream can't be found
public: bool Load(const std::string &_filename);

/// \brief Get the width of the video in pixels
/// \return the width
public: int Width() const;

/// \brief Get the height of the video in pixels
/// \return the height
public: int Height() const;

/// \brief Convenience type alias for duration
/// where 1000000 is the same as AV_TIME_BASE fractional seconds
public:
using Length = std::chrono::duration<int64_t, std::ratio<1, 1000000>>;

/// \brief Get the duration of the video
/// \return the duration
public: Length Duration() const;

/// \brief Get the next frame of the video.
/// \param[out] _buffer Allocated buffer in which the frame is stored
/// (size has to be width * height * 3 bytes).
/// \return false on error or end of file
public: bool NextFrame(unsigned char **_buffer);

/// \brief free up open Video object, close files, streams
private: void Cleanup();

IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief Private data pointer
private: std::unique_ptr<VideoPrivate> dataPtr;
IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
};
}
}
#endif
Loading

0 comments on commit d72650b

Please sign in to comment.