4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungbae Shin <seungbae.shin@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_SHARE = 0, /**< Share type : this type shares it's session with other share type application */
49 MM_SESSION_TYPE_EXCLUSIVE, /**< Exclusive type : this type make previous session stop. And it does not allow other share type session start */
54 * This enumeration defines session callback message type.
57 MM_SESSION_MSG_STOP, /**< Message Stop : this messages means that session of application has interrupted by policy.
58 So application should stop it's multi-media context when this message has come */
59 MM_SESSION_MSG_RESUME, /**< Message Stop : this messages means that session interrupt of application has ended.
60 So application could resume it's multi-media context when this message has come */
65 MM_SESSION_EVENT_MEDIA = 0,
66 MM_SESSION_EVENT_CALL,
67 MM_SESSION_EVENT_ALARM,
68 MM_SESSION_EVENT_EARJACK_UNPLUG,
69 MM_SESSION_EVENT_RESOURCE_CONFLICT,
70 MM_SESSION_EVENT_EMERGENCY,
71 MM_SESSION_EVENT_RESUMABLE_MEDIA,
74 typedef void (*session_callback_fn) (session_msg_t msg, session_event_t event, void *user_param);
77 * This function defines application's Multimedia Session policy
79 * @param sessiontype [in] Multimedia Session type
81 * @return This function returns MM_ERROR_NONE on success, or negative value
83 * @remark Session type is unique for each application (each PID actually).
84 * if application want to change session type, Finish session first and Init again
85 * @see MMSessionType mm_session_finish
87 * @pre There should be pre-initialized session type for caller application.
88 * @post A session type of caller application will be defined process widely.
91 #include <mm_session.h>
93 static int _create(void *data)
97 // Initialize Multimedia Session Type
98 ret = mm_session_init(MM_SESSION_TYPE_SHARE);
101 printf("Can not initialize session \n");
106 static int _terminate(void* data)
110 // Deinitialize Multimedia Session Type
111 ret = mm_session_finish();
114 printf("Can not finish session\n");
122 struct appcore_ops ops = {
124 .terminate = _terminate,
130 return appcore_efl_main(PACKAGE, ..., &ops);
135 int mm_session_init(int sessiontype);
141 * This function defines application's Multimedia Session policy
143 * @param sessiontype [in] Multimedia Session type
144 * @param session_callback_fn [in] session message callback function pointer
145 * @param user_param [in] callback function user parameter
147 * @return This function returns MM_ERROR_NONE on success, or negative value
149 * @remark Session type is unique for each application (each PID actually).
150 * if application want to change session type, Finish session first and Init again
151 * @pre There should be pre-initialized session type for caller application.
152 * @post A session type of caller application will be defined process widely.
153 * And session callback will be registered as given function pointer with given user_param
154 * @see MMSessionType mm_session_finish
158 #include <mm_session.h>
160 session_callback_fn session_cb(session_msg_t msg, session_event_t event, void *user_param)
162 struct appdata* ad = (struct appdata*) user_param;
166 case MM_SESSION_MSG_STOP:
167 // Stop multi-media context here
170 case MM_SESSION_MSG_RESUME:
171 // Resume multi-media context here
180 static int _create(void *data)
182 struct appdata* ad = (struct appdata*) data;
185 // Initialize Multimedia Session Type with callback
186 ret = mm_session_init_ex(MM_SESSION_TYPE_SHARE, session_cb, (void*)ad);
189 printf("Can not initialize session \n");
194 static int _terminate(void* data)
198 // Deinitialize Multimedia Session Type
199 ret = mm_session_finish();
202 printf("Can not finish session\n");
211 struct appcore_ops ops = {
213 .terminate = _terminate,
219 return appcore_efl_main(PACKAGE, ..., &ops);
224 int mm_session_init_ex(int sessiontype, session_callback_fn callback, void* user_param);
229 * This function finish application's Multimedia Session.
232 * @return This function returns MM_ERROR_NONE on success, or negative value
234 * @remark Session type is unique for each application (each PID actually).
235 * if application want to change session type, Finish session first and Init again
236 * @see mm_session_init
237 * @pre A session type should be initialized for caller application.
238 * @post A session type for caller application will be cleared.
242 #include <mm_session.h>
244 static int _create(void *data)
248 // Initialize Multimedia Session Type
249 ret = mm_session_init(MM_SESSION_TYPE_SHARE);
252 printf("Can not initialize session \n");
257 static int _terminate(void* data)
261 // Deinitialize Multimedia Session Type
262 ret = mm_session_finish();
265 printf("Can not finish session\n");
273 struct appcore_ops ops = {
275 .terminate = _terminate,
281 return appcore_efl_main(PACKAGE, ..., &ops);
285 int mm_session_finish(void);
288 * This function get current application's Multimedia Session type
290 * @param sessiontype [out] Current Multimedia Session type
291 * @return This function returns MM_ERROR_NONE on success, or negative value
293 * @see mm_session_init
296 int mm_session_get_current_type (int *sessiontype);