Added refcount getter to media_format 62/275562/1
authordesperadok <heechul.jeon@samsung.com>
Thu, 26 May 2022 08:14:54 +0000 (17:14 +0900)
committerdesperadok <heechul.jeon@samsung.com>
Thu, 26 May 2022 08:28:28 +0000 (17:28 +0900)
Change-Id: I63185067d0a02a0d8052a6a650b94c6cadb2e584
Signed-off-by: desperadok <heechul.jeon@samsung.com>
include/media_format_internal.h [new file with mode: 0644]
src/media_format_internal.c [new file with mode: 0644]
unittest/unittest.cpp

diff --git a/include/media_format_internal.h b/include/media_format_internal.h
new file mode 100644 (file)
index 0000000..a94ec89
--- /dev/null
@@ -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 <stdint.h>
+#include <tizen.h>
+#include <media_format.h>
+
+#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 (file)
index 0000000..cf02762
--- /dev/null
@@ -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 <stdio.h>
+// #include <stdlib.h>
+// #include <string.h>
+
+#include <dlog.h>
+#include <media_format.h>
+#include <media_format_private.h>
+
+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;
+}
index 3cdc49cd5bd8ac4780575fceb332ac1c5f881883..43a7a9fd7dcf7df6ebd9ca7f3081df42ad47ce04 100644 (file)
@@ -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);