Remove libmm-log build dependency
[platform/core/multimedia/libmm-transcode.git] / transcode / mm_transcode_codec.c
1 /*
2  * libmm-transcode
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: YoungHun Kim <yh8004.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 #include "mm_transcode.h"
22 #include "mm_transcode_internal.h"
23
24 int _mm_encodebin_set_venc_aenc(handle_s *handle)
25 {
26         int ret = MM_ERROR_NONE;
27
28         if (!handle) {
29                 LOGE("[ERROR] - handle");
30                 return MM_ERROR_INVALID_ARGUMENT;
31         }
32
33         if (!handle->property) {
34                 LOGE("[ERROR] - handle property");
35                 return MM_ERROR_TRANSCODE_INTERNAL;
36         }
37
38         handle->property->mux = malloc(sizeof(gchar) * ENC_BUFFER_SIZE);
39         if (handle->property->mux == NULL) {
40                 LOGE("[NULL] mux");
41                 return MM_ERROR_INVALID_ARGUMENT;
42         }
43         handle->property->venc = malloc(sizeof(gchar) * ENC_BUFFER_SIZE);
44         if (handle->property->venc == NULL) {
45                 LOGE("[NULL] venc");
46                 TRANSCODE_FREE(handle->property->mux);
47                 return MM_ERROR_INVALID_ARGUMENT;
48         }
49         handle->property->aenc = malloc(sizeof(gchar) * ENC_BUFFER_SIZE);
50         if (handle->property->aenc == NULL) {
51                 LOGE("[NULL] aenc");
52                 TRANSCODE_FREE(handle->property->mux);
53                 TRANSCODE_FREE(handle->property->venc);
54                 return MM_ERROR_INVALID_ARGUMENT;
55         }
56
57         memset(handle->property->mux, 0, ENC_BUFFER_SIZE);
58         memset(handle->property->venc, 0, ENC_BUFFER_SIZE);
59         memset(handle->property->aenc, 0, ENC_BUFFER_SIZE);
60
61         switch (handle->property->containerformat) {
62         case MM_CONTAINER_3GP:
63         case MM_CONTAINER_MP4:
64                 if (handle->property->videoencoder == MM_VIDEOENCODER_NO_USE && handle->property->audioencoder == MM_AUDIOENCODER_AAC)
65                         strncpy(handle->property->mux, MUXAAC, ENC_BUFFER_SIZE - 1);
66                 else
67                         strncpy(handle->property->mux, MUX3GP, ENC_BUFFER_SIZE - 1);
68                 break;
69         default:
70                 LOGE("error container value");
71                 break;
72         }
73
74         switch (handle->property->videoencoder) {
75         case MM_VIDEOENCODER_MPEG4:
76                 strncpy(handle->property->venc, AVENCMPEG4, ENC_BUFFER_SIZE - 1);
77                 LOGD("[FFMPEG] %s", handle->property->venc);
78                 break;
79         case MM_VIDEOENCODER_H263:
80                 strncpy(handle->property->venc, AVENCH263, ENC_BUFFER_SIZE - 1);
81                 LOGD("[FFMPEG] %s", handle->property->venc);
82                 break;
83         case MM_VIDEOENCODER_NO_USE:
84                 LOGD("No VIDEO");
85                 break;
86         default:
87                 LOGE("error videoencoder value");
88                 break;
89         }
90
91         switch (handle->property->audioencoder) {
92         case MM_AUDIOENCODER_AAC:
93                 strncpy(handle->property->aenc, AACENC, ENC_BUFFER_SIZE - 1);
94                 LOGD("[FFMPEG] %s", handle->property->aenc);
95                 break;
96         case MM_AUDIOENCODER_AMR:
97                 strncpy(handle->property->aenc, AMRENC, ENC_BUFFER_SIZE - 1);
98                 LOGD("[FFMPEG] %s", handle->property->aenc);
99                 break;
100         case MM_AUDIOENCODER_NO_USE:
101                 LOGD("No AUDIO");
102                 break;
103         default:
104                 LOGE("error audioencoder value");
105                 break;
106         }
107         return ret;
108 }