From: desperadok Date: Thu, 26 May 2022 08:14:54 +0000 (+0900) Subject: Added refcount getter to media_format X-Git-Tag: submit/unittc/20220615.013956~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F62%2F275562%2F1;p=platform%2Fcore%2Fapi%2Fmediatool.git Added refcount getter to media_format Change-Id: I63185067d0a02a0d8052a6a650b94c6cadb2e584 Signed-off-by: desperadok --- diff --git a/include/media_format_internal.h b/include/media_format_internal.h new file mode 100644 index 0000000..a94ec89 --- /dev/null +++ b/include/media_format_internal.h @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2022 Samsung Electronics Co., Ltd 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 __TIZEN_MEDIA_FORMAT_INTERNAL_H__ +#define __TIZEN_MEDIA_FORMAT_INTERNAL_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file media_format_internal.h + * @brief This file contains the media format internal API. + */ + +/** + * @addtogroup CAPI_MEDIA_TOOL_MEDIA_FORMAT_INTERNAL_MODULE + * @{ + */ + +/** + * @brief Get reference count of #media_format_h object. + * @since_tizen 7.0 + * @param[in] fmt exist #media_format_h + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #MEDIA_FORMAT_ERROR_NONE Successful + * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter + * @see media_format_ref() + * @see media_format_unref() + */ +int media_format_get_refcount(media_format_h fmt, int *ref_count); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_MEDIA_FORMAT_INTERNAL_H__ */ diff --git a/src/media_format_internal.c b/src/media_format_internal.c new file mode 100644 index 0000000..cf02762 --- /dev/null +++ b/src/media_format_internal.c @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2022 Samsung Electronics Co., Ltd 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. +*/ +// #include +// #include +// #include + +#include +#include +#include + +int media_format_get_refcount(media_format_h fmt, int *ref_count) +{ + MEDIA_FORMAT_INSTANCE_CHECK(fmt); + MEDIA_FORMAT_NULL_ARG_CHECK(ref_count); + + media_format_s *fmt_handle; + + *ref_count = MEDIA_FORMAT_GET_REFCOUNT(fmt); + + LOGI("format[%p] ref_count[%d]", fmt, *ref_count); + + return MEDIA_FORMAT_ERROR_NONE; +} diff --git a/unittest/unittest.cpp b/unittest/unittest.cpp index 3cdc49c..43a7a9f 100644 --- a/unittest/unittest.cpp +++ b/unittest/unittest.cpp @@ -16,6 +16,7 @@ #include "media_tool_gtest.h" #include "media_format.h" +#include "media_format_internal.h" using ::testing::InitGoogleTest; using ::testing::Test; @@ -41,6 +42,19 @@ TEST(MediaToolTest, media_tool_gtest_create) media_format_unref(fmt); } +TEST(MediaToolTest, media_tool_gtest_refcount_init) +{ + media_format_h fmt; + int ref_count; + int ret = media_format_create(&fmt); + ASSERT_EQ(ret, MEDIA_FORMAT_ERROR_NONE); + + media_format_get_refcount(fmt, &ref_count); + ASSERT_EQ(ref_count, 1); + + media_format_unref(fmt); +} + int main(int argc, char **argv) { InitGoogleTest(&argc, argv);