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_
34 #include <audio-session-manager-types.h>
43 This part is describes multimedia framework session type and function
47 * This enumeration defines application's session types.
50 MM_SESSION_TYPE_MEDIA = 0,
51 MM_SESSION_TYPE_MEDIA_RECORD,
52 MM_SESSION_TYPE_ALARM,
53 MM_SESSION_TYPE_NOTIFY,
54 MM_SESSION_TYPE_EMERGENCY,
56 MM_SESSION_TYPE_VIDEOCALL,
58 MM_SESSION_TYPE_VOICE_RECOGNITION,
59 MM_SESSION_TYPE_RECORD_AUDIO,
60 MM_SESSION_TYPE_RECORD_VIDEO,
65 * This enumeration defines behavior of update.
68 MM_SESSION_UPDATE_TYPE_ADD,
69 MM_SESSION_UPDATE_TYPE_REMOVE,
70 MM_SESSION_UPDATE_TYPE_NUM
71 }session_update_type_t;
74 * This define is for session options
76 #define MM_SESSION_OPTION_PAUSE_OTHERS ASM_SESSION_OPTION_PAUSE_OTHERS
77 #define MM_SESSION_OPTION_UNINTERRUPTIBLE ASM_SESSION_OPTION_UNINTERRUPTIBLE
78 #define MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED ASM_SESSION_OPTION_RESUME_BY_MEDIA_PAUSED
81 * This enumeration defines session callback message type.
84 MM_SESSION_MSG_STOP, /**< Message Stop : this messages means that session of application has interrupted by policy.
85 So application should stop it's multi-media context when this message has come */
86 MM_SESSION_MSG_RESUME, /**< Message Stop : this messages means that session interrupt of application has ended.
87 So application could resume it's multi-media context when this message has come */
92 MM_SESSION_EVENT_MEDIA = 0,
93 MM_SESSION_EVENT_CALL,
94 MM_SESSION_EVENT_ALARM,
95 MM_SESSION_EVENT_EARJACK_UNPLUG,
96 MM_SESSION_EVENT_RESOURCE_CONFLICT,
97 MM_SESSION_EVENT_EMERGENCY,
98 MM_SESSION_EVENT_NOTIFICATION,
102 MM_SESSION_WATCH_EVENT_IGNORE = -1,
103 MM_SESSION_WATCH_EVENT_CALL = 0,
104 MM_SESSION_WATCH_EVENT_VIDEO_CALL,
105 MM_SESSION_WATCH_EVENT_ALARM,
106 MM_SESSION_WATCH_EVENT_NUM
107 }session_watch_event_t;
110 MM_SESSION_WATCH_STATE_STOP = 0,
111 MM_SESSION_WATCH_STATE_PLAYING,
112 MM_SESSION_WATCH_STATE_NUM
113 }session_watch_state_t;
115 typedef void (*session_callback_fn) (session_msg_t msg, session_event_t event, void *user_param);
116 typedef void (*watch_callback_fn) (session_watch_event_t event, session_watch_state_t state, void *user_param);
119 * This function defines application's Multimedia Session policy
121 * @param sessiontype [in] Multimedia Session type
123 * @return This function returns MM_ERROR_NONE on success, or negative value
125 * @remark Session type is unique for each application (each PID actually).
126 * if application want to change session type, Finish session first and Init again
127 * @see MMSessionType mm_session_finish
129 * @pre There should be pre-initialized session type for caller application.
130 * @post A session type of caller application will be defined process widely.
133 #include <mm_session.h>
135 static int _create(void *data)
139 // Initialize Multimedia Session Type
140 ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
143 printf("Can not initialize session \n");
148 static int _terminate(void* data)
152 // Deinitialize Multimedia Session Type
153 ret = mm_session_finish();
156 printf("Can not finish session\n");
164 struct appcore_ops ops = {
166 .terminate = _terminate,
172 return appcore_efl_main(PACKAGE, ..., &ops);
177 int mm_session_init(int sessiontype);
183 * This function defines application's Multimedia Session policy
185 * @param sessiontype [in] Multimedia Session type
186 * @param session_callback_fn [in] session message callback function pointer
187 * @param user_param [in] callback function user parameter
189 * @return This function returns MM_ERROR_NONE on success, or negative value
191 * @remark Session type is unique for each application (each PID actually).
192 * if application want to change session type, Finish session first and Init again
193 * @pre There should be pre-initialized session type for caller application.
194 * @post A session type of caller application will be defined process widely.
195 * And session callback will be registered as given function pointer with given user_param
196 * @see MMSessionType mm_session_finish
200 #include <mm_session.h>
202 session_callback_fn session_cb(session_msg_t msg, session_event_t event, void *user_param)
204 struct appdata* ad = (struct appdata*) user_param;
208 case MM_SESSION_MSG_STOP:
209 // Stop multi-media context here
212 case MM_SESSION_MSG_RESUME:
213 // Resume multi-media context here
222 static int _create(void *data)
224 struct appdata* ad = (struct appdata*) data;
227 // Initialize Multimedia Session Type with callback
228 ret = mm_session_init_ex(MM_SESSION_TYPE_MEDIA, session_cb, (void*)ad);
231 printf("Can not initialize session \n");
236 static int _terminate(void* data)
240 // Deinitialize Multimedia Session Type
241 ret = mm_session_finish();
244 printf("Can not finish session\n");
253 struct appcore_ops ops = {
255 .terminate = _terminate,
261 return appcore_efl_main(PACKAGE, ..., &ops);
266 int mm_session_init_ex(int sessiontype, session_callback_fn callback, void* user_param);
271 * This function finish application's Multimedia Session.
274 * @return This function returns MM_ERROR_NONE on success, or negative value
276 * @remark Session type is unique for each application (each PID actually).
277 * if application want to change session type, Finish session first and Init again
278 * @see mm_session_init
279 * @pre A session type should be initialized for caller application.
280 * @post A session type for caller application will be cleared.
284 #include <mm_session.h>
286 static int _create(void *data)
290 // Initialize Multimedia Session Type
291 ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
294 printf("Can not initialize session \n");
299 static int _terminate(void* data)
303 // Deinitialize Multimedia Session Type
304 ret = mm_session_finish();
307 printf("Can not finish session\n");
315 struct appcore_ops ops = {
317 .terminate = _terminate,
323 return appcore_efl_main(PACKAGE, ..., &ops);
327 int mm_session_finish(void);
330 * This function get current application's Multimedia Session type
332 * @param sessiontype [out] Current Multimedia Session type
333 * @return This function returns MM_ERROR_NONE on success, or negative value
335 * @see mm_session_init
338 int mm_session_get_current_type(int *sessiontype);
341 * This function get current application's Multimedia Session information
343 * @param session_type [out] Current Multimedia Session type
344 * @param session_options [out] Current Multimedia Session options
345 * @return This function returns MM_ERROR_NONE on success, or negative value
350 int mm_session_get_current_information(int *session_type, int *session_options);
353 * This function update application's Multimedia Session options
355 * @param update_type [in] add or remove options
356 * @param session_options [in] Multimedia Session options to be updated
357 * @return This function returns MM_ERROR_NONE on success, or negative value
362 int mm_session_update_option(session_update_type_t update_type, int options);
365 * This function add a watch callback
367 * @param watchevent [in] The session type to be watched
368 * @param watchstate [in] The session state of the session type of first argument to be watched
369 * @param callback [in] The callback which will be called when the watched session state was activated
370 * @param user_param [in] The user param passed from the callback registration function
371 * @return This function returns MM_ERROR_NONE on success, or negative value
376 int mm_session_add_watch_callback(int watchevent, int watchstate, watch_callback_fn callback, void* user_param);
379 * This function removes a watch callback corresponding with two arguments
381 * @param watchevent [in] The session type to be removed
382 * @param watchstate [in] The session state to be removed
383 * @return This function returns MM_ERROR_NONE on success, or negative value
388 int mm_session_remove_watch_callback(int watchevent, int watchstate);
391 * This function initialize resumption of other ASM handles which were paused by this session
392 * It can be used only when call series or voice recognition session is set
394 * @return This function returns MM_ERROR_NONE on success, or negative value
397 int mm_session_reset_resumption_info(void);