static void __mmplayer_audio_stream_send_data(mm_player_t* player, mm_player_audio_stream_buff_t *a_buffer);
static void __mmplayer_initialize_storage_info(mm_player_t* player, MMPlayerPathType path_type);
static int __resource_release_cb(mm_resource_manager_h rm, mm_resource_manager_res_h res, void *user_data);
+static gboolean __mmplayer_update_duration_attrs(mm_player_t *player, MMHandleType attrs);
+static gboolean __mmplayer_update_audio_attrs(mm_player_t *player, MMHandleType attrs);
+static gboolean __mmplayer_update_video_attrs(mm_player_t *player, MMHandleType attrs);
+static gboolean __mmplayer_update_bitrate_attrs(mm_player_t *player, MMHandleType attrs);
static void __mmplayer_copy_uri_and_set_type(MMPlayerParseProfile* data, const char *uri, int uri_type);
static int __mmplayer_set_mem_uri(MMPlayerParseProfile* data, char *path, void *param);
static gboolean has_bitrate = FALSE;
gboolean missing_only = FALSE;
gboolean all = FALSE;
- gint64 dur_nsec = 0;
- GstStructure* p = NULL;
MMHandleType attrs = 0;
- gchar *path = NULL;
- struct stat sb;
MMPLAYER_FENTER();
missing_only = FALSE;
}
- if ((flag & ATTR_DURATION) || (!has_duration && missing_only) || all) {
- LOGD("try to update duration");
- has_duration = FALSE;
-
- if (gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &dur_nsec) && (dur_nsec > 0)) {
- player->duration = dur_nsec;
- LOGW("duration : %"G_GINT64_FORMAT" msec", GST_TIME_AS_MSECONDS(dur_nsec));
- has_duration = TRUE;
- }
-
- if (player->duration < 0) {
- LOGW("duration is Non-Initialized !!!");
- player->duration = 0;
- }
-
- /* update streaming service type */
- player->streaming_type = __mmplayer_get_stream_service_type(player);
-
- /* check duration is OK */
- if (dur_nsec == 0 && !MMPLAYER_IS_LIVE_STREAMING(player)) {
- /* FIXIT : find another way to get duration here. */
- LOGW("finally it's failed to get duration from pipeline. progressbar will not work correctely!");
- }
- }
-
- if ((flag & ATTR_AUDIO) || (!has_audio_attrs && missing_only) || all) {
- /* update audio params
- NOTE : We need original audio params and it can be only obtained from src pad of audio
- decoder. Below code only valid when we are not using 'resampler' just before
- 'audioconverter'. */
-
- LOGD("try to update audio attrs");
- has_audio_attrs = FALSE;
-
- if (player->pipeline->audiobin &&
- player->pipeline->audiobin[MMPLAYER_A_SINK].gst) {
- GstCaps *caps_a = NULL;
- GstPad* pad = NULL;
- gint samplerate = 0, channels = 0;
-
- pad = gst_element_get_static_pad(
- player->pipeline->audiobin[MMPLAYER_A_CONV].gst, "sink");
-
- if (pad) {
- caps_a = gst_pad_get_current_caps(pad);
-
- if (caps_a) {
- p = gst_caps_get_structure(caps_a, 0);
+ if ((flag & ATTR_DURATION) || (!has_duration && missing_only) || all)
+ has_duration = __mmplayer_update_duration_attrs(player, attrs);
- mm_attrs_get_int_by_name(attrs, "content_audio_samplerate", &samplerate);
+ if ((flag & ATTR_AUDIO) || (!has_audio_attrs && missing_only) || all)
+ has_audio_attrs = __mmplayer_update_audio_attrs(player, attrs);
- gst_structure_get_int(p, "rate", &samplerate);
- mm_attrs_set_int_by_name(attrs, "content_audio_samplerate", samplerate);
+ if ((flag & ATTR_VIDEO) || (!has_video_attrs && missing_only) || all)
+ has_video_attrs = __mmplayer_update_video_attrs(player, attrs);
- gst_structure_get_int(p, "channels", &channels);
- mm_attrs_set_int_by_name(attrs, "content_audio_channels", channels);
-
- SECURE_LOGD("samplerate : %d channels : %d", samplerate, channels);
-
- gst_caps_unref(caps_a);
- caps_a = NULL;
-
- has_audio_attrs = TRUE;
- } else
- LOGW("not ready to get audio caps");
-
- gst_object_unref(pad);
- } else
- LOGW("failed to get pad from audiosink");
- }
- }
-
- if ((flag & ATTR_VIDEO) || (!has_video_attrs && missing_only) || all) {
- LOGD("try to update video attrs");
- has_video_attrs = FALSE;
-
- if (player->pipeline->videobin &&
- player->pipeline->videobin[MMPLAYER_V_SINK].gst) {
- GstCaps *caps_v = NULL;
- GstPad* pad = NULL;
- gint tmpNu, tmpDe;
- gint width, height;
-
- pad = gst_element_get_static_pad(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sink");
- if (pad) {
- caps_v = gst_pad_get_current_caps(pad);
-
- /* Use v_stream_caps, if fail to get video_sink sink pad*/
- if (!caps_v && player->v_stream_caps) {
- caps_v = player->v_stream_caps;
- gst_caps_ref(caps_v);
- }
-
- if (caps_v) {
- p = gst_caps_get_structure(caps_v, 0);
- gst_structure_get_int(p, "width", &width);
- mm_attrs_set_int_by_name(attrs, "content_video_width", width);
-
- gst_structure_get_int(p, "height", &height);
- mm_attrs_set_int_by_name(attrs, "content_video_height", height);
-
- gst_structure_get_fraction(p, "framerate", &tmpNu, &tmpDe);
-
- SECURE_LOGD("width : %d height : %d", width, height);
-
- gst_caps_unref(caps_v);
- caps_v = NULL;
-
- if (tmpDe > 0) {
- mm_attrs_set_int_by_name(attrs, "content_video_fps", tmpNu / tmpDe);
- SECURE_LOGD("fps : %d", tmpNu / tmpDe);
- }
-
- has_video_attrs = TRUE;
- } else
- LOGD("no negitiated caps from videosink");
- gst_object_unref(pad);
- pad = NULL;
- } else {
- LOGD("no videosink sink pad");
- }
- }
- }
-
-
- if ((flag & ATTR_BITRATE) || (!has_bitrate && missing_only) || all) {
- has_bitrate = FALSE;
-
- /* FIXIT : please make it clear the dependancy with duration/codec/uritype */
- if (player->duration) {
- guint64 data_size = 0;
-
- if (!MMPLAYER_IS_STREAMING(player) && (player->can_support_codec & FOUND_PLUGIN_VIDEO)) {
- mm_attrs_get_string_by_name(attrs, "profile_uri", &path);
-
- if (stat(path, &sb) == 0)
- data_size = (guint64)sb.st_size;
- } else if (MMPLAYER_IS_HTTP_STREAMING(player)) {
- data_size = player->http_content_size;
- }
- LOGD("try to update bitrate : data_size = %"G_GUINT64_FORMAT, data_size);
-
- if (data_size) {
- guint64 bitrate = 0;
- guint64 msec_dur = 0;
-
- msec_dur = GST_TIME_AS_MSECONDS(player->duration);
- if (msec_dur > 0) {
- bitrate = data_size * 8 * 1000 / msec_dur;
- SECURE_LOGD("file size : %u, video bitrate = %llu", data_size, bitrate);
- mm_attrs_set_int_by_name(attrs, "content_video_bitrate", bitrate);
-
- has_bitrate = TRUE;
- } else {
- LOGD("player duration is less than 0");
- }
- }
-
- if (MMPLAYER_IS_RTSP_STREAMING(player)) {
- if (player->total_bitrate) {
- mm_attrs_set_int_by_name(attrs, "content_video_bitrate", player->total_bitrate);
- has_bitrate = TRUE;
- }
- }
- }
- }
+ if ((flag & ATTR_BITRATE) || (!has_bitrate && missing_only) || all)
+ has_bitrate = __mmplayer_update_bitrate_attrs(player, attrs);
/* validate all */
if (mmf_attrs_commit(attrs)) {
return ret;
}
+static gboolean
+__mmplayer_update_duration_attrs(mm_player_t *player, MMHandleType attrs)
+{
+ gboolean ret = FALSE;
+ gint64 dur_nsec = 0;
+ LOGD("try to update duration");
+
+ if (gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &dur_nsec) && (dur_nsec > 0)) {
+ player->duration = dur_nsec;
+ LOGW("duration : %"G_GINT64_FORMAT" msec", GST_TIME_AS_MSECONDS(dur_nsec));
+ ret = TRUE;
+ }
+
+ if (player->duration < 0) {
+ LOGW("duration is Non-Initialized !!!");
+ player->duration = 0;
+ }
+
+ /* update streaming service type */
+ player->streaming_type = __mmplayer_get_stream_service_type(player);
+
+ /* check duration is OK */
+ if (dur_nsec == 0 && !MMPLAYER_IS_LIVE_STREAMING(player)) {
+ /* FIXIT : find another way to get duration here. */
+ LOGW("finally it's failed to get duration from pipeline. progressbar will not work correctely!");
+ }
+
+ return ret;
+}
+
+static gboolean
+__mmplayer_update_audio_attrs(mm_player_t *player, MMHandleType attrs)
+{
+ /* update audio params
+ NOTE : We need original audio params and it can be only obtained from src pad of audio
+ decoder. Below code only valid when we are not using 'resampler' just before
+ 'audioconverter'. */
+ GstCaps *caps_a = NULL;
+ GstPad* pad = NULL;
+ gint samplerate = 0, channels = 0;
+ GstStructure* p = NULL;
+
+ LOGD("try to update audio attrs");
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline->audiobin, FALSE);
+ MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline->audiobin[MMPLAYER_A_SINK].gst, FALSE);
+
+ pad = gst_element_get_static_pad(
+ player->pipeline->audiobin[MMPLAYER_A_CONV].gst, "sink");
+
+ if (!pad) {
+ LOGW("failed to get pad from audiosink");
+ return FALSE;
+ }
+
+ caps_a = gst_pad_get_current_caps(pad);
+
+ if (!caps_a) {
+ LOGW("not ready to get audio caps");
+ gst_object_unref(pad);
+ return FALSE;
+ }
+
+ p = gst_caps_get_structure(caps_a, 0);
+
+ mm_attrs_get_int_by_name(attrs, "content_audio_samplerate", &samplerate);
+
+ gst_structure_get_int(p, "rate", &samplerate);
+ mm_attrs_set_int_by_name(attrs, "content_audio_samplerate", samplerate);
+
+ gst_structure_get_int(p, "channels", &channels);
+ mm_attrs_set_int_by_name(attrs, "content_audio_channels", channels);
+
+ SECURE_LOGD("samplerate : %d channels : %d", samplerate, channels);
+
+ gst_caps_unref(caps_a);
+ gst_object_unref(pad);
+
+ return TRUE;
+}
+
+static gboolean
+__mmplayer_update_video_attrs(mm_player_t *player, MMHandleType attrs)
+{
+ LOGD("try to update video attrs");
+
+ GstCaps *caps_v = NULL;
+ GstPad* pad = NULL;
+ gint tmpNu, tmpDe;
+ gint width, height;
+ GstStructure* p = NULL;
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline->videobin, FALSE);
+ MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline->videobin[MMPLAYER_V_SINK].gst, FALSE);
+
+ pad = gst_element_get_static_pad(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sink");
+ if (!pad) {
+ LOGD("no videosink sink pad");
+ return FALSE;
+ }
+
+ caps_v = gst_pad_get_current_caps(pad);
+ /* Use v_stream_caps, if fail to get video_sink sink pad*/
+ if (!caps_v && player->v_stream_caps) {
+ caps_v = player->v_stream_caps;
+ gst_caps_ref(caps_v);
+ }
+
+ if (!caps_v) {
+ LOGD("no negitiated caps from videosink");
+ gst_object_unref(pad);
+ return FALSE;
+ }
+
+ p = gst_caps_get_structure(caps_v, 0);
+ gst_structure_get_int(p, "width", &width);
+ mm_attrs_set_int_by_name(attrs, "content_video_width", width);
+
+ gst_structure_get_int(p, "height", &height);
+ mm_attrs_set_int_by_name(attrs, "content_video_height", height);
+
+ gst_structure_get_fraction(p, "framerate", &tmpNu, &tmpDe);
+
+ SECURE_LOGD("width : %d height : %d", width, height);
+
+ gst_caps_unref(caps_v);
+ gst_object_unref(pad);
+
+ if (tmpDe > 0) {
+ mm_attrs_set_int_by_name(attrs, "content_video_fps", tmpNu / tmpDe);
+ SECURE_LOGD("fps : %d", tmpNu / tmpDe);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+__mmplayer_update_bitrate_attrs(mm_player_t *player, MMHandleType attrs)
+{
+ gboolean ret = FALSE;
+ guint64 data_size = 0;
+ gchar *path = NULL;
+ struct stat sb;
+
+ /* FIXIT : please make it clear the dependancy with duration/codec/uritype */
+ if (!player->duration)
+ return FALSE;
+
+ if (!MMPLAYER_IS_STREAMING(player) && (player->can_support_codec & FOUND_PLUGIN_VIDEO)) {
+ mm_attrs_get_string_by_name(attrs, "profile_uri", &path);
+ if (stat(path, &sb) == 0)
+ data_size = (guint64)sb.st_size;
+
+ } else if (MMPLAYER_IS_HTTP_STREAMING(player)) {
+ data_size = player->http_content_size;
+ }
+
+ LOGD("try to update bitrate : data_size = %"G_GUINT64_FORMAT, data_size);
+
+ if (data_size) {
+ guint64 bitrate = 0;
+ guint64 msec_dur = 0;
+
+ msec_dur = GST_TIME_AS_MSECONDS(player->duration);
+ if (msec_dur > 0) {
+ bitrate = data_size * 8 * 1000 / msec_dur;
+ SECURE_LOGD("file size : %u, video bitrate = %llu", data_size, bitrate);
+ mm_attrs_set_int_by_name(attrs, "content_video_bitrate", bitrate);
+
+ ret = TRUE;
+ } else {
+ LOGD("player duration is less than 0");
+ }
+ }
+
+ if (MMPLAYER_IS_RTSP_STREAMING(player)) {
+ if (player->total_bitrate) {
+ mm_attrs_set_int_by_name(attrs, "content_video_bitrate", player->total_bitrate);
+ ret = TRUE;
+ }
+ }
+
+ return ret;
+}
static void
__mmplayer_copy_uri_and_set_type(MMPlayerParseProfile* data, const char *uri, int uri_type)
{