mirror of
https://github.com/openharmony/multimedia_video_processing_engine.git
synced 2026-07-18 17:14:29 -04:00
@@ -23,8 +23,11 @@ using namespace OHOS;
|
||||
using namespace std;
|
||||
constexpr int64_t NANOS_IN_SECOND = 1000000000L;
|
||||
constexpr int64_t NANOS_IN_MICRO = 1000L;
|
||||
constexpr int64_t SLEEP_MICROSECONDS = 33333L;
|
||||
constexpr int THREE = 3;
|
||||
|
||||
static int64_t GetSystemTimeUs()
|
||||
namespace OHOS {
|
||||
int64_t GetSystemTimeUs()
|
||||
{
|
||||
struct timespec now;
|
||||
(void)clock_gettime(CLOCK_BOOTTIME, &now);
|
||||
@@ -32,24 +35,25 @@ static int64_t GetSystemTimeUs()
|
||||
return nanoTime / NANOS_IN_MICRO;
|
||||
}
|
||||
|
||||
static void OnError(OH_VideoProcessing* videoProcessor, VideoProcessing_ErrorCode error, void* userData)
|
||||
void OnError(OH_VideoProcessing* videoProcessor, VideoProcessing_ErrorCode error, void* userData)
|
||||
{
|
||||
(void)videoProcessor;
|
||||
(void)error;
|
||||
(void)userData;
|
||||
}
|
||||
|
||||
static void OnState(OH_VideoProcessing* videoProcessor, VideoProcessing_State state, void* userData)
|
||||
void OnState(OH_VideoProcessing* videoProcessor, VideoProcessing_State state, void* userData)
|
||||
{
|
||||
(void)videoProcessor;
|
||||
(void)state;
|
||||
(void)userData;
|
||||
}
|
||||
|
||||
static void OnNewOutputBuffer(OH_VideoProcessing* videoProcessor, uint32_t index, void* userData)
|
||||
void OnNewOutputBuffer(OH_VideoProcessing* videoProcessor, uint32_t index, void* userData)
|
||||
{
|
||||
OH_VideoProcessing_RenderOutputBuffer(videoProcessor, index);
|
||||
}
|
||||
}
|
||||
|
||||
class VPEConsumerListener : public IBufferConsumerListener{
|
||||
public:
|
||||
@@ -153,13 +157,13 @@ int32_t VideoSample::InputFunc(const uint8_t *data, size_t size)
|
||||
err = OH_NativeBuffer_Map(nativeBuffer, &virAddr);
|
||||
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeBuffer_Map failed.");
|
||||
uint8_t *addr = reinterpret_cast<uint8_t *>(virAddr);
|
||||
memcpy_s(addr, config.stride * config.height * 3, data, size);
|
||||
memcpy_s(addr, config.stride * config.height * THREE, data, size);
|
||||
NativeWindowHandleOpt(inWindow, SET_UI_TIMESTAMP, GetSystemTimeUs());
|
||||
err = OH_NativeBuffer_Unmap(nativeBuffer);
|
||||
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeBuffer_Unmap failed.");
|
||||
err = OH_NativeWindow_NativeWindowFlushBuffer(inWindow, ohNativeWindowBuffer, -1, region);
|
||||
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeWindow_NativeWindowFlushBuffer failed.");
|
||||
usleep(33333);
|
||||
usleep(SLEEP_MICROSECONDS);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ constexpr int64_t NANOS_IN_MICRO = 1000L;
|
||||
constexpr int64_t SLEEP_MICROSECONDS = 33333L;
|
||||
constexpr int THREE = 3;
|
||||
|
||||
static int64_t GetSystemTimeUs()
|
||||
namespace OHOS {
|
||||
int64_t GetSystemTimeUs()
|
||||
{
|
||||
struct timespec now;
|
||||
(void)clock_gettime(CLOCK_BOOTTIME, &now);
|
||||
@@ -34,24 +35,25 @@ static int64_t GetSystemTimeUs()
|
||||
return nanoTime / NANOS_IN_MICRO;
|
||||
}
|
||||
|
||||
static void OnError(OH_VideoProcessing* videoProcessor, VideoProcessing_ErrorCode error, void* userData)
|
||||
void OnError(OH_VideoProcessing* videoProcessor, VideoProcessing_ErrorCode error, void* userData)
|
||||
{
|
||||
(void)videoProcessor;
|
||||
(void)error;
|
||||
(void)userData;
|
||||
}
|
||||
|
||||
static void OnState(OH_VideoProcessing* videoProcessor, VideoProcessing_State state, void* userData)
|
||||
void OnState(OH_VideoProcessing* videoProcessor, VideoProcessing_State state, void* userData)
|
||||
{
|
||||
(void)videoProcessor;
|
||||
(void)state;
|
||||
(void)userData;
|
||||
}
|
||||
|
||||
static void OnNewOutputBuffer(OH_VideoProcessing* videoProcessor, uint32_t index, void* userData)
|
||||
void OnNewOutputBuffer(OH_VideoProcessing* videoProcessor, uint32_t index, void* userData)
|
||||
{
|
||||
OH_VideoProcessing_RenderOutputBuffer(videoProcessor, index);
|
||||
}
|
||||
}
|
||||
|
||||
class VPEConsumerListener : public IBufferConsumerListener{
|
||||
public:
|
||||
|
||||
@@ -23,8 +23,11 @@ using namespace OHOS;
|
||||
using namespace std;
|
||||
constexpr int64_t NANOS_IN_SECOND = 1000000000L;
|
||||
constexpr int64_t NANOS_IN_MICRO = 1000L;
|
||||
constexpr int64_t SLEEP_MICROSECONDS = 33333L;
|
||||
constexpr int THREE = 3;
|
||||
|
||||
static int64_t GetSystemTimeUs()
|
||||
namespace OHOS {
|
||||
int64_t GetSystemTimeUs()
|
||||
{
|
||||
struct timespec now;
|
||||
(void)clock_gettime(CLOCK_BOOTTIME, &now);
|
||||
@@ -32,24 +35,25 @@ static int64_t GetSystemTimeUs()
|
||||
return nanoTime / NANOS_IN_MICRO;
|
||||
}
|
||||
|
||||
static void OnError(OH_VideoProcessing* videoProcessor, VideoProcessing_ErrorCode error, void* userData)
|
||||
void OnError(OH_VideoProcessing* videoProcessor, VideoProcessing_ErrorCode error, void* userData)
|
||||
{
|
||||
(void)videoProcessor;
|
||||
(void)error;
|
||||
(void)userData;
|
||||
}
|
||||
|
||||
static void OnState(OH_VideoProcessing* videoProcessor, VideoProcessing_State state, void* userData)
|
||||
void OnState(OH_VideoProcessing* videoProcessor, VideoProcessing_State state, void* userData)
|
||||
{
|
||||
(void)videoProcessor;
|
||||
(void)state;
|
||||
(void)userData;
|
||||
}
|
||||
|
||||
static void OnNewOutputBuffer(OH_VideoProcessing* videoProcessor, uint32_t index, void* userData)
|
||||
void OnNewOutputBuffer(OH_VideoProcessing* videoProcessor, uint32_t index, void* userData)
|
||||
{
|
||||
OH_VideoProcessing_RenderOutputBuffer(videoProcessor, index);
|
||||
}
|
||||
}
|
||||
|
||||
class VPEConsumerListener : public IBufferConsumerListener{
|
||||
public:
|
||||
@@ -153,13 +157,13 @@ int32_t VideoSample::InputFunc(const uint8_t *data, size_t size)
|
||||
err = OH_NativeBuffer_Map(nativeBuffer, &virAddr);
|
||||
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeBuffer_Map failed.");
|
||||
uint8_t *addr = reinterpret_cast<uint8_t *>(virAddr);
|
||||
memcpy_s(addr, config.stride * config.height * 3, data, size);
|
||||
memcpy_s(addr, config.stride * config.height * THREE, data, size);
|
||||
NativeWindowHandleOpt(inWindow, SET_UI_TIMESTAMP, GetSystemTimeUs());
|
||||
err = OH_NativeBuffer_Unmap(nativeBuffer);
|
||||
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeBuffer_Unmap failed.");
|
||||
err = OH_NativeWindow_NativeWindowFlushBuffer(inWindow, ohNativeWindowBuffer, -1, region);
|
||||
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeWindow_NativeWindowFlushBuffer failed.");
|
||||
usleep(33333);
|
||||
usleep(SLEEP_MICROSECONDS);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ constexpr int64_t NANOS_IN_MICRO = 1000L;
|
||||
constexpr int64_t SLEEP_MICROSECONDS = 33333L;
|
||||
constexpr int THREE = 3;
|
||||
|
||||
namespace {
|
||||
namespace OHOS {
|
||||
int64_t GetSystemTimeUs()
|
||||
{
|
||||
struct timespec now;
|
||||
|
||||
@@ -27,8 +27,9 @@ using namespace OHOS;
|
||||
using namespace std;
|
||||
constexpr int64_t NANOS_IN_SECOND = 1000000000L;
|
||||
constexpr int64_t NANOS_IN_MICRO = 1000L;
|
||||
constexpr int THREE = 3;
|
||||
|
||||
namespace {
|
||||
namespace OHOS {
|
||||
int64_t GetSystemTimeUs()
|
||||
{
|
||||
struct timespec now;
|
||||
@@ -159,7 +160,7 @@ int32_t VideoSample::InputFunc(const uint8_t *data, size_t size)
|
||||
err = OH_NativeBuffer_Map(nativeBuffer, &virAddr);
|
||||
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeBuffer_Map failed.");
|
||||
uint8_t *addr = reinterpret_cast<uint8_t *>(virAddr);
|
||||
memcpy_s(addr, config.stride * config.height * 3, data, size);
|
||||
memcpy_s(addr, config.stride * config.height * THREE, data, size);
|
||||
NativeWindowHandleOpt(inWindow, SET_UI_TIMESTAMP, GetSystemTimeUs());
|
||||
err = OH_NativeBuffer_Unmap(nativeBuffer);
|
||||
CHECK_AND_RETURN_RET(err == 0, err, "OH_NativeBuffer_Unmap failed.");
|
||||
|
||||
Reference in New Issue
Block a user