static bool gEncoderSupported;
static void *gHalHandleDec;
static void *gHalHandleEnc;
-static void *gCurrentHandle;
static guint gTimeoutSourceID;
static guint gFeedCount;
static guint gOutputCount;
static GMainLoop *gMainLoop;
-/*
- * main class
- */
-class CodecHalTest : public testing::Test
+class CodecHalTest
{
public:
- virtual void SetUp()
- {
- gDecoderSupported = true;
- gEncoderSupported = true;
-
- dec_ret = hal_codec_init(HAL_CODEC_TYPE_DECODER, &gHalHandleDec);
- if (dec_ret == HAL_CODEC_ERROR_NOT_SUPPORTED) {
- cout << "Codec HAL[Decoder] Not Supported" << endl;
- gDecoderSupported = false;
- } else if (dec_ret == HAL_CODEC_ERROR_NONE) {
- cout << "Codec HAL[Decoder] init - handle: " << gHalHandleDec << endl;
- } else {
- cout << "Codec HAL[Decoder] init failed " << dec_ret << endl;
- }
-
- enc_ret = hal_codec_init(HAL_CODEC_TYPE_ENCODER, &gHalHandleEnc);
- if (enc_ret == HAL_CODEC_ERROR_NOT_SUPPORTED) {
- cout << "Codec HAL[Encoder] Not Supported" << endl;
- gDecoderSupported = false;
- } else if (enc_ret == HAL_CODEC_ERROR_NONE) {
- cout << "Codec HAL[Encoder] init - handle: " << gHalHandleEnc << endl;
- } else {
- cout << "Codec HAL[Encoder] init failed " << enc_ret << endl;
- }
- }
-
- virtual void TearDown()
- {
- if (gHalHandleDec) {
- cout << "Codec HAL[Decoder] deinit - handle: " << gHalHandleDec << endl;
- hal_codec_deinit(gHalHandleDec);
- gHalHandleDec = nullptr;
- }
-
- if (gHalHandleEnc) {
- cout << "Codec HAL[Decoder] deinit - handle: " << gHalHandleEnc << endl;
- hal_codec_deinit(gHalHandleEnc);
- gHalHandleEnc = nullptr;
- }
-
- ReleaseContents();
-
- return;
- }
-
static void DumpBuffer(hal_codec_buffer_s *buffer, const char *dumpPath)
{
static int dumpCount = 0;
}
dumpCount++;
- cout << "Dump[count:" << dumpCount << "] buffer size[" << totalWrite << "]" << endl;
+ cout << "Dump[" << dumpPath << ", count:" << dumpCount << "] buffer size[" << totalWrite << "]" << endl;
fout.close();
}
static int MessageCb(hal_codec_message_s *message, void *user_data)
{
+ void *halHandle = user_data;
+
if (!message) {
cout << "Codec HAL : NULL message" << endl;
return 0;
if (message->buffer->meta.flags & HAL_CODEC_BUFFER_FLAG_EOS) {
cout << "[OUTPUT_BUFFER] Got EOS(output count: " << gOutputCount;
cout << "), remove timeout source " << gTimeoutSourceID << endl;
- hal_codec_release_output_buffer(gCurrentHandle, message->buffer->index);
+ hal_codec_release_output_buffer(halHandle, message->buffer->index);
g_source_remove(gTimeoutSourceID);
g_main_loop_quit(gMainLoop);
break;
cout << "[OUTPUT_BUFFER] index: " << message->buffer->index << endl;
- if (g_dump_decoder_output && gCurrentHandle == gHalHandleDec)
+ if (g_dump_decoder_output)
DumpBuffer(message->buffer, "/home/owner/media/dump.yuv");
- if (g_dump_encoder_output && gCurrentHandle == gHalHandleEnc)
- DumpBuffer(message->buffer, "/home/owner/media/dump.h264");
-
- hal_codec_release_output_buffer(gCurrentHandle, message->buffer->index);
+ hal_codec_release_output_buffer(halHandle, message->buffer->index);
break;
default:
cout << "[UNHANDLED MSG] type: " << message->type << endl;
mappedFileContents_ = nullptr;
}
+ bool CheckCurrentState(void *handle, hal_codec_state_e state)
+ {
+ hal_codec_state_e state_;
+ if (hal_codec_get_state(handle, &state_) != HAL_CODEC_ERROR_NONE) {
+ cout << "get_state failed " << ret << endl;
+ return false;
+ }
+
+ return (state_ == state);
+ }
+
+ GMappedFile *mappedFile_ {};
+ gsize mappedFileLength_ {};
+ gchar *mappedFileContents_ {};
+ gsize mappedFileOffset_ {};
+ hal_codec_buffer_s buffer_[CONTENTS_H264_FRAME_NUM + 1] {};
+};
+
+
+class CodecHalTestDecoder : public testing::Test, public CodecHalTest
+{
+ public:
+ virtual void SetUp()
+ {
+ gDecoderSupported = true;
+
+ dec_ret = hal_codec_init(HAL_CODEC_TYPE_DECODER, &gHalHandleDec);
+ if (dec_ret == HAL_CODEC_ERROR_NOT_SUPPORTED) {
+ cout << "Codec HAL[Decoder] Not Supported" << endl;
+ gDecoderSupported = false;
+ } else if (dec_ret == HAL_CODEC_ERROR_NONE) {
+ cout << "Codec HAL[Decoder] init - handle: " << gHalHandleDec << endl;
+ } else {
+ cout << "Codec HAL[Decoder] init failed " << dec_ret << endl;
+ }
+ }
+
+ virtual void TearDown()
+ {
+ if (gHalHandleDec) {
+ cout << "Codec HAL[Decoder] deinit - handle: " << gHalHandleDec << endl;
+ hal_codec_deinit(gHalHandleDec);
+ gHalHandleDec = nullptr;
+ }
+
+ ReleaseContents();
+
+ return;
+ }
+
int FeedDataDecode(void)
{
memset(&buffer_[gFeedCount], 0x0, sizeof(hal_codec_buffer_s));
return G_SOURCE_CONTINUE;
}
}
+};
+
+
+class CodecHalTestEncoder : public testing::Test, public CodecHalTest
+{
+ public:
+ virtual void SetUp()
+ {
+ gEncoderSupported = true;
+
+ enc_ret = hal_codec_init(HAL_CODEC_TYPE_ENCODER, &gHalHandleEnc);
+ if (enc_ret == HAL_CODEC_ERROR_NOT_SUPPORTED) {
+ cout << "Codec HAL[Encoder] Not Supported" << endl;
+ gDecoderSupported = false;
+ } else if (enc_ret == HAL_CODEC_ERROR_NONE) {
+ cout << "Codec HAL[Encoder] init - handle: " << gHalHandleEnc << endl;
+ } else {
+ cout << "Codec HAL[Encoder] init failed " << enc_ret << endl;
+ }
+ }
+
+ virtual void TearDown()
+ {
+ if (gHalHandleEnc) {
+ cout << "Codec HAL[Decoder] deinit - handle: " << gHalHandleEnc << endl;
+ hal_codec_deinit(gHalHandleEnc);
+ gHalHandleEnc = nullptr;
+ }
+
+ ReleaseContents();
+
+ return;
+ }
void EncodeDataNew(void)
{
cout << "[FeedDataEncode] buffer[" << gFeedCount << "] " << &buffer_[gFeedCount] << endl;
} else {
+ buffer_[gFeedCount].memory.num_fd = 0;
buffer_[gFeedCount].meta.flags = HAL_CODEC_BUFFER_FLAG_EOS;
cout << "[FeedDataEncode] Send EOS" << endl;
return G_SOURCE_CONTINUE;
}
- bool CheckCurrentState(void *handle, hal_codec_state_e state)
- {
- hal_codec_state_e state_;
- if (hal_codec_get_state(handle, &state_) != HAL_CODEC_ERROR_NONE) {
- cout << "get_state failed " << ret << endl;
- return false;
- }
-
- return (state_ == state);
- }
-
- GMappedFile *mappedFile_ {};
- gsize mappedFileLength_ {};
- gchar *mappedFileContents_ {};
- gsize mappedFileOffset_ {};
- hal_codec_buffer_s buffer_[CONTENTS_H264_FRAME_NUM + 1] {};
tbm_surface_h tSurface_ {};
tbm_surface_info_s tsInfo_ {};
tbm_bo tBo_[TBM_SURF_PLANE_MAX] {};
int tFd_[TBM_SURF_PLANE_MAX] {};
};
+
/**
* @testcase DecoderInitP
* @since_tizen 9.0
* @precondition None
* @postcondition None
*/
-TEST_F(CodecHalTest, DecoderInitP)
+TEST_F(CodecHalTestDecoder, DecoderInitP)
{
DECODER_SUPPORT_CHECK;
* @precondition None
* @postcondition None
*/
-TEST_F(CodecHalTest, DecoderDeinitP)
+TEST_F(CodecHalTestDecoder, DecoderDeinitP)
{
void *hal_handle = nullptr;
* @precondition None
* @postcondition None
*/
-TEST_F(CodecHalTest, DecoderConfigureReleaseP)
+TEST_F(CodecHalTestDecoder, DecoderConfigureReleaseP)
{
DECODER_SUPPORT_CHECK;
* @precondition None
* @postcondition None
*/
-TEST_F(CodecHalTest, DecoderStartStopP)
+TEST_F(CodecHalTestDecoder, DecoderStartStopP)
{
DECODER_SUPPORT_CHECK;
HAL_CODEC_FORMAT_H264, HAL_CODEC_FORMAT_NV12, false);
ASSERT_EQ(ret, HAL_CODEC_ERROR_NONE);
- gCurrentHandle = gHalHandleDec;
-
- ret = hal_codec_start(gHalHandleDec, CodecHalTest::MessageCb, nullptr);
+ ret = hal_codec_start(gHalHandleDec, CodecHalTestDecoder::MessageCb, gHalHandleDec);
ASSERT_EQ(ret, HAL_CODEC_ERROR_NONE);
ret = hal_codec_stop(gHalHandleDec);
* @precondition None
* @postcondition None
*/
-TEST_F(CodecHalTest, DecoderDecodeP)
+TEST_F(CodecHalTestDecoder, DecoderDecodeP)
{
DECODER_SUPPORT_CHECK;
ASSERT_EQ(ret, HAL_CODEC_ERROR_NONE);
ASSERT_TRUE(CheckCurrentState(gHalHandleDec, HAL_CODEC_STATE_CONFIGURED));
- gCurrentHandle = gHalHandleDec;
-
- ret = hal_codec_start(gHalHandleDec, CodecHalTest::MessageCb, nullptr);
+ ret = hal_codec_start(gHalHandleDec, CodecHalTestDecoder::MessageCb, gHalHandleDec);
ASSERT_EQ(ret, HAL_CODEC_ERROR_NONE);
ASSERT_TRUE(CheckCurrentState(gHalHandleDec, HAL_CODEC_STATE_STARTED));
gOutputCount = 0;
g_timeout_add(50, [](gpointer user_data) -> gboolean {
- CodecHalTest *self = (CodecHalTest *)user_data;
+ CodecHalTestDecoder *self = (CodecHalTestDecoder *)user_data;
return self->FeedDataDecode();
}, this);
* @precondition None
* @postcondition None
*/
-TEST_F(CodecHalTest, EncoderInitP)
+TEST_F(CodecHalTestEncoder, EncoderInitP)
{
ENCODER_SUPPORT_CHECK;
* @precondition None
* @postcondition None
*/
-TEST_F(CodecHalTest, EncoderDeinitP)
+TEST_F(CodecHalTestEncoder, EncoderDeinitP)
{
void *hal_handle = nullptr;
* @precondition None
* @postcondition None
*/
-TEST_F(CodecHalTest, EncoderConfigureReleaseP)
+TEST_F(CodecHalTestEncoder, EncoderConfigureReleaseP)
{
ENCODER_SUPPORT_CHECK;
* @precondition None
* @postcondition None
*/
-TEST_F(CodecHalTest, EncoderStartStopP)
+TEST_F(CodecHalTestEncoder, EncoderStartStopP)
{
ENCODER_SUPPORT_CHECK;
HAL_CODEC_FORMAT_NV12, HAL_CODEC_FORMAT_H264, false);
ASSERT_EQ(ret, HAL_CODEC_ERROR_NONE);
- gCurrentHandle = gHalHandleEnc;
-
- ret = hal_codec_start(gHalHandleEnc, CodecHalTest::MessageCb, nullptr);
+ ret = hal_codec_start(gHalHandleEnc, CodecHalTestEncoder::MessageCb, gHalHandleEnc);
ASSERT_EQ(ret, HAL_CODEC_ERROR_NONE);
ret = hal_codec_stop(gHalHandleEnc);
* @precondition None
* @postcondition None
*/
-TEST_F(CodecHalTest, EncoderEncodeP)
+TEST_F(CodecHalTestEncoder, EncoderEncodeP)
{
ENCODER_SUPPORT_CHECK;
ASSERT_EQ(ret, HAL_CODEC_ERROR_NONE);
ASSERT_TRUE(CheckCurrentState(gHalHandleEnc, HAL_CODEC_STATE_CONFIGURED));
- gCurrentHandle = gHalHandleEnc;
-
- ret = hal_codec_start(gHalHandleEnc, CodecHalTest::MessageCb, nullptr);
+ ret = hal_codec_start(gHalHandleEnc, CodecHalTestEncoder::MessageCb, gHalHandleEnc);
ASSERT_EQ(ret, HAL_CODEC_ERROR_NONE);
ASSERT_TRUE(CheckCurrentState(gHalHandleEnc, HAL_CODEC_STATE_STARTED));
gOutputCount = 0;
g_timeout_add(50, [](gpointer user_data) -> gboolean {
- CodecHalTest *self = (CodecHalTest *)user_data;
+ CodecHalTestEncoder *self = (CodecHalTestEncoder *)user_data;
return self->FeedDataEncode();
}, this);