4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungbae Shin <seungbae.shin at samsung.com>, Sangchul Lee <sc11.lee at 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 * This file declares common data structure of multimedia framework.
29 * @brief This file declares multimedia framework session type.
31 #ifndef _MM_SESSION_H_
32 #define _MM_SESSION_H_
41 This part is describes multimedia framework session type and function
45 * This enumeration defines application's session types.
48 MM_SESSION_TYPE_MEDIA = 0,
49 MM_SESSION_TYPE_MEDIA_RECORD,
50 MM_SESSION_TYPE_ALARM,
51 MM_SESSION_TYPE_NOTIFY,
52 MM_SESSION_TYPE_EMERGENCY,
54 MM_SESSION_TYPE_VIDEOCALL,
56 MM_SESSION_TYPE_VOICE_RECOGNITION,
57 MM_SESSION_TYPE_RECORD_AUDIO,
58 MM_SESSION_TYPE_RECORD_VIDEO,
63 * This enumeration defines behavior of update.
66 MM_SESSION_UPDATE_TYPE_ADD,
67 MM_SESSION_UPDATE_TYPE_REMOVE,
68 MM_SESSION_UPDATE_TYPE_NUM
69 }session_update_type_t;
72 * This define is for session options
74 #define MM_SESSION_OPTION_PAUSE_OTHERS 0x0001
75 #define MM_SESSION_OPTION_UNINTERRUPTIBLE 0x0002
76 #define MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED 0x0010
79 * This enumeration defines session callback message type.
82 MM_SESSION_MSG_STOP, /**< Message Stop : this messages means that session of application has interrupted by policy.
83 So application should stop it's multi-media context when this message has come */
84 MM_SESSION_MSG_RESUME, /**< Message Stop : this messages means that session interrupt of application has ended.
85 So application could resume it's multi-media context when this message has come */
90 MM_SESSION_EVENT_MEDIA = 0,
91 MM_SESSION_EVENT_CALL,
92 MM_SESSION_EVENT_ALARM,
93 MM_SESSION_EVENT_EARJACK_UNPLUG,
94 MM_SESSION_EVENT_RESOURCE_CONFLICT,
95 MM_SESSION_EVENT_EMERGENCY,
96 MM_SESSION_EVENT_NOTIFICATION,
100 MM_SESSION_WATCH_EVENT_IGNORE = -1,
101 MM_SESSION_WATCH_EVENT_CALL = 0,
102 MM_SESSION_WATCH_EVENT_VIDEO_CALL,
103 MM_SESSION_WATCH_EVENT_ALARM,
104 MM_SESSION_WATCH_EVENT_NUM
105 }session_watch_event_t;
108 MM_SESSION_WATCH_STATE_STOP = 0,
109 MM_SESSION_WATCH_STATE_PLAYING,
110 MM_SESSION_WATCH_STATE_NUM
111 }session_watch_state_t;
113 typedef void (*session_callback_fn) (session_msg_t msg, session_event_t event, void *user_param);
114 typedef void (*watch_callback_fn) (session_watch_event_t event, session_watch_state_t state, void *user_param);
117 * This function defines application's Multimedia Session policy
119 * @param sessiontype [in] Multimedia Session type
121 * @return This function returns MM_ERROR_NONE on success, or negative value
123 * @remark Session type is unique for each application (each PID actually).
124 * if application want to change session type, Finish session first and Init again
125 * @see MMSessionType mm_session_finish
127 * @pre There should be pre-initialized session type for caller application.
128 * @post A session type of caller application will be defined process widely.
131 #include <mm_session.h>
133 static int _create(void *data)
137 // Initialize Multimedia Session Type
138 ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
141 printf("Can not initialize session \n");
146 static int _terminate(void* data)
150 // Deinitialize Multimedia Session Type
151 ret = mm_session_finish();
154 printf("Can not finish session\n");
162 struct appcore_ops ops = {
164 .terminate = _terminate,
170 return appcore_efl_main(PACKAGE, ..., &ops);
175 int mm_session_init(int sessiontype);
181 * This function defines application's Multimedia Session policy
183 * @param sessiontype [in] Multimedia Session type
184 * @param session_callback_fn [in] session message callback function pointer
185 * @param user_param [in] callback function user parameter
187 * @return This function returns MM_ERROR_NONE on success, or negative value
189 * @remark Session type is unique for each application (each PID actually).
190 * if application want to change session type, Finish session first and Init again
191 * @pre There should be pre-initialized session type for caller application.
192 * @post A session type of caller application will be defined process widely.
193 * And session callback will be registered as given function pointer with given user_param
194 * @see MMSessionType mm_session_finish
198 #include <mm_session.h>
200 session_callback_fn session_cb(session_msg_t msg, session_event_t event, void *user_param)
202 struct appdata* ad = (struct appdata*) user_param;
206 case MM_SESSION_MSG_STOP:
207 // Stop multi-media context here
210 case MM_SESSION_MSG_RESUME:
211 // Resume multi-media context here
220 static int _create(void *data)
222 struct appdata* ad = (struct appdata*) data;
225 // Initialize Multimedia Session Type with callback
226 ret = mm_session_init_ex(MM_SESSION_TYPE_MEDIA, session_cb, (void*)ad);
229 printf("Can not initialize session \n");
234 static int _terminate(void* data)
238 // Deinitialize Multimedia Session Type
239 ret = mm_session_finish();
242 printf("Can not finish session\n");
251 struct appcore_ops ops = {
253 .terminate = _terminate,
259 return appcore_efl_main(PACKAGE, ..., &ops);
264 int mm_session_init_ex(int sessiontype, session_callback_fn callback, void* user_param);
269 * This function finish application's Multimedia Session.
272 * @return This function returns MM_ERROR_NONE on success, or negative value
274 * @remark Session type is unique for each application (each PID actually).
275 * if application want to change session type, Finish session first and Init again
276 * @see mm_session_init
277 * @pre A session type should be initialized for caller application.
278 * @post A session type for caller application will be cleared.
282 #include <mm_session.h>
284 static int _create(void *data)
288 // Initialize Multimedia Session Type
289 ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
292 printf("Can not initialize session \n");
297 static int _terminate(void* data)
301 // Deinitialize Multimedia Session Type
302 ret = mm_session_finish();
305 printf("Can not finish session\n");
313 struct appcore_ops ops = {
315 .terminate = _terminate,
321 return appcore_efl_main(PACKAGE, ..., &ops);
325 int mm_session_finish(void);
328 * This function get current application's Multimedia Session type
330 * @param sessiontype [out] Current Multimedia Session type
331 * @return This function returns MM_ERROR_NONE on success, or negative value
333 * @see mm_session_init
336 int mm_session_get_current_type(int *sessiontype);
339 * This function get current application's Multimedia Session information
341 * @param session_type [out] Current Multimedia Session type
342 * @param session_options [out] Current Multimedia Session options
343 * @return This function returns MM_ERROR_NONE on success, or negative value
348 int mm_session_get_current_information(int *session_type, int *session_options);
351 * This function update application's Multimedia Session options
353 * @param update_type [in] add or remove options
354 * @param session_options [in] Multimedia Session options to be updated
355 * @return This function returns MM_ERROR_NONE on success, or negative value
360 int mm_session_update_option(session_update_type_t update_type, int options);
363 * This function add a watch callback
365 * @param watchevent [in] The session type to be watched
366 * @param watchstate [in] The session state of the session type of first argument to be watched
367 * @param callback [in] The callback which will be called when the watched session state was activated
368 * @param user_param [in] The user param passed from the callback registration function
369 * @return This function returns MM_ERROR_NONE on success, or negative value
374 int mm_session_add_watch_callback(int watchevent, int watchstate, watch_callback_fn callback, void* user_param);
377 * This function removes a watch callback corresponding with two arguments
379 * @param watchevent [in] The session type to be removed
380 * @param watchstate [in] The session state to be removed
381 * @return This function returns MM_ERROR_NONE on success, or negative value
386 int mm_session_remove_watch_callback(int watchevent, int watchstate);
389 * This function initialize resumption of other ASM handles which were paused by this session
390 * It can be used only when call series or voice recognition session is set
392 * @return This function returns MM_ERROR_NONE on success, or negative value
395 int mm_session_reset_resumption_info(void);