2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "bluetooth-media-control.h"
23 #include <dbus/dbus-glib.h>
24 #include <dbus/dbus-glib-lowlevel.h>
26 #define MEDIA_ATRRIBUTE_LENGTH 256
28 media_player_settings_t player_settings = {0x00, 0x00, 0x00, 0x00, 0x01, 1111};
29 media_metadata_attributes_t metadata = {"Test Track", "Chethan", "TNC", "Tumkur", 1, 1, 14400};
31 void static __choose_metadata_settings(void)
34 media_metadata_attributes_t metadata = {0,};
37 printf("\nPlease enter\n");
38 printf("\t0: return to main menu\n");
39 printf("\t1: Meta data settings\n");
40 printf("\tEnter your choice [ ]\b\b");
49 metadata.title = calloc(1, MEDIA_ATRRIBUTE_LENGTH);
50 metadata.artist = calloc(1, MEDIA_ATRRIBUTE_LENGTH);
51 metadata.album = calloc(1, MEDIA_ATRRIBUTE_LENGTH);
52 metadata.genre = calloc(1, MEDIA_ATRRIBUTE_LENGTH);
54 printf("Enter the \"Track\" name\n");
55 scanf("%s", (char *)metadata.title);
57 printf(" Enter the \"Artist\" name\n");
58 scanf("%s", (char *)metadata.artist);
60 printf(" Enter the \"Album\" name\n");
61 scanf("%s", (char *)metadata.album);
63 printf(" Enter the \"Genre\" \n");
64 scanf("%s", (char *)metadata.genre);
66 printf(" Enter the \" Totol NumberOfTracks\" \n");
67 scanf("%d", &metadata.total_tracks);
69 printf(" Enter the \" Track Number\" \n");
70 scanf("%d", &metadata.number);
72 printf(" Enter the \"Duration\" \n");
73 scanf("%d", &metadata.duration);
78 bluetooth_media_player_change_track(&metadata);
80 if (NULL != metadata.title) {
81 free((void *)metadata.title);
82 metadata.title = NULL;
84 if (NULL != metadata.artist) {
85 free((void *)metadata.artist);
86 metadata.artist = NULL;
88 if (NULL != metadata.album) {
89 free((void *)metadata.album);
90 metadata.album = NULL;
92 if (NULL != metadata.genre) {
93 free((void *)metadata.genre);
94 metadata.genre = NULL;
99 void static __choose_player_settings(void)
102 media_player_property_type type;
105 printf("\nPlease choose player settings\n");
106 printf("\t0: return to main menu\n");
107 printf("\t1. Equalizer\n");
108 printf("\t2. Repeat\n");
109 printf("\t3. Shuffle\n");
110 printf("\t4. Scan \n");
111 printf("\t5. Status \n");
112 printf("\t6. Position \n");
113 printf("\tEnter your choice [ ]\b\b");
120 case 1: /* Equalizer */
122 printf("Possible Values - EQUALIZER_OFF = 0x00 and EQUALIZER_ON = 0x01,\n");
123 scanf("%d", &player_settings.equalizer);
126 bluetooth_media_player_change_property(type,
127 (unsigned int)player_settings.equalizer);
133 printf(" Possible Values - REPEAT_MODE_OFF = 0x00, REPEAT_SINGLE_TRACK = 0x01 , \
134 REPEAT_ALL_TRACK = 0x02, REPEAT_GROUP = 0x03\n");
135 scanf("%d", &player_settings.repeat);
138 bluetooth_media_player_change_property(type,
139 (unsigned int)player_settings.repeat);
142 case 3: /* Shuffle */
144 printf(" Possible Values - SHUFFLE_MODE_OFF = 0x00, SHUFFLE_ALL_TRACK = 0x01 , \
145 SHUFFLE_GROUP = 0x02\n");
146 scanf("%d", &player_settings.shuffle);
149 bluetooth_media_player_change_property(type,
150 (unsigned int)player_settings.shuffle);
155 printf(" Possible Values - SCAN_MODE_OFF = 0x00, SCAN_ALL_TRACK = 0x01 , \
156 SCAN_GROUP = 0x02\n");
157 scanf("%d", &player_settings.scan);
160 bluetooth_media_player_change_property(type,
161 (unsigned int)player_settings.scan);
166 printf(" Possible Values - STATUS_PLAYING = 0x00, STATUS_STOPPED = 0x01 , \
167 STATUS_PAUSED = 0x02,STATUS_FORWARD_SEEK = 0x03 \
168 STATUS_REVERSE_SEEK = 0x04 STATUS_ERROR = 0x05\n");
169 scanf("%d", &player_settings.status);
172 bluetooth_media_player_change_property(type,
173 (unsigned int)player_settings.status);
176 case 6: /* Position */
178 printf("Enter the possible value: ");
179 scanf("%d", &player_settings.position);
182 bluetooth_media_player_change_property(type,
183 player_settings.position);
194 GMainLoop *agent_loop;
197 agent_loop = g_main_loop_new(NULL, FALSE);
199 printf("MP-AV test application started\n");
201 printf("\n\n\t0. Exit\n");
202 printf("\t1. bluetooth_media_player_property_changed\n");
203 printf("\t2. bluetooth_media_player_track_changed\n");
204 printf("\tEnter your choice [ ]\b\b");
209 case 0: /* exit the application */
216 __choose_player_settings();
221 __choose_metadata_settings();
226 printf("gmain loop enter\n");
227 g_main_loop_run(agent_loop);
228 printf("gmain loop leave\n");