5267d9d8adcc7a36da812bd69ae2ed7d4d645834
[framework/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 prev_video_ts;     /**< previous 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         int is_firstframe;
78         gboolean support_dual_stream;   /**< support dual stream flag */
79         gboolean record_dual_stream;    /**< record with dual stream flag */
80         gboolean restart_preview;       /**< flag for whether restart preview or not when start recording */
81         pthread_mutex_t size_check_lock;/**< mutex for checking recording size */
82 } _MMCamcorderVideoInfo;
83
84 /*=======================================================================================
85 | CONSTANT DEFINITIONS                                                                  |
86 ========================================================================================*/
87
88 /*=======================================================================================
89 | STATIC VARIABLES                                                                      |
90 ========================================================================================*/
91
92 /*=======================================================================================
93 | EXTERN GLOBAL VARIABLE                                                                |
94 ========================================================================================*/
95
96 /*=======================================================================================
97 | GLOBAL FUNCTION PROTOTYPES                                                            |
98 ========================================================================================*/
99 /**
100  * This function creates recorder pipeline.
101  * When application creates initial pipeline, there are only bins for preview.
102  * If application wants to record, recorder pipeline should be created.
103  *
104  * @param[in]   handle          Handle of camcorder context.
105  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
106  * @remarks
107  * @see         __mmcamcorder_create_preview_pipeline()
108  */
109 int _mmcamcorder_create_recorder_pipeline(MMHandleType handle);
110
111 /**
112  * This function connects video stream cb signal.
113  *
114  * @param[in]   handle          Handle of camcorder context.
115  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
116  * @remarks
117  */
118 int _mmcamcorder_connect_video_stream_cb_signal(MMHandleType handle);
119
120 /**
121  * This function remove recorder bin from main pipeline.
122  *
123  * @param[in]   handle          Handle of camcorder context.
124  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
125  * @remarks
126  * @see         __mmcamcorder_create_preview_pipeline(), __mmcamcorder_add_recorder_pipeline()
127  */
128 int _mmcamcorder_remove_recorder_pipeline(MMHandleType handle);
129
130 /**
131  * This function operates each command on video mode.
132  *
133  * @param[in]   handle          Handle of camcorder context.
134  * @param[in]   command         command type received from Multimedia Framework.
135  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
136  * @remarks
137  * @see         _mmcamcorder_set_functions()
138  */
139 int _mmcamcorder_video_command(MMHandleType handle, int command);
140
141 /**
142  * This function handles EOS(end of stream) when commit video recording.
143  *
144  * @param[in]   handle          Handle of camcorder context.
145  * @return      This function returns TRUE on success, or FALSE on failure.
146  * @remarks
147  * @see         _mmcamcorder_set_functions()
148  */
149 int _mmcamcorder_video_handle_eos(MMHandleType handle);
150
151 /**
152  * This function prepares video recording
153  *
154  * @param[in]   handle          Handle of camcorder context.
155  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
156  * @remarks
157  */
158 int _mmcamcorder_video_prepare_record(MMHandleType handle);
159
160
161 #ifdef __cplusplus
162 }
163 #endif
164
165 #endif /* __MM_CAMCORDER_VIDEOREC_H__ */