MMPlayerAudioStreamDataType audio_stream = { 0, };
MMPLAYER_FENTER();
- MMPLAYER_RETURN_IF_FAIL(player && player->audio_stream_render_cb_ex);
+ MMPLAYER_RETURN_IF_FAIL(player && player->audio_stream_render_cb);
audio_stream.bitrate = a_buffer->bitrate;
audio_stream.channel = a_buffer->channel;
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_ex(&audio_stream, player->audio_stream_cb_user_param);
+ player->audio_stream_render_cb(&audio_stream, player->audio_stream_cb_user_param);
MMPLAYER_FLEAVE();
}
GList *l = NULL;
MMPLAYER_FENTER();
- MMPLAYER_RETURN_IF_FAIL(player && player->audio_stream_render_cb_ex);
+ MMPLAYER_RETURN_IF_FAIL(player && player->audio_stream_render_cb);
gst_buffer_map(buffer, &mapinfo, GST_MAP_READ);
a_data = mapinfo.data;
return;
}
-void __mmplayer_gst_set_audiosink_property(mm_player_t* player, MMHandleType attrs)
+void __mmplayer_gst_set_pulsesink_property(mm_player_t* player, MMHandleType attrs)
{
#define MAX_PROPS_LEN 128
gint latency_mode = 0;
* But, it can not be changed during playing.
*/
MMPLAYER_FENTER();
+ MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && player->pipeline->audiobin);
+
mm_attrs_get_int_by_name(attrs, "sound_stream_index", &stream_id);
mm_attrs_get_string_by_name(attrs, "sound_stream_type", &stream_type);
if (!stream_type) {
- LOGE("stream_type is null.\n");
+ LOGE("stream_type is null.");
} else {
if (player->sound.focus_id)
snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d, media.focus_id=%d",
stream_type, stream_id);
props = gst_structure_from_string(stream_props, NULL);
g_object_set(player->pipeline->audiobin[MMPLAYER_A_SINK].gst, "stream-properties", props, NULL);
- LOGI("stream_type[%s], stream_id[%d], focus_id[%d], result[%s].\n",
+ LOGI("stream_type[%s], stream_id[%d], focus_id[%d], result[%s].",
stream_type, stream_id, player->sound.focus_id, stream_props);
gst_structure_free(props);
}
"latency", latency,
NULL);
- LOGD("audiosink property - latency=%s \n", latency);
+ LOGD("audiosink property - latency=%s", latency);
g_free(latency);
MMPLAYER_FLEAVE();
}
-static int
-__mmplayer_gst_create_audio_pipeline(mm_player_t* player)
+void __mmplayer_gst_set_openalsink_property(mm_player_t* player)
{
- MMPlayerGstElement *first_element = NULL;
MMPlayerGstElement *audiobin = NULL;
- MMHandleType attrs = 0;
- GstPad *pad = NULL;
- GstPad *ghostpad = NULL;
- GList *element_bucket = NULL;
- int i = 0;
- GstCaps *acaps;
MMPLAYER_FENTER();
+ MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && player->pipeline->audiobin);
- MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
+ audiobin = player->pipeline->audiobin;
- /* alloc handles */
- audiobin = (MMPlayerGstElement*)g_malloc0(sizeof(MMPlayerGstElement) * MMPLAYER_A_NUM);
- if (!audiobin) {
- LOGE("failed to allocate memory for audiobin\n");
- return MM_ERROR_PLAYER_NO_FREE_SPACE;
+ g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "source-ambisonics-type", 1, NULL);
+ sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, NULL, NULL, &stream_info);
+ g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "stream-info", stream_info, NULL);
+
+ if (player->video360_yaw_radians <= M_PI &&
+ player->video360_yaw_radians >= -M_PI &&
+ player->video360_pitch_radians <= M_PI_2 &&
+ player->video360_pitch_radians >= -M_PI_2) {
+ g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst),
+ "source-orientation-y", (int) (player->video360_yaw_radians * 180.0 / M_PI),
+ "source-orientation-x", (int) (player->video360_pitch_radians * 180.0 / M_PI), NULL);
+ } else if (player->video360_metadata.init_view_heading || player->video360_metadata.init_view_pitch) {
+ g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst),
+ "source-orientation-y", player->video360_metadata.init_view_heading,
+ "source-orientation-x", player->video360_metadata.init_view_pitch, NULL);
}
- attrs = MMPLAYER_GET_ATTRS(player);
+ MMPLAYER_FLEAVE();
+}
- /* create bin */
- audiobin[MMPLAYER_A_BIN].id = MMPLAYER_A_BIN;
- audiobin[MMPLAYER_A_BIN].gst = gst_bin_new("audiobin");
- if (!audiobin[MMPLAYER_A_BIN].gst) {
- LOGE("failed to create audiobin\n");
- goto ERROR;
- }
+static int
+__mmplayer_gst_fill_audio_bucket(mm_player_t *player, GList **bucket)
+{
+ MMPlayerGstElement *audiobin = NULL;
+ MMHandleType attrs = 0;
+ GList *element_bucket = NULL;
+ GstCaps *acaps = NULL;
+ GstPad *sink_pad = NULL;
- /* take it */
- player->pipeline->audiobin = audiobin;
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline &&
+ player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+ audiobin = player->pipeline->audiobin;
+ attrs = MMPLAYER_GET_ATTRS(player);
/* converter */
MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CONV, "audioconvert", "audio converter", TRUE, player);
/* resampler */
MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_RESAMPLER, player->ini.audioresampler_element, "audio resampler", TRUE, player);
- if (player->audio_stream_render_cb_ex) { /* pcm extraction only, no sound output */
+ if (player->audio_stream_render_cb) { /* pcm extraction only, no sound output */
gchar *dst_format = NULL;
int dst_len = 0;
int dst_samplerate = 0;
g_object_set(G_OBJECT(audiobin[MMPLAYER_A_DEINTERLEAVE].gst), "keep-positions", TRUE, NULL);
- /* raw pad handling signal */
+ /* 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);
+ MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "pad-added", G_CALLBACK(__mmplayer_gst_audio_deinterleave_pad_added), (gpointer)player);
} else {
g_object_set(G_OBJECT(audiobin[MMPLAYER_A_VOL].gst), "volume", player->sound.volume, NULL);
if (player->sound.mute) {
- LOGD("mute enabled\n");
+ LOGD("mute enabled");
g_object_set(G_OBJECT(audiobin[MMPLAYER_A_VOL].gst), "mute", player->sound.mute, NULL);
}
if ((srcpad = gst_element_get_static_pad(player->pipeline->mainbin[MMPLAYER_M_DEMUX].gst, "src"))) {
if ((caps = gst_pad_query_caps(srcpad, NULL))) {
- //MMPLAYER_LOG_GST_CAPS_TYPE(caps);
+ /* MMPLAYER_LOG_GST_CAPS_TYPE(caps); */
GstStructure *str = gst_caps_get_structure(caps, 0);
if (str)
gst_structure_get_int(str, "channels", &channels);
if ((!player->bypass_audio_effect)
&& (player->ini.use_audio_effect_preset || player->ini.use_audio_effect_custom)) {
- if (MM_AUDIO_EFFECT_TYPE_CUSTOM == player->audio_effect_info.effect_type) {
+ if (player->audio_effect_info.effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM) {
if (!_mmplayer_audio_effect_custom_apply(player))
- LOGI("apply audio effect(custom) setting success\n");
+ LOGI("apply audio effect(custom) setting success");
}
}
gst_caps_unref(acaps);
MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_SINK, "openalsink", "audiosink", TRUE, player);
- g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "source-ambisonics-type", 1, NULL);
- sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, NULL, NULL, &stream_info);
- g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "stream-info", stream_info, NULL);
player->is_openal_plugin_used = TRUE;
-
- if (player->video360_yaw_radians <= M_PI &&
- player->video360_yaw_radians >= -M_PI &&
- player->video360_pitch_radians <= M_PI_2 &&
- player->video360_pitch_radians >= -M_PI_2) {
- g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst),
- "source-orientation-y", (int) (player->video360_yaw_radians * 180.0 / M_PI),
- "source-orientation-x", (int) (player->video360_pitch_radians * 180.0 / M_PI), NULL);
- } else if (player->video360_metadata.init_view_heading || player->video360_metadata.init_view_pitch) {
- g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst),
- "source-orientation-y", player->video360_metadata.init_view_heading,
- "source-orientation-x", player->video360_metadata.init_view_pitch, NULL);
- }
} else {
if (player->is_360_feature_enabled && player->is_content_spherical)
- LOGW("Audio track isn't of the ambisonic type and can't be played back as a spatial sound.\n");
+ LOGW("Audio track isn't of the ambisonic type and can't be played back as a spatial sound.");
MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_SINK, player->ini.audiosink_element, "audiosink", TRUE, player);
}
- /* qos on */
- g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "qos", TRUE, NULL); /* qos on */
- g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "slave-method", GST_AUDIO_BASE_SINK_SLAVE_NONE, NULL);
-
-
if ((MMPLAYER_IS_RTSP_STREAMING(player)) ||
(player->videodec_linked && player->ini.use_system_clock)) {
- LOGD("system clock will be used.\n");
+ LOGD("system clock will be used.");
g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "provide-clock", FALSE, NULL);
}
if (g_strrstr(player->ini.audiosink_element, "pulsesink"))
- __mmplayer_gst_set_audiosink_property(player, attrs);
- }
+ __mmplayer_gst_set_pulsesink_property(player, attrs);
+ else if (g_strrstr(player->ini.audiosink_element, "openalsink"))
+ __mmplayer_gst_set_openalsink_property(player);
+
+ /* qos on */
+ g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "qos", TRUE, NULL); /* qos on */
+ g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "slave-method", GST_AUDIO_BASE_SINK_SLAVE_NONE, NULL);
- if (audiobin[MMPLAYER_A_SINK].gst) {
- GstPad *sink_pad = NULL;
sink_pad = gst_element_get_static_pad(audiobin[MMPLAYER_A_SINK].gst, "sink");
__mmplayer_add_signal_connection(player, G_OBJECT(sink_pad), MM_PLAYER_SIGNAL_TYPE_AUDIOBIN,
"notify::caps", G_CALLBACK(__mmplayer_gst_caps_notify_cb), (gpointer)player);
gst_object_unref(GST_OBJECT(sink_pad));
+
+ __mmplayer_add_sink(player, audiobin[MMPLAYER_A_SINK].gst);
}
- __mmplayer_add_sink(player, audiobin[MMPLAYER_A_SINK].gst);
+ *bucket = element_bucket;
- /* adding created elements to bin */
- LOGD("adding created elements to bin\n");
- if (!__mmplayer_gst_element_add_bucket_to_bin(GST_BIN(audiobin[MMPLAYER_A_BIN].gst), element_bucket)) {
- LOGE("failed to add elements\n");
+ MMPLAYER_FLEAVE();
+ return MM_ERROR_NONE;
+
+ERROR:
+ g_list_free(element_bucket);
+
+ *bucket = NULL;
+ MMPLAYER_FLEAVE();
+ return MM_ERROR_PLAYER_INTERNAL;
+}
+
+static int
+__mmplayer_gst_create_audio_pipeline(mm_player_t* player)
+{
+ MMPlayerGstElement *first_element = NULL;
+ MMPlayerGstElement *audiobin = NULL;
+ GstPad *pad = NULL;
+ GstPad *ghostpad = NULL;
+ GList *element_bucket = NULL;
+ int i = 0;
+
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+ /* alloc handles */
+ audiobin = (MMPlayerGstElement*)g_malloc0(sizeof(MMPlayerGstElement) * MMPLAYER_A_NUM);
+ if (!audiobin) {
+ LOGE("failed to allocate memory for audiobin");
+ return MM_ERROR_PLAYER_NO_FREE_SPACE;
+ }
+
+ /* create bin */
+ audiobin[MMPLAYER_A_BIN].id = MMPLAYER_A_BIN;
+ audiobin[MMPLAYER_A_BIN].gst = gst_bin_new("audiobin");
+ if (!audiobin[MMPLAYER_A_BIN].gst) {
+ LOGE("failed to create audiobin");
goto ERROR;
}
+ /* take it */
+ player->pipeline->audiobin = audiobin;
+
+ /* create audio filters and audiosink */
+ if (__mmplayer_gst_fill_audio_bucket(player, &element_bucket) != MM_ERROR_NONE)
+ goto ERROR;
+
+ /* adding created elements to bin */
+ LOGD("adding created elements to bin");
+ if (!__mmplayer_gst_element_add_bucket_to_bin(GST_BIN(audiobin[MMPLAYER_A_BIN].gst), element_bucket))
+ goto ERROR;
+
/* linking elements in the bucket by added order. */
- LOGD("Linking elements in the bucket by added order.\n");
- if (__mmplayer_gst_element_link_bucket(element_bucket) == -1) {
- LOGE("failed to link elements\n");
+ LOGD("Linking elements in the bucket by added order.");
+ if (__mmplayer_gst_element_link_bucket(element_bucket) == -1)
goto ERROR;
- }
/* get first element's sinkpad for creating ghostpad */
first_element = (MMPlayerGstElement *)element_bucket->data;
if (!first_element) {
- LOGE("failed to get first elem\n");
+ LOGE("failed to get first elem");
goto ERROR;
}
pad = gst_element_get_static_pad(GST_ELEMENT(first_element->gst), "sink");
if (!pad) {
- LOGE("failed to get pad from first element of audiobin\n");
+ LOGE("failed to get pad from first element of audiobin");
goto ERROR;
}
ghostpad = gst_ghost_pad_new("sink", pad);
if (!ghostpad) {
- LOGE("failed to create ghostpad\n");
+ LOGE("failed to create ghostpad");
goto ERROR;
}
if (!gst_element_add_pad(audiobin[MMPLAYER_A_BIN].gst, ghostpad)) {
- LOGE("failed to add ghostpad to audiobin\n");
+ LOGE("failed to add ghostpad to audiobin");
goto ERROR;
}
return MM_ERROR_NONE;
ERROR:
-
- LOGD("ERROR : releasing audiobin\n");
+ LOGD("ERROR : releasing audiobin");
if (pad)
gst_object_unref(GST_OBJECT(pad));
goto FAILED;
}
- if (player->audio_stream_render_cb_ex) {
+ if (player->audio_stream_render_cb) {
LOGW("not support in pcm extraction mode");
goto FAILED;
}
}
int
-_mmplayer_set_audiostream_cb_ex(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param)
+_mmplayer_set_audiostream_cb(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback callback, void *user_param)
{
- mm_player_t* player = (mm_player_t*) hplayer;
+ mm_player_t *player = (mm_player_t*) hplayer;
MMPLAYER_FENTER();
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
- player->audio_stream_render_cb_ex = callback;
+ player->audio_stream_render_cb = callback;
player->audio_stream_cb_user_param = user_param;
player->audio_stream_sink_sync = sync;
- LOGD("Audio Stream cb Handle value is %p : %p audio_stream_sink_sync : %d\n", player, player->audio_stream_render_cb_ex, player->audio_stream_sink_sync);
+ LOGD("handle: %p, cb: %p, sync: %d", player, player->audio_stream_render_cb, player->audio_stream_sink_sync);
MMPLAYER_FLEAVE();
player->video_stream_cb_user_param = NULL;
player->video_stream_prerolled = FALSE;
- player->audio_stream_render_cb_ex = NULL;
+ player->audio_stream_render_cb = NULL;
player->audio_stream_cb_user_param = NULL;
player->audio_stream_sink_sync = false;