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 #define DEFAULT_FRAMERATE_NUM 30
119 #define DEFAULT_FRAMERATE_DEN 1
120 media_format_mimetype_e mime;
126 if (media_format_get_video_info (format, &mime, &width, &height, &avg_bps,
127 NULL) != MEDIA_FORMAT_ERROR_NONE) {
128 LOGE ("media_format_get_video_info failed");
129 return MM_ERROR_PLAYER_INTERNAL;
132 if (media_format_get_video_frame_rate(format, &frame_rate)) {
133 LOGW ("failed to get video frame rate, will be set 30.");
135 LOGD ("frame_rate %d", frame_rate);
137 __convert_media_format_video_mime_to_str (video, mime);
139 video->width = width;
140 video->height = height;
141 video->framerate_num = (frame_rate>0)?(frame_rate):(DEFAULT_FRAMERATE_NUM);
142 video->framerate_den = DEFAULT_FRAMERATE_DEN;
145 return MM_ERROR_NONE;
149 __mmplayer_update_video_info(MMHandleType hplayer, media_format_h fmt)
151 mm_player_t *player = (mm_player_t *) hplayer;
152 gboolean ret = FALSE;
153 GstStructure *str = NULL;
154 media_format_mimetype_e mimetype = 0;
155 gint cur_width = 0, width = 0;
156 gint cur_height = 0, height = 0;
160 MMPLAYER_RETURN_VAL_IF_FAIL (player, FALSE);
161 MMPLAYER_RETURN_VAL_IF_FAIL (fmt, FALSE);
163 if (player->v_stream_caps)
165 str = gst_caps_get_structure (player->v_stream_caps, 0);
166 if ( !gst_structure_get_int (str, "width", &cur_width))
168 LOGD ("missing 'width' field in video caps");
171 if ( !gst_structure_get_int (str, "height", &cur_height))
173 LOGD ("missing 'height' field in video caps");
176 media_format_get_video_info(fmt, &mimetype, &width, &height, NULL, NULL);
177 if ((cur_width != width) || (cur_height != height))
179 LOGW ("resolution is changed %dx%d -> %dx%d",
180 cur_width, cur_height, width, height);
181 _mmplayer_set_video_info(hplayer, fmt);
192 _mmplayer_set_media_stream_buffer_status_cb(MMHandleType hplayer,
193 MMPlayerStreamType type,
194 mm_player_media_stream_buffer_status_callback callback,
197 mm_player_t *player = (mm_player_t *) hplayer;
201 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
203 if ((type < MM_PLAYER_STREAM_TYPE_DEFAULT) || (type > MM_PLAYER_STREAM_TYPE_TEXT))
204 return MM_ERROR_INVALID_ARGUMENT;
206 if (player->media_stream_buffer_status_cb[type])
210 LOGD ("[type:%d] will be clear.\n", type);
214 LOGD ("[type:%d] will be overwritten.\n", type);
218 player->media_stream_buffer_status_cb[type] = callback;
219 player->buffer_cb_user_param = user_param;
221 LOGD ("player handle %p, type %d, callback %p\n", player, type,
222 player->media_stream_buffer_status_cb[type]);
226 return MM_ERROR_NONE;
230 _mmplayer_set_media_stream_seek_data_cb(MMHandleType hplayer,
231 MMPlayerStreamType type,
232 mm_player_media_stream_seek_data_callback callback,
235 mm_player_t *player = (mm_player_t *) hplayer;
239 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
241 if ((type < MM_PLAYER_STREAM_TYPE_DEFAULT) || (type > MM_PLAYER_STREAM_TYPE_TEXT))
242 return MM_ERROR_INVALID_ARGUMENT;
244 if (player->media_stream_seek_data_cb[type])
248 LOGD ("[type:%d] will be clear.\n", type);
252 LOGD ("[type:%d] will be overwritten.\n", type);
256 player->media_stream_seek_data_cb[type] = callback;
257 player->buffer_cb_user_param = user_param;
259 LOGD ("player handle %p, type %d, callback %p\n", player, type,
260 player->media_stream_seek_data_cb[type]);
264 return MM_ERROR_NONE;
268 __mmplayer_get_source_element (mm_player_t *player, MMPlayerStreamType type)
270 enum MainElementID elemId = MMPLAYER_M_NUM;
272 if (player && player->pipeline && player->pipeline->mainbin) {
274 /* get elem according to the stream type */
275 if (type == MM_PLAYER_STREAM_TYPE_AUDIO) {
276 if (player->pipeline->mainbin[MMPLAYER_M_2ND_SRC].gst) {
277 elemId = MMPLAYER_M_2ND_SRC;
278 } else if (g_strrstr (GST_ELEMENT_NAME (player->pipeline->mainbin[MMPLAYER_M_SRC].gst), "audio_appsrc")) {
279 elemId = MMPLAYER_M_SRC;
282 else if (type == MM_PLAYER_STREAM_TYPE_VIDEO) {
283 elemId = MMPLAYER_M_SRC;
285 else if (type == MM_PLAYER_STREAM_TYPE_TEXT) {
286 elemId = MMPLAYER_M_SUBSRC;
289 if (elemId != MMPLAYER_M_NUM)
290 return player->pipeline->mainbin[elemId].gst;
297 _mmplayer_set_media_stream_max_size(MMHandleType hplayer, MMPlayerStreamType type, guint64 max_size)
299 mm_player_t *player = (mm_player_t *) hplayer;
300 GstElement *element = NULL;
303 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
305 if ((type < MM_PLAYER_STREAM_TYPE_AUDIO) ||
306 (type > MM_PLAYER_STREAM_TYPE_TEXT) ||
308 LOGE ("Invalid param type:%d, max_size:%d", type, max_size);
309 return MM_ERROR_INVALID_ARGUMENT;
312 LOGD ("type %d, max_size %llu\n", type, max_size);
314 if ((element = __mmplayer_get_source_element(player, type))) {
315 LOGD ("update max_size of %s\n", GST_ELEMENT_NAME(element));
316 g_object_set(G_OBJECT(element), "max-bytes", max_size, NULL);
319 player->media_stream_buffer_max_size[type] = max_size;
322 return MM_ERROR_NONE;
326 _mmplayer_get_media_stream_max_size(MMHandleType hplayer, MMPlayerStreamType type, guint64 *max_size)
328 mm_player_t *player = (mm_player_t *) hplayer;
332 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
333 MMPLAYER_RETURN_VAL_IF_FAIL (max_size, MM_ERROR_INVALID_ARGUMENT);
335 if ((type < MM_PLAYER_STREAM_TYPE_DEFAULT) || (type > MM_PLAYER_STREAM_TYPE_TEXT))
336 return MM_ERROR_INVALID_ARGUMENT;
338 *max_size = player->media_stream_buffer_max_size[type];
342 return MM_ERROR_NONE;
346 _mmplayer_set_media_stream_min_percent(MMHandleType hplayer, MMPlayerStreamType type, guint min_percent)
348 mm_player_t *player = (mm_player_t *) hplayer;
349 GstElement *element = NULL;
353 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
355 if ((type < MM_PLAYER_STREAM_TYPE_AUDIO) || (type > MM_PLAYER_STREAM_TYPE_TEXT)) {
356 LOGE ("Invalid param type:%d", type);
357 return MM_ERROR_INVALID_ARGUMENT;
360 LOGD ("type %d, min_per %u\n", type, min_percent);
362 if ((element = __mmplayer_get_source_element(player, type))) {
363 LOGD ("update min_per of %s\n", GST_ELEMENT_NAME(element));
364 g_object_set(G_OBJECT(element), "min-percent", min_percent, NULL);
367 player->media_stream_buffer_min_percent[type] = min_percent;
370 return MM_ERROR_NONE;
374 _mmplayer_get_media_stream_min_percent(MMHandleType hplayer, MMPlayerStreamType type, guint *min_percent)
376 mm_player_t *player = (mm_player_t *) hplayer;
380 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
381 MMPLAYER_RETURN_VAL_IF_FAIL (min_percent, MM_ERROR_INVALID_ARGUMENT);
383 if ((type < MM_PLAYER_STREAM_TYPE_DEFAULT) || (type > MM_PLAYER_STREAM_TYPE_TEXT))
384 return MM_ERROR_INVALID_ARGUMENT;
386 *min_percent = player->media_stream_buffer_min_percent[type];
390 return MM_ERROR_NONE;
394 __mmplayer_check_buffer_level(mm_player_t *player, GstElement* element, MMPlayerStreamType type)
396 guint64 current_level_bytes = 0;
397 guint64 max_bytes = 0;
398 guint current_level_per = 0;
401 MMPLAYER_RETURN_VAL_IF_FAIL ( player && element, MM_ERROR_PLAYER_NOT_INITIALIZED);
403 if (player->media_stream_buffer_max_size[type] > 0) {
404 max_bytes = player->media_stream_buffer_max_size[type];
406 g_object_get(G_OBJECT(element), "max-bytes", &max_bytes, NULL);
409 if (max_bytes == 0) {
410 LOGW ("buffer max size is zero.");
411 return MM_ERROR_NONE;
414 g_object_get(G_OBJECT(element), "current-level-bytes", ¤t_level_bytes, NULL);
416 if (max_bytes <= current_level_bytes) {
417 LOGE ("no available buffer space. type %d, max %lld, curr %lld", type, max_bytes, current_level_bytes);
418 return MM_ERROR_PLAYER_BUFFER_SPACE;
421 if (MMPLAYER_CURRENT_STATE(player) != MM_PLAYER_STATE_PLAYING) {
422 if (!player->media_stream_buffer_status_cb[type]) {
423 return MM_ERROR_NONE;
426 current_level_per = (guint)(gst_util_guint64_to_gdouble(current_level_bytes)/gst_util_guint64_to_gdouble(max_bytes)*100);
428 LOGD ("type %d, min_per %u, curr_per %u max %lld cur %lld\n",
429 type, player->media_stream_buffer_min_percent[type],
431 player->media_stream_buffer_max_size[type],
432 current_level_bytes);
434 if (current_level_per < player->media_stream_buffer_min_percent[type])
435 player->media_stream_buffer_status_cb[type](type, MM_PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN, current_level_bytes, player->buffer_cb_user_param);
439 return MM_ERROR_NONE;
443 _mmplayer_submit_packet (MMHandleType hplayer, media_packet_h packet)
445 int ret = MM_ERROR_NONE;
446 GstBuffer *_buffer = NULL;
447 mm_player_t *player = (mm_player_t *) hplayer;
450 GstElement* element = NULL;
451 MMPlayerStreamType streamtype = MM_PLAYER_STREAM_TYPE_AUDIO;
452 media_format_h fmt = NULL;
456 MMPLAYER_RETURN_VAL_IF_FAIL (packet, MM_ERROR_INVALID_ARGUMENT);
457 MMPLAYER_RETURN_VAL_IF_FAIL ( player &&
459 player->pipeline->mainbin &&
460 player->pipeline->mainbin[MMPLAYER_M_SRC].gst,
461 MM_ERROR_PLAYER_INTERNAL );
463 /* get stream type if audio or video */
464 media_packet_is_audio (packet, &flag);
466 streamtype = MM_PLAYER_STREAM_TYPE_AUDIO;
468 media_packet_is_video (packet, &flag);
470 streamtype = MM_PLAYER_STREAM_TYPE_VIDEO;
472 streamtype = MM_PLAYER_STREAM_TYPE_TEXT;
475 element = __mmplayer_get_source_element(player, streamtype);
477 LOGE ("there is no source element of type %d", streamtype);
478 ret = MM_ERROR_PLAYER_INTERNAL;
482 /* check buffer level */
483 ret = __mmplayer_check_buffer_level (player, element, streamtype);
484 if (ret != MM_ERROR_NONE)
488 if (media_packet_get_buffer_data_ptr (packet, (void **) &buf) != MEDIA_PACKET_ERROR_NONE) {
489 LOGE("failed to get buffer data ptr");
490 ret = MM_ERROR_PLAYER_INTERNAL;
494 if (media_packet_get_buffer_size (packet, &size) != MEDIA_PACKET_ERROR_NONE) {
495 LOGE("failed to get buffer size");
496 ret = MM_ERROR_PLAYER_INTERNAL;
500 if (buf != NULL && size > 0) {
501 GstMapInfo buff_info = GST_MAP_INFO_INIT;
505 _buffer = gst_buffer_new_and_alloc (size);
508 LOGE("failed to allocate memory for push buffer\n");
509 ret = MM_ERROR_PLAYER_NO_FREE_SPACE;
513 if (gst_buffer_map (_buffer, &buff_info, GST_MAP_READWRITE)) {
515 memcpy (buff_info.data, buf, size);
516 buff_info.size = size;
518 gst_buffer_unmap (_buffer, &buff_info);
521 if (streamtype == MM_PLAYER_STREAM_TYPE_VIDEO) {
522 /* get format to check video format */
523 media_packet_get_format (packet, &fmt);
525 if (__mmplayer_update_video_info(hplayer, fmt)) {
526 LOGD("update video caps");
527 g_object_set(G_OBJECT(player->pipeline->mainbin[MMPLAYER_M_SRC].gst),
528 "caps", player->v_stream_caps, NULL);
530 media_format_unref(fmt);
535 if (media_packet_get_pts (packet, &pts) != MEDIA_PACKET_ERROR_NONE) {
536 LOGE("failed to get pts info");
537 ret = MM_ERROR_PLAYER_INTERNAL;
540 GST_BUFFER_PTS (_buffer) = (GstClockTime)pts;
541 gst_app_src_push_buffer (GST_APP_SRC (element), _buffer);
545 if (media_packet_is_end_of_stream(packet, &is_eos) != MEDIA_PACKET_ERROR_NONE) {
546 LOGE("failed to get eos info");
547 ret = MM_ERROR_PLAYER_INTERNAL;
552 LOGW ("we got eos of stream type(%d)", streamtype);
553 g_signal_emit_by_name (element, "end-of-stream", &ret);
561 __mmplayer_video_caps_new (MMHandleType hplayer, MMPlayerVideoStreamInfo * video,
562 const char *fieldname, ...)
565 GstCaps *caps = NULL;
566 GstStructure *structure = NULL;
568 mm_player_t *player = MM_PLAYER_CAST (hplayer);
571 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
572 MMPLAYER_RETURN_VAL_IF_FAIL (video, MM_ERROR_PLAYER_NOT_INITIALIZED);
574 LOGD ("width=%d height=%d framerate num=%d, den=%d",
575 video->width, video->height, video->framerate_num, video->framerate_den);
577 caps = gst_caps_new_simple (video->mime,
578 "width", G_TYPE_INT, video->width,
579 "height", G_TYPE_INT, video->height,
580 "framerate", GST_TYPE_FRACTION, video->framerate_num, video->framerate_den, NULL);
582 for (cap_size = 0; cap_size < gst_caps_get_size (caps); cap_size++) {
583 va_start (var_args, fieldname);
584 structure = gst_caps_get_structure (caps, cap_size);
585 gst_structure_set_valist (structure, fieldname, var_args);
589 if (video->extradata_size) {
590 GstBuffer *buf = NULL;
591 GstMapInfo buff_info = GST_MAP_INFO_INIT;
593 buf = gst_buffer_new_and_alloc (video->extradata_size);
595 if (gst_buffer_map (buf, &buff_info, GST_MAP_READ)) {
596 memcpy (buff_info.data, video->codec_extradata, video->extradata_size);
597 buff_info.size = video->extradata_size;
598 gst_buffer_unmap (buf, &buff_info);
601 gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
602 gst_buffer_unref (buf);
605 if (player->v_stream_caps)
607 LOGW ("caps will be updated ");
609 gst_caps_unref(player->v_stream_caps);
610 player->v_stream_caps = NULL;
613 player->v_stream_caps = gst_caps_copy (caps);
614 MMPLAYER_LOG_GST_CAPS_TYPE (player->v_stream_caps);
615 gst_caps_unref (caps);
619 return MM_ERROR_NONE;
623 __mmplayer_set_uri_type(mm_player_t *player)
627 player->profile.uri_type = MM_PLAYER_URI_TYPE_MS_BUFF;
628 player->es_player_push_mode = TRUE;
635 _mmplayer_set_video_info (MMHandleType hplayer, media_format_h format)
637 mm_player_t *player = MM_PLAYER_CAST (hplayer);
638 MMPlayerVideoStreamInfo video = { 0, };
639 int ret = MM_ERROR_NONE;
640 gboolean drc = FALSE;
644 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
646 __mmplayer_set_uri_type(player);
648 ret = __parse_media_format (&video, NULL, format);
649 if(ret != MM_ERROR_NONE)
652 mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_DRC_MODE, &drc);
654 if (strstr (video.mime, "video/mpeg")) {
655 __mmplayer_video_caps_new (hplayer, &video,
656 "mpegversion", G_TYPE_INT, video.version,
657 "systemstream", G_TYPE_BOOLEAN, FALSE,
658 "adaptive-streaming", G_TYPE_BOOLEAN, drc, NULL);
659 } else if (strstr (video.mime, "video/x-h264")) {
660 //if (info.colordepth)
662 // __mmplayer_video_caps_new(hplayer, &info,
663 // "colordepth", G_TYPE_INT, info.colordepth, NULL);
667 __mmplayer_video_caps_new (hplayer, &video,
668 "stream-format", G_TYPE_STRING, "byte-stream",
669 "alignment", G_TYPE_STRING, "au",
670 "adaptive-streaming", G_TYPE_BOOLEAN, drc, NULL);
674 else if (strstr (info->mime, "video/x-wmv")) {
675 __mmplayer_video_caps_new (hplayer, &info,
676 "wmvversion", G_TYPE_INT, info.version, NULL);
677 } else if (strstr (info.mime, "video/x-pn-realvideo")) {
678 __mmplayer_video_caps_new (hplayer, &info,
679 "rmversion", G_TYPE_INT, info.version, NULL);
680 } else if (strstr (info.mime, "video/x-msmpeg")) {
681 __mmplayer_video_caps_new (hplayer, &info,
682 "msmpegversion", G_TYPE_INT, info.version, NULL);
683 } else if (strstr (info.mime, "video/x-h265")) {
684 if (info.colordepth) {
685 __mmplayer_video_caps_new (hplayer, &info,
686 "colordepth", G_TYPE_INT, info.colordepth, NULL);
688 __mmplayer_video_caps_new (hplayer, &info, NULL);
691 __mmplayer_video_caps_new (hplayer, &info, NULL);
694 g_free ((char *) video.mime);
698 return MM_ERROR_NONE;
702 _mmplayer_set_audio_info (MMHandleType hplayer, media_format_h format)
704 mm_player_t *player = MM_PLAYER_CAST (hplayer);
705 GstCaps *caps = NULL;
706 MMPlayerAudioStreamInfo audio = { 0, };
707 int ret = MM_ERROR_NONE;
711 MMPLAYER_RETURN_VAL_IF_FAIL (hplayer, MM_ERROR_PLAYER_NOT_INITIALIZED);
713 __mmplayer_set_uri_type(player);
715 ret = __parse_media_format (NULL, &audio, format);
716 if(ret != MM_ERROR_NONE)
719 audio.user_info = 0; //test
721 LOGD ("set audio player[%p] info [%p] version=%d rate=%d channel=%d",
722 player, audio, audio.version, audio.sample_rate, audio.channels);
724 if (strstr (audio.mime, "audio/mpeg")) {
725 if (audio.version == 1) { // mp3
726 caps = gst_caps_new_simple ("audio/mpeg",
727 "channels", G_TYPE_INT, audio.channels,
728 "rate", G_TYPE_INT, audio.sample_rate,
729 "mpegversion", G_TYPE_INT, audio.version,
730 "layer", G_TYPE_INT, audio.user_info, NULL);
732 gchar *format = NULL;
734 if (audio.user_info == 0)
735 format = g_strdup ("raw");
736 else if (audio.user_info == 1)
737 format = g_strdup ("adts");
738 else if (audio.user_info == 2)
739 format = g_strdup ("adif");
741 caps = gst_caps_new_simple ("audio/mpeg",
742 "channels", G_TYPE_INT, audio.channels,
743 "rate", G_TYPE_INT, audio.sample_rate,
744 "mpegversion", G_TYPE_INT, audio.version,
745 "stream-format", G_TYPE_STRING, format, NULL);
752 else if (strstr (audio.mime, "audio/x-raw-int")) {
753 caps = gst_caps_new_simple ("audio/x-raw-int",
754 "width", G_TYPE_INT, audio.width,
755 "depth", G_TYPE_INT, audio.depth,
756 "endianness", G_TYPE_INT, audio.endianness,
757 "signed", G_TYPE_BOOLEAN, audio.signedness,
758 "channels", G_TYPE_INT, audio.channels,
759 "rate", G_TYPE_INT, audio.sample_rate, NULL);
761 caps = gst_caps_new_simple (audio.mime,
762 "channels", G_TYPE_INT, audio.channels,
763 "rate", G_TYPE_INT, audio.sample_rate, NULL);
767 if (audio.extradata_size) {
768 GstBuffer *buf = NULL;
769 GstMapInfo buff_info = GST_MAP_INFO_INIT;
771 buf = gst_buffer_new_and_alloc (audio.extradata_size);
773 if (gst_buffer_map (buf, &buff_info, GST_MAP_READ)) {
774 memcpy (buff_info.data, audio.codec_extradata, audio.extradata_size);
775 gst_buffer_unmap (buf, &buff_info);
778 gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
779 gst_buffer_unref (buf);
782 g_free ((char *) audio.mime);
784 player->a_stream_caps = gst_caps_copy (caps);
785 gst_caps_unref (caps);
789 return MM_ERROR_NONE;
793 _mmplayer_set_subtitle_info (MMHandleType hplayer,
794 MMPlayerSubtitleStreamInfo * subtitle)
798 mm_player_t *player = MM_PLAYER_CAST (hplayer);
799 GstCaps *caps = NULL;
803 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
804 MMPLAYER_RETURN_VAL_IF_FAIL (info, MM_ERROR_PLAYER_NOT_INITIALIZED);
806 LOGD ("set subtitle player[%p] info [%p]", player, info);
809 caps = gst_caps_new_simple (info->mime, NULL, NULL); // TO CHECK
813 if (strstr (info->mime, "application/x-xsub")) {
814 gst_caps_set_simple (caps, "codec_tag", G_TYPE_UINT, info->codec_tag, NULL);
815 } else if (strstr (info->mime, "application/x-smpte-text")) {
817 gst_caps_set_simple (caps, "ttml_priv_data", G_TYPE_POINTER,
818 info->context, NULL);
822 player->s_stream_caps = gst_caps_copy (caps);
824 gst_caps_unref (caps);
829 return MM_ERROR_NONE;
833 _mmplayer_set_media_stream_dynamic_resolution(MMHandleType hplayer, bool drc)
835 mm_player_t *player = MM_PLAYER_CAST (hplayer);
836 int ret = MM_ERROR_NONE;
840 MMPLAYER_RETURN_VAL_IF_FAIL (player, MM_ERROR_PLAYER_NOT_INITIALIZED);
842 mm_attrs_set_int_by_name (player->attrs, MM_PLAYER_DRC_MODE, (int)drc);
843 if (player->v_stream_caps)
845 gst_caps_set_simple (player->v_stream_caps,
846 "adaptive-streaming", G_TYPE_BOOLEAN, drc, NULL);
847 MMPLAYER_LOG_GST_CAPS_TYPE (player->v_stream_caps);