4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
24 #include "mm_radio_rt_api_test.h"
26 #define MENU_ITEM_MAX 16
28 static int __menu(void);
29 static void __call_api( int choosen );
30 static int __msg_rt_callback(int message, void *param, void *user_param);
32 static MMHandleType g_my_radio = 0;
34 void __call_api( int choosen )
36 int ret = MM_ERROR_NONE;
42 RADIO_TEST__( mm_radio_create( &g_my_radio ); )
43 RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); )
49 RADIO_TEST__( mm_radio_destroy( g_my_radio ); )
56 RADIO_TEST__( mm_radio_realize(g_my_radio ); )
62 RADIO_TEST__( mm_radio_unrealize(g_my_radio ); )
68 MMRadioStateType state = 0;
69 RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); )
71 printf("state : %d\n", state);
77 RADIO_TEST__( mm_radio_start(g_my_radio); )
83 RADIO_TEST__( mm_radio_stop(g_my_radio); )
89 MMRadioSeekDirectionType direction = 0;
90 printf("input seek direction(0:UP/1:DOWN) : ");
91 scanf("%d", &direction);
92 RADIO_TEST__( mm_radio_seek(g_my_radio, direction); )
99 printf("input freq : ");
101 RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); )
108 RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); )
110 printf("freq : %d\n", freq);
116 RADIO_TEST__( mm_radio_scan_start(g_my_radio); )
122 RADIO_TEST__( mm_radio_scan_stop(g_my_radio); )
128 MMRadioOutputType path = 0;
129 printf("input path(0:NONE/1:AUTO/2:SPK/3:EAR) : ");
131 RADIO_TEST__( mm_radio_set_sound_path(g_my_radio, path); )
138 printf("select one(0:UNMUTE/1:MUTE) : ");
140 RADIO_TEST__( mm_radio_set_mute(g_my_radio, muted); )
149 int mm_radio_rt_api_test(void)
164 __call_api( choosen );
167 printf("radio test client finished\n");
176 printf("---------------------------------------------------------\n");
177 printf("mm-radio rt api test. try now!\n");
178 printf("---------------------------------------------------------\n");
179 printf("[1] mm_radio_create\n");
180 printf("[2] mm_radio_destroy\n");
181 printf("[3] mm_radio_realize\n");
182 printf("[4] mm_radio_unrealize\n");
183 printf("[7] mm_radio_get_state\n");
184 printf("[8] mm_radio_start\n");
185 printf("[9] mm_radio_stop\n");
186 printf("[10] mm_radio_seek\n");
187 printf("[11] mm_radio_set_frequency(ex.1077)\n");
188 printf("[12] mm_radio_get_frequency\n");
189 printf("[13] mm_radio_scan_start\n");
190 printf("[14] mm_radio_scan_stop\n");
191 printf("[15] mm_radio_set_sound_path\n");
192 printf("[16] mm_radio_set_mute\n");
193 printf("[0] quit\n");
194 printf("---------------------------------------------------------\n");
195 printf("choose one : ");
196 scanf("%d", &menu_item);
198 if ( menu_item > MENU_ITEM_MAX )
205 int __msg_rt_callback(int message, void *pParam, void *user_param)
207 MMMessageParamType* param = (MMMessageParamType*)pParam;
208 MMHandleType radio = (MMHandleType) user_param;
211 printf("incomming message : %d\n", message);
215 case MM_MESSAGE_STATE_CHANGED:
217 printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n"
218 , param->state.current, param->state.previous);
220 case MM_MESSAGE_RADIO_SCAN_START:
221 printf("MM_MESSAGE_RADIO_SCAN_START\n");
223 case MM_MESSAGE_RADIO_SCAN_INFO:
225 printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency);
227 case MM_MESSAGE_RADIO_SCAN_STOP:
228 printf("MM_MESSAGE_RADIO_SCAN_STOP\n");
230 case MM_MESSAGE_RADIO_SCAN_FINISH:
231 printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n");
232 RADIO_TEST__( mm_radio_scan_stop(radio); )
234 case MM_MESSAGE_RADIO_SEEK_START:
235 printf("MM_MESSAGE_RADIO_SEEK_START\n");
237 case MM_MESSAGE_RADIO_SEEK_FINISH:
238 printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency);
241 printf("ERROR : unknown message received!\n");