From: YoungHun Kim Date: Fri, 2 Aug 2024 09:12:35 +0000 (+0900) Subject: Update file format X-Git-Tag: accepted/tizen/unified/20240806.010612^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_9.0_unified;p=platform%2Fcore%2Fmultimedia%2Fresource-center-api.git Update file format - Remove CRLF line terminators Change-Id: I93ea6c5087db11b2d9fdc371718e27f6a32a5ab4 --- diff --git a/LICENSE.APLv2 b/LICENSE.APLv2 index bbe9d02..f94008a 100644 --- a/LICENSE.APLv2 +++ b/LICENSE.APLv2 @@ -1,206 +1,206 @@ -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. - - - +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. + + + diff --git a/include/resource_center_internal.h b/include/resource_center_internal.h index c489c4c..f5b210c 100644 --- a/include/resource_center_internal.h +++ b/include/resource_center_internal.h @@ -1,109 +1,109 @@ -/* - * 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 __TIZEN_RESOURCE_CENTER_INTERNAL_H__ -#define __TIZEN_RESOURCE_CENTER_INTERNAL_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef enum { - RC_AUDIO_OUT_MAIN = 1, /**< audio out main */ - RC_AUDIO_OUT_SUB /**< audio out sub */ -} rc_audio_out_e; - -/** - * @brief Register player - * @param[in] player_id player id - * @param[in] resource_id window resource id - * @return @c 0 on success, otherwise a negative error value - * @pre None - * @post None - * @exception None - */ -int rc_player_register(int player_id, int resource_id); - -/** - * @brief Request play - * @param[in] player_id player id - * @param[out] audio_out player's audio out - * @return @c 0 on success, otherwise a negative error value - * @pre None - * @post None - * @exception None - */ -int rc_player_request_play(int player_id, rc_audio_out_e* audio_out); - -/** - * @brief Request stop - * @param[in] player_id player id - * @return @c 0 on success, otherwise a negative error value - * @pre None - * @post None - * @exception None - */ -int rc_player_request_stop(int player_id); - -/** - * @brief Unregister player - * @param[in] player_id player id - * @return @c 0 on success, otherwise a negative error value - * @pre None - * @post None - * @exception None - */ -int rc_player_unregister(int player_id); - -/** - * @brief Register external speaker info - * @param[in] info external speaker info - * @param[in] zone_id zone id - * @return @c 0 on success, otherwise a negative error value - * @pre None - * @post None - * @exception None - */ -int rc_extspk_info_register(const char* info, int zone_id); - -/** - * @brief Unegister external speaker info - * @param[in] info external speaker info - * @param[in] zone_id zone id - * @return @c 0 on success, otherwise a negative error value - * @pre None - * @post None - * @exception None - */ -int rc_extspk_info_unregister(const char* info, int zone_id); - -/** - * @brief Register external speaker info - * @param[in] info external speaker info - * @param[out] audio_out audio out of external speaker - * @return @c 0 on success, otherwise a negative error value - * @pre None - * @post None - * @exception None - */ -int rc_get_extspk_info_audio_out(const char* info, int* audio_out); - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_RESOURCE_CENTER_INTERNAL_H__ */ +/* + * 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 __TIZEN_RESOURCE_CENTER_INTERNAL_H__ +#define __TIZEN_RESOURCE_CENTER_INTERNAL_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef enum { + RC_AUDIO_OUT_MAIN = 1, /**< audio out main */ + RC_AUDIO_OUT_SUB /**< audio out sub */ +} rc_audio_out_e; + +/** + * @brief Register player + * @param[in] player_id player id + * @param[in] resource_id window resource id + * @return @c 0 on success, otherwise a negative error value + * @pre None + * @post None + * @exception None + */ +int rc_player_register(int player_id, int resource_id); + +/** + * @brief Request play + * @param[in] player_id player id + * @param[out] audio_out player's audio out + * @return @c 0 on success, otherwise a negative error value + * @pre None + * @post None + * @exception None + */ +int rc_player_request_play(int player_id, rc_audio_out_e* audio_out); + +/** + * @brief Request stop + * @param[in] player_id player id + * @return @c 0 on success, otherwise a negative error value + * @pre None + * @post None + * @exception None + */ +int rc_player_request_stop(int player_id); + +/** + * @brief Unregister player + * @param[in] player_id player id + * @return @c 0 on success, otherwise a negative error value + * @pre None + * @post None + * @exception None + */ +int rc_player_unregister(int player_id); + +/** + * @brief Register external speaker info + * @param[in] info external speaker info + * @param[in] zone_id zone id + * @return @c 0 on success, otherwise a negative error value + * @pre None + * @post None + * @exception None + */ +int rc_extspk_info_register(const char* info, int zone_id); + +/** + * @brief Unegister external speaker info + * @param[in] info external speaker info + * @param[in] zone_id zone id + * @return @c 0 on success, otherwise a negative error value + * @pre None + * @post None + * @exception None + */ +int rc_extspk_info_unregister(const char* info, int zone_id); + +/** + * @brief Register external speaker info + * @param[in] info external speaker info + * @param[out] audio_out audio out of external speaker + * @return @c 0 on success, otherwise a negative error value + * @pre None + * @post None + * @exception None + */ +int rc_get_extspk_info_audio_out(const char* info, int* audio_out); + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_RESOURCE_CENTER_INTERNAL_H__ */ diff --git a/src/resource_center_internal.cpp b/src/resource_center_internal.cpp index 0c9e3bf..af695b2 100644 --- a/src/resource_center_internal.cpp +++ b/src/resource_center_internal.cpp @@ -1,75 +1,75 @@ -/* - * 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 -#include "resource_center_internal.h" -#include "resource_center_private.h" - -int rc_player_register(int player_id, int resource_id) -{ - RC_LOG_INFO(">>"); - - return _rc_player_register(player_id, resource_id); -} - -int rc_player_request_play(int player_id, rc_audio_out_e* audio_out) -{ - RC_LOG_INFO(">>"); - - return _rc_player_request_play(player_id, audio_out); -} - -int rc_player_request_stop(int player_id) -{ - RC_LOG_INFO(">>"); - - return _rc_player_request_stop(player_id); -} - -int rc_player_unregister(int player_id) -{ - RC_LOG_INFO(">>"); - - return _rc_player_unregister(player_id); -} - -int rc_extspk_info_register(const char* info, int zone_id) -{ - RC_LOG_INFO(">>"); - - return _rc_extspk_info_register(info, zone_id); -} - -int rc_extspk_info_unregister(const char* info, int zone_id) -{ - RC_LOG_INFO(">>"); - - return _rc_extspk_info_unregister(info, zone_id); -} - -int rc_get_extspk_info_audio_out(const char* info, int* audio_out) -{ - int ret; - RC_LOG_INFO(">>"); - - ret = _rc_get_extspk_info_audio_out(info); - - if (ret < 0) - return ret; - - *audio_out = ret; - return 0; -} \ 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 +#include "resource_center_internal.h" +#include "resource_center_private.h" + +int rc_player_register(int player_id, int resource_id) +{ + RC_LOG_INFO(">>"); + + return _rc_player_register(player_id, resource_id); +} + +int rc_player_request_play(int player_id, rc_audio_out_e* audio_out) +{ + RC_LOG_INFO(">>"); + + return _rc_player_request_play(player_id, audio_out); +} + +int rc_player_request_stop(int player_id) +{ + RC_LOG_INFO(">>"); + + return _rc_player_request_stop(player_id); +} + +int rc_player_unregister(int player_id) +{ + RC_LOG_INFO(">>"); + + return _rc_player_unregister(player_id); +} + +int rc_extspk_info_register(const char* info, int zone_id) +{ + RC_LOG_INFO(">>"); + + return _rc_extspk_info_register(info, zone_id); +} + +int rc_extspk_info_unregister(const char* info, int zone_id) +{ + RC_LOG_INFO(">>"); + + return _rc_extspk_info_unregister(info, zone_id); +} + +int rc_get_extspk_info_audio_out(const char* info, int* audio_out) +{ + int ret; + RC_LOG_INFO(">>"); + + ret = _rc_get_extspk_info_audio_out(info); + + if (ret < 0) + return ret; + + *audio_out = ret; + return 0; +} diff --git a/ut/inc/TCApp.h b/ut/inc/TCApp.h index b0ebbde..ebb08b3 100644 --- a/ut/inc/TCApp.h +++ b/ut/inc/TCApp.h @@ -1,57 +1,57 @@ -/* - * 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_APP_H__ -#define __TC_APP_H__ -#include - -class TCApp -{ -public: - TCApp(const char* app_id); - ~TCApp(); - - static void ResourceChangedCb(const char* app_id, rc_resource_h rsc, void *data); - int RegisterResourceChangeCb(void); - int UnregisterResourceChangeCb(void); - - std::string GetAppId(void) { return m_app_id; } - - void IncreaseCbCount(void) { m_cb_count++; } - void ResetCbCount(void) { m_cb_count = 0; } - int GetCbCount(void) { return m_cb_count;} - - bool IsMaxRszChanged(void) { return m_max_rsz_changed; } - bool IsAudioRscChanged(void) { return m_audio_rsc_changed; } - - void SetMaxRszChanged(bool changed) { m_max_rsz_changed = changed; } - void SetAudioRscChanged(bool changed) { m_audio_rsc_changed = changed; } - void SetMaxResolution(int w, int h, int f) { m_max_width = w; m_max_height = h; m_max_framerate = f; } - void GetMaxResolution(int *w, int *h, int *f) { *w = m_max_width, *h = m_max_height, *f = m_max_framerate; } - void ResetCbData(void) { m_max_width = 0; m_max_height = 0; m_max_framerate = 0; m_max_rsz_changed = false; m_audio_rsc_changed = false; } - -private: - std::string m_app_id; - int m_cb_count; - - int m_max_width = 0; - int m_max_height = 0; - int m_max_framerate = 0; - bool m_max_rsz_changed = false; - bool m_audio_rsc_changed = false; -}; - -#endif //__TC_APP_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_APP_H__ +#define __TC_APP_H__ +#include + +class TCApp +{ +public: + TCApp(const char* app_id); + ~TCApp(); + + static void ResourceChangedCb(const char* app_id, rc_resource_h rsc, void *data); + int RegisterResourceChangeCb(void); + int UnregisterResourceChangeCb(void); + + std::string GetAppId(void) { return m_app_id; } + + void IncreaseCbCount(void) { m_cb_count++; } + void ResetCbCount(void) { m_cb_count = 0; } + int GetCbCount(void) { return m_cb_count;} + + bool IsMaxRszChanged(void) { return m_max_rsz_changed; } + bool IsAudioRscChanged(void) { return m_audio_rsc_changed; } + + void SetMaxRszChanged(bool changed) { m_max_rsz_changed = changed; } + void SetAudioRscChanged(bool changed) { m_audio_rsc_changed = changed; } + void SetMaxResolution(int w, int h, int f) { m_max_width = w; m_max_height = h; m_max_framerate = f; } + void GetMaxResolution(int *w, int *h, int *f) { *w = m_max_width, *h = m_max_height, *f = m_max_framerate; } + void ResetCbData(void) { m_max_width = 0; m_max_height = 0; m_max_framerate = 0; m_max_rsz_changed = false; m_audio_rsc_changed = false; } + +private: + std::string m_app_id; + int m_cb_count; + + int m_max_width = 0; + int m_max_height = 0; + int m_max_framerate = 0; + bool m_max_rsz_changed = false; + bool m_audio_rsc_changed = false; +}; + +#endif //__TC_APP_H__ diff --git a/ut/inc/TCPlayer.h b/ut/inc/TCPlayer.h index d043430..600c0cd 100644 --- a/ut/inc/TCPlayer.h +++ b/ut/inc/TCPlayer.h @@ -1,81 +1,81 @@ -/* - * 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 -#include -#include - -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 GetHandle(void) { return m_handle; } - std::string GetAppId(void) { return m_app_id; } - 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 GetCapableCategoryIdFromRC(int category_id); - - 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 GetActiveAudioOut(void); - -private: - std::map m_allocated_resources; - std::map m_requested_resources; - std::map 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__ \ 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_PLAYER_H__ +#define __TC_PLAYER_H__ + +#include +#include +#include + +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 GetHandle(void) { return m_handle; } + std::string GetAppId(void) { return m_app_id; } + 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 GetCapableCategoryIdFromRC(int category_id); + + 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 GetActiveAudioOut(void); + +private: + std::map m_allocated_resources; + std::map m_requested_resources; + std::map 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__ diff --git a/ut/inc/TCResource.h b/ut/inc/TCResource.h index 545b5af..c3068b4 100644 --- a/ut/inc/TCResource.h +++ b/ut/inc/TCResource.h @@ -1,36 +1,36 @@ -/* - * 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__ \ 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__ diff --git a/ut/inc/tomatoGtest.h b/ut/inc/tomatoGtest.h index 2fda25e..5d5bc98 100644 --- a/ut/inc/tomatoGtest.h +++ b/ut/inc/tomatoGtest.h @@ -1,99 +1,99 @@ -/* - * 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. - */ - -//invoke Tomato LIB -#ifndef __TOMATO_GTEST_H__ -#define __TOMATO_GTEST_H__ - -#include "TomatoAPI.h" - -//Set TC-config to tomato via Gtest macro -#undef GTEST_TEST_ -#define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)\ -class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\ - public:\ - GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\ - private:\ - virtual void TestBody();\ - virtual void TestBody_();\ - static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\ - GTEST_DISALLOW_COPY_AND_ASSIGN_(\ - GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\ -};\ -\ -::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\ - ::test_info_ =\ - ::testing::internal::MakeAndRegisterTestInfo(\ - #test_case_name, #test_name, NULL, NULL, \ - (parent_id), \ - parent_class::SetUpTestCase, \ - parent_class::TearDownTestCase, \ - new ::testing::internal::TestFactoryImpl<\ - GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\ -void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()\ -{\ - CTomatoAPI::BeginTestCase(#test_name);\ - this->TestBody_();\ - CTomatoAPI::EndTestCase();\ -}\ -void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody_() - -// Re-define Gtest macro for redirecting gtest-report to tomato -/* - EXPECT_EQ - ASSERT_EQ - - @ refer to "gtest_pred_impl.h" -*/ -// parvin.kumar - -#undef GTEST_PRED_FORMAT2_ -#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\ - GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), v2, on_failure) \ - -#undef GTEST_ASSERT_ -#define GTEST_ASSERT_(expression, v2, on_failure) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (const ::testing::AssertionResult gtest_ar = (expression)) {\ - CTomatoAPI::WriteTestResult( #v2, true , "success"); { \ - else \ - { on_failure(gtest_ar.failure_message()); \ - CTomatoAPI::WriteTestResult( #v2, false , gtest_ar.failure_message()); { - - -/* - EXPECT_TRUE : return TRUE -> PASS - EXPECT_FALSE : return FALSE -> PASS - ASSERT_TRUE - ASSERT_FALSE -*/ - - -// Implements Boolean test assertions such as EXPECT_TRUE. expression can be -// either a boolean expression or an AssertionResult. text is a textual -// representation of expression as it was passed into the EXPECT_TRUE. -#undef GTEST_TEST_BOOLEAN_ -#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (const ::testing::AssertionResult gtest_ar_ = \ - ::testing::AssertionResult(expression)) {\ - CTomatoAPI::WriteTestResult( text, true , "success"); { \ - else {\ - fail(::testing::internal::GetBoolAssertionFailureMessage(gtest_ar_, text, #actual, #expected).c_str());\ - CTomatoAPI::WriteTestResult( test, false , ::testing::internal::GetBoolAssertionFailureMessage(gtest_ar_, text, #actual, #expected).c_str()); { - - -#endif //__TOMATO_GTEST_H__ +/* + * 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. + */ + +//invoke Tomato LIB +#ifndef __TOMATO_GTEST_H__ +#define __TOMATO_GTEST_H__ + +#include "TomatoAPI.h" + +//Set TC-config to tomato via Gtest macro +#undef GTEST_TEST_ +#define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)\ +class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\ + public:\ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\ + private:\ + virtual void TestBody();\ + virtual void TestBody_();\ + static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\ + GTEST_DISALLOW_COPY_AND_ASSIGN_(\ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\ +};\ +\ +::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\ + ::test_info_ =\ + ::testing::internal::MakeAndRegisterTestInfo(\ + #test_case_name, #test_name, NULL, NULL, \ + (parent_id), \ + parent_class::SetUpTestCase, \ + parent_class::TearDownTestCase, \ + new ::testing::internal::TestFactoryImpl<\ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\ +void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()\ +{\ + CTomatoAPI::BeginTestCase(#test_name);\ + this->TestBody_();\ + CTomatoAPI::EndTestCase();\ +}\ +void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody_() + +// Re-define Gtest macro for redirecting gtest-report to tomato +/* + EXPECT_EQ + ASSERT_EQ + + @ refer to "gtest_pred_impl.h" +*/ +// parvin.kumar + +#undef GTEST_PRED_FORMAT2_ +#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\ + GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), v2, on_failure) \ + +#undef GTEST_ASSERT_ +#define GTEST_ASSERT_(expression, v2, on_failure) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (const ::testing::AssertionResult gtest_ar = (expression)) {\ + CTomatoAPI::WriteTestResult( #v2, true , "success"); { \ + else \ + { on_failure(gtest_ar.failure_message()); \ + CTomatoAPI::WriteTestResult( #v2, false , gtest_ar.failure_message()); { + + +/* + EXPECT_TRUE : return TRUE -> PASS + EXPECT_FALSE : return FALSE -> PASS + ASSERT_TRUE + ASSERT_FALSE +*/ + + +// Implements Boolean test assertions such as EXPECT_TRUE. expression can be +// either a boolean expression or an AssertionResult. text is a textual +// representation of expression as it was passed into the EXPECT_TRUE. +#undef GTEST_TEST_BOOLEAN_ +#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (const ::testing::AssertionResult gtest_ar_ = \ + ::testing::AssertionResult(expression)) {\ + CTomatoAPI::WriteTestResult( text, true , "success"); { \ + else {\ + fail(::testing::internal::GetBoolAssertionFailureMessage(gtest_ar_, text, #actual, #expected).c_str());\ + CTomatoAPI::WriteTestResult( test, false , ::testing::internal::GetBoolAssertionFailureMessage(gtest_ar_, text, #actual, #expected).c_str()); { + + +#endif //__TOMATO_GTEST_H__ diff --git a/ut/inc/ut_log.h b/ut/inc/ut_log.h index 572fdd4..6ee9f42 100644 --- a/ut/inc/ut_log.h +++ b/ut/inc/ut_log.h @@ -1,31 +1,31 @@ -/* - * 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_LOG_H__ -#define __UT_LOG_H__ - -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif//LOG_TAG - -#define LOG_TAG "RSC_CENTER_TC" -#define RC_TEST_ERR(fmt, ...) LOGE(fmt, ##__VA_ARGS__) -#define RC_TEST_INFO(fmt, ...) LOGI(fmt, ##__VA_ARGS__) -#define RC_TEST_DBG(fmt, ...) LOGD(fmt, ##__VA_ARGS__) - -#endif //__UT_LOG_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 __UT_LOG_H__ +#define __UT_LOG_H__ + +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif//LOG_TAG + +#define LOG_TAG "RSC_CENTER_TC" +#define RC_TEST_ERR(fmt, ...) LOGE(fmt, ##__VA_ARGS__) +#define RC_TEST_INFO(fmt, ...) LOGI(fmt, ##__VA_ARGS__) +#define RC_TEST_DBG(fmt, ...) LOGD(fmt, ##__VA_ARGS__) + +#endif //__UT_LOG_H__ diff --git a/ut/inc/ut_util.h b/ut/inc/ut_util.h index 40fd3b3..3a7ea8f 100644 --- a/ut/inc/ut_util.h +++ b/ut/inc/ut_util.h @@ -1,103 +1,103 @@ -/* - * 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_UTIL_H__ -#define __UT_UTIL_H__ -#include -#include -#include - -int AddZoneInfo(int category_id, int zone_id); - -class CResourceManagerAPI -{ -public: - - typedef enum { - CB_NORMAL = 0, - CB_COUNT - } cb_option; - - static CResourceManagerAPI* GetInstance(); - static gboolean SetAppZoneIdAsync(gpointer data); - static gboolean SetAudioFocusAsync(gpointer data); - - void Reset(void); - int RegisterPlayer(int cb_option, int expected); - int RegisterPlayer(std::string app_id, int cb_option, int expected); - int SetAppZoneIdAsync(std::string app_id, int zone_id, int sleep_sec); - int SetAudioFocusAsync(int zone_id, int sleep_sec); - -private: - CResourceManagerAPI() = default; - ~CResourceManagerAPI() = default; - - rm_resource_cb GetConflictCB(int option); - static rm_cb_result ConflictCB(int handle, rm_callback_type event, rm_device_request_s *info, void* data); - static rm_cb_result ConflictCBCount(int handle, rm_callback_type event, rm_device_request_s *info, void* data); - - static CResourceManagerAPI* m_instance; - int m_conflict_count; -}; - - -class CVideoCategory -{ -public: - CVideoCategory(); - ~CVideoCategory() = default; - - void SetProperties(std::string name, int width, int height, int framerate, int color_depth, int sampling); - ri_video_category_option_request_s* Build(void); - int GetCapableCategoryId(void); - -private: - void ResetProperties(void); - ri_video_category_option_request_s m_option; -}; - -class CAppInfo{ -public: - CAppInfo() = default; - ~CAppInfo() = default; - - void SetAppId(std::string app_id) {m_app_id = app_id;} - std::string GetAppId(void) {return m_app_id;} - void SetZoneId(int id) {m_zone_id = id;} - int GetZoneId(void) {return m_zone_id;} - void SetSleep(int sec) {m_sleep = sec;} - int GetSleep(void) {return m_sleep;} - -private: - std::string m_app_id; - int m_zone_id; - int m_sleep; -}; - -class CFocusInfo{ -public: - CFocusInfo() = default; - ~CFocusInfo() = default; - - void SetZoneId(int id) {m_zone_id = id;} - int GetZoneId(void) {return m_zone_id;} - void SetSleep(int sec) {m_sleep = sec;} - int GetSleep(void) {return m_sleep;} -private: - int m_sleep; - int m_zone_id; -}; -#endif //__UT_UTIL_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 __UT_UTIL_H__ +#define __UT_UTIL_H__ +#include +#include +#include + +int AddZoneInfo(int category_id, int zone_id); + +class CResourceManagerAPI +{ +public: + + typedef enum { + CB_NORMAL = 0, + CB_COUNT + } cb_option; + + static CResourceManagerAPI* GetInstance(); + static gboolean SetAppZoneIdAsync(gpointer data); + static gboolean SetAudioFocusAsync(gpointer data); + + void Reset(void); + int RegisterPlayer(int cb_option, int expected); + int RegisterPlayer(std::string app_id, int cb_option, int expected); + int SetAppZoneIdAsync(std::string app_id, int zone_id, int sleep_sec); + int SetAudioFocusAsync(int zone_id, int sleep_sec); + +private: + CResourceManagerAPI() = default; + ~CResourceManagerAPI() = default; + + rm_resource_cb GetConflictCB(int option); + static rm_cb_result ConflictCB(int handle, rm_callback_type event, rm_device_request_s *info, void* data); + static rm_cb_result ConflictCBCount(int handle, rm_callback_type event, rm_device_request_s *info, void* data); + + static CResourceManagerAPI* m_instance; + int m_conflict_count; +}; + + +class CVideoCategory +{ +public: + CVideoCategory(); + ~CVideoCategory() = default; + + void SetProperties(std::string name, int width, int height, int framerate, int color_depth, int sampling); + ri_video_category_option_request_s* Build(void); + int GetCapableCategoryId(void); + +private: + void ResetProperties(void); + ri_video_category_option_request_s m_option; +}; + +class CAppInfo{ +public: + CAppInfo() = default; + ~CAppInfo() = default; + + void SetAppId(std::string app_id) {m_app_id = app_id;} + std::string GetAppId(void) {return m_app_id;} + void SetZoneId(int id) {m_zone_id = id;} + int GetZoneId(void) {return m_zone_id;} + void SetSleep(int sec) {m_sleep = sec;} + int GetSleep(void) {return m_sleep;} + +private: + std::string m_app_id; + int m_zone_id; + int m_sleep; +}; + +class CFocusInfo{ +public: + CFocusInfo() = default; + ~CFocusInfo() = default; + + void SetZoneId(int id) {m_zone_id = id;} + int GetZoneId(void) {return m_zone_id;} + void SetSleep(int sec) {m_sleep = sec;} + int GetSleep(void) {return m_sleep;} +private: + int m_sleep; + int m_zone_id; +}; +#endif //__UT_UTIL_H__ diff --git a/ut/src/testcase/TCApp.cpp b/ut/src/testcase/TCApp.cpp index f00bfd8..1420446 100644 --- a/ut/src/testcase/TCApp.cpp +++ b/ut/src/testcase/TCApp.cpp @@ -1,74 +1,74 @@ -/* - * 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 -#include "TCApp.h" - -TCApp::TCApp(const char* app_id) -{ - if (app_id) - m_app_id.assign(app_id); - else - m_app_id.assign(""); - - m_cb_count = 0; - - m_max_width = 0; - m_max_height = 0; - m_max_framerate = 0; -} - -TCApp::~TCApp() -{ -} - -void TCApp::ResourceChangedCb(const char* app_id, rc_resource_h rsc, void *data) -{ - int w; - int h; - int f; - - if (!data) - return; - - TCApp* app = (TCApp*) data; - app->IncreaseCbCount(); - - EXPECT_STREQ(app->GetAppId().c_str(), app_id); - - if (rc_rsc_max_resolution_changed(rsc)) - { - EXPECT_EQ(0, rc_rsc_get_video_max_resolution(rsc, &w, &h, &f)); - app->SetMaxResolution(w, h, f); - app->SetMaxRszChanged(true); - } - - if (rc_rsc_audio_out_changed(rsc)) - { - app->SetAudioRscChanged(true); - } -} - -int TCApp::RegisterResourceChangeCb(void) -{ - return rc_register_resource_change_callback(m_app_id.c_str(), TCApp::ResourceChangedCb, this); -} - -int TCApp::UnregisterResourceChangeCb(void) -{ - return rc_unregister_resource_change_callback(m_app_id.c_str(), TCApp::ResourceChangedCb); -} \ 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 +#include "TCApp.h" + +TCApp::TCApp(const char* app_id) +{ + if (app_id) + m_app_id.assign(app_id); + else + m_app_id.assign(""); + + m_cb_count = 0; + + m_max_width = 0; + m_max_height = 0; + m_max_framerate = 0; +} + +TCApp::~TCApp() +{ +} + +void TCApp::ResourceChangedCb(const char* app_id, rc_resource_h rsc, void *data) +{ + int w; + int h; + int f; + + if (!data) + return; + + TCApp* app = (TCApp*) data; + app->IncreaseCbCount(); + + EXPECT_STREQ(app->GetAppId().c_str(), app_id); + + if (rc_rsc_max_resolution_changed(rsc)) + { + EXPECT_EQ(0, rc_rsc_get_video_max_resolution(rsc, &w, &h, &f)); + app->SetMaxResolution(w, h, f); + app->SetMaxRszChanged(true); + } + + if (rc_rsc_audio_out_changed(rsc)) + { + app->SetAudioRscChanged(true); + } +} + +int TCApp::RegisterResourceChangeCb(void) +{ + return rc_register_resource_change_callback(m_app_id.c_str(), TCApp::ResourceChangedCb, this); +} + +int TCApp::UnregisterResourceChangeCb(void) +{ + return rc_unregister_resource_change_callback(m_app_id.c_str(), TCApp::ResourceChangedCb); +} diff --git a/ut/src/testcase/TCPlayer.cpp b/ut/src/testcase/TCPlayer.cpp index 3cb81ae..740e763 100644 --- a/ut/src/testcase/TCPlayer.cpp +++ b/ut/src/testcase/TCPlayer.cpp @@ -1,284 +1,284 @@ -/* - * 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 -#include -#include -#include -#include -#include -#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); - - 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) -{ - m_app_id = 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(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(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(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(); - m_rsc_index = 0; -} - -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; - - return ri_get_capable_video_category_id(&opt); -} - -int TCPlayer::GetCapableCategoryIdFromRC(int category_id) -{ - return rc_get_capable_category_id(m_handle, m_app_id.c_str(), category_id); -} - -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(++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(); - m_allocated_rsc_index = 0; - - 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); -} +/* + * 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 +#include +#include +#include +#include +#include +#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); + + 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) +{ + m_app_id = 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(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(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(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(); + m_rsc_index = 0; +} + +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; + + return ri_get_capable_video_category_id(&opt); +} + +int TCPlayer::GetCapableCategoryIdFromRC(int category_id) +{ + return rc_get_capable_category_id(m_handle, m_app_id.c_str(), category_id); +} + +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(++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(); + m_allocated_rsc_index = 0; + + 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); +} diff --git a/ut/src/testcase/TCResource.cpp b/ut/src/testcase/TCResource.cpp index c149966..fc61df0 100644 --- a/ut/src/testcase/TCResource.cpp +++ b/ut/src/testcase/TCResource.cpp @@ -1,28 +1,28 @@ -/* - * 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() -{ -} +/* + * 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() +{ +} diff --git a/ut/src/testcase/ut_util.cpp b/ut/src/testcase/ut_util.cpp index 4d833dc..e5ab4ac 100644 --- a/ut/src/testcase/ut_util.cpp +++ b/ut/src/testcase/ut_util.cpp @@ -1,169 +1,169 @@ -/* - * 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 -#include -#include - -CResourceManagerAPI* CResourceManagerAPI::m_instance = NULL; - -CResourceManagerAPI* CResourceManagerAPI::GetInstance() -{ - if (!m_instance) - m_instance = new CResourceManagerAPI(); - - return m_instance; -} - -void CResourceManagerAPI::Reset(void) -{ - m_conflict_count = 0; -} - -rm_resource_cb CResourceManagerAPI::GetConflictCB(int option) -{ - if (option == CB_NORMAL) - return &CResourceManagerAPI::ConflictCB; - - if (option == CB_COUNT) - return &CResourceManagerAPI::ConflictCBCount; - - return &CResourceManagerAPI::ConflictCB; -} - - -rm_cb_result CResourceManagerAPI::ConflictCB(int handle, rm_callback_type event, rm_device_request_s *info, void* data) -{ - rm_unregister(handle); - return RM_CB_RESULT_OK; -} - -rm_cb_result CResourceManagerAPI::ConflictCBCount(int handle, rm_callback_type event, rm_device_request_s *info, void* data) -{ - CResourceManagerAPI* api = (CResourceManagerAPI*) data; - api->m_conflict_count++; - rm_unregister(handle); - return RM_CB_RESULT_OK; -} - -int CResourceManagerAPI::RegisterPlayer(int option, int expected) -{ - int handle = 0; - - EXPECT_EQ(expected, rm_register(GetConflictCB(option), this, &handle, NULL)); - - return handle; -} - -int CResourceManagerAPI::RegisterPlayer(std::string app_id, int option, int expected) -{ - return 0; -} - -gboolean CResourceManagerAPI::SetAppZoneIdAsync(gpointer data) -{ - CAppInfo *app_info = (CAppInfo*) data; - sleep(app_info->GetSleep()); - EXPECT_EQ(0, rc_set_app_zone_info(app_info->GetAppId().c_str(), app_info->GetZoneId())); - delete app_info; - return G_SOURCE_REMOVE; -} - -int CResourceManagerAPI::SetAppZoneIdAsync(std::string app_id, int zone_id, int sleep_sec) -{ - CAppInfo *app_info = new CAppInfo(); - app_info->SetAppId(app_id); - app_info->SetZoneId(zone_id); - app_info->SetSleep(sleep_sec); - - g_idle_add(&CResourceManagerAPI::SetAppZoneIdAsync, app_info); - return 0; -} - -gboolean CResourceManagerAPI::SetAudioFocusAsync(gpointer data) -{ - CFocusInfo *focus_info = (CFocusInfo*) data; - sleep(focus_info->GetSleep()); - EXPECT_EQ(0, rc_set_audio_focus(focus_info->GetZoneId())); - delete focus_info; - return G_SOURCE_REMOVE; -} - -int CResourceManagerAPI::SetAudioFocusAsync(int zone_id, int sleep_sec) -{ - CFocusInfo *focus_info = new CFocusInfo(); - focus_info->SetZoneId(zone_id); - focus_info->SetSleep(sleep_sec); - - g_idle_add(&CResourceManagerAPI::SetAudioFocusAsync, focus_info); - return 0; -} - -CVideoCategory::CVideoCategory() -{ - m_option.codec_name = NULL; - m_option.h_size = 0; - m_option.v_size = 0; - m_option.framerate = 0; - m_option.color_depth = 0; - m_option.sampling_format = 0; -} - -void CVideoCategory::SetProperties(std::string codec, int width, int height, int framerate, int color_depth, int sampling) -{ - ResetProperties(); - - m_option.codec_name = strndup(codec.c_str(), codec.length()); - m_option.h_size = width; - m_option.v_size = height; - m_option.framerate = framerate; - m_option.color_depth = color_depth; - m_option.sampling_format = sampling; -} - -void CVideoCategory::ResetProperties(void) -{ - if (m_option.codec_name) { - free((void*) m_option.codec_name); - m_option.codec_name = NULL; - } - - m_option.h_size = 0; - m_option.v_size = 0; - m_option.framerate = 0; - m_option.color_depth = 0; - m_option.sampling_format = 0; -} - -ri_video_category_option_request_s* CVideoCategory::Build(void) -{ - return &m_option; -} - -int CVideoCategory::GetCapableCategoryId(void) -{ - return ri_get_capable_video_category_id(&m_option); -} - -int AddZoneInfo(int category_id, int zone_id) -{ - const int PM_ZONE_ID_OFFSET = 21; - int zone_info = (zone_id << PM_ZONE_ID_OFFSET); - - return (category_id | zone_info); -} - +/* + * 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 +#include +#include + +CResourceManagerAPI* CResourceManagerAPI::m_instance = NULL; + +CResourceManagerAPI* CResourceManagerAPI::GetInstance() +{ + if (!m_instance) + m_instance = new CResourceManagerAPI(); + + return m_instance; +} + +void CResourceManagerAPI::Reset(void) +{ + m_conflict_count = 0; +} + +rm_resource_cb CResourceManagerAPI::GetConflictCB(int option) +{ + if (option == CB_NORMAL) + return &CResourceManagerAPI::ConflictCB; + + if (option == CB_COUNT) + return &CResourceManagerAPI::ConflictCBCount; + + return &CResourceManagerAPI::ConflictCB; +} + + +rm_cb_result CResourceManagerAPI::ConflictCB(int handle, rm_callback_type event, rm_device_request_s *info, void* data) +{ + rm_unregister(handle); + return RM_CB_RESULT_OK; +} + +rm_cb_result CResourceManagerAPI::ConflictCBCount(int handle, rm_callback_type event, rm_device_request_s *info, void* data) +{ + CResourceManagerAPI* api = (CResourceManagerAPI*) data; + api->m_conflict_count++; + rm_unregister(handle); + return RM_CB_RESULT_OK; +} + +int CResourceManagerAPI::RegisterPlayer(int option, int expected) +{ + int handle = 0; + + EXPECT_EQ(expected, rm_register(GetConflictCB(option), this, &handle, NULL)); + + return handle; +} + +int CResourceManagerAPI::RegisterPlayer(std::string app_id, int option, int expected) +{ + return 0; +} + +gboolean CResourceManagerAPI::SetAppZoneIdAsync(gpointer data) +{ + CAppInfo *app_info = (CAppInfo*) data; + sleep(app_info->GetSleep()); + EXPECT_EQ(0, rc_set_app_zone_info(app_info->GetAppId().c_str(), app_info->GetZoneId())); + delete app_info; + return G_SOURCE_REMOVE; +} + +int CResourceManagerAPI::SetAppZoneIdAsync(std::string app_id, int zone_id, int sleep_sec) +{ + CAppInfo *app_info = new CAppInfo(); + app_info->SetAppId(app_id); + app_info->SetZoneId(zone_id); + app_info->SetSleep(sleep_sec); + + g_idle_add(&CResourceManagerAPI::SetAppZoneIdAsync, app_info); + return 0; +} + +gboolean CResourceManagerAPI::SetAudioFocusAsync(gpointer data) +{ + CFocusInfo *focus_info = (CFocusInfo*) data; + sleep(focus_info->GetSleep()); + EXPECT_EQ(0, rc_set_audio_focus(focus_info->GetZoneId())); + delete focus_info; + return G_SOURCE_REMOVE; +} + +int CResourceManagerAPI::SetAudioFocusAsync(int zone_id, int sleep_sec) +{ + CFocusInfo *focus_info = new CFocusInfo(); + focus_info->SetZoneId(zone_id); + focus_info->SetSleep(sleep_sec); + + g_idle_add(&CResourceManagerAPI::SetAudioFocusAsync, focus_info); + return 0; +} + +CVideoCategory::CVideoCategory() +{ + m_option.codec_name = NULL; + m_option.h_size = 0; + m_option.v_size = 0; + m_option.framerate = 0; + m_option.color_depth = 0; + m_option.sampling_format = 0; +} + +void CVideoCategory::SetProperties(std::string codec, int width, int height, int framerate, int color_depth, int sampling) +{ + ResetProperties(); + + m_option.codec_name = strndup(codec.c_str(), codec.length()); + m_option.h_size = width; + m_option.v_size = height; + m_option.framerate = framerate; + m_option.color_depth = color_depth; + m_option.sampling_format = sampling; +} + +void CVideoCategory::ResetProperties(void) +{ + if (m_option.codec_name) { + free((void*) m_option.codec_name); + m_option.codec_name = NULL; + } + + m_option.h_size = 0; + m_option.v_size = 0; + m_option.framerate = 0; + m_option.color_depth = 0; + m_option.sampling_format = 0; +} + +ri_video_category_option_request_s* CVideoCategory::Build(void) +{ + return &m_option; +} + +int CVideoCategory::GetCapableCategoryId(void) +{ + return ri_get_capable_video_category_id(&m_option); +} + +int AddZoneInfo(int category_id, int zone_id) +{ + const int PM_ZONE_ID_OFFSET = 21; + int zone_info = (zone_id << PM_ZONE_ID_OFFSET); + + return (category_id | zone_info); +} +