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 ---------------------------------------------------------------------------*/
38 #define DEFAULT_FRAMERATE_NUM 30
39 #define DEFAULT_FRAMERATE_DEN 1
40 #define DEFAULT_VIDEO_FRAME_DURATION 33 /* ms */
42 /*---------------------------------------------------------------------------
43 | LOCAL FUNCTION PROTOTYPES: |
44 ---------------------------------------------------------------------------*/
45 static int __parse_media_format(MMPlayerVideoStreamInfo * video, MMPlayerAudioStreamInfo * audio, media_format_h format);
46 static int __convert_media_format_video_mime_to_str(MMPlayerVideoStreamInfo * video, media_format_mimetype_e mime);
47 static int __convert_media_format_audio_mime_to_str(MMPlayerAudioStreamInfo * audio, media_format_mimetype_e mime);
49 /*===========================================================================================
51 | FUNCTION DEFINITIONS |
53 ========================================================================================== */
56 __convert_media_format_video_mime_to_str(MMPlayerVideoStreamInfo * video,
57 media_format_mimetype_e mime)
59 MMPLAYER_RETURN_VAL_IF_FAIL(video, MM_ERROR_INVALID_ARGUMENT);
62 case MEDIA_FORMAT_MPEG4_SP:
63 video->mime = g_strdup("video/mpeg");
66 case MEDIA_FORMAT_H264_SP:
67 case MEDIA_FORMAT_H264_MP:
68 case MEDIA_FORMAT_H264_HP:
69 video->mime = g_strdup("video/x-h264");
72 video->mime = g_strdup("unknown");
80 __convert_media_format_audio_mime_to_str(MMPlayerAudioStreamInfo * audio,
81 media_format_mimetype_e mime)
83 MMPLAYER_RETURN_VAL_IF_FAIL(audio, MM_ERROR_INVALID_ARGUMENT);
86 case MEDIA_FORMAT_AAC:
87 audio->mime = g_strdup("audio/mpeg");
91 audio->mime = g_strdup("unknown");
99 __parse_media_format(MMPlayerVideoStreamInfo * video,
100 MMPlayerAudioStreamInfo * audio, media_format_h format)
103 media_format_mimetype_e mime;
108 if (media_format_get_audio_info(format, &mime, &channel, &samplerate, NULL,
109 &avg_bps) != MEDIA_FORMAT_ERROR_NONE) {
110 LOGE("media_format_get_audio_info failed");
111 return MM_ERROR_PLAYER_INTERNAL;
114 __convert_media_format_audio_mime_to_str(audio, mime);
115 audio->sample_rate = samplerate;
116 audio->channels = channel;
117 //video->user_info = ;
121 media_format_mimetype_e mime;
127 if (media_format_get_video_info(format, &mime, &width, &height, &avg_bps,
128 NULL) != MEDIA_FORMAT_ERROR_NONE) {
129 LOGE("media_format_get_video_info failed");
130 return MM_ERROR_PLAYER_INTERNAL;
133 if (media_format_get_video_frame_rate(format, &frame_rate))
134 LOGW("failed to get video frame rate, will be set 30.");
136 LOGD("frame_rate %d", frame_rate);
138 __convert_media_format_video_mime_to_str(video, mime);
140 video->width = width;
141 video->height = height;
142 video->framerate_num = (frame_rate > 0) ? (frame_rate) : (DEFAULT_FRAMERATE_NUM);
143 video->framerate_den = DEFAULT_FRAMERATE_DEN;
146 return MM_ERROR_NONE;
150 __mmplayer_update_video_info(MMHandleType hplayer, media_format_h fmt)
152 mm_player_t *player = (mm_player_t *) hplayer;
153 gboolean ret = FALSE;
154 GstStructure *str = NULL;
155 media_format_mimetype_e mimetype = 0;
156 gint cur_width = 0, width = 0;
157 gint cur_height = 0, height = 0;
161 MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
162 MMPLAYER_RETURN_VAL_IF_FAIL(fmt, FALSE);
164 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))
167 LOGD("missing 'width' field in video caps");
169 if (!gst_structure_get_int(str, "height", &cur_height))
170 LOGD("missing 'height' field in video caps");
172 media_format_get_video_info(fmt, &mimetype, &width, &height, NULL, NULL);
173 if ((cur_width != width) || (cur_height != height)) {
174 LOGW("resolution is changed %dx%d -> %dx%d",
175 cur_width, cur_height, width, height);
176 _mmplayer_set_video_info(hplayer, fmt);
187 _mmplayer_set_media_stream_buffer_status_cb(MMHandleType hplayer,
188 MMPlayerStreamType type,
189 mm_player_media_stream_buffer_status_callback callback,
192 mm_player_t *player = (mm_player_t *) hplayer;
196 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
198 if ((type < MM_PLAYER_STREAM_TYPE_DEFAULT) || (type > MM_PLAYER_STREAM_TYPE_TEXT))
199 return MM_ERROR_INVALID_ARGUMENT;
201 if (player->media_stream_buffer_status_cb[type]) {
203 LOGD("[type:%d] will be clear.\n", type);
205 LOGD("[type:%d] will be overwritten.\n", type);
208 player->media_stream_buffer_status_cb[type] = callback;
209 player->buffer_cb_user_param = user_param;
211 LOGD("player handle %p, type %d, callback %p\n", player, type,
212 player->media_stream_buffer_status_cb[type]);
216 return MM_ERROR_NONE;
220 _mmplayer_set_media_stream_seek_data_cb(MMHandleType hplayer,
221 MMPlayerStreamType type,
222 mm_player_media_stream_seek_data_callback callback,
225 mm_player_t *player = (mm_player_t *) hplayer;
229 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
231 if ((type < MM_PLAYER_STREAM_TYPE_DEFAULT) || (type > MM_PLAYER_STREAM_TYPE_TEXT))
232 return MM_ERROR_INVALID_ARGUMENT;
234 if (player->media_stream_seek_data_cb[type]) {
236 LOGD("[type:%d] will be clear.\n", type);
238 LOGD("[type:%d] will be overwritten.\n", type);
241 player->media_stream_seek_data_cb[type] = callback;
242 player->buffer_cb_user_param = user_param;
244 LOGD("player handle %p, type %d, callback %p\n", player, type,
245 player->media_stream_seek_data_cb[type]);
249 return MM_ERROR_NONE;
253 __mmplayer_get_source_element(mm_player_t *player, MMPlayerStreamType type)
255 enum MainElementID elemId = MMPLAYER_M_NUM;
257 if (player && player->pipeline && player->pipeline->mainbin) {
258 /* get elem according to the stream type */
259 if (type == MM_PLAYER_STREAM_TYPE_AUDIO) {
260 if (player->pipeline->mainbin[MMPLAYER_M_2ND_SRC].gst)
261 elemId = MMPLAYER_M_2ND_SRC;
262 else if (g_strrstr(GST_ELEMENT_NAME(player->pipeline->mainbin[MMPLAYER_M_SRC].gst), "audio_appsrc"))
263 elemId = MMPLAYER_M_SRC;
264 } else if (type == MM_PLAYER_STREAM_TYPE_VIDEO) {
265 elemId = MMPLAYER_M_SRC;
266 } else if (type == MM_PLAYER_STREAM_TYPE_TEXT) {
267 elemId = MMPLAYER_M_SUBSRC;
270 if (elemId != MMPLAYER_M_NUM)
271 return player->pipeline->mainbin[elemId].gst;
278 _mmplayer_set_media_stream_max_size(MMHandleType hplayer, MMPlayerStreamType type, guint64 max_size)
280 mm_player_t *player = (mm_player_t *) hplayer;
281 GstElement *element = NULL;
284 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
286 if ((type < MM_PLAYER_STREAM_TYPE_AUDIO) ||
287 (type > MM_PLAYER_STREAM_TYPE_TEXT) ||
289 LOGE("Invalid param type:%d, max_size:%d", type, max_size);
290 return MM_ERROR_INVALID_ARGUMENT;
293 LOGD("type %d, max_size %llu\n", type, max_size);
295 if ((element = __mmplayer_get_source_element(player, type))) {
296 LOGD("update max_size of %s\n", GST_ELEMENT_NAME(element));
297 g_object_set(G_OBJECT(element), "max-bytes", max_size, NULL);
300 player->media_stream_buffer_max_size[type] = max_size;
303 return MM_ERROR_NONE;
307 _mmplayer_get_media_stream_max_size(MMHandleType hplayer, MMPlayerStreamType type, guint64 *max_size)
309 mm_player_t *player = (mm_player_t *) hplayer;
313 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
314 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
316 if ((type < MM_PLAYER_STREAM_TYPE_DEFAULT) || (type > MM_PLAYER_STREAM_TYPE_TEXT))
317 return MM_ERROR_INVALID_ARGUMENT;
319 *max_size = player->media_stream_buffer_max_size[type];
323 return MM_ERROR_NONE;
327 _mmplayer_set_media_stream_min_percent(MMHandleType hplayer, MMPlayerStreamType type, guint min_percent)
329 mm_player_t *player = (mm_player_t *) hplayer;
330 GstElement *element = NULL;
334 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
336 if ((type < MM_PLAYER_STREAM_TYPE_AUDIO) || (type > MM_PLAYER_STREAM_TYPE_TEXT)) {
337 LOGE("Invalid param type:%d", type);
338 return MM_ERROR_INVALID_ARGUMENT;
341 LOGD("type %d, min_per %u\n", type, min_percent);
343 if ((element = __mmplayer_get_source_element(player, type))) {
344 LOGD("update min_per of %s\n", GST_ELEMENT_NAME(element));
345 g_object_set(G_OBJECT(element), "min-percent", min_percent, NULL);
348 player->media_stream_buffer_min_percent[type] = min_percent;
351 return MM_ERROR_NONE;
355 _mmplayer_get_media_stream_min_percent(MMHandleType hplayer, MMPlayerStreamType type, guint *min_percent)
357 mm_player_t *player = (mm_player_t *) hplayer;
361 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
362 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
364 if ((type < MM_PLAYER_STREAM_TYPE_DEFAULT) || (type > MM_PLAYER_STREAM_TYPE_TEXT))
365 return MM_ERROR_INVALID_ARGUMENT;
367 *min_percent = player->media_stream_buffer_min_percent[type];
371 return MM_ERROR_NONE;
375 __mmplayer_check_buffer_level(mm_player_t *player, GstElement* element, MMPlayerStreamType type)
377 guint64 current_level_bytes = 0;
378 guint64 max_bytes = 0;
379 guint current_level_per = 0;
382 MMPLAYER_RETURN_VAL_IF_FAIL(player && element, MM_ERROR_PLAYER_NOT_INITIALIZED);
384 if (player->media_stream_buffer_max_size[type] > 0)
385 max_bytes = player->media_stream_buffer_max_size[type];
387 g_object_get(G_OBJECT(element), "max-bytes", &max_bytes, NULL);
389 if (max_bytes == 0) {
390 LOGW("buffer max size is zero.");
391 return MM_ERROR_NONE;
394 g_object_get(G_OBJECT(element), "current-level-bytes", ¤t_level_bytes, NULL);
396 if (max_bytes <= current_level_bytes) {
397 LOGE("no available buffer space. type %d, max %lld, curr %lld", type, max_bytes, current_level_bytes);
398 return MM_ERROR_PLAYER_BUFFER_SPACE;
401 if (MMPLAYER_CURRENT_STATE(player) != MM_PLAYER_STATE_PLAYING) {
402 if (!player->media_stream_buffer_status_cb[type])
403 return MM_ERROR_NONE;
405 current_level_per = (guint)(gst_util_guint64_to_gdouble(current_level_bytes)/gst_util_guint64_to_gdouble(max_bytes)*100);
407 LOGD("type %d, min_per %u, curr_per %u max %lld cur %lld\n",
408 type, player->media_stream_buffer_min_percent[type],
410 player->media_stream_buffer_max_size[type],
411 current_level_bytes);
413 if (current_level_per < player->media_stream_buffer_min_percent[type])
414 player->media_stream_buffer_status_cb[type](type, MM_PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN, current_level_bytes, player->buffer_cb_user_param);
418 return MM_ERROR_NONE;
422 _mmplayer_submit_packet(MMHandleType hplayer, media_packet_h packet)
424 int ret = MM_ERROR_NONE;
425 GstBuffer *_buffer = NULL;
426 mm_player_t *player = (mm_player_t *) hplayer;
429 GstElement* element = NULL;
430 MMPlayerStreamType streamtype = MM_PLAYER_STREAM_TYPE_AUDIO;
431 media_format_h fmt = NULL;
435 MMPLAYER_RETURN_VAL_IF_FAIL(packet, MM_ERROR_INVALID_ARGUMENT);
436 MMPLAYER_RETURN_VAL_IF_FAIL(player &&
438 player->pipeline->mainbin &&
439 player->pipeline->mainbin[MMPLAYER_M_SRC].gst,
440 MM_ERROR_PLAYER_INTERNAL);
442 /* get stream type if audio or video */
443 media_packet_is_audio(packet, &flag);
445 streamtype = MM_PLAYER_STREAM_TYPE_AUDIO;
447 media_packet_is_video(packet, &flag);
449 streamtype = MM_PLAYER_STREAM_TYPE_VIDEO;
451 streamtype = MM_PLAYER_STREAM_TYPE_TEXT;
454 element = __mmplayer_get_source_element(player, streamtype);
456 LOGE("there is no source element of type %d", streamtype);
457 ret = MM_ERROR_PLAYER_INTERNAL;
461 /* check buffer level */
462 ret = __mmplayer_check_buffer_level(player, element, streamtype);
463 if (ret != MM_ERROR_NONE)
467 if (media_packet_get_buffer_data_ptr(packet, (void **) &buf) != MEDIA_PACKET_ERROR_NONE) {
468 LOGE("failed to get buffer data ptr");
469 ret = MM_ERROR_PLAYER_INTERNAL;
473 if (media_packet_get_buffer_size(packet, &size) != MEDIA_PACKET_ERROR_NONE) {
474 LOGE("failed to get buffer size");
475 ret = MM_ERROR_PLAYER_INTERNAL;
479 if (buf != NULL && size > 0) {
480 GstMapInfo buff_info = GST_MAP_INFO_INIT;
482 uint64_t duration = 0;
485 _buffer = gst_buffer_new_and_alloc(size);
488 LOGE("failed to allocate memory for push buffer\n");
489 ret = MM_ERROR_PLAYER_NO_FREE_SPACE;
493 if (gst_buffer_map(_buffer, &buff_info, GST_MAP_READWRITE)) {
494 memcpy(buff_info.data, buf, size);
495 buff_info.size = size;
497 gst_buffer_unmap(_buffer, &buff_info);
500 if (streamtype == MM_PLAYER_STREAM_TYPE_VIDEO) {
501 /* get format to check video format */
502 media_packet_get_format(packet, &fmt);
504 if (__mmplayer_update_video_info(hplayer, fmt)) {
505 LOGD("update video caps");
506 g_object_set(G_OBJECT(player->pipeline->mainbin[MMPLAYER_M_SRC].gst),
507 "caps", player->v_stream_caps, NULL);
509 media_format_unref(fmt);
513 if (media_packet_get_duration(packet, &duration) != MEDIA_PACKET_ERROR_NONE) {
514 LOGW("failed to get duration info");
515 /* keep push without error handling */
519 duration = DEFAULT_VIDEO_FRAME_DURATION * GST_MSECOND;
522 GST_BUFFER_DURATION(_buffer) = (GstClockTime)duration;
526 if (media_packet_get_pts(packet, &pts) != MEDIA_PACKET_ERROR_NONE) {
527 LOGE("failed to get pts info");
528 ret = MM_ERROR_PLAYER_INTERNAL;
531 GST_BUFFER_PTS(_buffer) = (GstClockTime)pts;
532 gst_app_src_push_buffer(GST_APP_SRC(element), _buffer);
536 if (media_packet_is_end_of_stream(packet, &is_eos) != MEDIA_PACKET_ERROR_NONE) {
537 LOGE("failed to get eos info");
538 ret = MM_ERROR_PLAYER_INTERNAL;
543 LOGW("we got eos of stream type(%d)", streamtype);
544 g_signal_emit_by_name(element, "end-of-stream", &ret);
552 __mmplayer_video_caps_new(MMHandleType hplayer, MMPlayerVideoStreamInfo * video,
553 const char *fieldname, ...)
556 GstCaps *caps = NULL;
557 GstStructure *structure = NULL;
559 mm_player_t *player = MM_PLAYER_CAST(hplayer);
562 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
563 MMPLAYER_RETURN_VAL_IF_FAIL(video, MM_ERROR_PLAYER_NOT_INITIALIZED);
565 LOGD("width=%d height=%d framerate num=%d, den=%d",
566 video->width, video->height, video->framerate_num, video->framerate_den);
568 caps = gst_caps_new_simple(video->mime,
569 "width", G_TYPE_INT, video->width,
570 "height", G_TYPE_INT, video->height,
571 "framerate", GST_TYPE_FRACTION, video->framerate_num, video->framerate_den, NULL);
573 for (cap_size = 0; cap_size < gst_caps_get_size(caps); cap_size++) {
574 va_start(var_args, fieldname);
575 structure = gst_caps_get_structure(caps, cap_size);
576 gst_structure_set_valist(structure, fieldname, var_args);
580 if (video->extradata_size) {
581 GstBuffer *buf = NULL;
582 GstMapInfo buff_info = GST_MAP_INFO_INIT;
584 buf = gst_buffer_new_and_alloc(video->extradata_size);
586 if (gst_buffer_map(buf, &buff_info, GST_MAP_READ)) {
587 memcpy(buff_info.data, video->codec_extradata, video->extradata_size);
588 buff_info.size = video->extradata_size;
589 gst_buffer_unmap(buf, &buff_info);
592 gst_caps_set_simple(caps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
593 gst_buffer_unref(buf);
596 if (player->v_stream_caps) {
597 LOGW("caps will be updated ");
599 gst_caps_unref(player->v_stream_caps);
600 player->v_stream_caps = NULL;
603 player->v_stream_caps = gst_caps_copy(caps);
604 MMPLAYER_LOG_GST_CAPS_TYPE(player->v_stream_caps);
605 gst_caps_unref(caps);
609 return MM_ERROR_NONE;
613 __mmplayer_set_uri_type(mm_player_t *player)
617 player->profile.uri_type = MM_PLAYER_URI_TYPE_MS_BUFF;
618 player->es_player_push_mode = TRUE;
625 _mmplayer_set_video_info(MMHandleType hplayer, media_format_h format)
627 mm_player_t *player = MM_PLAYER_CAST(hplayer);
628 MMPlayerVideoStreamInfo video = { 0, };
629 int ret = MM_ERROR_NONE;
630 gboolean drc = FALSE;
634 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
636 __mmplayer_set_uri_type(player);
638 ret = __parse_media_format(&video, NULL, format);
639 if (ret != MM_ERROR_NONE)
642 mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_DRC_MODE, &drc);
644 if (strstr(video.mime, "video/mpeg")) {
645 __mmplayer_video_caps_new(hplayer, &video,
646 "mpegversion", G_TYPE_INT, video.version,
647 "systemstream", G_TYPE_BOOLEAN, FALSE,
648 "adaptive-streaming", G_TYPE_BOOLEAN, drc, NULL);
649 } else if (strstr(video.mime, "video/x-h264")) {
651 if (info.colordepth) {
652 __mmplayer_video_caps_new(hplayer, &info,
653 "colordepth", G_TYPE_INT, info.colordepth, NULL);
657 __mmplayer_video_caps_new(hplayer, &video,
658 "stream-format", G_TYPE_STRING, "byte-stream",
659 "alignment", G_TYPE_STRING, "au",
660 "adaptive-streaming", G_TYPE_BOOLEAN, drc, NULL);
664 else if (strstr(info->mime, "video/x-wmv")) {
665 __mmplayer_video_caps_new(hplayer, &info,
666 "wmvversion", G_TYPE_INT, info.version, NULL);
667 } else if (strstr(info.mime, "video/x-pn-realvideo")) {
668 __mmplayer_video_caps_new(hplayer, &info,
669 "rmversion", G_TYPE_INT, info.version, NULL);
670 } else if (strstr(info.mime, "video/x-msmpeg")) {
671 __mmplayer_video_caps_new(hplayer, &info,
672 "msmpegversion", G_TYPE_INT, info.version, NULL);
673 } else if (strstr(info.mime, "video/x-h265")) {
675 __mmplayer_video_caps_new(hplayer, &info,
676 "colordepth", G_TYPE_INT, info.colordepth, NULL);
678 __mmplayer_video_caps_new(hplayer, &info, NULL);
680 __mmplayer_video_caps_new(hplayer, &info, NULL);
682 g_free((char *) video.mime);
686 return MM_ERROR_NONE;
690 _mmplayer_set_audio_info(MMHandleType hplayer, media_format_h format)
692 mm_player_t *player = MM_PLAYER_CAST(hplayer);
693 GstCaps *caps = NULL;
694 MMPlayerAudioStreamInfo audio = { 0, };
695 int ret = MM_ERROR_NONE;
699 MMPLAYER_RETURN_VAL_IF_FAIL(hplayer, MM_ERROR_PLAYER_NOT_INITIALIZED);
701 __mmplayer_set_uri_type(player);
703 ret = __parse_media_format(NULL, &audio, format);
704 if (ret != MM_ERROR_NONE)
707 audio.user_info = 0; //test
709 LOGD("set audio player[%p] info [%p] version=%d rate=%d channel=%d",
710 player, audio, audio.version, audio.sample_rate, audio.channels);
712 if (strstr(audio.mime, "audio/mpeg")) {
713 if (audio.version == 1) { // mp3
714 caps = gst_caps_new_simple("audio/mpeg",
715 "channels", G_TYPE_INT, audio.channels,
716 "rate", G_TYPE_INT, audio.sample_rate,
717 "mpegversion", G_TYPE_INT, audio.version,
718 "layer", G_TYPE_INT, audio.user_info, NULL);
720 gchar *format = NULL;
722 if (audio.user_info == 0)
723 format = g_strdup("raw");
724 else if (audio.user_info == 1)
725 format = g_strdup("adts");
726 else if (audio.user_info == 2)
727 format = g_strdup("adif");
729 caps = gst_caps_new_simple("audio/mpeg",
730 "channels", G_TYPE_INT, audio.channels,
731 "rate", G_TYPE_INT, audio.sample_rate,
732 "mpegversion", G_TYPE_INT, audio.version,
733 "stream-format", G_TYPE_STRING, format, NULL);
740 else if (strstr(audio.mime, "audio/x-raw-int")) {
741 caps = gst_caps_new_simple("audio/x-raw-int",
742 "width", G_TYPE_INT, audio.width,
743 "depth", G_TYPE_INT, audio.depth,
744 "endianness", G_TYPE_INT, audio.endianness,
745 "signed", G_TYPE_BOOLEAN, audio.signedness,
746 "channels", G_TYPE_INT, audio.channels,
747 "rate", G_TYPE_INT, audio.sample_rate, NULL);
749 caps = gst_caps_new_simple(audio.mime,
750 "channels", G_TYPE_INT, audio.channels,
751 "rate", G_TYPE_INT, audio.sample_rate, NULL);
755 if (audio.extradata_size) {
756 GstBuffer *buf = NULL;
757 GstMapInfo buff_info = GST_MAP_INFO_INIT;
759 buf = gst_buffer_new_and_alloc(audio.extradata_size);
761 if (gst_buffer_map(buf, &buff_info, GST_MAP_READ)) {
762 memcpy(buff_info.data, audio.codec_extradata, audio.extradata_size);
763 gst_buffer_unmap(buf, &buff_info);
766 gst_caps_set_simple(caps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
767 gst_buffer_unref(buf);
770 g_free((char *) audio.mime);
772 player->a_stream_caps = gst_caps_copy(caps);
773 gst_caps_unref(caps);
777 return MM_ERROR_NONE;
781 _mmplayer_set_subtitle_info(MMHandleType hplayer,
782 MMPlayerSubtitleStreamInfo * subtitle)
785 mm_player_t *player = MM_PLAYER_CAST(hplayer);
786 GstCaps *caps = NULL;
790 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
791 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_PLAYER_NOT_INITIALIZED);
793 LOGD("set subtitle player[%p] info [%p]", player, info);
796 caps = gst_caps_new_simple(info->mime, NULL, NULL); // TO CHECK
800 if (strstr(info->mime, "application/x-xsub")) {
801 gst_caps_set_simple(caps, "codec_tag", G_TYPE_UINT, info->codec_tag, NULL);
802 } else if (strstr(info->mime, "application/x-smpte-text")) {
804 gst_caps_set_simple(caps, "ttml_priv_data", G_TYPE_POINTER,
805 info->context, NULL);
809 player->s_stream_caps = gst_caps_copy(caps);
811 gst_caps_unref(caps);
816 return MM_ERROR_NONE;
820 _mmplayer_set_media_stream_dynamic_resolution(MMHandleType hplayer, bool drc)
822 mm_player_t *player = MM_PLAYER_CAST(hplayer);
823 int ret = MM_ERROR_NONE;
827 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
829 mm_attrs_set_int_by_name(player->attrs, MM_PLAYER_DRC_MODE, (int)drc);
830 if (player->v_stream_caps) {
831 gst_caps_set_simple(player->v_stream_caps,
832 "adaptive-streaming", G_TYPE_BOOLEAN, drc, NULL);
833 MMPLAYER_LOG_GST_CAPS_TYPE(player->v_stream_caps);