提交 20886361 编写于 作者: O openharmony_ci 提交者: Gitee

!21 通过宏适配surface的编译

Merge pull request !21 from SimonLi/master
...@@ -11,22 +11,41 @@ ...@@ -11,22 +11,41 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
shared_library("media_common") { import("//build/lite/config/component/lite_component.gni")
lite_library("media_common") {
if (ohos_kernel_type == "liteos_m") {
target_type = "static_library"
} else {
target_type = "shared_library"
}
sources = [ sources = [
"src/format.cpp", "src/format.cpp",
"src/source.cpp", "src/source.cpp",
] ]
cflags = [ "-fPIC" ]
cflags += [ "-Wall" ]
cflags_cc = cflags
include_dirs = [ include_dirs = [
"interfaces/kits", "interfaces/kits",
"//third_party/bounds_checking_function/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog",
]
public_deps = [
"$ohos_board_adapter_dir/media:hardware_media_sdk",
"$ohos_board_adapter_dir/middleware:middleware_source_sdk",
"//foundation/graphic/surface:lite_surface",
"//third_party/bounds_checking_function:libsec_shared",
] ]
if (ohos_kernel_type == "liteos_m") {
public_deps = [ "//third_party/bounds_checking_function:libsec_static" ]
} else {
public_deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
}
if (ohos_kernel_type == "liteos_m") {
public_deps +=
[ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static" ]
public_configs = [ ":media_common_public_config" ]
} else {
public_deps += [
"$ohos_board_adapter_dir/media:hardware_media_sdk",
"$ohos_board_adapter_dir/middleware:middleware_source_sdk",
"//foundation/graphic/surface:lite_surface",
]
}
}
config("media_common_public_config") {
defines = [ "SURFACE_DISABLED" ]
} }
...@@ -40,7 +40,9 @@ ...@@ -40,7 +40,9 @@
#include <map> #include <map>
#include <string> #include <string>
#include "format.h" #include "format.h"
#ifndef SURFACE_DISABLED
#include "surface.h" #include "surface.h"
#endif
using std::shared_ptr; using std::shared_ptr;
...@@ -144,9 +146,11 @@ public: ...@@ -144,9 +146,11 @@ public:
virtual ~StreamSource(void); virtual ~StreamSource(void);
#ifndef SURFACE_DISABLED
void SetSurface(Surface* surface); void SetSurface(Surface* surface);
Surface* GetSurface(void); Surface* GetSurface(void);
#endif
uint8_t* GetSharedBuffer(size_t& size); uint8_t* GetSharedBuffer(size_t& size);
...@@ -173,8 +177,10 @@ public: ...@@ -173,8 +177,10 @@ public:
private: private:
#ifndef SURFACE_DISABLED
Surface* surface_; Surface* surface_;
SurfaceBuffer* curBuffer_; SurfaceBuffer* curBuffer_;
#endif
}; };
/** /**
......
...@@ -61,18 +61,23 @@ const Format &Source::GetSourceStreamFormat() const ...@@ -61,18 +61,23 @@ const Format &Source::GetSourceStreamFormat() const
} }
StreamSource::StreamSource() StreamSource::StreamSource()
#ifndef SURFACE_DISABLED
: surface_(nullptr), : surface_(nullptr),
curBuffer_(nullptr) curBuffer_(nullptr)
#endif
{} {}
StreamSource::~StreamSource() StreamSource::~StreamSource()
{ {
MEDIA_ERR_LOG("[%s,%d] in", __func__, __LINE__); MEDIA_ERR_LOG("[%s,%d] in", __func__, __LINE__);
#ifndef SURFACE_DISABLED
if (surface_ != nullptr) { if (surface_ != nullptr) {
delete surface_; delete surface_;
} }
#endif
} }
#ifndef SURFACE_DISABLED
void StreamSource::SetSurface(Surface* surface) void StreamSource::SetSurface(Surface* surface)
{ {
surface_ = surface; surface_ = surface;
...@@ -82,10 +87,11 @@ Surface* StreamSource::GetSurface(void) ...@@ -82,10 +87,11 @@ Surface* StreamSource::GetSurface(void)
{ {
return surface_; return surface_;
} }
#endif
uint8_t* StreamSource::GetSharedBuffer(size_t& size) uint8_t* StreamSource::GetSharedBuffer(size_t& size)
{ {
#ifndef SURFACE_DISABLED
if ((surface_ == nullptr) || (curBuffer_ != nullptr)){ if ((surface_ == nullptr) || (curBuffer_ != nullptr)){
return nullptr; return nullptr;
} }
...@@ -97,10 +103,14 @@ uint8_t* StreamSource::GetSharedBuffer(size_t& size) ...@@ -97,10 +103,14 @@ uint8_t* StreamSource::GetSharedBuffer(size_t& size)
} else { } else {
return nullptr; return nullptr;
} }
#else
return nullptr;
#endif
} }
int StreamSource::QueueSharedBuffer(void* buffer, size_t size) int StreamSource::QueueSharedBuffer(void* buffer, size_t size)
{ {
#ifndef SURFACE_DISABLED
if ((surface_ == nullptr) || (buffer == nullptr) || (curBuffer_ == nullptr)){ if ((surface_ == nullptr) || (buffer == nullptr) || (curBuffer_ == nullptr)){
return -1; return -1;
} }
...@@ -115,6 +125,7 @@ int StreamSource::QueueSharedBuffer(void* buffer, size_t size) ...@@ -115,6 +125,7 @@ int StreamSource::QueueSharedBuffer(void* buffer, size_t size)
return -1; return -1;
} }
curBuffer_ = nullptr; curBuffer_ = nullptr;
#endif
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册