4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyuntae Kim <ht1211.kim@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.
22 /*=======================================================================================
24 =======================================================================================*/
27 #include <sys/vfs.h> /* struct statfs */
29 #include "mm_streamrecorder_internal.h"
30 #include "mm_streamrecorder_util.h"
31 #include "mm_streamrecorder_fileinfo.h"
33 /*-----------------------------------------------------------------------
34 | GLOBAL VARIABLE DEFINITIONS for internal |
35 -----------------------------------------------------------------------*/
37 /*-----------------------------------------------------------------------
38 | LOCAL VARIABLE DEFINITIONS for internal |
39 -----------------------------------------------------------------------*/
41 /*---------------------------------------------------------------------------
42 | LOCAL FUNCTION PROTOTYPES: |
43 ---------------------------------------------------------------------------*/
44 /* STATIC INTERNAL FUNCTION */
46 /*===========================================================================================
48 | FUNCTION DEFINITIONS |
49 ========================================================================================== */
50 /*---------------------------------------------------------------------------
51 | GLOBAL FUNCTION DEFINITIONS: |
52 ---------------------------------------------------------------------------*/
54 gboolean _mmstreamrecorder_update_composition_matrix(FILE *f, int orientation)
57 guint32 a = 0x00010000;
60 guint32 d = 0x00010000;
62 switch (orientation) {
63 case MM_STREAMRECORDER_TAG_VIDEO_ORT_90: /* 90 degree */
69 case MM_STREAMRECORDER_TAG_VIDEO_ORT_180: /* 180 degree */
73 case MM_STREAMRECORDER_TAG_VIDEO_ORT_270: /* 270 degree */
79 case MM_STREAMRECORDER_TAG_VIDEO_ORT_NONE: /* 0 degree */
92 write_to_32(f, 0x40000000);
94 _mmstreamrec_dbg_log("orientation : %d, write data 0x%x 0x%x 0x%x 0x%x", orientation, a, b, c, d);
99 guint64 _mmstreamrecorder_get_container_size(const guchar *size)
107 result = result | (temp << 16);
109 result = result | (temp << 8);
110 result = result | size[3];
112 _mmstreamrec_dbg_log("result : %lld", (unsigned long long)result);
117 gboolean _mmstreamrecorder_update_size(FILE *f, gint64 prev_pos, gint64 curr_pos)
119 _mmstreamrec_dbg_log("size : %" G_GINT64_FORMAT "", curr_pos - prev_pos);
120 if (fseek(f, prev_pos, SEEK_SET) != 0) {
121 _mmstreamrec_dbg_err("fseek() fail");
125 if (!write_to_32(f, curr_pos - prev_pos))
128 if (fseek(f, curr_pos, SEEK_SET) != 0) {
129 _mmstreamrec_dbg_err("fseek() fail");
136 gboolean _mmstreamrecorder_write_udta_m4a(FILE *f)
138 gint64 current_pos, pos;
140 _mmstreamrec_dbg_log("");
142 if ((pos = ftell(f)) < 0) {
143 _mmstreamrec_dbg_err("ftell() returns negative value");
147 if (!write_to_32(f, 0)) /* udta atomic size */
150 if (!write_tag(f, "udta")) /* user data fourcc */
153 if ((current_pos = ftell(f)) < 0) {
154 _mmstreamrec_dbg_err("ftell() returns negative value");
158 if (!_mmstreamrecorder_update_size(f, pos, current_pos))
164 gboolean _mmstreamrecorder_write_udta(FILE *f, _MMStreamRecorderLocationInfo info)
166 gint64 current_pos, pos;
168 _mmstreamrec_dbg_log("");
170 if ((pos = ftell(f)) < 0) {
171 _mmstreamrec_dbg_err("ftell() returns negative value");
175 if (!write_to_32(f, 0)) /*size */
178 if (!write_tag(f, "udta")) /* type */
181 if ((current_pos = ftell(f)) < 0) {
182 _mmstreamrec_dbg_err("ftell() returns negative value");
186 if (!_mmstreamrecorder_update_size(f, pos, current_pos))