2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file mediademuxer_port.h
19 * @brief general port based functions. sets specific function pointers
22 #ifndef __TIZEN_MEDIADEMUXER_PORT_H__
23 #define __TIZEN_MEDIADEMUXER_PORT_H__
25 /*===========================================================================================
29 ========================================================================================== */
33 #include <mm_message.h>
34 #include <media_format.h>
35 #include <mediademuxer_util.h>
45 This part describes APIs used for playback of multimedia contents.
46 All multimedia contents are created by a media demuxer through handle of playback.
47 In creating a demuxer, it displays the demuxer's status or information
48 by registering callback function.
51 In case of streaming playback, network has to be opend by using datanetwork API.
52 If proxy, cookies and the other attributes for streaming playback are needed,
53 set those attributes using mm_demuxer_set_attribute() before create demuxer.
56 The subtitle for local video playback is supported. Set "subtitle_uri" attribute
57 using mm_demuxer_set_attribute() before the application creates the demuxer.
58 Then the application could receive MMMessageParamType which includes subtitle string and duration.
61 MediaDemuxer can have 5 states, and each state can be changed by calling
62 described functions on "Figure1. State of MediaDemuxer".
65 @image html demuxer_state.jpg "Figure1. State of MediaDemuxer" width=12cm
66 @image latex demuxer_state.jpg "Figure1. State of MediaDemuxer" width=12cm
69 Most of functions which change demuxer state work as synchronous. But, mm_demuxer_start() should be used
70 asynchronously. Both mm_demuxer_pause() and mm_demuxer_resume() should also be used asynchronously
71 in the case of streaming data.
72 So, application have to confirm the result of those APIs through message callback function.
75 Note that "None" and Null" state could be reached from any state
76 by calling mm_demuxer_destroy() and mm_demuxer_unrealize().
81 <td><B>FUNCTION</B></td>
82 <td><B>PRE-STATE</B></td>
83 <td><B>POST-STATE</B></td>
84 <td><B>SYNC TYPE</B></td>
99 <td>md_set_data_source()</td>
107 Following are the attributes supported in demuxer which may be set after initialization. \n
108 Those are handled as a string.
118 <td>"profile_uri"</td>
123 <td>"content_duration"</td>
128 <td>"content_video_width"</td>
133 <td>"content_video_height"</td>
138 <td>"profile_user_param"</td>
143 <td>"profile_play_count"</td>
148 <td>"streaming_type"</td>
153 <td>"streaming_udp_timeout"</td>
158 <td>"streaming_user_agent"</td>
163 <td>"streaming_wap_profile"</td>
168 <td>"streaming_network_bandwidth"</td>
173 <td>"streaming_cookie"</td>
178 <td>"streaming_proxy_ip"</td>
183 <td>"streaming_proxy_port"</td>
188 <td>"subtitle_uri"</td>
195 Following attributes are supported for playing stream data. Those value can be readable only and valid after starting playback.\n
196 Please use mm_fileinfo for local playback.
206 <td>"content_video_found"</td>
211 <td>"content_video_codec"</td>
216 <td>"content_video_track_num"</td>
221 <td>"content_audio_found"</td>
226 <td>"content_audio_codec"</td>
231 <td>"content_audio_bitrate"</td>
236 <td>"content_audio_channels"</td>
241 <td>"content_audio_samplerate"</td>
246 <td>"content_audio_track_num"</td>
251 <td>"content_text_track_num"</td>
256 <td>"tag_artist"</td>
276 <td>"tag_author"</td>
281 <td>"tag_copyright"</td>
291 <td>"tag_description"</td>
296 <td>"tag_track_num"</td>
304 /*===========================================================================================
306 | GLOBAL DEFINITIONS AND DECLARATIONS |
308 ========================================================================================== */
310 * @brief Called when error occurs in media demuxer.
311 * @details Following error codes can be delivered.
312 * #MEDIADEMUXER_ERROR_INVALID_OPERATION,
313 * #MEDIADEMUXER_ERROR_NOT_SUPPORTED,
314 * #MEDIADEMUXER_ERROR_INVALID_PATH,
315 * #MEDIADEMUXER_ERROR_RESOURCE_LIMIT,
316 * #MEDIADEMUXER_ERROR_SEEK_FAILED,
317 * #MEDIADEMUXER_ERROR_DRM_NOT_PERMITTED
319 * @param[in] error The error that occurred in media demuxer
320 * @param[in] user_data The user data passed from the code where
321 * mediademuxer_set_error_cb() was invoked
322 * This data will be accessible from @a mediademuxer_error_cb
323 * @pre Create media demuxer handle by calling mediademuxer_create() function.
324 * @see mediademuxer_set_error_cb()
325 * @see mediademuxer_unset_error_cb()
327 typedef void (*md_error_cb)(mediademuxer_error_e error, void *user_data);
330 * @brief Called when eos occurs in media demuxer.
332 * @param[in] track_num The track_num which indicate eos has occurred in which track numbe
333 * @param[in] user_data The user data passed from the code where
334 * mediademuxer_set_eos_cb() was invoked
335 * This data will be accessible from @a mediademuxer_eos_cb
336 * @pre Create media demuxer handle by calling mediademuxer_create() function.
337 * @see mediademuxer_set_eos_cb()
338 * @see mediademuxer_unset_eos_cb()
340 typedef void (*md_eos_cb)(int track_num, void *user_data);
343 * Enumerations of demuxer state.
346 * Attribute validity structure
348 typedef struct _media_port_demuxer_ops {
350 int (*init)(MMHandleType *pHandle);
351 int (*prepare)(MMHandleType pHandle, char *uri);
352 int (*get_track_count)(MMHandleType pHandle, int *count);
353 int (*set_track)(MMHandleType pHandle, int track);
354 int (*start)(MMHandleType pHandle);
355 int (*get_track_info)(MMHandleType pHandle, media_format_h *format, int track);
356 int (*read_sample)(MMHandleType pHandle, media_packet_h *outbuf, int track_indx);
357 int (*seek)(MMHandleType pHandle, int64_t pos1);
358 int (*unset_track)(MMHandleType pHandle, int track);
359 int (*stop)(MMHandleType pHandle);
360 int (*unprepare)(MMHandleType pHandle);
361 int (*destroy)(MMHandleType pHandle);
362 int (*set_error_cb)(MMHandleType demuxer, md_error_cb callback, void *user_data);
363 int (*set_eos_cb)(MMHandleType demuxer, md_eos_cb callback, void *user_data);
364 int (*get_data)(MMHandleType pHandle, char *buffer);
365 } media_port_demuxer_ops;
367 /*===========================================================================================
369 | GLOBAL FUNCTION PROTOTYPES |
371 ========================================================================================== */
374 * This function creates a demuxer object for parsing multimedia contents. \n
375 * The attributes of demuxer are created to get/set some values with application. \n
376 * And, proper port is selected to do the actual parsing of the mdia.
378 * @param demuxer [out] Handle of demuxer
380 * @return This function returns zero on success, or negative value with error code. \n
381 * Please refer 'mm_demuxer_error.h' to know it in detail.
385 MMHandleType demuxer;
388 md_destroy(&demuxer);
391 int md_create(MMHandleType *demuxer);
394 * This function sets the input data source to parse. \n
395 * The source can be a local file or remote server file
397 * @param demuxer [in] Handle of demuxer
398 * @param uri [in] absolute path for the source media
400 * @return This function returns zero on success, or negative value with error code. \n
401 * Please refer 'mm_demuxer_error.h' to know it in detail.
407 if (md_set_data_source(demuxer) != MM_ERROR_NONE)
409 MD_E("failed to set the source \n");
411 md_destroy(&demuxer);
414 int md_set_data_source(MMHandleType demuxer, const char *uri);
417 * This function releases demuxer object and all resources which were created by md_create(). \n
418 * And, demuxer handle will also be destroyed.
420 * @param demuxer [in] Handle of demuxer
422 * @return This function returns zero on success, or negative value with error code.
427 if (md_destroy(g_demuxer) != MM_ERROR_NONE)
429 MD_E("failed to destroy demuxer\n");
433 int md_destroy(MMHandleType demuxer);
436 * This function set up the internal structure of gstreamer, ffmpeg & custom to handle data set up md_set_data_source
438 * @param demuxer [in] Handle of demuxer
440 * @return This function returns zero on success, or negative value with error code.
441 * @see md_set_data_source
445 if (md_prepare(g_demuxer) != MM_ERROR_NONE)
447 MD_E("failed to prepare demuxer\n");
451 int md_prepare(MMHandleType demuxer);
454 * This function get the total number of tracks present in the stream.
456 * @param demuxer [in] Handle of demuxer
457 * @param count [out] Total track number of streams available in the media
459 * @return This function returns zero on success, or negative value with error code.
460 * @see md_set_data_source
464 if (md_get_track_count(g_demuxer,count) != MM_ERROR_NONE)
466 MD_E("failed to get count\n");
470 int md_get_track_count(MMHandleType demuxer, int *count);
473 * This function get the format of selected track present in the stream.
475 * @param demuxer [in] Handle of demuxer
476 * @param track [in] index for the track
477 * @param format [out] pointer to the Handle of media_format
479 * @return This function returns zero on success, or negative value with error code.
483 if (md_get_track_info(g_demuxer, format, track) != MM_ERROR_NONE)
485 MD_E("failed to get track info\n");
489 int md_get_track_info(MMHandleType demuxer, int track, media_format_h *format);
492 * This function start the pipeline(in case of gst port it set the pipeline to play state).
494 * @param demuxer [in] Handle of demuxer
496 * @return This function returns zero on success, or negative value with error code.
498 int md_start(MMHandleType demuxer);
501 * This function read a packet of data from demuxer
503 * @param demuxer [in] Handle of demuxer
504 * @param track_indx [in] selected track number
505 * @param outbuf [out] demuxed packet
507 * @return This function returns zero on success, or negative value with error code.
509 int md_read_sample(MMHandleType demuxer, int track_indx, media_packet_h *outbuf);
512 * This function stop the pipeline in case of gst_port
514 * @param demuxer [in] Handle of demuxer
516 * @return This function returns zero on success, or negative value with error code.
517 * @see md_set_data_source
519 int md_stop(MMHandleType demuxer);
522 * This function destroy the pipeline
524 * @param demuxer [in] Handle of demuxer
526 * @return This function returns zero on success, or negative value with error code.
527 * @see md_set_data_source
529 int md_unprepare(MMHandleType demuxer);
532 * This function is to select a track on which read need to be performed
534 * @param demuxer [in] Handle of demuxer
535 * @param index [in] index for the track to be selected
537 * @return This function returns zero on success, or negative value with error code.
538 * @see md_set_data_source
540 int md_select_track(MMHandleType demuxer, int index);
543 * This function is to unselect a track on which readsample can't be performed
545 * @param demuxer [in] Handle of demuxer
546 * @param index [in] index for the track to be selected
548 * @return This function returns zero on success, or negative value with error code.
549 * @see md_set_data_source
551 int md_unselect_track(MMHandleType demuxer, int index);
554 * This function is to seek to a particular position relative to current position
556 * @param demuxer [in] Handle of demuxer
557 * @param pos [in] relative position to seek
559 * @return This function returns zero on success, or negative value with error code.
560 * @see md_set_data_source
562 int md_seek(MMHandleType demuxer, int64_t pos);
565 * This function is to set error call back function
567 * @param demuxer [in] Handle of demuxer
568 * @param callback [in] call back function pointer
569 * @param user_data [in] user specific data pointer
571 * @return This function returns zero on success, or negative value with error code.
573 int md_set_error_cb(MMHandleType demuxer, md_error_cb callback, void *user_data);
576 * This function is to set eos call back function
578 * @param demuxer [in] Handle of demuxer
579 * @param callback [in] call back function pointer
580 * @param user_data [in] user specific data pointer
582 * @return This function returns zero on success, or negative value with error code.
584 int md_set_eos_cb(MMHandleType demuxer, md_eos_cb callback, void *user_data);
589 #endif /* __TIZEN_MEDIADEMUXER_PORT_H__ */