[Release version 0.10.29]
[platform/core/multimedia/libmm-camcorder.git] / src / include / mm_camcorder_videorec.h
1 /*
2  * libmm-camcorder
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jeongmo Yang <jm80.yang@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_CAMCORDER_VIDEOREC_H__
23 #define __MM_CAMCORDER_VIDEOREC_H__
24
25 /*=======================================================================================
26 | INCLUDE FILES                                                                         |
27 ========================================================================================*/
28 #include <mm_types.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /*=======================================================================================
35 | GLOBAL DEFINITIONS AND DECLARATIONS FOR CAMCORDER                                     |
36 ========================================================================================*/
37
38 /*=======================================================================================
39 | MACRO DEFINITIONS                                                                     |
40 ========================================================================================*/
41
42 /*=======================================================================================
43 | ENUM DEFINITIONS                                                                      |
44 ========================================================================================*/
45 enum {
46         PUSH_ENCODING_BUFFER_INIT = 0,
47         PUSH_ENCODING_BUFFER_RUN,
48         PUSH_ENCODING_BUFFER_STOP,
49 };
50
51 /*=======================================================================================
52 | STRUCTURE DEFINITIONS                                                                 |
53 ========================================================================================*/
54 /**
55  * MMCamcorder information for video(preview/recording) mode
56  */
57 typedef struct {
58         gboolean b_commiting;           /**< Is it commiting now? */
59         char *filename;                 /**< recorded filename */
60         double record_timestamp_ratio;  /**< timestamp ratio of video recording for slow/fast motion recording */
61         double record_motion_rate;      /**< motion rate of video recording for slow/fast motion recording */
62         GstClockTime prev_preview_ts;   /**< previous preview frame timestamp */
63         GstClockTime base_video_ts;     /**< base video frame timestamp */
64         guint record_drop_count;        /**< drop count of video recording for slow/fast motion recording */
65         guint64 video_frame_count;      /**< current video frame */
66         guint64 audio_frame_count;      /**< current audio frame */
67         guint64 filesize;               /**< current file size */
68         guint64 max_size;               /**< max recording size */
69         guint64 max_time;               /**< max recording time */
70         int fileformat;                 /**< recording file format */
71         int push_encoding_buffer;       /**< ready to record flag */
72         int preview_width;              /**< preview width */
73         int preview_height;             /**< preview height */
74         int video_width;                /**< video width */
75         int video_height;               /**< video height */
76         int fps;                        /**< fps in videosrc caps */
77         gboolean is_firstframe;
78         gboolean get_first_I_frame;     /**< start flag for H.264 preview recording */
79         gboolean support_dual_stream;   /**< support dual stream flag */
80         gboolean record_dual_stream;    /**< record with dual stream flag */
81         gboolean restart_preview;       /**< flag for whether restart preview or not when start recording */
82         GMutex size_check_lock;         /**< mutex for checking recording size */
83 } _MMCamcorderVideoInfo;
84
85 /*=======================================================================================
86 | CONSTANT DEFINITIONS                                                                  |
87 ========================================================================================*/
88
89 /*=======================================================================================
90 | STATIC VARIABLES                                                                      |
91 ========================================================================================*/
92
93 /*=======================================================================================
94 | EXTERN GLOBAL VARIABLE                                                                |
95 ========================================================================================*/
96
97 /*=======================================================================================
98 | GLOBAL FUNCTION PROTOTYPES                                                            |
99 ========================================================================================*/
100 /**
101  * This function creates recorder pipeline.
102  * When application creates initial pipeline, there are only bins for preview.
103  * If application wants to record, recorder pipeline should be created.
104  *
105  * @param[in]   handle          Handle of camcorder context.
106  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
107  * @remarks
108  * @see         __mmcamcorder_create_preview_pipeline()
109  */
110 int _mmcamcorder_create_recorder_pipeline(MMHandleType handle);
111
112 /**
113  * This function connects video stream cb signal.
114  *
115  * @param[in]   handle          Handle of camcorder context.
116  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
117  * @remarks
118  */
119 int _mmcamcorder_connect_video_stream_cb_signal(MMHandleType handle);
120
121 /**
122  * This function remove recorder bin from main pipeline.
123  *
124  * @param[in]   handle          Handle of camcorder context.
125  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
126  * @remarks
127  * @see         __mmcamcorder_create_preview_pipeline(), __mmcamcorder_add_recorder_pipeline()
128  */
129 int _mmcamcorder_remove_recorder_pipeline(MMHandleType handle);
130
131 /**
132  * This function operates each command on video mode.
133  *
134  * @param[in]   handle          Handle of camcorder context.
135  * @param[in]   command         command type received from Multimedia Framework.
136  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
137  * @remarks
138  * @see         _mmcamcorder_set_functions()
139  */
140 int _mmcamcorder_video_command(MMHandleType handle, int command);
141
142 /**
143  * This function handles EOS(end of stream) when commit video recording.
144  *
145  * @param[in]   handle          Handle of camcorder context.
146  * @return      This function returns TRUE on success, or FALSE on failure.
147  * @remarks
148  * @see         _mmcamcorder_set_functions()
149  */
150 int _mmcamcorder_video_handle_eos(MMHandleType handle);
151
152 /**
153  * This function prepares video recording
154  *
155  * @param[in]   handle          Handle of camcorder context.
156  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
157  * @remarks
158  */
159 int _mmcamcorder_video_prepare_record(MMHandleType handle);
160
161
162 #ifdef __cplusplus
163 }
164 #endif
165
166 #endif /* __MM_CAMCORDER_VIDEOREC_H__ */