return result;
}
+
+int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
+{
+ int result = MM_ERROR_NONE;
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+ MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
+
+ MMPLAYER_CMD_LOCK( player );
+
+ result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
+
+ MMPLAYER_CMD_UNLOCK( player );
+
+ return result;
+}
+
+int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
+{
+ int result = MM_ERROR_NONE;
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+ MMPLAYER_CMD_LOCK( player );
+
+ result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
+
+ MMPLAYER_CMD_UNLOCK( player );
+
+ return result;
+}
+
+int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
+{
+ int result = MM_ERROR_NONE;
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+ MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
+
+ MMPLAYER_CMD_LOCK( player );
+
+ result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
+
+ MMPLAYER_CMD_UNLOCK( player );
+
+ return result;
+}
#define PLAYER_DISPLAY_MODE_DST_ROI 5
+#define ADAPTIVE_VARIANT_DEFAULT_VALUE -1 /* auto */
+
/*---------------------------------------------------------------------------
| LOCAL CONSTANT DEFINITIONS: |
---------------------------------------------------------------------------*/
}
}
+static VariantData *
+__mmplayer_adaptive_var_info(const VariantData *self, gpointer user_data)
+{
+ VariantData *var_info = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+
+ var_info = g_new0(VariantData, 1);
+ if (!var_info) return NULL;
+ var_info->bandwidth = self->bandwidth;
+ var_info->width = self->width;
+ var_info->height = self->height;
+ return var_info;
+}
+
static gboolean
__mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @
{
case GST_MESSAGE_ELEMENT:
{
const gchar *structure_name;
- gint count = 0;
+ gint count = 0, idx = 0;
MMHandleType attrs = 0;
attrs = MMPLAYER_GET_ATTRS(player);
if (!structure_name)
break;
+ LOGD("GST_MESSAGE_ELEMENT %s from %s", structure_name, GST_OBJECT_NAME(GST_MESSAGE_SRC(msg)));
+
+ if (!strcmp(structure_name, "adaptive-streaming-variant")) {
+ const GValue *var_info = NULL;
+
+ var_info = gst_structure_get_value(gst_message_get_structure(msg), "video-variant-info");
+ if (var_info != NULL) {
+ if (player->adaptive_info.var_list)
+ g_list_free_full(player->adaptive_info.var_list, g_free);
+
+ /* share addr or copy the list */
+ player->adaptive_info.var_list =
+ g_list_copy_deep((GList *)g_value_get_pointer(var_info), (GCopyFunc)__mmplayer_adaptive_var_info, NULL);
+
+ count = g_list_length(player->adaptive_info.var_list);
+ if (count > 0) {
+ VariantData *temp = NULL;
+
+ /* print out for debug */
+ LOGD("num of variant_info %d", count);
+ for (idx = 0; idx < count; idx++) {
+ temp = g_list_nth_data(player->adaptive_info.var_list, idx);
+ if (temp)
+ LOGD("variant(%d) [b]%d [w]%d [h]%d ", idx, temp->bandwidth, temp->width, temp->height);
+ }
+ }
+ }
+ }
+
if (!strcmp(structure_name, "prepare-decode-buffers")) {
gint num_buffers = 0;
gint extra_num_buffers = 0;
else
player->ini.set_dump_element_flag = TRUE;
+ player->adaptive_info.limit.bandwidth = ADAPTIVE_VARIANT_DEFAULT_VALUE;
+ player->adaptive_info.limit.width = ADAPTIVE_VARIANT_DEFAULT_VALUE;
+ player->adaptive_info.limit.height = ADAPTIVE_VARIANT_DEFAULT_VALUE;
+
/* set player state to null */
MMPLAYER_STATE_CHANGE_TIMEOUT(player) = player->ini.localplayback_state_change_timeout;
MMPLAYER_SET_STATE(player, MM_PLAYER_STATE_NULL);
player->parsers = g_list_append(player->parsers, selected);
}
- if ((g_strrstr(klass, "Demux") || g_strrstr(klass, "Parse")) && !(g_strrstr(klass, "Adaptive"))) {
+ if (g_strrstr(klass, "Demuxer/Adaptive")) {
+ player->pipeline->mainbin[MMPLAYER_M_ADAPTIVE_DEMUX].id = MMPLAYER_M_ADAPTIVE_DEMUX;
+ player->pipeline->mainbin[MMPLAYER_M_ADAPTIVE_DEMUX].gst = element;
+
+ LOGD("set max variant limit: %d, %d %d", player->adaptive_info.limit.bandwidth,
+ player->adaptive_info.limit.width, player->adaptive_info.limit.height);
+
+ g_object_set(player->pipeline->mainbin[MMPLAYER_M_ADAPTIVE_DEMUX].gst,
+ "max-bandwidth", player->adaptive_info.limit.bandwidth,
+ "max-video-width", player->adaptive_info.limit.width,
+ "max-video-height", player->adaptive_info.limit.height, NULL);
+
+ } else if (g_strrstr(klass, "Demux") || g_strrstr(klass, "Parse")) {
/* FIXIT : first value will be overwritten if there's more
* than 1 demuxer/parser
*/
player->state_tune_caps = NULL;
}
+ if (player->adaptive_info.var_list) {
+ g_list_free_full(player->adaptive_info.var_list, g_free);
+ player->adaptive_info.var_list = NULL;
+ }
+
+ player->adaptive_info.limit.bandwidth = ADAPTIVE_VARIANT_DEFAULT_VALUE;
+ player->adaptive_info.limit.width = ADAPTIVE_VARIANT_DEFAULT_VALUE;
+ player->adaptive_info.limit.height = ADAPTIVE_VARIANT_DEFAULT_VALUE;
+
MMPLAYER_FLEAVE();
}
return ret;
}
+int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info)
+{
+ int ret = MM_ERROR_NONE;
+ mm_player_t* player = (mm_player_t*) hplayer;
+ int idx = 0, total = 0;
+ gchar *result = NULL, *tmp = NULL;
+
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+ MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
+
+ total = *num = g_list_length(player->adaptive_info.var_list);
+ if (total <= 0) {
+ LOGW("There is no stream variant info.");
+ return ret;
+ }
+
+ result = g_strdup ("");
+ for (idx = 0 ; idx < total ; idx++) {
+ VariantData *v_data = NULL;
+ v_data = g_list_nth_data(player->adaptive_info.var_list, idx);
+
+ if (v_data) {
+ gchar data[64]={0};
+ snprintf(data, sizeof(data), "%d,%d,%d,", v_data->bandwidth, v_data->width, v_data->height);
+
+ tmp = g_strconcat (result, data, NULL);
+ g_free (result);
+ result = tmp;
+ } else {
+ LOGW("There is no variant data in %d", idx);
+ (*num)--;
+ }
+ }
+
+ *var_info = (char *)result;
+
+ LOGD("variant info %d:%s", *num, *var_info);
+ MMPLAYER_FLEAVE();
+ return ret;
+}
+
+int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth, int width, int height)
+{
+ int ret = MM_ERROR_NONE;
+ mm_player_t* player = (mm_player_t*) hplayer;
+
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+ LOGD("set limit to [b]%d, [w]%d, [h]%d", bandwidth, width, height);
+
+ player->adaptive_info.limit.bandwidth = (bandwidth >= ADAPTIVE_VARIANT_DEFAULT_VALUE)?(bandwidth):(ADAPTIVE_VARIANT_DEFAULT_VALUE);
+ player->adaptive_info.limit.width = (width >= ADAPTIVE_VARIANT_DEFAULT_VALUE)?(width):(ADAPTIVE_VARIANT_DEFAULT_VALUE);
+ player->adaptive_info.limit.height = (height >= ADAPTIVE_VARIANT_DEFAULT_VALUE)?(height):(ADAPTIVE_VARIANT_DEFAULT_VALUE);
+
+ if (player->pipeline && player->pipeline->mainbin && player->pipeline->mainbin[MMPLAYER_M_ADAPTIVE_DEMUX].gst) {
+ LOGD("update max limit of %s", GST_ELEMENT_NAME(player->pipeline->mainbin[MMPLAYER_M_ADAPTIVE_DEMUX].gst));
+ g_object_set(player->pipeline->mainbin[MMPLAYER_M_ADAPTIVE_DEMUX].gst,
+ "max-bandwidth", bandwidth, "max-video-width", width, "max-video-height", height, NULL);
+
+ /* FIXME: seek to current position for applying new variant limitation */
+ }
+
+ MMPLAYER_FLEAVE();
+ return ret;
+
+}
+
+int _mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidth, int *width, int *height)
+{
+ int ret = MM_ERROR_NONE;
+ mm_player_t* player = (mm_player_t*) hplayer;
+
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+ MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
+
+ *bandwidth = player->adaptive_info.limit.bandwidth;
+ *width = player->adaptive_info.limit.width;
+ *height = player->adaptive_info.limit.height;
+
+ LOGD("get limit to [b]%d, [w]%d, [h]%d", *bandwidth, *width, *height);
+
+ MMPLAYER_FLEAVE();
+ return ret;
+}