-
Notifications
You must be signed in to change notification settings - Fork 47
support android ndk #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
support android ndk #102
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,14 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) | |
message(FATAL_ERROR "Do not build in source directory!") | ||
endif() | ||
|
||
if (DEFINED ENV{USER_ROOT} AND ANDROID_ABI) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个可以放到CMake/options里面。 |
||
include_directories($ENV{USER_ROOT}/${ANDROID_ABI}/usr/include) | ||
link_directories($ENV{USER_ROOT}/${ANDROID_ABI}/usr/lib) | ||
|
||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_SHARED_LINKER_FLAGS}") | ||
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_SHARED_LINKER_FLAGS}") | ||
endif() | ||
|
||
add_subdirectory(libmodelbox) | ||
add_subdirectory(drivers) | ||
add_subdirectory(develop) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,16 @@ Status FfmpegVideoMuxer::Mux(const AVRational &time_base, | |
av_packet_rescale_ts(av_packet.get(), time_base, stream_->time_base); | ||
av_packet->stream_index = stream_->index; | ||
if (!is_header_wrote_) { | ||
#ifndef ANDROID | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里为什么 Android和其它有区别? |
||
auto ret = avformat_write_header(format_ctx_.get(), nullptr); | ||
#else | ||
AVDictionary *options = nullptr; | ||
av_dict_set(&options, "rtsp_transport", "tcp", 0); | ||
av_dict_set(&options, "recv_buffer_size", "10240000", 0); | ||
av_dict_set(&options, "stimeout", "2000000", 0); | ||
auto ret = avformat_write_header(format_ctx_.get(), &options); | ||
#endif | ||
|
||
if (ret < 0) { | ||
GET_FFMPEG_ERR(ret, ffmpeg_err); | ||
MBLOG_ERROR << "avformat_write_header failed, ret " << ffmpeg_err; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,6 +188,15 @@ class Collection { | |
return false; | ||
} | ||
|
||
#ifdef ANDROID | ||
/* When they come from different so files, they may have different hash | ||
* codes even if they have the same names. */ | ||
if (strcmp(typeid(T).name(), entrys_[key].type().name()) == 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. strncmp |
||
value = any_cast<T>(entrys_[key]); | ||
return true; | ||
} | ||
#endif | ||
|
||
if (!CanConvert(typeid(T).hash_code(), entrys_[key].type().hash_code())) { | ||
// always a bad condition | ||
MBLOG_ERROR << "Get value for " << key | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2021 The Modelbox Project Authors. All Rights Reserved. | ||
* | ||
* 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 MODELBOX_MEMORY_STUB_H_ | ||
#define MODELBOX_MEMORY_STUB_H_ | ||
|
||
#include <memory> | ||
|
||
#ifndef ANDROID | ||
|
||
#define modelbox_dynamic_pointer_cast std::dynamic_pointer_cast | ||
|
||
#else /* ANDROID */ | ||
|
||
#define modelbox_dynamic_pointer_cast modelbox::dynamic_pointer_cast | ||
|
||
namespace modelbox { | ||
|
||
/* LLVM __dynamic_cast calls is_equal() with use_strcmp=false, | ||
* so the string names are not compared. It will return NULL | ||
* if the object is allocated in one so file and dynamicly casted | ||
* in another so file. */ | ||
template<class _Tp, class _Up> | ||
inline _LIBCPP_INLINE_VISIBILITY | ||
typename std::enable_if | ||
< | ||
!std::is_array<_Tp>::value && !std::is_array<_Up>::value, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. vscode里面格式化代码 |
||
std::shared_ptr<_Tp> | ||
>::type | ||
dynamic_pointer_cast(const std::shared_ptr<_Up>& __r) _NOEXCEPT | ||
{ | ||
auto __p = std::dynamic_pointer_cast<_Tp>(__r); | ||
if (__p) { | ||
return __p; | ||
} | ||
return std::static_pointer_cast<_Tp>(__r); | ||
} | ||
|
||
} // namespace modelbox | ||
#endif /* ANDROID */ | ||
|
||
#endif /* MODELBOX_MEMORY_STUB_H_ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mindspore和lite版本能混用吗?
是否应该要分开?