Update file format 56/315556/3 accepted/tizen/unified/20240806.010604 accepted/tizen/unified/20240815.163637 accepted/tizen/unified/dev/20240807.092936 accepted/tizen/unified/toolchain/20240812.130149 accepted/tizen/unified/x/20240806.104707 accepted/tizen/unified/x/asan/20240813.224514
authorYoungHun Kim <yh8004.kim@samsung.com>
Fri, 2 Aug 2024 08:36:21 +0000 (17:36 +0900)
committerYoungHun Kim <yh8004.kim@samsung.com>
Fri, 2 Aug 2024 09:07:06 +0000 (18:07 +0900)
 - Remove CRLF line terminators

Change-Id: I553d841974802698ab66836e7b152fae826f917b

32 files changed:
LICENSE.APLv2
include/rm_api.h
include/rm_module_api.h
include/rm_resource.h
include_internal/rm_callback.h
include_internal/rm_dbus.h
include_internal/rm_debug.h
include_internal/rm_internal.h
include_internal/rm_msg.h
packaging/resource-manager.spec
src/rm_dbus.cpp
src/rm_debug.cpp
src/rm_module_api.cpp
src/rm_msg.cpp
ut/testcase/TCCallbackListener.cpp
ut/testcase/TCCallbackListener.h
ut/testcase/TCPlayer.cpp
ut/testcase/TCPlayer.h
ut/testcase/TCResource.cpp
ut/testcase/TCResource.h
ut/testcase/common.cpp
ut/testcase/ut_common.h
ut/testcase/ut_tc_8k.cpp
ut/testcase/ut_tc_interaction_sound.cpp
ut/testcase/ut_tc_multiview.cpp
ut/testcase/ut_tc_multiview_not_support.cpp
ut/testcase/ut_tc_resource.cpp
ut/testcase/ut_tc_resource_scaler.cpp
ut/testcase/ut_tc_video_dec_ai.cpp
ut/testcase/ut_tc_video_dec_portrait.cpp
ut/testcase/ut_tc_virtual_scaler.cpp
ut/testcase/ut_tc_vr360.cpp

index bbe9d02f324e5a6bb343e5bc18f86dce1dfb833d..f94008a3a3ecf62c44fa318348e32e36b3e44dfd 100644 (file)
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
-\r
-                                 Apache License\r
-                           Version 2.0, January 2004\r
-                        http://www.apache.org/licenses/\r
-\r
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
-\r
-   1. Definitions.\r
-\r
-      "License" shall mean the terms and conditions for use, reproduction,\r
-      and distribution as defined by Sections 1 through 9 of this document.\r
-\r
-      "Licensor" shall mean the copyright owner or entity authorized by\r
-      the copyright owner that is granting the License.\r
-\r
-      "Legal Entity" shall mean the union of the acting entity and all\r
-      other entities that control, are controlled by, or are under common\r
-      control with that entity. For the purposes of this definition,\r
-      "control" means (i) the power, direct or indirect, to cause the\r
-      direction or management of such entity, whether by contract or\r
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
-      outstanding shares, or (iii) beneficial ownership of such entity.\r
-\r
-      "You" (or "Your") shall mean an individual or Legal Entity\r
-      exercising permissions granted by this License.\r
-\r
-      "Source" form shall mean the preferred form for making modifications,\r
-      including but not limited to software source code, documentation\r
-      source, and configuration files.\r
-\r
-      "Object" form shall mean any form resulting from mechanical\r
-      transformation or translation of a Source form, including but\r
-      not limited to compiled object code, generated documentation,\r
-      and conversions to other media types.\r
-\r
-      "Work" shall mean the work of authorship, whether in Source or\r
-      Object form, made available under the License, as indicated by a\r
-      copyright notice that is included in or attached to the work\r
-      (an example is provided in the Appendix below).\r
-\r
-      "Derivative Works" shall mean any work, whether in Source or Object\r
-      form, that is based on (or derived from) the Work and for which the\r
-      editorial revisions, annotations, elaborations, or other modifications\r
-      represent, as a whole, an original work of authorship. For the purposes\r
-      of this License, Derivative Works shall not include works that remain\r
-      separable from, or merely link (or bind by name) to the interfaces of,\r
-      the Work and Derivative Works thereof.\r
-\r
-      "Contribution" shall mean any work of authorship, including\r
-      the original version of the Work and any modifications or additions\r
-      to that Work or Derivative Works thereof, that is intentionally\r
-      submitted to Licensor for inclusion in the Work by the copyright owner\r
-      or by an individual or Legal Entity authorized to submit on behalf of\r
-      the copyright owner. For the purposes of this definition, "submitted"\r
-      means any form of electronic, verbal, or written communication sent\r
-      to the Licensor or its representatives, including but not limited to\r
-      communication on electronic mailing lists, source code control systems,\r
-      and issue tracking systems that are managed by, or on behalf of, the\r
-      Licensor for the purpose of discussing and improving the Work, but\r
-      excluding communication that is conspicuously marked or otherwise\r
-      designated in writing by the copyright owner as "Not a Contribution."\r
-\r
-      "Contributor" shall mean Licensor and any individual or Legal Entity\r
-      on behalf of whom a Contribution has been received by Licensor and\r
-      subsequently incorporated within the Work.\r
-\r
-   2. Grant of Copyright License. Subject to the terms and conditions of\r
-      this License, each Contributor hereby grants to You a perpetual,\r
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
-      copyright license to reproduce, prepare Derivative Works of,\r
-      publicly display, publicly perform, sublicense, and distribute the\r
-      Work and such Derivative Works in Source or Object form.\r
-\r
-   3. Grant of Patent License. Subject to the terms and conditions of\r
-      this License, each Contributor hereby grants to You a perpetual,\r
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
-      (except as stated in this section) patent license to make, have made,\r
-      use, offer to sell, sell, import, and otherwise transfer the Work,\r
-      where such license applies only to those patent claims licensable\r
-      by such Contributor that are necessarily infringed by their\r
-      Contribution(s) alone or by combination of their Contribution(s)\r
-      with the Work to which such Contribution(s) was submitted. If You\r
-      institute patent litigation against any entity (including a\r
-      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
-      or a Contribution incorporated within the Work constitutes direct\r
-      or contributory patent infringement, then any patent licenses\r
-      granted to You under this License for that Work shall terminate\r
-      as of the date such litigation is filed.\r
-\r
-   4. Redistribution. You may reproduce and distribute copies of the\r
-      Work or Derivative Works thereof in any medium, with or without\r
-      modifications, and in Source or Object form, provided that You\r
-      meet the following conditions:\r
-\r
-      (a) You must give any other recipients of the Work or\r
-          Derivative Works a copy of this License; and\r
-\r
-      (b) You must cause any modified files to carry prominent notices\r
-          stating that You changed the files; and\r
-\r
-      (c) You must retain, in the Source form of any Derivative Works\r
-          that You distribute, all copyright, patent, trademark, and\r
-          attribution notices from the Source form of the Work,\r
-          excluding those notices that do not pertain to any part of\r
-          the Derivative Works; and\r
-\r
-      (d) If the Work includes a "NOTICE" text file as part of its\r
-          distribution, then any Derivative Works that You distribute must\r
-          include a readable copy of the attribution notices contained\r
-          within such NOTICE file, excluding those notices that do not\r
-          pertain to any part of the Derivative Works, in at least one\r
-          of the following places: within a NOTICE text file distributed\r
-          as part of the Derivative Works; within the Source form or\r
-          documentation, if provided along with the Derivative Works; or,\r
-          within a display generated by the Derivative Works, if and\r
-          wherever such third-party notices normally appear. The contents\r
-          of the NOTICE file are for informational purposes only and\r
-          do not modify the License. You may add Your own attribution\r
-          notices within Derivative Works that You distribute, alongside\r
-          or as an addendum to the NOTICE text from the Work, provided\r
-          that such additional attribution notices cannot be construed\r
-          as modifying the License.\r
-\r
-      You may add Your own copyright statement to Your modifications and\r
-      may provide additional or different license terms and conditions\r
-      for use, reproduction, or distribution of Your modifications, or\r
-      for any such Derivative Works as a whole, provided Your use,\r
-      reproduction, and distribution of the Work otherwise complies with\r
-      the conditions stated in this License.\r
-\r
-   5. Submission of Contributions. Unless You explicitly state otherwise,\r
-      any Contribution intentionally submitted for inclusion in the Work\r
-      by You to the Licensor shall be under the terms and conditions of\r
-      this License, without any additional terms or conditions.\r
-      Notwithstanding the above, nothing herein shall supersede or modify\r
-      the terms of any separate license agreement you may have executed\r
-      with Licensor regarding such Contributions.\r
-\r
-   6. Trademarks. This License does not grant permission to use the trade\r
-      names, trademarks, service marks, or product names of the Licensor,\r
-      except as required for reasonable and customary use in describing the\r
-      origin of the Work and reproducing the content of the NOTICE file.\r
-\r
-   7. Disclaimer of Warranty. Unless required by applicable law or\r
-      agreed to in writing, Licensor provides the Work (and each\r
-      Contributor provides its Contributions) on an "AS IS" BASIS,\r
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
-      implied, including, without limitation, any warranties or conditions\r
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
-      PARTICULAR PURPOSE. You are solely responsible for determining the\r
-      appropriateness of using or redistributing the Work and assume any\r
-      risks associated with Your exercise of permissions under this License.\r
-\r
-   8. Limitation of Liability. In no event and under no legal theory,\r
-      whether in tort (including negligence), contract, or otherwise,\r
-      unless required by applicable law (such as deliberate and grossly\r
-      negligent acts) or agreed to in writing, shall any Contributor be\r
-      liable to You for damages, including any direct, indirect, special,\r
-      incidental, or consequential damages of any character arising as a\r
-      result of this License or out of the use or inability to use the\r
-      Work (including but not limited to damages for loss of goodwill,\r
-      work stoppage, computer failure or malfunction, or any and all\r
-      other commercial damages or losses), even if such Contributor\r
-      has been advised of the possibility of such damages.\r
-\r
-   9. Accepting Warranty or Additional Liability. While redistributing\r
-      the Work or Derivative Works thereof, You may choose to offer,\r
-      and charge a fee for, acceptance of support, warranty, indemnity,\r
-      or other liability obligations and/or rights consistent with this\r
-      License. However, in accepting such obligations, You may act only\r
-      on Your own behalf and on Your sole responsibility, not on behalf\r
-      of any other Contributor, and only if You agree to indemnify,\r
-      defend, and hold each Contributor harmless for any liability\r
-      incurred by, or claims asserted against, such Contributor by reason\r
-      of your accepting any such warranty or additional liability.\r
-\r
-   END OF TERMS AND CONDITIONS\r
-\r
-   APPENDIX: How to apply the Apache License to your work.\r
-\r
-      To apply the Apache License to your work, attach the following\r
-      boilerplate notice, with the fields enclosed by brackets "[]"\r
-      replaced with your own identifying information. (Don't include\r
-      the brackets!)  The text should be enclosed in the appropriate\r
-      comment syntax for the file format. We also recommend that a\r
-      file or class name and description of purpose be included on the\r
-      same "printed page" as the copyright notice for easier\r
-      identification within third-party archives.\r
-\r
-   Copyright [yyyy] [name of copyright owner]\r
-\r
-   Licensed under the Apache License, Version 2.0 (the "License");\r
-   you may not use this file except in compliance with the License.\r
-   You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-\r
-\r
-\r
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
+
+
+
index 60167a7d80eb2754116d083c9da04641db5df8f7..4727db52b19037f666b67ee95f4f992e479e2eff 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __RM_API_H__\r
-#define __RM_API_H__\r
-\r
-#include <rm_type.h>\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-/**\r
- * @brief                               Register a player\r
- * @param[in] cb                        callback to receive resource conflict event\r
- * @param[in] data                      user data passed to cb\r
- * @param[out] handle                   handle got from resource manager\r
- * @param[in] consumer_info             player information such as player type, priority, window id and so on\r
- * @return int failure reason\r
- * @pre                                                                        None\r
- * @post                                                               None\r
- * @exception                                                  None\r
- */\r
-int rm_register(rm_resource_cb cb, void *data, int *handle, rm_consumer_info *consumer_info);\r
-\r
-/**\r
- * @brief                               Unregister a player\r
- * @param[in] handle                    handle to unregister\r
- * @return int failure reason\r
- * @pre                                                                        None\r
- * @post                                                               handle is deactivated.\n\r
- *                                                                             All resources which have been allocated to handle are released\r
- * @exception                                                  None\r
- */\r
-int rm_unregister(int handle);\r
-\r
-/**\r
- * @brief                               request to allocate resources\r
- * @param[in] handle                    handle to which resources are to be allocated\r
- * @param[in] requests                                 Resource information to allocate\r
- *         can request N resources simultaneously\r
- *         Ex. {Resource A, Resource A, Resouce B,¡¦. Resouce N}\r
- * @param[out] return_devices          allocated Device ID. Caller needs to release memory allocated by Resource Manager\r
- *                                      !!IMPORTANT!!!\r
- *                                      The member of structure(device_node, omx_comp_name) must be freed by API caller side.\r
- * @return int failure reason\r
- * @pre                                                                        None\r
- * @post                                                               None\r
- * @exception                                                  None\r
- */\r
-int rm_allocate_resources(int handle, const rm_category_request_s *requests, rm_device_return_s *return_devices);\r
-\r
-/**\r
- * @brief                               request to release resources\r
- * @param[in] handle                    handle to which resources have been allocated\r
- * @param[in] requests                             device information to release\r
- * @return int failure reason\r
- * @pre                                                                        None\r
- * @post                                                               None\r
- * @exception                                                  None\r
- */\r
-int rm_deallocate_resources(int handle, rm_device_request_s *requests);\r
-\r
-/**\r
- * @brief                               Query resource state\r
- * @param[in] handle                    handle gotten from rm_register()\r
- * @param[in] query_type                query type such as allocation\r
- * @param[in] requests                  Resource information to query\r
- * @param[out] query_result             0: not available\r
- *                                      1: available\r
- * @return int failure reason\r
- * @pre                                                                        None\r
- * @post                                                               None\r
- * @exception                                                  None\r
- */\r
-int rm_query(int handle, rm_query_type_e query_type, rm_category_request_s *requests, int *query_result);\r
-\r
-/**\r
- * @brief                               Set priority of handle\r
- * @param[in] handle                    handle to change priority\r
- * @param[in] priority                  new priority of handle\r
- * @return int failure reason\r
- * @pre                                                                        None\r
- * @post                                                               None\r
- * @exception                                                  None\r
- */\r
-int rm_set_priority(int handle, int priority);\r
-\r
-/**\r
- * @brief                               Set application id of handle\r
- * @param[in] handle                    handle to change application id\r
- * @param[in] app_id                   new application id of handle\r
- * @return int failure reason\r
- * @pre                                                                        None\r
- * @post                                                               None\r
- * @exception                                                  None\r
- */\r
-int rm_set_app_id(int handle, char *app_id);\r
-\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif // __RM_API_H__
\ No newline at end of file
+/*
+ * Copyright (c) 2024 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 __RM_API_H__
+#define __RM_API_H__
+
+#include <rm_type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief                               Register a player
+ * @param[in] cb                        callback to receive resource conflict event
+ * @param[in] data                      user data passed to cb
+ * @param[out] handle                   handle got from resource manager
+ * @param[in] consumer_info             player information such as player type, priority, window id and so on
+ * @return int failure reason
+ * @pre                                                                        None
+ * @post                                                               None
+ * @exception                                                  None
+ */
+int rm_register(rm_resource_cb cb, void *data, int *handle, rm_consumer_info *consumer_info);
+
+/**
+ * @brief                               Unregister a player
+ * @param[in] handle                    handle to unregister
+ * @return int failure reason
+ * @pre                                                                        None
+ * @post                                                               handle is deactivated.\n
+ *                                                                             All resources which have been allocated to handle are released
+ * @exception                                                  None
+ */
+int rm_unregister(int handle);
+
+/**
+ * @brief                               request to allocate resources
+ * @param[in] handle                    handle to which resources are to be allocated
+ * @param[in] requests                                 Resource information to allocate
+ *         can request N resources simultaneously
+ *         Ex. {Resource A, Resource A, Resouce B, Resouce N}
+ * @param[out] return_devices          allocated Device ID. Caller needs to release memory allocated by Resource Manager
+ *                                      !!IMPORTANT!!!
+ *                                      The member of structure(device_node, omx_comp_name) must be freed by API caller side.
+ * @return int failure reason
+ * @pre                                                                        None
+ * @post                                                               None
+ * @exception                                                  None
+ */
+int rm_allocate_resources(int handle, const rm_category_request_s *requests, rm_device_return_s *return_devices);
+
+/**
+ * @brief                               request to release resources
+ * @param[in] handle                    handle to which resources have been allocated
+ * @param[in] requests                             device information to release
+ * @return int failure reason
+ * @pre                                                                        None
+ * @post                                                               None
+ * @exception                                                  None
+ */
+int rm_deallocate_resources(int handle, rm_device_request_s *requests);
+
+/**
+ * @brief                               Query resource state
+ * @param[in] handle                    handle gotten from rm_register()
+ * @param[in] query_type                query type such as allocation
+ * @param[in] requests                  Resource information to query
+ * @param[out] query_result             0: not available
+ *                                      1: available
+ * @return int failure reason
+ * @pre                                                                        None
+ * @post                                                               None
+ * @exception                                                  None
+ */
+int rm_query(int handle, rm_query_type_e query_type, rm_category_request_s *requests, int *query_result);
+
+/**
+ * @brief                               Set priority of handle
+ * @param[in] handle                    handle to change priority
+ * @param[in] priority                  new priority of handle
+ * @return int failure reason
+ * @pre                                                                        None
+ * @post                                                               None
+ * @exception                                                  None
+ */
+int rm_set_priority(int handle, int priority);
+
+/**
+ * @brief                               Set application id of handle
+ * @param[in] handle                    handle to change application id
+ * @param[in] app_id                   new application id of handle
+ * @return int failure reason
+ * @pre                                                                        None
+ * @post                                                               None
+ * @exception                                                  None
+ */
+int rm_set_app_id(int handle, char *app_id);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif // __RM_API_H__
index 05ab413c55c2dd74136711222176eaf443d2c531..f2fdbcddcad002a05753031e818a06d189be0121 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __RM_MODULE_API_H__\r
-#define __RM_MODULE_API_H__\r
-\r
-#include <rm_type.h>\r
-#include <rm_resource.h>\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-/**\r
- * @brief The resource category option to select a resource\r
- * @remark This is supposed to be used by the resource center only\r
- * @version 3.0\r
- */\r
-typedef enum {\r
-       RM_FORCE_TO_MAIN = (0x1 << 27),\r
-       RM_FORCE_TO_SUB = (0x1 << 26)\r
-} rm_device_request_e;\r
-\r
-/**\r
- * @brief The resource collection\r
- * @remark This is supposed to be used by the resource center only\r
- * @version 4.0\r
- */\r
-typedef enum {\r
-       RM_RSC_COLLECTION_MAIN = 0,             /**< main resources */\r
-       RM_RSC_COLLECTION_ACTIVE_VIDEO_DECODER, /**< active video decoders */\r
-       RM_RSC_COLLECTION_AUDIO                 /**< audio resources (audio decoder, audio out) */\r
-} rm_rsc_collection_e;\r
-\r
-/**\r
- * @brief The audio out type\r
- * @remark This is supposed to be used by the resource center only\r
- * @version 3.0\r
- */\r
-typedef enum {\r
-       RM_AUDIO_OUT_NONE = 0,\r
-       RM_AUDIO_OUT_MAIN = 0x1,\r
-       RM_AUDIO_OUT_SUB = 0x2,\r
-} rm_audio_out_e;\r
-\r
-/**\r
- * @brief The video sampling format\r
- * @remark This is used as a return value of rm_resource_get_max_sampling_format()\r
- * @version 3.0\r
- */\r
-typedef enum {\r
-       RM_SAMPLING_FORMAT_ARGB = 0, /**< ARGB */\r
-       RM_SAMPLING_FORMAT_420, /**< YUV420 */\r
-       RM_SAMPLING_FORMAT_422, /**< YUV422 */\r
-       RM_SAMPLING_FORMAT_444 /**< YUV444 */\r
-} rm_sampling_format_e;\r
-\r
-/**\r
- * @brief The video resolution\r
- * @remark This is used as a return value of rm_resource_get_max_resolution()\r
- * @version 3.0\r
- */\r
-typedef enum {\r
-       RM_RESOLUTION_HD = 0, /**< HD */\r
-       RM_RESOLUTION_FHD, /**< FHD */\r
-       RM_RESOLUTION_4K, /**< 4K */\r
-       RM_RESOLUTION_8K /**< 8K */\r
-} rm_resolution_e;\r
-\r
-/**\r
- * @brief Get current resource state\r
- * @param[in] rsc_id resource id\r
- * @param[out] state current resource state\r
- * @return RM_OK on success, otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @version 3.0\r
- * @exception None\r
- */\r
-int rm_get_resource_state(int rsc_id, rm_resource_state_e *state);\r
-\r
-/**\r
- * @brief Get the resource list handle of video scaler\r
- * @param[out] list resource list handle\r
- * @return RM_OK on success, otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @version 3.0\r
- * @exception None\r
- * @remark\r
- * \li This API is supposed to be used by the resource center for internal use\r
- * \li Please do not use for other purpose\r
- * \li The returned list  must be freed by rm_free_resource_list() after use\r
- */\r
-int rm_get_scaler_state(rm_resource_list_h *list);\r
-\r
-/**\r
- * @brief Called when scaler state is changed\r
- * @param[out] scalers Scaler list\r
- * @param[out] data The user data passed from the callback registration function\r
- * @pre None\r
- * @post None\r
- * @version 3.0\r
- */\r
-typedef void (*scaler_state_change_cb)(rm_resource_list_h scalers, void *data);\r
-\r
-/**\r
- * @brief Register a callback to observe scaler state change\r
- * @details Once there is any state change of scaler, the registered callback will be invoked.\r
- * @param[in] cb The callback function to register\r
- * @param[in] data The user data to be passed to the callback function\r
- * @return @c RM_OK on success,\r
- *         otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li This API is supposed to be used by the resource center for internal use\r
- * \li Please do not use for other purpose\r
- */\r
-int rm_subscribe_scaler_state_change(scaler_state_change_cb cb, void *data);\r
-\r
-/**\r
- * @brief Unregister a callback which had been added to observe scaler state change\r
- * @param[in] cb The callback function to unregister\r
- * @return @c RM_OK on success,\r
- *         otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li This API is supposed to be used by the resource center for internal use\r
- * \li Please do not use for other purpose\r
- */\r
-int rm_unsubscribe_scaler_state_change(scaler_state_change_cb cb);\r
-\r
-/**\r
- * @brief Get virtual id of scaler\r
- * @param[in] scaler scaler handle\r
- * @return virtual id of scaler\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li This API is supposed to be used by the resource center for internal use\r
- * \li Please do not use for other purpose\r
- */\r
-int rm_scaler_get_virtual_id(rm_resource_h scaler);\r
-\r
-/**\r
- * @brief Get source id of scaler\r
- * @param[in] scaler scaler handle\r
- * @return source id of scaler\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li This API is supposed to be used by the resource center for internal use\r
- * \li Please do not use for other purpose\r
- */\r
-int rm_scaler_get_source_id(rm_resource_h scaler);\r
-\r
-/**\r
- * @brief Called when a resource state is changed\r
- * @param[out] state The resource state handle\r
- * @param[out] data The user data passed from the callback registration function\r
- * @pre None\r
- * @post None\r
- * @version 3.0\r
- * @remarks The data of the resource state handle can be accessed by the following APIs.\r
- *          rm_rsc_state_get_category()\r
- *          rm_rsc_state_get_id()\r
- *          rm_rsc_state_get_state()\r
- *          The passed resource state handle is valid in resource_state_change_cb() only.\r
- *          In other words, the passed resource state handle is freed once resource_state_change_cb() returns.\r
- *          Thus, need a deep copy in case information of the resource state handle is required outside of resource_state_change_cb().\r
- */\r
-typedef void (*resource_state_change_cb)(rm_resource_state_h state, void *data);\r
-\r
-/**\r
- * @brief Register a callback to observe resource state change\r
- * @details Once there is state change of a resource included in passed category, the registered callback will be invoked.\r
- * @param[in] category category id to observe\r
- * @param[in] cb The callback function to register\r
- * @param[in] data The user data to be passed to the callback function\r
- * @return @c RM_OK on success,\r
- *         otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_subscribe_resource_state_change(rm_rsc_category_e category, resource_state_change_cb cb, void *data);\r
-\r
-/**\r
- * @brief Unregister a callback which had been added to observe resource state change\r
- * @param[in] category category id to stop to observe\r
- * @param[in] cb The callback function to unregister\r
- * @return @c RM_OK on success,\r
- *         otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_unsubscribe_resource_state_change(rm_rsc_category_e category, resource_state_change_cb cb);\r
-\r
-/**\r
- * @brief Get category id of the state changed resource\r
- * @param[in] state The state changed resource handle\r
- * @return category id of the state changed resource handle on success,\r
- *         otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_rsc_state_get_category(rm_resource_state_h state);\r
-\r
-/**\r
- * @brief Get device id of the state changed resource\r
- * @param[in] state The state changed resource handle\r
- * @return device id of the state changed resource handle on success,\r
- *         otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_rsc_state_get_device_id(rm_resource_state_h state);\r
-\r
-/**\r
- * @brief Get state of the state changed resource\r
- * @param[in] state The state changed resource handle\r
- * @return state of the state changed resource handle on success,\r
- *         otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_rsc_state_get_state(rm_resource_state_h state);\r
-\r
-/**\r
- * @brief Get consumer id of the state changed resource\r
- * @param[in] state The state changed resource handle\r
- * @return consumer id of the state changed resource handle on success,\r
- *         otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_rsc_state_get_consumer_id(rm_resource_state_h state);\r
-\r
-/**\r
- * @brief Get app id of the state changed resource\r
- * @param[in] state The state changed resource handle\r
- * @return app id of the state changed resource handle on success,\r
- *         otherwise NULL\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-char *rm_rsc_state_get_app_id(rm_resource_state_h state);\r
-\r
-struct rm_conflict_resource;\r
-/**\r
- * @brief The conflicted resource handle\r
- */\r
-typedef struct rm_conflict_resource *rm_conflict_resource_h;\r
-\r
-/**\r
- * @brief Called when a resource conflict occurs\r
- * @param[out] resource The conflicted resource handle\r
- * @param[out] data The user data passed from the callback registration function\r
- * @pre None\r
- * @post None\r
- * @version 3.0\r
- * @remarks The data of the conflicted resource handle can be accessed by the following APIs.\r
- *          rm_conflict_get_category_id()\r
- *          rm_conflict_get_device_id()\r
- *          rm_conflict_get_consumer_id()\r
- *          rm_conflict_get_app_id()\r
- *          The passed conflicted resource handle is valid in rm_conflict_event_cb() only.\r
- *          In other words, the passed conflicted resource handle is freed once rm_conflict_event_cb() returns.\r
- *          Thus, need a deep copy in case information of the conflicted resource handle is required outside of rm_conflict_event_cb().\r
- */\r
-typedef void (*rm_conflict_event_cb)(rm_conflict_resource_h resource, void *data);\r
-\r
-/**\r
- * @brief Register a callback to observe resource conflict event.\r
- * @details Once there is a resource conflict, the registered callback will be invoked.\r
- * @param[in] cb The callback function to add\r
- * @param[in] data The user data to be passed to the callback function\r
- * @return @c RM_OK on success,\r
- *         otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_subscribe_resource_conflict_event(rm_conflict_event_cb cb, void *data);\r
-\r
-/**\r
- * @brief Unregister a callback which had been added to observe resource conflict event.\r
- * @param[in] cb The callback function to remove\r
- * @return @c RM_OK on success,\r
- *         otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_unsubscribe_resource_conflict_event(rm_conflict_event_cb cb);\r
-\r
-/**\r
- * @brief Gets resource category id of the conflicted resource\r
- * @param[in] rsc The conflicted resource handle\r
- * @return resource category id of the conflicted resource handle on success,\r
- *         otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_conflict_get_category_id(rm_conflict_resource_h rsc);\r
-\r
-/**\r
- * @brief Gets device id of the conflicted resource\r
- * @param[in] rsc The conflicted resource handle\r
- * @return device id of the conflicted resource handle on success,\r
- *         otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_conflict_get_device_id(rm_conflict_resource_h rsc);\r
-\r
-/**\r
- * @brief Gets consumer id of the conflicted resource\r
- * @param[in] rsc The conflicted resource handle\r
- * @return consumer id of the conflicted resource handle on success,\r
- *         otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @remarks The consumer id is an unique id which is assigned to a player as a result of rm_register().\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_conflict_get_consumer_id(rm_conflict_resource_h rsc);\r
-\r
-/**\r
- * @brief Gets application id of the conflicted resource\r
- * @param[in] rsc The conflicted resource handle\r
- * @return application id of the conflicted resource on success\r
- *         otherwise NULL\r
- * @pre None\r
- * @post None\r
- * @remarks In case any application id is not set by a player, NULL can be returned on success.\r
- * @exception None\r
- * @version 3.0\r
- */\r
-const char *rm_conflict_get_app_id(rm_conflict_resource_h rsc);\r
-\r
-/**\r
- * @brief Gets multiview zone id of the consumer that needs to release the conflicted resource\r
- * @param[in] rsc The conflicted resource handle\r
- * @return multiview zone id in case the conflicted resource is allocated to a multiview zone\r
- *         otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_conflict_get_multiview_zone_id_consumer(rm_conflict_resource_h rsc);\r
-\r
-/**\r
- * @brief Gets multiview zone id of the requester that caused this resource conflict\r
- * @param[in] rsc The conflicted resource handle\r
- * @return multiview zone id in case the requester is placed to a multiview zone\r
- *         otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- */\r
-int rm_conflict_get_multiview_zone_id_requester(rm_conflict_resource_h rsc);\r
-\r
-/**\r
- * @brief Unmask category option bits\r
- * @param[in] category resource category to unmask\r
- * @return unmasked category id\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- */\r
-int rm_unmask_category_options(int category);\r
-\r
-/**\r
- * @brief Find real device id which is mapped to virtual device id\r
- * @param[in] virtual_id virtual device id\r
- * @return positive real resource id on success, negative value on failure\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li This API is available for the scaler device supporting virtual device.\r
- */\r
-int rm_find_device_id(int virtual_id);\r
-\r
-/**\r
- * @brief Swap two resources\r
- * @param[in] device_id_a device id to swap\r
- * @param[in] device_id_b device id to swap\r
- * @return RM_OK on success, otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li This API is available for the scaler device supporting virtual device.\r
- * \li This API is supposed to be called by the resource center only\r
- */\r
-int rm_swap_resources(int device_id_a, int device_id_b);\r
-\r
-/**\r
- * @brief Swap two resources asynchronously\r
- * @param[in] device_id_a device id to swap\r
- * @param[in] device_id_b device id to swap\r
- * @return RM_OK on success, otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.1\r
- * @remark\r
- * \li This API is available for the scaler device supporting virtual device.\r
- * \li This API is supposed to be called by the resource center only\r
- */\r
-int rm_swap_resources_async(int device_id_a, int device_id_b);\r
-\r
-/**\r
- * @brief Restore resources that have been swapped by rm_swap_resources()\r
- * @param[in] category resource category to restore\r
- * @return RM_OK on success, otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li This API is supposed to be called by the resource center only\r
- */\r
-int rm_restore_resources(int category);\r
-\r
-/**\r
- * @brief Get the resource list handle of resource collection\r
- * @param[in] collection resource collection\r
- * @param[out] list resource list handle\r
- * @return RM_OK on success, otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li The returned list  must be freed by rm_free_resource_list() after use\r
- */\r
-int rm_get_resource_collection_state(rm_rsc_collection_e collection, rm_resource_list_h *list);\r
-\r
-/**\r
- * @brief Get application id of handle\r
- * @param[in] handle player handle returned by rm_register()\r
- * @param[out] app_id application id of handle\r
- * @return RM_OK on success, otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li This API is supposed to be called by the resource center only\r
- * \li Do not use other purpose\r
- */\r
-int rm_get_app_id(int handle, char**app_id);\r
-\r
-/**\r
- * @brief Get active audio out resources being used by handle\r
- * @param[in] handle player handle returned by rm_register()\r
- * @return positive value masked with rm_audio_out_e on success, otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li This API is supposed to be called by the resource center only\r
- * \li Do not use other purpose\r
- */\r
-int rm_get_active_audio_out(int handle);\r
-\r
-/**\r
- * @brief Get hw id of scaler assigned to passed multiview zone id\r
- * @param[in] zone_id multiview zone id\r
- * @param[out] id The hw id of scaler assigned to passed multiview zone id,\r
- * @return positive value on success, otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li This API is supposed to be called by the resource center only\r
- * \li Do not use other purpose\r
- */\r
-int rm_get_scaler_hw_id(int zone_id, int *id);\r
-\r
-/**\r
- * @brief Notify current resource policy\r
- * @param[in] policy resource policy\r
- * @return positive value on success, otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.1\r
- * @remark\r
- * \li This API is supposed to be called by the resource center only\r
- * \li Do not use other purpose\r
- */\r
-int rm_notify_resource_policy(int policy);\r
-\r
-/**\r
- * @brief Notify application's zone info in multiview\r
- * @param[in] app_id application id\r
- * @param[in] zone_id zone id\r
- * @return positive value on success, otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 5.0\r
- * @remark\r
- * \li This API is supposed to be called by the resource center only\r
- * \li Do not use other purpose\r
- */\r
-int rm_notify_app_zone_info_async(const char *app_id, int zone_id);\r
-\r
-/**\r
- * @brief Reclaim all resources allocated to the handle\r
- * @param[in] handle player handle returned by rm_register()\r
- * @return positive value on success, otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 4.0\r
- * @remark\r
- * \li This API is supposed to be called by the resource center only\r
- * \li Do not use other purpose\r
- */\r
-int rm_reclaim_resources(int handle);\r
-\r
-/**\r
- * @brief Reclaim all resources allocated to the application\r
- * @param[in] app_id application id\r
- * @param[in] notify true : notify resource conflict, false : skip to notify\r
- * @return positive value on success, otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 5.0\r
- * @remark\r
- * \li This API is supposed to be called by the resource center only\r
- * \li Do not use other purpose\r
- */\r
-int rm_reclaim_app_resources(const char *app_id, const bool notify);\r
-\r
-\r
-/**\r
- * @brief Reclaim all resources allocated to the application asynchronously\r
- * @param[in] app_id application id\r
- * @param[in] notify true : notify resource conflict, false : skip to notify\r
- * @return positive value on success, otherwise negative value\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 5.0\r
- * @remark\r
- * \li This API is supposed to be called by the resource center only\r
- * \li Do not use other purpose\r
- */\r
-int rm_reclaim_app_resources_async(const char *app_id, const bool notify);\r
-\r
-/**\r
- * @brief Reclaim all video decoders allocated to applications other than requester\r
- * @param[in] requester application id of the requester\r
- * @return RM_OK on success, otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 5.0\r
- * @remark\r
- * \li This API is supposed to be called by the camera framework only\r
- * \li Do not use for other purpose\r
- */\r
-int rm_reclaim_video_decoders(const char *requester);\r
-\r
-/**\r
- * @brief Check if the handle is valid or not\r
- * @param[in] handle player handle returned by rm_register()\r
- * @return true : player handle is valid, false : player handle is invalid\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 6.0\r
- * @remark\r
- * \li This API is supposed to be called by the resource center only\r
- * \li Do not use for other purpose\r
- */\r
-bool rm_active_player(const int handle);\r
-\r
-/**\r
- * @brief Check if the player is in progress of reclaiming resource\r
- * @param[in] handle player handle returned by rm_register()\r
- * @return true : reclaim is in progress against the player, false : reclaim is not in progress against the player\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @remark\r
- * \li This API is supposed to be called by the resource center only\r
- * \li Do not use for other purpose\r
- */\r
-bool rm_reclaimed_player(const int handle);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif //__RM_MODULE_API_H__\r
+/*
+ * Copyright (c) 2024 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 __RM_MODULE_API_H__
+#define __RM_MODULE_API_H__
+
+#include <rm_type.h>
+#include <rm_resource.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief The resource category option to select a resource
+ * @remark This is supposed to be used by the resource center only
+ * @version 3.0
+ */
+typedef enum {
+       RM_FORCE_TO_MAIN = (0x1 << 27),
+       RM_FORCE_TO_SUB = (0x1 << 26)
+} rm_device_request_e;
+
+/**
+ * @brief The resource collection
+ * @remark This is supposed to be used by the resource center only
+ * @version 4.0
+ */
+typedef enum {
+       RM_RSC_COLLECTION_MAIN = 0,             /**< main resources */
+       RM_RSC_COLLECTION_ACTIVE_VIDEO_DECODER, /**< active video decoders */
+       RM_RSC_COLLECTION_AUDIO                 /**< audio resources (audio decoder, audio out) */
+} rm_rsc_collection_e;
+
+/**
+ * @brief The audio out type
+ * @remark This is supposed to be used by the resource center only
+ * @version 3.0
+ */
+typedef enum {
+       RM_AUDIO_OUT_NONE = 0,
+       RM_AUDIO_OUT_MAIN = 0x1,
+       RM_AUDIO_OUT_SUB = 0x2,
+} rm_audio_out_e;
+
+/**
+ * @brief The video sampling format
+ * @remark This is used as a return value of rm_resource_get_max_sampling_format()
+ * @version 3.0
+ */
+typedef enum {
+       RM_SAMPLING_FORMAT_ARGB = 0, /**< ARGB */
+       RM_SAMPLING_FORMAT_420, /**< YUV420 */
+       RM_SAMPLING_FORMAT_422, /**< YUV422 */
+       RM_SAMPLING_FORMAT_444 /**< YUV444 */
+} rm_sampling_format_e;
+
+/**
+ * @brief The video resolution
+ * @remark This is used as a return value of rm_resource_get_max_resolution()
+ * @version 3.0
+ */
+typedef enum {
+       RM_RESOLUTION_HD = 0, /**< HD */
+       RM_RESOLUTION_FHD, /**< FHD */
+       RM_RESOLUTION_4K, /**< 4K */
+       RM_RESOLUTION_8K /**< 8K */
+} rm_resolution_e;
+
+/**
+ * @brief Get current resource state
+ * @param[in] rsc_id resource id
+ * @param[out] state current resource state
+ * @return RM_OK on success, otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @version 3.0
+ * @exception None
+ */
+int rm_get_resource_state(int rsc_id, rm_resource_state_e *state);
+
+/**
+ * @brief Get the resource list handle of video scaler
+ * @param[out] list resource list handle
+ * @return RM_OK on success, otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @version 3.0
+ * @exception None
+ * @remark
+ * \li This API is supposed to be used by the resource center for internal use
+ * \li Please do not use for other purpose
+ * \li The returned list  must be freed by rm_free_resource_list() after use
+ */
+int rm_get_scaler_state(rm_resource_list_h *list);
+
+/**
+ * @brief Called when scaler state is changed
+ * @param[out] scalers Scaler list
+ * @param[out] data The user data passed from the callback registration function
+ * @pre None
+ * @post None
+ * @version 3.0
+ */
+typedef void (*scaler_state_change_cb)(rm_resource_list_h scalers, void *data);
+
+/**
+ * @brief Register a callback to observe scaler state change
+ * @details Once there is any state change of scaler, the registered callback will be invoked.
+ * @param[in] cb The callback function to register
+ * @param[in] data The user data to be passed to the callback function
+ * @return @c RM_OK on success,
+ *         otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li This API is supposed to be used by the resource center for internal use
+ * \li Please do not use for other purpose
+ */
+int rm_subscribe_scaler_state_change(scaler_state_change_cb cb, void *data);
+
+/**
+ * @brief Unregister a callback which had been added to observe scaler state change
+ * @param[in] cb The callback function to unregister
+ * @return @c RM_OK on success,
+ *         otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li This API is supposed to be used by the resource center for internal use
+ * \li Please do not use for other purpose
+ */
+int rm_unsubscribe_scaler_state_change(scaler_state_change_cb cb);
+
+/**
+ * @brief Get virtual id of scaler
+ * @param[in] scaler scaler handle
+ * @return virtual id of scaler
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li This API is supposed to be used by the resource center for internal use
+ * \li Please do not use for other purpose
+ */
+int rm_scaler_get_virtual_id(rm_resource_h scaler);
+
+/**
+ * @brief Get source id of scaler
+ * @param[in] scaler scaler handle
+ * @return source id of scaler
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li This API is supposed to be used by the resource center for internal use
+ * \li Please do not use for other purpose
+ */
+int rm_scaler_get_source_id(rm_resource_h scaler);
+
+/**
+ * @brief Called when a resource state is changed
+ * @param[out] state The resource state handle
+ * @param[out] data The user data passed from the callback registration function
+ * @pre None
+ * @post None
+ * @version 3.0
+ * @remarks The data of the resource state handle can be accessed by the following APIs.
+ *          rm_rsc_state_get_category()
+ *          rm_rsc_state_get_id()
+ *          rm_rsc_state_get_state()
+ *          The passed resource state handle is valid in resource_state_change_cb() only.
+ *          In other words, the passed resource state handle is freed once resource_state_change_cb() returns.
+ *          Thus, need a deep copy in case information of the resource state handle is required outside of resource_state_change_cb().
+ */
+typedef void (*resource_state_change_cb)(rm_resource_state_h state, void *data);
+
+/**
+ * @brief Register a callback to observe resource state change
+ * @details Once there is state change of a resource included in passed category, the registered callback will be invoked.
+ * @param[in] category category id to observe
+ * @param[in] cb The callback function to register
+ * @param[in] data The user data to be passed to the callback function
+ * @return @c RM_OK on success,
+ *         otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+int rm_subscribe_resource_state_change(rm_rsc_category_e category, resource_state_change_cb cb, void *data);
+
+/**
+ * @brief Unregister a callback which had been added to observe resource state change
+ * @param[in] category category id to stop to observe
+ * @param[in] cb The callback function to unregister
+ * @return @c RM_OK on success,
+ *         otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+int rm_unsubscribe_resource_state_change(rm_rsc_category_e category, resource_state_change_cb cb);
+
+/**
+ * @brief Get category id of the state changed resource
+ * @param[in] state The state changed resource handle
+ * @return category id of the state changed resource handle on success,
+ *         otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+int rm_rsc_state_get_category(rm_resource_state_h state);
+
+/**
+ * @brief Get device id of the state changed resource
+ * @param[in] state The state changed resource handle
+ * @return device id of the state changed resource handle on success,
+ *         otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+int rm_rsc_state_get_device_id(rm_resource_state_h state);
+
+/**
+ * @brief Get state of the state changed resource
+ * @param[in] state The state changed resource handle
+ * @return state of the state changed resource handle on success,
+ *         otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+int rm_rsc_state_get_state(rm_resource_state_h state);
+
+/**
+ * @brief Get consumer id of the state changed resource
+ * @param[in] state The state changed resource handle
+ * @return consumer id of the state changed resource handle on success,
+ *         otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+int rm_rsc_state_get_consumer_id(rm_resource_state_h state);
+
+/**
+ * @brief Get app id of the state changed resource
+ * @param[in] state The state changed resource handle
+ * @return app id of the state changed resource handle on success,
+ *         otherwise NULL
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+char *rm_rsc_state_get_app_id(rm_resource_state_h state);
+
+struct rm_conflict_resource;
+/**
+ * @brief The conflicted resource handle
+ */
+typedef struct rm_conflict_resource *rm_conflict_resource_h;
+
+/**
+ * @brief Called when a resource conflict occurs
+ * @param[out] resource The conflicted resource handle
+ * @param[out] data The user data passed from the callback registration function
+ * @pre None
+ * @post None
+ * @version 3.0
+ * @remarks The data of the conflicted resource handle can be accessed by the following APIs.
+ *          rm_conflict_get_category_id()
+ *          rm_conflict_get_device_id()
+ *          rm_conflict_get_consumer_id()
+ *          rm_conflict_get_app_id()
+ *          The passed conflicted resource handle is valid in rm_conflict_event_cb() only.
+ *          In other words, the passed conflicted resource handle is freed once rm_conflict_event_cb() returns.
+ *          Thus, need a deep copy in case information of the conflicted resource handle is required outside of rm_conflict_event_cb().
+ */
+typedef void (*rm_conflict_event_cb)(rm_conflict_resource_h resource, void *data);
+
+/**
+ * @brief Register a callback to observe resource conflict event.
+ * @details Once there is a resource conflict, the registered callback will be invoked.
+ * @param[in] cb The callback function to add
+ * @param[in] data The user data to be passed to the callback function
+ * @return @c RM_OK on success,
+ *         otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+int rm_subscribe_resource_conflict_event(rm_conflict_event_cb cb, void *data);
+
+/**
+ * @brief Unregister a callback which had been added to observe resource conflict event.
+ * @param[in] cb The callback function to remove
+ * @return @c RM_OK on success,
+ *         otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+int rm_unsubscribe_resource_conflict_event(rm_conflict_event_cb cb);
+
+/**
+ * @brief Gets resource category id of the conflicted resource
+ * @param[in] rsc The conflicted resource handle
+ * @return resource category id of the conflicted resource handle on success,
+ *         otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+int rm_conflict_get_category_id(rm_conflict_resource_h rsc);
+
+/**
+ * @brief Gets device id of the conflicted resource
+ * @param[in] rsc The conflicted resource handle
+ * @return device id of the conflicted resource handle on success,
+ *         otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+int rm_conflict_get_device_id(rm_conflict_resource_h rsc);
+
+/**
+ * @brief Gets consumer id of the conflicted resource
+ * @param[in] rsc The conflicted resource handle
+ * @return consumer id of the conflicted resource handle on success,
+ *         otherwise negative value
+ * @pre None
+ * @post None
+ * @remarks The consumer id is an unique id which is assigned to a player as a result of rm_register().
+ * @exception None
+ * @version 3.0
+ */
+int rm_conflict_get_consumer_id(rm_conflict_resource_h rsc);
+
+/**
+ * @brief Gets application id of the conflicted resource
+ * @param[in] rsc The conflicted resource handle
+ * @return application id of the conflicted resource on success
+ *         otherwise NULL
+ * @pre None
+ * @post None
+ * @remarks In case any application id is not set by a player, NULL can be returned on success.
+ * @exception None
+ * @version 3.0
+ */
+const char *rm_conflict_get_app_id(rm_conflict_resource_h rsc);
+
+/**
+ * @brief Gets multiview zone id of the consumer that needs to release the conflicted resource
+ * @param[in] rsc The conflicted resource handle
+ * @return multiview zone id in case the conflicted resource is allocated to a multiview zone
+ *         otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+int rm_conflict_get_multiview_zone_id_consumer(rm_conflict_resource_h rsc);
+
+/**
+ * @brief Gets multiview zone id of the requester that caused this resource conflict
+ * @param[in] rsc The conflicted resource handle
+ * @return multiview zone id in case the requester is placed to a multiview zone
+ *         otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ */
+int rm_conflict_get_multiview_zone_id_requester(rm_conflict_resource_h rsc);
+
+/**
+ * @brief Unmask category option bits
+ * @param[in] category resource category to unmask
+ * @return unmasked category id
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ */
+int rm_unmask_category_options(int category);
+
+/**
+ * @brief Find real device id which is mapped to virtual device id
+ * @param[in] virtual_id virtual device id
+ * @return positive real resource id on success, negative value on failure
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li This API is available for the scaler device supporting virtual device.
+ */
+int rm_find_device_id(int virtual_id);
+
+/**
+ * @brief Swap two resources
+ * @param[in] device_id_a device id to swap
+ * @param[in] device_id_b device id to swap
+ * @return RM_OK on success, otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li This API is available for the scaler device supporting virtual device.
+ * \li This API is supposed to be called by the resource center only
+ */
+int rm_swap_resources(int device_id_a, int device_id_b);
+
+/**
+ * @brief Swap two resources asynchronously
+ * @param[in] device_id_a device id to swap
+ * @param[in] device_id_b device id to swap
+ * @return RM_OK on success, otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.1
+ * @remark
+ * \li This API is available for the scaler device supporting virtual device.
+ * \li This API is supposed to be called by the resource center only
+ */
+int rm_swap_resources_async(int device_id_a, int device_id_b);
+
+/**
+ * @brief Restore resources that have been swapped by rm_swap_resources()
+ * @param[in] category resource category to restore
+ * @return RM_OK on success, otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li This API is supposed to be called by the resource center only
+ */
+int rm_restore_resources(int category);
+
+/**
+ * @brief Get the resource list handle of resource collection
+ * @param[in] collection resource collection
+ * @param[out] list resource list handle
+ * @return RM_OK on success, otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li The returned list  must be freed by rm_free_resource_list() after use
+ */
+int rm_get_resource_collection_state(rm_rsc_collection_e collection, rm_resource_list_h *list);
+
+/**
+ * @brief Get application id of handle
+ * @param[in] handle player handle returned by rm_register()
+ * @param[out] app_id application id of handle
+ * @return RM_OK on success, otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li This API is supposed to be called by the resource center only
+ * \li Do not use other purpose
+ */
+int rm_get_app_id(int handle, char**app_id);
+
+/**
+ * @brief Get active audio out resources being used by handle
+ * @param[in] handle player handle returned by rm_register()
+ * @return positive value masked with rm_audio_out_e on success, otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li This API is supposed to be called by the resource center only
+ * \li Do not use other purpose
+ */
+int rm_get_active_audio_out(int handle);
+
+/**
+ * @brief Get hw id of scaler assigned to passed multiview zone id
+ * @param[in] zone_id multiview zone id
+ * @param[out] id The hw id of scaler assigned to passed multiview zone id,
+ * @return positive value on success, otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li This API is supposed to be called by the resource center only
+ * \li Do not use other purpose
+ */
+int rm_get_scaler_hw_id(int zone_id, int *id);
+
+/**
+ * @brief Notify current resource policy
+ * @param[in] policy resource policy
+ * @return positive value on success, otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.1
+ * @remark
+ * \li This API is supposed to be called by the resource center only
+ * \li Do not use other purpose
+ */
+int rm_notify_resource_policy(int policy);
+
+/**
+ * @brief Notify application's zone info in multiview
+ * @param[in] app_id application id
+ * @param[in] zone_id zone id
+ * @return positive value on success, otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 5.0
+ * @remark
+ * \li This API is supposed to be called by the resource center only
+ * \li Do not use other purpose
+ */
+int rm_notify_app_zone_info_async(const char *app_id, int zone_id);
+
+/**
+ * @brief Reclaim all resources allocated to the handle
+ * @param[in] handle player handle returned by rm_register()
+ * @return positive value on success, otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 4.0
+ * @remark
+ * \li This API is supposed to be called by the resource center only
+ * \li Do not use other purpose
+ */
+int rm_reclaim_resources(int handle);
+
+/**
+ * @brief Reclaim all resources allocated to the application
+ * @param[in] app_id application id
+ * @param[in] notify true : notify resource conflict, false : skip to notify
+ * @return positive value on success, otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 5.0
+ * @remark
+ * \li This API is supposed to be called by the resource center only
+ * \li Do not use other purpose
+ */
+int rm_reclaim_app_resources(const char *app_id, const bool notify);
+
+
+/**
+ * @brief Reclaim all resources allocated to the application asynchronously
+ * @param[in] app_id application id
+ * @param[in] notify true : notify resource conflict, false : skip to notify
+ * @return positive value on success, otherwise negative value
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 5.0
+ * @remark
+ * \li This API is supposed to be called by the resource center only
+ * \li Do not use other purpose
+ */
+int rm_reclaim_app_resources_async(const char *app_id, const bool notify);
+
+/**
+ * @brief Reclaim all video decoders allocated to applications other than requester
+ * @param[in] requester application id of the requester
+ * @return RM_OK on success, otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 5.0
+ * @remark
+ * \li This API is supposed to be called by the camera framework only
+ * \li Do not use for other purpose
+ */
+int rm_reclaim_video_decoders(const char *requester);
+
+/**
+ * @brief Check if the handle is valid or not
+ * @param[in] handle player handle returned by rm_register()
+ * @return true : player handle is valid, false : player handle is invalid
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 6.0
+ * @remark
+ * \li This API is supposed to be called by the resource center only
+ * \li Do not use for other purpose
+ */
+bool rm_active_player(const int handle);
+
+/**
+ * @brief Check if the player is in progress of reclaiming resource
+ * @param[in] handle player handle returned by rm_register()
+ * @return true : reclaim is in progress against the player, false : reclaim is not in progress against the player
+ * @pre None
+ * @post None
+ * @exception None
+ * @remark
+ * \li This API is supposed to be called by the resource center only
+ * \li Do not use for other purpose
+ */
+bool rm_reclaimed_player(const int handle);
+
+#ifdef __cplusplus
+}
+#endif
+#endif //__RM_MODULE_API_H__
index 2e9adadebdab3fdb271e2525262ecd183e0c319a..4a4e60c05bfc0082f6b78ea60cb4f29008980ad2 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __RM_RESOURCE_H__\r
-#define __RM_RESOURCE_H__\r
-\r
-#include <rm_type.h>\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-/**\r
- * @brief Create a resource list handle\r
- * @param None\r
- * @return resource list handle on success, otherwise NULL\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li The returned list  must be freed by rm_free_resource_list() after use\r
- */\r
-rm_resource_list_h rm_resource_list_create(void);\r
-\r
-/**\r
- * @brief Get the resource list handle of resource category\r
- * @param[in] category resource category\r
- * @param[out] list resource list handle\r
- * @return RM_OK on success, otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li The returned list  must be freed by rm_free_resource_list() after use\r
- */\r
-int rm_get_resource_list(rm_rsc_category_e category, rm_resource_list_h *list);\r
-\r
-/**\r
- * @brief Free resource list handle\r
- * @param[in] list resource list handle\r
- * @return None\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li The elements in the list will be freed as well\r
- */\r
-void rm_free_resource_list(rm_resource_list_h list);\r
-\r
-/**\r
- * @brief Append a resource to the resource list\r
- * @param[in] list resource list handle\r
- * @param[out] resource resource handle\r
- * @return RM_OK on success, otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-int rm_resource_list_append(rm_resource_list_h list, rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get next resource handle from resource list handle\r
- * @param[in] list resource list handle\r
- * @return next resource handle\r
- *         In case there is no next resource handle or error, returns NULL\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-rm_resource_h rm_resource_list_get_next(rm_resource_list_h list);\r
-\r
-/**\r
- * @brief Get previous resource handle from resource list handle\r
- * @param[in] list resource list handle\r
- * @return previous resource handle\r
- *         In case there is no previous resource handle or error, returns NULL\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-rm_resource_h rm_resource_list_get_prev(rm_resource_list_h list);\r
-\r
-/**\r
- * @brief Get first resource handle from resource list handle\r
- * @param[in] list resource list handle\r
- * @return first resource handle\r
- *         In case there is no previous resource handle or error, returns NULL\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-rm_resource_h rm_resource_list_get_first(rm_resource_list_h list);\r
-\r
-/**\r
- * @brief Get last resource handle from resource list handle\r
- * @param[in] list resource list handle\r
- * @return last resource handle\r
- * @pre In case there is no last resource handle or error, returns NULL\r
- * @post None\r
- * @exception None\r
- */\r
-rm_resource_h rm_resource_list_get_last(rm_resource_list_h list);\r
-\r
-/**\r
- * @brief Get number of resource handles in resource list handle\r
- * @param[in] list resource list handle\r
- * @return number of resource handles in resource list handle\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-int rm_resource_list_get_count(rm_resource_list_h list);\r
-\r
-/**\r
- * @brief Get node of the resource\r
- * @param[in] resource resource handle\r
- * @return node of the resource\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-const char *rm_resource_get_node(rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get id of the resource\r
- * @param[in] resource resource handle\r
- * @return resource id\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-int rm_resource_get_id(rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get category id of the resource\r
- * @param[in] resource resource handle\r
- * @return resource id\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-int rm_resource_get_category(rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get category id of the resource\r
- * @param[in] resource resource handle\r
- * @return resource id\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-int rm_resource_get_cur_category(rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get consumer id using the resource\r
- * @param[in] resource resource handle\r
- * @return resource id\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-int rm_resource_get_consumer(rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get state of the resource\r
- * @param[in] resource resource handle\r
- * @return resource id\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-int rm_resource_get_state(rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get application id using the resource\r
- * @param[in] resource resource handle\r
- * @return resource id\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-const char *rm_resource_get_app_id(rm_resource_h resource);\r
-\r
-/**\r
- * @brief Check whether the resource is being used by the android app\r
- * @param[in] resource resource handle\r
- * @return true : the resource is being used by the android app, false : not being used by the android app\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- */\r
-bool rm_resource_android_app(const rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get framerate of the resource\r
- * @param[in] resource resource handle\r
- * @return framerate\r
- * @pre None\r
- * @post None\r
- * @version 3.0\r
- * @exception None\r
- */\r
-unsigned int rm_resource_get_framerate(rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get max resolution of the resource\r
- * @param[in] resource resource handle\r
- * @return max resolution. This is one of rm_resolution_e values.\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li The API is valid for the resource belongs to RM_CATEGORY_DISPLAY_OUT\r
- */\r
-int rm_resource_get_max_resolution(rm_resource_h resource);\r
-\r
-/**\r
- * @brief This function returns whether the resource supports overlay or not\r
- * @param[in] resource resource handle\r
- * @return true : overlay supported, false : overlay not supported\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @version 3.0\r
- * @remark\r
- * \li The API is valid for the resource belongs to RM_CATEGORY_DISPLAY_OUT\r
- */\r
-bool rm_resource_support_overlay(rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get max sampling format of the resource\r
- * @param[in] resource resource handle\r
- * @return max color format. This is one of rm_sampling_format_e values.\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @remark\r
- * \li The API is valid for the resource belongs to RM_CATEGORY_DISPLAY_OUT\r
- */\r
-int rm_resource_get_max_sampling_format(rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get multiview zone id of the resource\r
- * @param[in] resource resource handle\r
- * @return multiview zone id\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @remark\r
- * \li The API is valid for the resource belongs to RM_CATEGORY_SCALER\r
- */\r
-int rm_resource_get_zone_id(rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get width of the resource\r
- * @param[in] resource resource handle\r
- * @return width of the content to be encoded\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @remark\r
- * \li The API is valid for the resource belongs to RM_CATEGORY_VIDEO_ENCODER\r
- */\r
-unsigned int rm_resource_get_width(const rm_resource_h resource);\r
-\r
-/**\r
- * @brief Get height of the resource\r
- * @param[in] resource resource handle\r
- * @return height of the content to be encoded\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @remark\r
- * \li The API is valid for the resource belongs to RM_CATEGORY_VIDEO_ENCODER\r
- */\r
-unsigned int rm_resource_get_height(const rm_resource_h resource);\r
-\r
-/**\r
- * @brief Create a video encoder handle\r
- * @param[in] width width of the content to encode (in pixel)\r
- * @param[in] height height of the content to encode (in pixel)\r
- * @param[in] framerate frame rate of the content to encode (frame per second)\r
- * @return resource handle on success, otherwise NULL\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @remark\r
- * \li If the returned resource handle is appended to the resource list then you can free this with rm_free_resource_list()\r
- */\r
-rm_resource_h rm_create_video_encoder(const unsigned int width, const unsigned int height, const unsigned int framerate);\r
-\r
-/**\r
- * @brief Checks whether the video encoders in the list are allocatable for multi encoding scenario\r
- * @param[in] list the resource list including the video encoders\r
- * @param[out] result true : allocatable, false : not allocatable\r
- * @return RM_OK on success, otherwise RM_ERROR\r
- * @pre None\r
- * @post None\r
- * @exception None\r
- * @remark\r
- * \li This function checks whether the video encoders are allocatable based on available bandwidth of the video encoder.\r
- * \li In other words, the result can be different depending on current video encoder usage status.\r
- */\r
-int rm_allocatable_video_encoders(const rm_resource_list_h list, bool *result);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif //__RM_RESOURCE_H__\r
+/*
+ * Copyright (c) 2024 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 __RM_RESOURCE_H__
+#define __RM_RESOURCE_H__
+
+#include <rm_type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Create a resource list handle
+ * @param None
+ * @return resource list handle on success, otherwise NULL
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li The returned list  must be freed by rm_free_resource_list() after use
+ */
+rm_resource_list_h rm_resource_list_create(void);
+
+/**
+ * @brief Get the resource list handle of resource category
+ * @param[in] category resource category
+ * @param[out] list resource list handle
+ * @return RM_OK on success, otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li The returned list  must be freed by rm_free_resource_list() after use
+ */
+int rm_get_resource_list(rm_rsc_category_e category, rm_resource_list_h *list);
+
+/**
+ * @brief Free resource list handle
+ * @param[in] list resource list handle
+ * @return None
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li The elements in the list will be freed as well
+ */
+void rm_free_resource_list(rm_resource_list_h list);
+
+/**
+ * @brief Append a resource to the resource list
+ * @param[in] list resource list handle
+ * @param[out] resource resource handle
+ * @return RM_OK on success, otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ */
+int rm_resource_list_append(rm_resource_list_h list, rm_resource_h resource);
+
+/**
+ * @brief Get next resource handle from resource list handle
+ * @param[in] list resource list handle
+ * @return next resource handle
+ *         In case there is no next resource handle or error, returns NULL
+ * @pre None
+ * @post None
+ * @exception None
+ */
+rm_resource_h rm_resource_list_get_next(rm_resource_list_h list);
+
+/**
+ * @brief Get previous resource handle from resource list handle
+ * @param[in] list resource list handle
+ * @return previous resource handle
+ *         In case there is no previous resource handle or error, returns NULL
+ * @pre None
+ * @post None
+ * @exception None
+ */
+rm_resource_h rm_resource_list_get_prev(rm_resource_list_h list);
+
+/**
+ * @brief Get first resource handle from resource list handle
+ * @param[in] list resource list handle
+ * @return first resource handle
+ *         In case there is no previous resource handle or error, returns NULL
+ * @pre None
+ * @post None
+ * @exception None
+ */
+rm_resource_h rm_resource_list_get_first(rm_resource_list_h list);
+
+/**
+ * @brief Get last resource handle from resource list handle
+ * @param[in] list resource list handle
+ * @return last resource handle
+ * @pre In case there is no last resource handle or error, returns NULL
+ * @post None
+ * @exception None
+ */
+rm_resource_h rm_resource_list_get_last(rm_resource_list_h list);
+
+/**
+ * @brief Get number of resource handles in resource list handle
+ * @param[in] list resource list handle
+ * @return number of resource handles in resource list handle
+ * @pre None
+ * @post None
+ * @exception None
+ */
+int rm_resource_list_get_count(rm_resource_list_h list);
+
+/**
+ * @brief Get node of the resource
+ * @param[in] resource resource handle
+ * @return node of the resource
+ * @pre None
+ * @post None
+ * @exception None
+ */
+const char *rm_resource_get_node(rm_resource_h resource);
+
+/**
+ * @brief Get id of the resource
+ * @param[in] resource resource handle
+ * @return resource id
+ * @pre None
+ * @post None
+ * @exception None
+ */
+int rm_resource_get_id(rm_resource_h resource);
+
+/**
+ * @brief Get category id of the resource
+ * @param[in] resource resource handle
+ * @return resource id
+ * @pre None
+ * @post None
+ * @exception None
+ */
+int rm_resource_get_category(rm_resource_h resource);
+
+/**
+ * @brief Get category id of the resource
+ * @param[in] resource resource handle
+ * @return resource id
+ * @pre None
+ * @post None
+ * @exception None
+ */
+int rm_resource_get_cur_category(rm_resource_h resource);
+
+/**
+ * @brief Get consumer id using the resource
+ * @param[in] resource resource handle
+ * @return resource id
+ * @pre None
+ * @post None
+ * @exception None
+ */
+int rm_resource_get_consumer(rm_resource_h resource);
+
+/**
+ * @brief Get state of the resource
+ * @param[in] resource resource handle
+ * @return resource id
+ * @pre None
+ * @post None
+ * @exception None
+ */
+int rm_resource_get_state(rm_resource_h resource);
+
+/**
+ * @brief Get application id using the resource
+ * @param[in] resource resource handle
+ * @return resource id
+ * @pre None
+ * @post None
+ * @exception None
+ */
+const char *rm_resource_get_app_id(rm_resource_h resource);
+
+/**
+ * @brief Check whether the resource is being used by the android app
+ * @param[in] resource resource handle
+ * @return true : the resource is being used by the android app, false : not being used by the android app
+ * @pre None
+ * @post None
+ * @exception None
+ */
+bool rm_resource_android_app(const rm_resource_h resource);
+
+/**
+ * @brief Get framerate of the resource
+ * @param[in] resource resource handle
+ * @return framerate
+ * @pre None
+ * @post None
+ * @version 3.0
+ * @exception None
+ */
+unsigned int rm_resource_get_framerate(rm_resource_h resource);
+
+/**
+ * @brief Get max resolution of the resource
+ * @param[in] resource resource handle
+ * @return max resolution. This is one of rm_resolution_e values.
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li The API is valid for the resource belongs to RM_CATEGORY_DISPLAY_OUT
+ */
+int rm_resource_get_max_resolution(rm_resource_h resource);
+
+/**
+ * @brief This function returns whether the resource supports overlay or not
+ * @param[in] resource resource handle
+ * @return true : overlay supported, false : overlay not supported
+ * @pre None
+ * @post None
+ * @exception None
+ * @version 3.0
+ * @remark
+ * \li The API is valid for the resource belongs to RM_CATEGORY_DISPLAY_OUT
+ */
+bool rm_resource_support_overlay(rm_resource_h resource);
+
+/**
+ * @brief Get max sampling format of the resource
+ * @param[in] resource resource handle
+ * @return max color format. This is one of rm_sampling_format_e values.
+ * @pre None
+ * @post None
+ * @exception None
+ * @remark
+ * \li The API is valid for the resource belongs to RM_CATEGORY_DISPLAY_OUT
+ */
+int rm_resource_get_max_sampling_format(rm_resource_h resource);
+
+/**
+ * @brief Get multiview zone id of the resource
+ * @param[in] resource resource handle
+ * @return multiview zone id
+ * @pre None
+ * @post None
+ * @exception None
+ * @remark
+ * \li The API is valid for the resource belongs to RM_CATEGORY_SCALER
+ */
+int rm_resource_get_zone_id(rm_resource_h resource);
+
+/**
+ * @brief Get width of the resource
+ * @param[in] resource resource handle
+ * @return width of the content to be encoded
+ * @pre None
+ * @post None
+ * @exception None
+ * @remark
+ * \li The API is valid for the resource belongs to RM_CATEGORY_VIDEO_ENCODER
+ */
+unsigned int rm_resource_get_width(const rm_resource_h resource);
+
+/**
+ * @brief Get height of the resource
+ * @param[in] resource resource handle
+ * @return height of the content to be encoded
+ * @pre None
+ * @post None
+ * @exception None
+ * @remark
+ * \li The API is valid for the resource belongs to RM_CATEGORY_VIDEO_ENCODER
+ */
+unsigned int rm_resource_get_height(const rm_resource_h resource);
+
+/**
+ * @brief Create a video encoder handle
+ * @param[in] width width of the content to encode (in pixel)
+ * @param[in] height height of the content to encode (in pixel)
+ * @param[in] framerate frame rate of the content to encode (frame per second)
+ * @return resource handle on success, otherwise NULL
+ * @pre None
+ * @post None
+ * @exception None
+ * @remark
+ * \li If the returned resource handle is appended to the resource list then you can free this with rm_free_resource_list()
+ */
+rm_resource_h rm_create_video_encoder(const unsigned int width, const unsigned int height, const unsigned int framerate);
+
+/**
+ * @brief Checks whether the video encoders in the list are allocatable for multi encoding scenario
+ * @param[in] list the resource list including the video encoders
+ * @param[out] result true : allocatable, false : not allocatable
+ * @return RM_OK on success, otherwise RM_ERROR
+ * @pre None
+ * @post None
+ * @exception None
+ * @remark
+ * \li This function checks whether the video encoders are allocatable based on available bandwidth of the video encoder.
+ * \li In other words, the result can be different depending on current video encoder usage status.
+ */
+int rm_allocatable_video_encoders(const rm_resource_list_h list, bool *result);
+
+#ifdef __cplusplus
+}
+#endif
+#endif //__RM_RESOURCE_H__
index 5914eeb4a3ae3b0c0fc16f1f1029d7d6f120b2b0..440001603eec78c5fe1249a9fc0120a3605b8b79 100644 (file)
@@ -1,67 +1,67 @@
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __RM_CALLBACK_H__\r
-#define __RM_CALLBACK_H__\r
-\r
-#include <glib.h>\r
-#include <list>\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-typedef struct {\r
-       int msg_type;       // callback message type\r
-       int cid;            // consumer id\r
-       int pid;            // process id\r
-       int conflicted_num; // conflicted resource num\r
-} rm_cb_head_s;\r
-\r
-typedef struct {\r
-       rm_conflict_event_cb cb;\r
-       void *data;\r
-} conflict_event_cb;\r
-\r
-typedef struct {\r
-       scaler_state_change_cb cb;\r
-       void *data;\r
-} scaler_state_cb;\r
-\r
-GMainLoop *rm_get_main_loop(void);\r
-GMainContext *rm_get_context(void);\r
-void rm_set_context(GMainContext *context);\r
-int rm_init_cb(int cid, rm_resource_cb cb, void *data);\r
-int rm_send_cb_msg(rm_cb_head_s *cb_head, int result);\r
-void rm_register_callback(int handle, rm_resource_cb cb, void *data, int fd, GSource *callback_handler, GIOChannel *gio);\r
-void rm_unregister_callback(int handle);\r
-\r
-int rm_add_state_change_cb(int category, resource_state_change_cb cb, void *data);\r
-int rm_remove_state_change_cb(int category, resource_state_change_cb cb);\r
-void rm_call_state_changed_cb(int category, int device_id, int state, int consumer_id, char *app_id);\r
-\r
-int rm_add_conflict_event_cb(rm_conflict_event_cb cb, void *data);\r
-int rm_remove_conflict_event_cb(rm_conflict_event_cb cb);\r
-std::list<conflict_event_cb*>& rm_get_conflict_event_cb_list(void);\r
-\r
-int rm_add_scaler_state_change_cb(scaler_state_change_cb cb, void *data);\r
-int rm_remove_scaler_state_change_cb(scaler_state_change_cb cb);\r
-void rm_call_scaler_state_changed_cb(rm_resource_list *scaler_list);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif// __RM_CALLBACK_H__\r
+/*
+ * Copyright (c) 2024 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 __RM_CALLBACK_H__
+#define __RM_CALLBACK_H__
+
+#include <glib.h>
+#include <list>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+       int msg_type;       // callback message type
+       int cid;            // consumer id
+       int pid;            // process id
+       int conflicted_num; // conflicted resource num
+} rm_cb_head_s;
+
+typedef struct {
+       rm_conflict_event_cb cb;
+       void *data;
+} conflict_event_cb;
+
+typedef struct {
+       scaler_state_change_cb cb;
+       void *data;
+} scaler_state_cb;
+
+GMainLoop *rm_get_main_loop(void);
+GMainContext *rm_get_context(void);
+void rm_set_context(GMainContext *context);
+int rm_init_cb(int cid, rm_resource_cb cb, void *data);
+int rm_send_cb_msg(rm_cb_head_s *cb_head, int result);
+void rm_register_callback(int handle, rm_resource_cb cb, void *data, int fd, GSource *callback_handler, GIOChannel *gio);
+void rm_unregister_callback(int handle);
+
+int rm_add_state_change_cb(int category, resource_state_change_cb cb, void *data);
+int rm_remove_state_change_cb(int category, resource_state_change_cb cb);
+void rm_call_state_changed_cb(int category, int device_id, int state, int consumer_id, char *app_id);
+
+int rm_add_conflict_event_cb(rm_conflict_event_cb cb, void *data);
+int rm_remove_conflict_event_cb(rm_conflict_event_cb cb);
+std::list<conflict_event_cb*>& rm_get_conflict_event_cb_list(void);
+
+int rm_add_scaler_state_change_cb(scaler_state_change_cb cb, void *data);
+int rm_remove_scaler_state_change_cb(scaler_state_change_cb cb);
+void rm_call_scaler_state_changed_cb(rm_resource_list *scaler_list);
+
+#ifdef __cplusplus
+}
+#endif
+#endif// __RM_CALLBACK_H__
index 0cf8140bca77f91fbc9727f17012b08683b84140..45904b9e5bbb3701ce16c88e849700304085a507 100644 (file)
@@ -1,38 +1,38 @@
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __RM_DBUS_H__\r
-#define __RM_DBUS_H__\r
-\r
-#include <glib.h>\r
-#include <gio/gio.h>\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-#define RM_DBUS_BUS_NAME "rscmgr.resource"\r
-#define RM_DBUS_INTERFACE_NAME "rscmgr.resource"\r
-#define RM_DBUS_OBJ_PATH "/rscmgr/resource"\r
-\r
-int rm_dbus_method_call(const char *method, GVariant *args, GVariant **result);\r
-int rm_dbus_method_call_async_with_no_reply(const char *method, GVariant *args);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif //__RM_DBUS_H__
\ No newline at end of file
+/*
+ * Copyright (c) 2024 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 __RM_DBUS_H__
+#define __RM_DBUS_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RM_DBUS_BUS_NAME "rscmgr.resource"
+#define RM_DBUS_INTERFACE_NAME "rscmgr.resource"
+#define RM_DBUS_OBJ_PATH "/rscmgr/resource"
+
+int rm_dbus_method_call(const char *method, GVariant *args, GVariant **result);
+int rm_dbus_method_call_async_with_no_reply(const char *method, GVariant *args);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__RM_DBUS_H__
index 4cfb311c8e9ed1cb7b9e1a987c3e9fafad815a81..fc00a55322d42467c8087315308115eece6ab89f 100644 (file)
@@ -1,59 +1,59 @@
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __RM_DEBUG_H__\r
-#define __RM_DEBUG_H__\r
-\r
-#include <rm_api.h>\r
-#include <dlog.h>\r
-#include <rm_internal.h>\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-#ifdef LOG_TAG\r
-#undef LOG_TAG\r
-#endif //LOG_TAG\r
-\r
-#define LOG_TAG "RSC_MGR"\r
-\r
-\r
-#ifndef RM_DBG\r
-#define RM_DBG(fmt, args...) SLOGD(fmt, ##args)\r
-#endif\r
-\r
-#ifndef RM_INFO\r
-#define RM_INFO(fmt, args...) SLOGI(fmt, ##args)\r
-#endif\r
-\r
-#ifndef RM_WARN\r
-#define RM_WARN(fmt, args...) SLOGW(fmt, ##args)\r
-#endif\r
-\r
-#ifndef RM_ERR\r
-#define RM_ERR(fmt, args...) SLOGE(fmt, ##args)\r
-#endif\r
-\r
-const char *rm_convert_requested_state_enum_to_string(rm_requests_resource_state_e state_enum);\r
-const char *rm_convert_category_enum_to_string(rm_rsc_category_e category_enum);\r
-int is_symlink_file(const char *path);\r
-int _rc_get_capable_catgory_id(int handle, const char *app_id, int category_src);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif //__RM_DEBUG_H__\r
+/*
+ * Copyright (c) 2024 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 __RM_DEBUG_H__
+#define __RM_DEBUG_H__
+
+#include <rm_api.h>
+#include <dlog.h>
+#include <rm_internal.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif //LOG_TAG
+
+#define LOG_TAG "RSC_MGR"
+
+
+#ifndef RM_DBG
+#define RM_DBG(fmt, args...) SLOGD(fmt, ##args)
+#endif
+
+#ifndef RM_INFO
+#define RM_INFO(fmt, args...) SLOGI(fmt, ##args)
+#endif
+
+#ifndef RM_WARN
+#define RM_WARN(fmt, args...) SLOGW(fmt, ##args)
+#endif
+
+#ifndef RM_ERR
+#define RM_ERR(fmt, args...) SLOGE(fmt, ##args)
+#endif
+
+const char *rm_convert_requested_state_enum_to_string(rm_requests_resource_state_e state_enum);
+const char *rm_convert_category_enum_to_string(rm_rsc_category_e category_enum);
+int is_symlink_file(const char *path);
+int _rc_get_capable_catgory_id(int handle, const char *app_id, int category_src);
+
+#ifdef __cplusplus
+}
+#endif
+#endif //__RM_DEBUG_H__
index 9759fe0acf2b03a1a46b16e994bec7f8a2697cbf..57533d4bdd0aca63582450bd3edd9b4d6a8963ac 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __RM_INTERNAL_H__\r
-#define __RM_INTERNAL_H__\r
-\r
-#include <rm_type.h>\r
-#include <glib.h>\r
-\r
-#define RM_RETURN_ERR_IF_NULL(a, msg) \\r
-               if (!a) \\r
-               { \\r
-                       RM_ERR("%s", msg); \\r
-                       return RM_ERROR; \\r
-               }\r
-\r
-#define RM_RETURN_NULL_IF_NULL(a, msg) \\r
-               if (!a) \\r
-               { \\r
-                       RM_ERR("%s", msg); \\r
-                       return NULL; \\r
-               }\r
-\r
-#define RM_RETURN_MINUS_IF_NULL(a, msg) \\r
-               if (!a) \\r
-               { \\r
-                       RM_ERR("%s", msg); \\r
-                       return -1; \\r
-               }\r
-\r
-#define RM_RETURN_IF_NULL(a, msg) \\r
-               if (!a) \\r
-               { \\r
-                       RM_ERR("%s", msg); \\r
-                       return; \\r
-               }\r
-\r
-#define RM_FREE(a) \\r
-               if (a) \\r
-               { \\r
-                       free(a); \\r
-                       a = NULL; \\r
-               }\r
-\r
-#define RM_RETURN_ERR_IF_LT(a, v, msg) \\r
-               if (a < v) \\r
-               { \\r
-                       RM_ERR("invalid value(%d)", a); \\r
-                       return RM_ERROR; \\r
-               }\r
-\r
-#define RM_RETURN_ERR_IF_GT(a, v, msg) \\r
-               if (a > v) \\r
-               { \\r
-                       RM_ERR("invalid value(%d)", a); \\r
-                       return RM_ERROR; \\r
-               }\r
-\r
-#define RM_DEVICE_NODE_LEN_MAX 4096\r
-#define RM_INT32_LEN 32\r
-\r
-/**\r
- * @enum    rm_resource_internal_state_e\r
- * @brief        Resource State\r
- *             This state can be returned using RM API\r
- */\r
-typedef enum {\r
-       RM_INTERNAL_STATE_FREE,\r
-       RM_INTERNAL_STATE_SHARABLE,\r
-       RM_INTERNAL_STATE_SHARED,\r
-       RM_INTERNAL_STATE_EXCLUSIVE,\r
-       RM_INTERNAL_STATE_ERROR\r
-} rm_resource_internal_state_e;\r
-\r
-typedef struct\r
-{\r
-       rm_rsc_category_e category_id;\r
-       int device_id;\r
-} rm_conflicted_resource_info_s;\r
-\r
-/**\r
- * @brief      request data type\r
- */\r
-typedef enum {\r
-       RM_REQUEST_DATA_TYPE_COMMON = 1,\r
-       RM_REQUEST_DATA_TYPE_REGISTER = (0x2 << 29),\r
-} rm_request_data_type;\r
-\r
-typedef enum {\r
-       RM_RESPONSE_DATA_TYPE_ALL = 0,\r
-       RM_RESPONSE_DATA_TYPE_COMMON = 1,\r
-       RM_RESPONSE_DATA_TYPE_REGISTER = (0x2 << 29)\r
-} rm_response_data_type;\r
-\r
-typedef enum {\r
-       RM_REQUEST_REGISTER,\r
-       RM_REQUEST_UNREGISTER,\r
-       RM_REQUEST_ALLOCATE_RESOURCE,\r
-       RM_REQUEST_RELEASE_RESOURCES,\r
-       RM_REQUEST_QUERY,\r
-       RM_REQUEST_SET_PRIORITY,\r
-       RM_REQUEST_SET_APPID,\r
-       RM_REQUEST_MAX,\r
-} rm_request_type_e;\r
-\r
-/**\r
- * @struct    rm_category_s\r
- * @brief        category information for allocation\r
- */\r
-typedef struct\r
-{\r
-       rm_rsc_category_e    category_id;\r
-       int                  category_id_optional;\r
-       rm_requests_resource_state_e    requested_state;\r
-} rm_category_s;\r
-\r
-\r
-/**\r
- * @struct rm_requests_category_s\r
- * @brief resource type information when consumer requests resource category\r
- *\r
- * The rm_requests_category_s struct encapsulate the number of resource.\r
- * resource type array. requests_state in the one data\r
- *\r
- */\r
-typedef struct\r
-{\r
-       int resources_num;\r
-       rm_category_s *resources_categories;\r
-} rm_requests_category_s;\r
-\r
-#define RM_APPID_LENGTH 256\r
-\r
-typedef struct {\r
-       long data_type;\r
-       int type;\r
-       int handle;\r
-       int pid;\r
-       int request_num;\r
-       int resource[RM_REQUEST_RESOURCE_MAX];\r
-       int resource_option[RM_REQUEST_RESOURCE_MAX];\r
-       int state[RM_REQUEST_RESOURCE_MAX];\r
-       int main_priority;\r
-       int sub_priority;\r
-       int app_pid;\r
-       char app_id[RM_APPID_LENGTH]; /* APPID */\r
-       int device_id[RM_REQUEST_RESOURCE_MAX];\r
-       int sub_type;\r
-       unsigned long time;\r
-} rm_msg_request;\r
-\r
-typedef struct {\r
-       long                    data_type;\r
-       int                     type;\r
-       int                     result;\r
-       int                     resource_num;\r
-       int                     resource[RM_REQUEST_RESOURCE_MAX];\r
-       rm_resource_internal_state_e resource_state[RM_REQUEST_RESOURCE_MAX];\r
-       int                     available;\r
-       int                     handle;\r
-       int                     error_type;\r
-       int                     pid;\r
-} rm_msg_response;\r
-\r
-struct rm_resource {\r
-       int id;\r
-       char *node;\r
-       int state;\r
-       int category_id;\r
-       int consumer_id;\r
-       char *app_id;\r
-       int virtual_id; //only for scaler\r
-       int source_id; //only for scaler\r
-       int max_rez; // max resolution only for scaler\r
-       int max_sampling_format; // only for scaler\r
-       int support_overlay; // only for scaler\r
-       int zone_id; // only for scaler\r
-       unsigned int framerate;\r
-       int cur_category_id; //only for scaler\r
-       unsigned int width;\r
-       unsigned int height;\r
-       bool android_app;\r
-};\r
-\r
-struct rm_resource_state {\r
-       int catId;\r
-       int devId;\r
-       int state;\r
-       int consumerId;\r
-       char *appId;\r
-};\r
-\r
-struct rm_resource_list {\r
-       int n_rsc;\r
-       GList *rsc_list;\r
-       GList *iter;\r
-};\r
-\r
-struct rm_conflict_resource {\r
-       int catId; // resource category id\r
-       int devId; // device id\r
-       int cId; // consumer id\r
-       const char *appId; // application id\r
-       int aZoneId; //application zone id\r
-       int rZoneId; //requester zone id\r
-};\r
-\r
-void rm_wait_for_server_ready(void);\r
-\r
-void rm_set_cpu_inheritance(void);\r
-void rm_clear_cpu_inheritance(void);\r
-\r
-#endif //__RM_INTERNAL_H__\r
+/*
+ * Copyright (c) 2024 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 __RM_INTERNAL_H__
+#define __RM_INTERNAL_H__
+
+#include <rm_type.h>
+#include <glib.h>
+
+#define RM_RETURN_ERR_IF_NULL(a, msg) \
+               if (!a) \
+               { \
+                       RM_ERR("%s", msg); \
+                       return RM_ERROR; \
+               }
+
+#define RM_RETURN_NULL_IF_NULL(a, msg) \
+               if (!a) \
+               { \
+                       RM_ERR("%s", msg); \
+                       return NULL; \
+               }
+
+#define RM_RETURN_MINUS_IF_NULL(a, msg) \
+               if (!a) \
+               { \
+                       RM_ERR("%s", msg); \
+                       return -1; \
+               }
+
+#define RM_RETURN_IF_NULL(a, msg) \
+               if (!a) \
+               { \
+                       RM_ERR("%s", msg); \
+                       return; \
+               }
+
+#define RM_FREE(a) \
+               if (a) \
+               { \
+                       free(a); \
+                       a = NULL; \
+               }
+
+#define RM_RETURN_ERR_IF_LT(a, v, msg) \
+               if (a < v) \
+               { \
+                       RM_ERR("invalid value(%d)", a); \
+                       return RM_ERROR; \
+               }
+
+#define RM_RETURN_ERR_IF_GT(a, v, msg) \
+               if (a > v) \
+               { \
+                       RM_ERR("invalid value(%d)", a); \
+                       return RM_ERROR; \
+               }
+
+#define RM_DEVICE_NODE_LEN_MAX 4096
+#define RM_INT32_LEN 32
+
+/**
+ * @enum    rm_resource_internal_state_e
+ * @brief        Resource State
+ *             This state can be returned using RM API
+ */
+typedef enum {
+       RM_INTERNAL_STATE_FREE,
+       RM_INTERNAL_STATE_SHARABLE,
+       RM_INTERNAL_STATE_SHARED,
+       RM_INTERNAL_STATE_EXCLUSIVE,
+       RM_INTERNAL_STATE_ERROR
+} rm_resource_internal_state_e;
+
+typedef struct
+{
+       rm_rsc_category_e category_id;
+       int device_id;
+} rm_conflicted_resource_info_s;
+
+/**
+ * @brief      request data type
+ */
+typedef enum {
+       RM_REQUEST_DATA_TYPE_COMMON = 1,
+       RM_REQUEST_DATA_TYPE_REGISTER = (0x2 << 29),
+} rm_request_data_type;
+
+typedef enum {
+       RM_RESPONSE_DATA_TYPE_ALL = 0,
+       RM_RESPONSE_DATA_TYPE_COMMON = 1,
+       RM_RESPONSE_DATA_TYPE_REGISTER = (0x2 << 29)
+} rm_response_data_type;
+
+typedef enum {
+       RM_REQUEST_REGISTER,
+       RM_REQUEST_UNREGISTER,
+       RM_REQUEST_ALLOCATE_RESOURCE,
+       RM_REQUEST_RELEASE_RESOURCES,
+       RM_REQUEST_QUERY,
+       RM_REQUEST_SET_PRIORITY,
+       RM_REQUEST_SET_APPID,
+       RM_REQUEST_MAX,
+} rm_request_type_e;
+
+/**
+ * @struct    rm_category_s
+ * @brief        category information for allocation
+ */
+typedef struct
+{
+       rm_rsc_category_e    category_id;
+       int                  category_id_optional;
+       rm_requests_resource_state_e    requested_state;
+} rm_category_s;
+
+
+/**
+ * @struct rm_requests_category_s
+ * @brief resource type information when consumer requests resource category
+ *
+ * The rm_requests_category_s struct encapsulate the number of resource.
+ * resource type array. requests_state in the one data
+ *
+ */
+typedef struct
+{
+       int resources_num;
+       rm_category_s *resources_categories;
+} rm_requests_category_s;
+
+#define RM_APPID_LENGTH 256
+
+typedef struct {
+       long data_type;
+       int type;
+       int handle;
+       int pid;
+       int request_num;
+       int resource[RM_REQUEST_RESOURCE_MAX];
+       int resource_option[RM_REQUEST_RESOURCE_MAX];
+       int state[RM_REQUEST_RESOURCE_MAX];
+       int main_priority;
+       int sub_priority;
+       int app_pid;
+       char app_id[RM_APPID_LENGTH]; /* APPID */
+       int device_id[RM_REQUEST_RESOURCE_MAX];
+       int sub_type;
+       unsigned long time;
+} rm_msg_request;
+
+typedef struct {
+       long                    data_type;
+       int                     type;
+       int                     result;
+       int                     resource_num;
+       int                     resource[RM_REQUEST_RESOURCE_MAX];
+       rm_resource_internal_state_e resource_state[RM_REQUEST_RESOURCE_MAX];
+       int                     available;
+       int                     handle;
+       int                     error_type;
+       int                     pid;
+} rm_msg_response;
+
+struct rm_resource {
+       int id;
+       char *node;
+       int state;
+       int category_id;
+       int consumer_id;
+       char *app_id;
+       int virtual_id; //only for scaler
+       int source_id; //only for scaler
+       int max_rez; // max resolution only for scaler
+       int max_sampling_format; // only for scaler
+       int support_overlay; // only for scaler
+       int zone_id; // only for scaler
+       unsigned int framerate;
+       int cur_category_id; //only for scaler
+       unsigned int width;
+       unsigned int height;
+       bool android_app;
+};
+
+struct rm_resource_state {
+       int catId;
+       int devId;
+       int state;
+       int consumerId;
+       char *appId;
+};
+
+struct rm_resource_list {
+       int n_rsc;
+       GList *rsc_list;
+       GList *iter;
+};
+
+struct rm_conflict_resource {
+       int catId; // resource category id
+       int devId; // device id
+       int cId; // consumer id
+       const char *appId; // application id
+       int aZoneId; //application zone id
+       int rZoneId; //requester zone id
+};
+
+void rm_wait_for_server_ready(void);
+
+void rm_set_cpu_inheritance(void);
+void rm_clear_cpu_inheritance(void);
+
+#endif //__RM_INTERNAL_H__
index 86dd15d62b1ce710d47785df748cff06cb90ad4e..d1da2aa84a0a04a2de952c713163e20d2b02ba5c 100644 (file)
@@ -1,33 +1,33 @@
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __RM_MSG_H__\r
-#define __RM_MSG_H__\r
-\r
-#include <rm_internal.h>\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-int rm_send_msg(rm_msg_request  *data);\r
-int rm_receive_msg(rm_msg_response *response, int msg_type);\r
-void rm_construct_request_msg(rm_msg_request *request, int msg_type, int handle);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif //__RM_MSG_H__\r
+/*
+ * Copyright (c) 2024 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 __RM_MSG_H__
+#define __RM_MSG_H__
+
+#include <rm_internal.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int rm_send_msg(rm_msg_request  *data);
+int rm_receive_msg(rm_msg_response *response, int msg_type);
+void rm_construct_request_msg(rm_msg_request *request, int msg_type, int handle);
+
+#ifdef __cplusplus
+}
+#endif
+#endif //__RM_MSG_H__
index 3b06835c0ec930e68f5389d86587e77c6cad568b..6f0df4c2eee630042587d75b0a92d8d3674a85a8 100644 (file)
@@ -1,7 +1,7 @@
 Name:       resource-manager
 Summary:    Resource manager
 Version:    0.1
-Release:    0
+Release:    1
 Group:      Multimedia/Libraries
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index 509eeca135e64eedc67865b968aa3afa302406e7..42d42ca399047911caf356f67f80676a05030e53 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include <stdlib.h>\r
-#include <stdint.h>\r
-#include <unistd.h>\r
-\r
-#include <rm_dbus.h>\r
-#include <rm_debug.h>\r
-\r
-// LCOV_EXCL_START\r
-\r
-static bool _wait_server_ready(void)\r
-{\r
-       const char *rsc_event_name = "/run/rsc_mgr_ready";\r
-\r
-       return access(rsc_event_name, F_OK) == 0;\r
-}\r
-\r
-static GDBusConnection* __dbus_get_connection()\r
-{\r
-       static GDBusConnection *conn = NULL;\r
-       GError *err = NULL;\r
-\r
-       if (conn)\r
-               return conn;\r
-\r
-       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);\r
-       if (!conn)      {\r
-               RM_ERR("g_bus_get_sync() error (%s)", err->message);\r
-               g_error_free(err);\r
-               return NULL;\r
-       }\r
-\r
-       return conn;\r
-}\r
-\r
-void rm_set_cpu_inheritance(void)\r
-{\r
-       //resource_set_cpu_inheritance(0, "rscmgr-service", 1000);\r
-}\r
-\r
-void rm_clear_cpu_inheritance(void)\r
-{\r
-       //resource_clear_cpu_inheritance(0, "rscmgr-service");\r
-}\r
-\r
-int rm_dbus_method_call(const char *method, GVariant *args, GVariant **result)\r
-{\r
-       GError *err = NULL;\r
-       GVariant *reply = NULL;\r
-       GDBusConnection *conn = NULL;\r
-\r
-       if (!method) {\r
-               RM_ERR("Invalid Argument");\r
-               g_variant_unref(args);\r
-               return -1;\r
-       }\r
-\r
-       RM_INFO("Method call '%s'", method);\r
-\r
-       if (!_wait_server_ready()) {\r
-               RM_ERR("server is not ready yet");\r
-               g_variant_unref(args);\r
-               return -1;\r
-       }\r
-\r
-       conn = __dbus_get_connection();\r
-\r
-       if (!conn) {\r
-               g_variant_unref(args);\r
-               return -1;\r
-       }\r
-\r
-       rm_set_cpu_inheritance();\r
-       reply = g_dbus_connection_call_sync(conn, RM_DBUS_BUS_NAME, RM_DBUS_OBJ_PATH, RM_DBUS_INTERFACE_NAME,\r
-                                                                               method, args, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);\r
-       rm_clear_cpu_inheritance();\r
-\r
-       if (!reply) {\r
-               RM_ERR("Method Call '%s' Failed (%s)", method, err->message);\r
-               g_error_free(err);\r
-               return -1;\r
-       }\r
-\r
-       if (result)\r
-               *result = reply;\r
-\r
-       return 0;\r
-}\r
-\r
-int rm_dbus_method_call_async_with_no_reply(const char *method, GVariant *args)\r
-{\r
-       if (!method) {\r
-               RM_ERR("Invalid Argument");\r
-               g_variant_unref(args);\r
-               return -1;\r
-       }\r
-\r
-       RM_INFO("Method call (async) '%s'", method);\r
-\r
-       if (!_wait_server_ready()) {\r
-               RM_ERR("server is not ready yet");\r
-               return -1;\r
-       }\r
-\r
-       GDBusConnection *conn = __dbus_get_connection();\r
-       if (!conn) {\r
-               g_variant_unref(args);\r
-               return -1;\r
-       }\r
-\r
-       g_dbus_connection_call(conn, RM_DBUS_BUS_NAME, RM_DBUS_OBJ_PATH, RM_DBUS_INTERFACE_NAME,\r
-                                                                               method, args, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);\r
-\r
-       return 0;\r
-}\r
-// LCOV_EXCL_STOP\r
+/*
+ * Copyright (c) 2024 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 <stdlib.h>
+#include <stdint.h>
+#include <unistd.h>
+
+#include <rm_dbus.h>
+#include <rm_debug.h>
+
+// LCOV_EXCL_START
+
+static bool _wait_server_ready(void)
+{
+       const char *rsc_event_name = "/run/rsc_mgr_ready";
+
+       return access(rsc_event_name, F_OK) == 0;
+}
+
+static GDBusConnection* __dbus_get_connection()
+{
+       static GDBusConnection *conn = NULL;
+       GError *err = NULL;
+
+       if (conn)
+               return conn;
+
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+       if (!conn)      {
+               RM_ERR("g_bus_get_sync() error (%s)", err->message);
+               g_error_free(err);
+               return NULL;
+       }
+
+       return conn;
+}
+
+void rm_set_cpu_inheritance(void)
+{
+       //resource_set_cpu_inheritance(0, "rscmgr-service", 1000);
+}
+
+void rm_clear_cpu_inheritance(void)
+{
+       //resource_clear_cpu_inheritance(0, "rscmgr-service");
+}
+
+int rm_dbus_method_call(const char *method, GVariant *args, GVariant **result)
+{
+       GError *err = NULL;
+       GVariant *reply = NULL;
+       GDBusConnection *conn = NULL;
+
+       if (!method) {
+               RM_ERR("Invalid Argument");
+               g_variant_unref(args);
+               return -1;
+       }
+
+       RM_INFO("Method call '%s'", method);
+
+       if (!_wait_server_ready()) {
+               RM_ERR("server is not ready yet");
+               g_variant_unref(args);
+               return -1;
+       }
+
+       conn = __dbus_get_connection();
+
+       if (!conn) {
+               g_variant_unref(args);
+               return -1;
+       }
+
+       rm_set_cpu_inheritance();
+       reply = g_dbus_connection_call_sync(conn, RM_DBUS_BUS_NAME, RM_DBUS_OBJ_PATH, RM_DBUS_INTERFACE_NAME,
+                                                                               method, args, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+       rm_clear_cpu_inheritance();
+
+       if (!reply) {
+               RM_ERR("Method Call '%s' Failed (%s)", method, err->message);
+               g_error_free(err);
+               return -1;
+       }
+
+       if (result)
+               *result = reply;
+
+       return 0;
+}
+
+int rm_dbus_method_call_async_with_no_reply(const char *method, GVariant *args)
+{
+       if (!method) {
+               RM_ERR("Invalid Argument");
+               g_variant_unref(args);
+               return -1;
+       }
+
+       RM_INFO("Method call (async) '%s'", method);
+
+       if (!_wait_server_ready()) {
+               RM_ERR("server is not ready yet");
+               return -1;
+       }
+
+       GDBusConnection *conn = __dbus_get_connection();
+       if (!conn) {
+               g_variant_unref(args);
+               return -1;
+       }
+
+       g_dbus_connection_call(conn, RM_DBUS_BUS_NAME, RM_DBUS_OBJ_PATH, RM_DBUS_INTERFACE_NAME,
+                                                                               method, args, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
+
+       return 0;
+}
+// LCOV_EXCL_STOP
index f3dde0312a2895cdb572f473541acf3645bf90b7..7eb9f52c18887d57b25208a29814c264df12967f 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include <rm_debug.h>\r
-#include <sys/types.h>\r
-#include <sys/stat.h>\r
-#include <unistd.h>\r
-\r
-// LCOV_EXCL_START\r
-const char *rm_convert_requested_state_enum_to_string(rm_requests_resource_state_e state_enum)\r
-{\r
-       switch(state_enum) {\r
-               case RM_STATE_PASSIVE:\r
-                       return "PASSIVE";\r
-               case RM_STATE_SHARABLE:\r
-                       return "SHARABLE";\r
-               case RM_STATE_EXCLUSIVE:\r
-                       return "EXCLUSIVE";\r
-               case RM_STATE_EXCLUSIVE_CONDITIONAL:\r
-                       return "EXCLUSIVE_CONDITIONAL";\r
-               case RM_STATE_EXCLUSIVE_AUTO:\r
-                       return "EXCLUSIVE_AUTO";\r
-               case RM_STATE_EXCLUSIVE_PREFERENCE:\r
-                       return "EXCLUSIVE_PREFERENCE";\r
-               default:\r
-                       return "NONE";\r
-       }\r
-}\r
-\r
-const char *rm_convert_category_enum_to_string(rm_rsc_category_e category_enum)\r
-{\r
-       switch(category_enum) {\r
-               case RM_CATEGORY_NONE:\r
-                       return "NONE";\r
-               case RM_CATEGORY_AUDIO_DECODER:\r
-                       return "Audio_Decoder";\r
-               case RM_CATEGORY_AUDIO_DECODER_PRIMARY:\r
-                       return "Audio_Decoder_Primary";\r
-               case RM_CATEGORY_AUDIO_EVENT_COMPRESS:\r
-                       return "Audio_Event_Compress";\r
-               case RM_CATEGORY_AUDIO_SPDIF_ES_OUTPUT:\r
-                       return "Not Defined Yet";\r
-               case RM_CATEGORY_VIDEO_DECODER:\r
-                       return "Video_Decoder";\r
-               case RM_CATEGORY_DEMUX:\r
-                       return "Demux_Main";\r
-               case RM_CATEGORY_AUDIO_ENCODER:\r
-                       return "Audio_Encoder";\r
-               case RM_CATEGORY_VIDEO_ENCODER:\r
-                       return "Video_Encoder";\r
-               case RM_CATEGORY_SCALER:\r
-                       return "Video_Scaler";\r
-               case RM_CATEGORY_TUNER:\r
-                       return "Tuner";\r
-               case RM_CATEGORY_AUDIO_MAIN_OUT:\r
-                       return "Audio_Main_Out";\r
-               case RM_CATEGORY_AUDIO_REMOTE_OUT:\r
-                       return "Audio_Remote_Out";\r
-               case RM_CATEGORY_AUDIO_SCART_OUT:\r
-                       return "Audio_Scart_Out";\r
-               case RM_CATEGORY_MM_PCM_OUT:\r
-                       return "MM_PCM_playback";\r
-               case RM_CATEGORY_AUDIO_DECODER_SUB:\r
-                       return "Audio_Decorder_Sub";\r
-               case RM_CATEGORY_JPEG_DECODER:\r
-                       return "JPEG_Decoder";\r
-               case RM_CATEGORY_MJPEG_DECODER:\r
-                       return "MJPEG_Decoder";\r
-               case RM_CATEGORY_SCALER_SUB:\r
-                       return "Video_Scaler_Sub";\r
-               case RM_CATEGORY_EXT_VIDEO_SRC:\r
-                       return "Ext_Video_Src";\r
-               case RM_CATEGORY_EXT_AUDIO_SRC:\r
-                       return "Ext_Audio_Src";\r
-               case RM_CATEGORY_EXT_HDMI_SRC:\r
-                       return "Ext_HDMI_Src";\r
-               case RM_CATEGORY_VIDEO_DECODER_SUB:\r
-                       return "Video_Decoder_Sub";\r
-               case RM_CATEGORY_CAMERA:\r
-                       return "Camera";\r
-               case RM_CATEGORY_DEMUX_REC:\r
-                       return "Demux_Rec";\r
-               case RM_CATEGORY_TUNER_SUB:\r
-                       return "Tuner_Sub";\r
-               case RM_CATEGORY_VIDEO_DECODER_UHD:\r
-                       return "Video_Decoder UHD";\r
-               case RM_CATEGORY_INPUT_SRC_DTV:\r
-                       return "Input_Src_DTV";\r
-               case RM_CATEGORY_INPUT_SRC_ATV:\r
-                       return "Input_Src_ATV";\r
-               case RM_CATEGORY_INPUT_SRC_HDMI:\r
-                       return "Input_Src_HDMI";\r
-               case RM_CATEGORY_INPUT_SRC_COMP:\r
-                       return "Input_Src_COMP";\r
-               case RM_CATEGORY_INPUT_SRC_AV:\r
-                       return "Input_Src_AV";\r
-               case RM_CATEGORY_INPUT_SRC_SCART:\r
-                       return "Input_Src_SCART";\r
-\r
-               default:\r
-                       return "";\r
-       }\r
-}\r
-\r
-int is_symlink_file(const char *path)\r
-{\r
-       struct stat st;\r
-       if (lstat(path, &st) == -1) {\r
-               RM_ERR("stat error. file path(%s)", path);\r
-               return 0;\r
-       }\r
-\r
-       return (S_ISLNK(st.st_mode)) ? 1 : 0;\r
-}\r
-// LCOV_EXCL_STOP\r
+/*
+ * Copyright (c) 2024 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 <rm_debug.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+// LCOV_EXCL_START
+const char *rm_convert_requested_state_enum_to_string(rm_requests_resource_state_e state_enum)
+{
+       switch(state_enum) {
+               case RM_STATE_PASSIVE:
+                       return "PASSIVE";
+               case RM_STATE_SHARABLE:
+                       return "SHARABLE";
+               case RM_STATE_EXCLUSIVE:
+                       return "EXCLUSIVE";
+               case RM_STATE_EXCLUSIVE_CONDITIONAL:
+                       return "EXCLUSIVE_CONDITIONAL";
+               case RM_STATE_EXCLUSIVE_AUTO:
+                       return "EXCLUSIVE_AUTO";
+               case RM_STATE_EXCLUSIVE_PREFERENCE:
+                       return "EXCLUSIVE_PREFERENCE";
+               default:
+                       return "NONE";
+       }
+}
+
+const char *rm_convert_category_enum_to_string(rm_rsc_category_e category_enum)
+{
+       switch(category_enum) {
+               case RM_CATEGORY_NONE:
+                       return "NONE";
+               case RM_CATEGORY_AUDIO_DECODER:
+                       return "Audio_Decoder";
+               case RM_CATEGORY_AUDIO_DECODER_PRIMARY:
+                       return "Audio_Decoder_Primary";
+               case RM_CATEGORY_AUDIO_EVENT_COMPRESS:
+                       return "Audio_Event_Compress";
+               case RM_CATEGORY_AUDIO_SPDIF_ES_OUTPUT:
+                       return "Not Defined Yet";
+               case RM_CATEGORY_VIDEO_DECODER:
+                       return "Video_Decoder";
+               case RM_CATEGORY_DEMUX:
+                       return "Demux_Main";
+               case RM_CATEGORY_AUDIO_ENCODER:
+                       return "Audio_Encoder";
+               case RM_CATEGORY_VIDEO_ENCODER:
+                       return "Video_Encoder";
+               case RM_CATEGORY_SCALER:
+                       return "Video_Scaler";
+               case RM_CATEGORY_TUNER:
+                       return "Tuner";
+               case RM_CATEGORY_AUDIO_MAIN_OUT:
+                       return "Audio_Main_Out";
+               case RM_CATEGORY_AUDIO_REMOTE_OUT:
+                       return "Audio_Remote_Out";
+               case RM_CATEGORY_AUDIO_SCART_OUT:
+                       return "Audio_Scart_Out";
+               case RM_CATEGORY_MM_PCM_OUT:
+                       return "MM_PCM_playback";
+               case RM_CATEGORY_AUDIO_DECODER_SUB:
+                       return "Audio_Decorder_Sub";
+               case RM_CATEGORY_JPEG_DECODER:
+                       return "JPEG_Decoder";
+               case RM_CATEGORY_MJPEG_DECODER:
+                       return "MJPEG_Decoder";
+               case RM_CATEGORY_SCALER_SUB:
+                       return "Video_Scaler_Sub";
+               case RM_CATEGORY_EXT_VIDEO_SRC:
+                       return "Ext_Video_Src";
+               case RM_CATEGORY_EXT_AUDIO_SRC:
+                       return "Ext_Audio_Src";
+               case RM_CATEGORY_EXT_HDMI_SRC:
+                       return "Ext_HDMI_Src";
+               case RM_CATEGORY_VIDEO_DECODER_SUB:
+                       return "Video_Decoder_Sub";
+               case RM_CATEGORY_CAMERA:
+                       return "Camera";
+               case RM_CATEGORY_DEMUX_REC:
+                       return "Demux_Rec";
+               case RM_CATEGORY_TUNER_SUB:
+                       return "Tuner_Sub";
+               case RM_CATEGORY_VIDEO_DECODER_UHD:
+                       return "Video_Decoder UHD";
+               case RM_CATEGORY_INPUT_SRC_DTV:
+                       return "Input_Src_DTV";
+               case RM_CATEGORY_INPUT_SRC_ATV:
+                       return "Input_Src_ATV";
+               case RM_CATEGORY_INPUT_SRC_HDMI:
+                       return "Input_Src_HDMI";
+               case RM_CATEGORY_INPUT_SRC_COMP:
+                       return "Input_Src_COMP";
+               case RM_CATEGORY_INPUT_SRC_AV:
+                       return "Input_Src_AV";
+               case RM_CATEGORY_INPUT_SRC_SCART:
+                       return "Input_Src_SCART";
+
+               default:
+                       return "";
+       }
+}
+
+int is_symlink_file(const char *path)
+{
+       struct stat st;
+       if (lstat(path, &st) == -1) {
+               RM_ERR("stat error. file path(%s)", path);
+               return 0;
+       }
+
+       return (S_ISLNK(st.st_mode)) ? 1 : 0;
+}
+// LCOV_EXCL_STOP
index 8cb6d5f5d975ba335436f89e25e920ba5a293c9f..6567c4f5abb5b230c5ce5cd4401d12b138449b8b 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include <stdio.h>\r
-#include <assert.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include <rm_debug.h>\r
-#include <rm_internal.h>\r
-#include <rm_dbus.h>\r
-#include <rm_module_api.h>\r
-#include <rm_callback.h>\r
-#include <rm_module_api.h>\r
-#include <rm_shm_api.h>\r
-\r
-// LCOV_EXCL_START\r
-\r
-#define RMS_INITIALIZED (access("/run/rsc_mgr_ready", F_OK) == 0)\r
-\r
-void rm_wait_for_server_ready(void)\r
-{\r
-       while (!RMS_INITIALIZED) {\r
-               RM_INFO("waiting for server ready");\r
-               usleep(50*1000); // 50ms\r
-       }\r
-       RM_WARN("resource manager server is ready !!!");\r
-}\r
-\r
-int rm_get_resource_state(int rsc_id, rm_resource_state_e *state)\r
-{\r
-       RM_RETURN_ERR_IF_NULL(state, "invalid parameter");\r
-       if (rsc_id < 0) {\r
-               RM_ERR("invalid resource id (%d)", rsc_id);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       int ret = RM_OK;\r
-       int rsc_state = 0;\r
-       GVariant *result = NULL;\r
-\r
-       ret = rm_dbus_method_call("GetResourceState",\r
-                                                       g_variant_new("(i)", rsc_id),\r
-                                                       &result);\r
-\r
-       if (ret) {\r
-               RM_ERR("dbus_method_call() for FindDeviceId is failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       g_variant_get(result, "(i)", &rsc_state);\r
-\r
-       if (rsc_state < 0) {\r
-               RM_ERR("can't get state(%d : %d)", rsc_id, rsc_state);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       *state = (rm_resource_state_e) rsc_state;\r
-       RM_INFO("state (%d : %d)", rsc_id, rsc_state);\r
-       g_variant_unref(result);\r
-       return RM_OK;\r
-}\r
-\r
-int rm_get_scaler_state(rm_resource_list_h *list)\r
-{\r
-       RM_RETURN_ERR_IF_NULL(list, "invalid parameter");\r
-\r
-       int ret = RM_OK;\r
-       GVariant *result = NULL;\r
-       rm_resource_list *list_reply = NULL;\r
-\r
-       list_reply = (rm_resource_list*) calloc(1, sizeof(rm_resource_list));\r
-       assert(list_reply);\r
-       list_reply->n_rsc = 0;\r
-       *list = list_reply;\r
-\r
-       ret = rm_dbus_method_call("GetScalerState",\r
-                                                       g_variant_new("(i)", RM_CATEGORY_SCALER),\r
-                                                       &result);\r
-\r
-       if (ret) {\r
-               RM_ERR("dbus_method_call() for GetScalerState is failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       int category_id;\r
-       int cur_category_id;\r
-       int rsc_id;\r
-       int state;\r
-       int cid;\r
-       int zone_id;\r
-       int android_app;\r
-       gchar *app_id;\r
-\r
-       GVariantIter *iter;\r
-       g_variant_get(result, "(a(iiiiiisi))", &iter);\r
-\r
-       while (g_variant_iter_loop(iter, "(iiiiiisi)", &category_id, &cur_category_id, &rsc_id, &state, &cid, &zone_id, &app_id, &android_app)) {\r
-               rm_resource *resource = (rm_resource*) calloc(1, sizeof(rm_resource));\r
-               assert(resource);\r
-               resource->category_id = category_id;\r
-               resource->cur_category_id = cur_category_id;\r
-               resource->id = rsc_id;\r
-               resource->state = state;\r
-               resource->consumer_id = cid;\r
-               resource->zone_id = zone_id;\r
-               RM_INFO("(%d : %s)", resource->id, app_id ? app_id : "null");\r
-               resource->app_id = (app_id) ? (char*) strndup(app_id, strlen(app_id)) : NULL;\r
-               resource->android_app = android_app;\r
-               list_reply->rsc_list = g_list_append(list_reply->rsc_list, resource);\r
-       }\r
-       g_variant_iter_free(iter);\r
-\r
-       list_reply->n_rsc = g_list_length(list_reply->rsc_list);\r
-       list_reply->iter = list_reply->rsc_list;\r
-\r
-       g_variant_unref(result);\r
-       return ret;\r
-}\r
-\r
-int rm_get_resource_list(rm_rsc_category_e category, rm_resource_list_h *list)\r
-{\r
-       RM_RETURN_ERR_IF_NULL(list, "invalid parameter");\r
-\r
-       int ret = RM_OK;\r
-       GVariant *result = NULL;\r
-       rm_resource_list *list_reply = NULL;\r
-\r
-       list_reply = (rm_resource_list*) calloc(1, sizeof(rm_resource_list));\r
-       assert(list_reply);\r
-       list_reply->n_rsc = 0;\r
-       *list = list_reply;\r
-\r
-       ret = rm_dbus_method_call("GetResourceList",\r
-                                                       g_variant_new("(i)", category),\r
-                                                       &result);\r
-\r
-       if (ret) {\r
-               RM_ERR("dbus_method_call() for GetResourceList is failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       int rsc_id;\r
-       int rsc_state;\r
-       int cid;\r
-       gchar *dev_node;\r
-       gchar *app_id;\r
-\r
-       GVariantIter *iter;\r
-       g_variant_get(result, "(a(iissi))", &iter);\r
-\r
-       while (g_variant_iter_loop(iter, "(iissi)", &rsc_id, &rsc_state, &dev_node, &app_id, &cid)) {\r
-               rm_resource *resource = (rm_resource*) calloc(1, sizeof(rm_resource));\r
-               assert(resource);\r
-               resource->id = rsc_id;\r
-               resource->state = rsc_state;\r
-               resource->consumer_id = cid;\r
-               resource->support_overlay = ri_is_overlay_supported(rsc_id);\r
-               resource->max_rez = ri_get_supported_max_resolution(rsc_id);\r
-               resource->max_sampling_format = ri_get_max_sampling_format(rsc_id);\r
-               int category_id = 0;\r
-               if (ri_get_category_type_by_device_id(rsc_id, &category_id) != RI_OK) {\r
-                       RM_ERR("failed to get category of (%d)", rsc_id);\r
-               }\r
-               resource->category_id = category_id;\r
-\r
-               RM_INFO("(%d:%s)", resource->id, dev_node?dev_node : "null");\r
-               resource->node = (dev_node) ? (char*) strndup(dev_node, strlen(dev_node)) : NULL;\r
-               resource->app_id = (app_id) ? (char*) strndup(app_id, strlen(app_id)) : NULL;\r
-               list_reply->rsc_list = g_list_append(list_reply->rsc_list, resource);\r
-       }\r
-\r
-       g_variant_iter_free(iter);\r
-\r
-       list_reply->n_rsc = g_list_length(list_reply->rsc_list);\r
-       list_reply->iter = list_reply->rsc_list;\r
-\r
-       g_variant_unref(result);\r
-       return ret;\r
-}\r
-\r
-static void rm_resource_free(gpointer data)\r
-{\r
-       rm_resource *resource = (rm_resource*) data;\r
-       RM_RETURN_IF_NULL(resource, "resource null");\r
-       RM_FREE(resource->node);\r
-       RM_FREE(resource->app_id);\r
-       RM_FREE(resource);\r
-}\r
-\r
-void rm_free_resource_list(rm_resource_list_h list)\r
-{\r
-       if (!list)\r
-               return;\r
-\r
-       g_list_free_full(list->rsc_list, rm_resource_free);\r
-       RM_FREE(list);\r
-}\r
-\r
-rm_resource_h rm_resource_list_get_next(rm_resource_list_h list)\r
-{\r
-       RM_RETURN_NULL_IF_NULL(list, "invalid list");\r
-       RM_RETURN_NULL_IF_NULL(list->rsc_list, "no device in resource list");\r
-       RM_RETURN_NULL_IF_NULL(list->iter, "no device in resource list");\r
-\r
-       GList *tmp = g_list_next(list->iter);\r
-\r
-       RM_RETURN_NULL_IF_NULL(tmp, "no next resource");\r
-\r
-       list->iter = tmp;\r
-       return (rm_resource_h) list->iter->data;\r
-}\r
-\r
-rm_resource_h rm_resource_list_get_prev(rm_resource_list_h list)\r
-{\r
-       RM_RETURN_NULL_IF_NULL(list, "invalid list");\r
-       RM_RETURN_NULL_IF_NULL(list->rsc_list, "no device in resource list");\r
-       RM_RETURN_NULL_IF_NULL(list->iter, "no device in resource list");\r
-\r
-       GList *tmp = g_list_previous(list->iter);\r
-\r
-       RM_RETURN_NULL_IF_NULL(tmp, "no prev resource");\r
-\r
-       list->iter = tmp;\r
-       return (rm_resource_h) list->iter->data;\r
-}\r
-\r
-rm_resource_h rm_resource_list_get_first(rm_resource_list_h list)\r
-{\r
-       RM_RETURN_NULL_IF_NULL(list, "invalid list");\r
-       RM_RETURN_NULL_IF_NULL(list->rsc_list, "no device in resource list");\r
-       RM_RETURN_NULL_IF_NULL(list->iter, "no device in resource list");\r
-\r
-       GList *tmp = g_list_first(list->iter);\r
-\r
-       RM_RETURN_NULL_IF_NULL(tmp, "no first resource");\r
-\r
-       list->iter = tmp;\r
-       return (rm_resource_h) list->iter->data;\r
-}\r
-\r
-rm_resource_h rm_resource_list_get_last(rm_resource_list_h list)\r
-{\r
-       RM_RETURN_NULL_IF_NULL(list, "invalid list");\r
-       RM_RETURN_NULL_IF_NULL(list->rsc_list, "no device in resource list");\r
-       RM_RETURN_NULL_IF_NULL(list->iter, "no device in resource list");\r
-\r
-       GList *tmp = g_list_last(list->iter);\r
-\r
-       RM_RETURN_NULL_IF_NULL(tmp, "no last resource");\r
-\r
-       list->iter = tmp;\r
-       return (rm_resource_h) list->iter->data;\r
-}\r
-\r
-int rm_resource_list_get_count(rm_resource_list_h list)\r
-{\r
-       return (list) ? list->n_rsc : 0;\r
-}\r
-\r
-const char *rm_resource_get_node(rm_resource_h resource)\r
-{\r
-       RM_RETURN_NULL_IF_NULL(resource, "invalid parameter");\r
-       return resource->node;\r
-}\r
-\r
-int rm_resource_get_category(rm_resource_h resource)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(resource, "invalid parameter");\r
-       return resource->category_id;\r
-}\r
-\r
-int rm_resource_get_cur_category(rm_resource_h resource)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(resource, "invalid parameter");\r
-       return resource->cur_category_id;\r
-}\r
-\r
-int rm_resource_get_consumer(rm_resource_h resource)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(resource, "invalid parameter");\r
-       return resource->consumer_id;\r
-}\r
-\r
-int rm_resource_get_state(rm_resource_h resource)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(resource, "invalid parameter");\r
-       return resource->state;\r
-}\r
-\r
-const char *rm_resource_get_app_id(rm_resource_h resource)\r
-{\r
-       RM_RETURN_NULL_IF_NULL(resource, "invalid parameter");\r
-       return resource->app_id;\r
-}\r
-\r
-unsigned int rm_resource_get_framerate(rm_resource_h resource)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(resource, "invalid parameter");\r
-       return resource->framerate;\r
-}\r
-\r
-int rm_resource_get_id(rm_resource_h resource)\r
-{\r
-       return (resource) ? resource->id : -1;\r
-}\r
-\r
-int rm_resource_get_max_resolution(rm_resource_h resource)\r
-{\r
-       return (resource) ? resource->max_rez : -1;\r
-}\r
-\r
-bool rm_resource_support_overlay(rm_resource_h resource)\r
-{\r
-       return (resource) ? resource->support_overlay : false;\r
-}\r
-\r
-int rm_resource_get_max_sampling_format(rm_resource_h resource)\r
-{\r
-       return (resource) ? resource->max_sampling_format : -1;\r
-}\r
-\r
-int rm_resource_get_zone_id(rm_resource_h resource)\r
-{\r
-       return (resource) ? resource->zone_id : -1;\r
-}\r
-\r
-static unsigned int state_change_signal_id = 0;\r
-\r
-static void onResourceStateChanged(GDBusConnection *conn,\r
-               const gchar *sender,\r
-               const gchar *object,\r
-               const gchar *interface,\r
-               const gchar *signal,\r
-               GVariant *parameters,\r
-               gpointer user_data)\r
-{\r
-       int device_id;\r
-       int category_id;\r
-       int state;\r
-       int handle;\r
-       char *app_id;\r
-\r
-       g_variant_get(parameters, "(iiii&s)", &device_id, &category_id, &state, &handle, &app_id);\r
-       RM_INFO("signal (%s) received - (%d(%d) : %d : %d(%s))", signal, device_id, category_id, state, handle, app_id);\r
-       rm_call_state_changed_cb(category_id, device_id, state, handle, app_id);\r
-}\r
-\r
-int rm_subscribe_resource_state_change(rm_rsc_category_e category, resource_state_change_cb cb, void *data)\r
-{\r
-       RM_RETURN_ERR_IF_NULL(cb, "invalid parameter");\r
-\r
-       if (rm_add_state_change_cb(category, cb, data) < 0) {\r
-               RM_ERR("already registered cb (%d : %p)", category, cb);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       if (state_change_signal_id)\r
-               return RM_OK;\r
-\r
-       GError *error = NULL;\r
-       GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);\r
-       if (!connection) {\r
-               RM_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       state_change_signal_id = g_dbus_connection_signal_subscribe(connection,\r
-                       NULL,\r
-                       RM_DBUS_INTERFACE_NAME,\r
-                       "RscStateChanged",\r
-                       RM_DBUS_OBJ_PATH,\r
-                       NULL,\r
-                       G_DBUS_SIGNAL_FLAGS_NONE,\r
-                       onResourceStateChanged,\r
-                       NULL,\r
-                       NULL);\r
-\r
-       if (state_change_signal_id == 0) {\r
-               if (error) {\r
-                       RM_ERR("dbus connection close error: %s", error->message);\r
-                       g_clear_error(&error);\r
-               }\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("subscribe resource state changed (%d)", state_change_signal_id);\r
-       return RM_OK;\r
-}\r
-\r
-int rm_unsubscribe_resource_state_change(rm_rsc_category_e category, resource_state_change_cb cb)\r
-{\r
-       RM_RETURN_ERR_IF_NULL(cb, "invalid parameter");\r
-\r
-       int remain = 0;\r
-       if ((remain = rm_remove_state_change_cb(category, cb)) < 0) {\r
-               RM_ERR("not registered cb (%d:%p)", category, cb);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       if (remain > 0) {\r
-               RM_INFO("resource state change cb(%d:%p) removed", category, cb);\r
-               return RM_OK;\r
-       }\r
-\r
-       GError *error = NULL;\r
-       GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);\r
-       if (!connection) {\r
-               RM_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");\r
-               return RM_OK;\r
-       }\r
-\r
-       RM_INFO("remove state change signal id(%d)", state_change_signal_id);\r
-       g_dbus_connection_signal_unsubscribe(connection, state_change_signal_id);\r
-       state_change_signal_id = 0;\r
-\r
-       return RM_OK;\r
-}\r
-\r
-int rm_rsc_state_get_category(rm_resource_state_h state)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(state, "invalid state");\r
-       return state->catId;\r
-}\r
-\r
-int rm_rsc_state_get_device_id(rm_resource_state_h state)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(state, "invalid state");\r
-       return state->devId;\r
-}\r
-\r
-int rm_rsc_state_get_state(rm_resource_state_h state)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(state, "invalid state");\r
-       return state->state;\r
-}\r
-\r
-int rm_rsc_state_get_consumer_id(rm_resource_state_h state)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(state, "invalid state");\r
-       return state->consumerId;\r
-}\r
-\r
-char *rm_rsc_state_get_app_id(rm_resource_state_h state)\r
-{\r
-       RM_RETURN_NULL_IF_NULL(state, "invalid state");\r
-       return state->appId;\r
-}\r
-\r
-static void OnResourceConflictEvent(GDBusConnection *conn,\r
-               const gchar *sender,\r
-               const gchar *object,\r
-               const gchar *interface,\r
-               const gchar *signal,\r
-               GVariant *parameters,\r
-               gpointer user_data)\r
-{\r
-       rm_conflict_resource rsc;\r
-       g_variant_get(parameters, "(iii&sii)", &rsc.catId, &rsc.devId, &rsc.cId, &rsc.appId, &rsc.aZoneId, &rsc.rZoneId);\r
-\r
-       RM_INFO("signal (%s) received - (%d:%d:%d:%s:%d:%d)", signal, rsc.catId, rsc.devId, rsc.cId, rsc.appId, rsc.aZoneId, rsc.rZoneId);\r
-\r
-       std::list<conflict_event_cb*> cb_list = rm_get_conflict_event_cb_list();\r
-\r
-       for (auto& it : cb_list) {\r
-               RM_INFO("call cb(%p)", it->cb);\r
-               it->cb(&rsc, it->data);\r
-       }\r
-}\r
-\r
-static unsigned int conflict_event_signal_id = 0;\r
-\r
-int rm_subscribe_resource_conflict_event(rm_conflict_event_cb cb, void *data)\r
-{\r
-       RM_RETURN_ERR_IF_NULL(cb, "invalid cb");\r
-\r
-       if (rm_add_conflict_event_cb(cb, data) < 0) {\r
-               RM_ERR("already registered cb(%p)", cb);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       if (conflict_event_signal_id)\r
-               return RM_OK;\r
-\r
-       GError *error = NULL;\r
-       GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);\r
-       if (!connection) {\r
-               RM_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");\r
-               rm_remove_conflict_event_cb(cb);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       conflict_event_signal_id = g_dbus_connection_signal_subscribe(connection,\r
-                       NULL,\r
-                       RM_DBUS_INTERFACE_NAME,\r
-                       "RscConflicted",\r
-                       RM_DBUS_OBJ_PATH,\r
-                       NULL,\r
-                       G_DBUS_SIGNAL_FLAGS_NONE,\r
-                       OnResourceConflictEvent,\r
-                       NULL,\r
-                       NULL);\r
-\r
-       if (conflict_event_signal_id == 0) {\r
-               if (error) {\r
-                       RM_ERR("dbus connection close error: %s", error->message);\r
-                       g_clear_error(&error);\r
-                       rm_remove_conflict_event_cb(cb);\r
-               }\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("subscribe conflict event (%d)", conflict_event_signal_id);\r
-\r
-       return RM_OK;\r
-}\r
-\r
-int rm_unsubscribe_resource_conflict_event(rm_conflict_event_cb cb)\r
-{\r
-       RM_RETURN_ERR_IF_NULL(cb, "invalid cb");\r
-\r
-       int remain = 0;\r
-       if ((remain = rm_remove_conflict_event_cb(cb)) < 0) {\r
-               RM_ERR("unregistered cb(%p)", cb);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("callback unregistered(%p)-(%d)", cb, remain);\r
-\r
-       if (remain > 0)\r
-               return RM_OK;\r
-\r
-       GError *error = NULL;\r
-       GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);\r
-       if (!connection) {\r
-               RM_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");\r
-               return RM_OK;\r
-       }\r
-\r
-       RM_INFO("remove conflict event signal id(%d)", conflict_event_signal_id);\r
-       g_dbus_connection_signal_unsubscribe(connection, conflict_event_signal_id);\r
-       conflict_event_signal_id = 0;\r
-\r
-       return RM_OK;\r
-}\r
-\r
-int rm_conflict_get_category_id(rm_conflict_resource_h rsc)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(rsc, "invalid rsc");\r
-       return rsc->catId;\r
-}\r
-\r
-int rm_conflict_get_device_id(rm_conflict_resource_h rsc)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(rsc, "invalid rsc");\r
-       return rsc->devId;\r
-}\r
-\r
-int rm_conflict_get_consumer_id(rm_conflict_resource_h rsc)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(rsc, "invalid rsc");\r
-       return rsc->cId;\r
-}\r
-\r
-const char *rm_conflict_get_app_id(rm_conflict_resource_h rsc)\r
-{\r
-       RM_RETURN_NULL_IF_NULL(rsc, "invalid rsc");\r
-       return rsc->appId;\r
-}\r
-\r
-int rm_conflict_get_multiview_zone_id_consumer(rm_conflict_resource_h rsc)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(rsc, "invalid rsc");\r
-       return rsc->aZoneId;\r
-}\r
-\r
-int rm_conflict_get_multiview_zone_id_requester(rm_conflict_resource_h rsc)\r
-{\r
-       RM_RETURN_MINUS_IF_NULL(rsc, "invalid rsc");\r
-       return rsc->rZoneId;\r
-}\r
-\r
-int rm_get_resource_collection_state(rm_rsc_collection_e collection, rm_resource_list_h *list)\r
-{\r
-       RM_RETURN_ERR_IF_NULL(list, "invalid parameter");\r
-\r
-       int ret;\r
-       GVariant *result = NULL;\r
-       rm_resource_list *list_reply = NULL;\r
-\r
-       list_reply = (rm_resource_list*) calloc(1, sizeof(rm_resource_list));\r
-       assert(list_reply);\r
-       list_reply->n_rsc = 0;\r
-       *list = list_reply;\r
-\r
-       ret = rm_dbus_method_call("GetRscCollectionState",\r
-                                                       g_variant_new("(i)", collection),\r
-                                                       &result);\r
-\r
-       if (ret) {\r
-               RM_ERR("dbus_method_call() for GetRscCollectionState is failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       int rsc_id;\r
-       int rsc_state;\r
-       int rsc_category;\r
-       int cid;\r
-       int zone_id;\r
-       int android_app;\r
-       gchar *app_id;\r
-       gchar *dev_node;\r
-\r
-       GVariantIter *iter;\r
-       g_variant_get(result, "(a(isiiisii))", &iter);\r
-\r
-       while (g_variant_iter_loop(iter, "(isiiisii)", &rsc_id, &dev_node, &rsc_state, &rsc_category, &cid, &app_id, &zone_id, &android_app)) {\r
-               rm_resource *resource = (rm_resource*) calloc(1, sizeof(rm_resource));\r
-               assert(resource);\r
-               resource->id = rsc_id;\r
-               RM_INFO("(%d:%s)", resource->id, dev_node?dev_node : "null");\r
-               resource->node = (dev_node) ? (char*) strndup(dev_node, strlen(dev_node)) : NULL;\r
-               resource->state = rsc_state;\r
-               resource->category_id = rsc_category;\r
-               resource->framerate = ri_get_video_category_framerate(rsc_category);\r
-               resource->consumer_id = cid;\r
-               resource->app_id = (app_id) ? (char*) strndup(app_id, strlen(app_id)) : NULL;\r
-               resource->zone_id = zone_id;\r
-               resource->android_app = android_app;\r
-               list_reply->rsc_list = g_list_append(list_reply->rsc_list, resource);\r
-       }\r
-\r
-       g_variant_iter_free(iter);\r
-\r
-       list_reply->n_rsc = g_list_length(list_reply->rsc_list);\r
-       list_reply->iter = list_reply->rsc_list;\r
-\r
-       g_variant_unref(result);\r
-       return ret;\r
-}\r
-\r
-int rm_unmask_category_options(int category)\r
-{\r
-       int result = category;\r
-\r
-       result = (result & ~RM_DEVICE_OPT_MAIN);\r
-       result = (result & ~RM_DEVICE_OPT_SUB);\r
-\r
-       return ri_unmask_category_options(result);\r
-}\r
-\r
-int rm_find_device_id(int virtual_id)\r
-{\r
-       if (virtual_id < 0) {\r
-               RM_ERR("invalid resource id (%d)", virtual_id);\r
-               return -1;\r
-       }\r
-\r
-       int real_id = 0;\r
-       if (rm_shm_find_device_id(virtual_id, &real_id) == RM_OK) {\r
-               RM_INFO("real id (%d:%d)", virtual_id, real_id);\r
-               return real_id;\r
-       }\r
-\r
-       int ret = RM_OK;\r
-\r
-       GVariant *result = NULL;\r
-\r
-       ret = rm_dbus_method_call("FindDeviceId",\r
-                                               g_variant_new("(i)", virtual_id),\r
-                                               &result);\r
-\r
-       if (ret) {\r
-               RM_ERR("dbus_method_call() for FindDeviceId is failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       g_variant_get(result, "(i)", &real_id);\r
-\r
-       RM_INFO("real id (%d:%d)", virtual_id, real_id);\r
-\r
-       g_variant_unref(result);\r
-       return real_id;\r
-}\r
-\r
-int rm_swap_resources(int device_id_a, int device_id_b)\r
-{\r
-       if ((device_id_a < 0) || (device_id_b < 0)) {\r
-               RM_ERR("invalid resource id (%d/%d)", device_id_a, device_id_b);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       int ret = RM_OK;\r
-       int swap_result = 0;\r
-       GVariant *result = NULL;\r
-\r
-       ret = rm_dbus_method_call("SwapResources",\r
-                                               g_variant_new("(ii)", device_id_a, device_id_b),\r
-                                               &result);\r
-\r
-       if (ret) {\r
-               RM_ERR("dbus_method_call() for SwapResources is failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       g_variant_get(result, "(i)", &swap_result);\r
-\r
-       if (swap_result < 0) {\r
-               RM_ERR("faild to swap resources(%d:%d)", device_id_a, device_id_b);\r
-               ret = RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("swapped (%d:%d)", device_id_a, device_id_b);\r
-\r
-       g_variant_unref(result);\r
-       return ret;\r
-}\r
-\r
-int rm_swap_resources_async(int device_id_a, int device_id_b)\r
-{\r
-       if ((device_id_a < 0) || (device_id_b < 0)) {\r
-               RM_ERR("invalid resource id (%d/%d)", device_id_a, device_id_b);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       int ret = rm_dbus_method_call_async_with_no_reply("SwapResources",\r
-                                                       g_variant_new("(ii)", device_id_a, device_id_b));\r
-       if (ret) {\r
-               RM_ERR("dbus_method_call() for SwapResourcesAsync is failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("swapped requested (%d:%d)", device_id_a, device_id_b);\r
-       return RM_OK;\r
-}\r
-\r
-int rm_restore_resources(int category)\r
-{\r
-       if (category < 0) {\r
-               RM_ERR("invalid category id (%d)", category);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       int ret = RM_OK;\r
-       int restore_result = 0;\r
-       GVariant *result = NULL;\r
-\r
-       ret = rm_dbus_method_call("RestoreResources",\r
-                                                       g_variant_new("(i)", category),\r
-                                                       &result);\r
-\r
-       if (ret) {\r
-               RM_ERR("dbus_method_call() for RestoreResources is failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       g_variant_get(result, "(i)", &restore_result);\r
-\r
-       if (restore_result < 0) {\r
-               RM_ERR("faild to restore resources(%d)", category);\r
-               ret = RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("restored (%d)", category);\r
-\r
-       g_variant_unref(result);\r
-       return ret;\r
-}\r
-\r
-int rm_get_app_id(int handle, char**app_id)\r
-{\r
-       if (handle < 0 || !app_id) {\r
-               RM_ERR("invalid param (%d)", handle);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       if (rm_shm_get_app_id(handle, app_id) == RM_OK)\r
-               return RM_OK;\r
-\r
-       int ret = RM_OK;\r
-       int dbus_ret = 0;\r
-       char *ret_val = NULL;\r
-       GVariant *result = NULL;\r
-\r
-       ret = rm_dbus_method_call("GetAppId",\r
-                                                       g_variant_new("(i)", handle),\r
-                                                       &result);\r
-\r
-       if (ret) {\r
-               RM_ERR("dbus_method_call() for GetAppId is failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       g_variant_get(result, "(i&s)", &dbus_ret, &ret_val);\r
-\r
-       if (dbus_ret < 0)\r
-               ret = RM_ERROR;\r
-\r
-       if (ret_val)\r
-               *app_id = strndup(ret_val, strlen(ret_val));\r
-\r
-       RM_INFO("(%d) - app_id(%d : %s)", dbus_ret, handle, (ret_val) ? *app_id : "null");\r
-\r
-       g_variant_unref(result);\r
-       return ret;\r
-}\r
-\r
-int rm_get_active_audio_out(int handle)\r
-{\r
-       if (handle < 0) {\r
-               RM_ERR("invalid handle(%d)", handle);\r
-               return -1;\r
-       }\r
-\r
-       int active_audio_out = 0;\r
-       if (rm_shm_get_active_audio_out(handle, &active_audio_out) == RM_OK)\r
-               return active_audio_out;\r
-\r
-       int ret = 0;\r
-       GVariant *result = NULL;\r
-\r
-       ret = rm_dbus_method_call("GetActiveAudioOut",\r
-                                                       g_variant_new("(i)", handle),\r
-                                                       &result);\r
-       if (ret) {\r
-               RM_ERR("dbus_method_call() for GetActiveAudioOut is failed");\r
-               return -1;\r
-       }\r
-\r
-       g_variant_get(result, "(i)", &active_audio_out);\r
-\r
-       RM_INFO("active audio out (%d:%d)", handle, active_audio_out);\r
-\r
-       g_variant_unref(result);\r
-       return active_audio_out;\r
-}\r
-\r
-int rm_scaler_get_virtual_id(rm_resource_h scaler)\r
-{\r
-       return (scaler) ? scaler->virtual_id : -1;\r
-}\r
-\r
-int rm_scaler_get_source_id(rm_resource_h scaler)\r
-{\r
-       return (scaler) ? scaler->source_id : -1;\r
-}\r
-\r
-static unsigned int scaler_change_signal_id = 0;\r
-static void onScalerStateChanged(GDBusConnection *conn,\r
-               const gchar *sender,\r
-               const gchar *object,\r
-               const gchar *interface,\r
-               const gchar *signal,\r
-               GVariant *param,\r
-               gpointer user_data)\r
-{\r
-       rm_resource_list *scaler_list = NULL;\r
-\r
-       scaler_list = (rm_resource_list*) calloc(1, sizeof(rm_resource_list));\r
-       assert(scaler_list);\r
-       scaler_list->n_rsc = 0;\r
-\r
-       int virtual_id;\r
-       int source_id;\r
-       GVariantIter *iter;\r
-       g_variant_get(param, "(a(ii))", &iter);\r
-\r
-       RM_INFO(">> scaler state changed");\r
-       while (g_variant_iter_loop(iter, "(ii)", &virtual_id, &source_id)) {\r
-               rm_resource *scaler = (rm_resource*) calloc(1, sizeof(rm_resource));\r
-               assert(scaler);\r
-\r
-               scaler->virtual_id = virtual_id;\r
-               scaler->source_id = source_id;\r
-               RM_INFO("(%d:%d)", scaler->virtual_id, scaler->source_id);\r
-\r
-               scaler_list->rsc_list = g_list_append(scaler_list->rsc_list, scaler);\r
-       }\r
-\r
-       g_variant_iter_free(iter);\r
-\r
-       scaler_list->n_rsc = g_list_length(scaler_list->rsc_list);\r
-       scaler_list->iter = scaler_list->rsc_list;\r
-\r
-       rm_call_scaler_state_changed_cb(scaler_list);\r
-\r
-       g_list_free_full(scaler_list->rsc_list, rm_resource_free);\r
-       RM_FREE(scaler_list);\r
-}\r
-\r
-int rm_subscribe_scaler_state_change(scaler_state_change_cb cb, void *data)\r
-{\r
-       RM_RETURN_ERR_IF_NULL(cb, "invalid parameter");\r
-\r
-       if (rm_add_scaler_state_change_cb(cb, data) < 0) {\r
-               RM_ERR("already registered cb (%p)", cb);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       if (scaler_change_signal_id)\r
-               return RM_OK;\r
-\r
-       GError *error = NULL;\r
-       GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);\r
-       if (!connection) {\r
-               RM_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       scaler_change_signal_id = g_dbus_connection_signal_subscribe(connection,\r
-                       NULL,\r
-                       RM_DBUS_INTERFACE_NAME,\r
-                       "ScalerStateChanged",\r
-                       RM_DBUS_OBJ_PATH,\r
-                       NULL,\r
-                       G_DBUS_SIGNAL_FLAGS_NONE,\r
-                       onScalerStateChanged,\r
-                       NULL,\r
-                       NULL);\r
-\r
-       if (scaler_change_signal_id == 0) {\r
-               if (error) {\r
-                       RM_ERR("dbus connection close error: %s", error->message);\r
-                       g_clear_error(&error);\r
-               }\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("subscribe resource state changed (%d)", scaler_change_signal_id);\r
-       return RM_OK;\r
-}\r
-\r
-int rm_unsubscribe_scaler_state_change(scaler_state_change_cb cb)\r
-{\r
-       RM_RETURN_ERR_IF_NULL(cb, "invalid parameter");\r
-\r
-       int remain = 0;\r
-       if ((remain = rm_remove_scaler_state_change_cb(cb)) < 0) {\r
-               RM_ERR("not registered cb (%p)", cb);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       if (remain > 0) {\r
-               RM_INFO("scaler state change cb(%p) removed", cb);\r
-               return RM_OK;\r
-       }\r
-\r
-       GError *error = NULL;\r
-       GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);\r
-       if (!connection) {\r
-               RM_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");\r
-               return RM_OK;\r
-       }\r
-\r
-       RM_INFO("remove scaler change signal id(%d)", scaler_change_signal_id);\r
-       g_dbus_connection_signal_unsubscribe(connection, scaler_change_signal_id);\r
-       scaler_change_signal_id = 0;\r
-\r
-       return RM_OK;\r
-}\r
-\r
-int rm_get_scaler_hw_id(int zone_id, int *id)\r
-{\r
-       if (zone_id <= 0) {\r
-               RM_ERR("invalid resource id (%d)", zone_id);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       if (rm_shm_find_scaler_hw_id(zone_id, id) == RM_OK)\r
-               return RM_OK;\r
-\r
-       int ret = RM_OK;\r
-       int hw_id = 0;\r
-       GVariant *result = NULL;\r
-\r
-       ret = rm_dbus_method_call("GetScalerHWID",\r
-                                                       g_variant_new("(i)", zone_id),\r
-                                                       &result);\r
-\r
-       if (ret) {\r
-               RM_ERR("dbus_method_call() for GetScalerHWID is failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       g_variant_get(result, "(i)", &hw_id);\r
-\r
-       if (hw_id < 0) {\r
-               RM_ERR("can't get hw id(%d:%d)", zone_id, hw_id);\r
-               g_variant_unref(result);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       *id = hw_id;\r
-       RM_INFO("hw id (%d:%d)", zone_id, hw_id);\r
-       g_variant_unref(result);\r
-       return RM_OK;\r
-}\r
-\r
-int rm_notify_resource_policy(int policy)\r
-{\r
-       if (policy < 0) {\r
-               RM_ERR("invalid policy (%d)", policy);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       int ret = rm_dbus_method_call_async_with_no_reply("NotifyResourcePolicy",\r
-                                                       g_variant_new("(i)", policy));\r
-\r
-       if (ret) {\r
-               RM_ERR("dbus_method_call() for NotifyResourcePolicy is failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("notified (%d)", policy);\r
-       return ret;\r
-}\r
-\r
-int rm_notify_app_zone_info_async(const char *app_id, int zone_id)\r
-{\r
-       if (!app_id || zone_id < -1) {\r
-               RM_ERR("invalid param (%d)", zone_id);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       if (rm_dbus_method_call_async_with_no_reply("NotifyAppZoneInfo", g_variant_new("(si)", app_id, zone_id)) != 0) {\r
-               RM_ERR("dbus_method_call() for NotifyAppZoneInfo is failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("notified (%s:%d)", app_id, zone_id);\r
-       return RM_OK;\r
-}\r
-\r
-int rm_reclaim_resources(int handle)\r
-{\r
-       RM_INFO("reclaim resources of (%d)", handle);\r
-\r
-       if (rm_dbus_method_call_async_with_no_reply("ReclaimResources", g_variant_new("(i)", handle)) != 0) {\r
-               RM_ERR("dbus call for ReclaimResources failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       return RM_OK;\r
-}\r
-\r
-int rm_reclaim_app_resources(const char *app_id, const bool notify)\r
-{\r
-       if (!app_id) {\r
-               RM_ERR("invalid app id");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("reclaim resources of (%s:%d)", app_id, notify);\r
-\r
-       GVariant *response = NULL;\r
-       if (rm_dbus_method_call("ReclaimAppResources", g_variant_new("(si)", app_id, notify), &response) != 0) {\r
-               RM_ERR("dbus call for ReclaimAppResources failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       int reclaim_result = 0;\r
-       g_variant_get(response, "(i)", &reclaim_result);\r
-\r
-       int result = (reclaim_result < 0) ? RM_ERROR : RM_OK;\r
-       RM_INFO("reclaime result (%s : %d)", app_id, result);\r
-\r
-       g_variant_unref(response);\r
-       return result;\r
-}\r
-\r
-int rm_reclaim_app_resources_async(const char *app_id, const bool notify)\r
-{\r
-       if (!app_id) {\r
-               RM_ERR("invalid app id");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("reclaim resources of (%s : %d)", app_id, notify);\r
-\r
-       if (rm_dbus_method_call_async_with_no_reply("ReclaimAppResources", g_variant_new("(si)", app_id, notify)) != 0) {\r
-               RM_ERR("dbus call for ReclaimAppResources failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       return RM_OK;\r
-}\r
-\r
-rm_resource_list_h rm_resource_list_create(void)\r
-{\r
-       rm_resource_list *list = (rm_resource_list*) calloc(1, sizeof(rm_resource_list));\r
-       if (!list) {\r
-               RM_ERR("insufficient memory");\r
-               return NULL;\r
-       }\r
-\r
-       list->n_rsc = 0;\r
-       return list;\r
-}\r
-\r
-int rm_resource_list_append(rm_resource_list_h list, const rm_resource_h resource)\r
-{\r
-       if (!list || !resource) {\r
-               RM_ERR("invalid param");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       list->rsc_list = g_list_append(list->rsc_list, resource);\r
-       list->n_rsc = g_list_length(list->rsc_list);\r
-       list->iter = list->rsc_list;\r
-       return RM_OK;\r
-}\r
-\r
-rm_resource_h rm_create_video_encoder(const unsigned int width, const unsigned int height, const unsigned int framerate)\r
-{\r
-       rm_resource *resource = (rm_resource*) calloc(1, sizeof(rm_resource));\r
-       if (!resource) {\r
-               RM_ERR("insufficient memory");\r
-               return NULL;\r
-       }\r
-\r
-       resource->width = width;\r
-       resource->height = height;\r
-       resource->framerate = framerate;\r
-       return resource;\r
-}\r
-\r
-int rm_allocatable_video_encoders(const rm_resource_list_h list, bool *result)\r
-{\r
-       if (!list) {\r
-               RM_ERR("invalid param");\r
-               *result = false;\r
-               return RM_ERROR;\r
-       }\r
-\r
-       GVariantBuilder builder;\r
-       g_variant_builder_init(&builder, G_VARIANT_TYPE("(a(uuu))"));\r
-       g_variant_builder_open(&builder, G_VARIANT_TYPE("a(uuu)"));\r
-\r
-       rm_resource_h resource = rm_resource_list_get_first(list);\r
-       while (resource) {\r
-               RM_INFO("w(%u)/h(%u)/fps(%u)", rm_resource_get_width(resource), rm_resource_get_height(resource), rm_resource_get_framerate(resource));\r
-               g_variant_builder_add(&builder, "(uuu)", rm_resource_get_width(resource), rm_resource_get_height(resource), rm_resource_get_framerate(resource));\r
-               resource = rm_resource_list_get_next(list);\r
-       };\r
-\r
-       g_variant_builder_close(&builder);\r
-\r
-       GVariant *response = NULL;\r
-       if (rm_dbus_method_call("AllocatableVideoEncoders", g_variant_builder_end(&builder), &response) != 0) {\r
-               *result = false;\r
-               RM_ERR("dbus_method_call() for AllocatableVideoEncoders failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       int available = 0;\r
-       g_variant_get(response, "(i)", &available);\r
-       g_variant_unref(response);\r
-       RM_INFO("available (%d)", available);\r
-       *result = (available == 1);\r
-       return RM_OK;\r
-}\r
-\r
-unsigned int rm_resource_get_width(const rm_resource_h resource)\r
-{\r
-       if (!resource) {\r
-               RM_ERR("invalid param");\r
-               return 0;\r
-       }\r
-       return resource->width;\r
-}\r
-\r
-unsigned int rm_resource_get_height(const rm_resource_h resource)\r
-{\r
-       if (!resource) {\r
-               RM_ERR("invalid param");\r
-               return 0;\r
-       }\r
-       return resource->height;\r
-}\r
-\r
-bool rm_resource_android_app(const rm_resource_h resource)\r
-{\r
-       if (!resource)\r
-               return false;\r
-\r
-       return resource->android_app;\r
-}\r
-\r
-int rm_reclaim_video_decoders(const char *requester)\r
-{\r
-       if (!requester) {\r
-               RM_ERR("invalid param");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("reclaim video decoders allocated to other than (%s)", requester);\r
-\r
-       GVariant *response = NULL;\r
-       if (rm_dbus_method_call("ReclaimVideoDecoders", g_variant_new("(s)", requester), &response) != 0) {\r
-               RM_ERR("dbus call for ReclaimVideoDecoders failed");\r
-               return RM_ERROR;\r
-       }\r
-\r
-       int result = 0;\r
-       g_variant_get(response, "(i)", &result);\r
-       g_variant_unref(response);\r
-\r
-       RM_INFO("result : (%d)", result);\r
-       return (result == 0) ? RM_OK : RM_ERROR;\r
-}\r
-\r
-bool rm_active_player(const int handle)\r
-{\r
-       bool result = false;\r
-       if (rm_shm_active_player(handle, &result) == RM_OK) {\r
-               RM_INFO("(%d : %d)", handle, result);\r
-               return result;\r
-       }\r
-\r
-       GVariant *response = NULL;\r
-       if (rm_dbus_method_call("ActivePlayer", g_variant_new("(i)", handle), &response) != 0) {\r
-               RM_ERR("dbus call for ActivePlayer (%d) failed", handle);\r
-               return false;\r
-       }\r
-\r
-       g_variant_get(response, "(b)", &result);\r
-\r
-       RM_INFO("(%d : %d)", handle, result);\r
-       return result;\r
-}\r
-\r
-bool rm_reclaimed_player(const int handle)\r
-{\r
-       bool result = false;\r
-\r
-       GVariant *response = NULL;\r
-       if (rm_dbus_method_call("ReclaimedPlayer", g_variant_new("(i)", handle), &response)!= 0) {\r
-               RM_ERR("dbus call for ReclaimedPlayer (%d) failed", handle);\r
-               return false;\r
-       }\r
-\r
-       g_variant_get(response, "(b)", &result);\r
-\r
-       RM_INFO("(%d : %d)", handle, result);\r
-       return result;\r
-}\r
-\r
-// LCOV_EXCL_STOP\r
+/*
+ * Copyright (c) 2024 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 <assert.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include <rm_debug.h>
+#include <rm_internal.h>
+#include <rm_dbus.h>
+#include <rm_module_api.h>
+#include <rm_callback.h>
+#include <rm_module_api.h>
+#include <rm_shm_api.h>
+
+// LCOV_EXCL_START
+
+#define RMS_INITIALIZED (access("/run/rsc_mgr_ready", F_OK) == 0)
+
+void rm_wait_for_server_ready(void)
+{
+       while (!RMS_INITIALIZED) {
+               RM_INFO("waiting for server ready");
+               usleep(50*1000); // 50ms
+       }
+       RM_WARN("resource manager server is ready !!!");
+}
+
+int rm_get_resource_state(int rsc_id, rm_resource_state_e *state)
+{
+       RM_RETURN_ERR_IF_NULL(state, "invalid parameter");
+       if (rsc_id < 0) {
+               RM_ERR("invalid resource id (%d)", rsc_id);
+               return RM_ERROR;
+       }
+
+       int ret = RM_OK;
+       int rsc_state = 0;
+       GVariant *result = NULL;
+
+       ret = rm_dbus_method_call("GetResourceState",
+                                                       g_variant_new("(i)", rsc_id),
+                                                       &result);
+
+       if (ret) {
+               RM_ERR("dbus_method_call() for FindDeviceId is failed");
+               return RM_ERROR;
+       }
+
+       g_variant_get(result, "(i)", &rsc_state);
+
+       if (rsc_state < 0) {
+               RM_ERR("can't get state(%d : %d)", rsc_id, rsc_state);
+               return RM_ERROR;
+       }
+
+       *state = (rm_resource_state_e) rsc_state;
+       RM_INFO("state (%d : %d)", rsc_id, rsc_state);
+       g_variant_unref(result);
+       return RM_OK;
+}
+
+int rm_get_scaler_state(rm_resource_list_h *list)
+{
+       RM_RETURN_ERR_IF_NULL(list, "invalid parameter");
+
+       int ret = RM_OK;
+       GVariant *result = NULL;
+       rm_resource_list *list_reply = NULL;
+
+       list_reply = (rm_resource_list*) calloc(1, sizeof(rm_resource_list));
+       assert(list_reply);
+       list_reply->n_rsc = 0;
+       *list = list_reply;
+
+       ret = rm_dbus_method_call("GetScalerState",
+                                                       g_variant_new("(i)", RM_CATEGORY_SCALER),
+                                                       &result);
+
+       if (ret) {
+               RM_ERR("dbus_method_call() for GetScalerState is failed");
+               return RM_ERROR;
+       }
+
+       int category_id;
+       int cur_category_id;
+       int rsc_id;
+       int state;
+       int cid;
+       int zone_id;
+       int android_app;
+       gchar *app_id;
+
+       GVariantIter *iter;
+       g_variant_get(result, "(a(iiiiiisi))", &iter);
+
+       while (g_variant_iter_loop(iter, "(iiiiiisi)", &category_id, &cur_category_id, &rsc_id, &state, &cid, &zone_id, &app_id, &android_app)) {
+               rm_resource *resource = (rm_resource*) calloc(1, sizeof(rm_resource));
+               assert(resource);
+               resource->category_id = category_id;
+               resource->cur_category_id = cur_category_id;
+               resource->id = rsc_id;
+               resource->state = state;
+               resource->consumer_id = cid;
+               resource->zone_id = zone_id;
+               RM_INFO("(%d : %s)", resource->id, app_id ? app_id : "null");
+               resource->app_id = (app_id) ? (char*) strndup(app_id, strlen(app_id)) : NULL;
+               resource->android_app = android_app;
+               list_reply->rsc_list = g_list_append(list_reply->rsc_list, resource);
+       }
+       g_variant_iter_free(iter);
+
+       list_reply->n_rsc = g_list_length(list_reply->rsc_list);
+       list_reply->iter = list_reply->rsc_list;
+
+       g_variant_unref(result);
+       return ret;
+}
+
+int rm_get_resource_list(rm_rsc_category_e category, rm_resource_list_h *list)
+{
+       RM_RETURN_ERR_IF_NULL(list, "invalid parameter");
+
+       int ret = RM_OK;
+       GVariant *result = NULL;
+       rm_resource_list *list_reply = NULL;
+
+       list_reply = (rm_resource_list*) calloc(1, sizeof(rm_resource_list));
+       assert(list_reply);
+       list_reply->n_rsc = 0;
+       *list = list_reply;
+
+       ret = rm_dbus_method_call("GetResourceList",
+                                                       g_variant_new("(i)", category),
+                                                       &result);
+
+       if (ret) {
+               RM_ERR("dbus_method_call() for GetResourceList is failed");
+               return RM_ERROR;
+       }
+
+       int rsc_id;
+       int rsc_state;
+       int cid;
+       gchar *dev_node;
+       gchar *app_id;
+
+       GVariantIter *iter;
+       g_variant_get(result, "(a(iissi))", &iter);
+
+       while (g_variant_iter_loop(iter, "(iissi)", &rsc_id, &rsc_state, &dev_node, &app_id, &cid)) {
+               rm_resource *resource = (rm_resource*) calloc(1, sizeof(rm_resource));
+               assert(resource);
+               resource->id = rsc_id;
+               resource->state = rsc_state;
+               resource->consumer_id = cid;
+               resource->support_overlay = ri_is_overlay_supported(rsc_id);
+               resource->max_rez = ri_get_supported_max_resolution(rsc_id);
+               resource->max_sampling_format = ri_get_max_sampling_format(rsc_id);
+               int category_id = 0;
+               if (ri_get_category_type_by_device_id(rsc_id, &category_id) != RI_OK) {
+                       RM_ERR("failed to get category of (%d)", rsc_id);
+               }
+               resource->category_id = category_id;
+
+               RM_INFO("(%d:%s)", resource->id, dev_node?dev_node : "null");
+               resource->node = (dev_node) ? (char*) strndup(dev_node, strlen(dev_node)) : NULL;
+               resource->app_id = (app_id) ? (char*) strndup(app_id, strlen(app_id)) : NULL;
+               list_reply->rsc_list = g_list_append(list_reply->rsc_list, resource);
+       }
+
+       g_variant_iter_free(iter);
+
+       list_reply->n_rsc = g_list_length(list_reply->rsc_list);
+       list_reply->iter = list_reply->rsc_list;
+
+       g_variant_unref(result);
+       return ret;
+}
+
+static void rm_resource_free(gpointer data)
+{
+       rm_resource *resource = (rm_resource*) data;
+       RM_RETURN_IF_NULL(resource, "resource null");
+       RM_FREE(resource->node);
+       RM_FREE(resource->app_id);
+       RM_FREE(resource);
+}
+
+void rm_free_resource_list(rm_resource_list_h list)
+{
+       if (!list)
+               return;
+
+       g_list_free_full(list->rsc_list, rm_resource_free);
+       RM_FREE(list);
+}
+
+rm_resource_h rm_resource_list_get_next(rm_resource_list_h list)
+{
+       RM_RETURN_NULL_IF_NULL(list, "invalid list");
+       RM_RETURN_NULL_IF_NULL(list->rsc_list, "no device in resource list");
+       RM_RETURN_NULL_IF_NULL(list->iter, "no device in resource list");
+
+       GList *tmp = g_list_next(list->iter);
+
+       RM_RETURN_NULL_IF_NULL(tmp, "no next resource");
+
+       list->iter = tmp;
+       return (rm_resource_h) list->iter->data;
+}
+
+rm_resource_h rm_resource_list_get_prev(rm_resource_list_h list)
+{
+       RM_RETURN_NULL_IF_NULL(list, "invalid list");
+       RM_RETURN_NULL_IF_NULL(list->rsc_list, "no device in resource list");
+       RM_RETURN_NULL_IF_NULL(list->iter, "no device in resource list");
+
+       GList *tmp = g_list_previous(list->iter);
+
+       RM_RETURN_NULL_IF_NULL(tmp, "no prev resource");
+
+       list->iter = tmp;
+       return (rm_resource_h) list->iter->data;
+}
+
+rm_resource_h rm_resource_list_get_first(rm_resource_list_h list)
+{
+       RM_RETURN_NULL_IF_NULL(list, "invalid list");
+       RM_RETURN_NULL_IF_NULL(list->rsc_list, "no device in resource list");
+       RM_RETURN_NULL_IF_NULL(list->iter, "no device in resource list");
+
+       GList *tmp = g_list_first(list->iter);
+
+       RM_RETURN_NULL_IF_NULL(tmp, "no first resource");
+
+       list->iter = tmp;
+       return (rm_resource_h) list->iter->data;
+}
+
+rm_resource_h rm_resource_list_get_last(rm_resource_list_h list)
+{
+       RM_RETURN_NULL_IF_NULL(list, "invalid list");
+       RM_RETURN_NULL_IF_NULL(list->rsc_list, "no device in resource list");
+       RM_RETURN_NULL_IF_NULL(list->iter, "no device in resource list");
+
+       GList *tmp = g_list_last(list->iter);
+
+       RM_RETURN_NULL_IF_NULL(tmp, "no last resource");
+
+       list->iter = tmp;
+       return (rm_resource_h) list->iter->data;
+}
+
+int rm_resource_list_get_count(rm_resource_list_h list)
+{
+       return (list) ? list->n_rsc : 0;
+}
+
+const char *rm_resource_get_node(rm_resource_h resource)
+{
+       RM_RETURN_NULL_IF_NULL(resource, "invalid parameter");
+       return resource->node;
+}
+
+int rm_resource_get_category(rm_resource_h resource)
+{
+       RM_RETURN_MINUS_IF_NULL(resource, "invalid parameter");
+       return resource->category_id;
+}
+
+int rm_resource_get_cur_category(rm_resource_h resource)
+{
+       RM_RETURN_MINUS_IF_NULL(resource, "invalid parameter");
+       return resource->cur_category_id;
+}
+
+int rm_resource_get_consumer(rm_resource_h resource)
+{
+       RM_RETURN_MINUS_IF_NULL(resource, "invalid parameter");
+       return resource->consumer_id;
+}
+
+int rm_resource_get_state(rm_resource_h resource)
+{
+       RM_RETURN_MINUS_IF_NULL(resource, "invalid parameter");
+       return resource->state;
+}
+
+const char *rm_resource_get_app_id(rm_resource_h resource)
+{
+       RM_RETURN_NULL_IF_NULL(resource, "invalid parameter");
+       return resource->app_id;
+}
+
+unsigned int rm_resource_get_framerate(rm_resource_h resource)
+{
+       RM_RETURN_MINUS_IF_NULL(resource, "invalid parameter");
+       return resource->framerate;
+}
+
+int rm_resource_get_id(rm_resource_h resource)
+{
+       return (resource) ? resource->id : -1;
+}
+
+int rm_resource_get_max_resolution(rm_resource_h resource)
+{
+       return (resource) ? resource->max_rez : -1;
+}
+
+bool rm_resource_support_overlay(rm_resource_h resource)
+{
+       return (resource) ? resource->support_overlay : false;
+}
+
+int rm_resource_get_max_sampling_format(rm_resource_h resource)
+{
+       return (resource) ? resource->max_sampling_format : -1;
+}
+
+int rm_resource_get_zone_id(rm_resource_h resource)
+{
+       return (resource) ? resource->zone_id : -1;
+}
+
+static unsigned int state_change_signal_id = 0;
+
+static void onResourceStateChanged(GDBusConnection *conn,
+               const gchar *sender,
+               const gchar *object,
+               const gchar *interface,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       int device_id;
+       int category_id;
+       int state;
+       int handle;
+       char *app_id;
+
+       g_variant_get(parameters, "(iiii&s)", &device_id, &category_id, &state, &handle, &app_id);
+       RM_INFO("signal (%s) received - (%d(%d) : %d : %d(%s))", signal, device_id, category_id, state, handle, app_id);
+       rm_call_state_changed_cb(category_id, device_id, state, handle, app_id);
+}
+
+int rm_subscribe_resource_state_change(rm_rsc_category_e category, resource_state_change_cb cb, void *data)
+{
+       RM_RETURN_ERR_IF_NULL(cb, "invalid parameter");
+
+       if (rm_add_state_change_cb(category, cb, data) < 0) {
+               RM_ERR("already registered cb (%d : %p)", category, cb);
+               return RM_ERROR;
+       }
+
+       if (state_change_signal_id)
+               return RM_OK;
+
+       GError *error = NULL;
+       GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (!connection) {
+               RM_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");
+               return RM_ERROR;
+       }
+
+       state_change_signal_id = g_dbus_connection_signal_subscribe(connection,
+                       NULL,
+                       RM_DBUS_INTERFACE_NAME,
+                       "RscStateChanged",
+                       RM_DBUS_OBJ_PATH,
+                       NULL,
+                       G_DBUS_SIGNAL_FLAGS_NONE,
+                       onResourceStateChanged,
+                       NULL,
+                       NULL);
+
+       if (state_change_signal_id == 0) {
+               if (error) {
+                       RM_ERR("dbus connection close error: %s", error->message);
+                       g_clear_error(&error);
+               }
+               return RM_ERROR;
+       }
+
+       RM_INFO("subscribe resource state changed (%d)", state_change_signal_id);
+       return RM_OK;
+}
+
+int rm_unsubscribe_resource_state_change(rm_rsc_category_e category, resource_state_change_cb cb)
+{
+       RM_RETURN_ERR_IF_NULL(cb, "invalid parameter");
+
+       int remain = 0;
+       if ((remain = rm_remove_state_change_cb(category, cb)) < 0) {
+               RM_ERR("not registered cb (%d:%p)", category, cb);
+               return RM_ERROR;
+       }
+
+       if (remain > 0) {
+               RM_INFO("resource state change cb(%d:%p) removed", category, cb);
+               return RM_OK;
+       }
+
+       GError *error = NULL;
+       GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (!connection) {
+               RM_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");
+               return RM_OK;
+       }
+
+       RM_INFO("remove state change signal id(%d)", state_change_signal_id);
+       g_dbus_connection_signal_unsubscribe(connection, state_change_signal_id);
+       state_change_signal_id = 0;
+
+       return RM_OK;
+}
+
+int rm_rsc_state_get_category(rm_resource_state_h state)
+{
+       RM_RETURN_MINUS_IF_NULL(state, "invalid state");
+       return state->catId;
+}
+
+int rm_rsc_state_get_device_id(rm_resource_state_h state)
+{
+       RM_RETURN_MINUS_IF_NULL(state, "invalid state");
+       return state->devId;
+}
+
+int rm_rsc_state_get_state(rm_resource_state_h state)
+{
+       RM_RETURN_MINUS_IF_NULL(state, "invalid state");
+       return state->state;
+}
+
+int rm_rsc_state_get_consumer_id(rm_resource_state_h state)
+{
+       RM_RETURN_MINUS_IF_NULL(state, "invalid state");
+       return state->consumerId;
+}
+
+char *rm_rsc_state_get_app_id(rm_resource_state_h state)
+{
+       RM_RETURN_NULL_IF_NULL(state, "invalid state");
+       return state->appId;
+}
+
+static void OnResourceConflictEvent(GDBusConnection *conn,
+               const gchar *sender,
+               const gchar *object,
+               const gchar *interface,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       rm_conflict_resource rsc;
+       g_variant_get(parameters, "(iii&sii)", &rsc.catId, &rsc.devId, &rsc.cId, &rsc.appId, &rsc.aZoneId, &rsc.rZoneId);
+
+       RM_INFO("signal (%s) received - (%d:%d:%d:%s:%d:%d)", signal, rsc.catId, rsc.devId, rsc.cId, rsc.appId, rsc.aZoneId, rsc.rZoneId);
+
+       std::list<conflict_event_cb*> cb_list = rm_get_conflict_event_cb_list();
+
+       for (auto& it : cb_list) {
+               RM_INFO("call cb(%p)", it->cb);
+               it->cb(&rsc, it->data);
+       }
+}
+
+static unsigned int conflict_event_signal_id = 0;
+
+int rm_subscribe_resource_conflict_event(rm_conflict_event_cb cb, void *data)
+{
+       RM_RETURN_ERR_IF_NULL(cb, "invalid cb");
+
+       if (rm_add_conflict_event_cb(cb, data) < 0) {
+               RM_ERR("already registered cb(%p)", cb);
+               return RM_ERROR;
+       }
+
+       if (conflict_event_signal_id)
+               return RM_OK;
+
+       GError *error = NULL;
+       GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (!connection) {
+               RM_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");
+               rm_remove_conflict_event_cb(cb);
+               return RM_ERROR;
+       }
+
+       conflict_event_signal_id = g_dbus_connection_signal_subscribe(connection,
+                       NULL,
+                       RM_DBUS_INTERFACE_NAME,
+                       "RscConflicted",
+                       RM_DBUS_OBJ_PATH,
+                       NULL,
+                       G_DBUS_SIGNAL_FLAGS_NONE,
+                       OnResourceConflictEvent,
+                       NULL,
+                       NULL);
+
+       if (conflict_event_signal_id == 0) {
+               if (error) {
+                       RM_ERR("dbus connection close error: %s", error->message);
+                       g_clear_error(&error);
+                       rm_remove_conflict_event_cb(cb);
+               }
+               return RM_ERROR;
+       }
+
+       RM_INFO("subscribe conflict event (%d)", conflict_event_signal_id);
+
+       return RM_OK;
+}
+
+int rm_unsubscribe_resource_conflict_event(rm_conflict_event_cb cb)
+{
+       RM_RETURN_ERR_IF_NULL(cb, "invalid cb");
+
+       int remain = 0;
+       if ((remain = rm_remove_conflict_event_cb(cb)) < 0) {
+               RM_ERR("unregistered cb(%p)", cb);
+               return RM_ERROR;
+       }
+
+       RM_INFO("callback unregistered(%p)-(%d)", cb, remain);
+
+       if (remain > 0)
+               return RM_OK;
+
+       GError *error = NULL;
+       GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (!connection) {
+               RM_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");
+               return RM_OK;
+       }
+
+       RM_INFO("remove conflict event signal id(%d)", conflict_event_signal_id);
+       g_dbus_connection_signal_unsubscribe(connection, conflict_event_signal_id);
+       conflict_event_signal_id = 0;
+
+       return RM_OK;
+}
+
+int rm_conflict_get_category_id(rm_conflict_resource_h rsc)
+{
+       RM_RETURN_MINUS_IF_NULL(rsc, "invalid rsc");
+       return rsc->catId;
+}
+
+int rm_conflict_get_device_id(rm_conflict_resource_h rsc)
+{
+       RM_RETURN_MINUS_IF_NULL(rsc, "invalid rsc");
+       return rsc->devId;
+}
+
+int rm_conflict_get_consumer_id(rm_conflict_resource_h rsc)
+{
+       RM_RETURN_MINUS_IF_NULL(rsc, "invalid rsc");
+       return rsc->cId;
+}
+
+const char *rm_conflict_get_app_id(rm_conflict_resource_h rsc)
+{
+       RM_RETURN_NULL_IF_NULL(rsc, "invalid rsc");
+       return rsc->appId;
+}
+
+int rm_conflict_get_multiview_zone_id_consumer(rm_conflict_resource_h rsc)
+{
+       RM_RETURN_MINUS_IF_NULL(rsc, "invalid rsc");
+       return rsc->aZoneId;
+}
+
+int rm_conflict_get_multiview_zone_id_requester(rm_conflict_resource_h rsc)
+{
+       RM_RETURN_MINUS_IF_NULL(rsc, "invalid rsc");
+       return rsc->rZoneId;
+}
+
+int rm_get_resource_collection_state(rm_rsc_collection_e collection, rm_resource_list_h *list)
+{
+       RM_RETURN_ERR_IF_NULL(list, "invalid parameter");
+
+       int ret;
+       GVariant *result = NULL;
+       rm_resource_list *list_reply = NULL;
+
+       list_reply = (rm_resource_list*) calloc(1, sizeof(rm_resource_list));
+       assert(list_reply);
+       list_reply->n_rsc = 0;
+       *list = list_reply;
+
+       ret = rm_dbus_method_call("GetRscCollectionState",
+                                                       g_variant_new("(i)", collection),
+                                                       &result);
+
+       if (ret) {
+               RM_ERR("dbus_method_call() for GetRscCollectionState is failed");
+               return RM_ERROR;
+       }
+
+       int rsc_id;
+       int rsc_state;
+       int rsc_category;
+       int cid;
+       int zone_id;
+       int android_app;
+       gchar *app_id;
+       gchar *dev_node;
+
+       GVariantIter *iter;
+       g_variant_get(result, "(a(isiiisii))", &iter);
+
+       while (g_variant_iter_loop(iter, "(isiiisii)", &rsc_id, &dev_node, &rsc_state, &rsc_category, &cid, &app_id, &zone_id, &android_app)) {
+               rm_resource *resource = (rm_resource*) calloc(1, sizeof(rm_resource));
+               assert(resource);
+               resource->id = rsc_id;
+               RM_INFO("(%d:%s)", resource->id, dev_node?dev_node : "null");
+               resource->node = (dev_node) ? (char*) strndup(dev_node, strlen(dev_node)) : NULL;
+               resource->state = rsc_state;
+               resource->category_id = rsc_category;
+               resource->framerate = ri_get_video_category_framerate(rsc_category);
+               resource->consumer_id = cid;
+               resource->app_id = (app_id) ? (char*) strndup(app_id, strlen(app_id)) : NULL;
+               resource->zone_id = zone_id;
+               resource->android_app = android_app;
+               list_reply->rsc_list = g_list_append(list_reply->rsc_list, resource);
+       }
+
+       g_variant_iter_free(iter);
+
+       list_reply->n_rsc = g_list_length(list_reply->rsc_list);
+       list_reply->iter = list_reply->rsc_list;
+
+       g_variant_unref(result);
+       return ret;
+}
+
+int rm_unmask_category_options(int category)
+{
+       int result = category;
+
+       result = (result & ~RM_DEVICE_OPT_MAIN);
+       result = (result & ~RM_DEVICE_OPT_SUB);
+
+       return ri_unmask_category_options(result);
+}
+
+int rm_find_device_id(int virtual_id)
+{
+       if (virtual_id < 0) {
+               RM_ERR("invalid resource id (%d)", virtual_id);
+               return -1;
+       }
+
+       int real_id = 0;
+       if (rm_shm_find_device_id(virtual_id, &real_id) == RM_OK) {
+               RM_INFO("real id (%d:%d)", virtual_id, real_id);
+               return real_id;
+       }
+
+       int ret = RM_OK;
+
+       GVariant *result = NULL;
+
+       ret = rm_dbus_method_call("FindDeviceId",
+                                               g_variant_new("(i)", virtual_id),
+                                               &result);
+
+       if (ret) {
+               RM_ERR("dbus_method_call() for FindDeviceId is failed");
+               return RM_ERROR;
+       }
+
+       g_variant_get(result, "(i)", &real_id);
+
+       RM_INFO("real id (%d:%d)", virtual_id, real_id);
+
+       g_variant_unref(result);
+       return real_id;
+}
+
+int rm_swap_resources(int device_id_a, int device_id_b)
+{
+       if ((device_id_a < 0) || (device_id_b < 0)) {
+               RM_ERR("invalid resource id (%d/%d)", device_id_a, device_id_b);
+               return RM_ERROR;
+       }
+
+       int ret = RM_OK;
+       int swap_result = 0;
+       GVariant *result = NULL;
+
+       ret = rm_dbus_method_call("SwapResources",
+                                               g_variant_new("(ii)", device_id_a, device_id_b),
+                                               &result);
+
+       if (ret) {
+               RM_ERR("dbus_method_call() for SwapResources is failed");
+               return RM_ERROR;
+       }
+
+       g_variant_get(result, "(i)", &swap_result);
+
+       if (swap_result < 0) {
+               RM_ERR("faild to swap resources(%d:%d)", device_id_a, device_id_b);
+               ret = RM_ERROR;
+       }
+
+       RM_INFO("swapped (%d:%d)", device_id_a, device_id_b);
+
+       g_variant_unref(result);
+       return ret;
+}
+
+int rm_swap_resources_async(int device_id_a, int device_id_b)
+{
+       if ((device_id_a < 0) || (device_id_b < 0)) {
+               RM_ERR("invalid resource id (%d/%d)", device_id_a, device_id_b);
+               return RM_ERROR;
+       }
+
+       int ret = rm_dbus_method_call_async_with_no_reply("SwapResources",
+                                                       g_variant_new("(ii)", device_id_a, device_id_b));
+       if (ret) {
+               RM_ERR("dbus_method_call() for SwapResourcesAsync is failed");
+               return RM_ERROR;
+       }
+
+       RM_INFO("swapped requested (%d:%d)", device_id_a, device_id_b);
+       return RM_OK;
+}
+
+int rm_restore_resources(int category)
+{
+       if (category < 0) {
+               RM_ERR("invalid category id (%d)", category);
+               return RM_ERROR;
+       }
+
+       int ret = RM_OK;
+       int restore_result = 0;
+       GVariant *result = NULL;
+
+       ret = rm_dbus_method_call("RestoreResources",
+                                                       g_variant_new("(i)", category),
+                                                       &result);
+
+       if (ret) {
+               RM_ERR("dbus_method_call() for RestoreResources is failed");
+               return RM_ERROR;
+       }
+
+       g_variant_get(result, "(i)", &restore_result);
+
+       if (restore_result < 0) {
+               RM_ERR("faild to restore resources(%d)", category);
+               ret = RM_ERROR;
+       }
+
+       RM_INFO("restored (%d)", category);
+
+       g_variant_unref(result);
+       return ret;
+}
+
+int rm_get_app_id(int handle, char**app_id)
+{
+       if (handle < 0 || !app_id) {
+               RM_ERR("invalid param (%d)", handle);
+               return RM_ERROR;
+       }
+
+       if (rm_shm_get_app_id(handle, app_id) == RM_OK)
+               return RM_OK;
+
+       int ret = RM_OK;
+       int dbus_ret = 0;
+       char *ret_val = NULL;
+       GVariant *result = NULL;
+
+       ret = rm_dbus_method_call("GetAppId",
+                                                       g_variant_new("(i)", handle),
+                                                       &result);
+
+       if (ret) {
+               RM_ERR("dbus_method_call() for GetAppId is failed");
+               return RM_ERROR;
+       }
+
+       g_variant_get(result, "(i&s)", &dbus_ret, &ret_val);
+
+       if (dbus_ret < 0)
+               ret = RM_ERROR;
+
+       if (ret_val)
+               *app_id = strndup(ret_val, strlen(ret_val));
+
+       RM_INFO("(%d) - app_id(%d : %s)", dbus_ret, handle, (ret_val) ? *app_id : "null");
+
+       g_variant_unref(result);
+       return ret;
+}
+
+int rm_get_active_audio_out(int handle)
+{
+       if (handle < 0) {
+               RM_ERR("invalid handle(%d)", handle);
+               return -1;
+       }
+
+       int active_audio_out = 0;
+       if (rm_shm_get_active_audio_out(handle, &active_audio_out) == RM_OK)
+               return active_audio_out;
+
+       int ret = 0;
+       GVariant *result = NULL;
+
+       ret = rm_dbus_method_call("GetActiveAudioOut",
+                                                       g_variant_new("(i)", handle),
+                                                       &result);
+       if (ret) {
+               RM_ERR("dbus_method_call() for GetActiveAudioOut is failed");
+               return -1;
+       }
+
+       g_variant_get(result, "(i)", &active_audio_out);
+
+       RM_INFO("active audio out (%d:%d)", handle, active_audio_out);
+
+       g_variant_unref(result);
+       return active_audio_out;
+}
+
+int rm_scaler_get_virtual_id(rm_resource_h scaler)
+{
+       return (scaler) ? scaler->virtual_id : -1;
+}
+
+int rm_scaler_get_source_id(rm_resource_h scaler)
+{
+       return (scaler) ? scaler->source_id : -1;
+}
+
+static unsigned int scaler_change_signal_id = 0;
+static void onScalerStateChanged(GDBusConnection *conn,
+               const gchar *sender,
+               const gchar *object,
+               const gchar *interface,
+               const gchar *signal,
+               GVariant *param,
+               gpointer user_data)
+{
+       rm_resource_list *scaler_list = NULL;
+
+       scaler_list = (rm_resource_list*) calloc(1, sizeof(rm_resource_list));
+       assert(scaler_list);
+       scaler_list->n_rsc = 0;
+
+       int virtual_id;
+       int source_id;
+       GVariantIter *iter;
+       g_variant_get(param, "(a(ii))", &iter);
+
+       RM_INFO(">> scaler state changed");
+       while (g_variant_iter_loop(iter, "(ii)", &virtual_id, &source_id)) {
+               rm_resource *scaler = (rm_resource*) calloc(1, sizeof(rm_resource));
+               assert(scaler);
+
+               scaler->virtual_id = virtual_id;
+               scaler->source_id = source_id;
+               RM_INFO("(%d:%d)", scaler->virtual_id, scaler->source_id);
+
+               scaler_list->rsc_list = g_list_append(scaler_list->rsc_list, scaler);
+       }
+
+       g_variant_iter_free(iter);
+
+       scaler_list->n_rsc = g_list_length(scaler_list->rsc_list);
+       scaler_list->iter = scaler_list->rsc_list;
+
+       rm_call_scaler_state_changed_cb(scaler_list);
+
+       g_list_free_full(scaler_list->rsc_list, rm_resource_free);
+       RM_FREE(scaler_list);
+}
+
+int rm_subscribe_scaler_state_change(scaler_state_change_cb cb, void *data)
+{
+       RM_RETURN_ERR_IF_NULL(cb, "invalid parameter");
+
+       if (rm_add_scaler_state_change_cb(cb, data) < 0) {
+               RM_ERR("already registered cb (%p)", cb);
+               return RM_ERROR;
+       }
+
+       if (scaler_change_signal_id)
+               return RM_OK;
+
+       GError *error = NULL;
+       GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (!connection) {
+               RM_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");
+               return RM_ERROR;
+       }
+
+       scaler_change_signal_id = g_dbus_connection_signal_subscribe(connection,
+                       NULL,
+                       RM_DBUS_INTERFACE_NAME,
+                       "ScalerStateChanged",
+                       RM_DBUS_OBJ_PATH,
+                       NULL,
+                       G_DBUS_SIGNAL_FLAGS_NONE,
+                       onScalerStateChanged,
+                       NULL,
+                       NULL);
+
+       if (scaler_change_signal_id == 0) {
+               if (error) {
+                       RM_ERR("dbus connection close error: %s", error->message);
+                       g_clear_error(&error);
+               }
+               return RM_ERROR;
+       }
+
+       RM_INFO("subscribe resource state changed (%d)", scaler_change_signal_id);
+       return RM_OK;
+}
+
+int rm_unsubscribe_scaler_state_change(scaler_state_change_cb cb)
+{
+       RM_RETURN_ERR_IF_NULL(cb, "invalid parameter");
+
+       int remain = 0;
+       if ((remain = rm_remove_scaler_state_change_cb(cb)) < 0) {
+               RM_ERR("not registered cb (%p)", cb);
+               return RM_ERROR;
+       }
+
+       if (remain > 0) {
+               RM_INFO("scaler state change cb(%p) removed", cb);
+               return RM_OK;
+       }
+
+       GError *error = NULL;
+       GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (!connection) {
+               RM_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");
+               return RM_OK;
+       }
+
+       RM_INFO("remove scaler change signal id(%d)", scaler_change_signal_id);
+       g_dbus_connection_signal_unsubscribe(connection, scaler_change_signal_id);
+       scaler_change_signal_id = 0;
+
+       return RM_OK;
+}
+
+int rm_get_scaler_hw_id(int zone_id, int *id)
+{
+       if (zone_id <= 0) {
+               RM_ERR("invalid resource id (%d)", zone_id);
+               return RM_ERROR;
+       }
+
+       if (rm_shm_find_scaler_hw_id(zone_id, id) == RM_OK)
+               return RM_OK;
+
+       int ret = RM_OK;
+       int hw_id = 0;
+       GVariant *result = NULL;
+
+       ret = rm_dbus_method_call("GetScalerHWID",
+                                                       g_variant_new("(i)", zone_id),
+                                                       &result);
+
+       if (ret) {
+               RM_ERR("dbus_method_call() for GetScalerHWID is failed");
+               return RM_ERROR;
+       }
+
+       g_variant_get(result, "(i)", &hw_id);
+
+       if (hw_id < 0) {
+               RM_ERR("can't get hw id(%d:%d)", zone_id, hw_id);
+               g_variant_unref(result);
+               return RM_ERROR;
+       }
+
+       *id = hw_id;
+       RM_INFO("hw id (%d:%d)", zone_id, hw_id);
+       g_variant_unref(result);
+       return RM_OK;
+}
+
+int rm_notify_resource_policy(int policy)
+{
+       if (policy < 0) {
+               RM_ERR("invalid policy (%d)", policy);
+               return RM_ERROR;
+       }
+
+       int ret = rm_dbus_method_call_async_with_no_reply("NotifyResourcePolicy",
+                                                       g_variant_new("(i)", policy));
+
+       if (ret) {
+               RM_ERR("dbus_method_call() for NotifyResourcePolicy is failed");
+               return RM_ERROR;
+       }
+
+       RM_INFO("notified (%d)", policy);
+       return ret;
+}
+
+int rm_notify_app_zone_info_async(const char *app_id, int zone_id)
+{
+       if (!app_id || zone_id < -1) {
+               RM_ERR("invalid param (%d)", zone_id);
+               return RM_ERROR;
+       }
+
+       if (rm_dbus_method_call_async_with_no_reply("NotifyAppZoneInfo", g_variant_new("(si)", app_id, zone_id)) != 0) {
+               RM_ERR("dbus_method_call() for NotifyAppZoneInfo is failed");
+               return RM_ERROR;
+       }
+
+       RM_INFO("notified (%s:%d)", app_id, zone_id);
+       return RM_OK;
+}
+
+int rm_reclaim_resources(int handle)
+{
+       RM_INFO("reclaim resources of (%d)", handle);
+
+       if (rm_dbus_method_call_async_with_no_reply("ReclaimResources", g_variant_new("(i)", handle)) != 0) {
+               RM_ERR("dbus call for ReclaimResources failed");
+               return RM_ERROR;
+       }
+
+       return RM_OK;
+}
+
+int rm_reclaim_app_resources(const char *app_id, const bool notify)
+{
+       if (!app_id) {
+               RM_ERR("invalid app id");
+               return RM_ERROR;
+       }
+
+       RM_INFO("reclaim resources of (%s:%d)", app_id, notify);
+
+       GVariant *response = NULL;
+       if (rm_dbus_method_call("ReclaimAppResources", g_variant_new("(si)", app_id, notify), &response) != 0) {
+               RM_ERR("dbus call for ReclaimAppResources failed");
+               return RM_ERROR;
+       }
+
+       int reclaim_result = 0;
+       g_variant_get(response, "(i)", &reclaim_result);
+
+       int result = (reclaim_result < 0) ? RM_ERROR : RM_OK;
+       RM_INFO("reclaime result (%s : %d)", app_id, result);
+
+       g_variant_unref(response);
+       return result;
+}
+
+int rm_reclaim_app_resources_async(const char *app_id, const bool notify)
+{
+       if (!app_id) {
+               RM_ERR("invalid app id");
+               return RM_ERROR;
+       }
+
+       RM_INFO("reclaim resources of (%s : %d)", app_id, notify);
+
+       if (rm_dbus_method_call_async_with_no_reply("ReclaimAppResources", g_variant_new("(si)", app_id, notify)) != 0) {
+               RM_ERR("dbus call for ReclaimAppResources failed");
+               return RM_ERROR;
+       }
+
+       return RM_OK;
+}
+
+rm_resource_list_h rm_resource_list_create(void)
+{
+       rm_resource_list *list = (rm_resource_list*) calloc(1, sizeof(rm_resource_list));
+       if (!list) {
+               RM_ERR("insufficient memory");
+               return NULL;
+       }
+
+       list->n_rsc = 0;
+       return list;
+}
+
+int rm_resource_list_append(rm_resource_list_h list, const rm_resource_h resource)
+{
+       if (!list || !resource) {
+               RM_ERR("invalid param");
+               return RM_ERROR;
+       }
+
+       list->rsc_list = g_list_append(list->rsc_list, resource);
+       list->n_rsc = g_list_length(list->rsc_list);
+       list->iter = list->rsc_list;
+       return RM_OK;
+}
+
+rm_resource_h rm_create_video_encoder(const unsigned int width, const unsigned int height, const unsigned int framerate)
+{
+       rm_resource *resource = (rm_resource*) calloc(1, sizeof(rm_resource));
+       if (!resource) {
+               RM_ERR("insufficient memory");
+               return NULL;
+       }
+
+       resource->width = width;
+       resource->height = height;
+       resource->framerate = framerate;
+       return resource;
+}
+
+int rm_allocatable_video_encoders(const rm_resource_list_h list, bool *result)
+{
+       if (!list) {
+               RM_ERR("invalid param");
+               *result = false;
+               return RM_ERROR;
+       }
+
+       GVariantBuilder builder;
+       g_variant_builder_init(&builder, G_VARIANT_TYPE("(a(uuu))"));
+       g_variant_builder_open(&builder, G_VARIANT_TYPE("a(uuu)"));
+
+       rm_resource_h resource = rm_resource_list_get_first(list);
+       while (resource) {
+               RM_INFO("w(%u)/h(%u)/fps(%u)", rm_resource_get_width(resource), rm_resource_get_height(resource), rm_resource_get_framerate(resource));
+               g_variant_builder_add(&builder, "(uuu)", rm_resource_get_width(resource), rm_resource_get_height(resource), rm_resource_get_framerate(resource));
+               resource = rm_resource_list_get_next(list);
+       };
+
+       g_variant_builder_close(&builder);
+
+       GVariant *response = NULL;
+       if (rm_dbus_method_call("AllocatableVideoEncoders", g_variant_builder_end(&builder), &response) != 0) {
+               *result = false;
+               RM_ERR("dbus_method_call() for AllocatableVideoEncoders failed");
+               return RM_ERROR;
+       }
+
+       int available = 0;
+       g_variant_get(response, "(i)", &available);
+       g_variant_unref(response);
+       RM_INFO("available (%d)", available);
+       *result = (available == 1);
+       return RM_OK;
+}
+
+unsigned int rm_resource_get_width(const rm_resource_h resource)
+{
+       if (!resource) {
+               RM_ERR("invalid param");
+               return 0;
+       }
+       return resource->width;
+}
+
+unsigned int rm_resource_get_height(const rm_resource_h resource)
+{
+       if (!resource) {
+               RM_ERR("invalid param");
+               return 0;
+       }
+       return resource->height;
+}
+
+bool rm_resource_android_app(const rm_resource_h resource)
+{
+       if (!resource)
+               return false;
+
+       return resource->android_app;
+}
+
+int rm_reclaim_video_decoders(const char *requester)
+{
+       if (!requester) {
+               RM_ERR("invalid param");
+               return RM_ERROR;
+       }
+
+       RM_INFO("reclaim video decoders allocated to other than (%s)", requester);
+
+       GVariant *response = NULL;
+       if (rm_dbus_method_call("ReclaimVideoDecoders", g_variant_new("(s)", requester), &response) != 0) {
+               RM_ERR("dbus call for ReclaimVideoDecoders failed");
+               return RM_ERROR;
+       }
+
+       int result = 0;
+       g_variant_get(response, "(i)", &result);
+       g_variant_unref(response);
+
+       RM_INFO("result : (%d)", result);
+       return (result == 0) ? RM_OK : RM_ERROR;
+}
+
+bool rm_active_player(const int handle)
+{
+       bool result = false;
+       if (rm_shm_active_player(handle, &result) == RM_OK) {
+               RM_INFO("(%d : %d)", handle, result);
+               return result;
+       }
+
+       GVariant *response = NULL;
+       if (rm_dbus_method_call("ActivePlayer", g_variant_new("(i)", handle), &response) != 0) {
+               RM_ERR("dbus call for ActivePlayer (%d) failed", handle);
+               return false;
+       }
+
+       g_variant_get(response, "(b)", &result);
+
+       RM_INFO("(%d : %d)", handle, result);
+       return result;
+}
+
+bool rm_reclaimed_player(const int handle)
+{
+       bool result = false;
+
+       GVariant *response = NULL;
+       if (rm_dbus_method_call("ReclaimedPlayer", g_variant_new("(i)", handle), &response)!= 0) {
+               RM_ERR("dbus call for ReclaimedPlayer (%d) failed", handle);
+               return false;
+       }
+
+       g_variant_get(response, "(b)", &result);
+
+       RM_INFO("(%d : %d)", handle, result);
+       return result;
+}
+
+// LCOV_EXCL_STOP
index f1f6ae4b10d4870ca25938d509bd2ca9bc2baf5e..2175abb5b73ec5872d72424fe8e406238e0a695d 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include <stdlib.h>\r
-#include <sys/types.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-#include <errno.h>\r
-#include <unistd.h>\r
-#include <time.h>\r
-\r
-#include <rm_msg.h>\r
-#include <rm_internal.h>\r
-#include <rm_debug.h>\r
-\r
-#define RM_MSGQ_KEY_TX 8211\r
-#define RM_MSGQ_KEY_RX 8212\r
-\r
-static int msgq_tx = -1;\r
-static int msgq_rx = -1;\r
-\r
-static inline bool msgq_initialized(void)\r
-{\r
-       return ((msgq_tx >= 0) && (msgq_rx >= 0));\r
-}\r
-\r
-static int msgq_create(void)\r
-{\r
-       msgq_tx = msgget((key_t)RM_MSGQ_KEY_TX, 0666 | IPC_CREAT);\r
-       msgq_rx = msgget((key_t)RM_MSGQ_KEY_RX, 0666 | IPC_CREAT);\r
-\r
-       if ((msgq_tx == -1) || (msgq_rx == -1)) {\r
-               RM_ERR("failed to get msgq_id - msgq_tx(%d), msgq_rx(%d)", msgq_tx, msgq_rx);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_INFO("msgq_tx (%d), msgq_rx(%d)", msgq_tx, msgq_rx);\r
-\r
-       return RM_OK;\r
-}\r
-\r
-// LCOV_EXCL_START\r
-static int msgq_recover_tx(void)\r
-{\r
-       msgq_tx = msgget((key_t)RM_MSGQ_KEY_TX, 0666 | IPC_CREAT);\r
-\r
-       if (msgq_tx == -1) {\r
-               RM_ERR("failed to get new msgq_id - msgq_tx(%d), errno(%d)", msgq_tx, errno);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_ERR("msgq recovered - msgq_tx(%d)", msgq_tx);\r
-       return RM_OK;\r
-}\r
-\r
-\r
-static int msgq_recover_rx(void)\r
-{\r
-       msgq_rx = msgget((key_t)RM_MSGQ_KEY_RX, 0666 | IPC_CREAT);\r
-\r
-       if (msgq_rx == -1) {\r
-               RM_ERR("failed to get new msgq_id - msgq_rx(%d), errno(%d)", msgq_rx, errno);\r
-               return RM_ERROR;\r
-       }\r
-\r
-       RM_ERR("msgq recovered - msgq_rx(%d)", msgq_rx);\r
-       return RM_OK;\r
-}\r
-// LCOV_EXCL_STOP\r
-\r
-int rm_send_msg(rm_msg_request *data)\r
-{\r
-       struct timespec tnow;\r
-       clock_gettime(CLOCK_MONOTONIC, &tnow);\r
-\r
-       if (!msgq_initialized())\r
-               msgq_create();\r
-\r
-       RM_INFO("msgq_tx %d msgq_rx %d", msgq_tx, msgq_rx);\r
-\r
-       int retry = 0;\r
-\r
-       RM_WARN("handle(%d) req.data_type : %ld, req #%d, req.type : %d, req.pid : %d", data->handle, data->data_type, data->request_num, data->type, data->pid);\r
-\r
-       while (msgsnd(msgq_tx,(void*) data, sizeof(rm_msg_request) - sizeof(long), 0) == -1) {\r
-               // LCOV_EXCL_START\r
-               RM_ERR("failed to send message (%d)", errno);\r
-\r
-               if (errno == EIDRM) {\r
-                       RM_ERR("ERROR! msgid removed from system");\r
-                       if (msgq_recover_tx() != RM_OK)\r
-                               return RM_ERROR;\r
-               } else if ((errno == EINVAL) && (data->data_type > 0)) { /* maybe msgid removed from system */\r
-                       RM_ERR("ERROR! invalid argument error. maybe msgid removed from system");\r
-                       if (msgq_recover_tx() != RM_OK)\r
-                               return RM_ERROR;\r
-               }\r
-\r
-               if (retry >= 5) {\r
-                       RM_ERR("ERROR! timeout");\r
-                       return RM_ERROR;\r
-               }\r
-\r
-               usleep(20 * 1000); /* 20ms */\r
-               retry++;\r
-               // LCOV_EXCL_STOP\r
-       }\r
-\r
-       return RM_OK;\r
-}\r
-\r
-int rm_receive_msg(rm_msg_response *response, int msg_type)\r
-{\r
-       int retry = 0;\r
-       struct timespec tnow;\r
-       clock_gettime(CLOCK_MONOTONIC, &tnow);\r
-\r
-       if (!msgq_initialized())\r
-               msgq_create();\r
-\r
-       while (msgrcv(msgq_rx, (void*) response, sizeof(rm_msg_response) - sizeof(long), msg_type, 0) == -1) {\r
-               // LCOV_EXCL_START\r
-               RM_ERR("Failed to get message, errno(%d)", errno);\r
-\r
-               if (errno == EIDRM) {\r
-                       RM_ERR("WARNING! msgid removed from system");\r
-                       msgq_recover_rx();\r
-                       return RM_ERROR;\r
-               } else if (errno == EINVAL) { /* maybe msgid removed from system */\r
-                       RM_ERR("ERROR! invalid argument error. maybe msgid removed from system");\r
-                       if (msgq_recover_rx() != RM_OK)\r
-                               return RM_ERROR;\r
-\r
-                       if (retry >= 5) {\r
-                               RM_ERR("ERROR! timeout");\r
-                               return RM_ERROR;\r
-                       }\r
-\r
-                       usleep(20 * 1000); /* 20ms */\r
-                       retry++;\r
-               } else if (errno == EINTR) {\r
-                       RM_ERR("WARNING! System Call Inturrupted");\r
-                       continue;\r
-               } else {\r
-                       RM_ERR("Error(errno:%d) is occured!!", errno);\r
-                       return RM_ERROR;\r
-               }\r
-               // LCOV_EXCL_STOP\r
-       }\r
-\r
-       return RM_OK;\r
-}\r
-\r
-static int get_msg_uid(void)\r
-{\r
-       static int msg_id = 1;\r
-       const int msg_id_max = 65535; // (2^16 - 1)\r
-\r
-       return (++msg_id > msg_id_max) ? 1 : msg_id;\r
-}\r
-\r
-long get_data_type(int handle, int msg_type)\r
-{\r
-       long data_type = 0L;\r
-       int msg_uid = get_msg_uid();\r
-\r
-       data_type = ((static_cast<long>(handle)) << 22);\r
-       data_type |= ((static_cast<long>(msg_type)) << 16);\r
-       data_type |= msg_uid;\r
-       data_type = (data_type < 0) ? labs(data_type) : data_type; /* message type must be > 0, refer to description of struct msgbuf */\r
-\r
-       RM_INFO("data_type : (%ld), msg_uid : (%d), handle : (%d), msg_type : (%d)", data_type, msg_uid, handle, msg_type);\r
-\r
-       return data_type;\r
-}\r
-\r
-unsigned long long get_uptime(void)\r
-{\r
-       struct timespec t;\r
-       clock_gettime(CLOCK_MONOTONIC, &t);\r
-       return t.tv_sec;\r
-}\r
-\r
-void rm_construct_request_msg(rm_msg_request *request, int msg_type, int handle)\r
-{\r
-       if (!request) {\r
-               RM_ERR("request is NULL");\r
-               return;\r
-       }\r
-\r
-       request->data_type = (msg_type == RM_REQUEST_REGISTER) ? (RM_REQUEST_DATA_TYPE_REGISTER | getpid()) : get_data_type(handle, msg_type);\r
-       request->type = msg_type;\r
-       request->handle = handle;\r
-       request->pid = getpid();\r
-       request->time = get_uptime();\r
-\r
-       RM_INFO("DONE");\r
-}\r
+/*
+ * Copyright (c) 2024 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 <stdlib.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <errno.h>
+#include <unistd.h>
+#include <time.h>
+
+#include <rm_msg.h>
+#include <rm_internal.h>
+#include <rm_debug.h>
+
+#define RM_MSGQ_KEY_TX 8211
+#define RM_MSGQ_KEY_RX 8212
+
+static int msgq_tx = -1;
+static int msgq_rx = -1;
+
+static inline bool msgq_initialized(void)
+{
+       return ((msgq_tx >= 0) && (msgq_rx >= 0));
+}
+
+static int msgq_create(void)
+{
+       msgq_tx = msgget((key_t)RM_MSGQ_KEY_TX, 0666 | IPC_CREAT);
+       msgq_rx = msgget((key_t)RM_MSGQ_KEY_RX, 0666 | IPC_CREAT);
+
+       if ((msgq_tx == -1) || (msgq_rx == -1)) {
+               RM_ERR("failed to get msgq_id - msgq_tx(%d), msgq_rx(%d)", msgq_tx, msgq_rx);
+               return RM_ERROR;
+       }
+
+       RM_INFO("msgq_tx (%d), msgq_rx(%d)", msgq_tx, msgq_rx);
+
+       return RM_OK;
+}
+
+// LCOV_EXCL_START
+static int msgq_recover_tx(void)
+{
+       msgq_tx = msgget((key_t)RM_MSGQ_KEY_TX, 0666 | IPC_CREAT);
+
+       if (msgq_tx == -1) {
+               RM_ERR("failed to get new msgq_id - msgq_tx(%d), errno(%d)", msgq_tx, errno);
+               return RM_ERROR;
+       }
+
+       RM_ERR("msgq recovered - msgq_tx(%d)", msgq_tx);
+       return RM_OK;
+}
+
+
+static int msgq_recover_rx(void)
+{
+       msgq_rx = msgget((key_t)RM_MSGQ_KEY_RX, 0666 | IPC_CREAT);
+
+       if (msgq_rx == -1) {
+               RM_ERR("failed to get new msgq_id - msgq_rx(%d), errno(%d)", msgq_rx, errno);
+               return RM_ERROR;
+       }
+
+       RM_ERR("msgq recovered - msgq_rx(%d)", msgq_rx);
+       return RM_OK;
+}
+// LCOV_EXCL_STOP
+
+int rm_send_msg(rm_msg_request *data)
+{
+       struct timespec tnow;
+       clock_gettime(CLOCK_MONOTONIC, &tnow);
+
+       if (!msgq_initialized())
+               msgq_create();
+
+       RM_INFO("msgq_tx %d msgq_rx %d", msgq_tx, msgq_rx);
+
+       int retry = 0;
+
+       RM_WARN("handle(%d) req.data_type : %ld, req #%d, req.type : %d, req.pid : %d", data->handle, data->data_type, data->request_num, data->type, data->pid);
+
+       while (msgsnd(msgq_tx,(void*) data, sizeof(rm_msg_request) - sizeof(long), 0) == -1) {
+               // LCOV_EXCL_START
+               RM_ERR("failed to send message (%d)", errno);
+
+               if (errno == EIDRM) {
+                       RM_ERR("ERROR! msgid removed from system");
+                       if (msgq_recover_tx() != RM_OK)
+                               return RM_ERROR;
+               } else if ((errno == EINVAL) && (data->data_type > 0)) { /* maybe msgid removed from system */
+                       RM_ERR("ERROR! invalid argument error. maybe msgid removed from system");
+                       if (msgq_recover_tx() != RM_OK)
+                               return RM_ERROR;
+               }
+
+               if (retry >= 5) {
+                       RM_ERR("ERROR! timeout");
+                       return RM_ERROR;
+               }
+
+               usleep(20 * 1000); /* 20ms */
+               retry++;
+               // LCOV_EXCL_STOP
+       }
+
+       return RM_OK;
+}
+
+int rm_receive_msg(rm_msg_response *response, int msg_type)
+{
+       int retry = 0;
+       struct timespec tnow;
+       clock_gettime(CLOCK_MONOTONIC, &tnow);
+
+       if (!msgq_initialized())
+               msgq_create();
+
+       while (msgrcv(msgq_rx, (void*) response, sizeof(rm_msg_response) - sizeof(long), msg_type, 0) == -1) {
+               // LCOV_EXCL_START
+               RM_ERR("Failed to get message, errno(%d)", errno);
+
+               if (errno == EIDRM) {
+                       RM_ERR("WARNING! msgid removed from system");
+                       msgq_recover_rx();
+                       return RM_ERROR;
+               } else if (errno == EINVAL) { /* maybe msgid removed from system */
+                       RM_ERR("ERROR! invalid argument error. maybe msgid removed from system");
+                       if (msgq_recover_rx() != RM_OK)
+                               return RM_ERROR;
+
+                       if (retry >= 5) {
+                               RM_ERR("ERROR! timeout");
+                               return RM_ERROR;
+                       }
+
+                       usleep(20 * 1000); /* 20ms */
+                       retry++;
+               } else if (errno == EINTR) {
+                       RM_ERR("WARNING! System Call Inturrupted");
+                       continue;
+               } else {
+                       RM_ERR("Error(errno:%d) is occured!!", errno);
+                       return RM_ERROR;
+               }
+               // LCOV_EXCL_STOP
+       }
+
+       return RM_OK;
+}
+
+static int get_msg_uid(void)
+{
+       static int msg_id = 1;
+       const int msg_id_max = 65535; // (2^16 - 1)
+
+       return (++msg_id > msg_id_max) ? 1 : msg_id;
+}
+
+long get_data_type(int handle, int msg_type)
+{
+       long data_type = 0L;
+       int msg_uid = get_msg_uid();
+
+       data_type = ((static_cast<long>(handle)) << 22);
+       data_type |= ((static_cast<long>(msg_type)) << 16);
+       data_type |= msg_uid;
+       data_type = (data_type < 0) ? labs(data_type) : data_type; /* message type must be > 0, refer to description of struct msgbuf */
+
+       RM_INFO("data_type : (%ld), msg_uid : (%d), handle : (%d), msg_type : (%d)", data_type, msg_uid, handle, msg_type);
+
+       return data_type;
+}
+
+unsigned long long get_uptime(void)
+{
+       struct timespec t;
+       clock_gettime(CLOCK_MONOTONIC, &t);
+       return t.tv_sec;
+}
+
+void rm_construct_request_msg(rm_msg_request *request, int msg_type, int handle)
+{
+       if (!request) {
+               RM_ERR("request is NULL");
+               return;
+       }
+
+       request->data_type = (msg_type == RM_REQUEST_REGISTER) ? (RM_REQUEST_DATA_TYPE_REGISTER | getpid()) : get_data_type(handle, msg_type);
+       request->type = msg_type;
+       request->handle = handle;
+       request->pid = getpid();
+       request->time = get_uptime();
+
+       RM_INFO("DONE");
+}
index 713b85a209382d121d26f77fcb1c31d7a295a8b4..81a6703008eb782e4dc317bb09ffc0b2a4de25e5 100644 (file)
@@ -1,76 +1,76 @@
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include <assert.h>\r
-#include <rm_module_api.h>\r
-\r
-#include <ut_common.h>\r
-#include <TCCallbackListener.h>\r
-\r
-void TCCallbackListener::ScalerStateChangeCb(rm_resource_list_h scalers, void *data)\r
-{\r
-       TCCallbackListener *listener = (TCCallbackListener*) data;\r
-       assert(listener);\r
-\r
-       listener->RemoveAllScalers();\r
-       listener->IncreaseNotificationNum();\r
-\r
-       int n_allocated_scalers = rm_resource_list_get_count(scalers);\r
-       RM_TEST_MSG("n_allocated_scalers(%d)", n_allocated_scalers);\r
-       if (n_allocated_scalers == 0)\r
-               return;\r
-\r
-       rm_resource_h scaler = rm_resource_list_get_first(scalers);\r
-       while (scaler) {\r
-               RM_TEST_MSG("scaler(%d:%d)", rm_scaler_get_virtual_id(scaler), rm_scaler_get_source_id(scaler));\r
-               listener->AddScaler(rm_scaler_get_virtual_id(scaler), rm_scaler_get_source_id(scaler));\r
-               scaler = rm_resource_list_get_next(scalers);\r
-       }\r
-}\r
-\r
-TCCallbackListener::TCCallbackListener()\r
-{\r
-       m_n_notification = 0;\r
-}\r
-\r
-TCCallbackListener::~TCCallbackListener()\r
-{\r
-       UnregisterScalerStateChangeCb();\r
-}\r
-\r
-void TCCallbackListener::AddScaler(int vid, int src_id)\r
-{\r
-       m_scalers.insert(std::pair<int, int>(vid, src_id));\r
-}\r
-\r
-bool TCCallbackListener::IsIncluded(int vid, int src_id)\r
-{\r
-       auto it = m_scalers.find(vid);\r
-       if (it == m_scalers.end())\r
-               return false;\r
-\r
-       return (it->second == src_id) ? true:false;\r
-}\r
-\r
-int TCCallbackListener::RegisterScalerStateChangeCb(void)\r
-{\r
-       return rm_subscribe_scaler_state_change(TCCallbackListener::ScalerStateChangeCb, this);\r
-}\r
-\r
-int TCCallbackListener::UnregisterScalerStateChangeCb(void)\r
-{\r
-       return rm_unsubscribe_scaler_state_change(TCCallbackListener::ScalerStateChangeCb);\r
-}\r
+/*
+ * Copyright (c) 2024 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 <assert.h>
+#include <rm_module_api.h>
+
+#include <ut_common.h>
+#include <TCCallbackListener.h>
+
+void TCCallbackListener::ScalerStateChangeCb(rm_resource_list_h scalers, void *data)
+{
+       TCCallbackListener *listener = (TCCallbackListener*) data;
+       assert(listener);
+
+       listener->RemoveAllScalers();
+       listener->IncreaseNotificationNum();
+
+       int n_allocated_scalers = rm_resource_list_get_count(scalers);
+       RM_TEST_MSG("n_allocated_scalers(%d)", n_allocated_scalers);
+       if (n_allocated_scalers == 0)
+               return;
+
+       rm_resource_h scaler = rm_resource_list_get_first(scalers);
+       while (scaler) {
+               RM_TEST_MSG("scaler(%d:%d)", rm_scaler_get_virtual_id(scaler), rm_scaler_get_source_id(scaler));
+               listener->AddScaler(rm_scaler_get_virtual_id(scaler), rm_scaler_get_source_id(scaler));
+               scaler = rm_resource_list_get_next(scalers);
+       }
+}
+
+TCCallbackListener::TCCallbackListener()
+{
+       m_n_notification = 0;
+}
+
+TCCallbackListener::~TCCallbackListener()
+{
+       UnregisterScalerStateChangeCb();
+}
+
+void TCCallbackListener::AddScaler(int vid, int src_id)
+{
+       m_scalers.insert(std::pair<int, int>(vid, src_id));
+}
+
+bool TCCallbackListener::IsIncluded(int vid, int src_id)
+{
+       auto it = m_scalers.find(vid);
+       if (it == m_scalers.end())
+               return false;
+
+       return (it->second == src_id) ? true:false;
+}
+
+int TCCallbackListener::RegisterScalerStateChangeCb(void)
+{
+       return rm_subscribe_scaler_state_change(TCCallbackListener::ScalerStateChangeCb, this);
+}
+
+int TCCallbackListener::UnregisterScalerStateChangeCb(void)
+{
+       return rm_unsubscribe_scaler_state_change(TCCallbackListener::ScalerStateChangeCb);
+}
index b1c1ce5ce57b4984fb1ad888ef9a31d04d1834b8..37abd41d3a7f1ca938ef96c20d57150a49bb573b 100644 (file)
@@ -1,45 +1,45 @@
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __TC_CALLBACK_LISTENER_H__\r
-#define __TC_CALLBACK_LISTENER_H__\r
-\r
-#include <map>\r
-#include <rm_module_api.h>\r
-\r
-class TCCallbackListener\r
-{\r
-public:\r
-       TCCallbackListener();\r
-       ~TCCallbackListener();\r
-\r
-       static void ScalerStateChangeCb(rm_resource_list_h scalers, void *data);\r
-\r
-       int RegisterScalerStateChangeCb(void);\r
-       int UnregisterScalerStateChangeCb(void);\r
-       void RemoveAllScalers(void) { m_scalers.clear(); }\r
-       void AddScaler(int vid, int src_id);\r
-       bool IsIncluded(int vid, int src_id);\r
-       int GetNotificationNum(void) { return m_n_notification; }\r
-       void ResetNotificationNum(void) { m_n_notification = 0; }\r
-       void IncreaseNotificationNum(void) { m_n_notification++; }\r
-\r
-private:\r
-       std::map<int, int> m_scalers;\r
-       int m_n_notification;\r
-};\r
-\r
-#endif //__TC_CALLBACK_LISTENER_H__
\ No newline at end of file
+/*
+ * Copyright (c) 2024 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 __TC_CALLBACK_LISTENER_H__
+#define __TC_CALLBACK_LISTENER_H__
+
+#include <map>
+#include <rm_module_api.h>
+
+class TCCallbackListener
+{
+public:
+       TCCallbackListener();
+       ~TCCallbackListener();
+
+       static void ScalerStateChangeCb(rm_resource_list_h scalers, void *data);
+
+       int RegisterScalerStateChangeCb(void);
+       int UnregisterScalerStateChangeCb(void);
+       void RemoveAllScalers(void) { m_scalers.clear(); }
+       void AddScaler(int vid, int src_id);
+       bool IsIncluded(int vid, int src_id);
+       int GetNotificationNum(void) { return m_n_notification; }
+       void ResetNotificationNum(void) { m_n_notification = 0; }
+       void IncreaseNotificationNum(void) { m_n_notification++; }
+
+private:
+       std::map<int, int> m_scalers;
+       int m_n_notification;
+};
+
+#endif //__TC_CALLBACK_LISTENER_H__
index 8408b30664f8b50d64cff1aee1e1b15ce807af0f..e7c97885720379d8d3c74a7c108ef673c90dbdf1 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "gtest/gtest.h"\r
-#include <rm_api.h>\r
-#include <rm_module_api.h>\r
-#include <ut_common.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include "TCResource.h"\r
-#include "TCPlayer.h"\r
-\r
-TCPlayer::TCPlayer()\r
-{\r
-       m_handle = 0;\r
-       m_allocated_rsc_index = 0;\r
-       m_rsc_index = 0;\r
-       m_query_index = 0;\r
-       m_n_conflict = 0;\r
-       m_n_conflicted_rsc = 0;\r
-}\r
-\r
-TCPlayer::~TCPlayer()\r
-{\r
-       Unregister();\r
-}\r
-\r
-rm_cb_result TCPlayer::ConflictCb(int handle, rm_callback_type event, rm_device_request_s *info, void *data)\r
-{\r
-       if (!data)\r
-               return RM_CB_RESULT_ERROR;\r
-\r
-       TCPlayer *player = (TCPlayer*) data;\r
-       player->IncreaseConflictNum();\r
-       player->SetConflictedResourcesNum(info->request_num);\r
-\r
-       for (int j = 0; j < info->request_num; j++) {\r
-               player->AddConflictedResource(j+1, info->device_id[j]);\r
-       }\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, info));\r
-       return RM_CB_RESULT_OK;\r
-}\r
-\r
-int TCPlayer::Register(void)\r
-{\r
-       if (m_handle != 0)\r
-               return RM_ERROR;\r
-\r
-       return rm_register(TCPlayer::ConflictCb, this, &m_handle, NULL);\r
-}\r
-\r
-int TCPlayer::Unregister(void)\r
-{\r
-       int result = RM_ERROR;;\r
-\r
-       RemoveResources();\r
-       RemoveQueries();\r
-       m_allocated_resources.clear();\r
-\r
-       result = rm_unregister(m_handle);\r
-       m_handle = 0;\r
-\r
-       return result;\r
-}\r
-\r
-int TCPlayer::SetPriority(int priority)\r
-{\r
-       return rm_set_priority(m_handle, priority);\r
-}\r
-\r
-int TCPlayer::SetAppId(std::string app_id)\r
-{\r
-       return rm_set_app_id(m_handle, (char*) app_id.c_str());\r
-}\r
-\r
-int TCPlayer::AddResource(int category_id, int state)\r
-{\r
-       TCResource *rsc = new TCResource(category_id, 0, state);\r
-       m_rsc_index++;\r
-       m_requested_resources.insert(std::pair<int, TCResource *>(m_rsc_index, rsc));\r
-       return 0;\r
-}\r
-\r
-int TCPlayer::AddResource(int category_id, int category_option, int state)\r
-{\r
-       TCResource *rsc = new TCResource(category_id, category_option, state);\r
-       m_rsc_index++;\r
-       m_requested_resources.insert(std::pair<int, TCResource *>(m_rsc_index, rsc));\r
-       return 0;\r
-}\r
-\r
-int TCPlayer::AddQuery(int category_id, int category_option, int state)\r
-{\r
-       TCResource *rsc = new TCResource(category_id, category_option, state);\r
-       m_query_index++;\r
-       m_queries.insert(std::pair<int, TCResource *>(m_query_index, rsc));\r
-       return 0;\r
-}\r
-\r
-void TCPlayer::RemoveResources(void)\r
-{\r
-       TCResource *rsc = nullptr;\r
-\r
-       for (auto &it : m_requested_resources) {\r
-               rsc = it.second;\r
-               if (rsc)\r
-                       delete rsc;\r
-       }\r
-       m_requested_resources.clear();\r
-}\r
-\r
-int TCPlayer::GetAudioCategory(std::string codec_name, int mixing_mode)\r
-{\r
-       ri_audio_category_option_request_s audio_option;\r
-       memset(&audio_option, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       audio_option.codec_name = codec_name.c_str();\r
-       audio_option.mixing_mode = (ri_audio_mixing_mode) mixing_mode;\r
-\r
-       return ri_get_capable_audio_category_id(&audio_option);\r
-}\r
-\r
-int TCPlayer::GetCapableVideoCategory(std::string codec_name, int h_size, int v_size, int color_depth, int sampling_format, int framerate)\r
-{\r
-       ri_video_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       opt.codec_name = strndup(codec_name.c_str(), codec_name.length());\r
-       opt.color_depth = color_depth;\r
-       opt.framerate = framerate;\r
-       opt.h_size = h_size;\r
-       opt.v_size = v_size;\r
-       opt.sampling_format = sampling_format;\r
-\r
-       int result = ri_get_capable_video_category_id(&opt);\r
-\r
-       free((void*) opt.codec_name);\r
-       return result;\r
-}\r
-\r
-int TCPlayer::GetCapableImageCategory(std::string codec_name, int w_size, int h_size)\r
-{\r
-       char *codec = strndup(codec_name.c_str(), codec_name.length());\r
-       int result = ri_get_image_category_id(codec, w_size, h_size);\r
-       free(codec);\r
-       return result;\r
-}\r
-\r
-int TCPlayer::GetCapableNDecoderCategory(std::string codec_name, int h_size, int v_size, int color_depth, int sampling_format, int framerate)\r
-{\r
-       ri_video_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       opt.codec_name = strndup(codec_name.c_str(), codec_name.length());\r
-       opt.color_depth = color_depth;\r
-       opt.framerate = framerate;\r
-       opt.h_size = h_size;\r
-       opt.v_size = v_size;\r
-       opt.sampling_format = sampling_format;\r
-\r
-       return ri_get_n_decoder_category_id(&opt);\r
-}\r
-\r
-int TCPlayer::Query(int query_type, int *ans)\r
-{\r
-       rm_category_request_s req;\r
-       memset(&req, 0, sizeof(rm_category_request_s));\r
-\r
-       int i = 0;\r
-       int result = RM_ERROR;\r
-       int answer;\r
-\r
-       req.request_num = m_queries.size();\r
-\r
-       for (auto &it : m_queries) {\r
-               TCResource *rsc = it.second;\r
-               req.category_id[i] = (rm_rsc_category_e) rsc->GetCategoryId();\r
-               req.category_option[i] = rsc->GetCategoryOption();\r
-               req.state[i] = (rm_requests_resource_state_e) rsc->GetState();\r
-               i++;\r
-       }\r
-\r
-       result = rm_query(m_handle, (rm_query_type_e) query_type, &req, &answer);\r
-       *ans = answer;\r
-\r
-       return result;\r
-}\r
-\r
-void TCPlayer::RemoveQueries(void)\r
-{\r
-       TCResource *rsc = nullptr;\r
-\r
-       for (auto &it : m_queries) {\r
-               rsc = it.second;\r
-               if (rsc)\r
-                       delete rsc;\r
-       }\r
-       m_queries.clear();\r
-}\r
-\r
-void TCPlayer::AddAllocatedResource(int device_id)\r
-{\r
-       m_allocated_resources.insert(std::pair<int, int>(++m_allocated_rsc_index, device_id));\r
-}\r
-\r
-int TCPlayer::GetAllocatedResourceId(int index)\r
-{\r
-       auto it = m_allocated_resources.find(index);\r
-\r
-       return (it == m_allocated_resources.end()) ? -1 : it->second;\r
-}\r
-\r
-int TCPlayer::AllocateResources(void)\r
-{\r
-       if (m_requested_resources.size() == 0)\r
-               return RM_ERROR;\r
-\r
-       int i = 0;\r
-       int result = RM_ERROR;\r
-\r
-       rm_category_request_s req;\r
-       memset(&req, 0, sizeof(rm_category_request_s));\r
-\r
-       req.request_num = m_requested_resources.size();\r
-\r
-       for (auto &it : m_requested_resources) {\r
-               TCResource *rsc = it.second;\r
-               req.category_id[i] = (rm_rsc_category_e) rsc->GetCategoryId();\r
-               req.category_option[i] = rsc->GetCategoryOption();\r
-               req.state[i] = (rm_requests_resource_state_e) rsc->GetState();\r
-               i++;\r
-       }\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(allocated));\r
-\r
-       result = rm_allocate_resources(m_handle, &req, &allocated);\r
-\r
-       if (result == RM_OK) {\r
-               for (int j = 0; j < allocated.allocated_num; j++)\r
-                       AddAllocatedResource(allocated.device_id[j]);\r
-       }\r
-\r
-       return result;\r
-}\r
-\r
-int TCPlayer::ReleaseResources(void)\r
-{\r
-       if (m_allocated_resources.size() <= 0)\r
-               return RM_ERROR;\r
-\r
-       int i = 0;\r
-       rm_device_request_s req;\r
-       memset(&req, 0, sizeof(req));\r
-\r
-       req.request_num = m_allocated_resources.size();\r
-\r
-       for (auto &it : m_allocated_resources) {\r
-               req.device_id[i] = it.second;\r
-               i++;\r
-       }\r
-\r
-       m_allocated_resources.clear();\r
-\r
-       return rm_deallocate_resources(m_handle, &req);\r
-}\r
-\r
-int TCPlayer::ReleaseResource(int index)\r
-{\r
-       if (m_allocated_resources.size() <= 0)\r
-               return RM_ERROR;\r
-\r
-       auto it = m_allocated_resources.find(index);\r
-       int device_id = (it == m_allocated_resources.end()) ? -1 : it->second;\r
-\r
-       rm_device_request_s req;\r
-       memset(&req, 0, sizeof(req));\r
-\r
-       req.request_num = 1;\r
-       req.device_id[0] = device_id;\r
-\r
-       m_allocated_resources.erase(index);\r
-\r
-       return rm_deallocate_resources(m_handle, &req);\r
-}\r
-\r
-int TCPlayer::GetActiveAudioOut(void)\r
-{\r
-       return rm_get_active_audio_out(m_handle);\r
-}\r
-\r
-int TCPlayer::GetConflictedResourceId(int index)\r
-{\r
-       auto it = m_conflicted_resources.find(index);\r
-\r
-       return (it == m_conflicted_resources.end()) ? -1 : it->second;\r
-}\r
-\r
-void TCPlayer::AddConflictedResource(int index, int device_id)\r
-{\r
-       m_conflicted_resources.insert(std::pair<int, int>(index, device_id));\r
-}\r
+/*
+ * Copyright (c) 2024 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 "gtest/gtest.h"
+#include <rm_api.h>
+#include <rm_module_api.h>
+#include <ut_common.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include "TCResource.h"
+#include "TCPlayer.h"
+
+TCPlayer::TCPlayer()
+{
+       m_handle = 0;
+       m_allocated_rsc_index = 0;
+       m_rsc_index = 0;
+       m_query_index = 0;
+       m_n_conflict = 0;
+       m_n_conflicted_rsc = 0;
+}
+
+TCPlayer::~TCPlayer()
+{
+       Unregister();
+}
+
+rm_cb_result TCPlayer::ConflictCb(int handle, rm_callback_type event, rm_device_request_s *info, void *data)
+{
+       if (!data)
+               return RM_CB_RESULT_ERROR;
+
+       TCPlayer *player = (TCPlayer*) data;
+       player->IncreaseConflictNum();
+       player->SetConflictedResourcesNum(info->request_num);
+
+       for (int j = 0; j < info->request_num; j++) {
+               player->AddConflictedResource(j+1, info->device_id[j]);
+       }
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, info));
+       return RM_CB_RESULT_OK;
+}
+
+int TCPlayer::Register(void)
+{
+       if (m_handle != 0)
+               return RM_ERROR;
+
+       return rm_register(TCPlayer::ConflictCb, this, &m_handle, NULL);
+}
+
+int TCPlayer::Unregister(void)
+{
+       int result = RM_ERROR;;
+
+       RemoveResources();
+       RemoveQueries();
+       m_allocated_resources.clear();
+
+       result = rm_unregister(m_handle);
+       m_handle = 0;
+
+       return result;
+}
+
+int TCPlayer::SetPriority(int priority)
+{
+       return rm_set_priority(m_handle, priority);
+}
+
+int TCPlayer::SetAppId(std::string app_id)
+{
+       return rm_set_app_id(m_handle, (char*) app_id.c_str());
+}
+
+int TCPlayer::AddResource(int category_id, int state)
+{
+       TCResource *rsc = new TCResource(category_id, 0, state);
+       m_rsc_index++;
+       m_requested_resources.insert(std::pair<int, TCResource *>(m_rsc_index, rsc));
+       return 0;
+}
+
+int TCPlayer::AddResource(int category_id, int category_option, int state)
+{
+       TCResource *rsc = new TCResource(category_id, category_option, state);
+       m_rsc_index++;
+       m_requested_resources.insert(std::pair<int, TCResource *>(m_rsc_index, rsc));
+       return 0;
+}
+
+int TCPlayer::AddQuery(int category_id, int category_option, int state)
+{
+       TCResource *rsc = new TCResource(category_id, category_option, state);
+       m_query_index++;
+       m_queries.insert(std::pair<int, TCResource *>(m_query_index, rsc));
+       return 0;
+}
+
+void TCPlayer::RemoveResources(void)
+{
+       TCResource *rsc = nullptr;
+
+       for (auto &it : m_requested_resources) {
+               rsc = it.second;
+               if (rsc)
+                       delete rsc;
+       }
+       m_requested_resources.clear();
+}
+
+int TCPlayer::GetAudioCategory(std::string codec_name, int mixing_mode)
+{
+       ri_audio_category_option_request_s audio_option;
+       memset(&audio_option, 0, sizeof(ri_audio_category_option_request_s));
+
+       audio_option.codec_name = codec_name.c_str();
+       audio_option.mixing_mode = (ri_audio_mixing_mode) mixing_mode;
+
+       return ri_get_capable_audio_category_id(&audio_option);
+}
+
+int TCPlayer::GetCapableVideoCategory(std::string codec_name, int h_size, int v_size, int color_depth, int sampling_format, int framerate)
+{
+       ri_video_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_video_category_option_request_s));
+
+       opt.codec_name = strndup(codec_name.c_str(), codec_name.length());
+       opt.color_depth = color_depth;
+       opt.framerate = framerate;
+       opt.h_size = h_size;
+       opt.v_size = v_size;
+       opt.sampling_format = sampling_format;
+
+       int result = ri_get_capable_video_category_id(&opt);
+
+       free((void*) opt.codec_name);
+       return result;
+}
+
+int TCPlayer::GetCapableImageCategory(std::string codec_name, int w_size, int h_size)
+{
+       char *codec = strndup(codec_name.c_str(), codec_name.length());
+       int result = ri_get_image_category_id(codec, w_size, h_size);
+       free(codec);
+       return result;
+}
+
+int TCPlayer::GetCapableNDecoderCategory(std::string codec_name, int h_size, int v_size, int color_depth, int sampling_format, int framerate)
+{
+       ri_video_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_video_category_option_request_s));
+
+       opt.codec_name = strndup(codec_name.c_str(), codec_name.length());
+       opt.color_depth = color_depth;
+       opt.framerate = framerate;
+       opt.h_size = h_size;
+       opt.v_size = v_size;
+       opt.sampling_format = sampling_format;
+
+       return ri_get_n_decoder_category_id(&opt);
+}
+
+int TCPlayer::Query(int query_type, int *ans)
+{
+       rm_category_request_s req;
+       memset(&req, 0, sizeof(rm_category_request_s));
+
+       int i = 0;
+       int result = RM_ERROR;
+       int answer;
+
+       req.request_num = m_queries.size();
+
+       for (auto &it : m_queries) {
+               TCResource *rsc = it.second;
+               req.category_id[i] = (rm_rsc_category_e) rsc->GetCategoryId();
+               req.category_option[i] = rsc->GetCategoryOption();
+               req.state[i] = (rm_requests_resource_state_e) rsc->GetState();
+               i++;
+       }
+
+       result = rm_query(m_handle, (rm_query_type_e) query_type, &req, &answer);
+       *ans = answer;
+
+       return result;
+}
+
+void TCPlayer::RemoveQueries(void)
+{
+       TCResource *rsc = nullptr;
+
+       for (auto &it : m_queries) {
+               rsc = it.second;
+               if (rsc)
+                       delete rsc;
+       }
+       m_queries.clear();
+}
+
+void TCPlayer::AddAllocatedResource(int device_id)
+{
+       m_allocated_resources.insert(std::pair<int, int>(++m_allocated_rsc_index, device_id));
+}
+
+int TCPlayer::GetAllocatedResourceId(int index)
+{
+       auto it = m_allocated_resources.find(index);
+
+       return (it == m_allocated_resources.end()) ? -1 : it->second;
+}
+
+int TCPlayer::AllocateResources(void)
+{
+       if (m_requested_resources.size() == 0)
+               return RM_ERROR;
+
+       int i = 0;
+       int result = RM_ERROR;
+
+       rm_category_request_s req;
+       memset(&req, 0, sizeof(rm_category_request_s));
+
+       req.request_num = m_requested_resources.size();
+
+       for (auto &it : m_requested_resources) {
+               TCResource *rsc = it.second;
+               req.category_id[i] = (rm_rsc_category_e) rsc->GetCategoryId();
+               req.category_option[i] = rsc->GetCategoryOption();
+               req.state[i] = (rm_requests_resource_state_e) rsc->GetState();
+               i++;
+       }
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(allocated));
+
+       result = rm_allocate_resources(m_handle, &req, &allocated);
+
+       if (result == RM_OK) {
+               for (int j = 0; j < allocated.allocated_num; j++)
+                       AddAllocatedResource(allocated.device_id[j]);
+       }
+
+       return result;
+}
+
+int TCPlayer::ReleaseResources(void)
+{
+       if (m_allocated_resources.size() <= 0)
+               return RM_ERROR;
+
+       int i = 0;
+       rm_device_request_s req;
+       memset(&req, 0, sizeof(req));
+
+       req.request_num = m_allocated_resources.size();
+
+       for (auto &it : m_allocated_resources) {
+               req.device_id[i] = it.second;
+               i++;
+       }
+
+       m_allocated_resources.clear();
+
+       return rm_deallocate_resources(m_handle, &req);
+}
+
+int TCPlayer::ReleaseResource(int index)
+{
+       if (m_allocated_resources.size() <= 0)
+               return RM_ERROR;
+
+       auto it = m_allocated_resources.find(index);
+       int device_id = (it == m_allocated_resources.end()) ? -1 : it->second;
+
+       rm_device_request_s req;
+       memset(&req, 0, sizeof(req));
+
+       req.request_num = 1;
+       req.device_id[0] = device_id;
+
+       m_allocated_resources.erase(index);
+
+       return rm_deallocate_resources(m_handle, &req);
+}
+
+int TCPlayer::GetActiveAudioOut(void)
+{
+       return rm_get_active_audio_out(m_handle);
+}
+
+int TCPlayer::GetConflictedResourceId(int index)
+{
+       auto it = m_conflicted_resources.find(index);
+
+       return (it == m_conflicted_resources.end()) ? -1 : it->second;
+}
+
+void TCPlayer::AddConflictedResource(int index, int device_id)
+{
+       m_conflicted_resources.insert(std::pair<int, int>(index, device_id));
+}
index 3910ed13e4602452ecb373a369db42ceaa774675..1cc1dfa2b4734374dc8eccf0fd52d8ccd9ecb4ed 100644 (file)
@@ -1,82 +1,82 @@
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __TC_PLAYER_H__\r
-#define __TC_PLAYER_H__\r
-\r
-#include <string>\r
-#include <map>\r
-#include <rm_api.h>\r
-\r
-class TCResource;\r
-class TCPlayer\r
-{\r
-public:\r
-       TCPlayer();\r
-       TCPlayer(std::string app_id) { m_app_id = app_id; }\r
-       ~TCPlayer();\r
-\r
-       static rm_cb_result ConflictCb(int handle, rm_callback_type event, rm_device_request_s *info, void *data);\r
-       int Register(void);\r
-       int Unregister(void);\r
-\r
-       int SetPriority(int priority);\r
-       int SetAppId(std::string app_id);\r
-       void SetCustomHandle(int handle) { m_handle = handle;}\r
-\r
-       int AddResource(int category_id, int state);\r
-       int AddResource(int category_id, int category_option, int state);\r
-       void RemoveResources(void);\r
-       int GetAudioCategory(std::string codec_name, int mixing_mode);\r
-       int GetCapableVideoCategory(std::string codec_name, int h_size, int v_size, int color_depth, int sampling_format, int framerate);\r
-       int GetCapableNDecoderCategory(std::string codec_name, int h_size, int v_size, int color_depth, int sampling_format, int framerate);\r
-       int GetCapableImageCategory(std::string codec_name, int h_size, int v_size);\r
-\r
-       int AddQuery(int category_id, int category_option, int state);\r
-       void RemoveQueries(void);\r
-       int Query(int query_type, int *ans);\r
-\r
-       void AddAllocatedResource(int device_id);\r
-       int AllocateResources(void);\r
-       int ReleaseResources(void);\r
-       int ReleaseResource(int index);\r
-       int GetAllocatedResourceId(int index);\r
-       int GetAllocatedResourcesNum(void) { return m_allocated_resources.size(); }\r
-\r
-       void IncreaseConflictNum(void) { m_n_conflict++; }\r
-       int GetConflictNum(void) { return m_n_conflict; }\r
-       void SetConflictedResourcesNum(int n) { m_n_conflicted_rsc = n; }\r
-       int GetConflictedResourcesNum(void) { return m_n_conflicted_rsc; }\r
-       int GetConflictedResourceId(int index);\r
-       void AddConflictedResource(int index, int device_id);\r
-       int GetActiveAudioOut(void);\r
-\r
-private:\r
-       std::map<int, int> m_allocated_resources;\r
-       std::map<int, int> m_conflicted_resources;\r
-       std::map<int, TCResource *> m_requested_resources;\r
-       std::map<int, TCResource *> m_queries;\r
-\r
-       std::string m_app_id;\r
-       int m_handle;\r
-       int m_rsc_index;\r
-       int m_query_index;\r
-       int m_allocated_rsc_index;\r
-       int m_n_conflict;\r
-       int m_n_conflicted_rsc;\r
-};\r
-\r
-#endif //__TC_PLAYER_H__\r
+/*
+ * Copyright (c) 2024 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 __TC_PLAYER_H__
+#define __TC_PLAYER_H__
+
+#include <string>
+#include <map>
+#include <rm_api.h>
+
+class TCResource;
+class TCPlayer
+{
+public:
+       TCPlayer();
+       TCPlayer(std::string app_id) { m_app_id = app_id; }
+       ~TCPlayer();
+
+       static rm_cb_result ConflictCb(int handle, rm_callback_type event, rm_device_request_s *info, void *data);
+       int Register(void);
+       int Unregister(void);
+
+       int SetPriority(int priority);
+       int SetAppId(std::string app_id);
+       void SetCustomHandle(int handle) { m_handle = handle;}
+
+       int AddResource(int category_id, int state);
+       int AddResource(int category_id, int category_option, int state);
+       void RemoveResources(void);
+       int GetAudioCategory(std::string codec_name, int mixing_mode);
+       int GetCapableVideoCategory(std::string codec_name, int h_size, int v_size, int color_depth, int sampling_format, int framerate);
+       int GetCapableNDecoderCategory(std::string codec_name, int h_size, int v_size, int color_depth, int sampling_format, int framerate);
+       int GetCapableImageCategory(std::string codec_name, int h_size, int v_size);
+
+       int AddQuery(int category_id, int category_option, int state);
+       void RemoveQueries(void);
+       int Query(int query_type, int *ans);
+
+       void AddAllocatedResource(int device_id);
+       int AllocateResources(void);
+       int ReleaseResources(void);
+       int ReleaseResource(int index);
+       int GetAllocatedResourceId(int index);
+       int GetAllocatedResourcesNum(void) { return m_allocated_resources.size(); }
+
+       void IncreaseConflictNum(void) { m_n_conflict++; }
+       int GetConflictNum(void) { return m_n_conflict; }
+       void SetConflictedResourcesNum(int n) { m_n_conflicted_rsc = n; }
+       int GetConflictedResourcesNum(void) { return m_n_conflicted_rsc; }
+       int GetConflictedResourceId(int index);
+       void AddConflictedResource(int index, int device_id);
+       int GetActiveAudioOut(void);
+
+private:
+       std::map<int, int> m_allocated_resources;
+       std::map<int, int> m_conflicted_resources;
+       std::map<int, TCResource *> m_requested_resources;
+       std::map<int, TCResource *> m_queries;
+
+       std::string m_app_id;
+       int m_handle;
+       int m_rsc_index;
+       int m_query_index;
+       int m_allocated_rsc_index;
+       int m_n_conflict;
+       int m_n_conflicted_rsc;
+};
+
+#endif //__TC_PLAYER_H__
index c14996602c19b0ceeab77985b420cb07adc67846..fc61df0e4709ed8fee3a47a7ba6799d0325709d9 100644 (file)
@@ -1,28 +1,28 @@
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "TCResource.h"\r
-\r
-TCResource::TCResource(int category_id, int category_option, int state)\r
-{\r
-       m_category_id = category_id;\r
-       m_category_option = category_option;\r
-       m_state = state;\r
-}\r
-\r
-TCResource::~TCResource()\r
-{\r
-}\r
+/*
+ * Copyright (c) 2024 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 "TCResource.h"
+
+TCResource::TCResource(int category_id, int category_option, int state)
+{
+       m_category_id = category_id;
+       m_category_option = category_option;
+       m_state = state;
+}
+
+TCResource::~TCResource()
+{
+}
index 545b5afc253d7842f4fd67b477470c28db808309..c3068b4809eb67ae294aef1403e3184fbeacdbfb 100644 (file)
@@ -1,36 +1,36 @@
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __TC_RESOURCE_H__\r
-#define __TC_RESOURCE_H__\r
-\r
-class TCResource\r
-{\r
-public:\r
-       TCResource(int category_id, int category_option, int state);\r
-       ~TCResource();\r
-\r
-       int GetCategoryId(void) {return m_category_id;}\r
-       int GetCategoryOption(void) {return m_category_option;}\r
-       int GetState(void) {return m_state;}\r
-\r
-private:\r
-       int m_category_id;\r
-       int m_category_option;\r
-       int m_state;\r
-};\r
-\r
-#endif //__TC_RESOURCE_H__
\ No newline at end of file
+/*
+ * Copyright (c) 2024 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 __TC_RESOURCE_H__
+#define __TC_RESOURCE_H__
+
+class TCResource
+{
+public:
+       TCResource(int category_id, int category_option, int state);
+       ~TCResource();
+
+       int GetCategoryId(void) {return m_category_id;}
+       int GetCategoryOption(void) {return m_category_option;}
+       int GetState(void) {return m_state;}
+
+private:
+       int m_category_id;
+       int m_category_option;
+       int m_state;
+};
+
+#endif //__TC_RESOURCE_H__
index eaa331bcff9fcc8f7fa95c7fa243a7695d581c80..12b222345e7c12278f926894e7ee593298e82092 100644 (file)
-/*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved\r
- * For conditions of distribution and use, see the accompanying LICENSE.Samsung file .\r
- */\r
-\r
-#include <stdio.h>\r
-#include <unistd.h>\r
-#include <stdlib.h>\r
-#include <sys/stat.h>\r
-#include "gtest/gtest.h"\r
-#include <rm_api.h>\r
-#include <ut_common.h>\r
-\r
-bool read_rm_index(const char *filename, int *data)\r
-{\r
-       FILE *fp = NULL;\r
-       char str[10] = {0,};\r
-       size_t str_size;\r
-\r
-       if (!data) {\r
-               RM_TEST_MSG("invalid input : null data");\r
-               return false;\r
-       }\r
-\r
-       fp = fopen(filename, "rb");\r
-\r
-       if (!fp) {\r
-               RM_TEST_MSG("failed to open (%s) - errno(%d)", filename, errno);\r
-               return false;\r
-       }\r
-\r
-       str_size = fread(str, sizeof(char), sizeof(str)-1, fp);\r
-\r
-       str[str_size] = '\0';\r
-\r
-       if (str_size == 0) {\r
-               fclose(fp);\r
-               return false;\r
-       }\r
-\r
-       *data = atoi(str);\r
-\r
-       fclose(fp);\r
-       fp = NULL;\r
-\r
-       return true;\r
-}\r
-\r
-bool is_8k_model(void)\r
-{\r
-       return false;\r
-}\r
-\r
-static int conflicted;\r
-static int conflicted_cmp;\r
-static int num_of_dealloc_rsc;\r
-\r
-rm_cb_result rm_cb_counting_conflicted(int handle, rm_callback_type event, rm_device_request_s *info, void *data)\r
-{\r
-       ++conflicted;\r
-       num_of_dealloc_rsc = info->request_num;\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, info));\r
-       return RM_CB_RESULT_OK;\r
-}\r
-\r
-rm_cb_result rm_cb_counting_conflicted_cmp(int handle, rm_callback_type event, rm_device_request_s *info, void *data)\r
-{\r
-       ++conflicted_cmp;\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, info));\r
-       return RM_CB_RESULT_OK;\r
-}\r
-\r
-rm_cb_result rm_cb_set_conflict_flag(int handle, rm_callback_type event, rm_device_request_s *info, void *data)\r
-{\r
-       conflicted = 1;\r
-       num_of_dealloc_rsc = info->request_num;\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, info));\r
-\r
-       return RM_CB_RESULT_OK;\r
-}\r
-\r
-rm_cb_result rm_cb_for_conditional_check(int handle, rm_callback_type event, rm_device_request_s *info, void *data)\r
-{\r
-       rm_deallocate_resources(handle, info);\r
-       return RM_CB_RESULT_OK;\r
-}\r
-\r
-int rm_tc_get_conflict_num(void)\r
-{\r
-       return conflicted;\r
-}\r
-\r
-void rm_tc_reset_conflict_num(void)\r
-{\r
-       conflicted = 0;\r
-}\r
-\r
-int rm_tc_get_conflict_num_cmp(void)\r
-{\r
-       return conflicted_cmp;\r
-}\r
-\r
-void rm_tc_reset_conflict_num_cmp(void)\r
-{\r
-       conflicted_cmp = 0;\r
-}\r
-\r
-int rm_tc_get_conflicted_resources_num(void)\r
-{\r
-       return num_of_dealloc_rsc;\r
-}\r
-\r
-void rm_tc_reset_conflicted_resources_num(void)\r
-{\r
-       num_of_dealloc_rsc = 0;\r
-}\r
-\r
-void rm_tc_clear_audio_decoders(void)\r
-{\r
-       RM_TEST_MSG("clear_audio_decoders...");\r
-\r
-       int handle1 = 0;\r
-       if (rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL) != RM_OK) {\r
-               RM_TEST_MSG("failed to register");\r
-               return;\r
-       }\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 2;\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request.category_option[0] = 0;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-       request.category_id[1] = RM_CATEGORY_AUDIO_DECODER_SUB;\r
-       request.category_option[1] = 0;\r
-       request.state[1] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       if (rm_allocate_resources(handle1, &request, &allocated) != RM_OK)\r
-               RM_TEST_MSG("failed to clear audio decoders");\r
-\r
-       if (rm_unregister(handle1) != RM_OK)\r
-               RM_TEST_MSG("failed to unregister");\r
-\r
-       RM_TEST_MSG("clear_audio_decoders done...");\r
-}\r
-\r
-void rm_tc_clear_video_decoders(void)\r
-{\r
-       RM_TEST_MSG("clear_video_decoders...");\r
-\r
-       int handle1 = 0;\r
-       if (rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL) != RM_OK) {\r
-               RM_TEST_MSG("failed to register");\r
-               return;\r
-       }\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = RM_CATEGORY_VIDEO_DECODER_MPEG4_FHD_8BIT_60P;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       if (rm_allocate_resources(handle1, &request, &allocated) != RM_OK)\r
-               RM_TEST_MSG("failed to clear video decoders");\r
-\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = RM_CATEGORY_VIDEO_DECODER_H264_UHD_8BIT_60P;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       if (rm_allocate_resources(handle1, &request, &allocated) != RM_OK)\r
-               RM_TEST_MSG("failed to clear video decoders");\r
-\r
-       if (rm_unregister(handle1) != RM_OK)\r
-               RM_TEST_MSG("failed to unregister");\r
-\r
-       RM_TEST_MSG("clear_video_decoders done...");\r
-}\r
-\r
-void rm_tc_template_exceptional_test_case(int vdec1, int vdec2)\r
-{\r
-       //consumer#1\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));\r
-\r
-       //alloc\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request->category_option[0] = vdec1 | RM_DEVICE_OPT_MAIN;\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-\r
-       //consumer#2\r
-       int handle2 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle2, NULL));\r
-\r
-       //alloc\r
-       rm_category_request_s *request2 = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request2, 0, sizeof(rm_category_request_s));\r
-\r
-       request2->request_num = 1;\r
-       request2->category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request2->category_option[0] = vdec2;\r
-       request2->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated2 = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated2, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request2, allocated2));\r
-\r
-       //unregister\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-}\r
-\r
-bool is_support_4k(void)\r
-{\r
-#ifdef RM_TC_SUPPORT_4K\r
-       return true;\r
-#else\r
-       return false;\r
-#endif //RM_TC_SUPPORT_4K\r
-}\r
-\r
-bool is_support_8k(void)\r
-{\r
-#ifdef RM_TC_SUPPORT_8K\r
-       return true;\r
-#else\r
-       return false;\r
-#endif //RM_TC_SUPPORT_8K\r
-}\r
-\r
-bool is_support_av1_120p(void)\r
-{\r
-#ifdef RM_TC_SUPPORT_AV1_120P\r
-       return true;\r
-#else\r
-       return false;\r
-#endif //RM_TC_SUPPORT_AV1_120P\r
-}\r
-\r
-bool use_unified_jpeg_decoder(void)\r
-{\r
-#ifdef RM_TC_USE_UNIFIED_JPEG_DEC\r
-       return true;\r
-#else\r
-       return false;\r
-#endif// RM_TC_USE_UNIFIED_JPEG_DEC\r
-}\r
-\r
-bool is_oscars_unified_jpeg_decoder(void)\r
-{\r
-#ifdef RM_TC_USE_UNIFIED_JPEG_DEC_OSCARS\r
-       return true;\r
-#else\r
-       return false;\r
-#endif\r
-}\r
-\r
-bool is_support_audio_dual_decoding(void)\r
-{\r
-#ifdef RM_TC_SUPPORT_AUDIO_DUAL_DECODING\r
-       return true;\r
-#else\r
-       return false;\r
-#endif //RM_TC_SUPPORT_AUDIO_DUAL_DECODING\r
-}\r
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ * For conditions of distribution and use, see the accompanying LICENSE.Samsung file .
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include "gtest/gtest.h"
+#include <rm_api.h>
+#include <ut_common.h>
+
+bool read_rm_index(const char *filename, int *data)
+{
+       FILE *fp = NULL;
+       char str[10] = {0,};
+       size_t str_size;
+
+       if (!data) {
+               RM_TEST_MSG("invalid input : null data");
+               return false;
+       }
+
+       fp = fopen(filename, "rb");
+
+       if (!fp) {
+               RM_TEST_MSG("failed to open (%s) - errno(%d)", filename, errno);
+               return false;
+       }
+
+       str_size = fread(str, sizeof(char), sizeof(str)-1, fp);
+
+       str[str_size] = '\0';
+
+       if (str_size == 0) {
+               fclose(fp);
+               return false;
+       }
+
+       *data = atoi(str);
+
+       fclose(fp);
+       fp = NULL;
+
+       return true;
+}
+
+bool is_8k_model(void)
+{
+       return false;
+}
+
+static int conflicted;
+static int conflicted_cmp;
+static int num_of_dealloc_rsc;
+
+rm_cb_result rm_cb_counting_conflicted(int handle, rm_callback_type event, rm_device_request_s *info, void *data)
+{
+       ++conflicted;
+       num_of_dealloc_rsc = info->request_num;
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, info));
+       return RM_CB_RESULT_OK;
+}
+
+rm_cb_result rm_cb_counting_conflicted_cmp(int handle, rm_callback_type event, rm_device_request_s *info, void *data)
+{
+       ++conflicted_cmp;
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, info));
+       return RM_CB_RESULT_OK;
+}
+
+rm_cb_result rm_cb_set_conflict_flag(int handle, rm_callback_type event, rm_device_request_s *info, void *data)
+{
+       conflicted = 1;
+       num_of_dealloc_rsc = info->request_num;
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, info));
+
+       return RM_CB_RESULT_OK;
+}
+
+rm_cb_result rm_cb_for_conditional_check(int handle, rm_callback_type event, rm_device_request_s *info, void *data)
+{
+       rm_deallocate_resources(handle, info);
+       return RM_CB_RESULT_OK;
+}
+
+int rm_tc_get_conflict_num(void)
+{
+       return conflicted;
+}
+
+void rm_tc_reset_conflict_num(void)
+{
+       conflicted = 0;
+}
+
+int rm_tc_get_conflict_num_cmp(void)
+{
+       return conflicted_cmp;
+}
+
+void rm_tc_reset_conflict_num_cmp(void)
+{
+       conflicted_cmp = 0;
+}
+
+int rm_tc_get_conflicted_resources_num(void)
+{
+       return num_of_dealloc_rsc;
+}
+
+void rm_tc_reset_conflicted_resources_num(void)
+{
+       num_of_dealloc_rsc = 0;
+}
+
+void rm_tc_clear_audio_decoders(void)
+{
+       RM_TEST_MSG("clear_audio_decoders...");
+
+       int handle1 = 0;
+       if (rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL) != RM_OK) {
+               RM_TEST_MSG("failed to register");
+               return;
+       }
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 2;
+       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request.category_option[0] = 0;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+       request.category_id[1] = RM_CATEGORY_AUDIO_DECODER_SUB;
+       request.category_option[1] = 0;
+       request.state[1] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       if (rm_allocate_resources(handle1, &request, &allocated) != RM_OK)
+               RM_TEST_MSG("failed to clear audio decoders");
+
+       if (rm_unregister(handle1) != RM_OK)
+               RM_TEST_MSG("failed to unregister");
+
+       RM_TEST_MSG("clear_audio_decoders done...");
+}
+
+void rm_tc_clear_video_decoders(void)
+{
+       RM_TEST_MSG("clear_video_decoders...");
+
+       int handle1 = 0;
+       if (rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL) != RM_OK) {
+               RM_TEST_MSG("failed to register");
+               return;
+       }
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = RM_CATEGORY_VIDEO_DECODER_MPEG4_FHD_8BIT_60P;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       if (rm_allocate_resources(handle1, &request, &allocated) != RM_OK)
+               RM_TEST_MSG("failed to clear video decoders");
+
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = RM_CATEGORY_VIDEO_DECODER_H264_UHD_8BIT_60P;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       if (rm_allocate_resources(handle1, &request, &allocated) != RM_OK)
+               RM_TEST_MSG("failed to clear video decoders");
+
+       if (rm_unregister(handle1) != RM_OK)
+               RM_TEST_MSG("failed to unregister");
+
+       RM_TEST_MSG("clear_video_decoders done...");
+}
+
+void rm_tc_template_exceptional_test_case(int vdec1, int vdec2)
+{
+       //consumer#1
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));
+
+       //alloc
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request->category_option[0] = vdec1 | RM_DEVICE_OPT_MAIN;
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+
+       //consumer#2
+       int handle2 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle2, NULL));
+
+       //alloc
+       rm_category_request_s *request2 = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request2, 0, sizeof(rm_category_request_s));
+
+       request2->request_num = 1;
+       request2->category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request2->category_option[0] = vdec2;
+       request2->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated2 = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated2, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request2, allocated2));
+
+       //unregister
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+}
+
+bool is_support_4k(void)
+{
+#ifdef RM_TC_SUPPORT_4K
+       return true;
+#else
+       return false;
+#endif //RM_TC_SUPPORT_4K
+}
+
+bool is_support_8k(void)
+{
+#ifdef RM_TC_SUPPORT_8K
+       return true;
+#else
+       return false;
+#endif //RM_TC_SUPPORT_8K
+}
+
+bool is_support_av1_120p(void)
+{
+#ifdef RM_TC_SUPPORT_AV1_120P
+       return true;
+#else
+       return false;
+#endif //RM_TC_SUPPORT_AV1_120P
+}
+
+bool use_unified_jpeg_decoder(void)
+{
+#ifdef RM_TC_USE_UNIFIED_JPEG_DEC
+       return true;
+#else
+       return false;
+#endif// RM_TC_USE_UNIFIED_JPEG_DEC
+}
+
+bool is_oscars_unified_jpeg_decoder(void)
+{
+#ifdef RM_TC_USE_UNIFIED_JPEG_DEC_OSCARS
+       return true;
+#else
+       return false;
+#endif
+}
+
+bool is_support_audio_dual_decoding(void)
+{
+#ifdef RM_TC_SUPPORT_AUDIO_DUAL_DECODING
+       return true;
+#else
+       return false;
+#endif //RM_TC_SUPPORT_AUDIO_DUAL_DECODING
+}
index d56023cbde5281401b40ca1d098d897a29dc0281..663916958521b693f8242e8af1280adb25bdf29c 100644 (file)
@@ -1,66 +1,66 @@
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef __UT_COMMON_H__\r
-#define __UT_COMMON_H__\r
-\r
-#include <dlog.h>\r
-#include <glib.h>\r
-#include <rm_api.h>\r
-\r
-#ifdef LOG_TAG\r
-#undef LOG_TAG\r
-#endif//LOG_TAG\r
-\r
-#define LOG_TAG "RSC_MGR_SERVER_TEST"\r
-#define RM_TEST_SLEEP_TIME 1\r
-#define RM_TEST_MSG(fmt, arg...) \\r
-       do { SLOGE(fmt, ##arg); } while (0)\r
-\r
-#define RM_TC_FREE(a) \\r
-               if (a) \\r
-               { \\r
-                       free(a); \\r
-                       a = NULL; \\r
-               }\r
-\r
-bool is_8k_model(void);\r
-bool read_rm_index(const char *filename, int *data);\r
-bool is_support_4k(void);\r
-bool is_support_8k(void);\r
-bool is_support_av1_120p(void);\r
-bool use_unified_jpeg_decoder(void);\r
-bool is_support_audio_dual_decoding(void);\r
-bool is_oscars_unified_jpeg_decoder(void);\r
-\r
-GMainContext *get_callback_thread_context(void);\r
-\r
-rm_cb_result rm_cb_counting_conflicted(int handle, rm_callback_type event, rm_device_request_s *info, void *data);\r
-rm_cb_result rm_cb_counting_conflicted_cmp(int handle, rm_callback_type event, rm_device_request_s *info, void *data);\r
-rm_cb_result rm_cb_set_conflict_flag(int handle, rm_callback_type event, rm_device_request_s *info, void *data);\r
-rm_cb_result rm_cb_for_conditional_check(int handle, rm_callback_type event, rm_device_request_s *info, void *data);\r
-\r
-void rm_tc_template_exceptional_test_case(int vdec1, int vdec2);\r
-\r
-int rm_tc_get_conflict_num(void);\r
-void rm_tc_reset_conflict_num(void);\r
-int rm_tc_get_conflict_num_cmp(void);\r
-void rm_tc_reset_conflict_num_cmp(void);\r
-int rm_tc_get_conflicted_resources_num(void);\r
-void rm_tc_reset_conflicted_resources_num(void);\r
-void rm_tc_clear_audio_decoders(void);\r
-void rm_tc_clear_video_decoders(void);\r
-#endif //__UT_COMMON_H__\r
+/*
+ * Copyright (c) 2024 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 __UT_COMMON_H__
+#define __UT_COMMON_H__
+
+#include <dlog.h>
+#include <glib.h>
+#include <rm_api.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif//LOG_TAG
+
+#define LOG_TAG "RSC_MGR_SERVER_TEST"
+#define RM_TEST_SLEEP_TIME 1
+#define RM_TEST_MSG(fmt, arg...) \
+       do { SLOGE(fmt, ##arg); } while (0)
+
+#define RM_TC_FREE(a) \
+               if (a) \
+               { \
+                       free(a); \
+                       a = NULL; \
+               }
+
+bool is_8k_model(void);
+bool read_rm_index(const char *filename, int *data);
+bool is_support_4k(void);
+bool is_support_8k(void);
+bool is_support_av1_120p(void);
+bool use_unified_jpeg_decoder(void);
+bool is_support_audio_dual_decoding(void);
+bool is_oscars_unified_jpeg_decoder(void);
+
+GMainContext *get_callback_thread_context(void);
+
+rm_cb_result rm_cb_counting_conflicted(int handle, rm_callback_type event, rm_device_request_s *info, void *data);
+rm_cb_result rm_cb_counting_conflicted_cmp(int handle, rm_callback_type event, rm_device_request_s *info, void *data);
+rm_cb_result rm_cb_set_conflict_flag(int handle, rm_callback_type event, rm_device_request_s *info, void *data);
+rm_cb_result rm_cb_for_conditional_check(int handle, rm_callback_type event, rm_device_request_s *info, void *data);
+
+void rm_tc_template_exceptional_test_case(int vdec1, int vdec2);
+
+int rm_tc_get_conflict_num(void);
+void rm_tc_reset_conflict_num(void);
+int rm_tc_get_conflict_num_cmp(void);
+void rm_tc_reset_conflict_num_cmp(void);
+int rm_tc_get_conflicted_resources_num(void);
+void rm_tc_reset_conflicted_resources_num(void);
+void rm_tc_clear_audio_decoders(void);
+void rm_tc_clear_video_decoders(void);
+#endif //__UT_COMMON_H__
index 9d8d6e3914a4c67de4c195df985dd2fbf973c8fa..a41a7389163a34ea8430747d83160108328e2e85 100644 (file)
@@ -1,93 +1,93 @@
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "gtest/gtest.h"\r
-#include <unistd.h>\r
-\r
-#include <rm_api.h>\r
-#include <stdlib.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include <rm_debug.h>\r
-#include <dlog.h>\r
-#include <sys/stat.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-\r
-#include <ut_common.h>\r
-\r
-/*\r
- * The test cases for 8K model.\r
- *  1. 8K model specific features\r
- */\r
-\r
-TEST(ut_rm_api, dependency_between_8k_jpeg_decoder_and_bg_scaler)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_JPEG_DECODER_8K -> Alloc : No conflict\r
-       * 2. Allocate a RI_CATEGORY_SCALER_BG -> Alloc : (No conflict in 8K not supported model, conflict in 8k model)\r
-       */\r
-\r
-       RM_TEST_MSG("dependency_between_8k_jpeg_decoder_and_bg_scaler start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-\r
-       // Allocate a RI_CATEGORY_JPEG_DECODER_8K\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_JPEG_DECODER;\r
-       request.category_option[0] = ri_get_sub_jpeg_category_id("JPEG", 7680, 4320);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, &request, &allocated));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_CATEGORY_SCALER_BG\r
-       int handle2 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));\r
-\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-       memset(&allocated, 0, sizeof(sizeof(rm_device_return_s)));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_SCALER_BG;\r
-       request.category_option[0] = 0;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       int expected_result = RM_OK; // bg scaler exists in 8k model only\r
-       int expected_conflict = 1; // bg scaler should be conflicted with 8k jpeg decoder\r
-\r
-       EXPECT_EQ(expected_result, rm_allocate_resources(handle2, &request, &allocated));\r
-       EXPECT_EQ(expected_conflict, rm_tc_get_conflict_num());\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("dependency_between_8k_jpeg_decoder_and_bg_scaler end...");\r
-}\r
+/*
+ * Copyright (c) 2024 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 "gtest/gtest.h"
+#include <unistd.h>
+
+#include <rm_api.h>
+#include <stdlib.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include <rm_debug.h>
+#include <dlog.h>
+#include <sys/stat.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <ut_common.h>
+
+/*
+ * The test cases for 8K model.
+ *  1. 8K model specific features
+ */
+
+TEST(ut_rm_api, dependency_between_8k_jpeg_decoder_and_bg_scaler)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_JPEG_DECODER_8K -> Alloc : No conflict
+       * 2. Allocate a RI_CATEGORY_SCALER_BG -> Alloc : (No conflict in 8K not supported model, conflict in 8k model)
+       */
+
+       RM_TEST_MSG("dependency_between_8k_jpeg_decoder_and_bg_scaler start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+
+       // Allocate a RI_CATEGORY_JPEG_DECODER_8K
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_JPEG_DECODER;
+       request.category_option[0] = ri_get_sub_jpeg_category_id("JPEG", 7680, 4320);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, &request, &allocated));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_CATEGORY_SCALER_BG
+       int handle2 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));
+
+       memset(&request, 0, sizeof(rm_category_request_s));
+       memset(&allocated, 0, sizeof(sizeof(rm_device_return_s)));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_SCALER_BG;
+       request.category_option[0] = 0;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       int expected_result = RM_OK; // bg scaler exists in 8k model only
+       int expected_conflict = 1; // bg scaler should be conflicted with 8k jpeg decoder
+
+       EXPECT_EQ(expected_result, rm_allocate_resources(handle2, &request, &allocated));
+       EXPECT_EQ(expected_conflict, rm_tc_get_conflict_num());
+
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("dependency_between_8k_jpeg_decoder_and_bg_scaler end...");
+}
index 760d39598c55f6a0b9423f58757d697dca248ac8..546fbdebfed1fff345807e595ca14ee61f507841 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "gtest/gtest.h"\r
-#include <unistd.h>\r
-\r
-#include <rm_api.h>\r
-#include <stdlib.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include <rm_debug.h>\r
-#include <dlog.h>\r
-#include <sys/stat.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-\r
-#include <ut_common.h>\r
-\r
-TEST(ut_rm_api, allocate_audio_decoder_mpeg_InteractionSound)\r
-{\r
-       rm_tc_clear_audio_decoders();\r
-\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG (appid : user1)-> Alloc : No conflict\r
-       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG (appid : user1)-> Alloc : No conflict\r
-       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG (appid : user1)-> Alloc : Conflict with handle#1\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_mpeg_InteractionSound start...");\r
-\r
-       const char *app_id = "user1";\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)app_id));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG\r
-       int handle2 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle2, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle2, (char*)app_id));\r
-\r
-       //alloc\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG\r
-\r
-       int handle3 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle3, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle3, (char*)app_id));\r
-\r
-       //alloc\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));\r
-       EXPECT_EQ(1, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle3));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_mpeg_InteractionSound end...");\r
-}\r
-\r
-TEST(ut_rm_api, allocate_audio_decoder_mpeg_with_differnt_type_of_resources_InteractionSound)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG (appid : user1)-> Alloc : No conflict\r
-       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG (appid : user1)-> Alloc : No conflict\r
-       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG (appid : user1)-> Alloc : Conflict with handle#1\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_mpeg_with_differnt_type_of_resources_InteractionSound start...");\r
-\r
-       const char *app_id = "user1";\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)app_id));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG\r
-       int handle2 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle2, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle2, (char*)app_id));\r
-\r
-       //alloc\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG\r
-\r
-       int handle3 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle3, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle3, (char*)app_id));\r
-\r
-       //alloc\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));\r
-\r
-       EXPECT_EQ(1, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle3));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_mpeg_with_differnt_type_of_resources_InteractionSound end...");\r
-}\r
-\r
-\r
-TEST(ut_rm_api, allocate_audio_decoder_ac3_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_AC3 (appid : user1) -> Alloc : No conflict\r
-       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_AC3 (appid : user1) -> Alloc : No conflict\r
-       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER_AC3 (appid : user1) -> Alloc : Conflict with handle#1\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_ac3_interactionSound start...");\r
-\r
-       const char *app_id = "user1";\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_AC3\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)app_id));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_AC3;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_AC3\r
-       int handle2 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle2, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle2, (char*)app_id));\r
-\r
-       //alloc\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_AC3;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_AC3\r
-\r
-       int handle3 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle3, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle3, (char*)app_id));\r
-\r
-       //alloc\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_AC3;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));\r
-\r
-       EXPECT_EQ(1, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle3));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_ac3_interactionSound end...");\r
-}\r
-\r
-TEST(ut_rm_api, allocate_audio_decoder_ac4_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_AC4 (appid : user1) -> Alloc : No conflict\r
-       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_AC4 (appid : user1) -> Alloc : No conflict\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_ac4_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_AC4\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_AC4;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       int handle2 = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle2, NULL));\r
-\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_AC4;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_ac4_interactionSound end...");\r
-}\r
-\r
-TEST(ut_rm_api, allocate_audio_decoder_trueHD_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_TRUEHD (appid : user1) -> Alloc : No conflict\r
-       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_TRUEHD (appid : user1) -> Alloc : No conflict\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_trueHD_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_TRUEHD\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_TRUEHD;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       int handle2 = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle2, NULL));\r
-\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_TRUEHD;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_trueHD_interactionSound end...");\r
-}\r
-\r
-TEST(ut_rm_api, allocate_audio_decoder_PCM_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_PCM -> Alloc : Alloc (Mixing mode is supported)\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_PCM_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_PCM\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_PCM;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_audio_decodallocate_audio_decoder_PCM_interactionSounder_PCM end...");\r
-}\r
-\r
-\r
-TEST(ut_rm_api, allocate_audio_decoder_G2Cook_trueHD_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK -> Alloc : No conflict\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_G2Cook_trueHD_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_G2Cook_trueHD_interactionSound end...");\r
-}\r
-\r
-TEST(ut_rm_api, allocate_audio_decoder_G2Cook_trueHD2_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK -> Alloc (appid : user1) : No conflict\r
-       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK -> Alloc (appid : user1) : No conflict\r
-       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER_TRUEHD -> Alloc (appid : user2) : Alloc conflict with consumer#1\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_G2Cook_trueHD2_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-       const char *app_id1 = "user1";\r
-       const char *app_id2 = "user2";\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)app_id1));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK\r
-       int handle2 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle2, (char*) app_id1));\r
-\r
-       //alloc\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_TRUEHD\r
-\r
-       int handle3 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle3, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle3, (char*)app_id2));\r
-\r
-       //alloc\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_TRUEHD;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));\r
-       EXPECT_EQ(1, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle3));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_G2Cook_trueHD2_interactionSound end...");\r
-}\r
-\r
-TEST(ut_rm_api, allocate_audio_decoder_G2Cook_MPEG_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK -> Alloc (appid : user1) : No conflict\r
-       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK -> Alloc (appid : user1) : No conflict\r
-       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG -> Alloc (appid : user2) :  Alloc conflict with consumer#1\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_G2Cook_MPEG_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-       const char *app_id1 = "user1";\r
-       const char *app_id2 = "user2";\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)app_id1));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK\r
-       int handle2 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle2, (char*) app_id1));\r
-\r
-       //alloc\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_AUDIO_CODEC_NAME_MPEG\r
-\r
-       int handle3 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle3, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle3, (char*)app_id2));\r
-\r
-       //alloc\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));\r
-\r
-       EXPECT_EQ(1, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle3));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_G2Cook_MPEG_interactionSound end...");\r
-}\r
-\r
-TEST(ut_rm_api, allocate_audio_decoder_MPEG_MPEG_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG -> Alloc (appid : user1) : No conflict\r
-       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG -> Alloc (appid : user2) : No conflict\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_MPEG_MPEG_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-       const char *app_id1 = "user1";\r
-       const char *app_id2 = "user2";\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)app_id1));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_AUDIO_CODEC_NAME_MPEG\r
-\r
-       int handle3 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle3, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle3, (char*)app_id2));\r
-\r
-       //alloc\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle3));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_MPEG_MPEG_interactionSound end...");\r
-}\r
-\r
-\r
-TEST(ut_rm_api, allocate_multi_audio_decoders_by_same_consumer1_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#1 -> Alloc : No conflict\r
-       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_ADPCM with consumer id#1 -> Alloc : No conflict\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_multi_audio_decoders_by_same_consumer1_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-       const char *user_id = "user1";\r
-\r
-       // Allocate two RI_CATEGORY_AUDIO_DECODER_G2COOK\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)user_id));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_ADPCM\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_ADPCM;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_multi_audio_decoders_by_same_consumer1_interactionSound end...");\r
-}\r
-\r
-TEST(ut_rm_api, allocate_multi_audio_decoders_by_same_consumer2_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#1 -> Alloc : No conflict\r
-       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#1 -> Alloc : No conflict\r
-       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#1 -> Alloc : Fail\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_multi_audio_decoders_by_same_consumer2_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-       const char *user_id = "user1";\r
-\r
-       // Allocate two RI_CATEGORY_AUDIO_DECODER_G2COOK\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)user_id));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 2;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       request->category_id[1] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[1] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[1] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK\r
-       //alloc\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_NE(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_multi_audio_decoders_by_same_consumer2_interactionSound end...");\r
-}\r
-\r
-TEST(ut_rm_api, allocate_reclaim_resource_had_been_allocated_first_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#1 -> Alloc : No conflict -> main audio decoder\r
-       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#2 -> Alloc : No conflict -> sub audio decoder\r
-       * 3. Release main audio decoder -> released\r
-       * 4. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#3 -> Alloc : No conflict -> main audio decoder\r
-       * 5. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#4 -> Alloc : conflict with handle#2 -> sub audio decoder\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_reclaim_resource_had_been_allocated_first_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-       const char *user_id = "user1";\r
-\r
-       // Allocate two RI_CATEGORY_AUDIO_DECODER_G2COOK\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)user_id));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, allocated->device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK\r
-\r
-       int handle2 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));\r
-\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, allocated->device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       // release main audio decoder\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-\r
-       int handle3 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle3, NULL));\r
-\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, allocated->device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       int handle4 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle4, NULL));\r
-\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle4, request, allocated));\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, allocated->device_id[0]);\r
-       EXPECT_EQ(1, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle3));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle4));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_reclaim_resource_had_been_allocated_first_interactionSound end...");\r
-}\r
-\r
-\r
-TEST(ut_rm_api, allocate_multi_audio_decoders_by_same_consumer_at_once_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate RI_CATEGORY_AUDIO_DECODER_G2COOK and RI_CATEGORY_AUDIO_DECODER_TRUEHD with consumer id#1 at once -> Alloc\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_multi_audio_decoders_by_same_consumer_at_once_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-       const char *user_id = "user1";\r
-\r
-       // Allocate RI_CATEGORY_AUDIO_DECODER_G2COOK and RI_CATEGORY_AUDIO_DECODER_TRUEHD at once.\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle1,(char*) user_id));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 2;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_TRUEHD;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->category_id[1] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[1] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[1] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_multi_audio_decoders_by_same_consumer_at_once_interactionSound end...");\r
-}\r
-\r
-TEST(ut_rm_api, allocate_mixing_not_supported_codec_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate RI_CATEGORY_AUDIO_DECODER_MPEG_H -> Alloc (Mixing is not supported but allocate)\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_mixing_not_supported_codec_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-       const char *user_id = "user1";\r
-\r
-       // Allocate RI_CATEGORY_AUDIO_DECODER_MPEG_H\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle1,(char*) user_id));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG_H;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_mixing_not_supported_codec_interactionSound end...");\r
-}\r
-\r
-TEST(ut_rm_api, allocate_mixing_not_supported_codec2_interactionSound)\r
-{\r
-       /*\r
-       * 1. Allocate RI_CATEGORY_AUDIO_DECODER_G2COOK -> Alloc\r
-       * 2. Allocate RI_CATEGORY_AUDIO_DECODER_MPEG_H -> Alloc conflict with handle#1 (Mixing is not supported)\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_mixing_not_supported_codec2_interactionSound start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-       rm_tc_reset_conflicted_resources_num();\r
-       const char *user_id = "user1";\r
-\r
-       int handle1 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle1,(char*) user_id));\r
-\r
-       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       int handle2 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle2, (char*) user_id));\r
-\r
-       memset((void*)request, 0, sizeof(rm_category_request_s));\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG_H;\r
-       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;\r
-\r
-       request->request_num = 1;\r
-       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request->category_option[0] = ri_get_capable_audio_category_id(&opt);\r
-       request->state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset((void*)allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));\r
-       EXPECT_EQ(1, rm_tc_get_conflict_num());\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_mixing_not_supported_codec2_interactionSound end...");\r
-}
\ No newline at end of file
+/*
+ * Copyright (c) 2024 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 "gtest/gtest.h"
+#include <unistd.h>
+
+#include <rm_api.h>
+#include <stdlib.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include <rm_debug.h>
+#include <dlog.h>
+#include <sys/stat.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <ut_common.h>
+
+TEST(ut_rm_api, allocate_audio_decoder_mpeg_InteractionSound)
+{
+       rm_tc_clear_audio_decoders();
+
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG (appid : user1)-> Alloc : No conflict
+       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG (appid : user1)-> Alloc : No conflict
+       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG (appid : user1)-> Alloc : Conflict with handle#1
+       */
+
+       RM_TEST_MSG("allocate_audio_decoder_mpeg_InteractionSound start...");
+
+       const char *app_id = "user1";
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)app_id));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG
+       int handle2 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle2, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle2, (char*)app_id));
+
+       //alloc
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG
+
+       int handle3 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle3, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle3, (char*)app_id));
+
+       //alloc
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));
+       EXPECT_EQ(1, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+       EXPECT_EQ(RM_OK, rm_unregister(handle3));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_audio_decoder_mpeg_InteractionSound end...");
+}
+
+TEST(ut_rm_api, allocate_audio_decoder_mpeg_with_differnt_type_of_resources_InteractionSound)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG (appid : user1)-> Alloc : No conflict
+       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG (appid : user1)-> Alloc : No conflict
+       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG (appid : user1)-> Alloc : Conflict with handle#1
+       */
+
+       RM_TEST_MSG("allocate_audio_decoder_mpeg_with_differnt_type_of_resources_InteractionSound start...");
+
+       const char *app_id = "user1";
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)app_id));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG
+       int handle2 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle2, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle2, (char*)app_id));
+
+       //alloc
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG
+
+       int handle3 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle3, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle3, (char*)app_id));
+
+       //alloc
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));
+
+       EXPECT_EQ(1, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+       EXPECT_EQ(RM_OK, rm_unregister(handle3));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_audio_decoder_mpeg_with_differnt_type_of_resources_InteractionSound end...");
+}
+
+
+TEST(ut_rm_api, allocate_audio_decoder_ac3_interactionSound)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_AC3 (appid : user1) -> Alloc : No conflict
+       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_AC3 (appid : user1) -> Alloc : No conflict
+       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER_AC3 (appid : user1) -> Alloc : Conflict with handle#1
+       */
+
+       RM_TEST_MSG("allocate_audio_decoder_ac3_interactionSound start...");
+
+       const char *app_id = "user1";
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_AC3
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)app_id));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_AC3;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_AC3
+       int handle2 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle2, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle2, (char*)app_id));
+
+       //alloc
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_AC3;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_AC3
+
+       int handle3 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle3, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle3, (char*)app_id));
+
+       //alloc
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_AC3;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));
+
+       EXPECT_EQ(1, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+       EXPECT_EQ(RM_OK, rm_unregister(handle3));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_audio_decoder_ac3_interactionSound end...");
+}
+
+TEST(ut_rm_api, allocate_audio_decoder_ac4_interactionSound)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_AC4 (appid : user1) -> Alloc : No conflict
+       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_AC4 (appid : user1) -> Alloc : No conflict
+       */
+
+       RM_TEST_MSG("allocate_audio_decoder_ac4_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_AC4
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_AC4;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       int handle2 = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle2, NULL));
+
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_AC4;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_audio_decoder_ac4_interactionSound end...");
+}
+
+TEST(ut_rm_api, allocate_audio_decoder_trueHD_interactionSound)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_TRUEHD (appid : user1) -> Alloc : No conflict
+       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_TRUEHD (appid : user1) -> Alloc : No conflict
+       */
+
+       RM_TEST_MSG("allocate_audio_decoder_trueHD_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_TRUEHD
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_TRUEHD;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       int handle2 = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle2, NULL));
+
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_TRUEHD;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_audio_decoder_trueHD_interactionSound end...");
+}
+
+TEST(ut_rm_api, allocate_audio_decoder_PCM_interactionSound)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_PCM -> Alloc : Alloc (Mixing mode is supported)
+       */
+
+       RM_TEST_MSG("allocate_audio_decoder_PCM_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_PCM
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_PCM;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_audio_decodallocate_audio_decoder_PCM_interactionSounder_PCM end...");
+}
+
+
+TEST(ut_rm_api, allocate_audio_decoder_G2Cook_trueHD_interactionSound)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK -> Alloc : No conflict
+       */
+
+       RM_TEST_MSG("allocate_audio_decoder_G2Cook_trueHD_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle1, NULL));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_audio_decoder_G2Cook_trueHD_interactionSound end...");
+}
+
+TEST(ut_rm_api, allocate_audio_decoder_G2Cook_trueHD2_interactionSound)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK -> Alloc (appid : user1) : No conflict
+       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK -> Alloc (appid : user1) : No conflict
+       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER_TRUEHD -> Alloc (appid : user2) : Alloc conflict with consumer#1
+       */
+
+       RM_TEST_MSG("allocate_audio_decoder_G2Cook_trueHD2_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+       const char *app_id1 = "user1";
+       const char *app_id2 = "user2";
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)app_id1));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK
+       int handle2 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle2, (char*) app_id1));
+
+       //alloc
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_TRUEHD
+
+       int handle3 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle3, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle3, (char*)app_id2));
+
+       //alloc
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_TRUEHD;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));
+       EXPECT_EQ(1, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+       EXPECT_EQ(RM_OK, rm_unregister(handle3));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_audio_decoder_G2Cook_trueHD2_interactionSound end...");
+}
+
+TEST(ut_rm_api, allocate_audio_decoder_G2Cook_MPEG_interactionSound)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK -> Alloc (appid : user1) : No conflict
+       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK -> Alloc (appid : user1) : No conflict
+       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG -> Alloc (appid : user2) :  Alloc conflict with consumer#1
+       */
+
+       RM_TEST_MSG("allocate_audio_decoder_G2Cook_MPEG_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+       const char *app_id1 = "user1";
+       const char *app_id2 = "user2";
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)app_id1));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK
+       int handle2 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle2, (char*) app_id1));
+
+       //alloc
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_AUDIO_CODEC_NAME_MPEG
+
+       int handle3 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle3, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle3, (char*)app_id2));
+
+       //alloc
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));
+
+       EXPECT_EQ(1, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+       EXPECT_EQ(RM_OK, rm_unregister(handle3));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_audio_decoder_G2Cook_MPEG_interactionSound end...");
+}
+
+TEST(ut_rm_api, allocate_audio_decoder_MPEG_MPEG_interactionSound)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG -> Alloc (appid : user1) : No conflict
+       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG -> Alloc (appid : user2) : No conflict
+       */
+
+       RM_TEST_MSG("allocate_audio_decoder_MPEG_MPEG_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+       const char *app_id1 = "user1";
+       const char *app_id2 = "user2";
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_MPEG
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)app_id1));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_AUDIO_CODEC_NAME_MPEG
+
+       int handle3 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_set_conflict_flag, NULL, &handle3, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle3, (char*)app_id2));
+
+       //alloc
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle3));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_audio_decoder_MPEG_MPEG_interactionSound end...");
+}
+
+
+TEST(ut_rm_api, allocate_multi_audio_decoders_by_same_consumer1_interactionSound)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#1 -> Alloc : No conflict
+       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_ADPCM with consumer id#1 -> Alloc : No conflict
+       */
+
+       RM_TEST_MSG("allocate_multi_audio_decoders_by_same_consumer1_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+       const char *user_id = "user1";
+
+       // Allocate two RI_CATEGORY_AUDIO_DECODER_G2COOK
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)user_id));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_ADPCM
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_ADPCM;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_multi_audio_decoders_by_same_consumer1_interactionSound end...");
+}
+
+TEST(ut_rm_api, allocate_multi_audio_decoders_by_same_consumer2_interactionSound)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#1 -> Alloc : No conflict
+       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#1 -> Alloc : No conflict
+       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#1 -> Alloc : Fail
+       */
+
+       RM_TEST_MSG("allocate_multi_audio_decoders_by_same_consumer2_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+       const char *user_id = "user1";
+
+       // Allocate two RI_CATEGORY_AUDIO_DECODER_G2COOK
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)user_id));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 2;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       request->category_id[1] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[1] = ri_get_capable_audio_category_id(&opt);
+       request->state[1] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK
+       //alloc
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_NE(RM_OK, rm_allocate_resources(handle1, request, allocated));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_multi_audio_decoders_by_same_consumer2_interactionSound end...");
+}
+
+TEST(ut_rm_api, allocate_reclaim_resource_had_been_allocated_first_interactionSound)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#1 -> Alloc : No conflict -> main audio decoder
+       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#2 -> Alloc : No conflict -> sub audio decoder
+       * 3. Release main audio decoder -> released
+       * 4. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#3 -> Alloc : No conflict -> main audio decoder
+       * 5. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with consumer id#4 -> Alloc : conflict with handle#2 -> sub audio decoder
+       */
+
+       RM_TEST_MSG("allocate_reclaim_resource_had_been_allocated_first_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+       const char *user_id = "user1";
+
+       // Allocate two RI_CATEGORY_AUDIO_DECODER_G2COOK
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle1, (char*)user_id));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, allocated->device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK
+
+       int handle2 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));
+
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, allocated->device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       // release main audio decoder
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+
+       int handle3 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle3, NULL));
+
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, request, allocated));
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, allocated->device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       int handle4 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle4, NULL));
+
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle4, request, allocated));
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, allocated->device_id[0]);
+       EXPECT_EQ(1, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+       EXPECT_EQ(RM_OK, rm_unregister(handle3));
+       EXPECT_EQ(RM_OK, rm_unregister(handle4));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_reclaim_resource_had_been_allocated_first_interactionSound end...");
+}
+
+
+TEST(ut_rm_api, allocate_multi_audio_decoders_by_same_consumer_at_once_interactionSound)
+{
+       /*
+       * 1. Allocate RI_CATEGORY_AUDIO_DECODER_G2COOK and RI_CATEGORY_AUDIO_DECODER_TRUEHD with consumer id#1 at once -> Alloc
+       */
+
+       RM_TEST_MSG("allocate_multi_audio_decoders_by_same_consumer_at_once_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+       const char *user_id = "user1";
+
+       // Allocate RI_CATEGORY_AUDIO_DECODER_G2COOK and RI_CATEGORY_AUDIO_DECODER_TRUEHD at once.
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle1,(char*) user_id));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 2;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_TRUEHD;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->category_id[1] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[1] = ri_get_capable_audio_category_id(&opt);
+       request->state[1] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_multi_audio_decoders_by_same_consumer_at_once_interactionSound end...");
+}
+
+TEST(ut_rm_api, allocate_mixing_not_supported_codec_interactionSound)
+{
+       /*
+       * 1. Allocate RI_CATEGORY_AUDIO_DECODER_MPEG_H -> Alloc (Mixing is not supported but allocate)
+       */
+
+       RM_TEST_MSG("allocate_mixing_not_supported_codec_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+       const char *user_id = "user1";
+
+       // Allocate RI_CATEGORY_AUDIO_DECODER_MPEG_H
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle1,(char*) user_id));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG_H;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_mixing_not_supported_codec_interactionSound end...");
+}
+
+TEST(ut_rm_api, allocate_mixing_not_supported_codec2_interactionSound)
+{
+       /*
+       * 1. Allocate RI_CATEGORY_AUDIO_DECODER_G2COOK -> Alloc
+       * 2. Allocate RI_CATEGORY_AUDIO_DECODER_MPEG_H -> Alloc conflict with handle#1 (Mixing is not supported)
+       */
+
+       RM_TEST_MSG("allocate_mixing_not_supported_codec2_interactionSound start...");
+
+       rm_tc_reset_conflict_num();
+       rm_tc_reset_conflicted_resources_num();
+       const char *user_id = "user1";
+
+       int handle1 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle1,(char*) user_id));
+
+       rm_category_request_s *request = (rm_category_request_s*) malloc (sizeof(rm_category_request_s));
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, request, allocated));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       int handle2 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle2, (char*) user_id));
+
+       memset((void*)request, 0, sizeof(rm_category_request_s));
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_MPEG_H;
+       opt.mixing_mode = RI_MIXING_MODE_INTERACTION_SOUND;
+
+       request->request_num = 1;
+       request->category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request->category_option[0] = ri_get_capable_audio_category_id(&opt);
+       request->state[0] = RM_STATE_EXCLUSIVE;
+
+       memset((void*)allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, request, allocated));
+       EXPECT_EQ(1, rm_tc_get_conflict_num());
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_mixing_not_supported_codec2_interactionSound end...");
+}
index 740ece15f6b98aa36461674bffd51a12cb8095c4..76b7059b2ae30c69802897fbd1b90e89d057382e 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "gtest/gtest.h"\r
-#include <unistd.h>\r
-\r
-#include <rm_api.h>\r
-#include <rm_module_api.h>\r
-#include <stdlib.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include <rm_debug.h>\r
-#include <dlog.h>\r
-#include <sys/stat.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-\r
-#include <ut_common.h>\r
-#include <TCPlayer.h>\r
-\r
-\r
-TEST(ut_rm_api, alloc_main_audio_dec_p1_multiview)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with main option -> Alloc : No conflict\r
-       */\r
-\r
-       RM_TEST_MSG("alloc_main_audio_dec_p1_multiview start...");\r
-\r
-       int handle = 0;\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_MULTIVIEW;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request.category_option[0] = ri_get_capable_audio_category_id(&opt) | RM_DEVICE_OPT_MAIN;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, allocated.device_id[0]);\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_main_audio_dec_p1_multiview end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_sub_audio_dec_p1_multiview)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with sub option -> Alloc : No conflict\r
-       */\r
-\r
-       RM_TEST_MSG("alloc_sub_audio_dec_p1_multiview start...");\r
-\r
-       int handle = 0;\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_audio_category_option_request_s opt;\r
-       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;\r
-       opt.mixing_mode = RI_MIXING_MODE_MULTIVIEW;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER_SUB;\r
-       request.category_option[0] = ri_get_capable_audio_category_id(&opt) | RM_DEVICE_OPT_SUB;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, allocated.device_id[0]);\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_sub_audio_dec_p1_multiview end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_three_video_decoders_in_multiview_p1)\r
-{\r
-       rm_tc_clear_video_decoders();\r
-\r
-       RM_TEST_MSG("alloc_three_video_decoders_in_multiview_p1 start...");\r
-\r
-       int handle1 = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "H264";\r
-       option.color_depth = 8;\r
-       option.framerate = 30;\r
-       option.h_size = 1920;\r
-       option.v_size = 1080;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 2;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = 0;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       request.category_id[1] = RM_CATEGORY_SCALER;\r
-       request.state[1] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, &request, &allocated));\r
-       EXPECT_EQ(2, allocated.allocated_num);\r
-       // The mfc0 shall be allocated first\r
-       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_MAIN, allocated.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       rm_device_request_s req_rel;\r
-       memset(&req_rel, 0, sizeof(rm_device_request_s));\r
-\r
-       req_rel.request_num = 1;\r
-       req_rel.device_id[0] = allocated.device_id[1];\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle1, &req_rel));\r
-\r
-       int handle2 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));\r
-\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       request.request_num = 2;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_capable_video_category_id(&option);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       request.category_id[1] = RM_CATEGORY_SCALER_SUB;\r
-       request.state[1] = RM_STATE_EXCLUSIVE;\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &request, &allocated));\r
-       EXPECT_EQ(2, allocated.allocated_num);\r
-\r
-       // The mfc1 shall be allocated later\r
-       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_SUB, allocated.device_id[0]);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated.device_id[1]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated.device_id[1]));\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       int handle3 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle3, NULL));\r
-\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       request.request_num = 2;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER_SUB;\r
-       request.category_option[0] = (ri_get_capable_video_category_id(&option) | RM_DEVICE_OPT_SUB);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       request.category_id[1] = RM_CATEGORY_SCALER_SUB;\r
-       request.state[1] = RM_STATE_EXCLUSIVE;\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, &request, &allocated));\r
-       EXPECT_EQ(2, allocated.allocated_num);\r
-\r
-       // The mfc0 shall be allocated\r
-       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_SUB, allocated.device_id[0]);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated.device_id[1]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated.device_id[1]));\r
-       EXPECT_EQ(1, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle3));\r
-\r
-       RM_TEST_MSG("alloc_three_video_decoders_in_multiview_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, multiview_audio_decoder_conflict_p2)\r
-{\r
-       RM_TEST_MSG("multiview_audio_decoder_conflict_p2 start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       int handle1;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request.category_option[0] = (RI_CATEGORY_AUDIO_DECODER_AAC | RM_DEVICE_OPT_MAIN);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, &request, &allocated));\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, allocated.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       sleep(2);\r
-\r
-       rm_tc_reset_conflict_num();\r
-       int handle2;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));\r
-\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER_SUB;\r
-       request.category_option[0] = 0;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &request, &allocated));\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, allocated.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       int handle3;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle3, NULL));\r
-\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER_SUB;\r
-       request.category_option[0] = 0;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, &request, &allocated));\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, allocated.device_id[0]);\r
-       EXPECT_EQ(1, rm_tc_get_conflict_num());\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle3));\r
-\r
-       RM_TEST_MSG("multiview_audio_decoder_conflict_p2 end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_audio_sub_out_p)\r
-{\r
-       /*\r
-       * 1. Allocate the following resource with handle#1\r
-       *    RM_CATEGORY_AUDIO_SUB_OUT with RM_STATE_EXCLUSIVE -> Alloc\r
-       */\r
-\r
-       RM_TEST_MSG("alloc_audio_sub_out_p start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       int handle = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       rm_device_return_s allocated_devices;\r
-       memset(&allocated_devices, 0, sizeof(rm_device_return_s));\r
-\r
-       request.request_num = 1;\r
-\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_SUB_OUT;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated_devices));\r
-\r
-       EXPECT_EQ(1, allocated_devices.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, allocated_devices.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("alloc_audio_sub_out_p end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_audio_sub_out_conflict_1)\r
-{\r
-       /*\r
-       * 1. Allocate the following resource with handle#1\r
-       *    RM_CATEGORY_AUDIO_SUB_OUT with RM_STATE_EXCLUSIVE -> Alloc\r
-       * 2. Allocate the following resource with handle#2\r
-       *    RM_CATEGORY_AUDIO_MAIN_OUT with RM_STATE_EXCLUSIVE -> Alloc : No conflict\r
-       */\r
-\r
-       RM_TEST_MSG("alloc_audio_sub_out_conflict_1 start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       int handle = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       rm_device_return_s allocated_devices;\r
-       memset(&allocated_devices, 0, sizeof(rm_device_return_s));\r
-\r
-       request.request_num = 1;\r
-\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_SUB_OUT;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated_devices));\r
-\r
-       EXPECT_EQ(1, allocated_devices.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, allocated_devices.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       int handle2 = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));\r
-\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-       memset(&allocated_devices, 0, sizeof(rm_device_return_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_MAIN_OUT;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &request, &allocated_devices));\r
-\r
-       EXPECT_EQ(1, allocated_devices.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_MAIN_OUT, allocated_devices.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("alloc_audio_sub_out_conflict_1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_audio_sub_out_conflict_2)\r
-{\r
-       /*\r
-       * 1. Allocate the following resource with handle#1\r
-       *    RM_CATEGORY_AUDIO_SUB_OUT with RM_STATE_EXCLUSIVE -> Alloc\r
-       * 2. Allocate the following resource with handle#2\r
-       *    RM_CATEGORY_AUDIO_MAIN_OUT with RM_STATE_EXCLUSIVE -> Alloc : No conflict\r
-       */\r
-\r
-       RM_TEST_MSG("alloc_audio_sub_out_conflict_2 start...");\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       int handle = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       rm_device_return_s allocated_devices;\r
-       memset(&allocated_devices, 0, sizeof(rm_device_return_s));\r
-\r
-       request.request_num = 1;\r
-\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_SUB_OUT;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated_devices));\r
-\r
-       EXPECT_EQ(1, allocated_devices.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, allocated_devices.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       int handle2 = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));\r
-\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-       memset(&allocated_devices, 0, sizeof(rm_device_return_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_MAIN_OUT;\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &request, &allocated_devices));\r
-\r
-       EXPECT_EQ(1, allocated_devices.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_MAIN_OUT, allocated_devices.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("alloc_audio_sub_out_conflict_2 end...");\r
-}\r
-\r
-\r
-TEST(ut_rm_api, multiview_scaler_to_main_p1)\r
-{\r
-       RM_TEST_MSG("multiview_scaler_to_main_p1 start...");\r
-\r
-       int handle = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_SCALER;\r
-       request.category_option[0] = (RM_CATEGORY_SCALER | RM_FORCE_TO_MAIN);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated.device_id[0]));\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("multiview_scaler_to_main_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, multiview_scaler_to_main_p2)\r
-{\r
-       RM_TEST_MSG("multiview_scaler_to_main_p2 start...");\r
-\r
-       int handle = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_SCALER_SUB;\r
-       request.category_option[0] = (RM_CATEGORY_SCALER_SUB | RM_FORCE_TO_MAIN);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated.device_id[0]));\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("multiview_scaler_to_main_p2 end...");\r
-}\r
-\r
-TEST(ut_rm_api, multiview_scaler_to_sub_p1)\r
-{\r
-       RM_TEST_MSG("multiview_scaler_to_sub_p1 start...");\r
-\r
-       int handle = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_SCALER;\r
-       request.category_option[0] = (RM_CATEGORY_SCALER | RM_FORCE_TO_SUB);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated.device_id[0]));\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("multiview_scaler_to_sub_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, multiview_audio_out_to_main_p1)\r
-{\r
-       RM_TEST_MSG("multiview_audio_out_to_main_p1 start...");\r
-\r
-       int handle = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_MAIN_OUT;\r
-       request.category_option[0] = (RM_CATEGORY_AUDIO_MAIN_OUT | RM_FORCE_TO_MAIN);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_MAIN_OUT, allocated.device_id[0]);\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("multiview_audio_out_to_main_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, multiview_audio_out_to_main_p2)\r
-{\r
-       RM_TEST_MSG("multiview_audio_out_to_main_p2 start...");\r
-\r
-       int handle = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_MAIN_OUT;\r
-       request.category_option[0] = (RM_CATEGORY_AUDIO_MAIN_OUT | RM_FORCE_TO_SUB);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, allocated.device_id[0]);\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("multiview_audio_out_to_main_p2 end...");\r
-}\r
-\r
-TEST(ut_rm_api, multiview_audio_decoder_main_p1)\r
-{\r
-       RM_TEST_MSG("multiview_audio_decoder_main_p1 start...");\r
-\r
-       int handle = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request.category_option[0] = (RM_CATEGORY_AUDIO_DECODER | RM_DEVICE_OPT_MAIN | RM_FORCE_TO_MAIN);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, allocated.device_id[0]);\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("multiview_audio_decoder_main_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, multiview_audio_decoder_main_p2)\r
-{\r
-       RM_TEST_MSG("multiview_audio_decoder_main_p2 start...");\r
-\r
-       int handle = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER;\r
-       request.category_option[0] = (RM_CATEGORY_AUDIO_DECODER | RM_DEVICE_OPT_SUB | RM_FORCE_TO_SUB);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, allocated.device_id[0]);\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("multiview_audio_decoder_main_p2 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_active_audio_out_p1)\r
-{\r
-       RM_TEST_MSG("rm_active_audio_out_p1 start...");\r
-\r
-       TCPlayer *player = new TCPlayer();\r
-       EXPECT_EQ(RM_OK, player->Register());\r
-\r
-       EXPECT_EQ(RM_AUDIO_OUT_NONE, player->GetActiveAudioOut());\r
-\r
-       // Allocate audio main out\r
-       player->AddResource(RM_CATEGORY_AUDIO_MAIN_OUT, RM_STATE_EXCLUSIVE);\r
-       EXPECT_EQ(RM_OK, player->AllocateResources());\r
-       EXPECT_EQ(RM_AUDIO_OUT_MAIN, player->GetActiveAudioOut());\r
-\r
-       // Allocate audio sub out\r
-       player->RemoveResources();\r
-       player->AddResource(RM_CATEGORY_AUDIO_SUB_OUT, RM_STATE_EXCLUSIVE);\r
-       EXPECT_EQ(RM_OK, player->AllocateResources());\r
-       EXPECT_EQ((RM_AUDIO_OUT_MAIN | RM_AUDIO_OUT_SUB), player->GetActiveAudioOut());\r
-\r
-       // Release audio main & sub out\r
-       player->RemoveResources();\r
-       EXPECT_EQ(RM_OK, player->ReleaseResources());\r
-       EXPECT_EQ(RM_AUDIO_OUT_NONE, player->GetActiveAudioOut());\r
-\r
-       // Allocate audio sub out\r
-       player->AddResource(RM_CATEGORY_AUDIO_SUB_OUT, RM_STATE_EXCLUSIVE);\r
-       EXPECT_EQ(RM_OK, player->AllocateResources());\r
-       EXPECT_EQ(RM_AUDIO_OUT_SUB, player->GetActiveAudioOut());\r
-\r
-       EXPECT_EQ(RM_OK, player->Unregister());\r
-       delete player;\r
-\r
-       RM_TEST_MSG("rm_active_audio_out_p1 end...");\r
-}\r
+/*
+ * Copyright (c) 2024 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 "gtest/gtest.h"
+#include <unistd.h>
+
+#include <rm_api.h>
+#include <rm_module_api.h>
+#include <stdlib.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include <rm_debug.h>
+#include <dlog.h>
+#include <sys/stat.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <ut_common.h>
+#include <TCPlayer.h>
+
+
+TEST(ut_rm_api, alloc_main_audio_dec_p1_multiview)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with main option -> Alloc : No conflict
+       */
+
+       RM_TEST_MSG("alloc_main_audio_dec_p1_multiview start...");
+
+       int handle = 0;
+
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_MULTIVIEW;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request.category_option[0] = ri_get_capable_audio_category_id(&opt) | RM_DEVICE_OPT_MAIN;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, allocated.device_id[0]);
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       rm_tc_reset_conflict_num();
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_main_audio_dec_p1_multiview end...");
+}
+
+TEST(ut_rm_api, alloc_sub_audio_dec_p1_multiview)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER_G2COOK with sub option -> Alloc : No conflict
+       */
+
+       RM_TEST_MSG("alloc_sub_audio_dec_p1_multiview start...");
+
+       int handle = 0;
+
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_audio_category_option_request_s opt;
+       memset(&opt, 0, sizeof(ri_audio_category_option_request_s));
+
+       opt.codec_name = RI_AUDIO_CODEC_NAME_G2COOK;
+       opt.mixing_mode = RI_MIXING_MODE_MULTIVIEW;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER_SUB;
+       request.category_option[0] = ri_get_capable_audio_category_id(&opt) | RM_DEVICE_OPT_SUB;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, allocated.device_id[0]);
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       rm_tc_reset_conflict_num();
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_sub_audio_dec_p1_multiview end...");
+}
+
+TEST(ut_rm_api, alloc_three_video_decoders_in_multiview_p1)
+{
+       rm_tc_clear_video_decoders();
+
+       RM_TEST_MSG("alloc_three_video_decoders_in_multiview_p1 start...");
+
+       int handle1 = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "H264";
+       option.color_depth = 8;
+       option.framerate = 30;
+       option.h_size = 1920;
+       option.v_size = 1080;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 2;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = 0;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       request.category_id[1] = RM_CATEGORY_SCALER;
+       request.state[1] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, &request, &allocated));
+       EXPECT_EQ(2, allocated.allocated_num);
+       // The mfc0 shall be allocated first
+       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_MAIN, allocated.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       rm_device_request_s req_rel;
+       memset(&req_rel, 0, sizeof(rm_device_request_s));
+
+       req_rel.request_num = 1;
+       req_rel.device_id[0] = allocated.device_id[1];
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle1, &req_rel));
+
+       int handle2 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));
+
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       request.request_num = 2;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_capable_video_category_id(&option);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       request.category_id[1] = RM_CATEGORY_SCALER_SUB;
+       request.state[1] = RM_STATE_EXCLUSIVE;
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &request, &allocated));
+       EXPECT_EQ(2, allocated.allocated_num);
+
+       // The mfc1 shall be allocated later
+       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_SUB, allocated.device_id[0]);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated.device_id[1]);
+       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated.device_id[1]));
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       int handle3 = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle3, NULL));
+
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       request.request_num = 2;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER_SUB;
+       request.category_option[0] = (ri_get_capable_video_category_id(&option) | RM_DEVICE_OPT_SUB);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       request.category_id[1] = RM_CATEGORY_SCALER_SUB;
+       request.state[1] = RM_STATE_EXCLUSIVE;
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, &request, &allocated));
+       EXPECT_EQ(2, allocated.allocated_num);
+
+       // The mfc0 shall be allocated
+       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_SUB, allocated.device_id[0]);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated.device_id[1]);
+       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated.device_id[1]));
+       EXPECT_EQ(1, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+       EXPECT_EQ(RM_OK, rm_unregister(handle3));
+
+       RM_TEST_MSG("alloc_three_video_decoders_in_multiview_p1 end...");
+}
+
+TEST(ut_rm_api, multiview_audio_decoder_conflict_p2)
+{
+       RM_TEST_MSG("multiview_audio_decoder_conflict_p2 start...");
+
+       rm_tc_reset_conflict_num();
+
+       int handle1;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle1, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request.category_option[0] = (RI_CATEGORY_AUDIO_DECODER_AAC | RM_DEVICE_OPT_MAIN);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, &request, &allocated));
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, allocated.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       sleep(2);
+
+       rm_tc_reset_conflict_num();
+       int handle2;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));
+
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER_SUB;
+       request.category_option[0] = 0;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &request, &allocated));
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, allocated.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       rm_tc_reset_conflict_num();
+
+       int handle3;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle3, NULL));
+
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER_SUB;
+       request.category_option[0] = 0;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, &request, &allocated));
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, allocated.device_id[0]);
+       EXPECT_EQ(1, rm_tc_get_conflict_num());
+
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+       EXPECT_EQ(RM_OK, rm_unregister(handle3));
+
+       RM_TEST_MSG("multiview_audio_decoder_conflict_p2 end...");
+}
+
+TEST(ut_rm_api, alloc_audio_sub_out_p)
+{
+       /*
+       * 1. Allocate the following resource with handle#1
+       *    RM_CATEGORY_AUDIO_SUB_OUT with RM_STATE_EXCLUSIVE -> Alloc
+       */
+
+       RM_TEST_MSG("alloc_audio_sub_out_p start...");
+
+       rm_tc_reset_conflict_num();
+
+       int handle = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       rm_device_return_s allocated_devices;
+       memset(&allocated_devices, 0, sizeof(rm_device_return_s));
+
+       request.request_num = 1;
+
+       request.category_id[0] = RM_CATEGORY_AUDIO_SUB_OUT;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated_devices));
+
+       EXPECT_EQ(1, allocated_devices.allocated_num);
+       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, allocated_devices.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("alloc_audio_sub_out_p end...");
+}
+
+TEST(ut_rm_api, alloc_audio_sub_out_conflict_1)
+{
+       /*
+       * 1. Allocate the following resource with handle#1
+       *    RM_CATEGORY_AUDIO_SUB_OUT with RM_STATE_EXCLUSIVE -> Alloc
+       * 2. Allocate the following resource with handle#2
+       *    RM_CATEGORY_AUDIO_MAIN_OUT with RM_STATE_EXCLUSIVE -> Alloc : No conflict
+       */
+
+       RM_TEST_MSG("alloc_audio_sub_out_conflict_1 start...");
+
+       rm_tc_reset_conflict_num();
+
+       int handle = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       rm_device_return_s allocated_devices;
+       memset(&allocated_devices, 0, sizeof(rm_device_return_s));
+
+       request.request_num = 1;
+
+       request.category_id[0] = RM_CATEGORY_AUDIO_SUB_OUT;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated_devices));
+
+       EXPECT_EQ(1, allocated_devices.allocated_num);
+       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, allocated_devices.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       int handle2 = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));
+
+       memset(&request, 0, sizeof(rm_category_request_s));
+       memset(&allocated_devices, 0, sizeof(rm_device_return_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_AUDIO_MAIN_OUT;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &request, &allocated_devices));
+
+       EXPECT_EQ(1, allocated_devices.allocated_num);
+       EXPECT_EQ(RM_DEVICE_AUDIO_MAIN_OUT, allocated_devices.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("alloc_audio_sub_out_conflict_1 end...");
+}
+
+TEST(ut_rm_api, alloc_audio_sub_out_conflict_2)
+{
+       /*
+       * 1. Allocate the following resource with handle#1
+       *    RM_CATEGORY_AUDIO_SUB_OUT with RM_STATE_EXCLUSIVE -> Alloc
+       * 2. Allocate the following resource with handle#2
+       *    RM_CATEGORY_AUDIO_MAIN_OUT with RM_STATE_EXCLUSIVE -> Alloc : No conflict
+       */
+
+       RM_TEST_MSG("alloc_audio_sub_out_conflict_2 start...");
+
+       rm_tc_reset_conflict_num();
+
+       int handle = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       rm_device_return_s allocated_devices;
+       memset(&allocated_devices, 0, sizeof(rm_device_return_s));
+
+       request.request_num = 1;
+
+       request.category_id[0] = RM_CATEGORY_AUDIO_SUB_OUT;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated_devices));
+
+       EXPECT_EQ(1, allocated_devices.allocated_num);
+       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, allocated_devices.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       int handle2 = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle2, NULL));
+
+       memset(&request, 0, sizeof(rm_category_request_s));
+       memset(&allocated_devices, 0, sizeof(rm_device_return_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_AUDIO_MAIN_OUT;
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &request, &allocated_devices));
+
+       EXPECT_EQ(1, allocated_devices.allocated_num);
+       EXPECT_EQ(RM_DEVICE_AUDIO_MAIN_OUT, allocated_devices.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("alloc_audio_sub_out_conflict_2 end...");
+}
+
+
+TEST(ut_rm_api, multiview_scaler_to_main_p1)
+{
+       RM_TEST_MSG("multiview_scaler_to_main_p1 start...");
+
+       int handle = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_SCALER;
+       request.category_option[0] = (RM_CATEGORY_SCALER | RM_FORCE_TO_MAIN);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated.device_id[0]));
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("multiview_scaler_to_main_p1 end...");
+}
+
+TEST(ut_rm_api, multiview_scaler_to_main_p2)
+{
+       RM_TEST_MSG("multiview_scaler_to_main_p2 start...");
+
+       int handle = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_SCALER_SUB;
+       request.category_option[0] = (RM_CATEGORY_SCALER_SUB | RM_FORCE_TO_MAIN);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated.device_id[0]));
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("multiview_scaler_to_main_p2 end...");
+}
+
+TEST(ut_rm_api, multiview_scaler_to_sub_p1)
+{
+       RM_TEST_MSG("multiview_scaler_to_sub_p1 start...");
+
+       int handle = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_SCALER;
+       request.category_option[0] = (RM_CATEGORY_SCALER | RM_FORCE_TO_SUB);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated.device_id[0]));
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("multiview_scaler_to_sub_p1 end...");
+}
+
+TEST(ut_rm_api, multiview_audio_out_to_main_p1)
+{
+       RM_TEST_MSG("multiview_audio_out_to_main_p1 start...");
+
+       int handle = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_AUDIO_MAIN_OUT;
+       request.category_option[0] = (RM_CATEGORY_AUDIO_MAIN_OUT | RM_FORCE_TO_MAIN);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RM_DEVICE_AUDIO_MAIN_OUT, allocated.device_id[0]);
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("multiview_audio_out_to_main_p1 end...");
+}
+
+TEST(ut_rm_api, multiview_audio_out_to_main_p2)
+{
+       RM_TEST_MSG("multiview_audio_out_to_main_p2 start...");
+
+       int handle = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_AUDIO_MAIN_OUT;
+       request.category_option[0] = (RM_CATEGORY_AUDIO_MAIN_OUT | RM_FORCE_TO_SUB);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, allocated.device_id[0]);
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("multiview_audio_out_to_main_p2 end...");
+}
+
+TEST(ut_rm_api, multiview_audio_decoder_main_p1)
+{
+       RM_TEST_MSG("multiview_audio_decoder_main_p1 start...");
+
+       int handle = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request.category_option[0] = (RM_CATEGORY_AUDIO_DECODER | RM_DEVICE_OPT_MAIN | RM_FORCE_TO_MAIN);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, allocated.device_id[0]);
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("multiview_audio_decoder_main_p1 end...");
+}
+
+TEST(ut_rm_api, multiview_audio_decoder_main_p2)
+{
+       RM_TEST_MSG("multiview_audio_decoder_main_p2 start...");
+
+       int handle = 0;
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_AUDIO_DECODER;
+       request.category_option[0] = (RM_CATEGORY_AUDIO_DECODER | RM_DEVICE_OPT_SUB | RM_FORCE_TO_SUB);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, allocated.device_id[0]);
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("multiview_audio_decoder_main_p2 end...");
+}
+
+TEST(ut_rm_api, rm_active_audio_out_p1)
+{
+       RM_TEST_MSG("rm_active_audio_out_p1 start...");
+
+       TCPlayer *player = new TCPlayer();
+       EXPECT_EQ(RM_OK, player->Register());
+
+       EXPECT_EQ(RM_AUDIO_OUT_NONE, player->GetActiveAudioOut());
+
+       // Allocate audio main out
+       player->AddResource(RM_CATEGORY_AUDIO_MAIN_OUT, RM_STATE_EXCLUSIVE);
+       EXPECT_EQ(RM_OK, player->AllocateResources());
+       EXPECT_EQ(RM_AUDIO_OUT_MAIN, player->GetActiveAudioOut());
+
+       // Allocate audio sub out
+       player->RemoveResources();
+       player->AddResource(RM_CATEGORY_AUDIO_SUB_OUT, RM_STATE_EXCLUSIVE);
+       EXPECT_EQ(RM_OK, player->AllocateResources());
+       EXPECT_EQ((RM_AUDIO_OUT_MAIN | RM_AUDIO_OUT_SUB), player->GetActiveAudioOut());
+
+       // Release audio main & sub out
+       player->RemoveResources();
+       EXPECT_EQ(RM_OK, player->ReleaseResources());
+       EXPECT_EQ(RM_AUDIO_OUT_NONE, player->GetActiveAudioOut());
+
+       // Allocate audio sub out
+       player->AddResource(RM_CATEGORY_AUDIO_SUB_OUT, RM_STATE_EXCLUSIVE);
+       EXPECT_EQ(RM_OK, player->AllocateResources());
+       EXPECT_EQ(RM_AUDIO_OUT_SUB, player->GetActiveAudioOut());
+
+       EXPECT_EQ(RM_OK, player->Unregister());
+       delete player;
+
+       RM_TEST_MSG("rm_active_audio_out_p1 end...");
+}
index 2d47a140f7db32ea9b3fb33611093b14fa17f26d..36ab5c78e870bdc8375f71a547ecaac930670311 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "gtest/gtest.h"\r
-#include <unistd.h>\r
-\r
-#include <rm_api.h>\r
-#include <stdlib.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include <rm_debug.h>\r
-#include <dlog.h>\r
-#include <sys/stat.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-\r
-#include <ut_common.h>\r
-#include <TCPlayer.h>\r
-\r
-TEST(ut_rm_api, alloc_audio_dec_in_mixing_not_supported_model_p1)\r
-{\r
-       /*\r
-       * 1. Allocate an Audio decoder with MultiView mixing mode in mixing not supported model (app_id : app1) -> Alloc : No conflict : Main audio decoder\r
-       * 2. Allocate an Audio decoder with MultiView mixing mode in mixing not supported model (app_id : app2) -> Alloc : conflict with player1: Main audio decoder\r
-       * 3. Allocate a sub Audio decoder with MultiView mixing mode in mixing not supported model (app_id : app3) -> Alloc : No conflict : Sub audio decoder\r
-       * 4. Allocate a sub Audio decoder with MultiView mixing mode in mixing not supported model (app_id : app4) -> Alloc : conflict with player3 : Sub audio decoder\r
-       */\r
-\r
-       RM_TEST_MSG("alloc_audio_dec_in_mixing_not_supported_model_p1 start...");\r
-\r
-       ri_audio_category_option_request_s audio_option;\r
-       memset(&audio_option, 0, sizeof(ri_audio_category_option_request_s));\r
-\r
-       // player1\r
-       audio_option.codec_name = RI_AUDIO_CODEC_NAME_MPEG;\r
-       audio_option.mixing_mode = RI_MIXING_MODE_MULTIVIEW;\r
-\r
-       TCPlayer *player = new TCPlayer();\r
-       player->AddResource(RM_CATEGORY_AUDIO_DECODER, (ri_get_capable_audio_category_id(&audio_option) | RM_DEVICE_OPT_MAIN), RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player->Register());\r
-       EXPECT_EQ(RM_OK, player->AllocateResources());\r
-\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, player->GetAllocatedResourceId(1));\r
-\r
-       // player2\r
-       TCPlayer *player2 = new TCPlayer();\r
-       player2->AddResource(RM_CATEGORY_AUDIO_DECODER, ri_get_capable_audio_category_id(&audio_option), RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player2->Register());\r
-       EXPECT_EQ(RM_OK, player2->AllocateResources());\r
-\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, player2->GetAllocatedResourceId(1));\r
-       EXPECT_EQ(1, player->GetConflictNum());\r
-\r
-       // player3\r
-       TCPlayer *player3 = new TCPlayer();\r
-       player3->AddResource(RM_CATEGORY_AUDIO_DECODER_SUB, (ri_get_capable_audio_category_id(&audio_option) | RM_DEVICE_OPT_SUB), RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player3->Register());\r
-       EXPECT_EQ(RM_OK, player3->AllocateResources());\r
-\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, player3->GetAllocatedResourceId(1));\r
-       EXPECT_EQ(1, player->GetConflictNum());\r
-       EXPECT_EQ(0, player2->GetConflictNum());\r
-\r
-       // player4\r
-       TCPlayer *player4 = new TCPlayer();\r
-       player4->AddResource(RM_CATEGORY_AUDIO_DECODER_SUB, ri_get_capable_audio_category_id(&audio_option), RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player4->Register());\r
-       EXPECT_EQ(RM_OK, player4->AllocateResources());\r
-\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, player4->GetAllocatedResourceId(1));\r
-       EXPECT_EQ(1, player->GetConflictNum());\r
-       EXPECT_EQ(0, player2->GetConflictNum());\r
-       EXPECT_EQ(1, player3->GetConflictNum());\r
-\r
-       EXPECT_EQ(RM_OK, player->Unregister());\r
-       EXPECT_EQ(RM_OK, player2->Unregister());\r
-       EXPECT_EQ(RM_OK, player3->Unregister());\r
-       EXPECT_EQ(RM_OK, player4->Unregister());\r
-\r
-       delete player;\r
-       delete player2;\r
-       delete player3;\r
-       delete player4;\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("alloc_audio_dec_in_mixing_not_supported_model_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, allocate_audio_decoder_with_legacy_one_not_support_multiview)\r
-{\r
-       /*\r
-       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER -> Alloc : No conflict  -> audio main decoder\r
-       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_WMA -> Alloc : conflict with Consumer#1  -> audio main decoder\r
-       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER -> Alloc : conflict with Consumer#2 -> audio main decoder\r
-       */\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_with_legacy_one_not_support_multiview start...");\r
-\r
-       TCPlayer *player = new TCPlayer();\r
-       player->AddResource(RM_CATEGORY_AUDIO_DECODER, RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player->Register());\r
-       EXPECT_EQ(RM_OK, player->SetAppId("user1"));\r
-       EXPECT_EQ(RM_OK, player->AllocateResources());\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, player->GetAllocatedResourceId(1));\r
-\r
-       // As a resource of GetAudioCategory(), RI_CATEGORY_NONE shall be returned because audio mixing is not supported\r
-       TCPlayer *player2 = new TCPlayer();\r
-       player2->AddResource(RM_CATEGORY_AUDIO_DECODER, player2->GetAudioCategory(RI_AUDIO_CODEC_NAME_WMA, 0), RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player2->Register());\r
-       EXPECT_EQ(RM_OK, player2->SetAppId("user2"));\r
-       EXPECT_EQ(RM_OK, player2->AllocateResources());\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, player2->GetAllocatedResourceId(1));\r
-\r
-       EXPECT_EQ(1, player->GetConflictNum());\r
-\r
-       TCPlayer *player3 = new TCPlayer();\r
-       player3->AddResource(RM_CATEGORY_AUDIO_DECODER, RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player3->Register());\r
-       EXPECT_EQ(RM_OK, player3->SetAppId("user3"));\r
-       EXPECT_EQ(RM_OK, player3->AllocateResources());\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, player3->GetAllocatedResourceId(1));\r
-\r
-       EXPECT_EQ(1, player->GetConflictNum());\r
-       EXPECT_EQ(1, player2->GetConflictNum());\r
-\r
-       EXPECT_EQ(RM_OK, player->Unregister());\r
-       EXPECT_EQ(RM_OK, player2->Unregister());\r
-       EXPECT_EQ(RM_OK, player3->Unregister());\r
-\r
-       delete player;\r
-       delete player2;\r
-       delete player3;\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-\r
-       RM_TEST_MSG("allocate_audio_decoder_with_legacy_one_not_support_multiview end...");\r
-}\r
+/*
+ * Copyright (c) 2024 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 "gtest/gtest.h"
+#include <unistd.h>
+
+#include <rm_api.h>
+#include <stdlib.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include <rm_debug.h>
+#include <dlog.h>
+#include <sys/stat.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <ut_common.h>
+#include <TCPlayer.h>
+
+TEST(ut_rm_api, alloc_audio_dec_in_mixing_not_supported_model_p1)
+{
+       /*
+       * 1. Allocate an Audio decoder with MultiView mixing mode in mixing not supported model (app_id : app1) -> Alloc : No conflict : Main audio decoder
+       * 2. Allocate an Audio decoder with MultiView mixing mode in mixing not supported model (app_id : app2) -> Alloc : conflict with player1: Main audio decoder
+       * 3. Allocate a sub Audio decoder with MultiView mixing mode in mixing not supported model (app_id : app3) -> Alloc : No conflict : Sub audio decoder
+       * 4. Allocate a sub Audio decoder with MultiView mixing mode in mixing not supported model (app_id : app4) -> Alloc : conflict with player3 : Sub audio decoder
+       */
+
+       RM_TEST_MSG("alloc_audio_dec_in_mixing_not_supported_model_p1 start...");
+
+       ri_audio_category_option_request_s audio_option;
+       memset(&audio_option, 0, sizeof(ri_audio_category_option_request_s));
+
+       // player1
+       audio_option.codec_name = RI_AUDIO_CODEC_NAME_MPEG;
+       audio_option.mixing_mode = RI_MIXING_MODE_MULTIVIEW;
+
+       TCPlayer *player = new TCPlayer();
+       player->AddResource(RM_CATEGORY_AUDIO_DECODER, (ri_get_capable_audio_category_id(&audio_option) | RM_DEVICE_OPT_MAIN), RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player->Register());
+       EXPECT_EQ(RM_OK, player->AllocateResources());
+
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, player->GetAllocatedResourceId(1));
+
+       // player2
+       TCPlayer *player2 = new TCPlayer();
+       player2->AddResource(RM_CATEGORY_AUDIO_DECODER, ri_get_capable_audio_category_id(&audio_option), RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player2->Register());
+       EXPECT_EQ(RM_OK, player2->AllocateResources());
+
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, player2->GetAllocatedResourceId(1));
+       EXPECT_EQ(1, player->GetConflictNum());
+
+       // player3
+       TCPlayer *player3 = new TCPlayer();
+       player3->AddResource(RM_CATEGORY_AUDIO_DECODER_SUB, (ri_get_capable_audio_category_id(&audio_option) | RM_DEVICE_OPT_SUB), RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player3->Register());
+       EXPECT_EQ(RM_OK, player3->AllocateResources());
+
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, player3->GetAllocatedResourceId(1));
+       EXPECT_EQ(1, player->GetConflictNum());
+       EXPECT_EQ(0, player2->GetConflictNum());
+
+       // player4
+       TCPlayer *player4 = new TCPlayer();
+       player4->AddResource(RM_CATEGORY_AUDIO_DECODER_SUB, ri_get_capable_audio_category_id(&audio_option), RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player4->Register());
+       EXPECT_EQ(RM_OK, player4->AllocateResources());
+
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER_SUB, player4->GetAllocatedResourceId(1));
+       EXPECT_EQ(1, player->GetConflictNum());
+       EXPECT_EQ(0, player2->GetConflictNum());
+       EXPECT_EQ(1, player3->GetConflictNum());
+
+       EXPECT_EQ(RM_OK, player->Unregister());
+       EXPECT_EQ(RM_OK, player2->Unregister());
+       EXPECT_EQ(RM_OK, player3->Unregister());
+       EXPECT_EQ(RM_OK, player4->Unregister());
+
+       delete player;
+       delete player2;
+       delete player3;
+       delete player4;
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("alloc_audio_dec_in_mixing_not_supported_model_p1 end...");
+}
+
+TEST(ut_rm_api, allocate_audio_decoder_with_legacy_one_not_support_multiview)
+{
+       /*
+       * 1. Allocate a RI_CATEGORY_AUDIO_DECODER -> Alloc : No conflict  -> audio main decoder
+       * 2. Allocate a RI_CATEGORY_AUDIO_DECODER_WMA -> Alloc : conflict with Consumer#1  -> audio main decoder
+       * 3. Allocate a RI_CATEGORY_AUDIO_DECODER -> Alloc : conflict with Consumer#2 -> audio main decoder
+       */
+
+       RM_TEST_MSG("allocate_audio_decoder_with_legacy_one_not_support_multiview start...");
+
+       TCPlayer *player = new TCPlayer();
+       player->AddResource(RM_CATEGORY_AUDIO_DECODER, RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player->Register());
+       EXPECT_EQ(RM_OK, player->SetAppId("user1"));
+       EXPECT_EQ(RM_OK, player->AllocateResources());
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, player->GetAllocatedResourceId(1));
+
+       // As a resource of GetAudioCategory(), RI_CATEGORY_NONE shall be returned because audio mixing is not supported
+       TCPlayer *player2 = new TCPlayer();
+       player2->AddResource(RM_CATEGORY_AUDIO_DECODER, player2->GetAudioCategory(RI_AUDIO_CODEC_NAME_WMA, 0), RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player2->Register());
+       EXPECT_EQ(RM_OK, player2->SetAppId("user2"));
+       EXPECT_EQ(RM_OK, player2->AllocateResources());
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, player2->GetAllocatedResourceId(1));
+
+       EXPECT_EQ(1, player->GetConflictNum());
+
+       TCPlayer *player3 = new TCPlayer();
+       player3->AddResource(RM_CATEGORY_AUDIO_DECODER, RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player3->Register());
+       EXPECT_EQ(RM_OK, player3->SetAppId("user3"));
+       EXPECT_EQ(RM_OK, player3->AllocateResources());
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, player3->GetAllocatedResourceId(1));
+
+       EXPECT_EQ(1, player->GetConflictNum());
+       EXPECT_EQ(1, player2->GetConflictNum());
+
+       EXPECT_EQ(RM_OK, player->Unregister());
+       EXPECT_EQ(RM_OK, player2->Unregister());
+       EXPECT_EQ(RM_OK, player3->Unregister());
+
+       delete player;
+       delete player2;
+       delete player3;
+
+       sleep(RM_TEST_SLEEP_TIME);
+
+       RM_TEST_MSG("allocate_audio_decoder_with_legacy_one_not_support_multiview end...");
+}
index f79eb6d44047e29ae2d42303e131603f2a1a6e40..f4f1c1c357b7dc801687bdecd0b63a37e411b85f 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "gtest/gtest.h"\r
-#include <unistd.h>\r
-\r
-#include <rm_api.h>\r
-#include <rm_module_api.h>\r
-#include <stdlib.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include <rm_debug.h>\r
-#include <dlog.h>\r
-#include <sys/stat.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-\r
-#include <ut_common.h>\r
-#include <TCPlayer.h>\r
-\r
-\r
-TEST(ut_rm_api, rm_rsc_state_p1)\r
-{\r
-       RM_TEST_MSG("rm_rsc_state_p1 start...");\r
-\r
-       rm_resource_state_e state;\r
-       int ret = rm_get_resource_state(RM_DEVICE_AUDIO_ENCODER, &state);\r
-\r
-       EXPECT_EQ(RM_OK, ret);\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, state);\r
-\r
-       RM_TEST_MSG("rm_rsc_state_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_rsc_state_n1)\r
-{\r
-       RM_TEST_MSG("rm_rsc_state_n1 start...");\r
-\r
-       rm_resource_state_e state;\r
-       int ret = rm_get_resource_state(9999999, &state);\r
-\r
-       EXPECT_NE(RM_OK, ret);\r
-\r
-       RM_TEST_MSG("rm_rsc_state_n1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_rsc_state_n2)\r
-{\r
-       RM_TEST_MSG("rm_rsc_state_n2 start...");\r
-\r
-       rm_resource_state_e state;\r
-       int ret = rm_get_resource_state(-1, &state);\r
-\r
-       EXPECT_NE(RM_OK, ret);\r
-\r
-       RM_TEST_MSG("rm_rsc_state_n2 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_rsc_state_n3)\r
-{\r
-       RM_TEST_MSG("rm_rsc_state_n2 start...");\r
-\r
-       int ret = rm_get_resource_state(RM_DEVICE_AUDIO_ENCODER, NULL);\r
-\r
-       EXPECT_NE(RM_OK, ret);\r
-\r
-       RM_TEST_MSG("rm_rsc_state_n3 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_rsc_get_resource_list_p1)\r
-{\r
-       RM_TEST_MSG("rm_rsc_get_resource_list_p1 start...");\r
-\r
-       rm_resource_list_h rsc_list;\r
-       int ret = rm_get_resource_list(RM_CATEGORY_DEMUX, &rsc_list);\r
-\r
-       EXPECT_EQ(RM_OK, ret);\r
-\r
-       rm_resource_h resource;\r
-       EXPECT_EQ(6, rm_resource_list_get_count(rsc_list));\r
-\r
-       resource = rm_resource_list_get_first(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_DEMUX0, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dvb/adapter0/demux0", rm_resource_get_node(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_DEMUX1, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dvb/adapter0/demux1", rm_resource_get_node(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_DEMUX2, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dvb/adapter0/demux2", rm_resource_get_node(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_DEMUX3, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dvb/adapter0/demux3", rm_resource_get_node(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_DEMUX4, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dvb/adapter0/demux4", rm_resource_get_node(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_DEMUX5, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dvb/adapter0/demux5", rm_resource_get_node(resource));\r
-\r
-       EXPECT_EQ(0, rm_resource_list_get_next(rsc_list));\r
-\r
-       resource = rm_resource_list_get_last(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_DEMUX5, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dvb/adapter0/demux5", rm_resource_get_node(resource));\r
-\r
-       resource = rm_resource_list_get_prev(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_DEMUX4, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dvb/adapter0/demux4", rm_resource_get_node(resource));\r
-\r
-       resource = rm_resource_list_get_prev(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_DEMUX3, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dvb/adapter0/demux3", rm_resource_get_node(resource));\r
-\r
-       resource = rm_resource_list_get_prev(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_DEMUX2, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dvb/adapter0/demux2", rm_resource_get_node(resource));\r
-\r
-       resource = rm_resource_list_get_prev(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_DEMUX1, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dvb/adapter0/demux1", rm_resource_get_node(resource));\r
-\r
-       resource = rm_resource_list_get_prev(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_DEMUX0, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dvb/adapter0/demux0", rm_resource_get_node(resource));\r
-\r
-       EXPECT_EQ(0, rm_resource_list_get_prev(rsc_list));\r
-\r
-       rm_free_resource_list(rsc_list);\r
-\r
-       RM_TEST_MSG("rm_rsc_get_resource_list_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_rsc_get_resource_list_p2)\r
-{\r
-       RM_TEST_MSG("rm_rsc_get_resource_list_p2 start...");\r
-\r
-       TCPlayer *player = new TCPlayer();\r
-       player->AddResource(RM_CATEGORY_SCALER, RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player->Register());\r
-       EXPECT_EQ(RM_OK, player->AllocateResources());\r
-\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, player->GetAllocatedResourceId(1));\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(player->GetAllocatedResourceId(1)));\r
-\r
-       rm_resource_list_h rsc_list;\r
-       int ret = rm_get_resource_list(RM_CATEGORY_SCALER, &rsc_list);\r
-\r
-       EXPECT_EQ(RM_OK, ret);\r
-\r
-       rm_resource_h resource;\r
-       EXPECT_EQ(1, rm_resource_list_get_count(rsc_list));\r
-       resource = rm_resource_list_get_first(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dri/card0", rm_resource_get_node(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, rm_resource_get_state(resource));\r
-\r
-       EXPECT_EQ(0, rm_resource_list_get_next(rsc_list));\r
-\r
-       resource = rm_resource_list_get_last(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dri/card0", rm_resource_get_node(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, rm_resource_get_state(resource));\r
-\r
-       EXPECT_EQ(0, rm_resource_list_get_prev(rsc_list));\r
-\r
-       rm_free_resource_list(rsc_list);\r
-\r
-       EXPECT_EQ(RM_OK, player->Unregister());\r
-       delete player;\r
-\r
-       ret = rm_get_resource_list(RM_CATEGORY_SCALER, &rsc_list);\r
-       EXPECT_EQ(RM_OK, ret);\r
-\r
-       EXPECT_EQ(1, rm_resource_list_get_count(rsc_list));\r
-       resource = rm_resource_list_get_first(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dri/card0", rm_resource_get_node(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));\r
-\r
-       EXPECT_EQ(0, rm_resource_list_get_next(rsc_list));\r
-\r
-       resource = rm_resource_list_get_last(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("/dev/dri/card0", rm_resource_get_node(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));\r
-\r
-       EXPECT_EQ(0, rm_resource_list_get_prev(rsc_list));\r
-\r
-       rm_free_resource_list(rsc_list);\r
-\r
-       RM_TEST_MSG("rm_rsc_get_resource_list_p2 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_rsc_get_resource_list_p3)\r
-{\r
-       if (!is_support_audio_dual_decoding())\r
-               return;\r
-\r
-       RM_TEST_MSG("rm_rsc_get_resource_list_p3 start...");\r
-\r
-       rm_resource_list_h rsc_list;\r
-       int ret = rm_get_resource_list(RM_CATEGORY_AUDIO_SUB_OUT, &rsc_list);\r
-\r
-       EXPECT_EQ(RM_OK, ret);\r
-\r
-       rm_resource_h resource;\r
-       EXPECT_EQ(1, rm_resource_list_get_count(rsc_list));\r
-       resource = rm_resource_list_get_first(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(resource));\r
-       EXPECT_EQ(0, rm_resource_list_get_next(rsc_list));\r
-\r
-       resource = rm_resource_list_get_last(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, rm_resource_get_id(resource));\r
-\r
-       EXPECT_EQ(0, rm_resource_list_get_prev(rsc_list));\r
-\r
-       rm_free_resource_list(rsc_list);\r
-\r
-       RM_TEST_MSG("rm_rsc_get_resource_list_p3 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_rsc_get_resource_list_p4)\r
-{\r
-       if (!is_support_audio_dual_decoding())\r
-               return;\r
-\r
-       RM_TEST_MSG("rm_rsc_get_resource_list_p4 start...");\r
-\r
-       TCPlayer *player = new TCPlayer();\r
-       player->AddResource(RM_CATEGORY_AUDIO_SUB_OUT, RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player->Register());\r
-       EXPECT_EQ(RM_OK, player->SetAppId("org.tizen.viewer"));\r
-       EXPECT_EQ(RM_OK, player->AllocateResources());\r
-\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, player->GetAllocatedResourceId(1));\r
-\r
-       rm_resource_list_h rsc_list;\r
-       int ret = rm_get_resource_list(RM_CATEGORY_AUDIO_SUB_OUT, &rsc_list);\r
-\r
-       EXPECT_EQ(RM_OK, ret);\r
-\r
-       rm_resource_h resource;\r
-       EXPECT_EQ(1, rm_resource_list_get_count(rsc_list));\r
-       resource = rm_resource_list_get_first(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, rm_resource_get_id(resource));\r
-       EXPECT_STREQ("org.tizen.viewer", rm_resource_get_app_id(resource));\r
-       EXPECT_EQ(0, rm_resource_list_get_next(rsc_list));\r
-\r
-       resource = rm_resource_list_get_last(rsc_list);\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, rm_resource_get_id(resource));\r
-\r
-       EXPECT_EQ(0, rm_resource_list_get_prev(rsc_list));\r
-\r
-       rm_free_resource_list(rsc_list);\r
-\r
-       EXPECT_EQ(RM_OK, player->Unregister());\r
-       delete player;\r
-\r
-       RM_TEST_MSG("rm_rsc_get_resource_list_p4 end...");\r
-}\r
-\r
-\r
-TEST(ut_rm_api, rm_rsc_get_resource_list_n1)\r
-{\r
-       RM_TEST_MSG("rm_rsc_get_resource_list_n1 start...");\r
-\r
-       rm_resource_list_h rsc_list;\r
-       int ret = rm_get_resource_list((rm_rsc_category_e) -10, &rsc_list);\r
-\r
-       EXPECT_EQ(RM_OK, ret);\r
-       rm_free_resource_list(rsc_list);\r
-\r
-       RM_TEST_MSG("rm_rsc_get_resource_list_n1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_rsc_get_resource_list_n2)\r
-{\r
-       RM_TEST_MSG("rm_rsc_get_resource_list_n2 start...");\r
-\r
-       int ret = rm_get_resource_list(RM_CATEGORY_DEMUX, NULL);\r
-\r
-       EXPECT_NE(RM_OK, ret);\r
-\r
-       RM_TEST_MSG("rm_rsc_get_resource_list_n2 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_resource_get_id_n1)\r
-{\r
-       RM_TEST_MSG("rm_resource_get_id_n1 start...");\r
-       EXPECT_EQ(-1, rm_resource_get_id(NULL));\r
-       RM_TEST_MSG("rm_resource_get_id_n1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_resource_get_node_n1)\r
-{\r
-       RM_TEST_MSG("rm_resource_get_node_n1 start...");\r
-       EXPECT_EQ(0, rm_resource_get_node(NULL));\r
-       RM_TEST_MSG("rm_resource_get_node_n1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_resource_list_get_prev_n1)\r
-{\r
-       RM_TEST_MSG("rm_resource_list_get_prev_n1 start...");\r
-       EXPECT_EQ(0, rm_resource_list_get_prev(NULL));\r
-       rm_resource_list_h list = NULL;\r
-       EXPECT_EQ(0, rm_resource_list_get_prev(list));\r
-       RM_TEST_MSG("rm_resource_list_get_prev_n1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_get_resource_collection_state_p1)\r
-{\r
-       RM_TEST_MSG("rm_get_resource_collection_state_p1 start...");\r
-\r
-       rm_resource_list_h rsc_list = NULL;\r
-\r
-       EXPECT_EQ(0, rm_get_resource_collection_state(RM_RSC_COLLECTION_MAIN, &rsc_list));\r
-\r
-       // MFD0, DVDE0, MAIN SCALER, MAIN AUDIO DECODER, MAIN AUDIO OUT\r
-       EXPECT_EQ(5, rm_resource_list_get_count(rsc_list));\r
-\r
-       rm_resource_h resource = rm_resource_list_get_first(rsc_list);\r
-\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_MAIN_OUT, rm_resource_get_id(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));\r
-       EXPECT_EQ(-1, rm_resource_get_consumer(resource));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(resource));\r
-       EXPECT_EQ(RM_CATEGORY_AUDIO_MAIN_OUT, rm_resource_get_category(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));\r
-       EXPECT_EQ(-1, rm_resource_get_consumer(resource));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(resource));\r
-       EXPECT_EQ(RM_CATEGORY_SCALER, rm_resource_get_category(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, rm_resource_get_id(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));\r
-       EXPECT_EQ(-1, rm_resource_get_consumer(resource));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(resource));\r
-       EXPECT_EQ(RM_CATEGORY_AUDIO_DECODER, rm_resource_get_category(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-\r
-       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_MAIN, rm_resource_get_id(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));\r
-       EXPECT_EQ(-1, rm_resource_get_consumer(resource));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(resource));\r
-       EXPECT_LE(RM_CATEGORY_VIDEO_DECODER, rm_resource_get_category(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-\r
-       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_DVDE0, rm_resource_get_id(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));\r
-       EXPECT_EQ(-1, rm_resource_get_consumer(resource));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(resource));\r
-       EXPECT_LE(RM_CATEGORY_VIDEO_DECODER_UHD, rm_resource_get_category(resource));\r
-\r
-       rm_free_resource_list(rsc_list);\r
-\r
-       RM_TEST_MSG("rm_get_resource_collection_state_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_get_resource_collection_state_p2)\r
-{\r
-       RM_TEST_MSG("rm_get_resource_collection_state_p2 start...");\r
-\r
-       int handle = 0;\r
-       const char *app_id = "org.tizen.test";\r
-       EXPECT_EQ(0, rm_register(rm_cb_set_conflict_flag, NULL, &handle, NULL));\r
-       EXPECT_EQ(0, rm_set_app_id(handle, (char*) app_id));\r
-\r
-       rm_category_request_s req;\r
-       memset(&req, 0, sizeof(req));\r
-\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(allocated));\r
-\r
-       EXPECT_EQ(0, rm_allocate_resources(handle, &req, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-\r
-       rm_resource_list_h rsc_list = NULL;\r
-\r
-       EXPECT_EQ(0, rm_get_resource_collection_state(RM_RSC_COLLECTION_MAIN, &rsc_list));\r
-\r
-       // MFD0, DVDE0, MAIN SCALER, MAIN AUDIO DECODER, MAIN AUDIO OUT\r
-       EXPECT_EQ(5, rm_resource_list_get_count(rsc_list));\r
-\r
-       rm_resource_h resource = rm_resource_list_get_first(rsc_list);\r
-\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_MAIN_OUT, rm_resource_get_id(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));\r
-       EXPECT_EQ(-1, rm_resource_get_consumer(resource));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(resource));\r
-       EXPECT_EQ(RM_CATEGORY_AUDIO_MAIN_OUT, rm_resource_get_category(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, rm_resource_get_state(resource));\r
-       EXPECT_EQ(handle, rm_resource_get_consumer(resource));\r
-       EXPECT_STREQ(app_id, rm_resource_get_app_id(resource));\r
-       EXPECT_EQ(RM_CATEGORY_SCALER, rm_resource_get_category(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-\r
-       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, rm_resource_get_id(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));\r
-       EXPECT_EQ(-1, rm_resource_get_consumer(resource));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(resource));\r
-       EXPECT_EQ(RM_CATEGORY_AUDIO_DECODER, rm_resource_get_category(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-\r
-       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_MAIN, rm_resource_get_id(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));\r
-       EXPECT_EQ(-1, rm_resource_get_consumer(resource));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(resource));\r
-       EXPECT_LE(RM_CATEGORY_VIDEO_DECODER, rm_resource_get_category(resource));\r
-\r
-       resource = rm_resource_list_get_next(rsc_list);\r
-\r
-       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_DVDE0, rm_resource_get_id(resource));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));\r
-       EXPECT_EQ(-1, rm_resource_get_consumer(resource));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(resource));\r
-       EXPECT_LE(RM_CATEGORY_VIDEO_DECODER_UHD, rm_resource_get_category(resource));\r
-\r
-       rm_free_resource_list(rsc_list);\r
-\r
-       EXPECT_EQ(0, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("rm_get_resource_collection_state_p2 end...");\r
-}\r
-\r
-\r
-static void tc_resource_state_change_cb1(rm_resource_state_h state, void *data)\r
-{\r
-\r
-}\r
-\r
-static void tc_resource_state_change_cb2(rm_resource_state_h state, void *data)\r
-{\r
-\r
-}\r
-\r
-static void tc_resource_state_change_cb3(rm_resource_state_h state, void *data)\r
-{\r
-\r
-}\r
-\r
-TEST(ut_rm_api, rm_resource_state_change_p1)\r
-{\r
-       RM_TEST_MSG("rm_resource_state_change_p1 start...");\r
-\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1, NULL));\r
-       EXPECT_EQ(RM_ERROR, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1, NULL));\r
-       EXPECT_EQ(RM_ERROR, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb2, NULL));\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb3, NULL));\r
-\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb3));\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb2));\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1));\r
-\r
-       RM_TEST_MSG("rm_resource_state_change_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_resource_state_change_p2)\r
-{\r
-       RM_TEST_MSG("rm_resource_state_change_p2 start...");\r
-\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_SCALER, tc_resource_state_change_cb1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_SCALER_BG, tc_resource_state_change_cb1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_SCALER_SUB, tc_resource_state_change_cb1, NULL));\r
-\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1));\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER, tc_resource_state_change_cb1));\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER_BG, tc_resource_state_change_cb1));\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER_SUB, tc_resource_state_change_cb1));\r
-\r
-       RM_TEST_MSG("rm_resource_state_change_p2 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_resource_state_change_p3)\r
-{\r
-       RM_TEST_MSG("rm_resource_state_change_p3 start...");\r
-\r
-       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1));\r
-       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER, tc_resource_state_change_cb1));\r
-       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER_BG, tc_resource_state_change_cb1));\r
-       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER_SUB, tc_resource_state_change_cb1));\r
-\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_SCALER, tc_resource_state_change_cb1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_SCALER_BG, tc_resource_state_change_cb1, NULL));\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_SCALER_SUB, tc_resource_state_change_cb1, NULL));\r
-\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1));\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER, tc_resource_state_change_cb1));\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER_BG, tc_resource_state_change_cb1));\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER_SUB, tc_resource_state_change_cb1));\r
-\r
-       RM_TEST_MSG("rm_resource_state_change_p3 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_resource_state_change_n1)\r
-{\r
-       RM_TEST_MSG("rm_resource_state_change_n1 start...");\r
-\r
-       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, NULL));\r
-       EXPECT_EQ(RM_ERROR, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, NULL, NULL));\r
-\r
-       RM_TEST_MSG("rm_resource_state_change_n1 end...");\r
-}\r
-\r
-typedef struct{\r
-       char *app_id;\r
-       int consumer_id;\r
-       int device_id;\r
-       int category_id;\r
-} expected_conflict_event;\r
-\r
-void conflict_event_cb(rm_conflict_resource_h resource, void *data)\r
-{\r
-       RM_TEST_MSG("conflict event cb invoked!");\r
-       if (!data)\r
-               return;\r
-\r
-       expected_conflict_event *expected = (expected_conflict_event*) data;\r
-\r
-       EXPECT_EQ(expected->category_id, rm_conflict_get_category_id(resource));\r
-       EXPECT_EQ(expected->device_id, rm_conflict_get_device_id(resource));\r
-       EXPECT_EQ(expected->consumer_id, rm_conflict_get_consumer_id(resource));\r
-       EXPECT_STREQ(expected->app_id, rm_conflict_get_app_id(resource));\r
-}\r
-\r
-void conflict_event_cb2(rm_conflict_resource_h resource, void *data)\r
-{\r
-\r
-}\r
-\r
-TEST(ut_rm_api, rm_conflict_event_cb_p1)\r
-{\r
-       RM_TEST_MSG("rm_conflict_event_cb_p1 start...");\r
-\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_conflict_event(conflict_event_cb, NULL));\r
-       EXPECT_EQ(RM_ERROR, rm_subscribe_resource_conflict_event(conflict_event_cb, NULL));\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_conflict_event(conflict_event_cb));\r
-       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_conflict_event(conflict_event_cb));\r
-\r
-       RM_TEST_MSG("rm_conflict_event_cb_p1 end...");\r
-}\r
-\r
-\r
-rm_cb_result resource_conflict_cb(int handle, rm_callback_type event, rm_device_request_s *info, void *data)\r
-{\r
-       RM_TEST_MSG("resource conflict cb invoked!");\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, info));\r
-       return RM_CB_RESULT_OK;\r
-}\r
-\r
-TEST(ut_rm_api, rm_conflict_event_cb_p2)\r
-{\r
-       RM_TEST_MSG("rm_conflict_event_cb_p2 start...");\r
-\r
-       int handle1 = 0;\r
-       rm_consumer_info *consumer_info1 = (rm_consumer_info*) calloc(1, sizeof(rm_consumer_info));\r
-       snprintf(consumer_info1->app_id, 1024, "%s", "org.tizen.rm.test");\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(resource_conflict_cb, NULL, &handle1, consumer_info1));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_JPEG_DECODER;\r
-       request.category_option[0] = ri_get_sub_jpeg_category_id("JPEG", 7680, 4320);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, &request, &allocated));\r
-\r
-       expected_conflict_event *expected = (expected_conflict_event*) calloc(1, sizeof(expected_conflict_event));\r
-       expected->app_id = strdup("org.tizen.rm.test");\r
-\r
-       if (use_unified_jpeg_decoder())\r
-               expected->category_id = RM_CATEGORY_JPEG_DECODER_8K;\r
-       else if (is_oscars_unified_jpeg_decoder())\r
-               expected->category_id = RM_CATEGORY_JPEG_DECODER;\r
-       else\r
-               expected->category_id = RM_CATEGORY_JPEG_DECODER_UHD;\r
-\r
-       expected->consumer_id = handle1;\r
-       expected->device_id = allocated.device_id[0];\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_conflict_event(conflict_event_cb, (void*) expected));\r
-\r
-       int handle2 = 0;\r
-       EXPECT_EQ(RM_OK, rm_register(resource_conflict_cb, NULL, &handle2, NULL));\r
-\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_JPEG_DECODER;\r
-       request.category_option[0] = ri_get_sub_jpeg_category_id("JPEG", 7680, 4320);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &request, &allocated));\r
-\r
-       sleep(5);\r
-\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_conflict_event(conflict_event_cb));\r
-\r
-       free(consumer_info1);\r
-       consumer_info1 = NULL;\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle1));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-\r
-       RM_TEST_MSG("rm_conflict_event_cb_p2 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_conflict_event_cb_n1)\r
-{\r
-       RM_TEST_MSG("rm_conflict_event_cb_n1 start...");\r
-\r
-       EXPECT_EQ(RM_ERROR, rm_subscribe_resource_conflict_event(NULL, NULL));\r
-       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_conflict_event(NULL));\r
-\r
-       RM_TEST_MSG("rm_conflict_event_cb_n1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_conflict_event_cb_p3)\r
-{\r
-       RM_TEST_MSG("rm_conflict_event_cb_p3 start...");\r
-\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_conflict_event(conflict_event_cb, NULL));\r
-       EXPECT_EQ(RM_OK, rm_subscribe_resource_conflict_event(conflict_event_cb2, NULL));\r
-\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_conflict_event(conflict_event_cb2));\r
-       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_conflict_event(conflict_event_cb));\r
-\r
-       RM_TEST_MSG("rm_conflict_event_cb_p3 end...");\r
-}\r
+/*
+ * Copyright (c) 2024 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 "gtest/gtest.h"
+#include <unistd.h>
+
+#include <rm_api.h>
+#include <rm_module_api.h>
+#include <stdlib.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include <rm_debug.h>
+#include <dlog.h>
+#include <sys/stat.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <ut_common.h>
+#include <TCPlayer.h>
+
+
+TEST(ut_rm_api, rm_rsc_state_p1)
+{
+       RM_TEST_MSG("rm_rsc_state_p1 start...");
+
+       rm_resource_state_e state;
+       int ret = rm_get_resource_state(RM_DEVICE_AUDIO_ENCODER, &state);
+
+       EXPECT_EQ(RM_OK, ret);
+       EXPECT_EQ(RM_RSC_STATE_FREE, state);
+
+       RM_TEST_MSG("rm_rsc_state_p1 end...");
+}
+
+TEST(ut_rm_api, rm_rsc_state_n1)
+{
+       RM_TEST_MSG("rm_rsc_state_n1 start...");
+
+       rm_resource_state_e state;
+       int ret = rm_get_resource_state(9999999, &state);
+
+       EXPECT_NE(RM_OK, ret);
+
+       RM_TEST_MSG("rm_rsc_state_n1 end...");
+}
+
+TEST(ut_rm_api, rm_rsc_state_n2)
+{
+       RM_TEST_MSG("rm_rsc_state_n2 start...");
+
+       rm_resource_state_e state;
+       int ret = rm_get_resource_state(-1, &state);
+
+       EXPECT_NE(RM_OK, ret);
+
+       RM_TEST_MSG("rm_rsc_state_n2 end...");
+}
+
+TEST(ut_rm_api, rm_rsc_state_n3)
+{
+       RM_TEST_MSG("rm_rsc_state_n2 start...");
+
+       int ret = rm_get_resource_state(RM_DEVICE_AUDIO_ENCODER, NULL);
+
+       EXPECT_NE(RM_OK, ret);
+
+       RM_TEST_MSG("rm_rsc_state_n3 end...");
+}
+
+TEST(ut_rm_api, rm_rsc_get_resource_list_p1)
+{
+       RM_TEST_MSG("rm_rsc_get_resource_list_p1 start...");
+
+       rm_resource_list_h rsc_list;
+       int ret = rm_get_resource_list(RM_CATEGORY_DEMUX, &rsc_list);
+
+       EXPECT_EQ(RM_OK, ret);
+
+       rm_resource_h resource;
+       EXPECT_EQ(6, rm_resource_list_get_count(rsc_list));
+
+       resource = rm_resource_list_get_first(rsc_list);
+       EXPECT_EQ(RM_DEVICE_DEMUX0, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dvb/adapter0/demux0", rm_resource_get_node(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+       EXPECT_EQ(RM_DEVICE_DEMUX1, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dvb/adapter0/demux1", rm_resource_get_node(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+       EXPECT_EQ(RM_DEVICE_DEMUX2, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dvb/adapter0/demux2", rm_resource_get_node(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+       EXPECT_EQ(RM_DEVICE_DEMUX3, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dvb/adapter0/demux3", rm_resource_get_node(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+       EXPECT_EQ(RM_DEVICE_DEMUX4, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dvb/adapter0/demux4", rm_resource_get_node(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+       EXPECT_EQ(RM_DEVICE_DEMUX5, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dvb/adapter0/demux5", rm_resource_get_node(resource));
+
+       EXPECT_EQ(0, rm_resource_list_get_next(rsc_list));
+
+       resource = rm_resource_list_get_last(rsc_list);
+       EXPECT_EQ(RM_DEVICE_DEMUX5, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dvb/adapter0/demux5", rm_resource_get_node(resource));
+
+       resource = rm_resource_list_get_prev(rsc_list);
+       EXPECT_EQ(RM_DEVICE_DEMUX4, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dvb/adapter0/demux4", rm_resource_get_node(resource));
+
+       resource = rm_resource_list_get_prev(rsc_list);
+       EXPECT_EQ(RM_DEVICE_DEMUX3, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dvb/adapter0/demux3", rm_resource_get_node(resource));
+
+       resource = rm_resource_list_get_prev(rsc_list);
+       EXPECT_EQ(RM_DEVICE_DEMUX2, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dvb/adapter0/demux2", rm_resource_get_node(resource));
+
+       resource = rm_resource_list_get_prev(rsc_list);
+       EXPECT_EQ(RM_DEVICE_DEMUX1, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dvb/adapter0/demux1", rm_resource_get_node(resource));
+
+       resource = rm_resource_list_get_prev(rsc_list);
+       EXPECT_EQ(RM_DEVICE_DEMUX0, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dvb/adapter0/demux0", rm_resource_get_node(resource));
+
+       EXPECT_EQ(0, rm_resource_list_get_prev(rsc_list));
+
+       rm_free_resource_list(rsc_list);
+
+       RM_TEST_MSG("rm_rsc_get_resource_list_p1 end...");
+}
+
+TEST(ut_rm_api, rm_rsc_get_resource_list_p2)
+{
+       RM_TEST_MSG("rm_rsc_get_resource_list_p2 start...");
+
+       TCPlayer *player = new TCPlayer();
+       player->AddResource(RM_CATEGORY_SCALER, RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player->Register());
+       EXPECT_EQ(RM_OK, player->AllocateResources());
+
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, player->GetAllocatedResourceId(1));
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(player->GetAllocatedResourceId(1)));
+
+       rm_resource_list_h rsc_list;
+       int ret = rm_get_resource_list(RM_CATEGORY_SCALER, &rsc_list);
+
+       EXPECT_EQ(RM_OK, ret);
+
+       rm_resource_h resource;
+       EXPECT_EQ(1, rm_resource_list_get_count(rsc_list));
+       resource = rm_resource_list_get_first(rsc_list);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dri/card0", rm_resource_get_node(resource));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, rm_resource_get_state(resource));
+
+       EXPECT_EQ(0, rm_resource_list_get_next(rsc_list));
+
+       resource = rm_resource_list_get_last(rsc_list);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dri/card0", rm_resource_get_node(resource));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, rm_resource_get_state(resource));
+
+       EXPECT_EQ(0, rm_resource_list_get_prev(rsc_list));
+
+       rm_free_resource_list(rsc_list);
+
+       EXPECT_EQ(RM_OK, player->Unregister());
+       delete player;
+
+       ret = rm_get_resource_list(RM_CATEGORY_SCALER, &rsc_list);
+       EXPECT_EQ(RM_OK, ret);
+
+       EXPECT_EQ(1, rm_resource_list_get_count(rsc_list));
+       resource = rm_resource_list_get_first(rsc_list);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dri/card0", rm_resource_get_node(resource));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));
+
+       EXPECT_EQ(0, rm_resource_list_get_next(rsc_list));
+
+       resource = rm_resource_list_get_last(rsc_list);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(resource));
+       EXPECT_STREQ("/dev/dri/card0", rm_resource_get_node(resource));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));
+
+       EXPECT_EQ(0, rm_resource_list_get_prev(rsc_list));
+
+       rm_free_resource_list(rsc_list);
+
+       RM_TEST_MSG("rm_rsc_get_resource_list_p2 end...");
+}
+
+TEST(ut_rm_api, rm_rsc_get_resource_list_p3)
+{
+       if (!is_support_audio_dual_decoding())
+               return;
+
+       RM_TEST_MSG("rm_rsc_get_resource_list_p3 start...");
+
+       rm_resource_list_h rsc_list;
+       int ret = rm_get_resource_list(RM_CATEGORY_AUDIO_SUB_OUT, &rsc_list);
+
+       EXPECT_EQ(RM_OK, ret);
+
+       rm_resource_h resource;
+       EXPECT_EQ(1, rm_resource_list_get_count(rsc_list));
+       resource = rm_resource_list_get_first(rsc_list);
+       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, rm_resource_get_id(resource));
+       EXPECT_STREQ("", rm_resource_get_app_id(resource));
+       EXPECT_EQ(0, rm_resource_list_get_next(rsc_list));
+
+       resource = rm_resource_list_get_last(rsc_list);
+       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, rm_resource_get_id(resource));
+
+       EXPECT_EQ(0, rm_resource_list_get_prev(rsc_list));
+
+       rm_free_resource_list(rsc_list);
+
+       RM_TEST_MSG("rm_rsc_get_resource_list_p3 end...");
+}
+
+TEST(ut_rm_api, rm_rsc_get_resource_list_p4)
+{
+       if (!is_support_audio_dual_decoding())
+               return;
+
+       RM_TEST_MSG("rm_rsc_get_resource_list_p4 start...");
+
+       TCPlayer *player = new TCPlayer();
+       player->AddResource(RM_CATEGORY_AUDIO_SUB_OUT, RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player->Register());
+       EXPECT_EQ(RM_OK, player->SetAppId("org.tizen.viewer"));
+       EXPECT_EQ(RM_OK, player->AllocateResources());
+
+       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, player->GetAllocatedResourceId(1));
+
+       rm_resource_list_h rsc_list;
+       int ret = rm_get_resource_list(RM_CATEGORY_AUDIO_SUB_OUT, &rsc_list);
+
+       EXPECT_EQ(RM_OK, ret);
+
+       rm_resource_h resource;
+       EXPECT_EQ(1, rm_resource_list_get_count(rsc_list));
+       resource = rm_resource_list_get_first(rsc_list);
+       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, rm_resource_get_id(resource));
+       EXPECT_STREQ("org.tizen.viewer", rm_resource_get_app_id(resource));
+       EXPECT_EQ(0, rm_resource_list_get_next(rsc_list));
+
+       resource = rm_resource_list_get_last(rsc_list);
+       EXPECT_EQ(RM_DEVICE_AUDIO_SUB_OUT, rm_resource_get_id(resource));
+
+       EXPECT_EQ(0, rm_resource_list_get_prev(rsc_list));
+
+       rm_free_resource_list(rsc_list);
+
+       EXPECT_EQ(RM_OK, player->Unregister());
+       delete player;
+
+       RM_TEST_MSG("rm_rsc_get_resource_list_p4 end...");
+}
+
+
+TEST(ut_rm_api, rm_rsc_get_resource_list_n1)
+{
+       RM_TEST_MSG("rm_rsc_get_resource_list_n1 start...");
+
+       rm_resource_list_h rsc_list;
+       int ret = rm_get_resource_list((rm_rsc_category_e) -10, &rsc_list);
+
+       EXPECT_EQ(RM_OK, ret);
+       rm_free_resource_list(rsc_list);
+
+       RM_TEST_MSG("rm_rsc_get_resource_list_n1 end...");
+}
+
+TEST(ut_rm_api, rm_rsc_get_resource_list_n2)
+{
+       RM_TEST_MSG("rm_rsc_get_resource_list_n2 start...");
+
+       int ret = rm_get_resource_list(RM_CATEGORY_DEMUX, NULL);
+
+       EXPECT_NE(RM_OK, ret);
+
+       RM_TEST_MSG("rm_rsc_get_resource_list_n2 end...");
+}
+
+TEST(ut_rm_api, rm_resource_get_id_n1)
+{
+       RM_TEST_MSG("rm_resource_get_id_n1 start...");
+       EXPECT_EQ(-1, rm_resource_get_id(NULL));
+       RM_TEST_MSG("rm_resource_get_id_n1 end...");
+}
+
+TEST(ut_rm_api, rm_resource_get_node_n1)
+{
+       RM_TEST_MSG("rm_resource_get_node_n1 start...");
+       EXPECT_EQ(0, rm_resource_get_node(NULL));
+       RM_TEST_MSG("rm_resource_get_node_n1 end...");
+}
+
+TEST(ut_rm_api, rm_resource_list_get_prev_n1)
+{
+       RM_TEST_MSG("rm_resource_list_get_prev_n1 start...");
+       EXPECT_EQ(0, rm_resource_list_get_prev(NULL));
+       rm_resource_list_h list = NULL;
+       EXPECT_EQ(0, rm_resource_list_get_prev(list));
+       RM_TEST_MSG("rm_resource_list_get_prev_n1 end...");
+}
+
+TEST(ut_rm_api, rm_get_resource_collection_state_p1)
+{
+       RM_TEST_MSG("rm_get_resource_collection_state_p1 start...");
+
+       rm_resource_list_h rsc_list = NULL;
+
+       EXPECT_EQ(0, rm_get_resource_collection_state(RM_RSC_COLLECTION_MAIN, &rsc_list));
+
+       // MFD0, DVDE0, MAIN SCALER, MAIN AUDIO DECODER, MAIN AUDIO OUT
+       EXPECT_EQ(5, rm_resource_list_get_count(rsc_list));
+
+       rm_resource_h resource = rm_resource_list_get_first(rsc_list);
+
+       EXPECT_EQ(RM_DEVICE_AUDIO_MAIN_OUT, rm_resource_get_id(resource));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));
+       EXPECT_EQ(-1, rm_resource_get_consumer(resource));
+       EXPECT_STREQ("", rm_resource_get_app_id(resource));
+       EXPECT_EQ(RM_CATEGORY_AUDIO_MAIN_OUT, rm_resource_get_category(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(resource));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));
+       EXPECT_EQ(-1, rm_resource_get_consumer(resource));
+       EXPECT_STREQ("", rm_resource_get_app_id(resource));
+       EXPECT_EQ(RM_CATEGORY_SCALER, rm_resource_get_category(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, rm_resource_get_id(resource));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));
+       EXPECT_EQ(-1, rm_resource_get_consumer(resource));
+       EXPECT_STREQ("", rm_resource_get_app_id(resource));
+       EXPECT_EQ(RM_CATEGORY_AUDIO_DECODER, rm_resource_get_category(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+
+       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_MAIN, rm_resource_get_id(resource));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));
+       EXPECT_EQ(-1, rm_resource_get_consumer(resource));
+       EXPECT_STREQ("", rm_resource_get_app_id(resource));
+       EXPECT_LE(RM_CATEGORY_VIDEO_DECODER, rm_resource_get_category(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+
+       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_DVDE0, rm_resource_get_id(resource));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));
+       EXPECT_EQ(-1, rm_resource_get_consumer(resource));
+       EXPECT_STREQ("", rm_resource_get_app_id(resource));
+       EXPECT_LE(RM_CATEGORY_VIDEO_DECODER_UHD, rm_resource_get_category(resource));
+
+       rm_free_resource_list(rsc_list);
+
+       RM_TEST_MSG("rm_get_resource_collection_state_p1 end...");
+}
+
+TEST(ut_rm_api, rm_get_resource_collection_state_p2)
+{
+       RM_TEST_MSG("rm_get_resource_collection_state_p2 start...");
+
+       int handle = 0;
+       const char *app_id = "org.tizen.test";
+       EXPECT_EQ(0, rm_register(rm_cb_set_conflict_flag, NULL, &handle, NULL));
+       EXPECT_EQ(0, rm_set_app_id(handle, (char*) app_id));
+
+       rm_category_request_s req;
+       memset(&req, 0, sizeof(req));
+
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(allocated));
+
+       EXPECT_EQ(0, rm_allocate_resources(handle, &req, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+
+       rm_resource_list_h rsc_list = NULL;
+
+       EXPECT_EQ(0, rm_get_resource_collection_state(RM_RSC_COLLECTION_MAIN, &rsc_list));
+
+       // MFD0, DVDE0, MAIN SCALER, MAIN AUDIO DECODER, MAIN AUDIO OUT
+       EXPECT_EQ(5, rm_resource_list_get_count(rsc_list));
+
+       rm_resource_h resource = rm_resource_list_get_first(rsc_list);
+
+       EXPECT_EQ(RM_DEVICE_AUDIO_MAIN_OUT, rm_resource_get_id(resource));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));
+       EXPECT_EQ(-1, rm_resource_get_consumer(resource));
+       EXPECT_STREQ("", rm_resource_get_app_id(resource));
+       EXPECT_EQ(RM_CATEGORY_AUDIO_MAIN_OUT, rm_resource_get_category(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(resource));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, rm_resource_get_state(resource));
+       EXPECT_EQ(handle, rm_resource_get_consumer(resource));
+       EXPECT_STREQ(app_id, rm_resource_get_app_id(resource));
+       EXPECT_EQ(RM_CATEGORY_SCALER, rm_resource_get_category(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+
+       EXPECT_EQ(RM_DEVICE_AUDIO_DECODER, rm_resource_get_id(resource));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));
+       EXPECT_EQ(-1, rm_resource_get_consumer(resource));
+       EXPECT_STREQ("", rm_resource_get_app_id(resource));
+       EXPECT_EQ(RM_CATEGORY_AUDIO_DECODER, rm_resource_get_category(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+
+       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_MAIN, rm_resource_get_id(resource));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));
+       EXPECT_EQ(-1, rm_resource_get_consumer(resource));
+       EXPECT_STREQ("", rm_resource_get_app_id(resource));
+       EXPECT_LE(RM_CATEGORY_VIDEO_DECODER, rm_resource_get_category(resource));
+
+       resource = rm_resource_list_get_next(rsc_list);
+
+       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_DVDE0, rm_resource_get_id(resource));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(resource));
+       EXPECT_EQ(-1, rm_resource_get_consumer(resource));
+       EXPECT_STREQ("", rm_resource_get_app_id(resource));
+       EXPECT_LE(RM_CATEGORY_VIDEO_DECODER_UHD, rm_resource_get_category(resource));
+
+       rm_free_resource_list(rsc_list);
+
+       EXPECT_EQ(0, rm_unregister(handle));
+
+       RM_TEST_MSG("rm_get_resource_collection_state_p2 end...");
+}
+
+
+static void tc_resource_state_change_cb1(rm_resource_state_h state, void *data)
+{
+
+}
+
+static void tc_resource_state_change_cb2(rm_resource_state_h state, void *data)
+{
+
+}
+
+static void tc_resource_state_change_cb3(rm_resource_state_h state, void *data)
+{
+
+}
+
+TEST(ut_rm_api, rm_resource_state_change_p1)
+{
+       RM_TEST_MSG("rm_resource_state_change_p1 start...");
+
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1, NULL));
+       EXPECT_EQ(RM_ERROR, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1, NULL));
+       EXPECT_EQ(RM_ERROR, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1, NULL));
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb2, NULL));
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb3, NULL));
+
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb3));
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb2));
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1));
+
+       RM_TEST_MSG("rm_resource_state_change_p1 end...");
+}
+
+TEST(ut_rm_api, rm_resource_state_change_p2)
+{
+       RM_TEST_MSG("rm_resource_state_change_p2 start...");
+
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1, NULL));
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_SCALER, tc_resource_state_change_cb1, NULL));
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_SCALER_BG, tc_resource_state_change_cb1, NULL));
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_SCALER_SUB, tc_resource_state_change_cb1, NULL));
+
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1));
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER, tc_resource_state_change_cb1));
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER_BG, tc_resource_state_change_cb1));
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER_SUB, tc_resource_state_change_cb1));
+
+       RM_TEST_MSG("rm_resource_state_change_p2 end...");
+}
+
+TEST(ut_rm_api, rm_resource_state_change_p3)
+{
+       RM_TEST_MSG("rm_resource_state_change_p3 start...");
+
+       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1));
+       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER, tc_resource_state_change_cb1));
+       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER_BG, tc_resource_state_change_cb1));
+       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER_SUB, tc_resource_state_change_cb1));
+
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1, NULL));
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_SCALER, tc_resource_state_change_cb1, NULL));
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_SCALER_BG, tc_resource_state_change_cb1, NULL));
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_state_change(RM_CATEGORY_SCALER_SUB, tc_resource_state_change_cb1, NULL));
+
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, tc_resource_state_change_cb1));
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER, tc_resource_state_change_cb1));
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER_BG, tc_resource_state_change_cb1));
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_state_change(RM_CATEGORY_SCALER_SUB, tc_resource_state_change_cb1));
+
+       RM_TEST_MSG("rm_resource_state_change_p3 end...");
+}
+
+TEST(ut_rm_api, rm_resource_state_change_n1)
+{
+       RM_TEST_MSG("rm_resource_state_change_n1 start...");
+
+       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_state_change(RM_CATEGORY_CAMERA, NULL));
+       EXPECT_EQ(RM_ERROR, rm_subscribe_resource_state_change(RM_CATEGORY_CAMERA, NULL, NULL));
+
+       RM_TEST_MSG("rm_resource_state_change_n1 end...");
+}
+
+typedef struct{
+       char *app_id;
+       int consumer_id;
+       int device_id;
+       int category_id;
+} expected_conflict_event;
+
+void conflict_event_cb(rm_conflict_resource_h resource, void *data)
+{
+       RM_TEST_MSG("conflict event cb invoked!");
+       if (!data)
+               return;
+
+       expected_conflict_event *expected = (expected_conflict_event*) data;
+
+       EXPECT_EQ(expected->category_id, rm_conflict_get_category_id(resource));
+       EXPECT_EQ(expected->device_id, rm_conflict_get_device_id(resource));
+       EXPECT_EQ(expected->consumer_id, rm_conflict_get_consumer_id(resource));
+       EXPECT_STREQ(expected->app_id, rm_conflict_get_app_id(resource));
+}
+
+void conflict_event_cb2(rm_conflict_resource_h resource, void *data)
+{
+
+}
+
+TEST(ut_rm_api, rm_conflict_event_cb_p1)
+{
+       RM_TEST_MSG("rm_conflict_event_cb_p1 start...");
+
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_conflict_event(conflict_event_cb, NULL));
+       EXPECT_EQ(RM_ERROR, rm_subscribe_resource_conflict_event(conflict_event_cb, NULL));
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_conflict_event(conflict_event_cb));
+       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_conflict_event(conflict_event_cb));
+
+       RM_TEST_MSG("rm_conflict_event_cb_p1 end...");
+}
+
+
+rm_cb_result resource_conflict_cb(int handle, rm_callback_type event, rm_device_request_s *info, void *data)
+{
+       RM_TEST_MSG("resource conflict cb invoked!");
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, info));
+       return RM_CB_RESULT_OK;
+}
+
+TEST(ut_rm_api, rm_conflict_event_cb_p2)
+{
+       RM_TEST_MSG("rm_conflict_event_cb_p2 start...");
+
+       int handle1 = 0;
+       rm_consumer_info *consumer_info1 = (rm_consumer_info*) calloc(1, sizeof(rm_consumer_info));
+       snprintf(consumer_info1->app_id, 1024, "%s", "org.tizen.rm.test");
+
+       EXPECT_EQ(RM_OK, rm_register(resource_conflict_cb, NULL, &handle1, consumer_info1));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_JPEG_DECODER;
+       request.category_option[0] = ri_get_sub_jpeg_category_id("JPEG", 7680, 4320);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle1, &request, &allocated));
+
+       expected_conflict_event *expected = (expected_conflict_event*) calloc(1, sizeof(expected_conflict_event));
+       expected->app_id = strdup("org.tizen.rm.test");
+
+       if (use_unified_jpeg_decoder())
+               expected->category_id = RM_CATEGORY_JPEG_DECODER_8K;
+       else if (is_oscars_unified_jpeg_decoder())
+               expected->category_id = RM_CATEGORY_JPEG_DECODER;
+       else
+               expected->category_id = RM_CATEGORY_JPEG_DECODER_UHD;
+
+       expected->consumer_id = handle1;
+       expected->device_id = allocated.device_id[0];
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_conflict_event(conflict_event_cb, (void*) expected));
+
+       int handle2 = 0;
+       EXPECT_EQ(RM_OK, rm_register(resource_conflict_cb, NULL, &handle2, NULL));
+
+       memset(&request, 0, sizeof(rm_category_request_s));
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_JPEG_DECODER;
+       request.category_option[0] = ri_get_sub_jpeg_category_id("JPEG", 7680, 4320);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &request, &allocated));
+
+       sleep(5);
+
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_conflict_event(conflict_event_cb));
+
+       free(consumer_info1);
+       consumer_info1 = NULL;
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle1));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+
+       RM_TEST_MSG("rm_conflict_event_cb_p2 end...");
+}
+
+TEST(ut_rm_api, rm_conflict_event_cb_n1)
+{
+       RM_TEST_MSG("rm_conflict_event_cb_n1 start...");
+
+       EXPECT_EQ(RM_ERROR, rm_subscribe_resource_conflict_event(NULL, NULL));
+       EXPECT_EQ(RM_ERROR, rm_unsubscribe_resource_conflict_event(NULL));
+
+       RM_TEST_MSG("rm_conflict_event_cb_n1 end...");
+}
+
+TEST(ut_rm_api, rm_conflict_event_cb_p3)
+{
+       RM_TEST_MSG("rm_conflict_event_cb_p3 start...");
+
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_conflict_event(conflict_event_cb, NULL));
+       EXPECT_EQ(RM_OK, rm_subscribe_resource_conflict_event(conflict_event_cb2, NULL));
+
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_conflict_event(conflict_event_cb2));
+       EXPECT_EQ(RM_OK, rm_unsubscribe_resource_conflict_event(conflict_event_cb));
+
+       RM_TEST_MSG("rm_conflict_event_cb_p3 end...");
+}
index 9d6de5eb9559877da61849926e9dec9b51d19d7a..68b0d1e1e0a3cf22f312fdcd7e0d7537a96c5dd8 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "gtest/gtest.h"\r
-#include <unistd.h>\r
-\r
-#include <rm_api.h>\r
-#include <rm_module_api.h>\r
-#include <stdlib.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include <rm_debug.h>\r
-#include <dlog.h>\r
-#include <sys/stat.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-\r
-#include <ut_common.h>\r
-#include <TCPlayer.h>\r
-\r
-rm_cb_result rsc_conflict_cb(int handle, rm_callback_type event, rm_device_request_s *info, void *data)\r
-{\r
-       RM_TEST_MSG("resource conflict cb invoked!");\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, info));\r
-       return RM_CB_RESULT_OK;\r
-}\r
-\r
-TEST(ut_rm_api, rm_get_scaler_state_p1)\r
-{\r
-       RM_TEST_MSG("rm_get_scaler_state_p1 start...");\r
-\r
-       int handle;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rsc_conflict_cb, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s req;\r
-       memset(&req, 0, sizeof(req));\r
-\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(allocated));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated.device_id[0]));\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       rm_resource_list_h scaler_list_h;\r
-       int result = rm_get_scaler_state(&scaler_list_h);\r
-       EXPECT_EQ(RM_OK, result);\r
-\r
-       if (result != RM_OK) {\r
-               RM_TEST_MSG("rm_get_scaler_state_p1 end...");\r
-               rm_free_resource_list(scaler_list_h);\r
-               return;\r
-       }\r
-\r
-       EXPECT_EQ(2, rm_resource_list_get_count(scaler_list_h));\r
-\r
-       // main scaler\r
-       rm_resource_h rsc = rm_resource_list_get_first(scaler_list_h);\r
-       EXPECT_EQ(RM_CATEGORY_SCALER, rm_resource_get_category(rsc));\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(rsc));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(rsc));\r
-       EXPECT_EQ(-1, rm_resource_get_consumer(rsc));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(rsc));\r
-\r
-       // sub scaler\r
-       rsc = rm_resource_list_get_next(scaler_list_h);\r
-       EXPECT_EQ(RM_CATEGORY_SCALER_SUB, rm_resource_get_category(rsc));\r
-       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_resource_get_id(rsc));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(rsc));\r
-       EXPECT_EQ(-1, rm_resource_get_consumer(rsc));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(rsc));\r
-\r
-       rm_free_resource_list(scaler_list_h);\r
-\r
-       RM_TEST_MSG("rm_get_scaler_state_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_get_scaler_state_p2)\r
-{\r
-       RM_TEST_MSG("rm_get_scaler_state_p2 start...");\r
-\r
-       int handle;\r
-       char *app_id1 = (char*) "org.tizen.rsc.test";\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rsc_conflict_cb, NULL, &handle, NULL));\r
-       EXPECT_EQ(RM_OK, rm_set_app_id(handle, app_id1));\r
-\r
-       rm_category_request_s req;\r
-       memset(&req, 0, sizeof(req));\r
-\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(allocated));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated.device_id[0]));\r
-\r
-\r
-       rm_resource_list_h scaler_list_h;\r
-       int result = rm_get_scaler_state(&scaler_list_h);\r
-       EXPECT_EQ(RM_OK, result);\r
-\r
-       if (result != RM_OK) {\r
-               EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-               rm_free_resource_list(scaler_list_h);\r
-               RM_TEST_MSG("rm_get_scaler_state_p2 end...");\r
-               return;\r
-       }\r
-\r
-       EXPECT_EQ(2, rm_resource_list_get_count(scaler_list_h));\r
-\r
-       // main scaler\r
-       rm_resource_h rsc = rm_resource_list_get_first(scaler_list_h);\r
-       EXPECT_EQ(RM_CATEGORY_SCALER, rm_resource_get_category(rsc));\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(rsc));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, rm_resource_get_state(rsc));\r
-       EXPECT_EQ(handle, rm_resource_get_consumer(rsc));\r
-       EXPECT_STREQ(app_id1, rm_resource_get_app_id(rsc));\r
-\r
-       // sub scaler\r
-       rsc = rm_resource_list_get_next(scaler_list_h);\r
-       EXPECT_EQ(RM_CATEGORY_SCALER_SUB, rm_resource_get_category(rsc));\r
-       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_resource_get_id(rsc));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(rsc));\r
-       EXPECT_EQ(-1, rm_resource_get_consumer(rsc));\r
-       EXPECT_STREQ("", rm_resource_get_app_id(rsc));\r
-\r
-       rm_free_resource_list(scaler_list_h);\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-       RM_TEST_MSG("rm_get_scaler_state_p2 end...");\r
-}\r
-\r
-/* issue : video decoder(mem cluster) conflict & rsc(sub scaler) conflict\r
- */\r
-TEST(ut_rm_api, rm_conflict11)\r
-{\r
-       RM_TEST_MSG("rm_conflict11 start...");\r
-\r
-       TCPlayer *player = new TCPlayer();\r
-       player->AddResource(RM_CATEGORY_VIDEO_DECODER, RM_DEVICE_OPT_MAIN, RM_STATE_EXCLUSIVE);\r
-       player->AddResource(RM_CATEGORY_SCALER_SUB, RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player->Register());\r
-       EXPECT_EQ(RM_OK, player->AllocateResources());\r
-\r
-       TCPlayer *player2 = new TCPlayer();\r
-       player2->AddResource(RM_CATEGORY_VIDEO_DECODER, RM_DEVICE_OPT_MAIN, RM_STATE_EXCLUSIVE);\r
-       player2->AddResource(RM_CATEGORY_SCALER_SUB, RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player2->Register());\r
-       EXPECT_EQ(RM_OK, player2->AllocateResources());\r
-\r
-       EXPECT_EQ(1, player->GetConflictNum());\r
-       EXPECT_EQ(2, player->GetConflictedResourcesNum());\r
-\r
-       EXPECT_EQ(RM_OK, player->Unregister());\r
-       EXPECT_EQ(RM_OK, player2->Unregister());\r
-\r
-       delete player;\r
-       delete player2;\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-       RM_TEST_MSG("rm_conflict11 end...");\r
-}\r
-\r
-/* issue : rsc(sub scaler) conflict\r
- */\r
-TEST(ut_rm_api, rm_conflict14)\r
-{\r
-       TCPlayer *player = new TCPlayer();\r
-       player->AddResource(RM_CATEGORY_VIDEO_DECODER, RM_DEVICE_OPT_MAIN, RM_STATE_EXCLUSIVE);\r
-       player->AddResource(RM_CATEGORY_SCALER_SUB, RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player->Register());\r
-       EXPECT_EQ(RM_OK, player->AllocateResources());\r
-\r
-       TCPlayer *player2 = new TCPlayer();\r
-       player2->AddResource(RM_CATEGORY_VIDEO_DECODER, RM_CATEGORY_VIDEO_DECODER_MPEG4_FHD_8BIT_30P, RM_STATE_EXCLUSIVE);\r
-       player2->AddResource(RM_CATEGORY_SCALER_SUB, RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player2->Register());\r
-       EXPECT_EQ(RM_OK, player2->AllocateResources());\r
-\r
-       EXPECT_EQ(1, player->GetConflictNum());\r
-       EXPECT_EQ(1, player->GetConflictedResourcesNum());\r
-\r
-       EXPECT_EQ(RM_OK, player->Unregister());\r
-       EXPECT_EQ(RM_OK, player2->Unregister());\r
-\r
-       delete player;\r
-       delete player2;\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-}\r
-\r
-/* issue : rsc(sub scaler) conflict\r
- */\r
-TEST(ut_rm_api, rm_conflict16)\r
-{\r
-       TCPlayer *player = new TCPlayer();\r
-       player->AddResource(RM_CATEGORY_VIDEO_DECODER, RM_CATEGORY_VIDEO_DECODER_MPEG4_FHD_8BIT_30P, RM_STATE_EXCLUSIVE);\r
-       player->AddResource(RM_CATEGORY_SCALER_SUB, RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player->Register());\r
-       EXPECT_EQ(RM_OK, player->AllocateResources());\r
-\r
-       TCPlayer *player2 = new TCPlayer();\r
-       player2->AddResource(RM_CATEGORY_VIDEO_DECODER, RM_CATEGORY_VIDEO_DECODER_MPEG4_FHD_8BIT_30P, RM_STATE_EXCLUSIVE);\r
-       player2->AddResource(RM_CATEGORY_SCALER_SUB, RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player2->Register());\r
-       EXPECT_EQ(RM_OK, player2->AllocateResources());\r
-\r
-       EXPECT_EQ(1, player->GetConflictNum());\r
-       EXPECT_EQ(1, player->GetConflictedResourcesNum());\r
-\r
-       EXPECT_EQ(RM_OK, player->Unregister());\r
-       EXPECT_EQ(RM_OK, player2->Unregister());\r
-\r
-       delete player;\r
-       delete player2;\r
-\r
-       sleep(RM_TEST_SLEEP_TIME);\r
-}
\ No newline at end of file
+/*
+ * Copyright (c) 2024 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 "gtest/gtest.h"
+#include <unistd.h>
+
+#include <rm_api.h>
+#include <rm_module_api.h>
+#include <stdlib.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include <rm_debug.h>
+#include <dlog.h>
+#include <sys/stat.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <ut_common.h>
+#include <TCPlayer.h>
+
+rm_cb_result rsc_conflict_cb(int handle, rm_callback_type event, rm_device_request_s *info, void *data)
+{
+       RM_TEST_MSG("resource conflict cb invoked!");
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, info));
+       return RM_CB_RESULT_OK;
+}
+
+TEST(ut_rm_api, rm_get_scaler_state_p1)
+{
+       RM_TEST_MSG("rm_get_scaler_state_p1 start...");
+
+       int handle;
+
+       EXPECT_EQ(RM_OK, rm_register(rsc_conflict_cb, NULL, &handle, NULL));
+
+       rm_category_request_s req;
+       memset(&req, 0, sizeof(req));
+
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(allocated));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated.device_id[0]));
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       rm_resource_list_h scaler_list_h;
+       int result = rm_get_scaler_state(&scaler_list_h);
+       EXPECT_EQ(RM_OK, result);
+
+       if (result != RM_OK) {
+               RM_TEST_MSG("rm_get_scaler_state_p1 end...");
+               rm_free_resource_list(scaler_list_h);
+               return;
+       }
+
+       EXPECT_EQ(2, rm_resource_list_get_count(scaler_list_h));
+
+       // main scaler
+       rm_resource_h rsc = rm_resource_list_get_first(scaler_list_h);
+       EXPECT_EQ(RM_CATEGORY_SCALER, rm_resource_get_category(rsc));
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(rsc));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(rsc));
+       EXPECT_EQ(-1, rm_resource_get_consumer(rsc));
+       EXPECT_STREQ("", rm_resource_get_app_id(rsc));
+
+       // sub scaler
+       rsc = rm_resource_list_get_next(scaler_list_h);
+       EXPECT_EQ(RM_CATEGORY_SCALER_SUB, rm_resource_get_category(rsc));
+       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_resource_get_id(rsc));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(rsc));
+       EXPECT_EQ(-1, rm_resource_get_consumer(rsc));
+       EXPECT_STREQ("", rm_resource_get_app_id(rsc));
+
+       rm_free_resource_list(scaler_list_h);
+
+       RM_TEST_MSG("rm_get_scaler_state_p1 end...");
+}
+
+TEST(ut_rm_api, rm_get_scaler_state_p2)
+{
+       RM_TEST_MSG("rm_get_scaler_state_p2 start...");
+
+       int handle;
+       char *app_id1 = (char*) "org.tizen.rsc.test";
+
+       EXPECT_EQ(RM_OK, rm_register(rsc_conflict_cb, NULL, &handle, NULL));
+       EXPECT_EQ(RM_OK, rm_set_app_id(handle, app_id1));
+
+       rm_category_request_s req;
+       memset(&req, 0, sizeof(req));
+
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(allocated));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated.device_id[0]));
+
+
+       rm_resource_list_h scaler_list_h;
+       int result = rm_get_scaler_state(&scaler_list_h);
+       EXPECT_EQ(RM_OK, result);
+
+       if (result != RM_OK) {
+               EXPECT_EQ(RM_OK, rm_unregister(handle));
+               rm_free_resource_list(scaler_list_h);
+               RM_TEST_MSG("rm_get_scaler_state_p2 end...");
+               return;
+       }
+
+       EXPECT_EQ(2, rm_resource_list_get_count(scaler_list_h));
+
+       // main scaler
+       rm_resource_h rsc = rm_resource_list_get_first(scaler_list_h);
+       EXPECT_EQ(RM_CATEGORY_SCALER, rm_resource_get_category(rsc));
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_resource_get_id(rsc));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, rm_resource_get_state(rsc));
+       EXPECT_EQ(handle, rm_resource_get_consumer(rsc));
+       EXPECT_STREQ(app_id1, rm_resource_get_app_id(rsc));
+
+       // sub scaler
+       rsc = rm_resource_list_get_next(scaler_list_h);
+       EXPECT_EQ(RM_CATEGORY_SCALER_SUB, rm_resource_get_category(rsc));
+       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_resource_get_id(rsc));
+       EXPECT_EQ(RM_RSC_STATE_FREE, rm_resource_get_state(rsc));
+       EXPECT_EQ(-1, rm_resource_get_consumer(rsc));
+       EXPECT_STREQ("", rm_resource_get_app_id(rsc));
+
+       rm_free_resource_list(scaler_list_h);
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+       RM_TEST_MSG("rm_get_scaler_state_p2 end...");
+}
+
+/* issue : video decoder(mem cluster) conflict & rsc(sub scaler) conflict
+ */
+TEST(ut_rm_api, rm_conflict11)
+{
+       RM_TEST_MSG("rm_conflict11 start...");
+
+       TCPlayer *player = new TCPlayer();
+       player->AddResource(RM_CATEGORY_VIDEO_DECODER, RM_DEVICE_OPT_MAIN, RM_STATE_EXCLUSIVE);
+       player->AddResource(RM_CATEGORY_SCALER_SUB, RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player->Register());
+       EXPECT_EQ(RM_OK, player->AllocateResources());
+
+       TCPlayer *player2 = new TCPlayer();
+       player2->AddResource(RM_CATEGORY_VIDEO_DECODER, RM_DEVICE_OPT_MAIN, RM_STATE_EXCLUSIVE);
+       player2->AddResource(RM_CATEGORY_SCALER_SUB, RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player2->Register());
+       EXPECT_EQ(RM_OK, player2->AllocateResources());
+
+       EXPECT_EQ(1, player->GetConflictNum());
+       EXPECT_EQ(2, player->GetConflictedResourcesNum());
+
+       EXPECT_EQ(RM_OK, player->Unregister());
+       EXPECT_EQ(RM_OK, player2->Unregister());
+
+       delete player;
+       delete player2;
+
+       sleep(RM_TEST_SLEEP_TIME);
+       RM_TEST_MSG("rm_conflict11 end...");
+}
+
+/* issue : rsc(sub scaler) conflict
+ */
+TEST(ut_rm_api, rm_conflict14)
+{
+       TCPlayer *player = new TCPlayer();
+       player->AddResource(RM_CATEGORY_VIDEO_DECODER, RM_DEVICE_OPT_MAIN, RM_STATE_EXCLUSIVE);
+       player->AddResource(RM_CATEGORY_SCALER_SUB, RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player->Register());
+       EXPECT_EQ(RM_OK, player->AllocateResources());
+
+       TCPlayer *player2 = new TCPlayer();
+       player2->AddResource(RM_CATEGORY_VIDEO_DECODER, RM_CATEGORY_VIDEO_DECODER_MPEG4_FHD_8BIT_30P, RM_STATE_EXCLUSIVE);
+       player2->AddResource(RM_CATEGORY_SCALER_SUB, RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player2->Register());
+       EXPECT_EQ(RM_OK, player2->AllocateResources());
+
+       EXPECT_EQ(1, player->GetConflictNum());
+       EXPECT_EQ(1, player->GetConflictedResourcesNum());
+
+       EXPECT_EQ(RM_OK, player->Unregister());
+       EXPECT_EQ(RM_OK, player2->Unregister());
+
+       delete player;
+       delete player2;
+
+       sleep(RM_TEST_SLEEP_TIME);
+}
+
+/* issue : rsc(sub scaler) conflict
+ */
+TEST(ut_rm_api, rm_conflict16)
+{
+       TCPlayer *player = new TCPlayer();
+       player->AddResource(RM_CATEGORY_VIDEO_DECODER, RM_CATEGORY_VIDEO_DECODER_MPEG4_FHD_8BIT_30P, RM_STATE_EXCLUSIVE);
+       player->AddResource(RM_CATEGORY_SCALER_SUB, RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player->Register());
+       EXPECT_EQ(RM_OK, player->AllocateResources());
+
+       TCPlayer *player2 = new TCPlayer();
+       player2->AddResource(RM_CATEGORY_VIDEO_DECODER, RM_CATEGORY_VIDEO_DECODER_MPEG4_FHD_8BIT_30P, RM_STATE_EXCLUSIVE);
+       player2->AddResource(RM_CATEGORY_SCALER_SUB, RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player2->Register());
+       EXPECT_EQ(RM_OK, player2->AllocateResources());
+
+       EXPECT_EQ(1, player->GetConflictNum());
+       EXPECT_EQ(1, player->GetConflictedResourcesNum());
+
+       EXPECT_EQ(RM_OK, player->Unregister());
+       EXPECT_EQ(RM_OK, player2->Unregister());
+
+       delete player;
+       delete player2;
+
+       sleep(RM_TEST_SLEEP_TIME);
+}
index e64d59332d81abcfeed9e1123c5ea44229971a2d..8361dc64e076eb0628783f8f69414ac42c04e734 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "gtest/gtest.h"\r
-#include <unistd.h>\r
-\r
-#include <rm_api.h>\r
-#include <stdlib.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include <rm_debug.h>\r
-#include <dlog.h>\r
-#include <sys/stat.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-\r
-#include <ut_common.h>\r
-\r
-TEST(ut_rm_api, alloc_ai_video_dec_hevc_fhd_p1)\r
-{\r
-       RM_TEST_MSG("alloc_ai_video_dec_hevc_fhd_p1 start...");\r
-\r
-       int handle = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "HEVC";\r
-       option.color_depth = 8;\r
-       option.framerate = 30;\r
-       option.h_size = 1920;\r
-       option.v_size = 1080;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_ai_decoder_category_id(ri_get_capable_video_category_id(&option));\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-\r
-       int expected = is_support_8k() ? RM_DEVICE_VIDEO_DECODER_HEVC_8K : RM_DEVICE_VIDEO_DECODER_DVDE0;\r
-\r
-       EXPECT_EQ(expected, allocated.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_ai_video_dec_hevc_fhd_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_ai_video_dec_hevc_uhd_p1)\r
-{\r
-       RM_TEST_MSG("alloc_ai_video_dec_hevc_uhd_p1 start...");\r
-\r
-       int handle = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "HEVC";\r
-       option.color_depth = 8;\r
-       option.framerate = 30;\r
-       option.h_size = 3840;\r
-       option.v_size = 2160;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_ai_decoder_category_id(ri_get_capable_video_category_id(&option));\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-\r
-       int expected = is_support_8k() ? RM_DEVICE_VIDEO_DECODER_HEVC_8K : RM_DEVICE_VIDEO_DECODER_DVDE0;\r
-\r
-       EXPECT_EQ(expected, allocated.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_ai_video_dec_hevc_uhd_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_ai_video_dec_hevc_8k_p1)\r
-{\r
-       RM_TEST_MSG("alloc_ai_video_dec_hevc_8k_p1 start...");\r
-\r
-       int handle = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "HEVC";\r
-       option.color_depth = 8;\r
-       option.framerate = 60;\r
-       option.h_size = 7680;\r
-       option.v_size = 4320;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_capable_video_category_id(&option);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       if (is_support_8k()) {\r
-               EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-               EXPECT_EQ(1, allocated.allocated_num);\r
-               EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_HEVC_8K, allocated.device_id[0]);\r
-       } else {\r
-               EXPECT_NE(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-               EXPECT_EQ(0, allocated.allocated_num);\r
-       }\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_ai_video_dec_hevc_8k_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_ai_video_dec_av1_fhd_p1)\r
-{\r
-       RM_TEST_MSG("alloc_ai_video_dec_av1_fhd_p1 start...");\r
-\r
-       int handle = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "AV1";\r
-       option.color_depth = 8;\r
-       option.framerate = 30;\r
-       option.h_size = 1920;\r
-       option.v_size = 1080;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_ai_decoder_category_id(ri_get_capable_video_category_id(&option));\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-\r
-       int expected = is_support_8k() ? RM_DEVICE_VIDEO_DECODER_HEVC_8K : RM_DEVICE_VIDEO_DECODER_DVDE0;\r
-\r
-       EXPECT_EQ(expected, allocated.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_ai_video_dec_av1_fhd_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_ai_video_dec_av1_uhd_p1)\r
-{\r
-       RM_TEST_MSG("alloc_ai_video_dec_av1_uhd_p1 start...");\r
-\r
-       int handle = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "AV1";\r
-       option.color_depth = 8;\r
-       option.framerate = 30;\r
-       option.h_size = 3840;\r
-       option.v_size = 2160;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_ai_decoder_category_id(ri_get_capable_video_category_id(&option));\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-\r
-       int expected = is_support_8k() ? RM_DEVICE_VIDEO_DECODER_HEVC_8K : RM_DEVICE_VIDEO_DECODER_DVDE0;\r
-\r
-       EXPECT_EQ(expected, allocated.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_ai_video_dec_av1_uhd_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_ai_video_dec_av1_8k_p1)\r
-{\r
-       RM_TEST_MSG("alloc_ai_video_dec_av1_8k_p1 start...");\r
-\r
-       int handle = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "AV1";\r
-       option.color_depth = 8;\r
-       option.framerate = 60;\r
-       option.h_size = 7680;\r
-       option.v_size = 4320;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_capable_video_category_id(&option);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       if (is_support_8k()) {\r
-               EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-               EXPECT_EQ(1, allocated.allocated_num);\r
-               EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_HEVC_8K, allocated.device_id[0]);\r
-       } else {\r
-               EXPECT_NE(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-               EXPECT_EQ(0, allocated.allocated_num);\r
-       }\r
-\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_ai_video_dec_av1_8k_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_ai_video_dec_h264_n1)\r
-{\r
-       RM_TEST_MSG("alloc_ai_video_dec_h264_n1 start...");\r
-\r
-       int handle = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "H264";\r
-       option.color_depth = 8;\r
-       option.framerate = 30;\r
-       option.h_size = 1920;\r
-       option.v_size = 1080;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_ai_decoder_category_id(ri_get_capable_video_category_id(&option));\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_NE(RM_DEVICE_VIDEO_DECODER_DVDE0, allocated.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_ai_video_dec_h264_n1 end...");\r
-}\r
+/*
+ * Copyright (c) 2024 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 "gtest/gtest.h"
+#include <unistd.h>
+
+#include <rm_api.h>
+#include <stdlib.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include <rm_debug.h>
+#include <dlog.h>
+#include <sys/stat.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <ut_common.h>
+
+TEST(ut_rm_api, alloc_ai_video_dec_hevc_fhd_p1)
+{
+       RM_TEST_MSG("alloc_ai_video_dec_hevc_fhd_p1 start...");
+
+       int handle = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "HEVC";
+       option.color_depth = 8;
+       option.framerate = 30;
+       option.h_size = 1920;
+       option.v_size = 1080;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_ai_decoder_category_id(ri_get_capable_video_category_id(&option));
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+       EXPECT_EQ(1, allocated.allocated_num);
+
+       int expected = is_support_8k() ? RM_DEVICE_VIDEO_DECODER_HEVC_8K : RM_DEVICE_VIDEO_DECODER_DVDE0;
+
+       EXPECT_EQ(expected, allocated.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_ai_video_dec_hevc_fhd_p1 end...");
+}
+
+TEST(ut_rm_api, alloc_ai_video_dec_hevc_uhd_p1)
+{
+       RM_TEST_MSG("alloc_ai_video_dec_hevc_uhd_p1 start...");
+
+       int handle = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "HEVC";
+       option.color_depth = 8;
+       option.framerate = 30;
+       option.h_size = 3840;
+       option.v_size = 2160;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_ai_decoder_category_id(ri_get_capable_video_category_id(&option));
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+       EXPECT_EQ(1, allocated.allocated_num);
+
+       int expected = is_support_8k() ? RM_DEVICE_VIDEO_DECODER_HEVC_8K : RM_DEVICE_VIDEO_DECODER_DVDE0;
+
+       EXPECT_EQ(expected, allocated.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_ai_video_dec_hevc_uhd_p1 end...");
+}
+
+TEST(ut_rm_api, alloc_ai_video_dec_hevc_8k_p1)
+{
+       RM_TEST_MSG("alloc_ai_video_dec_hevc_8k_p1 start...");
+
+       int handle = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "HEVC";
+       option.color_depth = 8;
+       option.framerate = 60;
+       option.h_size = 7680;
+       option.v_size = 4320;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_capable_video_category_id(&option);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       if (is_support_8k()) {
+               EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+               EXPECT_EQ(1, allocated.allocated_num);
+               EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_HEVC_8K, allocated.device_id[0]);
+       } else {
+               EXPECT_NE(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+               EXPECT_EQ(0, allocated.allocated_num);
+       }
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_ai_video_dec_hevc_8k_p1 end...");
+}
+
+TEST(ut_rm_api, alloc_ai_video_dec_av1_fhd_p1)
+{
+       RM_TEST_MSG("alloc_ai_video_dec_av1_fhd_p1 start...");
+
+       int handle = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "AV1";
+       option.color_depth = 8;
+       option.framerate = 30;
+       option.h_size = 1920;
+       option.v_size = 1080;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_ai_decoder_category_id(ri_get_capable_video_category_id(&option));
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+       EXPECT_EQ(1, allocated.allocated_num);
+
+       int expected = is_support_8k() ? RM_DEVICE_VIDEO_DECODER_HEVC_8K : RM_DEVICE_VIDEO_DECODER_DVDE0;
+
+       EXPECT_EQ(expected, allocated.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_ai_video_dec_av1_fhd_p1 end...");
+}
+
+TEST(ut_rm_api, alloc_ai_video_dec_av1_uhd_p1)
+{
+       RM_TEST_MSG("alloc_ai_video_dec_av1_uhd_p1 start...");
+
+       int handle = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "AV1";
+       option.color_depth = 8;
+       option.framerate = 30;
+       option.h_size = 3840;
+       option.v_size = 2160;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_ai_decoder_category_id(ri_get_capable_video_category_id(&option));
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+       EXPECT_EQ(1, allocated.allocated_num);
+
+       int expected = is_support_8k() ? RM_DEVICE_VIDEO_DECODER_HEVC_8K : RM_DEVICE_VIDEO_DECODER_DVDE0;
+
+       EXPECT_EQ(expected, allocated.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_ai_video_dec_av1_uhd_p1 end...");
+}
+
+TEST(ut_rm_api, alloc_ai_video_dec_av1_8k_p1)
+{
+       RM_TEST_MSG("alloc_ai_video_dec_av1_8k_p1 start...");
+
+       int handle = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "AV1";
+       option.color_depth = 8;
+       option.framerate = 60;
+       option.h_size = 7680;
+       option.v_size = 4320;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_capable_video_category_id(&option);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       if (is_support_8k()) {
+               EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+               EXPECT_EQ(1, allocated.allocated_num);
+               EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_HEVC_8K, allocated.device_id[0]);
+       } else {
+               EXPECT_NE(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+               EXPECT_EQ(0, allocated.allocated_num);
+       }
+
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_ai_video_dec_av1_8k_p1 end...");
+}
+
+TEST(ut_rm_api, alloc_ai_video_dec_h264_n1)
+{
+       RM_TEST_MSG("alloc_ai_video_dec_h264_n1 start...");
+
+       int handle = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "H264";
+       option.color_depth = 8;
+       option.framerate = 30;
+       option.h_size = 1920;
+       option.v_size = 1080;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_ai_decoder_category_id(ri_get_capable_video_category_id(&option));
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_NE(RM_DEVICE_VIDEO_DECODER_DVDE0, allocated.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_ai_video_dec_h264_n1 end...");
+}
index ff3a0d1a392fec1836ccd1d8b49d2cda6afc1018..4a0bf9f3d0b410da7b3cd4ee4cdc84850394ac51 100644 (file)
@@ -1,91 +1,91 @@
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "gtest/gtest.h"\r
-#include <unistd.h>\r
-\r
-#include <rm_api.h>\r
-#include <stdlib.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include <system_info.h>\r
-#include <rm_debug.h>\r
-\r
-#include <sys/stat.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-\r
-#include <ut_common.h>\r
-\r
-TEST(ut_rm_api, video_decoder_portrait_dtv_1080_1920)\r
-{\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "HEVC";\r
-       option.color_depth = 8;\r
-       option.framerate = 30;\r
-       option.h_size = 1080;\r
-       option.v_size = 1920; // Max height supported by mfc is 1080\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       EXPECT_EQ(RI_CATEGORY_VIDEO_DECODER_HEVC_UHD_8BIT_30P , ri_get_capable_video_category_id(&option));\r
-}\r
-\r
-TEST(ut_rm_api, video_decoder_portrait_dtv_720_1280)\r
-{\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "HEVC";\r
-       option.color_depth = 8;\r
-       option.framerate = 30;\r
-       option.h_size = 720;\r
-       option.v_size = 1280; // Max height supported by mfc is 1080\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       EXPECT_EQ(RI_CATEGORY_VIDEO_DECODER_HEVC_UHD_8BIT_30P , ri_get_capable_video_category_id(&option));\r
-}\r
-\r
-TEST(ut_rm_api, video_decoder_portrait_dtv_480_640)\r
-{\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "HEVC";\r
-       option.color_depth = 8;\r
-       option.framerate = 30;\r
-       option.h_size = 480;\r
-       option.v_size = 640; // Max height supported by mfc is 1080\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       EXPECT_EQ(RI_CATEGORY_VIDEO_DECODER_HEVC_FHD_8BIT_30P , ri_get_capable_video_category_id(&option));\r
-}\r
-\r
-TEST(ut_rm_api, video_decoder_portrait_dtv_2160_3840)\r
-{\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "HEVC";\r
-       option.color_depth = 8;\r
-       option.framerate = 30;\r
-       option.h_size = 2160;\r
-       option.v_size = 3840; // Max height supported by dvde is 2160\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       EXPECT_EQ(RI_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED , ri_get_capable_video_category_id(&option));\r
-}
\ No newline at end of file
+/*
+ * Copyright (c) 2024 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 "gtest/gtest.h"
+#include <unistd.h>
+
+#include <rm_api.h>
+#include <stdlib.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include <system_info.h>
+#include <rm_debug.h>
+
+#include <sys/stat.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <ut_common.h>
+
+TEST(ut_rm_api, video_decoder_portrait_dtv_1080_1920)
+{
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "HEVC";
+       option.color_depth = 8;
+       option.framerate = 30;
+       option.h_size = 1080;
+       option.v_size = 1920; // Max height supported by mfc is 1080
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       EXPECT_EQ(RI_CATEGORY_VIDEO_DECODER_HEVC_UHD_8BIT_30P , ri_get_capable_video_category_id(&option));
+}
+
+TEST(ut_rm_api, video_decoder_portrait_dtv_720_1280)
+{
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "HEVC";
+       option.color_depth = 8;
+       option.framerate = 30;
+       option.h_size = 720;
+       option.v_size = 1280; // Max height supported by mfc is 1080
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       EXPECT_EQ(RI_CATEGORY_VIDEO_DECODER_HEVC_UHD_8BIT_30P , ri_get_capable_video_category_id(&option));
+}
+
+TEST(ut_rm_api, video_decoder_portrait_dtv_480_640)
+{
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "HEVC";
+       option.color_depth = 8;
+       option.framerate = 30;
+       option.h_size = 480;
+       option.v_size = 640; // Max height supported by mfc is 1080
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       EXPECT_EQ(RI_CATEGORY_VIDEO_DECODER_HEVC_FHD_8BIT_30P , ri_get_capable_video_category_id(&option));
+}
+
+TEST(ut_rm_api, video_decoder_portrait_dtv_2160_3840)
+{
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "HEVC";
+       option.color_depth = 8;
+       option.framerate = 30;
+       option.h_size = 2160;
+       option.v_size = 3840; // Max height supported by dvde is 2160
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       EXPECT_EQ(RI_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED , ri_get_capable_video_category_id(&option));
+}
index 26a8676fec1d9c4e1ea4a66d6aaa6d2c033d6df1..85ce93a33f423192a71d830ed1aba8e6371ccfe5 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "gtest/gtest.h"\r
-#include <unistd.h>\r
-\r
-#include <rm_api.h>\r
-#include <rm_module_api.h>\r
-#include <stdlib.h>\r
-#include <TCPlayer.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include <rm_debug.h>\r
-#include <dlog.h>\r
-#include <sys/stat.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-\r
-#include <ut_common.h>\r
-#include <TCCallbackListener.h>\r
-\r
-static int cb_handle = 0;\r
-static int cb_time = 0;\r
-\r
-rm_cb_result _conflict_cb(int handle, rm_callback_type event, rm_device_request_s *info, void *data)\r
-{\r
-       cb_handle = handle;\r
-       cb_time++;\r
-       rm_unregister(handle);\r
-       return RM_CB_RESULT_OK;\r
-}\r
-\r
-void _reset_cb_info(void)\r
-{\r
-       cb_handle = -1;\r
-       cb_time = 0;\r
-}\r
-\r
-int _get_conflict_num(void)\r
-{\r
-       return cb_time;\r
-}\r
-\r
-int _get_conflict_handle(void)\r
-{\r
-       return cb_handle;\r
-}\r
-\r
-TEST(ut_rm_api, rm_virtual_scaler_p1)\r
-{\r
-       RM_TEST_MSG("rm_virtual_scaler_p1 start...");\r
-\r
-       int handle = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s req;\r
-       memset(&req, 0, sizeof(rm_category_request_s));\r
-\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated.device_id[0]));\r
-\r
-       rm_resource_state_e state;\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);\r
-\r
-       rm_device_request_s req_release;\r
-       memset(&req_release, 0, sizeof(rm_device_request_s));\r
-\r
-       req_release.request_num = 1;\r
-       req_release.device_id[0] = allocated.device_id[0];\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, &req_release));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, state);\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("rm_virtual_scaler_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_virtual_scaler_p2)\r
-{\r
-       RM_TEST_MSG("rm_virtual_scaler_p2 start...");\r
-\r
-       // Step#1 Allocate main scaler\r
-       int handle = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s req;\r
-       memset(&req, 0, sizeof(rm_category_request_s));\r
-\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated.device_id[0]));\r
-\r
-       rm_resource_state_e state;\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);\r
-\r
-       // Step#2 Allocate sub scaler\r
-       int handle2 = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle2, NULL));\r
-\r
-       memset(&req, 0, sizeof(rm_category_request_s));\r
-\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER_SUB;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated2;\r
-       memset(&allocated2, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &req, &allocated2));\r
-\r
-       EXPECT_EQ(1, allocated2.allocated_num);\r
-       EXPECT_EQ((RI_VIRTUAL_ID_SCALER + 1), allocated2.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated2.device_id[0]));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);\r
-\r
-       // Step#3 Release main scaler\r
-       rm_device_request_s req_release;\r
-       memset(&req_release, 0, sizeof(rm_device_request_s));\r
-\r
-       req_release.request_num = 1;\r
-       req_release.device_id[0] = allocated.device_id[0];\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, &req_release));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, state);\r
-\r
-       // Step#4 Release sub scaler\r
-       memset(&req_release, 0, sizeof(rm_device_request_s));\r
-\r
-       req_release.request_num = 1;\r
-       req_release.device_id[0] = allocated2.device_id[0];\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle2, &req_release));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, state);\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-\r
-       RM_TEST_MSG("rm_virtual_scaler_p2 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_virtual_scaler_p3)\r
-{\r
-       RM_TEST_MSG("rm_virtual_scaler_p3 start...");\r
-\r
-       // Step#1 Allocate sub scaler\r
-       int handle = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s req;\r
-       memset(&req, 0, sizeof(rm_category_request_s));\r
-\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER_SUB;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated.device_id[0]));\r
-\r
-       rm_resource_state_e state;\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);\r
-\r
-       // Step#2 Allocate main scaler\r
-       int handle2 = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle2, NULL));\r
-\r
-       memset(&req, 0, sizeof(rm_category_request_s));\r
-\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated2;\r
-       memset(&allocated2, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &req, &allocated2));\r
-\r
-       EXPECT_EQ(1, allocated2.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated2.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated2.device_id[0]));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);\r
-\r
-       // Step#3 Release sub scaler\r
-       rm_device_request_s req_release;\r
-       memset(&req_release, 0, sizeof(rm_device_request_s));\r
-\r
-       req_release.request_num = 1;\r
-       req_release.device_id[0] = allocated.device_id[0];\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, &req_release));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, state);\r
-\r
-       // Step#4 Release main scaler\r
-       memset(&req_release, 0, sizeof(rm_device_request_s));\r
-\r
-       req_release.request_num = 1;\r
-       req_release.device_id[0] = allocated2.device_id[0];\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle2, &req_release));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, state);\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-\r
-       RM_TEST_MSG("rm_virtual_scaler_p3 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_virtual_scaler_p4)\r
-{\r
-       RM_TEST_MSG("rm_virtual_scaler_p4 start...");\r
-       _reset_cb_info();\r
-\r
-       /* TEST SCENARIO\r
-       *  1. Allocate main scaler\r
-       *  2. Allocate main scaler (conflict with player 1)\r
-       */\r
-\r
-       TCPlayer *player = new TCPlayer();\r
-       player->AddResource(RM_CATEGORY_SCALER, RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player->Register());\r
-       EXPECT_EQ(RM_OK, player->AllocateResources());\r
-\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, player->GetAllocatedResourceId(1));\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(player->GetAllocatedResourceId(1)));\r
-\r
-       rm_resource_state_e state;\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);\r
-\r
-       TCPlayer *player2 = new TCPlayer();\r
-       player2->AddResource(RM_CATEGORY_SCALER, RM_STATE_EXCLUSIVE);\r
-\r
-       EXPECT_EQ(RM_OK, player2->Register());\r
-       EXPECT_EQ(RM_OK, player2->AllocateResources());\r
-\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, player2->GetAllocatedResourceId(1));\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(player2->GetAllocatedResourceId(1)));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);\r
-\r
-       EXPECT_EQ(1, player->GetConflictNum());\r
-       EXPECT_EQ(1, player->GetConflictedResourcesNum());\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, player->GetConflictedResourceId(1));\r
-\r
-       EXPECT_NE(RM_OK, player->ReleaseResource(1));\r
-       EXPECT_EQ(RM_OK, player2->ReleaseResource(1));\r
-\r
-       EXPECT_EQ(RM_OK, player->Unregister());\r
-       EXPECT_EQ(RM_OK, player2->Unregister());\r
-\r
-       delete player;\r
-       delete player2;\r
-\r
-       RM_TEST_MSG("rm_virtual_scaler_p4 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_virtual_scaler_swap_p1)\r
-{\r
-       RM_TEST_MSG("rm_virtual_scaler_swap_p1 start...");\r
-\r
-       /************************************************\r
-        * 1. Allocate sub scaler (handle1)\r
-        * 2. Allocate main scaler (handle2)\r
-        * 3. Swap main scaler with sub\r
-        * 4. Release main scaler (handle1)\r
-        * 5. Release sub scaler (handle2)\r
-        *************************************************/\r
-\r
-       // Step#1 Allocate sub scaler\r
-       int handle = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s req;\r
-       memset(&req, 0, sizeof(rm_category_request_s));\r
-\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER_SUB;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated.device_id[0]));\r
-\r
-       rm_resource_state_e state;\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);\r
-\r
-       // Step#2 Allocate main scaler\r
-       int handle2 = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle2, NULL));\r
-\r
-       memset(&req, 0, sizeof(rm_category_request_s));\r
-\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated2;\r
-       memset(&allocated2, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &req, &allocated2));\r
-\r
-       EXPECT_EQ(1, allocated2.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated2.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated2.device_id[0]));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);\r
-\r
-       // Step#3 Swap main scaler with sub\r
-       EXPECT_EQ(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_SCALER_SUB));\r
-\r
-       // Step#4 Release main scaler\r
-       rm_device_request_s req_release;\r
-       memset(&req_release, 0, sizeof(rm_device_request_s));\r
-\r
-       req_release.request_num = 1;\r
-       req_release.device_id[0] = allocated.device_id[0];\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, &req_release));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, state);\r
-\r
-       // Step#5 Release sub scaler\r
-       memset(&req_release, 0, sizeof(rm_device_request_s));\r
-\r
-       req_release.request_num = 1;\r
-       req_release.device_id[0] = allocated2.device_id[0];\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle2, &req_release));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, state);\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-\r
-       // restore\r
-       EXPECT_EQ(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_SCALER_SUB));\r
-\r
-       RM_TEST_MSG("rm_virtual_scaler_swap_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_virtual_scaler_swap_p2)\r
-{\r
-       RM_TEST_MSG("rm_virtual_scaler_swap_p2 start...");\r
-\r
-       /************************************************\r
-        * 1. Allocate sub scaler (handle1) 10000:sub\r
-        * 2. Allocate main scaler (handle2) 10001:main\r
-        * 3. Swap main scaler with sub : 10000:main 10001:sub\r
-        * 4. Try to allocate main scaler (handle3)\r
-        *    - Conflict with handle1\r
-        * 4. Release main scaler (handle3)\r
-        * 5. Release sub scaler (handle2)\r
-        *************************************************/\r
-\r
-       _reset_cb_info();\r
-\r
-       // Step#1 Allocate sub scaler\r
-       int handle = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s req;\r
-       memset(&req, 0, sizeof(rm_category_request_s));\r
-\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER_SUB;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));\r
-\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated.device_id[0]));\r
-\r
-       rm_resource_state_e state;\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);\r
-\r
-       // Step#2 Allocate main scaler\r
-       int handle2 = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle2, NULL));\r
-\r
-       memset(&req, 0, sizeof(rm_category_request_s));\r
-\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated2;\r
-       memset(&allocated2, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &req, &allocated2));\r
-\r
-       EXPECT_EQ(1, allocated2.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated2.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated2.device_id[0]));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);\r
-\r
-       // Step#3 Swap main scaler with sub\r
-       EXPECT_EQ(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_SCALER_SUB));\r
-\r
-       // Step#4 Try to allocate main scaler (handle3)\r
-       int handle3 = 0;\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle3, NULL));\r
-\r
-       memset(&req, 0, sizeof(rm_category_request_s));\r
-       req.request_num = 1;\r
-       req.category_id[0] = RM_CATEGORY_SCALER;\r
-       req.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated3;\r
-       memset(&allocated3, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, &req, &allocated3));\r
-\r
-       sleep(1);\r
-\r
-       EXPECT_EQ(1, allocated3.allocated_num);\r
-       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated3.device_id[0]);\r
-       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated3.device_id[0]));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);\r
-\r
-       EXPECT_EQ(handle, _get_conflict_handle());\r
-       EXPECT_EQ(1, _get_conflict_num());\r
-\r
-       // Step#5 Release main scaler (handle3)\r
-       rm_device_request_s req_release;\r
-       memset(&req_release, 0, sizeof(rm_device_request_s));\r
-\r
-       req_release.request_num = 1;\r
-       req_release.device_id[0] = allocated.device_id[0];\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle3, &req_release));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, state);\r
-\r
-       // Step#6 Release sub scaler (handle2)\r
-       memset(&req_release, 0, sizeof(rm_device_request_s));\r
-\r
-       req_release.request_num = 1;\r
-       req_release.device_id[0] = allocated2.device_id[0];\r
-\r
-       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle2, &req_release));\r
-\r
-       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));\r
-       EXPECT_EQ(RM_RSC_STATE_FREE, state);\r
-\r
-       EXPECT_NE(RM_OK, rm_unregister(handle)); // already unregistered by callback\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle2));\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle3));\r
-\r
-       //restore\r
-       EXPECT_EQ(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_SCALER_SUB));\r
-\r
-       RM_TEST_MSG("rm_virtual_scaler_swap_p2 end...");\r
-}\r
-\r
-\r
-\r
-TEST(ut_rm_api, rm_virtual_scaler_swap_n1)\r
-{\r
-       RM_TEST_MSG("rm_virtual_scaler_swap_n1 start...");\r
-\r
-       EXPECT_NE(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_TUNER));\r
-\r
-       RM_TEST_MSG("rm_virtual_scaler_swap_n1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_virtual_scaler_swap_n2)\r
-{\r
-       RM_TEST_MSG("rm_virtual_scaler_swap_n2 start...");\r
-\r
-       EXPECT_NE(RM_OK, rm_swap_resources(RM_DEVICE_VIDEO_DECODER_MAIN, RM_DEVICE_VIDEO_DECODER_SUB));\r
-\r
-       RM_TEST_MSG("rm_virtual_scaler_swap_n2 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_scaler_changed_cb_p1)\r
-{\r
-       RM_TEST_MSG("rm_scaler_changed_cb_p1 start...");\r
-\r
-       TCCallbackListener *listener = new TCCallbackListener();\r
-\r
-       EXPECT_EQ(RM_OK, listener->RegisterScalerStateChangeCb());\r
-       EXPECT_EQ(RM_OK, listener->UnregisterScalerStateChangeCb());\r
-\r
-       delete listener;\r
-\r
-       RM_TEST_MSG("rm_scaler_changed_cb_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, rm_scaler_changed_cb_n1)\r
-{\r
-       RM_TEST_MSG("rm_scaler_changed_cb_n1 start...");\r
-\r
-       TCCallbackListener *listener = new TCCallbackListener();\r
-\r
-       EXPECT_EQ(RM_OK, listener->RegisterScalerStateChangeCb());\r
-       EXPECT_NE(RM_OK, listener->RegisterScalerStateChangeCb());\r
-\r
-       EXPECT_EQ(RM_OK, listener->UnregisterScalerStateChangeCb());\r
-       EXPECT_NE(RM_OK, listener->UnregisterScalerStateChangeCb());\r
-\r
-       delete listener;\r
-\r
-       RM_TEST_MSG("rm_scaler_changed_cb_n1 end...");\r
-}\r
-\r
-int _get_source_id(int device_id)\r
-{\r
-       if (device_id == RM_DEVICE_SCALER)\r
-               return 0;\r
-       if (device_id == RM_DEVICE_SCALER_SUB)\r
-               return 1;\r
-       return 99;\r
-}\r
-\r
-#if 0 // Resource manager server doesn't send a dbus signal (disabled feature)\r
-TEST(ut_rm_api, rm_scaler_changed_cb_p2)\r
-{\r
-       RM_TEST_MSG("rm_scaler_changed_cb_p2 start...");\r
-\r
-       TCCallbackListener *listener = new TCCallbackListener();\r
-\r
-       EXPECT_EQ(RM_OK, listener->RegisterScalerStateChangeCb());\r
-\r
-       EXPECT_EQ(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_SCALER_SUB));\r
-\r
-       sleep(2);\r
-\r
-       EXPECT_EQ(1, listener->GetNotificationNum());\r
-       EXPECT_EQ(1, listener->IsIncluded(RI_VIRTUAL_ID_SCALER + 1, _get_source_id(RM_DEVICE_SCALER)));\r
-       EXPECT_EQ(1, listener->IsIncluded(RI_VIRTUAL_ID_SCALER, _get_source_id(RM_DEVICE_SCALER_SUB)));\r
-\r
-       EXPECT_EQ(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_SCALER_SUB));\r
-\r
-       sleep(2);\r
-\r
-       EXPECT_EQ(2, listener->GetNotificationNum());\r
-       EXPECT_EQ(1, listener->IsIncluded(RI_VIRTUAL_ID_SCALER, _get_source_id(RM_DEVICE_SCALER)));\r
-       EXPECT_EQ(1, listener->IsIncluded(RI_VIRTUAL_ID_SCALER + 1, _get_source_id(RM_DEVICE_SCALER_SUB)));\r
-\r
-       EXPECT_EQ(RM_OK, listener->UnregisterScalerStateChangeCb());\r
-\r
-       delete listener;\r
-\r
-       RM_TEST_MSG("rm_scaler_changed_cb_p2 end...");\r
-}\r
-#endif//0\r
+/*
+ * Copyright (c) 2024 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 "gtest/gtest.h"
+#include <unistd.h>
+
+#include <rm_api.h>
+#include <rm_module_api.h>
+#include <stdlib.h>
+#include <TCPlayer.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include <rm_debug.h>
+#include <dlog.h>
+#include <sys/stat.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <ut_common.h>
+#include <TCCallbackListener.h>
+
+static int cb_handle = 0;
+static int cb_time = 0;
+
+rm_cb_result _conflict_cb(int handle, rm_callback_type event, rm_device_request_s *info, void *data)
+{
+       cb_handle = handle;
+       cb_time++;
+       rm_unregister(handle);
+       return RM_CB_RESULT_OK;
+}
+
+void _reset_cb_info(void)
+{
+       cb_handle = -1;
+       cb_time = 0;
+}
+
+int _get_conflict_num(void)
+{
+       return cb_time;
+}
+
+int _get_conflict_handle(void)
+{
+       return cb_handle;
+}
+
+TEST(ut_rm_api, rm_virtual_scaler_p1)
+{
+       RM_TEST_MSG("rm_virtual_scaler_p1 start...");
+
+       int handle = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle, NULL));
+
+       rm_category_request_s req;
+       memset(&req, 0, sizeof(rm_category_request_s));
+
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated.device_id[0]));
+
+       rm_resource_state_e state;
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);
+
+       rm_device_request_s req_release;
+       memset(&req_release, 0, sizeof(rm_device_request_s));
+
+       req_release.request_num = 1;
+       req_release.device_id[0] = allocated.device_id[0];
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, &req_release));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_FREE, state);
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("rm_virtual_scaler_p1 end...");
+}
+
+TEST(ut_rm_api, rm_virtual_scaler_p2)
+{
+       RM_TEST_MSG("rm_virtual_scaler_p2 start...");
+
+       // Step#1 Allocate main scaler
+       int handle = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle, NULL));
+
+       rm_category_request_s req;
+       memset(&req, 0, sizeof(rm_category_request_s));
+
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated.device_id[0]));
+
+       rm_resource_state_e state;
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);
+
+       // Step#2 Allocate sub scaler
+       int handle2 = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle2, NULL));
+
+       memset(&req, 0, sizeof(rm_category_request_s));
+
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER_SUB;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated2;
+       memset(&allocated2, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &req, &allocated2));
+
+       EXPECT_EQ(1, allocated2.allocated_num);
+       EXPECT_EQ((RI_VIRTUAL_ID_SCALER + 1), allocated2.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated2.device_id[0]));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);
+
+       // Step#3 Release main scaler
+       rm_device_request_s req_release;
+       memset(&req_release, 0, sizeof(rm_device_request_s));
+
+       req_release.request_num = 1;
+       req_release.device_id[0] = allocated.device_id[0];
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, &req_release));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_FREE, state);
+
+       // Step#4 Release sub scaler
+       memset(&req_release, 0, sizeof(rm_device_request_s));
+
+       req_release.request_num = 1;
+       req_release.device_id[0] = allocated2.device_id[0];
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle2, &req_release));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));
+       EXPECT_EQ(RM_RSC_STATE_FREE, state);
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+
+       RM_TEST_MSG("rm_virtual_scaler_p2 end...");
+}
+
+TEST(ut_rm_api, rm_virtual_scaler_p3)
+{
+       RM_TEST_MSG("rm_virtual_scaler_p3 start...");
+
+       // Step#1 Allocate sub scaler
+       int handle = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle, NULL));
+
+       rm_category_request_s req;
+       memset(&req, 0, sizeof(rm_category_request_s));
+
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER_SUB;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated.device_id[0]));
+
+       rm_resource_state_e state;
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);
+
+       // Step#2 Allocate main scaler
+       int handle2 = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle2, NULL));
+
+       memset(&req, 0, sizeof(rm_category_request_s));
+
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated2;
+       memset(&allocated2, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &req, &allocated2));
+
+       EXPECT_EQ(1, allocated2.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated2.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated2.device_id[0]));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);
+
+       // Step#3 Release sub scaler
+       rm_device_request_s req_release;
+       memset(&req_release, 0, sizeof(rm_device_request_s));
+
+       req_release.request_num = 1;
+       req_release.device_id[0] = allocated.device_id[0];
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, &req_release));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));
+       EXPECT_EQ(RM_RSC_STATE_FREE, state);
+
+       // Step#4 Release main scaler
+       memset(&req_release, 0, sizeof(rm_device_request_s));
+
+       req_release.request_num = 1;
+       req_release.device_id[0] = allocated2.device_id[0];
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle2, &req_release));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_FREE, state);
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+
+       RM_TEST_MSG("rm_virtual_scaler_p3 end...");
+}
+
+TEST(ut_rm_api, rm_virtual_scaler_p4)
+{
+       RM_TEST_MSG("rm_virtual_scaler_p4 start...");
+       _reset_cb_info();
+
+       /* TEST SCENARIO
+       *  1. Allocate main scaler
+       *  2. Allocate main scaler (conflict with player 1)
+       */
+
+       TCPlayer *player = new TCPlayer();
+       player->AddResource(RM_CATEGORY_SCALER, RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player->Register());
+       EXPECT_EQ(RM_OK, player->AllocateResources());
+
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, player->GetAllocatedResourceId(1));
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(player->GetAllocatedResourceId(1)));
+
+       rm_resource_state_e state;
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);
+
+       TCPlayer *player2 = new TCPlayer();
+       player2->AddResource(RM_CATEGORY_SCALER, RM_STATE_EXCLUSIVE);
+
+       EXPECT_EQ(RM_OK, player2->Register());
+       EXPECT_EQ(RM_OK, player2->AllocateResources());
+
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, player2->GetAllocatedResourceId(1));
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(player2->GetAllocatedResourceId(1)));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);
+
+       EXPECT_EQ(1, player->GetConflictNum());
+       EXPECT_EQ(1, player->GetConflictedResourcesNum());
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, player->GetConflictedResourceId(1));
+
+       EXPECT_NE(RM_OK, player->ReleaseResource(1));
+       EXPECT_EQ(RM_OK, player2->ReleaseResource(1));
+
+       EXPECT_EQ(RM_OK, player->Unregister());
+       EXPECT_EQ(RM_OK, player2->Unregister());
+
+       delete player;
+       delete player2;
+
+       RM_TEST_MSG("rm_virtual_scaler_p4 end...");
+}
+
+TEST(ut_rm_api, rm_virtual_scaler_swap_p1)
+{
+       RM_TEST_MSG("rm_virtual_scaler_swap_p1 start...");
+
+       /************************************************
+        * 1. Allocate sub scaler (handle1)
+        * 2. Allocate main scaler (handle2)
+        * 3. Swap main scaler with sub
+        * 4. Release main scaler (handle1)
+        * 5. Release sub scaler (handle2)
+        *************************************************/
+
+       // Step#1 Allocate sub scaler
+       int handle = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle, NULL));
+
+       rm_category_request_s req;
+       memset(&req, 0, sizeof(rm_category_request_s));
+
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER_SUB;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated.device_id[0]));
+
+       rm_resource_state_e state;
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);
+
+       // Step#2 Allocate main scaler
+       int handle2 = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle2, NULL));
+
+       memset(&req, 0, sizeof(rm_category_request_s));
+
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated2;
+       memset(&allocated2, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &req, &allocated2));
+
+       EXPECT_EQ(1, allocated2.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated2.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated2.device_id[0]));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);
+
+       // Step#3 Swap main scaler with sub
+       EXPECT_EQ(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_SCALER_SUB));
+
+       // Step#4 Release main scaler
+       rm_device_request_s req_release;
+       memset(&req_release, 0, sizeof(rm_device_request_s));
+
+       req_release.request_num = 1;
+       req_release.device_id[0] = allocated.device_id[0];
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle, &req_release));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_FREE, state);
+
+       // Step#5 Release sub scaler
+       memset(&req_release, 0, sizeof(rm_device_request_s));
+
+       req_release.request_num = 1;
+       req_release.device_id[0] = allocated2.device_id[0];
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle2, &req_release));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));
+       EXPECT_EQ(RM_RSC_STATE_FREE, state);
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+
+       // restore
+       EXPECT_EQ(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_SCALER_SUB));
+
+       RM_TEST_MSG("rm_virtual_scaler_swap_p1 end...");
+}
+
+TEST(ut_rm_api, rm_virtual_scaler_swap_p2)
+{
+       RM_TEST_MSG("rm_virtual_scaler_swap_p2 start...");
+
+       /************************************************
+        * 1. Allocate sub scaler (handle1) 10000:sub
+        * 2. Allocate main scaler (handle2) 10001:main
+        * 3. Swap main scaler with sub : 10000:main 10001:sub
+        * 4. Try to allocate main scaler (handle3)
+        *    - Conflict with handle1
+        * 4. Release main scaler (handle3)
+        * 5. Release sub scaler (handle2)
+        *************************************************/
+
+       _reset_cb_info();
+
+       // Step#1 Allocate sub scaler
+       int handle = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle, NULL));
+
+       rm_category_request_s req;
+       memset(&req, 0, sizeof(rm_category_request_s));
+
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER_SUB;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &req, &allocated));
+
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER_SUB, rm_find_device_id(allocated.device_id[0]));
+
+       rm_resource_state_e state;
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);
+
+       // Step#2 Allocate main scaler
+       int handle2 = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle2, NULL));
+
+       memset(&req, 0, sizeof(rm_category_request_s));
+
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated2;
+       memset(&allocated2, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle2, &req, &allocated2));
+
+       EXPECT_EQ(1, allocated2.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER, allocated2.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated2.device_id[0]));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);
+
+       // Step#3 Swap main scaler with sub
+       EXPECT_EQ(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_SCALER_SUB));
+
+       // Step#4 Try to allocate main scaler (handle3)
+       int handle3 = 0;
+
+       EXPECT_EQ(RM_OK, rm_register(_conflict_cb, NULL, &handle3, NULL));
+
+       memset(&req, 0, sizeof(rm_category_request_s));
+       req.request_num = 1;
+       req.category_id[0] = RM_CATEGORY_SCALER;
+       req.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated3;
+       memset(&allocated3, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle3, &req, &allocated3));
+
+       sleep(1);
+
+       EXPECT_EQ(1, allocated3.allocated_num);
+       EXPECT_EQ(RI_VIRTUAL_ID_SCALER + 1, allocated3.device_id[0]);
+       EXPECT_EQ(RM_DEVICE_SCALER, rm_find_device_id(allocated3.device_id[0]));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_EXCLUSIVE, state);
+
+       EXPECT_EQ(handle, _get_conflict_handle());
+       EXPECT_EQ(1, _get_conflict_num());
+
+       // Step#5 Release main scaler (handle3)
+       rm_device_request_s req_release;
+       memset(&req_release, 0, sizeof(rm_device_request_s));
+
+       req_release.request_num = 1;
+       req_release.device_id[0] = allocated.device_id[0];
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle3, &req_release));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER, &state));
+       EXPECT_EQ(RM_RSC_STATE_FREE, state);
+
+       // Step#6 Release sub scaler (handle2)
+       memset(&req_release, 0, sizeof(rm_device_request_s));
+
+       req_release.request_num = 1;
+       req_release.device_id[0] = allocated2.device_id[0];
+
+       EXPECT_EQ(RM_OK, rm_deallocate_resources(handle2, &req_release));
+
+       EXPECT_EQ(RM_OK, rm_get_resource_state(RM_DEVICE_SCALER_SUB, &state));
+       EXPECT_EQ(RM_RSC_STATE_FREE, state);
+
+       EXPECT_NE(RM_OK, rm_unregister(handle)); // already unregistered by callback
+       EXPECT_EQ(RM_OK, rm_unregister(handle2));
+       EXPECT_EQ(RM_OK, rm_unregister(handle3));
+
+       //restore
+       EXPECT_EQ(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_SCALER_SUB));
+
+       RM_TEST_MSG("rm_virtual_scaler_swap_p2 end...");
+}
+
+
+
+TEST(ut_rm_api, rm_virtual_scaler_swap_n1)
+{
+       RM_TEST_MSG("rm_virtual_scaler_swap_n1 start...");
+
+       EXPECT_NE(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_TUNER));
+
+       RM_TEST_MSG("rm_virtual_scaler_swap_n1 end...");
+}
+
+TEST(ut_rm_api, rm_virtual_scaler_swap_n2)
+{
+       RM_TEST_MSG("rm_virtual_scaler_swap_n2 start...");
+
+       EXPECT_NE(RM_OK, rm_swap_resources(RM_DEVICE_VIDEO_DECODER_MAIN, RM_DEVICE_VIDEO_DECODER_SUB));
+
+       RM_TEST_MSG("rm_virtual_scaler_swap_n2 end...");
+}
+
+TEST(ut_rm_api, rm_scaler_changed_cb_p1)
+{
+       RM_TEST_MSG("rm_scaler_changed_cb_p1 start...");
+
+       TCCallbackListener *listener = new TCCallbackListener();
+
+       EXPECT_EQ(RM_OK, listener->RegisterScalerStateChangeCb());
+       EXPECT_EQ(RM_OK, listener->UnregisterScalerStateChangeCb());
+
+       delete listener;
+
+       RM_TEST_MSG("rm_scaler_changed_cb_p1 end...");
+}
+
+TEST(ut_rm_api, rm_scaler_changed_cb_n1)
+{
+       RM_TEST_MSG("rm_scaler_changed_cb_n1 start...");
+
+       TCCallbackListener *listener = new TCCallbackListener();
+
+       EXPECT_EQ(RM_OK, listener->RegisterScalerStateChangeCb());
+       EXPECT_NE(RM_OK, listener->RegisterScalerStateChangeCb());
+
+       EXPECT_EQ(RM_OK, listener->UnregisterScalerStateChangeCb());
+       EXPECT_NE(RM_OK, listener->UnregisterScalerStateChangeCb());
+
+       delete listener;
+
+       RM_TEST_MSG("rm_scaler_changed_cb_n1 end...");
+}
+
+int _get_source_id(int device_id)
+{
+       if (device_id == RM_DEVICE_SCALER)
+               return 0;
+       if (device_id == RM_DEVICE_SCALER_SUB)
+               return 1;
+       return 99;
+}
+
+#if 0 // Resource manager server doesn't send a dbus signal (disabled feature)
+TEST(ut_rm_api, rm_scaler_changed_cb_p2)
+{
+       RM_TEST_MSG("rm_scaler_changed_cb_p2 start...");
+
+       TCCallbackListener *listener = new TCCallbackListener();
+
+       EXPECT_EQ(RM_OK, listener->RegisterScalerStateChangeCb());
+
+       EXPECT_EQ(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_SCALER_SUB));
+
+       sleep(2);
+
+       EXPECT_EQ(1, listener->GetNotificationNum());
+       EXPECT_EQ(1, listener->IsIncluded(RI_VIRTUAL_ID_SCALER + 1, _get_source_id(RM_DEVICE_SCALER)));
+       EXPECT_EQ(1, listener->IsIncluded(RI_VIRTUAL_ID_SCALER, _get_source_id(RM_DEVICE_SCALER_SUB)));
+
+       EXPECT_EQ(RM_OK, rm_swap_resources(RM_DEVICE_SCALER, RM_DEVICE_SCALER_SUB));
+
+       sleep(2);
+
+       EXPECT_EQ(2, listener->GetNotificationNum());
+       EXPECT_EQ(1, listener->IsIncluded(RI_VIRTUAL_ID_SCALER, _get_source_id(RM_DEVICE_SCALER)));
+       EXPECT_EQ(1, listener->IsIncluded(RI_VIRTUAL_ID_SCALER + 1, _get_source_id(RM_DEVICE_SCALER_SUB)));
+
+       EXPECT_EQ(RM_OK, listener->UnregisterScalerStateChangeCb());
+
+       delete listener;
+
+       RM_TEST_MSG("rm_scaler_changed_cb_p2 end...");
+}
+#endif//0
index a4ca039790388d965f2167d2fbb04449c7e0727f..a0e210aca1be64e19d629113530f16f0a41576bc 100644 (file)
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "gtest/gtest.h"\r
-#include <unistd.h>\r
-\r
-#include <rm_api.h>\r
-#include <stdlib.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include <rm_debug.h>\r
-#include <dlog.h>\r
-#include <sys/stat.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-\r
-#include <ut_common.h>\r
-\r
-TEST(ut_rm_api, alloc_video_dec_av1_vr360_p1)\r
-{\r
-       RM_TEST_MSG("alloc_video_dec_av1_vr360_p1 start...");\r
-\r
-       int handle = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "AV1_VR360";\r
-       option.color_depth = 8;\r
-       option.framerate = 30;\r
-       option.h_size = 1920;\r
-       option.v_size = 1080;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_capable_video_category_id(&option);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_VR360DEC, allocated.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_video_dec_av1_vr360_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_video_dec_av1_vr360_p2)\r
-{\r
-       RM_TEST_MSG("alloc_video_dec_av1_vr360_p2 start...");\r
-\r
-       int handle = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "AV1_VR360";\r
-       option.color_depth = 8;\r
-       option.framerate = 60;\r
-       option.h_size = 3840;\r
-       option.v_size = 2160;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_capable_video_category_id(&option);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       if (is_support_4k()) {\r
-               EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-               EXPECT_EQ(1, allocated.allocated_num);\r
-               EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_VR360DEC, allocated.device_id[0]);\r
-               EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       } else {\r
-               EXPECT_NE(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-               EXPECT_EQ(0, allocated.allocated_num);\r
-               EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       }\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_video_dec_av1_vr360_p2 end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_video_dec_h264_vr360_p1)\r
-{\r
-       RM_TEST_MSG("alloc_video_dec_h264_vr360_p1 start...");\r
-\r
-       int handle = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "H264_VR360";\r
-       option.color_depth = 8;\r
-       option.framerate = 60;\r
-       option.h_size = 1920;\r
-       option.v_size = 1080;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_capable_video_category_id(&option);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_VR360DEC, allocated.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_video_dec_h264_vr360_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_video_dec_vp9_vr360_p1)\r
-{\r
-       RM_TEST_MSG("alloc_video_dec_vp9_vr360_p1 start...");\r
-\r
-       int handle = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "VP9_VR360";\r
-       option.color_depth = 8;\r
-       option.framerate = 60;\r
-       option.h_size = 1920;\r
-       option.v_size = 1080;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_capable_video_category_id(&option);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_VR360DEC, allocated.device_id[0]);\r
-       EXPECT_STREQ("OMX.SDP.video_decoder.vr360dec", allocated.omx_comp_name[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_video_dec_vp9_vr360_p1 end...");\r
-}\r
-\r
-TEST(ut_rm_api, alloc_video_dec_hevc_vr360_p1)\r
-{\r
-       RM_TEST_MSG("alloc_video_dec_hevc_vr360_p1 start...");\r
-\r
-       int handle = 0;\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));\r
-\r
-       rm_category_request_s request;\r
-       memset(&request, 0, sizeof(rm_category_request_s));\r
-\r
-       ri_video_category_option_request_s option;\r
-       memset(&option, 0, sizeof(ri_video_category_option_request_s));\r
-\r
-       option.codec_name = "HEVC_VR360";\r
-       option.color_depth = 8;\r
-       option.framerate = 60;\r
-       option.h_size = 1920;\r
-       option.v_size = 1080;\r
-       option.sampling_format = RI_SAMPLING_FORMAT_420;\r
-\r
-       request.request_num = 1;\r
-       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;\r
-       request.category_option[0] = ri_get_capable_video_category_id(&option);\r
-       request.state[0] = RM_STATE_EXCLUSIVE;\r
-\r
-       rm_device_return_s allocated;\r
-       memset(&allocated, 0, sizeof(rm_device_return_s));\r
-\r
-       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));\r
-       EXPECT_EQ(1, allocated.allocated_num);\r
-       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_VR360DEC, allocated.device_id[0]);\r
-       EXPECT_EQ(0, rm_tc_get_conflict_num());\r
-       rm_tc_reset_conflict_num();\r
-\r
-       EXPECT_EQ(RM_OK, rm_unregister(handle));\r
-\r
-       RM_TEST_MSG("alloc_video_dec_hevc_vr360_p1 end...");\r
-}\r
+/*
+ * Copyright (c) 2024 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 "gtest/gtest.h"
+#include <unistd.h>
+
+#include <rm_api.h>
+#include <stdlib.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include <rm_debug.h>
+#include <dlog.h>
+#include <sys/stat.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <ut_common.h>
+
+TEST(ut_rm_api, alloc_video_dec_av1_vr360_p1)
+{
+       RM_TEST_MSG("alloc_video_dec_av1_vr360_p1 start...");
+
+       int handle = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "AV1_VR360";
+       option.color_depth = 8;
+       option.framerate = 30;
+       option.h_size = 1920;
+       option.v_size = 1080;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_capable_video_category_id(&option);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_VR360DEC, allocated.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_video_dec_av1_vr360_p1 end...");
+}
+
+TEST(ut_rm_api, alloc_video_dec_av1_vr360_p2)
+{
+       RM_TEST_MSG("alloc_video_dec_av1_vr360_p2 start...");
+
+       int handle = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "AV1_VR360";
+       option.color_depth = 8;
+       option.framerate = 60;
+       option.h_size = 3840;
+       option.v_size = 2160;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_capable_video_category_id(&option);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       if (is_support_4k()) {
+               EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+               EXPECT_EQ(1, allocated.allocated_num);
+               EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_VR360DEC, allocated.device_id[0]);
+               EXPECT_EQ(0, rm_tc_get_conflict_num());
+       } else {
+               EXPECT_NE(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+               EXPECT_EQ(0, allocated.allocated_num);
+               EXPECT_EQ(0, rm_tc_get_conflict_num());
+       }
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_video_dec_av1_vr360_p2 end...");
+}
+
+TEST(ut_rm_api, alloc_video_dec_h264_vr360_p1)
+{
+       RM_TEST_MSG("alloc_video_dec_h264_vr360_p1 start...");
+
+       int handle = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "H264_VR360";
+       option.color_depth = 8;
+       option.framerate = 60;
+       option.h_size = 1920;
+       option.v_size = 1080;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_capable_video_category_id(&option);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_VR360DEC, allocated.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_video_dec_h264_vr360_p1 end...");
+}
+
+TEST(ut_rm_api, alloc_video_dec_vp9_vr360_p1)
+{
+       RM_TEST_MSG("alloc_video_dec_vp9_vr360_p1 start...");
+
+       int handle = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "VP9_VR360";
+       option.color_depth = 8;
+       option.framerate = 60;
+       option.h_size = 1920;
+       option.v_size = 1080;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_capable_video_category_id(&option);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_VR360DEC, allocated.device_id[0]);
+       EXPECT_STREQ("OMX.SDP.video_decoder.vr360dec", allocated.omx_comp_name[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_video_dec_vp9_vr360_p1 end...");
+}
+
+TEST(ut_rm_api, alloc_video_dec_hevc_vr360_p1)
+{
+       RM_TEST_MSG("alloc_video_dec_hevc_vr360_p1 start...");
+
+       int handle = 0;
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_register(rm_cb_counting_conflicted, NULL, &handle, NULL));
+
+       rm_category_request_s request;
+       memset(&request, 0, sizeof(rm_category_request_s));
+
+       ri_video_category_option_request_s option;
+       memset(&option, 0, sizeof(ri_video_category_option_request_s));
+
+       option.codec_name = "HEVC_VR360";
+       option.color_depth = 8;
+       option.framerate = 60;
+       option.h_size = 1920;
+       option.v_size = 1080;
+       option.sampling_format = RI_SAMPLING_FORMAT_420;
+
+       request.request_num = 1;
+       request.category_id[0] = RM_CATEGORY_VIDEO_DECODER;
+       request.category_option[0] = ri_get_capable_video_category_id(&option);
+       request.state[0] = RM_STATE_EXCLUSIVE;
+
+       rm_device_return_s allocated;
+       memset(&allocated, 0, sizeof(rm_device_return_s));
+
+       EXPECT_EQ(RM_OK, rm_allocate_resources(handle, &request, &allocated));
+       EXPECT_EQ(1, allocated.allocated_num);
+       EXPECT_EQ(RM_DEVICE_VIDEO_DECODER_VR360DEC, allocated.device_id[0]);
+       EXPECT_EQ(0, rm_tc_get_conflict_num());
+       rm_tc_reset_conflict_num();
+
+       EXPECT_EQ(RM_OK, rm_unregister(handle));
+
+       RM_TEST_MSG("alloc_video_dec_hevc_vr360_p1 end...");
+}