Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include(GNUInstallDirs)
include(GenerateExportHeader)

file(GLOB_RECURSE AV_SOURCES "avcpp/*.cpp")
file(GLOB_RECURSE AV_HEADERS "avcpp/*.h" "avcpp/*.hpp")
Expand Down Expand Up @@ -58,7 +59,7 @@ foreach(TARGET ${AV_TARGETS})
#PRIVATE
# ${CMAKE_CURRENT_SOURCE_DIR}
)
set_target_properties(${TARGET} PROPERTIES PUBLIC_HEADER "${AV_HEADERS};${CMAKE_CURRENT_BINARY_DIR}/avcpp/avconfig.h")
set_target_properties(${TARGET} PROPERTIES PUBLIC_HEADER "${AV_HEADERS};${CMAKE_CURRENT_BINARY_DIR}/avcpp/avconfig.h;${CMAKE_CURRENT_BINARY_DIR}/avcpp/avcpp_export.h")

# If not CMAKE_CXX_STANARD provided globally (subproject), use latest supported one
if (NOT CMAKE_CXX_STANDARD)
Expand All @@ -83,17 +84,37 @@ foreach(TARGET ${AV_TARGETS})
target_link_libraries(${TARGET} PRIVATE ws2_32)
endif()

if(MSVC AND TYPE STREQUAL "SHARED")
set_target_properties(${TARGET} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()

add_library(${AV_NAMESPACE}::${TARGET} ALIAS ${TARGET})
endforeach()

if (TARGET ${AV_BASENAME}-static)
set_target_properties(${AV_BASENAME}-static PROPERTIES OUTPUT_NAME ${AV_BASENAME})
endif()

# prepare export header for visibility macros
string(TOUPPER ${AV_BASENAME} AV_BASENAME_UPPER)
generate_export_header(${AV_BASENAME}
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/avcpp/avcpp_export.h
STATIC_DEFINE ${AV_BASENAME_UPPER}_STATIC_DEFINE
)
if (AV_ENABLE_SHARED)
set_target_properties(${AV_BASENAME} PROPERTIES
CXX_VISIBILITY_PRESET hidden
C_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)

if (TARGET ${AV_BASENAME}-static)
target_compile_definitions(${AV_BASENAME}-static PUBLIC
${AV_BASENAME_UPPER}_STATIC_DEFINE
)
endif()
else()
target_compile_definitions(${AV_BASENAME} PUBLIC
${AV_BASENAME_UPPER}_STATIC_DEFINE
)
endif()

# prepare configuration file
configure_file(avcpp/avconfig.h.in avcpp/avconfig.h @ONLY)

Expand Down Expand Up @@ -137,7 +158,7 @@ if (AVCPP_NOT_SUBPROJECT)
"${CMAKE_CURRENT_BINARY_DIR}/avcpp/avcpp-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/avcpp/avcpp-config-version.cmake"
DESTINATION
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/avcpp"
"${CMAKE_INSTALL_LIBDIR}/cmake/avcpp"
)

if (PKG_CONFIG_FOUND)
Expand Down Expand Up @@ -191,7 +212,6 @@ if (AVCPP_NOT_SUBPROJECT)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avcpp/libavcpp.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

endif()
endif()

4 changes: 3 additions & 1 deletion src/avcpp/audioresampler.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "avcpp/avcpp_export.h"

#include <functional>

#include "ffmpeg.h"
Expand All @@ -13,7 +15,7 @@ namespace av {

// TODO: support New Channel Layout directly

class AudioResampler : public FFWrapperPtr<SwrContext>, public noncopyable
class AVCPP_EXPORT AudioResampler : public FFWrapperPtr<SwrContext>, public noncopyable
{
public:
AudioResampler();
Expand Down
4 changes: 3 additions & 1 deletion src/avcpp/av.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#pragma once

#include "avcpp/avcpp_export.h"

namespace av {

/**
* Init all subsustems needed by avcpp. Must be call before any other functionality
*/
void init();
AVCPP_EXPORT void init();

} // ::av

10 changes: 6 additions & 4 deletions src/avcpp/averror.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "avcpp/avcpp_export.h"

#include <system_error>
#include <exception>

Expand Down Expand Up @@ -62,7 +64,7 @@ enum class Errors
MixBufferSinkAccess,
};

class OptionalErrorCode
class AVCPP_EXPORT OptionalErrorCode
{
OptionalErrorCode() {}

Expand All @@ -85,7 +87,7 @@ class OptionalErrorCode
*
* Simple wrap error code value and category
*/
class Exception : public std::system_error
class AVCPP_EXPORT Exception : public std::system_error
{
public:
using std::system_error::system_error;
Expand All @@ -95,7 +97,7 @@ class Exception : public std::system_error
* @brief The AvcppCategory class
* Describes internal AvCpp errors
*/
class AvcppCategory : public std::error_category
class AVCPP_EXPORT AvcppCategory : public std::error_category
{
public:

Expand All @@ -107,7 +109,7 @@ class AvcppCategory : public std::error_category
* @brief The FfmpegCategory class
* Describers FFmpeg internal errors
*/
class FfmpegCategory : public std::error_category
class AVCPP_EXPORT FfmpegCategory : public std::error_category
{
virtual const char *name() const noexcept override;
virtual std::string message(int ev) const override;
Expand Down
6 changes: 4 additions & 2 deletions src/avcpp/avtime.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#pragma once

#include "avcpp/avcpp_export.h"

#include "ffmpeg.h"

namespace av {

/**
* Get the current time in microseconds.
*/
int64_t gettime();
AVCPP_EXPORT int64_t gettime();


/**
Expand All @@ -18,7 +20,7 @@ int64_t gettime();
* @param usec Number of microseconds to sleep.
* @return zero on success or (negative) error code.
*/
int usleep(unsigned usec);
AVCPP_EXPORT int usleep(unsigned usec);


} // ::av
Expand Down
29 changes: 15 additions & 14 deletions src/avcpp/avutils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "avcpp/avconfig.h"
#include "avcpp/avcpp_export.h"

#include <ranges>
#include <string>
Expand Down Expand Up @@ -48,7 +49,7 @@ R lexical_cast(const T& v)
return result;
}

class noncopyable
class AVCPP_EXPORT noncopyable
{
protected:
noncopyable() = default;
Expand All @@ -63,7 +64,7 @@ class noncopyable
* mean less logging. A negative number tells FFmpeg to
* shut up.
*/
void set_logging_level(int32_t level);
AVCPP_EXPORT void set_logging_level(int32_t level);


/**
Expand All @@ -75,7 +76,7 @@ void set_logging_level(int32_t level);
* boost::lexical_cast will be used and set_logging_level(int32_t) will be
* called.
*/
void set_logging_level(const std::string& level);
AVCPP_EXPORT void set_logging_level(const std::string& level);

// Compat code
#define setFFmpegLoggingLevel set_logging_level
Expand All @@ -88,15 +89,15 @@ void set_logging_level(const std::string& level);
* @param width output width in hex values (real text screen with is: sw = width * 3 - 1)
*/
[[deprecated("Use av::hex_dump()")]]
void dumpBinaryBuffer(uint8_t *buffer, int buffer_size, int width = 16);
AVCPP_EXPORT void dumpBinaryBuffer(uint8_t *buffer, int buffer_size, int width = 16);


/**
* C++ verstion of the av_err2str()
* @param error - error code to convert to string
* @return string representation of error code
*/
std::string error2string(int error);
AVCPP_EXPORT std::string error2string(int error);

}

Expand All @@ -108,7 +109,7 @@ std::string error2string(int error);
//
namespace av {

struct EmptyDeleter
struct AVCPP_EXPORT EmptyDeleter
{
void operator()(void *) {}
};
Expand All @@ -119,7 +120,7 @@ struct EmptyDeleter
* Can be used with shared_ptr<> and so on.
*/
namespace v1 {
struct AvDeleter
struct AVCPP_EXPORT AvDeleter
{
bool operator() (struct SwsContext* &swsContext);
bool operator() (struct AVCodecContext* &codecContext);
Expand All @@ -138,7 +139,7 @@ struct AvDeleter
} // ::v1

inline namespace v2 {
struct SmartDeleter
struct AVCPP_EXPORT SmartDeleter
{
template<typename T>
bool operator() (T *ptr) {
Expand Down Expand Up @@ -169,7 +170,7 @@ std::unique_ptr<T, void(*)(void*)> memdup(const void *p, size_t size)
* Functor to take next element in list/array
*/
#if 0
struct AvNextElement
struct AVCPP_EXPORT AvNextElement
{
AVFilterInOut * operator()(AVFilterInOut * x) const
{
Expand Down Expand Up @@ -261,7 +262,7 @@ class ScopedValue
* In example above dtor of the action will be called before fd and we correctly close descriptor.
*
*/
class ScopeOutAction
class AVCPP_EXPORT ScopeOutAction
{
public:
template<typename Proc>
Expand Down Expand Up @@ -628,12 +629,12 @@ void array_to_container(const T* array, Container &container, Compare isEnd, Cal
//
// Allow to use without AVFORMAT library
//
void hex_dump(FILE *f, const uint8_t *buf, std::size_t size);
void hex_dump_log(void *avcl, int level, const uint8_t *buf, std::size_t size);
AVCPP_EXPORT void hex_dump(FILE *f, const uint8_t *buf, std::size_t size);
AVCPP_EXPORT void hex_dump_log(void *avcl, int level, const uint8_t *buf, std::size_t size);

#if AVCPP_CXX_STANDARD >= 20
void hex_dump(FILE *f, std::span<const uint8_t> buf);
void hex_dump_log(void *avcl, int level, std::span<const uint8_t> buf);
AVCPP_EXPORT void hex_dump(FILE *f, std::span<const uint8_t> buf);
AVCPP_EXPORT void hex_dump_log(void *avcl, int level, std::span<const uint8_t> buf);
#endif // if AVCPP_CXX_STANDARD >= 20

} // ::av
Expand Down
7 changes: 4 additions & 3 deletions src/avcpp/buffer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "avcpp/avcpp_export.h"
#include "avcpp/averror.h"
#include "ffmpeg.h"

Expand All @@ -13,15 +14,15 @@ namespace buffer {
/**
* Buffer deleter that do nothing. To wrap static data.
*/
void null_deleter(void* /*opaque*/, uint8_t* /*data*/);
AVCPP_EXPORT void null_deleter(void* /*opaque*/, uint8_t* /*data*/);
} // ::buffer

class BufferRef;

/**
* Non-owning view for the nested AVBufferRef
*/
class BufferRefView : public FFWrapperPtr<AVBufferRef>
class AVCPP_EXPORT BufferRefView : public FFWrapperPtr<AVBufferRef>
{
public:
using FFWrapperPtr<AVBufferRef>::FFWrapperPtr;
Expand Down Expand Up @@ -115,7 +116,7 @@ class BufferRefView : public FFWrapperPtr<AVBufferRef>
/**
* Light weight wrapper for the FFmpeg AVBufferRef functionality
*/
class BufferRef : public BufferRefView
class AVCPP_EXPORT BufferRef : public BufferRefView
{
//using FFWrapperPtr<AVBufferRef>::FFWrapperPtr;
using BufferRefView::BufferRefView;
Expand Down
14 changes: 8 additions & 6 deletions src/avcpp/channellayout.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "avcpp/avcpp_export.h"

#include <string>
#include <string_view>
#include <bitset>
Expand All @@ -14,14 +16,14 @@ extern "C" {

namespace av {

std::string channel_name(AVChannel channel);
std::string channel_description(AVChannel channel);
AVChannel channel_from_string(const std::string &name);
AVChannel channel_from_string(const char *name);
AVCPP_EXPORT std::string channel_name(AVChannel channel);
AVCPP_EXPORT std::string channel_description(AVChannel channel);
AVCPP_EXPORT AVChannel channel_from_string(const std::string &name);
AVCPP_EXPORT AVChannel channel_from_string(const char *name);

class ChannelLayout;

class ChannelLayoutView
class AVCPP_EXPORT ChannelLayoutView
{
public:
ChannelLayoutView() noexcept;
Expand Down Expand Up @@ -77,7 +79,7 @@ class ChannelLayoutView



class ChannelLayout : public ChannelLayoutView
class AVCPP_EXPORT ChannelLayout : public ChannelLayoutView
{
public:
ChannelLayout() = default;
Expand Down
Loading
Loading