[libmm-streamrecorder] initial code for new feature of streamrecorder
[platform/core/multimedia/libmm-streamrecorder.git] / src / mm_streamrecorder.c
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 /* ==============================================================================
23 |  INCLUDE FILES                                                                |
24 ===============================================================================*/
25 #include <stdio.h>
26 #include <string.h>
27
28 #include <mm_error.h>
29
30 #include <mm_attrs_private.h>
31 #include "mm_streamrecorder.h"
32 #include "mm_streamrecorder_internal.h"
33 #include "mm_streamrecorder_attribute.h"
34
35 /*===============================================================================
36 |  FUNCTION DEFINITIONS                                                         |
37 ===============================================================================*/
38 /*-------------------------------------------------------------------------------
39 |    GLOBAL FUNCTION DEFINITIONS:                                               |
40 -------------------------------------------------------------------------------*/
41 int mm_streamrecorder_create(MMHandleType *streamrecorder)
42 {
43         int error = MM_ERROR_NONE;
44
45         mmf_return_val_if_fail((void *)streamrecorder, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
46
47         _mmstreamrec_dbg_log("");
48
49         error = _mmstreamrecorder_create(streamrecorder);
50
51         _mmstreamrec_dbg_log("END");
52
53         return error;
54 }
55
56
57 int mm_streamrecorder_get_state(MMHandleType streamrecorder, MMStreamRecorderStateType *status)
58 {
59         int ret = MM_ERROR_NONE;
60
61         mmf_return_val_if_fail((void *)streamrecorder, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
62
63         mmf_return_val_if_fail((void *)status, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
64
65         _mmstreamrec_dbg_err("");
66
67         *status = _mmstreamrecorder_get_state(streamrecorder);
68
69         return ret;
70
71 }
72
73 int mm_streamrecorder_destroy(MMHandleType streamrecorder)
74 {
75         int error = MM_ERROR_NONE;
76
77         mmf_return_val_if_fail((void *)streamrecorder, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
78
79         _mmstreamrec_dbg_log("");
80
81         error = _mmstreamrecorder_destroy(streamrecorder);
82
83         _mmstreamrec_dbg_log("END!!!");
84
85         return error;
86 }
87
88 int mm_streamrecorder_realize(MMHandleType streamrecorder)
89 {
90         int error = MM_ERROR_NONE;
91
92         mmf_return_val_if_fail((void *)streamrecorder, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
93
94         _mmstreamrec_dbg_log("");
95
96         error = _mmstreamrecorder_realize(streamrecorder);
97
98         _mmstreamrec_dbg_log("END");
99
100         return error;
101 }
102
103 int mm_streamrecorder_pause(MMHandleType streamrecorder)
104 {
105         int error = MM_ERROR_NONE;
106
107         mmf_return_val_if_fail((void *)streamrecorder, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
108
109         _mmstreamrec_dbg_err("");
110
111         error = _mmstreamrecorder_pause(streamrecorder);
112
113         _mmstreamrec_dbg_err("END");
114
115         return error;
116 }
117
118
119 int mm_streamrecorder_unrealize(MMHandleType streamrecorder)
120 {
121         int error = MM_ERROR_NONE;
122
123         mmf_return_val_if_fail((void *)streamrecorder, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
124
125         _mmstreamrec_dbg_log("");
126
127         error = _mmstreamrecorder_unrealize(streamrecorder);
128
129         _mmstreamrec_dbg_log("END");
130
131         return error;
132 }
133
134 int mm_streamrecorder_record(MMHandleType streamrecorder)
135 {
136         int error = MM_ERROR_NONE;
137
138         mmf_return_val_if_fail((void *)streamrecorder, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
139
140         _mmstreamrec_dbg_log("");
141
142         error = _mmstreamrecorder_record(streamrecorder);
143
144         _mmstreamrec_dbg_log("END");
145
146         return error;
147 }
148
149 int mm_streamrecorder_push_stream_buffer(MMHandleType streamrecorder, MMStreamRecorderStreamType streamtype, unsigned long timestamp, void *buffer, int size)
150 {
151         int error = MM_ERROR_NONE;
152
153         mmf_return_val_if_fail((void *)streamrecorder, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
154
155         _mmstreamrec_dbg_log("");
156
157         error = _mmstreamrecorder_push_stream_buffer(streamrecorder, streamtype, timestamp, buffer, size);
158
159         _mmstreamrec_dbg_log("END");
160
161         return error;
162 }
163
164 int mm_streamrecorder_commit(MMHandleType streamrecorder)
165 {
166         int error = MM_ERROR_NONE;
167
168         mmf_return_val_if_fail((void *)streamrecorder, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
169
170         _mmstreamrec_dbg_log("");
171
172         error = _mmstreamrecorder_commit(streamrecorder);
173
174         _mmstreamrec_dbg_log("END");
175
176         return error;
177 }
178
179 int mm_streamrecorder_cancel(MMHandleType streamrecorder)
180 {
181         int error = MM_ERROR_NONE;
182
183         mmf_return_val_if_fail((void *)streamrecorder, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
184
185         _mmstreamrec_dbg_log("");
186
187         error = _mmstreamrecorder_cancel(streamrecorder);
188
189         _mmstreamrec_dbg_log("END");
190
191         return error;
192 }
193
194 int mm_streamrecorder_set_message_callback(MMHandleType streamrecorder, MMMessageCallback callback, void *user_data)
195 {
196         int error = MM_ERROR_NONE;
197
198         mmf_return_val_if_fail((void *)streamrecorder, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
199
200         error = _mmstreamrecorder_set_message_callback(streamrecorder, callback, user_data);
201
202         return error;
203 }
204
205 int mm_streamrecorder_get_attributes(MMHandleType streamrecorder, char **err_attr_name, const char *attribute_name, ...)
206 {
207         va_list var_args;
208         int ret = MM_ERROR_NONE;
209
210         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
211
212         va_start(var_args, attribute_name);
213         ret = _mmstreamrecorder_get_attributes(streamrecorder, err_attr_name, attribute_name, var_args);
214         va_end(var_args);
215
216         return ret;
217 }
218
219 int mm_streamrecorder_set_attributes(MMHandleType streamrecorder, char **err_attr_name, const char *attribute_name, ...)
220 {
221         va_list var_args;
222         int ret = MM_ERROR_NONE;
223
224         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
225
226         va_start(var_args, attribute_name);
227         ret = _mmstreamrecorder_set_attributes(streamrecorder, err_attr_name, attribute_name, var_args);
228         va_end(var_args);
229
230         return ret;
231 }