4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, heechul jeon <heechul.jeon@samsung.co>,
7 * YoungHwan An <younghwan_.an@samsung.com>, Eunhae Choi <eunhae1.choi@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 /*===========================================================================================
27 ========================================================================================== */
29 #include "mm_player_es.h"
30 #include "mm_player_utils.h"
31 #include "mm_player_internal.h"
33 #include <gst/app/gstappsrc.h>
35 /*---------------------------------------------------------------------------
36 | LOCAL VARIABLE DEFINITIONS for internal |
37 ---------------------------------------------------------------------------*/
39 /*---------------------------------------------------------------------------
40 | LOCAL FUNCTION PROTOTYPES: |
41 ---------------------------------------------------------------------------*/
42 static int _parse_media_format (MMPlayerVideoStreamInfo * video, MMPlayerAudioStreamInfo * audio, media_format_h format);
43 static int _convert_media_format_video_mime_to_str (MMPlayerVideoStreamInfo * video, media_format_mimetype_e mime);
44 static int _convert_media_format_audio_mime_to_str (MMPlayerAudioStreamInfo * audio, media_format_mimetype_e mime);
46 /*===========================================================================================
48 | FUNCTION DEFINITIONS |
50 ========================================================================================== */
53 _convert_media_format_video_mime_to_str (MMPlayerVideoStreamInfo * video,
54 media_format_mimetype_e mime)
56 MMPLAYER_RETURN_VAL_IF_FAIL (video, MM_ERROR_INVALID_ARGUMENT);
59 case MEDIA_FORMAT_MPEG4_SP:
60 video->mime = g_strdup ("video/mpeg");
63 case MEDIA_FORMAT_H264_SP:
64 case MEDIA_FORMAT_H264_MP:
65 case MEDIA_FORMAT_H264_HP:
66 video->mime = g_strdup ("video/x-h264");
69 video->mime = g_strdup ("unknown");
77 _convert_media_format_audio_mime_to_str (MMPlayerAudioStreamInfo * audio,
78 media_format_mimetype_e mime)
80 MMPLAYER_RETURN_VAL_IF_FAIL (audio, MM_ERROR_INVALID_ARGUMENT);
83 case MEDIA_FORMAT_AAC:
84 audio->mime = g_strdup ("audio/mpeg");
88 audio->mime = g_strdup ("unknown");
96 _parse_media_format (MMPlayerVideoStreamInfo * video,
97 MMPlayerAudioStreamInfo * audio, media_format_h format)
100 media_format_mimetype_e mime;
105 if (media_format_get_audio_info (format, &mime, &channel, &samplerate, NULL,
106 &avg_bps) != MEDIA_FORMAT_ERROR_NONE) {
107 LOGE ("media_format_get_audio_info failed");
108 return MM_ERROR_PLAYER_INTERNAL;
111 _convert_media_format_audio_mime_to_str (audio, mime);
112 audio->sample_rate = samplerate;
113 audio->channels = channel;
114 //video->user_info = ;
118 media_format_mimetype_e mime;
123 if (media_format_get_video_info (format, &mime, &width, &height, &avg_bps,
124 NULL) != MEDIA_FORMAT_ERROR_NONE) {
125 LOGE ("media_format_get_video_info failed");
126 return MM_ERROR_PLAYER_INTERNAL;
129 _convert_media_format_video_mime_to_str (video, mime);
130 video->width = width;
131 video->height = height;
134 return MM_ERROR_NONE;
138 _mmplayer_update_video_info(MMHandleType hplayer, media_format_h fmt)
140 mm_player_t *player = (mm_player_t *) hplayer;
141 gboolean ret = FALSE;
142 GstStructure *str = NULL;
143 media_format_mimetype_e mimetype = 0;
144 gint cur_width = 0, width = 0;
145 gint cur_height = 0, height = 0;
149 MMPLAYER_RETURN_VAL_IF_FAIL (player, FALSE);
150 MMPLAYER_RETURN_VAL_IF_FAIL (fmt, FALSE);
152 if (player->v_stream_caps)
154 str = gst_caps_get_structure (player->v_stream_caps, 0);
155 if ( !gst_structure_get_int (str, "width", &cur_width))
157 LOGD ("missing 'width' field in video caps");
160 if ( !gst_structure_get_int (str, "height", &cur_height))
162 LOGD ("missing 'height' field in video caps");
165 media_format_get_video_info(fmt, &mimetype, &width, &height, NULL, NULL);
166 if ((cur_width != width) || (cur_height != height))
168 LOGW ("resolution is changed %dx%d -> %dx%d",
169 cur_width, cur_height, width, height);
170 _mmplayer_set_video_info(hplayer, fmt);
181 _mmplayer_set_media_stream_buffer_status_cb(MMHandleType hplayer,
182 MMPlayerStreamType type,
183 mm_player_media_stream_buffer_status_callback callback,
186 mm_player_t *player = (mm_player_t *) hplayer;
190 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
192 if ((type < MM_PLAYER_STREAM_TYPE_DEFAULT) || (type > MM_PLAYER_STREAM_TYPE_TEXT))
193 return MM_ERROR_INVALID_ARGUMENT;
195 if (player->media_stream_buffer_status_cb[type])
199 LOGD ("[type:%d] will be clear.\n", type);
203 LOGD ("[type:%d] will be overwritten.\n", type);
207 player->media_stream_buffer_status_cb[type] = callback;
208 player->buffer_cb_user_param = user_param;
210 LOGD ("player handle %p, type %d, callback %p\n", player, type,
211 player->media_stream_buffer_status_cb[type]);
215 return MM_ERROR_NONE;
219 _mmplayer_set_media_stream_seek_data_cb(MMHandleType hplayer,
220 MMPlayerStreamType type,
221 mm_player_media_stream_seek_data_callback callback,
224 mm_player_t *player = (mm_player_t *) hplayer;
228 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
230 if ((type < MM_PLAYER_STREAM_TYPE_DEFAULT) || (type > MM_PLAYER_STREAM_TYPE_TEXT))
231 return MM_ERROR_INVALID_ARGUMENT;
233 if (player->media_stream_seek_data_cb[type])
237 LOGD ("[type:%d] will be clear.\n", type);
241 LOGD ("[type:%d] will be overwritten.\n", type);
245 player->media_stream_seek_data_cb[type] = callback;
246 player->buffer_cb_user_param = user_param;
248 LOGD ("player handle %p, type %d, callback %p\n", player, type,
249 player->media_stream_seek_data_cb[type]);
253 return MM_ERROR_NONE;
257 __mmplayer_get_source_element (mm_player_t *player, MMPlayerStreamType type)
259 enum MainElementID elemId = MMPLAYER_M_NUM;
261 if (player && player->pipeline && player->pipeline->mainbin) {
263 /* get elem according to the stream type */
264 if (type == MM_PLAYER_STREAM_TYPE_AUDIO) {
265 if (player->pipeline->mainbin[MMPLAYER_M_2ND_SRC].gst) {
266 elemId = MMPLAYER_M_2ND_SRC;
267 } else if (g_strrstr (GST_ELEMENT_NAME (player->pipeline->mainbin[MMPLAYER_M_SRC].gst), "audio_appsrc")) {
268 elemId = MMPLAYER_M_SRC;
271 else if (type == MM_PLAYER_STREAM_TYPE_VIDEO) {
272 elemId = MMPLAYER_M_SRC;
274 else if (type == MM_PLAYER_STREAM_TYPE_TEXT) {
275 elemId = MMPLAYER_M_SUBSRC;
278 if (elemId != MMPLAYER_M_NUM)
279 return player->pipeline->mainbin[elemId].gst;
286 _mmplayer_set_media_stream_max_size(MMHandleType hplayer, MMPlayerStreamType type, guint64 max_size)
288 mm_player_t *player = (mm_player_t *) hplayer;
289 GstElement *element = NULL;
292 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
294 if ((type < MM_PLAYER_STREAM_TYPE_AUDIO) ||
295 (type > MM_PLAYER_STREAM_TYPE_TEXT) ||
297 LOGE ("Invalid param type:%d, max_size:%d", type, max_size);
298 return MM_ERROR_INVALID_ARGUMENT;
301 LOGD ("type %d, max_size %llu\n", type, max_size);
303 if ((element = __mmplayer_get_source_element(player, type))) {
304 LOGD ("update max_size of %s\n", GST_ELEMENT_NAME(element));
305 g_object_set(G_OBJECT(element), "max-bytes", max_size, NULL);
308 player->media_stream_buffer_max_size[type] = max_size;
311 return MM_ERROR_NONE;
315 _mmplayer_get_media_stream_max_size(MMHandleType hplayer, MMPlayerStreamType type, guint64 *max_size)
317 mm_player_t *player = (mm_player_t *) hplayer;
321 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
322 MMPLAYER_RETURN_VAL_IF_FAIL (max_size, MM_ERROR_INVALID_ARGUMENT);
324 if ((type < MM_PLAYER_STREAM_TYPE_DEFAULT) || (type > MM_PLAYER_STREAM_TYPE_TEXT))
325 return MM_ERROR_INVALID_ARGUMENT;
327 *max_size = player->media_stream_buffer_max_size[type];
331 return MM_ERROR_NONE;
335 _mmplayer_set_media_stream_min_percent(MMHandleType hplayer, MMPlayerStreamType type, guint min_percent)
337 mm_player_t *player = (mm_player_t *) hplayer;
338 GstElement *element = NULL;
342 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
344 if ((type < MM_PLAYER_STREAM_TYPE_AUDIO) || (type > MM_PLAYER_STREAM_TYPE_TEXT)) {
345 LOGE ("Invalid param type:%d", type);
346 return MM_ERROR_INVALID_ARGUMENT;
349 LOGD ("type %d, min_per %u\n", type, min_percent);
351 if ((element = __mmplayer_get_source_element(player, type))) {
352 LOGD ("update min_per of %s\n", GST_ELEMENT_NAME(element));
353 g_object_set(G_OBJECT(element), "min-percent", min_percent, NULL);
356 player->media_stream_buffer_min_percent[type] = min_percent;
359 return MM_ERROR_NONE;
363 _mmplayer_get_media_stream_min_percent(MMHandleType hplayer, MMPlayerStreamType type, guint *min_percent)
365 mm_player_t *player = (mm_player_t *) hplayer;
369 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
370 MMPLAYER_RETURN_VAL_IF_FAIL (min_percent, MM_ERROR_INVALID_ARGUMENT);
372 if ((type < MM_PLAYER_STREAM_TYPE_DEFAULT) || (type > MM_PLAYER_STREAM_TYPE_TEXT))
373 return MM_ERROR_INVALID_ARGUMENT;
375 *min_percent = player->media_stream_buffer_min_percent[type];
379 return MM_ERROR_NONE;
383 __mmplayer_check_buffer_level(mm_player_t *player, GstElement* element, MMPlayerStreamType type)
385 guint64 current_level_bytes = 0;
386 guint64 max_bytes = 0;
387 guint current_level_per = 0;
390 MMPLAYER_RETURN_VAL_IF_FAIL ( player && element, MM_ERROR_PLAYER_NOT_INITIALIZED);
392 if (player->media_stream_buffer_max_size[type] > 0) {
393 max_bytes = player->media_stream_buffer_max_size[type];
395 g_object_get(G_OBJECT(element), "max-bytes", &max_bytes, NULL);
398 if (max_bytes == 0) {
399 LOGW ("buffer max size is zero.");
400 return MM_ERROR_NONE;
403 g_object_get(G_OBJECT(element), "current-level-bytes", ¤t_level_bytes, NULL);
405 if (max_bytes <= current_level_bytes) {
406 LOGE ("no available buffer space. type %d, max %lld, curr %lld", type, max_bytes, current_level_bytes);
407 return MM_ERROR_PLAYER_BUFFER_SPACE;
410 if (MMPLAYER_CURRENT_STATE(player) != MM_PLAYER_STATE_PLAYING) {
411 if (!player->media_stream_buffer_status_cb[type]) {
412 return MM_ERROR_NONE;
415 current_level_per = (guint)(gst_util_guint64_to_gdouble(current_level_bytes)/gst_util_guint64_to_gdouble(max_bytes)*100);
417 LOGD ("type %d, min_per %u, curr_per %u max %lld cur %lld\n",
418 type, player->media_stream_buffer_min_percent[type],
420 player->media_stream_buffer_max_size[type],
421 current_level_bytes);
423 if (current_level_per < player->media_stream_buffer_min_percent[type])
424 player->media_stream_buffer_status_cb[type](type, MM_PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN, current_level_bytes, player->buffer_cb_user_param);
428 return MM_ERROR_NONE;
432 _mmplayer_submit_packet (MMHandleType hplayer, media_packet_h packet)
434 int ret = MM_ERROR_NONE;
435 GstBuffer *_buffer = NULL;
436 mm_player_t *player = (mm_player_t *) hplayer;
439 GstElement* element = NULL;
440 MMPlayerStreamType streamtype = MM_PLAYER_STREAM_TYPE_AUDIO;
441 media_format_h fmt = NULL;
445 MMPLAYER_RETURN_VAL_IF_FAIL (packet, MM_ERROR_INVALID_ARGUMENT);
446 MMPLAYER_RETURN_VAL_IF_FAIL ( player &&
448 player->pipeline->mainbin &&
449 player->pipeline->mainbin[MMPLAYER_M_SRC].gst,
450 MM_ERROR_PLAYER_INTERNAL );
452 /* get stream type if audio or video */
453 media_packet_is_audio (packet, &flag);
455 streamtype = MM_PLAYER_STREAM_TYPE_AUDIO;
457 media_packet_is_video (packet, &flag);
459 streamtype = MM_PLAYER_STREAM_TYPE_VIDEO;
461 streamtype = MM_PLAYER_STREAM_TYPE_TEXT;
464 element = __mmplayer_get_source_element(player, streamtype);
466 LOGE ("there is no source element of type %d", streamtype);
467 ret = MM_ERROR_PLAYER_INTERNAL;
471 /* check buffer level */
472 ret = __mmplayer_check_buffer_level (player, element, streamtype);
473 if (ret != MM_ERROR_NONE)
477 if (media_packet_get_buffer_data_ptr (packet, (void **) &buf) != MEDIA_PACKET_ERROR_NONE) {
478 LOGE("failed to get buffer data ptr");
479 ret = MM_ERROR_PLAYER_INTERNAL;
483 if (media_packet_get_buffer_size (packet, &size) != MEDIA_PACKET_ERROR_NONE) {
484 LOGE("failed to get buffer size");
485 ret = MM_ERROR_PLAYER_INTERNAL;
489 if (buf != NULL && size > 0) {
490 GstMapInfo buff_info = GST_MAP_INFO_INIT;
494 _buffer = gst_buffer_new_and_alloc (size);
497 LOGE("failed to allocate memory for push buffer\n");
498 ret = MM_ERROR_PLAYER_NO_FREE_SPACE;
502 if (gst_buffer_map (_buffer, &buff_info, GST_MAP_READWRITE)) {
504 memcpy (buff_info.data, buf, size);
505 buff_info.size = size;
507 gst_buffer_unmap (_buffer, &buff_info);
510 if (streamtype == MM_PLAYER_STREAM_TYPE_VIDEO) {
511 /* get format to check video format */
512 media_packet_get_format (packet, &fmt);
514 if (_mmplayer_update_video_info(hplayer, fmt)) {
515 LOGD("update video caps");
516 g_object_set(G_OBJECT(player->pipeline->mainbin[MMPLAYER_M_SRC].gst),
517 "caps", player->v_stream_caps, NULL);
523 if (media_packet_get_pts (packet, &pts) != MEDIA_PACKET_ERROR_NONE) {
524 LOGE("failed to get pts info");
525 ret = MM_ERROR_PLAYER_INTERNAL;
528 GST_BUFFER_PTS (_buffer) = (GstClockTime)pts;
529 gst_app_src_push_buffer (GST_APP_SRC (element), _buffer);
533 if (media_packet_is_end_of_stream(packet, &is_eos) != MEDIA_PACKET_ERROR_NONE) {
534 LOGE("failed to get eos info");
535 ret = MM_ERROR_PLAYER_INTERNAL;
540 LOGW ("we got eos of stream type(%d)", streamtype);
541 g_signal_emit_by_name (element, "end-of-stream", &ret);
549 _mmplayer_video_caps_new (MMHandleType hplayer, MMPlayerVideoStreamInfo * video,
550 const char *fieldname, ...)
553 GstCaps *caps = NULL;
554 GstStructure *structure = NULL;
556 mm_player_t *player = MM_PLAYER_CAST (hplayer);
559 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
560 MMPLAYER_RETURN_VAL_IF_FAIL (video, MM_ERROR_PLAYER_NOT_INITIALIZED);
562 LOGD ("width=%d height=%d framerate num=%d, den=%d",
563 video->width, video->height, video->framerate_num, video->framerate_den);
565 caps = gst_caps_new_simple (video->mime,
566 "width", G_TYPE_INT, video->width,
567 "height", G_TYPE_INT, video->height,
568 "framerate", GST_TYPE_FRACTION, video->framerate_num, video->framerate_den, NULL);
570 for (cap_size = 0; cap_size < gst_caps_get_size (caps); cap_size++) {
571 va_start (var_args, fieldname);
572 structure = gst_caps_get_structure (caps, cap_size);
573 gst_structure_set_valist (structure, fieldname, var_args);
577 if (video->extradata_size) {
578 GstBuffer *buf = NULL;
579 GstMapInfo buff_info = GST_MAP_INFO_INIT;
581 buf = gst_buffer_new_and_alloc (video->extradata_size);
583 if (gst_buffer_map (buf, &buff_info, GST_MAP_READ)) {
584 memcpy (buff_info.data, video->codec_extradata, video->extradata_size);
585 buff_info.size = video->extradata_size;
586 gst_buffer_unmap (buf, &buff_info);
589 gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
590 gst_buffer_unref (buf);
593 if (player->v_stream_caps)
595 LOGW ("caps will be updated ");
597 gst_caps_unref(player->v_stream_caps);
598 player->v_stream_caps = NULL;
601 player->v_stream_caps = gst_caps_copy (caps);
602 MMPLAYER_LOG_GST_CAPS_TYPE (player->v_stream_caps);
603 gst_caps_unref (caps);
607 return MM_ERROR_NONE;
611 _mmplayer_set_uri_type(mm_player_t *player)
615 player->profile.uri_type = MM_PLAYER_URI_TYPE_MS_BUFF;
616 player->es_player_push_mode = TRUE;
623 _mmplayer_set_video_info (MMHandleType hplayer, media_format_h format)
625 mm_player_t *player = MM_PLAYER_CAST (hplayer);
626 MMPlayerVideoStreamInfo video = { 0, };
627 int ret = MM_ERROR_NONE;
631 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
633 _mmplayer_set_uri_type(player);
635 ret = _parse_media_format (&video, NULL, format);
636 if(ret != MM_ERROR_NONE)
639 if (strstr (video.mime, "video/mpeg")) {
640 _mmplayer_video_caps_new (hplayer, &video,
641 "mpegversion", G_TYPE_INT, video.version,
642 "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
643 } else if (strstr (video.mime, "video/x-h264")) {
644 //if (info.colordepth)
646 // _mmplayer_video_caps_new(hplayer, &info,
647 // "colordepth", G_TYPE_INT, info.colordepth, NULL);
651 _mmplayer_video_caps_new (hplayer, &video,
652 "stream-format", G_TYPE_STRING, "byte-stream",
653 "alignment", G_TYPE_STRING, "au", NULL);
657 else if (strstr (info->mime, "video/x-wmv")) {
658 _mmplayer_video_caps_new (hplayer, &info,
659 "wmvversion", G_TYPE_INT, info.version, NULL);
660 } else if (strstr (info.mime, "video/x-pn-realvideo")) {
661 _mmplayer_video_caps_new (hplayer, &info,
662 "rmversion", G_TYPE_INT, info.version, NULL);
663 } else if (strstr (info.mime, "video/x-msmpeg")) {
664 _mmplayer_video_caps_new (hplayer, &info,
665 "msmpegversion", G_TYPE_INT, info.version, NULL);
666 } else if (strstr (info.mime, "video/x-h265")) {
667 if (info.colordepth) {
668 _mmplayer_video_caps_new (hplayer, &info,
669 "colordepth", G_TYPE_INT, info.colordepth, NULL);
671 _mmplayer_video_caps_new (hplayer, &info, NULL);
674 _mmplayer_video_caps_new (hplayer, &info, NULL);
677 g_free ((char *) video.mime);
681 return MM_ERROR_NONE;
685 _mmplayer_set_audio_info (MMHandleType hplayer, media_format_h format)
687 mm_player_t *player = MM_PLAYER_CAST (hplayer);
688 GstCaps *caps = NULL;
689 MMPlayerAudioStreamInfo audio = { 0, };
690 int ret = MM_ERROR_NONE;
694 MMPLAYER_RETURN_VAL_IF_FAIL (hplayer, MM_ERROR_PLAYER_NOT_INITIALIZED);
696 _mmplayer_set_uri_type(player);
698 ret = _parse_media_format (NULL, &audio, format);
699 if(ret != MM_ERROR_NONE)
702 audio.user_info = 0; //test
704 LOGD ("set audio player[%p] info [%p] version=%d rate=%d channel=%d",
705 player, audio, audio.version, audio.sample_rate, audio.channels);
707 if (strstr (audio.mime, "audio/mpeg")) {
708 if (audio.version == 1) { // mp3
709 caps = gst_caps_new_simple ("audio/mpeg",
710 "channels", G_TYPE_INT, audio.channels,
711 "rate", G_TYPE_INT, audio.sample_rate,
712 "mpegversion", G_TYPE_INT, audio.version,
713 "layer", G_TYPE_INT, audio.user_info, NULL);
715 gchar *format = NULL;
717 if (audio.user_info == 0)
718 format = g_strdup ("raw");
719 else if (audio.user_info == 1)
720 format = g_strdup ("adts");
721 else if (audio.user_info == 2)
722 format = g_strdup ("adif");
724 caps = gst_caps_new_simple ("audio/mpeg",
725 "channels", G_TYPE_INT, audio.channels,
726 "rate", G_TYPE_INT, audio.sample_rate,
727 "mpegversion", G_TYPE_INT, audio.version,
728 "stream-format", G_TYPE_STRING, format, NULL);
735 else if (strstr (audio.mime, "audio/x-raw-int")) {
736 caps = gst_caps_new_simple ("audio/x-raw-int",
737 "width", G_TYPE_INT, audio.width,
738 "depth", G_TYPE_INT, audio.depth,
739 "endianness", G_TYPE_INT, audio.endianness,
740 "signed", G_TYPE_BOOLEAN, audio.signedness,
741 "channels", G_TYPE_INT, audio.channels,
742 "rate", G_TYPE_INT, audio.sample_rate, NULL);
744 caps = gst_caps_new_simple (audio.mime,
745 "channels", G_TYPE_INT, audio.channels,
746 "rate", G_TYPE_INT, audio.sample_rate, NULL);
750 if (audio.extradata_size) {
751 GstBuffer *buf = NULL;
752 GstMapInfo buff_info = GST_MAP_INFO_INIT;
754 buf = gst_buffer_new_and_alloc (audio.extradata_size);
756 if (gst_buffer_map (buf, &buff_info, GST_MAP_READ)) {
757 memcpy (buff_info.data, audio.codec_extradata, audio.extradata_size);
758 gst_buffer_unmap (buf, &buff_info);
761 gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
762 gst_buffer_unref (buf);
765 g_free ((char *) audio.mime);
767 player->a_stream_caps = gst_caps_copy (caps);
768 gst_caps_unref (caps);
772 return MM_ERROR_NONE;
776 _mmplayer_set_subtitle_info (MMHandleType hplayer,
777 MMPlayerSubtitleStreamInfo * subtitle)
781 mm_player_t *player = MM_PLAYER_CAST (hplayer);
782 GstCaps *caps = NULL;
786 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
787 MMPLAYER_RETURN_VAL_IF_FAIL (info, MM_ERROR_PLAYER_NOT_INITIALIZED);
789 LOGD ("set subtitle player[%p] info [%p]", player, info);
792 caps = gst_caps_new_simple (info->mime, NULL, NULL); // TO CHECK
796 if (strstr (info->mime, "application/x-xsub")) {
797 gst_caps_set_simple (caps, "codec_tag", G_TYPE_UINT, info->codec_tag, NULL);
798 } else if (strstr (info->mime, "application/x-smpte-text")) {
800 gst_caps_set_simple (caps, "ttml_priv_data", G_TYPE_POINTER,
801 info->context, NULL);
805 player->s_stream_caps = gst_caps_copy (caps);
807 gst_caps_unref (caps);
812 return MM_ERROR_NONE;