Skip to content

Commit

Permalink
Utilize ImplPtr in AV component (#296)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll authored Feb 10, 2022
1 parent 86388eb commit 47e6a3a
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 111 deletions.
16 changes: 2 additions & 14 deletions av/include/ignition/common/AudioDecoder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,21 @@

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

#include <ignition/common/av/Export.hh>
#include <ignition/utils/SuppressWarning.hh>
#include <ignition/utils/ImplPtr.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.
Expand All @@ -63,13 +56,8 @@ namespace ignition
/// If no file is decoded, -1 is returned.
public: int SampleRate();

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

IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief Private data pointer
private: std::unique_ptr<AudioDecoderPrivate> data;
IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr)
};
}
}
Expand Down
8 changes: 3 additions & 5 deletions av/include/ignition/common/HWEncoder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,19 @@
#ifndef IGNITION_COMMON_HWENCODER_HH
#define IGNITION_COMMON_HWENCODER_HH

#include <memory>
#include <string>
#include <optional>

#include <ignition/common/FlagSet.hh>
#include <ignition/common/av/Export.hh>
#include <ignition/common/HWVideo.hh>
#include <ignition/common/ffmpeg_inc.hh>
#include <ignition/utils/ImplPtr.hh>

/// This is an internal-use only class encapsulating HW video encoding. All
/// symbols defined here are hidden from the public API.
namespace ignition::common
{
// Forward declare private data class
class HWVideoPrivate;

/// \brief Representation of a GPU video encoder and its configuration.
/// \note This class is intentionally hidden as it provides highly customized
/// behavior tailored just for the use with VideoEncoder.
Expand Down Expand Up @@ -81,7 +78,8 @@ namespace ignition::common
/// The value will be NONE until ConfigHWAccel() successfully finishes.
public: HWEncoderType GetEncoderType() const;

private: std::unique_ptr<HWVideoPrivate> dataPtr;
/// \brief Private data pointer
IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr)
};
}

Expand Down
10 changes: 2 additions & 8 deletions av/include/ignition/common/Video.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
#define IGNITION_COMMON_VIDEO_HH_

#include <string>
#include <memory>

#include <ignition/common/av/Export.hh>
#include <ignition/utils/SuppressWarning.hh>
#include <ignition/utils/ImplPtr.hh>

struct AVFormatContext;
struct AVCodecContext;
Expand All @@ -33,9 +32,6 @@ 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
{
Expand Down Expand Up @@ -76,10 +72,8 @@ namespace ignition
/// \brief free up open Video object, close files, streams
private: void Cleanup();

IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief Private data pointer
private: std::unique_ptr<VideoPrivate> dataPtr;
IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr)
};
}
}
Expand Down
11 changes: 2 additions & 9 deletions av/include/ignition/common/VideoEncoder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@

#include <chrono>
#include <string>
#include <memory>
#include <optional>

#include <ignition/common/FlagSet.hh>
#include <ignition/common/av/Export.hh>
#include <ignition/common/HWVideo.hh>
#include <ignition/utils/SuppressWarning.hh>
#include <ignition/utils/ImplPtr.hh>

// Default bitrate (0) indicates that a bitrate should be calculated when
// Start is called.
Expand All @@ -39,9 +38,6 @@ namespace ignition
{
namespace common
{
// Forward declare private data class
class VideoEncoderPrivate;

/// \brief The VideoEncoder class supports encoding a series of images
/// to a video format, and then writing the video to disk.
class IGNITION_COMMON_AV_VISIBLE VideoEncoder
Expand Down Expand Up @@ -221,11 +217,8 @@ namespace ignition
/// memory. This will also delete any temporary files.
public: void Reset();

IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \internal
/// \brief Private data pointer
private: std::unique_ptr<VideoEncoderPrivate> dataPtr;
IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr)
};
}
}
Expand Down
Loading

0 comments on commit 47e6a3a

Please sign in to comment.