bool rich_audio;
bool video_zc; // video zero-copy
bool subtitle_off;
- bool media_packet_video_stream;
+ bool video_export;
} mmplayer_setting_mode_t; /* FIXME: renaming */
typedef struct {
void *pcm_data;
int data_size;
int buff_size;
+ media_format_mimetype_e pcm_format;
} mmplayer_audio_stream_buff_t;
/**
void *audio_stream_changed_cb_user_param;
/* video stream callback */
- mm_player_video_stream_callback video_stream_cb;
- void *video_stream_cb_user_param;
+ mm_player_video_decoded_callback video_decoded_cb;
+ void *video_decoded_cb_user_param;
GCond video_bo_cond;
GMutex video_bo_mutex;
GList *video_bo_list; /* mmplayer_video_bo_info_t, bo list for decoded video data by sw codec */
bool video_stream_prerolled;
/* audio stream callback */
- mm_player_audio_stream_callback audio_stream_render_cb;
- void *audio_stream_cb_user_param;
- bool audio_stream_sink_sync;
+ mm_player_audio_decoded_callback audio_decoded_cb;
+ void *audio_decoded_cb_user_param;
GList *audio_stream_buff_list; /* mmplayer_audio_stream_buff_t, buff list of extract pcm data */
+ mmplayer_audio_extract_opt_e audio_extract_opt;
/* video capture callback*/
gulong video_capture_cb_probe_id;
int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
int _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
int _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
-int _mmplayer_set_videostream_cb(MMHandleType hplayer, mm_player_video_stream_callback callback, void *user_param);
+int _mmplayer_set_video_decoded_cb(MMHandleType hplayer, mm_player_video_decoded_callback callback, void *user_param);
int _mmplayer_set_subtitle_silent(MMHandleType hplayer, int silent);
int _mmplayer_get_subtitle_silent(MMHandleType hplayer, int *silent);
int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char *filepath);
int _mmplayer_update_video_param(mmplayer_t *player, char *param_name);
int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay);
int _mmplayer_audio_effect_custom_apply(mmplayer_t *player);
-int _mmplayer_set_audiostream_cb(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback callback, void *user_param);
+int _mmplayer_set_audio_decoded_cb(MMHandleType hplayer, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param);
int _mmplayer_change_track_language(MMHandleType hplayer, mmplayer_track_type_e type, int index);
int _mmplayer_sync_subtitle_pipeline(mmplayer_t *player);
int _mmplayer_use_system_clock(MMHandleType hplayer);
#define FAKE_SINK_MAX_LATENESS G_GINT64_CONSTANT(20000000) /* set 20ms as waylandsink */
+#define DEFAULT_PCM_OUT_FORMAT "F32LE"
+#define DEFAULT_PCM_OUT_SAMPLERATE 44100
+#define DEFAULT_PCM_OUT_CHANNEL 2
+
/*---------------------------------------------------------------------------
| LOCAL CONSTANT DEFINITIONS: |
---------------------------------------------------------------------------*/
/* in case of exporting video frame, it requires the 360 video filter.
* it will be handled in _no_more_pads(). */
- if ((stype == MM_DISPLAY_SURFACE_NULL) && (!player->set_mode.media_packet_video_stream)) {
+ if ((stype == MM_DISPLAY_SURFACE_NULL) && (!player->set_mode.video_export)) {
__mmplayer_gst_make_fakesink(player, pad, name);
goto DONE;
}
/* LOGD("detected mimetype : %s", name); */
if (strstr(name, "audio")) {
if (player->pipeline->audiobin == NULL) {
+ const gchar *audio_format = gst_structure_get_string(str, "format");
+ if (audio_format) {
+ LOGD("original audio format %s", audio_format);
+ mm_attrs_set_string_by_name(player->attrs, "content_audio_format", audio_format);
+ }
+
if (__mmplayer_gst_create_audio_sink_bin(player) != MM_ERROR_NONE) {
LOGE("failed to create audiobin. continuing without audio");
goto ERROR;
mmplayer_audio_decoded_data_info_t audio_stream = { 0, };
MMPLAYER_FENTER();
- MMPLAYER_RETURN_IF_FAIL(player && player->audio_stream_render_cb);
+ MMPLAYER_RETURN_IF_FAIL(player && player->audio_decoded_cb);
audio_stream.bitrate = a_buffer->bitrate;
audio_stream.channel = a_buffer->channel;
audio_stream.data_size = a_buffer->data_size;
audio_stream.data = a_buffer->pcm_data;
- /* LOGD("[%"G_GUINT64_FORMAT"] send data size:%d, %p", audio_stream.channel_mask, audio_stream.data_size, player->audio_stream_cb_user_param); */
- player->audio_stream_render_cb(&audio_stream, player->audio_stream_cb_user_param);
+ /* LOGD("[%"G_GUINT64_FORMAT"] send data size:%d, %p", audio_stream.channel_mask, audio_stream.data_size, player->audio_decoded_cb_user_param); */
+ player->audio_decoded_cb(&audio_stream, player->audio_decoded_cb_user_param);
MMPLAYER_FLEAVE();
}
__mmplayer_audio_stream_decoded_render_cb(GstElement *object, GstBuffer *buffer, GstPad *pad, gpointer data)
{
mmplayer_t *player = (mmplayer_t *)data;
+ const gchar *pcm_format = NULL;
gint channel = 0;
gint rate = 0;
gint depth = 0;
GList *l = NULL;
MMPLAYER_FENTER();
- MMPLAYER_RETURN_IF_FAIL(player && player->audio_stream_render_cb);
+ MMPLAYER_RETURN_IF_FAIL(player && player->audio_decoded_cb);
gst_buffer_map(buffer, &mapinfo, GST_MAP_READ);
a_data = mapinfo.data;
GstStructure *structure = gst_caps_get_structure(caps, 0);
/* MMPLAYER_LOG_GST_CAPS_TYPE(caps); */
+ pcm_format = gst_structure_get_string(structure, "format");
gst_structure_get_int(structure, "rate", &rate);
gst_structure_get_int(structure, "channels", &channel);
gst_structure_get_int(structure, "depth", &depth);
a_buffer->is_little_endian = (endianness == 1234 ? true : false);
a_buffer->channel_mask = channel_mask;
a_buffer->data_size = a_size;
+ a_buffer->pcm_format = util_convert_audio_pcm_str_to_media_format_mime(pcm_format);
- if (!player->audio_stream_sink_sync) {
+ if (player->audio_extract_opt & MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK) {
/* If sync is FALSE, use buffer list to reduce the IPC. */
a_buffer->buff_size = (a_size > player->ini.pcm_buffer_size) ? (a_size) : (player->ini.pcm_buffer_size);
a_buffer->pcm_data = g_try_malloc(a_buffer->buff_size);
goto ERROR;
}
- LOGE("player->audio_stream_sink_sync: %d", player->audio_stream_sink_sync);
+ LOGE("audio_extract_opt : 0x%X", player->audio_extract_opt);
gst_object_unref(sinkpad);
- g_object_set(sink, "sync", player->audio_stream_sink_sync, NULL);
+ if (!(player->audio_extract_opt & MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK))
+ g_object_set(sink, "sync", TRUE, NULL);
g_object_set(sink, "signal-handoffs", TRUE, NULL);
gst_element_set_state(sink, GST_STATE_PAUSED);
/* resampler */
MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_RESAMPLER, player->ini.audioresampler_element, "audio resampler", TRUE, player);
- if (player->audio_stream_render_cb) { /* pcm extraction only, no sound output */
+ if (player->audio_decoded_cb) { /* pcm extraction only, no sound output */
gchar *dst_format = NULL;
int dst_len = 0;
int dst_samplerate = 0;
"pcm_extraction_channels", &dst_channels,
NULL);
- LOGD("pcm info - format: %s(%d), samplerate : %d, channel: %d", dst_format, dst_len, dst_samplerate, dst_channels);
+ LOGD("required pcm format - format: %s(%d), samplerate : %d, channel: %d", dst_format, dst_len, dst_samplerate, dst_channels);
+ if (dst_format == NULL || dst_len == 0 || dst_samplerate == 0 || dst_channels == 0) {
+ mm_attrs_multiple_get(player->attrs, NULL,
+ "content_audio_format", &dst_format, &dst_len, /* get string and len */
+ "content_audio_samplerate", &dst_samplerate,
+ "content_audio_channels", &dst_channels,
+ NULL);
+
+ LOGD("decoded pcm format - format: %s(%d), samplerate : %d, channel: %d", dst_format, dst_len, dst_samplerate, dst_channels);
+
+ /* If there is no enough information, set it to platform default value. */
+ if (dst_format == NULL || util_convert_audio_pcm_str_to_media_format_mime(dst_format) == MEDIA_FORMAT_MAX) {
+ LOGD("set platform default format");
+ dst_format = DEFAULT_PCM_OUT_FORMAT;
+ }
+ if (dst_samplerate <= 0) dst_samplerate = DEFAULT_PCM_OUT_SAMPLERATE;
+ if (dst_channels <= 0) dst_channels = DEFAULT_PCM_OUT_CHANNEL;
+ }
/* capsfilter */
MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CAPS_DEFAULT, "capsfilter", "audio capsfilter", TRUE, player);
gst_caps_unref(caps);
MMPLAYER_FREEIF(caps_str);
- MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_DEINTERLEAVE, "deinterleave", "deinterleave", TRUE, player);
-
- g_object_set(G_OBJECT(audiobin[MMPLAYER_A_DEINTERLEAVE].gst), "keep-positions", TRUE, NULL);
+ if (player->audio_extract_opt & MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE) {
+ MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_DEINTERLEAVE, "deinterleave", "deinterleave", TRUE, player);
- /* raw pad handling signal, audiosink will be added after getting signal */
- __mmplayer_add_signal_connection(player, G_OBJECT(audiobin[MMPLAYER_A_DEINTERLEAVE].gst),
- MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "pad-added", G_CALLBACK(__mmplayer_gst_audio_deinterleave_pad_added), (gpointer)player);
+ g_object_set(G_OBJECT(audiobin[MMPLAYER_A_DEINTERLEAVE].gst), "keep-positions", TRUE, NULL);
+ /* raw pad handling signal, audiosink will be added after getting signal */
+ __mmplayer_add_signal_connection(player, G_OBJECT(audiobin[MMPLAYER_A_DEINTERLEAVE].gst),
+ MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "pad-added", G_CALLBACK(__mmplayer_gst_audio_deinterleave_pad_added), (gpointer)player);
+ } else {
+ MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_SINK, "fakesink", "audiosink", TRUE, player);
+ if (!(player->audio_extract_opt & MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK))
+ g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "sync", TRUE, NULL);
+ g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "signal-handoffs", TRUE, NULL);
+
+ __mmplayer_add_signal_connection(player,
+ G_OBJECT(audiobin[MMPLAYER_A_SINK].gst),
+ MM_PLAYER_SIGNAL_TYPE_AUDIOBIN,
+ "handoff",
+ G_CALLBACK(__mmplayer_audio_stream_decoded_render_cb),
+ (gpointer)player);
+ }
} else {
-
/* normal playback */
gint channels = 0;
{
mmplayer_t *player = (mmplayer_t *)data;
MMPLAYER_FENTER();
- MMPLAYER_RETURN_IF_FAIL(player && player->video_stream_cb);
+ MMPLAYER_RETURN_IF_FAIL(player && player->video_decoded_cb);
/* send prerolled pkt */
player->video_stream_prerolled = false;
MMPLAYER_FENTER();
MMPLAYER_RETURN_IF_FAIL(player);
- MMPLAYER_RETURN_IF_FAIL(player->video_stream_cb);
+ MMPLAYER_RETURN_IF_FAIL(player->video_decoded_cb);
if (player->video_stream_prerolled) {
player->video_stream_prerolled = false;
/* check zero-copy */
if (player->set_mode.video_zc &&
- player->set_mode.media_packet_video_stream &&
+ player->set_mode.video_export &&
gst_is_tizen_memory(mem)) {
__mmplayer_zerocopy_set_stride_elevation_bo(stream, mem);
stream->internal_buffer = gst_buffer_ref(buffer);
goto ERROR;
}
- if (!player->video_stream_cb(stream, player->video_stream_cb_user_param)) {
- LOGE("failed to send video stream data.");
+ if (!player->video_decoded_cb(stream, player->video_decoded_cb_user_param)) {
+ LOGE("failed to send video decoded data.");
goto ERROR;
}
g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
}
- if (player->set_mode.media_packet_video_stream) {
+ if (player->set_mode.video_export) {
int enable = 0;
mm_attrs_get_int_by_name(player->attrs, "enable_video_decoded_cb", &enable);
if (enable || (surface_type == MM_DISPLAY_SURFACE_REMOTE) || (surface_type == MM_DISPLAY_SURFACE_NULL))
goto FAILED;
}
- if (player->audio_stream_render_cb) {
+ if (player->audio_decoded_cb) {
LOGW("not support in pcm extraction mode");
goto FAILED;
}
}
int
-_mmplayer_set_audiostream_cb(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback callback, void *user_param)
+_mmplayer_set_audio_decoded_cb(MMHandleType hplayer, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param)
{
mmplayer_t *player = (mmplayer_t *)hplayer;
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
- player->audio_stream_render_cb = callback;
- player->audio_stream_cb_user_param = user_param;
- player->audio_stream_sink_sync = sync;
- LOGD("handle: %p, cb: %p, sync: %d", player, player->audio_stream_render_cb, player->audio_stream_sink_sync);
+ player->audio_decoded_cb = callback;
+ player->audio_decoded_cb_user_param = user_param;
+ player->audio_extract_opt = opt;
+ LOGD("handle: %p, cb: %p, opt: 0x%X", player, player->audio_decoded_cb, player->audio_extract_opt);
MMPLAYER_FLEAVE();
}
int
-_mmplayer_set_videostream_cb(MMHandleType hplayer, mm_player_video_stream_callback callback, void *user_param)
+_mmplayer_set_video_decoded_cb(MMHandleType hplayer, mm_player_video_decoded_callback callback, void *user_param)
{
mmplayer_t *player = (mmplayer_t *)hplayer;
if (callback && !player->bufmgr)
player->bufmgr = tbm_bufmgr_init(-1);
- player->set_mode.media_packet_video_stream = (callback) ? true : false;
- player->video_stream_cb = callback;
- player->video_stream_cb_user_param = user_param;
+ player->set_mode.video_export = (callback) ? true : false;
+ player->video_decoded_cb = callback;
+ player->video_decoded_cb_user_param = user_param;
- LOGD("Stream cb Handle value is %p : %p, enable:%d", player, player->video_stream_cb, player->set_mode.media_packet_video_stream);
+ LOGD("Stream cb Handle value is %p : %p, enable:%d", player, player->video_decoded_cb, player->set_mode.video_export);
MMPLAYER_FLEAVE();
/* don't make video because of not required */
if ((stype == MM_DISPLAY_SURFACE_NULL) &&
- (!player->set_mode.media_packet_video_stream)) {
+ (!player->set_mode.video_export)) {
LOGD("no need video decoding, expose pad");
result = GST_AUTOPLUG_SELECT_EXPOSE;
goto DONE;
MMPLAYER_RETURN_IF_FAIL(player);
- player->video_stream_cb = NULL;
- player->video_stream_cb_user_param = NULL;
+ player->video_decoded_cb = NULL;
+ player->video_decoded_cb_user_param = NULL;
player->video_stream_prerolled = false;
- player->audio_stream_render_cb = NULL;
- player->audio_stream_cb_user_param = NULL;
- player->audio_stream_sink_sync = false;
+ player->audio_decoded_cb = NULL;
+ player->audio_decoded_cb_user_param = NULL;
+ player->audio_extract_opt = MM_PLAYER_AUDIO_EXTRACT_DEFAULT;
player->video_stream_changed_cb = NULL;
player->video_stream_changed_cb_user_param = NULL;
player->play_subtitle = FALSE;
player->adjust_subtitle_pos = 0;
player->has_closed_caption = FALSE;
- player->set_mode.media_packet_video_stream = false;
+ player->set_mode.video_export = false;
player->profile.uri_type = MM_PLAYER_URI_TYPE_NONE;
memset(&player->set_mode, 0, sizeof(mmplayer_setting_mode_t));
/* recover mode */