1d76e21629c6baf938beebee77f19dcd33db4776
[platform/core/multimedia/libmm-common.git] / include / mm_message.h
1 /*
2  * libmm-common
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jonghyuk Choi <jhchoi.choi@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 #ifndef __MM_MESSAGE_H__
24 #define __MM_MESSAGE_H__
25
26 #include <stdint.h>
27
28 #ifdef __cplusplus
29         extern "C" {
30 #endif
31
32
33 /**
34  *         @addtogroup COMMON
35  *         @{
36                  * @file                mm_message.h
37                  * @brief               This file declares the messages type of Multimedia framework.
38                  * @version             1.0
39                  *
40                  * This file declares the messages type of Multimedia framework.
41  */
42
43 /**
44  * Enumerations of messages type.
45 */
46 enum MMMessageType {
47         /* COMMON */
48         MM_MESSAGE_UNKNOWN = 0x00,         /**< Unknown message type */
49         MM_MESSAGE_ERROR,                  /**< Error message type */
50         MM_MESSAGE_WARNING,                /**< Warning message type */
51         MM_MESSAGE_STATE_CHANGED,          /**< State change message type */
52         MM_MESSAGE_STATE_INTERRUPTED,      /**< State change by interrupt */
53         MM_MESSAGE_READY_TO_RESUME,        /**< Ready to resume message type */
54
55         /* PLAYER */
56         MM_MESSAGE_CONNECTING = 0x100,                  /**< Connecting message type */
57         MM_MESSAGE_CONNECTED,                           /**< Rtspsrc has successed to connecting to server */
58         MM_MESSAGE_CONNECTION_TIMEOUT,                  /**< Connection timeout message type */
59         MM_MESSAGE_BUFFERING,                           /**< Buffering message type */
60         MM_MESSAGE_BEGIN_OF_STREAM,                     /**< Streaming begin message type */
61         MM_MESSAGE_END_OF_STREAM,                       /**< End of stream message type */
62         MM_MESSAGE_BLUETOOTH_ON,                        /**< Bluetooth A2DP Connection ON */
63         MM_MESSAGE_BLUETOOTH_OFF,                       /**< Bluetooth A2DP Connection OFF */
64         MM_MESSAGE_RESUMED_BY_REW,                      /**< Resumed by fast rewind message type */
65         MM_MESSAGE_UPDATE_SUBTITLE,                     /**< Update subtitle type */
66         MM_MESSAGE_RTP_SENDER_REPORT,                   /**< RTP sender report */
67         MM_MESSAGE_RTP_RECEIVER_REPORT,                 /**< RTP receiver report */
68         MM_MESSAGE_RTP_SESSION_STATUS,                  /**< RTP session status */
69         MM_MESSAGE_SENDER_STATE,                        /**< Sender state */
70         MM_MESSAGE_RECEIVER_STATE,                      /**< Receiver state */
71         MM_MESSAGE_FILE_NOT_SUPPORTED,                  /**< Not supported file */
72         MM_MESSAGE_FILE_NOT_FOUND,                      /**< Not founded file */
73         MM_MESSAGE_DRM_NOT_AUTHORIZED,                  /**< Not authorized to play the content */
74         MM_MESSAGE_VIDEO_CAPTURED,                      /**< Video frame has been captured */
75         MM_MESSAGE_VIDEO_NOT_CAPTURED,                  /**< video capture failed */
76         MM_MESSAGE_SEEK_COMPLETED,                      /**< Seek completed */
77         MM_MESSAGE_PD_DOWNLOADER_START, /**< PD downloader start message */
78         MM_MESSAGE_PD_DOWNLOADER_END,           /**< PD downloader end message */
79         MM_MESSAGE_IMAGE_BUFFER,        /**< hls image buffer message type */
80         MM_MESSAGE_DRM_NO_LICENSE,                      /**< No license */
81         MM_MESSAGE_DRM_EXPIRED,                         /**< Expired license */
82         MM_MESSAGE_DRM_FUTURE_USE,                      /**< License for future use */
83         MM_MESSAGE_VIDEO_BIN_CREATED,           /**< Video bin is created */
84         MM_MESSAGE_GAPLESS_CONSTRUCTION,                /**< pipeline is under the construction for gapless */
85         MM_MESSAGE_PLAY_POSITION,                       /**< Play position */
86
87         /* CAMCORDER */
88         MM_MESSAGE_CAMCORDER_STATE_CHANGED = 0x200,     /**< State changed.*/
89         MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM,      /**< State change by audio session manager message type */
90         MM_MESSAGE_CAMCORDER_MAX_SIZE,                  /**< Maximum size, camcorder waits for user's order (cam_commit/cancel).*/
91         MM_MESSAGE_CAMCORDER_NO_FREE_SPACE,             /**< No free space, camcorder waits for user's order (cam_commit/cancel).*/
92         MM_MESSAGE_CAMCORDER_TIME_LIMIT,                /**< Time limit, camcorder waits for user's order (cam_commit/cancel)*/
93         MM_MESSAGE_CAMCORDER_CAPTURED,                  /**< Image captured */
94         MM_MESSAGE_CAMCORDER_ERROR,                     /**< Error occurred.*/
95         MM_MESSAGE_CAMCORDER_FOCUS_CHANGED,             /**< Focus changed */
96         MM_MESSAGE_CAMCORDER_CURRENT_VOLUME,            /**< Current volume level of real input stream */
97         MM_MESSAGE_CAMCORDER_FIRMWARE_UPDATE,           /**< Firmware update */
98         MM_MESSAGE_CAMCORDER_RECORDING_STATUS,          /**< Recording status. (Elapsed time, total time, file size(KB))*/
99         MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY, /**< State change by system security(ex:MDM) message type */
100         MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED,   /**< Image captured while video recording */
101         MM_MESSAGE_CAMCORDER_HDR_PROGRESS,              /**< Progressing percent of HDR capture */
102         MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO,          /**< Face detection information */
103         MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED,            /**< Video captured */
104         MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED,            /**< Audio captured */
105         MM_MESSAGE_CAMCORDER_LOW_LIGHT_STATE,           /**< Low light state */
106         MM_MESSAGE_CAMCORDER_CAPTURE_SOUND,             /**< Noti to play capture sound - only single capture available */
107         MM_MESSAGE_CAMCORDER_CAPTURE_SOUND_COMPLETED,   /**< Noti to play capture sound completed - only single capture available */
108         MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_RM,       /**< State change by resource manager.*/
109         MM_MESSAGE_CAMCORDER_STATE_CHANGE_STARTED_BY_ASM,               /**< State change is started by sound policy */
110         MM_MESSAGE_CAMCORDER_STATE_CHANGE_STARTED_BY_SECURITY,  /**< State change is started by system security */
111         MM_MESSAGE_CAMCORDER_STATE_CHANGE_STARTED_BY_RM,        /**< State change is started by resource manager */
112
113         /* RADIO */
114         MM_MESSAGE_RADIO_SCAN_START = 0x300,            /**< Radio frequency scanning initiated */
115         MM_MESSAGE_RADIO_SCAN_INFO,                     /**< Founded radio frequency report. check message parameters  */
116         MM_MESSAGE_RADIO_SCAN_FINISH,                   /**< Radio frequency scanning has finished */
117         MM_MESSAGE_RADIO_SCAN_STOP,                     /**< Radio frequency scanning has stopped */
118         MM_MESSAGE_RADIO_SEEK_START,                    /**< Radio seeking has established */
119         MM_MESSAGE_RADIO_SEEK_FINISH,                   /**< Radio seeking has finished */
120         MM_MESSAGE_RADIO_SET_FREQUENCY,                 /**< Radio set frequency async*/
121         MM_MESSAGE_RADIO_RDS_PS,                        /**< Radio RDS Program Service Data has arrived> */
122         MM_MESSAGE_RADIO_RDS_RT,                        /**< Radio RDS Radio Text Data has arrived> */
123
124
125         /* MEDIA CALL */
126         MM_MESSAGE_MEDIACALL_RESERVED = 0x400,          /**< Reserved message for Media Call */
127
128         /* IMAGE */
129         MM_MESSAGE_IMAGE_RESERVED = 0x500,              /**< Reserved message for Image */
130
131         /* SOUND */
132         MM_MESSAGE_SOUND_PCM_CAPTURE_RESTRICTED = 0x600,        /**< Sound pcm capture is restricted by system */
133         MM_MESSAGE_SOUND_PCM_INTERRUPTED,                       /**< Sound pcm is interrupted by audio system */
134
135         /* FILE INFO */
136         MM_MESSAGE_FILEINFO_RESERVED = 0x700,           /**< Reserved message for File Info */
137
138         /* STREAM RECORDER */
139         MM_MESSAGE_STREAMRECORDER_ERROR = 0x800,
140         MM_MESSAGE_STREAMRECORDER_CONSUME_COMPLETE,
141         MM_MESSAGE_STREAMRECORDER_STATE_CHANGED,
142         MM_MESSAGE_STREAMRECORDER_MAX_SIZE,             /**< Maximum size, streamcorder waits for user's order (commit/cancel) */
143         MM_MESSAGE_STREAMRECORDER_NO_FREE_SPACE,        /**< No free space,streamcorder waits for user's order (commit/cancel) */
144         MM_MESSAGE_STREAMRECORDER_TIME_LIMIT,           /**< Time limit, streamcorder waits for user's order (commit/cancel) */
145         MM_MESSAGE_STREAMRECORDER_RECORDING_STATUS,     /**< Recording status. (Elapsed time, total time, file size(KB)) */
146         MM_MESSAGE_STREAMRECORDER_VIDEO_CAPTURED,       /**< Video captured done. This message will be called when video capture is finished (eos) */
147         MM_MESSAGE_STREAMRECORDER_AUDIO_CAPTURED,       /**< Audio captured done. This message will be called when audio capture is finished (eos) */
148
149         MM_MESSAGE_NUM,                                 /**< The number of the messages */
150 };
151
152
153 /**
154  * Union type of 'MMMessageParamType' structure. Please add type when you make new union type of MMMessageParamType
155  */
156 enum MMMessageUnionType {
157         MM_MSG_UNION_CODE,              /**< Default */
158         MM_MSG_UNION_STATE,
159         MM_MSG_UNION_TIME,
160         MM_MSG_UNION_CONNECTION,
161         MM_MSG_UNION_FIRMWARE,
162         MM_MSG_UNION_RTPSENDER_REPORT,
163         MM_MSG_UNION_RTPRECEIVER_REPORT,
164         MM_MSG_UNION_RTPSESSION_STATUS,
165         MM_MSG_UNION_SUBTITLE,
166         MM_MSG_UNION_RADIO_SCAN,
167         MM_MSG_UNION_RECORDING_STATUS,
168         MM_MSG_UNION_REC_VOLUME_DB,
169         MM_MSG_UNION_CONSUME_RECORDER_BUFFER,
170 };
171
172 /*
173  * Enumerations of code for MM_MESSAGE_STATE_INTERRUPTED messages type.
174  */
175 enum MMMessageInterruptedCode {
176         MM_MSG_CODE_INTERRUPTED_BY_MEDIA = 0,
177         MM_MSG_CODE_INTERRUPTED_BY_CALL_START,
178         MM_MSG_CODE_INTERRUPTED_BY_CALL_END,
179         MM_MSG_CODE_INTERRUPTED_BY_EARJACK_UNPLUG,
180         MM_MSG_CODE_INTERRUPTED_BY_RESOURCE_CONFLICT,
181         MM_MSG_CODE_INTERRUPTED_BY_ALARM_START,
182         MM_MSG_CODE_INTERRUPTED_BY_ALARM_END,
183         MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_START,
184         MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_END,
185         MM_MSG_CODE_INTERRUPTED_BY_OTHER_PLAYER_APP,
186         MM_MSG_CODE_INTERRUPTED_BY_NOTIFICATION_START,
187         MM_MSG_CODE_INTERRUPTED_BY_NOTIFICATION_END,
188 };
189
190 /*
191  * Enumerations of code for MM_MESSAGE_SOUND_PCM_CAPTURE_RESTRICTED messages type.
192  */
193 enum MMMessagePcmCaptureCode {
194         MM_MSG_CODE_PCM_CAPTURE_RESTRICTED = 0,
195         MM_MSG_CODE_PCM_CAPTURE_ALLOWED,
196 };
197
198 /**
199  * Message callback function type.
200  */
201 typedef int     (*MMMessageCallback) (int id, void *param, void *user_param);
202
203 /**
204  * Message Parameter.
205  */
206 typedef struct {
207         void *data;                             /**< Allocated data */
208
209 /**
210  * union.
211  */
212         int union_type;         /**< Type of union. Please refer MMMessageUnionType */
213
214         union {
215                 int code;                       /**< Error or warning code */
216 /**
217  * state.
218  */
219                 struct {
220                         int previous;           /**< Previous state */
221                         int current;            /**< Current state */
222                         int code;               /**< Error or warning code */
223                 } state;
224 /**
225  * time.
226  */
227                 struct {
228                         int64_t elapsed;  /**< Elapsed time */
229                         int64_t total;    /**< Total time */
230                 } time;
231 /**
232  * connection.
233  */
234                 struct {
235                         unsigned int buffering; /**< Buffering percent */
236                 } connection;
237
238 /**
239  * firmware.
240  */
241                 struct {
242                         int state;              /**< Update state*/
243                         int progress;           /**< Update progress percentage */
244                 } firmware;
245 /**
246  * RTPSenderReport.
247  */
248                 struct {
249                         unsigned char is_valid;                 /**< Structure is valid or not */
250                         //int64 ntptime;                        /**< The NTP timestamp indicates the point of time measured in wall clock time when this report was sent. */              unsigned int rtptime;                 /**< The RTP timestamp resembles the same time as the NTP timestamp ,but is measured in the same units and with the same random offset as the RTP timestamps in data packets */
251                         unsigned long long ntptime;             /**< The NTP timestamp indicates the point of time measured in wall clock time when this report was sent. */              unsigned int rtptime;                 /**< The RTP timestamp resembles the same time as the NTP timestamp ,but is measured in the same units and with the same random offset as the RTP timestamps in data packets */
252                         unsigned int packet_count;              /**< The sender's packet count totals up the number of RTP data packets transmitted by the sender since joining the RTP session */
253                         unsigned int octet_count;               /**< The total number of payload octets (i.e., not including the header or any padding) transmitted in RTP data packets by the sender since starting up transmission */
254                 } RTPSenderReport;      /**< RTPSenderReport message parameter structure. */
255 /**
256  * RTPReceiverReport.
257  */
258                 struct {
259                           unsigned char is_valid;               /**< Structure is valid or not */
260                           unsigned int ssrc;                    /**< The SSRC identifier of the sender whose reception is reported in this block . who the report is from */
261                           unsigned char fractionlost;           /**< The sender of the receiver report estimates the fraction of the RTP data packets from source SSRC_n that it assumes to be lost since it sent the previous SR or RR packet.*/
262                           unsigned int packetslost;             /**< The sender of a receiver report blocks also tries to estimate the total number of RTP data packets from source SSRC_n that have been lost since the beginning of reception. Packets that arrive late are not counted as lost, and the loss may be negative if there are duplicates. */
263                           unsigned int exthighestseq;           /**< The low 16 bits of the extended highest sequence number contain the highest sequence number received in an RTP data packet from source SSRC_n, and the most significant 16 bits extend that sequence number with the corresponding count of sequence number cycles. */
264                           unsigned int jitter;                  /**< An estimate of the statistical variance of the RTP data packet inter-arrival time, measured in timestamp units and expressed as an unsigned intege */
265                           unsigned int lsr;                     /**< Last SR Timestamp        */
266                           unsigned int dlsr;                    /**< Delay since last SR Timestamp    */
267                 } RTPReceiverReport;    /**< RTPReceiverReport message parameter structure. */
268 /**
269  * RTPSessionStatus.
270  */
271                 struct {
272                         double bandwidth;                       /**< Bandwidth Modifier*/
273                         double sender_fraction;                 /**< Fraction of packet loss by sender*/
274                         double receiver_fraction;               /**< Fraction of packet loss from Receiver*/
275                         double rtcp_bandwidth;                  /**< The total bandwidth that will be used for RTCP packets by all members of this session, in octets per second */
276                         double min_interval;                    /**< Minimum Interval */
277                         unsigned int sender_sources;            /**< Identifies the synchronization source from sender*/
278                         unsigned int active_sources;            /**< Identifies the Active source from sender*/
279                         unsigned int avg_rtcp_packet_size;      /**< Average RTCP packet size */
280                         unsigned int bye_members;               /**< BYE Packet members */
281                 } RTPSessionStatus;     /**< RTPSessionStatus message parameter structure. */
282 /**
283  * subtitle
284  */
285                 struct {
286                         unsigned long duration;         /**< duration */
287                 } subtitle;
288
289 /**
290  * Radio Scan Info
291  */
292                 struct {
293                         int frequency;                  /**< detected active frequency with MM_MESSAGE_RADIO_SCAN_INFO */
294                 } radio_scan;
295
296 /**
297  * Radio RDS PS and RT Info
298  */
299                 struct {
300                         int frequency;                /**< The frequency at which the RDS data was obtained> */
301                         char* rt_ps;                  /**< the radio text obtained with MM_MESSAGE_RADIO_RDS_PS and MM_MESSAGE_RADIO_RDS_RT */
302                 } radio_rds_text;
303 /**
304  * Recording status
305  */
306                 struct {
307                         unsigned long long elapsed;          /**< Elapsed time (ms) */
308                         unsigned long long total;            /**< Total time */
309                         unsigned long long filesize;         /**< Recording File size (KB). An approximate value. */
310                         unsigned long long remained_time;    /**< Remained time (ms).
311                                                                                                         This is available if time limit is not set or
312                                                                                                         time limit is bigger than estimated remained time. */
313                 } recording_status;
314
315 /**
316  * Recording volume level - dB
317  */
318                 float rec_volume_dB;
319
320                 struct {
321                         void * consumed_buffer;
322
323                 } consumed_mediabuffer;
324
325 /**
326  * Video frame capture
327  */
328                 struct {
329                         unsigned int width;                                             /* width of captured image */
330                         unsigned int height;                                    /* height of captured image */
331                         unsigned int orientation;                               /* orientation of captured image */
332                 } captured_frame;
333         };
334
335         int size;       /**< Allocated size of 'data' */
336
337         int reserved;   /**< reserved field for future use */
338 } MMMessageParamType;
339
340 /**
341  * @}
342  */
343
344 #ifdef __cplusplus
345         }
346 #endif
347
348
349 #endif  /* __MM_MESSAGE_H__ */