-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add wolf and wolf2 android armv7 and armv8 libraries
issue #43
- Loading branch information
1 parent
a006aad
commit 55400b9
Showing
1,350 changed files
with
27,885 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
if (WOLF_MEDIA_STB) | ||
add_subdirectory(stb) | ||
endif() | ||
|
||
if (WOLF_MEDIA_FFMPEG) | ||
add_subdirectory(ffmpeg) | ||
endif() | ||
|
||
if (WOLF_MEDIA_GSTREAMER) | ||
add_subdirectory(gst) | ||
endif() | ||
|
||
# if (WOLF_MEDIA_OPENAL) | ||
add_subdirectory(openal) | ||
# endif() | ||
|
||
if (WOLF_MEDIA_SCREEN_CAPTURE) | ||
message(FATAL_ERROR "WOLF_MEDIA_SCREEN_CAPTURE is not implemented yet.") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
set(WOLF_MEDIA_FFMPEG_HEADERS | ||
w_av_config.hpp | ||
w_av_format.hpp | ||
w_av_frame.hpp | ||
w_av_packet.hpp | ||
w_decoder.hpp | ||
w_encoder.hpp | ||
w_ffmpeg_ctx.hpp | ||
w_ffmpeg.hpp | ||
) | ||
set(WOLF_MEDIA_FFMPEG_SOURCES | ||
w_av_config.cpp | ||
w_av_format.cpp | ||
w_av_frame.cpp | ||
w_av_packet.cpp | ||
w_decoder.cpp | ||
w_encoder.cpp | ||
w_ffmpeg_ctx.cpp | ||
w_ffmpeg.cpp | ||
) | ||
target_sources(${PROJECT_NAME} | ||
PRIVATE | ||
${WOLF_MEDIA_FFMPEG_HEADERS} | ||
${WOLF_MEDIA_FFMPEG_SOURCES} | ||
) | ||
message("PATH_FFMPEG ") | ||
# set(PATH_FFMPEG | ||
# /mnt/c/github/wolfengine/wolf/build/android-arm-clang-shared/_deps/wolf-deps-src/ffmpeg/ffmpeg-6.0) | ||
|
||
set(PATH_FFMPEG | ||
"C:/github/wolfengine/wolf/build/windows-x64-msvc-shared/_deps/wolf-deps-src/ffmpeg/6") | ||
|
||
message("PATH_FFMPEG ${PATH_FFMPEG}") | ||
|
||
# dependency is availbale by wolf-deps in root cmake. | ||
# target_link_libraries(${PROJECT_NAME} PUBLIC ffmpeg::ffmpeg) | ||
# target_link_libraries(${PROJECT_NAME} PUBLIC | ||
# ${PATH_FFMPEG}/lib/libavcodec.so | ||
# ${PATH_FFMPEG}/lib/libavdevice.so | ||
# ${PATH_FFMPEG}/lib/libavfilter.so | ||
# ${PATH_FFMPEG}/lib/libavformat.so | ||
# ${PATH_FFMPEG}/lib/libavutil.so | ||
# ${PATH_FFMPEG}/lib/libpostproc.so | ||
# ${PATH_FFMPEG}/lib/libswresample.so | ||
# ${PATH_FFMPEG}/lib/libswscale.so | ||
# ) | ||
|
||
|
||
target_link_libraries(${PROJECT_NAME} PUBLIC | ||
${PATH_FFMPEG}/lib/win/avcodec.lib | ||
${PATH_FFMPEG}/lib/win/avdevice.lib | ||
${PATH_FFMPEG}/lib/win/avfilter.lib | ||
${PATH_FFMPEG}/lib/win/avformat.lib | ||
${PATH_FFMPEG}/lib/win/avutil.lib | ||
# ${PATH_FFMPEG}/lib/win/postproc.lib | ||
${PATH_FFMPEG}/lib/win/swresample.lib | ||
${PATH_FFMPEG}/lib/win/swscale.lib | ||
) | ||
|
||
target_include_directories(${PROJECT_NAME} PUBLIC | ||
${PATH_FFMPEG}/include | ||
) | ||
target_compile_definitions(${PROJECT_NAME} PUBLIC WOLF_MEDIA_FFMPEG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
set(WOLF_MEDIA_FFMPEG_HEADERS | ||
w_av_config.hpp | ||
w_av_format.hpp | ||
w_av_frame.hpp | ||
w_av_packet.hpp | ||
w_decoder.hpp | ||
w_encoder.hpp | ||
w_ffmpeg_ctx.hpp | ||
w_ffmpeg.hpp | ||
) | ||
set(WOLF_MEDIA_FFMPEG_SOURCES | ||
w_av_config.cpp | ||
w_av_format.cpp | ||
w_av_frame.cpp | ||
w_av_packet.cpp | ||
w_decoder.cpp | ||
w_encoder.cpp | ||
w_ffmpeg_ctx.cpp | ||
w_ffmpeg.cpp | ||
) | ||
target_sources(${PROJECT_NAME} | ||
PRIVATE | ||
${WOLF_MEDIA_FFMPEG_HEADERS} | ||
${WOLF_MEDIA_FFMPEG_SOURCES} | ||
) | ||
message("PATH_FFMPEG ") | ||
# set(PATH_FFMPEG | ||
# /mnt/c/github/wolfengine/wolf/build/android-arm-clang-shared/_deps/wolf-deps-src/ffmpeg/ffmpeg-6.0) | ||
|
||
set(PATH_FFMPEG | ||
"C:/github/wolfengine/wolf/build/windows-x64-msvc-shared/_deps/wolf-deps-src/ffmpeg/6") | ||
|
||
message("PATH_FFMPEG ${PATH_FFMPEG}") | ||
|
||
# dependency is availbale by wolf-deps in root cmake. | ||
# target_link_libraries(${PROJECT_NAME} PUBLIC ffmpeg::ffmpeg) | ||
# target_link_libraries(${PROJECT_NAME} PUBLIC | ||
# ${PATH_FFMPEG}/lib/libavcodec.so | ||
# ${PATH_FFMPEG}/lib/libavdevice.so | ||
# ${PATH_FFMPEG}/lib/libavfilter.so | ||
# ${PATH_FFMPEG}/lib/libavformat.so | ||
# ${PATH_FFMPEG}/lib/libavutil.so | ||
# ${PATH_FFMPEG}/lib/libpostproc.so | ||
# ${PATH_FFMPEG}/lib/libswresample.so | ||
# ${PATH_FFMPEG}/lib/libswscale.so | ||
# ) | ||
|
||
|
||
target_link_libraries(${PROJECT_NAME} PUBLIC | ||
${PATH_FFMPEG}/lib/win/avcodec.lib | ||
${PATH_FFMPEG}/lib/win/avdevice.lib | ||
${PATH_FFMPEG}/lib/win/avfilter.lib | ||
${PATH_FFMPEG}/lib/win/avformat.lib | ||
${PATH_FFMPEG}/lib/win/avutil.lib | ||
${PATH_FFMPEG}/lib/win/postproc.lib | ||
${PATH_FFMPEG}/lib/win/swresample.lib | ||
${PATH_FFMPEG}/lib/win/swscale.lib | ||
) | ||
|
||
target_include_directories(${PROJECT_NAME} PUBLIC | ||
${PATH_FFMPEG}/include | ||
) | ||
target_compile_definitions(${PROJECT_NAME} PUBLIC WOLF_MEDIA_FFMPEG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "wolf/media/ffmpeg/w_av_config.hpp" | ||
|
||
using w_av_config = wolf::media::ffmpeg::w_av_config; | ||
|
||
w_av_config::w_av_config(_In_ AVPixelFormat p_format, _In_ int p_width, | ||
_In_ int p_height, _In_ int p_alignment) noexcept | ||
: format(p_format), | ||
width(p_width), | ||
height(p_height), | ||
alignment(p_alignment) {} | ||
|
||
w_av_config::w_av_config(_In_ int p_nb_channels, | ||
_In_ AVSampleFormat p_sample_fmts, | ||
_In_ int p_sample_rate) noexcept | ||
: sample_rate(p_sample_rate), | ||
sample_fmts(p_sample_fmts), | ||
nb_channels(p_nb_channels) {} | ||
|
||
int w_av_config::get_required_video_buffer_size() const noexcept { | ||
return av_image_get_buffer_size(this->format, this->width, this->height, | ||
this->alignment); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
Project: Wolf Engine. Copyright © 2014-2023 Pooya Eimandar | ||
https://github.com/WolfSource/wolf | ||
*/ | ||
|
||
#ifdef WOLF_MEDIA_FFMPEG | ||
|
||
#pragma once | ||
|
||
#include <wolf.hpp> | ||
|
||
extern "C" { | ||
#include <libavformat/avformat.h> | ||
#include <libavutil/imgutils.h> | ||
} | ||
|
||
namespace wolf::media::ffmpeg { | ||
class w_av_config { | ||
public: | ||
#pragma region Constructors /Destructor | ||
// default constructor | ||
W_API w_av_config() noexcept = default; | ||
|
||
// constructor for av video format | ||
W_API w_av_config(_In_ AVPixelFormat p_format, _In_ int p_width, | ||
_In_ int p_height, _In_ int p_alignment = 1) noexcept; | ||
|
||
// constructor for av audio format | ||
W_API w_av_config(_In_ int p_nb_channels, _In_ AVSampleFormat p_sample_fmts, | ||
_In_ int p_sample_rate) noexcept; | ||
|
||
// destructor | ||
W_API virtual ~w_av_config() noexcept = default; | ||
|
||
// move constructor. | ||
W_API w_av_config(w_av_config &&p_other) noexcept = default; | ||
// move assignment operator. | ||
W_API w_av_config &operator=(w_av_config &&p_other) noexcept = default; | ||
|
||
// copy constructor | ||
w_av_config(const w_av_config &p_other) noexcept = default; | ||
// copy assignment operator | ||
w_av_config &operator=(const w_av_config &p_other) noexcept = default; | ||
#pragma endregion | ||
|
||
/** | ||
* @returns the required buffer size for video frame | ||
*/ | ||
W_API int get_required_video_buffer_size() const noexcept; | ||
|
||
// the format of av frame | ||
AVPixelFormat format = AVPixelFormat::AV_PIX_FMT_NONE; | ||
// the width of av frame | ||
int width = 0; | ||
// the height of av frame | ||
int height = 0; | ||
// data alignment | ||
int alignment = 0; | ||
// the sample rate of the audio | ||
int sample_rate = 0; | ||
// Audio only. The channel layout and number of channels | ||
AVChannelLayout ch_layout; | ||
// the sample format of the audio | ||
AVSampleFormat sample_fmts = AVSampleFormat::AV_SAMPLE_FMT_NONE; | ||
// number of channels | ||
int nb_channels = 0; | ||
}; | ||
} // namespace wolf::media::ffmpeg | ||
|
||
#endif // WOLF_MEDIA_FFMPEG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#ifdef WOLF_MEDIA_FFMPEG | ||
|
||
#include "w_av_format.hpp" | ||
|
||
#include "w_av_frame.hpp" | ||
|
||
using w_av_format = wolf::media::ffmpeg::w_av_format; | ||
|
||
w_av_format::w_av_format() noexcept | ||
: _stream_buffer(nullptr), _fmt_ctx(nullptr), _io_ctx(nullptr) {} | ||
|
||
void w_av_format::_release() noexcept { | ||
if (this->_stream_buffer != nullptr) { | ||
auto _ptr = this->_stream_buffer.get(); | ||
free(_ptr); | ||
this->_stream_buffer = nullptr; | ||
} | ||
if (this->_fmt_ctx != nullptr) { | ||
auto _ptr = this->_fmt_ctx.get(); | ||
avformat_close_input(&_ptr); | ||
this->_stream_buffer = nullptr; | ||
} | ||
if (this->_io_ctx != nullptr) { | ||
auto _ptr = this->_io_ctx.get(); | ||
av_free(_ptr); | ||
this->_stream_buffer = nullptr; | ||
} | ||
} | ||
|
||
static int s_read_packet(void *p_opaque, _Inout_ uint8_t *p_buf, | ||
_In_ int p_buf_size) { | ||
auto _av_fmt = gsl::narrow_cast<w_av_format *>(p_opaque); | ||
if (_av_fmt) { | ||
if (_av_fmt->on_read_callback) { | ||
return _av_fmt->on_read_callback(p_buf, p_buf_size); | ||
} | ||
} | ||
return -1; // failed | ||
} | ||
|
||
boost::leaf::result<int> w_av_format::init( | ||
_In_ int p_stream_buf_size) noexcept { | ||
_release(); | ||
|
||
// alloc a buffer for the stream | ||
auto _ptr = gsl::narrow_cast<uint8_t *>(malloc(p_stream_buf_size)); | ||
if (_ptr == nullptr) { | ||
// out of memory | ||
return W_FAILURE(std::errc::not_enough_memory, | ||
"could not allocate memory for stream buffer"); | ||
} | ||
this->_stream_buffer.reset(_ptr); | ||
|
||
// get a AVContext stream | ||
auto _io_ctx_ptr = avio_alloc_context( | ||
this->_stream_buffer.get(), // buffer | ||
p_stream_buf_size, // buffer size | ||
0, // buffer is only readable - set to 1 for read/write | ||
this, // use your specified data | ||
s_read_packet, // function - reading Packets (see example) | ||
nullptr, // function - write Packets | ||
nullptr // function - seek to position in stream (see example) | ||
); | ||
if (_io_ctx_ptr == nullptr) { | ||
// out of memory | ||
return W_FAILURE(std::errc::not_enough_memory, | ||
"could not allocate io context"); | ||
} | ||
this->_io_ctx.reset(_io_ctx_ptr); | ||
|
||
// allocate a AVContext | ||
auto _fmt_ctx_ptr = avformat_alloc_context(); | ||
if (_fmt_ctx_ptr == nullptr) { | ||
// out of memory | ||
return W_FAILURE(std::errc::not_enough_memory, | ||
"could not allocate avformat context"); | ||
} | ||
this->_fmt_ctx.reset(_fmt_ctx_ptr); | ||
|
||
// Setup the format context based on custom IO | ||
this->_fmt_ctx->pb = _io_ctx_ptr; | ||
this->_fmt_ctx->flags |= AVFMT_FLAG_CUSTOM_IO; | ||
|
||
// open "file" (open our custom IO) | ||
// empty string is where filename would go. doesn't matter since we aren't | ||
// reading a file NULL params are format and demuxer settings, respectively | ||
if (avformat_open_input(&_fmt_ctx_ptr, "", nullptr, nullptr) < 0) { | ||
// error on opening input | ||
return W_FAILURE(std::errc::not_enough_memory, | ||
"could not allocate io context"); | ||
} | ||
|
||
// find the stream info | ||
if (avformat_find_stream_info(_fmt_ctx_ptr, nullptr) < 0) { | ||
// Error on finding stream info | ||
return W_FAILURE(std::errc::operation_canceled, | ||
"could not get stream info"); | ||
} | ||
|
||
// find best stream | ||
const auto _ret = av_find_best_stream( | ||
_fmt_ctx_ptr, AVMediaType::AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0); | ||
if (_ret < 0) { | ||
// Error on finding stream info | ||
return W_FAILURE(std::errc::operation_canceled, | ||
"could not find best stream"); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
uint8_t *w_av_format::get_io_ctx_buffer() const { | ||
if (this->_io_ctx) { | ||
return this->_io_ctx->buffer; | ||
} | ||
return nullptr; | ||
} | ||
|
||
int w_av_format::get_io_ctx_size() const { | ||
if (this->_io_ctx) { | ||
return this->_io_ctx->buffer_size; | ||
} | ||
return -1; | ||
} | ||
|
||
#endif // WOLF_MEDIA_FFMPEG |
Oops, something went wrong.