summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEunhae Choi <eunhae1.choi@samsung.com>2017-07-06 18:19:58 +0900
committerEunhae Choi <eunhae1.choi@samsung.com>2017-07-06 18:22:29 +0900
commit114cd68363c3111278c3cfc597615b641d2a81d7 (patch)
treee7dedaeb15c1852f5b5eb151d7213ca7ca3a28bc
parenta646e3846b2306c8dd192b5c2bac904020572eb2 (diff)
downloadlibmm-player-114cd68363c3111278c3cfc597615b641d2a81d7.tar.gz
libmm-player-114cd68363c3111278c3cfc597615b641d2a81d7.tar.bz2
libmm-player-114cd68363c3111278c3cfc597615b641d2a81d7.zip
[0.6.56] add about adaptive streaming variant controlsubmit/tizen/20170707.065345accepted/tizen/unified/20170710.154324
- handle the element msg to share the adaptive streaming variant information - add set/get max variant limit path of adaptivedemux Change-Id: Iaf96dd345df0a51faf1cc4eb32ec2ff87ed74f1f
-rw-r--r--packaging/libmm-player.spec2
-rw-r--r--src/include/mm_player.h6
-rw-r--r--src/include/mm_player_priv.h17
-rw-r--r--src/mm_player.c47
-rw-r--r--src/mm_player_priv.c161
5 files changed, 230 insertions, 3 deletions
diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec
index 4e04055..4cb5974 100644
--- a/packaging/libmm-player.spec
+++ b/packaging/libmm-player.spec
@@ -1,6 +1,6 @@
Name: libmm-player
Summary: Multimedia Framework Player Library
-Version: 0.6.55
+Version: 0.6.56
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0
diff --git a/src/include/mm_player.h b/src/include/mm_player.h
index 787b42d..7c3944f 100644
--- a/src/include/mm_player.h
+++ b/src/include/mm_player.h
@@ -2342,6 +2342,12 @@ int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int
*/
int mm_player_manage_external_storage_state(MMHandleType player, int state);
+int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info);
+
+int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height);
+
+int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height);
+
/**
@}
*/
diff --git a/src/include/mm_player_priv.h b/src/include/mm_player_priv.h
index 3204604..62a06ba 100644
--- a/src/include/mm_player_priv.h
+++ b/src/include/mm_player_priv.h
@@ -187,6 +187,7 @@ enum MainElementID {
MMPLAYER_M_MUXED_S_BUFFER,
MMPLAYER_M_DEMUXED_S_BUFFER,
MMPLAYER_M_ID3DEMUX,
+ MMPLAYER_M_ADAPTIVE_DEMUX,
/* es buff src queue */
MMPLAYER_M_V_BUFFER,
@@ -450,6 +451,17 @@ typedef struct {
} mm_player_video_bo_info_t;
typedef struct {
+ gint bandwidth;
+ gint width;
+ gint height;
+} VariantData;
+
+typedef struct {
+ GList* var_list;
+ VariantData limit;
+} MMAdaptiveVariantInfo;
+
+typedef struct {
/* STATE */
int state; // player current state
int prev_state; // player previous state
@@ -760,6 +772,8 @@ typedef struct {
int pcm_samplerate;
int pcm_channel;
+
+ MMAdaptiveVariantInfo adaptive_info;
} mm_player_t;
typedef struct {
@@ -887,6 +901,9 @@ int _mmplayer_sound_register_with_pid(MMHandleType hplayer, int pid);
int _mmplayer_get_client_pid(MMHandleType hplayer, int* pid);
int __mmplayer_get_video_angle(mm_player_t* player, int *user_angle, int *org_angle);
int _mmplayer_video_stream_release_bo(mm_player_t* player, void* bo);
+int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info);
+int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth, int width, int height);
+int _mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidth, int *width, int *height);
#ifdef __cplusplus
}
diff --git a/src/mm_player.c b/src/mm_player.c
index dcac88c..f648d67 100644
--- a/src/mm_player.c
+++ b/src/mm_player.c
@@ -1338,3 +1338,50 @@ int mm_player_manage_external_storage_state(MMHandleType player, int state)
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;
+}
diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c
index 1e8ebe2..af55e5f 100644
--- a/src/mm_player_priv.c
+++ b/src/mm_player_priv.c
@@ -109,6 +109,8 @@
#define PLAYER_DISPLAY_MODE_DST_ROI 5
+#define ADAPTIVE_VARIANT_DEFAULT_VALUE -1 /* auto */
+
/*---------------------------------------------------------------------------
| LOCAL CONSTANT DEFINITIONS: |
---------------------------------------------------------------------------*/
@@ -1100,6 +1102,20 @@ __mmplayer_drop_subtitle(mm_player_t* player, gboolean is_drop)
}
}
+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) // @
{
@@ -1519,7 +1535,7 @@ __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);
@@ -1536,6 +1552,35 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @
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;
@@ -8495,6 +8540,10 @@ _mmplayer_create_player(MMHandleType handle) // @
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);
@@ -12009,7 +12058,19 @@ __mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data
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
*/
@@ -12224,6 +12285,15 @@ __mmplayer_release_misc(mm_player_t* player)
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();
}
@@ -15187,3 +15257,90 @@ int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int state)
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;
+}