Merge branch 'tizen' into tizen_5.5
[platform/core/multimedia/libmm-streamrecorder.git] / src / include / mm_streamrecorder_internal.h
1 /*
2  * libmm-streamrecorder
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyuntae Kim <ht1211.kim@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22 #ifndef __MM_STREAMRECORDER_INTERNAL_H__
23 #define __MM_STREAMRECORDER_INTERNAL_H__
24
25 /*=======================================================================================
26 | INCLUDE FILES                                                                         |
27 ========================================================================================*/
28 #include <malloc.h>
29 #include <string.h>
30 #include <unistd.h>
31 #include <pthread.h>
32 #include <semaphore.h>
33
34 #include <mm_types.h>
35 #include <mm_attrs.h>
36 #include <mm_message.h>
37
38 #include "mm_streamrecorder.h"
39 #include <gst/gst.h>
40
41 /* streamrecorder sub module */
42 #include "mm_streamrecorder_util.h"
43 #include "mm_streamrecorder_video.h"
44 #include "mm_streamrecorder_audio.h"
45 #include "mm_streamrecorder_fileinfo.h"
46 #include "mm_streamrecorder_gstcommon.h"
47 #include "mm_streamrecorder_ini.h"
48 #include "mm_streamrecorder_buffer_manager.h"
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 /*=======================================================================================
55 | MACRO DEFINITIONS                                                                     |
56 ========================================================================================*/
57
58 #ifndef ARRAY_SIZE
59 /**
60  *      Macro for getting array size
61  */
62 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
63 #endif
64
65 #define _MMSTREAMRECORDER_STATE_SET_COUNT               3       /* checking interval */
66 #define _MMSTREAMRECORDER_STATE_CHECK_INTERVAL  1000    //5000      /* checking interval */
67
68 /**
69  *      Functions related with LOCK and WAIT
70  */
71 #define _MMSTREAMRECORDER_CAST_MTSAFE(handle)                           (((mmf_streamrecorder_t*)handle)->mtsafe)
72 #define _MMSTREAMRECORDER_LOCK_FUNC(mutex)                              pthread_mutex_lock(&mutex)
73 #define _MMSTREAMRECORDER_TRYLOCK_FUNC(mutex)                   (!pthread_mutex_trylock(&mutex))
74 #define _MMSTREAMRECORDER_UNLOCK_FUNC(mutex)                            pthread_mutex_unlock(&mutex)
75
76 #define _MMSTREAMRECORDER_GET_LOCK(handle)                                      (_MMSTREAMRECORDER_CAST_MTSAFE(handle).lock)
77 #define _MMSTREAMRECORDER_LOCK(handle)                                          _MMSTREAMRECORDER_LOCK_FUNC(_MMSTREAMRECORDER_GET_LOCK(handle))
78 #define _MMSTREAMRECORDER_TRYLOCK(handle)                                       _MMSTREAMRECORDER_TRYLOCK_FUNC(_MMSTREAMRECORDER_GET_LOCK(handle))
79 #define _MMSTREAMRECORDER_UNLOCK(handle)                                        _MMSTREAMRECORDER_UNLOCK_FUNC(_MMSTREAMRECORDER_GET_LOCK(handle))
80
81 #define _MMSTREAMRECORDER_GET_COND(handle)                                      (_MMSTREAMRECORDER_CAST_MTSAFE(handle).cond)
82 #define _MMSTREAMRECORDER_WAIT(handle)                                          pthread_cond_wait(&_MMSTREAMRECORDER_GET_COND(handle), _MMSTREAMRECORDER_GET_LOCK(handle))
83 #define _MMSTREAMRECORDER_TIMED_WAIT(handle, timeout)           pthread_cond_timedwait(&_MMSTREAMRECORDER_GET_COND(handle), _MMSTREAMRECORDER_GET_LOCK(handle), &timeout)
84
85 /* for command */
86 #define _MMSTREAMRECORDER_GET_CMD_LOCK(handle)                                  (_MMSTREAMRECORDER_CAST_MTSAFE(handle).cmd_lock)
87 #define _MMSTREAMRECORDER_LOCK_CMD(handle)                                              _MMSTREAMRECORDER_LOCK_FUNC(_MMSTREAMRECORDER_GET_CMD_LOCK(handle))
88 #define _MMSTREAMRECORDER_TRYLOCK_CMD(handle)                                   _MMSTREAMRECORDER_TRYLOCK_FUNC(_MMSTREAMRECORDER_GET_CMD_LOCK(handle))
89 #define _MMSTREAMRECORDER_UNLOCK_CMD(handle)                                            _MMSTREAMRECORDER_UNLOCK_FUNC(_MMSTREAMRECORDER_GET_CMD_LOCK(handle))
90
91 /* for state change */
92 #define _MMSTREAMRECORDER_GET_STATE_LOCK(handle)                                        (_MMSTREAMRECORDER_CAST_MTSAFE(handle).state_lock)
93 #define _MMSTREAMRECORDER_LOCK_STATE(handle)                                            _MMSTREAMRECORDER_LOCK_FUNC(_MMSTREAMRECORDER_GET_STATE_LOCK(handle))
94 #define _MMSTREAMRECORDER_TRYLOCK_STATE(handle)                                 _MMSTREAMRECORDER_TRYLOCK_FUNC(_MMSTREAMRECORDER_GET_STATE_LOCK(handle))
95 #define _MMSTREAMRECORDER_UNLOCK_STATE(handle)                                          _MMSTREAMRECORDER_UNLOCK_FUNC(_MMSTREAMRECORDER_GET_STATE_LOCK(handle))
96
97 /* for gstreamer state change */
98 #define _MMSTREAMRECORDER_GET_GST_STATE_LOCK(handle)                                    (_MMSTREAMRECORDER_CAST_MTSAFE(handle).gst_state_lock)
99 #define _MMSTREAMRECORDER_LOCK_GST_STATE(handle)                                                _MMSTREAMRECORDER_LOCK_FUNC(_MMSTREAMRECORDER_GET_GST_STATE_LOCK(handle))
100 #define _MMSTREAMRECORDER_TRYLOCK_GST_STATE(handle)                                     _MMSTREAMRECORDER_TRYLOCK_FUNC(_MMSTREAMRECORDER_GET_GST_STATE_LOCK(handle))
101 #define _MMSTREAMRECORDER_UNLOCK_GST_STATE(handle)                                              _MMSTREAMRECORDER_UNLOCK_FUNC(_MMSTREAMRECORDER_GET_GST_STATE_LOCK(handle))
102
103 /* for setting/calling callback */
104 #define _MMSTREAMRECORDER_GET_MESSAGE_CALLBACK_LOCK(handle)      (_MMSTREAMRECORDER_CAST_MTSAFE(handle).message_cb_lock)
105 #define _MMSTREAMRECORDER_LOCK_MESSAGE_CALLBACK(handle)          _MMSTREAMRECORDER_LOCK_FUNC(_MMSTREAMRECORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
106 #define _MMSTREAMRECORDER_TRYLOCK_MESSAGE_CALLBACK(handle)       _MMSTREAMRECORDER_TRYLOCK_FUNC(_MMSTREAMRECORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
107 #define _MMSTREAMRECORDER_UNLOCK_MESSAGE_CALLBACK(handle)        _MMSTREAMRECORDER_UNLOCK_FUNC(_MMSTREAMRECORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
108
109 /**
110  * Caster of main handle (streamrecorder)
111  */
112 #define MMF_STREAMRECORDER(h) (mmf_streamrecorder_t *)(h)
113
114 /**
115  * Caster of subcontext
116  */
117 #define MMF_STREAMRECORDER_SUBCONTEXT(h) (((mmf_streamrecorder_t *)(h))->sub_context)
118
119 /* LOCAL CONSTANT DEFINITIONS */
120
121 /*=======================================================================================
122 | ENUM DEFINITIONS                                                                      |
123 ========================================================================================*/
124
125 /**
126  * streamrecorder Pipeline's Element name.
127  * @note index of element.
128  */
129 typedef enum {
130         _MMSTREAMRECORDER_ENCODE_NONE = (-1),
131
132         /* Main Pipeline Element */
133         _MMSTREAMRECORDER_ENCODE_MAIN_PIPE = 0x00,
134
135         /* Pipeline element of Audio input */
136         _MMSTREAMRECORDER_AUDIOSRC_BIN,
137         _MMSTREAMRECORDER_AUDIOSRC_SRC, /* appsrc */
138         _MMSTREAMRECORDER_AUDIOSRC_FILT,
139         _MMSTREAMRECORDER_AUDIOSRC_CONV,
140         _MMSTREAMRECORDER_AUDIOSRC_ENC,
141         _MMSTREAMRECORDER_AUDIOSRC_QUE,
142
143         /* Pipeline element of Encodebin */
144         _MMSTREAMRECORDER_ENCSINK_BIN,
145         _MMSTREAMRECORDER_ENCSINK_SRC,  /* video appsrc */
146         _MMSTREAMRECORDER_ENCSINK_FILT,
147         _MMSTREAMRECORDER_ENCSINK_ENCBIN,
148         _MMSTREAMRECORDER_ENCSINK_AQUE,
149         _MMSTREAMRECORDER_ENCSINK_CONV,
150         _MMSTREAMRECORDER_ENCSINK_AENC,
151         _MMSTREAMRECORDER_ENCSINK_AENC_QUE,
152         _MMSTREAMRECORDER_ENCSINK_VQUE,
153         _MMSTREAMRECORDER_ENCSINK_VCONV,
154         _MMSTREAMRECORDER_ENCSINK_VENC,
155         _MMSTREAMRECORDER_ENCSINK_VENC_QUE,
156         _MMSTREAMRECORDER_ENCSINK_PARSER,
157         _MMSTREAMRECORDER_ENCSINK_ITOG,
158         _MMSTREAMRECORDER_ENCSINK_ICROP,
159         _MMSTREAMRECORDER_ENCSINK_ISCALE,
160         _MMSTREAMRECORDER_ENCSINK_IFILT,
161         _MMSTREAMRECORDER_ENCSINK_IQUE,
162         _MMSTREAMRECORDER_ENCSINK_IENC,
163         _MMSTREAMRECORDER_ENCSINK_MUX,
164         _MMSTREAMRECORDER_ENCSINK_SINK,
165
166         _MMSTREAMRECORDER_ENCODE_PIPELINE_ELEMENT_NUM,
167 } _MMSTREAMRECORDER_ENCODE_PIPELINE_ELELMENT;
168
169 typedef enum {
170         /* Pipeline element of Audio input */
171         _MMSTREAMRECORDER_AUDIO_SRC = 0x01,
172         _MMSTREAMRECORDER_AUDIO_CONV,
173         _MMSTREAMRECORDER_AUDIO_ENC,
174         _MMSTREAMRECORDER_AUDIO_QUE,
175
176         /* Pipeline element of Video input */
177         _MMSTREAMRECORDER_VIDEO_SRC,
178         _MMSTREAMRECORDER_VIDEO_CAPS,
179         _MMSTREAMRECORDER_VIDEO_CONV,
180         _MMSTREAMRECORDER_VIDEO_ENC,
181         _MMSTREAMRECORDER_VIDEO_QUE,
182
183         /* Pipeline element of Common */
184         _MMSTREAMRECORDER_MUX,
185         _MMSTREAMRECORDER_SINK,
186
187         _MMSTREAMRECORDER_ELELMENT_NUM,
188 } _MMSTREAMRECORDER_ELELMENT;
189
190 /**
191  * Command type for streamrecorder.
192  */
193
194 typedef enum {
195         _MM_STREAMRECORDER_CMD_CREATE,
196         _MM_STREAMRECORDER_CMD_DESTROY,
197         _MM_STREAMRECORDER_CMD_REALIZE,
198         _MM_STREAMRECORDER_CMD_UNREALIZE,
199         _MM_STREAMRECORDER_CMD_START,
200         _MM_STREAMRECORDER_CMD_STOP,
201         _MM_STREAMRECORDER_CMD_RECORD,
202         _MM_STREAMRECORDER_CMD_PAUSE,
203         _MM_STREAMRECORDER_CMD_COMMIT,
204         _MM_STREAMRECORDER_CMD_CANCEL,
205         _MM_STREAMRECORDER_CMD_QUIT,
206 } _MMstreamrecorderCommandType;
207
208 /**
209  * System state change cause
210  */
211 typedef enum {
212         _MMSTREAMRECORDER_STATE_CHANGE_NORMAL = 0,
213 } _MMstreamrecorderStateChange;
214
215
216 /*=======================================================================================
217 | STRUCTURE DEFINITIONS                                                                 |
218 ========================================================================================*/
219
220 /**
221  * MMstreamrecorder information for Multi-Thread Safe
222  */
223 typedef struct {
224         pthread_mutex_t lock;           /**< Mutex (for general use) */
225         pthread_cond_t cond;            /**< Condition (for general use) */
226         pthread_mutex_t cmd_lock;       /**< Mutex (for command) */
227         pthread_mutex_t state_lock;     /**< Mutex (for state change) */
228         pthread_mutex_t gst_state_lock; /**< Mutex (for state change) */
229         pthread_mutex_t message_cb_lock;/**< Mutex (for message callback) */
230 } _MMStreamRecorderMTSafe;
231
232 /**
233  * MMstreamrecorder information for command loop
234  */
235
236 /**
237  * MMstreamrecorder Sub Context
238  */
239 typedef struct {
240         bool isMaxsizePausing;                          /**< Because of size limit, pipeline is paused. */
241         bool isMaxtimePausing;                          /**< Because of time limit, pipeline is paused. */
242         int encode_element_num;                         /**< count of encode element */
243         GstClockTime pipeline_time;                     /**< current time of Gstreamer Pipeline */
244         GstClockTime pause_time;                        /**< amount of time while pipeline is in PAUSE state.*/
245         gboolean error_occurs;                          /**< flag for error */
246         int error_code;                                         /**< error code for internal gstreamer error */
247         gboolean ferror_send;                           /**< file write/seek error **/
248         guint ferror_count;                                     /**< file write/seek error count **/
249         gboolean bget_eos;                                      /**< Whether getting EOS */
250         gboolean video_enable;                          /**< whether video is disabled or not when record */
251         gboolean audio_enable;                          /**< whether audio is disabled or not when record */
252
253         /* INI information */
254         unsigned int fourcc;                            /**< Get fourcc value */
255         _MMStreamRecorderVideoInfo *info_video;  /**< extra information for video recording */
256         _MMStreamRecorderAudioInfo *info_audio;  /**< extra information for audio recording */
257         _MMStreamRecorderFileInfo *info_file;  /**< extra information for audio recording */
258         _MMStreamRecorderGstElement *encode_element;
259                                                                                          /**< array of encode element */
260
261 //  type_element *VideosinkElement;         /**< configure data of videosink element */
262 } _MMStreamRecorderSubContext;
263
264 /**
265   * _MMstreamrecorderContext
266   */
267 typedef struct mmf_streamrecorder {
268         /* information */
269         //  int type;               /**< mmstreamrecorder_mode_type */
270         int state;              /**< state of streamrecorder */
271         //  int target_state;       /**< Target state that want to set. This is a flag that
272         //                             * stands for async state changing. If this value differ from state,
273         //                             * it means state is changing now asychronously. */
274
275         /* handles */
276         MMHandleType attributes;                           /**< Attribute handle */
277         _MMStreamRecorderSubContext *sub_context;       /**< sub context */
278         GList *buffer_probes;                              /**< a list of buffer probe handle */
279         GList *event_probes;                               /**< a list of event probe handle */
280         GList *data_probes;                                        /**< a list of data probe handle */
281         GList *signals;                                            /**< a list of signal handle */
282         GList *msg_data;                                           /**< a list of msg data */
283         guint pipeline_cb_event_id;                        /**< Event source ID of pipeline message callback */
284         guint encode_pipeline_cb_event_id;         /**< Event source ID of encode pipeline message callback */
285
286         /* callback handlers */
287         MMMessageCallback msg_cb;                                                               /**< message callback */
288         void *msg_cb_param;                                                                             /**< message callback parameter */
289         int (*command) (MMHandleType, int);                                             /**< streamrecorder's command */
290
291         /* etc */
292         _MMStreamRecorderMTSafe mtsafe;                                                          /**< Thread safe */
293         mm_streamrecorder_ini_t ini;
294
295         int reserved[4];                        /**< reserved */
296 } mmf_streamrecorder_t;
297
298 /*=======================================================================================
299 | EXTERN GLOBAL VARIABLE                                                                |
300 ========================================================================================*/
301
302 /*=======================================================================================
303 | GLOBAL FUNCTION PROTOTYPES                                                            |
304 ========================================================================================*/
305 /**
306  *      This function creates streamrecorder for capturing still image and recording.
307  *
308  *      @param[out]     handle          Specifies the streamrecorder  handle
309  *      @param[in]      info            Preset information of streamrecorder
310  *      @return         This function returns zero on success, or negative value with error code.
311  *      @remarks        When this function calls successfully, streamrecorder  handle will be filled with a @n
312  *                      valid value and the state of  the streamrecorder  will become MM_streamrecorder_STATE_NULL.@n
313  *                      Note that  it's not ready to working streamrecorder. @n
314  *                      You should call mmstreamrecorder_realize before starting streamrecorder.
315  *      @see            _mmstreamrecorder_create
316  */
317 int _mmstreamrecorder_create(MMHandleType *handle);
318
319 /**
320 *  This function gets the current state of streamreccorder.
321 *  mm_streamrecorderr is working on the base of its state. An user should check the state of mm_streamrecorder before calling its functions.
322 *  If the handle is avaiable, user can retrieve the value.
323 *
324 *  @param[in]  streamrecorder   A handle of streamrecorder.
325 *  @param[out] state       On return, it contains current state of streamrecorder.
326 *  @return     This function returns zero(MM_ERROR_NONE) on success, or negative value with error code.
327 *          Please refer 'mm_error.h' to know the exact meaning of the error.
328 *  @see        MMStreamRecorderStateType
329 *  @pre        None
330 *  @post       None
331 *  @remarks    None
332 */
333
334 MMStreamRecorderStateType _mmstreamrecorder_get_state(MMHandleType handle);
335
336 /**
337  *      This function destroys instance of streamrecorder.
338  *
339  *      @param[in]      hstreamrecorder Specifies the streamrecorder  handle
340  *      @return         This function returns zero on success, or negative value with error code.
341  *      @see            _mmstreamrecorder_create
342  */
343 int _mmstreamrecorder_destroy(MMHandleType handle);
344
345 /**
346  *      This function allocates memory for streamrecorder.
347  *
348  *      @param[in]      hstreamrecorder Specifies the streamrecorder  handle
349  *      @return         This function returns zero on success, or negative value with error code.
350  *      @remarks        This function can  be called successfully when current state is MM_streamrecorder_STATE_NULL @n
351  *                      and  the state of the streamrecorder  will become MM_streamrecorder_STATE_READY. @n
352  *                      Otherwise, this function will return MM_ERROR_streamrecorder_INVALID_CONDITION.
353  *      @see            _mmstreamrecorder_unrealize
354  *      @pre            MM_streamrecorder_STATE_NULL
355  *      @post           MM_streamrecorder_STATE_READY
356  */
357 int _mmstreamrecorder_realize(MMHandleType hstreamrecorder);
358
359 /**
360  *      This function free allocated memory for streamrecorder.
361  *
362  *      @param[in]      hstreamrecorder Specifies the streamrecorder  handle
363  *      @return         This function returns zero on success, or negative value with error code.
364  *      @remarks        This function release all resources which are allocated for the streamrecorder engine.@n
365  *                      This function can  be called successfully when current state is MM_streamrecorder_STATE_READY and  @n
366  *                      the state of the streamrecorder  will become MM_streamrecorder_STATE_NULL. @n
367  *                      Otherwise, this function will return MM_ERROR_streamrecorder_INVALID_CONDITION.
368  *      @see            _mmstreamrecorder_realize
369  *      @pre            MM_streamrecorder_STATE_READY
370  *      @post           MM_streamrecorder_STATE_NULL
371  */
372 int _mmstreamrecorder_unrealize(MMHandleType hstreamrecorder);
373
374 /**
375  *      This function is to start previewing.
376  *
377  *      @param[in]      hstreamrecorder Specifies the streamrecorder  handle
378  *      @return         This function returns zero on success, or negative value with error code.
379  *      @remarks        This function can  be called successfully when current state is MM_streamrecorder_STATE_READY and  @n
380  *                      the state of the streamrecorder  will become MM_streamrecorder_STATE_PREPARE. @n
381  *                      Otherwise, this function will return MM_ERROR_streamrecorder_INVALID_CONDITION.
382  *      @see            _mmstreamrecorder_stop
383  */
384 int _mmstreamrecorder_record(MMHandleType hstreamrecorder);
385
386 int _mmstreamrecorder_push_video_packet(MMHandleType handle, media_packet_h packet, unsigned long long timestamp, void *buffer);
387
388 int _mmstreamrecorder_push_stream_buffer(MMHandleType handle, MMStreamRecorderStreamType streamtype, unsigned long long timestamp, void *buffer, int size);
389
390 /**
391  *      This function is to pause video and audio recording
392  *
393  *      @param[in]      hstreamrecorder Specifies the streamrecorder  handle
394  *      @return         This function returns zero on success, or negative value with error code.
395  *      @remarks        This function can  be called successfully when current state is MM_streamrecorder_STATE_RECORDING and  @n
396  *                      the  state of the streamrecorder  will become MM_streamrecorder_STATE_PAUSED.@n
397  *                      Otherwise, this function will return MM_ERROR_streamrecorder_INVALID_CONDITION.@n
398  *      @see            _mmstreamrecorder_record
399  */
400 int _mmstreamrecorder_pause(MMHandleType hstreamrecorder);
401
402 /**
403  *      This function is to stop video and audio  recording and  save results.
404  *
405  *      @param[in]      hstreamrecorder Specifies the streamrecorder  handle
406  *      @return         This function returns zero on success, or negative value with error code.
407  *      @remarks        This function can  be called successfully when current state is @n
408  *                      MM_streamrecorder_STATE_PAUSED or MM_streamrecorder_STATE_RECORDING and  @n
409  *                      the state of the streamrecorder  will become MM_streamrecorder_STATE_PREPARE. @n
410  *                      Otherwise, this function will return MM_ERROR_streamrecorder_INVALID_CONDITION
411  *      @see            _mmstreamrecorder_cancel
412  */
413 int _mmstreamrecorder_commit(MMHandleType hstreamrecorder);
414
415 /**
416  *      This function is to stop video and audio recording and do not save results.
417  *
418  *      @param[in]      hstreamrecorder Specifies the streamrecorder  handle
419  *      @return         This function returns zero on success, or negative value with error code.
420  *      @remarks        This function can  be called successfully when current state is @n
421  *                      MM_streamrecorder_STATE_PAUSED or MM_streamrecorder_STATE_RECORDING and  @n
422  *                      the state of the streamrecorder  will become MM_streamrecorder_STATE_PREPARE. @n
423  *                      Otherwise, this function will return MM_ERROR_streamrecorder_INVALID_CONDITION.
424  *      @see            _mmstreamrecorder_commit
425  */
426 int _mmstreamrecorder_cancel(MMHandleType hstreamrecorder);
427
428 /**
429  *      This function is to set callback for receiving messages from streamrecorder.
430  *
431  *      @param[in]      hstreamrecorder Specifies the streamrecorder  handle
432  *      @param[in]      callback        Specifies the function pointer of callback function
433  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
434  *
435  *      @return         This function returns zero on success, or negative value with error code.
436  *      @remarks        typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
437  *              @n
438  *              typedef union                           @n
439  *              {                                                       @n
440  *                      int code;                               @n
441  *                      struct                                  @n
442  *                      {                                               @n
443  *                              int total;                      @n
444  *                              int elapsed;            @n
445  *                      } time;                                 @n
446  *                      struct                                  @n
447  *                      {                                               @n
448  *                              int previous;           @n
449  *                              int current;                    @n
450  *                      } state;                                        @n
451  *              } mm_message_type;      @n
452  *                                                                      @n
453  *              If a  message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
454  *              state value in mm_message_type  will be a mmstreamrecorder_state_type enum value;@n
455  *              @n
456  *              If  a message value for mm_message_callback is MM_MESSAGE_ERROR,  @n
457  *              the code value in mm_message_type will be a mmplayer_error_type enum value;
458  *
459  *      @see            mm_message_type,  mmstreamrecorder_state_type,  mmstreamrecorder_error_type
460  */
461 int _mmstreamrecorder_set_message_callback(MMHandleType hstreamrecorder, MMMessageCallback callback, void *user_data);
462
463 /**
464  * This function allocates structure of subsidiary attributes.
465  *
466  * @param[in]   type            Allocation type of streamrecorder context.
467  * @return      This function returns structure pointer on success, NULL value on failure.
468  * @remarks
469  * @see         _mmstreamrecorder_dealloc_subcontext()
470  *
471  */
472 int _mmstreamrecorder_alloc_subcontext(MMHandleType handle);
473
474 int _mmstreamrecorder_alloc_subcontext_videoinfo(MMHandleType handle);
475
476 int _mmstreamrecorder_alloc_subcontext_audioinfo(MMHandleType handle);
477
478 int _mmstreamrecorder_alloc_subcontext_fileinfo(MMHandleType handle);
479
480 /**
481  * This function releases structure of subsidiary attributes.
482  *
483  * @param[in]   sc              Handle of streamrecorder subcontext.
484  * @return      void
485  * @remarks
486  * @see         _mmstreamrecorder_alloc_subcontext()
487  *
488  */
489 void _mmstreamrecorder_dealloc_subcontext(MMHandleType handle);
490
491 /**
492  * This function sets command function according to the type.
493  *
494  * @param[in]   handle          Handle of streamrecorder context.
495  * @param[in]   type            Allocation type of streamrecorder context.
496  * @return      This function returns MM_ERROR_NONE on success, or other values with error code.
497  * @remarks
498  * @see         __mmstreamrecorder_video_command(), __mmstreamrecorder_audio_command(), __mmstreamrecorder_image_command()
499  *
500  */
501 void _mmstreamrecorder_set_functions(MMHandleType handle);
502
503 void _mmstreamrecorder_unset_functions(MMHandleType handle);
504
505 #ifdef __cplusplus
506 }
507 #endif
508 #endif                                                  /* __MM_streamrecorder_INTERNAL_H__ */