Merge from master.
[framework/messaging/msg-service.git] / plugin / mms_plugin / include / MmsPluginSmil.h
1 /*
2 * Copyright 2012-2013  Samsung Electronics Co., Ltd
3 *
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *    http://floralicense.org
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef MMS_PLUGIN_SMIL_H
18 #define MMS_PLUGIN_SMIL_H
19
20 #include <libxml/parser.h>
21 #include <libxml/tree.h>
22
23 #include "MsgMmsTypes.h"
24 #include "MmsPluginCodecTypes.h"
25
26 typedef enum _SMIL_ELEMENT_T {
27         ELEMENT_SMIL,
28         ELEMENT_HEAD,
29         ELEMENT_LAYOUT,
30         ELEMENT_ROOTLAYOUT,
31         ELEMENT_REGION,
32         ELEMENT_TRANSITION,
33         ELEMENT_META,
34         ELEMENT_BODY,
35         ELEMENT_PAR,
36         ELEMENT_PARAM,
37         ELEMENT_TEXT,
38         ELEMENT_IMG,
39         ELEMENT_AUDIO,
40         ELEMENT_VIDEO,
41         ELEMENT_REF,
42         ELEMENT_ANIMATE,
43         ELEMENT_MAX,
44 } SMIL_ELEMENT_T;
45
46 typedef int     HMmsSmil;                       // SmilDoc Handle
47
48 #define MMS_SMIL_MAX_DOC        1
49 #define MMS_SMIL_COLOR_SIZE     10
50 #define INVALID_HOBJ    -1
51 #define SP_NO_COLOR_SET -1
52 #define SP_BLACK        0
53
54 /* Structures */
55 /**
56  *      @brief  Represents Smil Doc Information. \n
57  */
58 typedef struct _MmsSmilDoc {
59         xmlDocPtr pSmilDoc;
60         xmlNodePtr pstRootNode;
61 } MmsSmilDoc;
62
63 typedef enum _SMIL_ATTRIBUTE_T {
64         ATTRIBUTE_UNKNOWN = -1,
65         ATTRIBUTE_ID,
66         ATTRIBUTE_TOP,
67         ATTRIBUTE_LEFT,
68         ATTRIBUTE_WIDTH,
69         ATTRIBUTE_HEIGHT,
70         ATTRIBUTE_FIT,
71         ATTRIBUTE_BGCOLOR,
72         ATTRIBUTE_DUR,
73         ATTRIBUTE_SRC,
74         ATTRIBUTE_COLOR,
75         ATTRIBUTE_BOLD,
76         ATTRIBUTE_UNDERLINE,
77         ATTRIBUTE_ITALIC,
78         ATTRIBUTE_REVERSE,
79         ATTRIBUTE_DIRECTION,
80         ATTRIBUTE_SIZE,
81         ATTRIBUTE_FONT,
82         ATTRIBUTE_REGION,
83         ATTRIBUTE_NAME,
84         ATTRIBUTE_VALUE,
85         ATTRIBUTE_ALT,
86         ATTRIBUTE_TYPE,
87         ATTRIBUTE_SUBTYPE,
88         ATTRIBUTE_CONTENT,
89         ATTRIBUTE_FGCOLOR,
90         ATTRIBUTE_TEXTFORMAT,
91         ATTRIBUTE_TRANSIN,
92         ATTRIBUTE_TRANSOUT,
93         ATTRIBUTE_BEGIN,
94         ATTRIBUTE_END,
95         ATTRIBUTE_REPEAT_COUNT,
96 } SMIL_ATTRIBUTE_T;
97
98 char *MmsSmilGetPresentationData(msg_message_id_t msgId);
99 bool MmsSmilParseSmilDoc(MMS_MESSAGE_DATA_S *pMmsMsg, char *pSmilDoc);
100 void MmsSmilGetElement(MMS_MESSAGE_DATA_S *pMmsMsg, xmlNode *a_node);
101 int MmsSmilGetColorValue(xmlChar *content);
102 int MmsSmilGetTime(char *pValue);
103 int MmsSmilAtoIHexa(char *pInput);
104 #ifndef __SUPPORT_DRM__
105 int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart);
106 #else
107 int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart, MMS_MEDIA_S *pMedia);
108 #endif
109 int MmsSmilGetElementID(char *pString);
110 int MmsSmilGetAttrID(char *pString);
111 bool MmsSmilGetFontAttrib(char *pString);
112 MmsTextDirection MmsSmilGetFontDirection(char *pString);
113 int MmsSmilGetFontSizeValue(char *pString);
114 MmsSmilFontType MmsSmilGetFontTypeValue(char *pString);
115 bool MmsSmilGetMediaFilePath(MMS_MEDIA_S *pMedia, char *pszTemp, int msgID);
116 bool __MmsGetRealFileName(MmsSmilMediaType mediaType, char *pszSrc, char *pszName, int msgID);
117 /**     @fn             bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
118  *      @brief  Forms Smil Buffer using pstMsgBody. \n
119  *      @param[in/out]  pstMsgBody is Message handle. \n
120  *      @retval TRUE                            In case of Success. \n
121  *      @retval FALSE                           In case of failure. \n
122  */
123 bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody);
124
125 /**     @fn             HMmsSmil MmsSmilCreateEmptySmilDoc(void)
126  *      @brief  Creates default Smil Doc based on input gszEmptyRawDoc. \n
127  *      @retval Returns Smil Document number. \n
128  */
129 HMmsSmil MmsSmilCreateEmptySmilDoc(void);
130
131  /**    @fn                     HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
132  *      @brief          Creates Smil Doc based on input pszRawData. \n
133  *      @param[in]      pszRawData is smil buffer. \n
134  *      @retval         Returns Smil Document number. \n
135  */
136 HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData);
137
138  /**    @fn                     BOOL MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
139  *      @brief          Destroys Smil Doc. \n
140  *      @param[in]      hSmilDoc is smil doc number. \n
141  *      @retval TRUE                            In case of Success. \n
142  *      @retval FALSE                           In case of failure. \n
143  */
144 bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc);
145
146 /**     @fn                     static bool IsValidSmilDocNo(int nSmilDocNo)
147  *      @brief          Form Smil Doc. \n
148  *      @param[in]      hSmilDoc is smil doc number. \n
149  *      @retval         Returns Smil Buffer     In case of success. \n
150  *      @retval         Returns NULL                    In case of failure. \n
151  */
152 bool IsValidSmilDocNo(int nSmilDocNo);
153
154 /**     @fn                     static char * MmsSmilGetRawData( HMmsSmil hSmilDoc )
155  *      @brief          Form Smil Doc. \n
156  *      @param[in]      hSmilDoc is smil doc number. \n
157  *      @retval         Returns Smil Buffer             In case of success. \n
158  *      @retval         Returns NULL                    In case of failure. \n
159  */
160 char *MmsSmilGetRawData(HMmsSmil hSmilDoc);
161
162 /**     @fn                     static bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
163  *      @brief          Add Page to Smil Doc. \n
164  *      @param[in]      hSmilDoc is smil doc number. \n
165  *      @param[in]      pstSmilPage specifies page information. \n
166  *      @retval         TRUE                            In case of Success. \n
167  *      @retval         FALSE                           In case of failure. \n
168  */
169 bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage);
170
171 /**     @fn                     static bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
172  *      @brief          Add Rootlayout to Smil Doc. \n
173  *      @param[in]      hSmilDoc is smil doc number. \n
174  *      @param[in]      pstSmilRootLayout specifies RootLayout information. \n
175  *      @retval         TRUE                            In case of Success. \n
176  *      @retval         FALSE                           In case of failure. \n
177  */
178 bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout);
179
180 /**     @fn                     static bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
181  *      @brief          Add Region to Smil Doc. \n
182  *      @param[in]      hSmilDoc is smil doc number. \n
183  *      @param[in]      pstSmilRegion specifies Region information. \n
184  *      @retval         TRUE                            In case of Success. \n
185  *      @retval         FALSE                           In case of failure. \n
186  */
187 bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion);
188
189 /**     @fn                     static bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
190  *      @brief          Add Media to Smil Doc. \n
191  *      @param[in]      hSmilDoc is smil doc number. \n
192  *      @param[in]      nPageNo specifies page number to which media belongs. \n
193  *      @param[in]      nMediaIdx specifies medi ID. \n
194  *      @param[in]      pstSmilMedia specifies Media information. \n
195  *      @param[in]      pszContentID specifies Content ID of media. \n
196  *      @retval         TRUE                            In case of Success. \n
197  *      @retval         FALSE                           In case of failure. \n
198  */
199 bool MmsSmilAddMedia(HMmsSmil hSmilDoc, int nPageNo, int nMediaIdx, MMS_MEDIA_S *pstSmilMedia, char *pszContentID);
200
201 /**     @fn                     static xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
202  *      @brief          Create Text Element. \n
203  *      @param[in]      pstSmilMedia specifies Media information. \n
204  *      @param[in]      pszContentID specifies Content ID of media. \n
205  *      @retval         Text Element node               In case of Success. \n
206  *      @retval         NULL                            In case of failure. \n
207  */
208 xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID);
209
210 /**     @fn                     static xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
211  *      @brief          Create Image/Audio/Video Element. \n
212  *      @param[in]      pstSmilMedia specifies Media information. \n
213  *      @param[in]      pszContentID specifies Content ID of media. \n
214  *      @retval         Image/Audio/Video Element node  In case of Success. \n
215  *      @retval         NULL                                                    In case of failure. \n
216  */
217 xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID);
218
219 /**     @fn                     static bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pstCurr)
220  *      @brief          Inserts first child to parent node. \n
221  *      @param[in]      pstParent specifies Parent node. \n
222  *      @param[in]      pstCurr specifies Child node. \n
223  *      @retval         TRUE                            In case of Success. \n
224  *      @retval         FALSE                           In case of failure. \n
225  */
226 bool __MmsInsertFirstChild(xmlNode *pParent, xmlNode *pNode);
227
228 /**     @fn                     static bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pstCurr)
229  *      @brief          Inserts node. \n
230  *      @param[in]      pstParent specifies Parent node. \n
231  *      @param[in]      pstLeftSibling specifies Left Sibling node. \n
232  *      @param[in]      pstCurr specifies Child node. \n
233  *      @retval         TRUE                            In case of Success. \n
234  *      @retval         FALSE                           In case of failure. \n
235  */
236 bool __MmsSmilInsertNode(xmlNode *pParent, xmlNode *pLeftSibling, xmlNode *pNode);
237
238 /**     @fn                     static void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
239  *      @brief          Sets Attribute. \n
240  *      @param[in]      pNode specifies node. \n
241  *      @param[in]      szField specifies attribute field. \n
242  *      @param[in]      szValue specifies value of field \n
243  */
244 void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue);
245
246 /**     @fn                     static char *__MmsSmilFindColorValue(int nValue)
247  *      @brief          Converts color to RGB. \n
248  *      @param[in]      nValue specifies color value. \n
249  *      @retval         RGB value. \n
250  */
251 char *__MmsSmilFindColorValue(int nValue);
252
253 /**     @fn                     static xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszValue)
254  *      @brief          Get node based on pszValue. \n
255  *      @param[in]      pNode specifies node. \n
256  *      @param[in]      pszName specifies name field. \n
257  *      @retval         RGB value. \n
258  */
259 xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszName);
260
261
262 bool MmsSmilParseSmilDocOnlyLayout(MMS_MESSAGE_DATA_S *pMmsMsg, char *pSmilDoc);
263
264
265 #endif//MMS_PLUGIN_SMIL_H