static void __mmplayer_del_sink(mm_player_t* player, GstElement* sink);
static void __mmplayer_release_signal_connection(mm_player_t* player, MMPlayerSignalType type);
static gpointer __mmplayer_next_play_thread(gpointer data);
-static gpointer __mmplayer_repeat_thread(gpointer data);
static gboolean _mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag);
static gboolean __mmplayer_add_dump_buffer_probe(mm_player_t *player, GstElement *element);
return NULL;
}
-static gpointer __mmplayer_repeat_thread(gpointer data)
-{
- mm_player_t* player = (mm_player_t*) data;
- gboolean ret_value = FALSE;
- MMHandleType attrs = 0;
- gint count = 0;
-
- MMPLAYER_RETURN_VAL_IF_FAIL(player, NULL);
-
- MMPLAYER_REPEAT_THREAD_LOCK(player);
- while (!player->repeat_thread_exit) {
- LOGD("repeat thread started. waiting for signal.\n");
- MMPLAYER_REPEAT_THREAD_WAIT(player);
-
- if (player->repeat_thread_exit) {
- LOGD("exiting repeat thread\n");
- break;
- }
-
-
- /* lock */
- MMPLAYER_CMD_LOCK(player);
-
- attrs = MMPLAYER_GET_ATTRS(player);
-
- if (mm_attrs_get_int_by_name(attrs, "profile_play_count", &count) != MM_ERROR_NONE) {
- LOGE("can not get play count\n");
- MMPLAYER_CMD_UNLOCK(player);
- break;
- }
-
- if (player->section_repeat) {
- ret_value = _mmplayer_activate_section_repeat((MMHandleType)player, player->section_repeat_start, player->section_repeat_end);
- } else {
- if (player->playback_rate < 0.0) {
- player->resumed_by_rewind = TRUE;
- _mmplayer_set_mute((MMHandleType)player, 0);
- MMPLAYER_POST_MSG(player, MM_MESSAGE_RESUMED_BY_REW, NULL);
- }
-
- ret_value = __gst_seek(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, player->playback_rate,
- GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
- 0, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
-
- /* initialize */
- player->sent_bos = FALSE;
- }
-
- if (!ret_value) {
- LOGE("failed to set position to zero for rewind\n");
- MMPLAYER_CMD_UNLOCK(player);
- continue;
- }
-
- /* decrease play count */
- if (count > 1) {
- /* we successeded to rewind. update play count and then wait for next EOS */
- count--;
-
- mm_attrs_set_int_by_name(attrs, "profile_play_count", count);
-
- /* commit attribute */
- if (mmf_attrs_commit(attrs))
- LOGE("failed to commit attribute\n");
- }
-
- /* unlock */
- MMPLAYER_CMD_UNLOCK(player);
- }
-
- MMPLAYER_REPEAT_THREAD_UNLOCK(player);
- return NULL;
-}
-
static void
__mmplayer_update_buffer_setting(mm_player_t *player, GstMessage *buffering_msg)
{
if (attrs) {
mm_attrs_get_int_by_name(attrs, "profile_play_count", &count);
- player->play_count = count;
-
- LOGD("remaining play count: %d, playback rate: %f\n", count, player->playback_rate);
- if (count > 1 || count == -1 || player->playback_rate < 0.0) /* default value is 1 */ {
- gint ret_value = 0;
+ LOGD("play count: %d, playback rate: %f\n", count, player->playback_rate);
- if (player->section_repeat) {
- ret_value = _mmplayer_activate_section_repeat((MMHandleType)player, player->section_repeat_start, player->section_repeat_end);
- } else {
- if (player->playback_rate < 0.0) {
- player->resumed_by_rewind = TRUE;
- _mmplayer_set_mute((MMHandleType)player, 0);
- MMPLAYER_POST_MSG(player, MM_MESSAGE_RESUMED_BY_REW, NULL);
- }
-
- __mmplayer_handle_eos_delay(player, player->ini.delay_before_repeat);
-
- /* initialize */
- player->sent_bos = FALSE;
+ if (count == -1 || player->playback_rate < 0.0) /* default value is 1 */ {
+ if (player->playback_rate < 0.0) {
+ player->resumed_by_rewind = TRUE;
+ _mmplayer_set_mute((MMHandleType)player, 0);
+ MMPLAYER_POST_MSG(player, MM_MESSAGE_RESUMED_BY_REW, NULL);
}
- if (MM_ERROR_NONE != ret_value)
- LOGE("failed to set position to zero for rewind\n");
+ __mmplayer_handle_eos_delay(player, player->ini.delay_before_repeat);
+
+ /* initialize */
+ player->sent_bos = FALSE;
/* not posting eos when repeating */
break;
/* create update tag lock */
g_mutex_init(&player->update_tag_lock);
- /* create repeat mutex */
- g_mutex_init(&player->repeat_thread_mutex);
-
- /* create repeat cond */
- g_cond_init(&player->repeat_thread_cond);
-
- /* create repeat thread */
- player->repeat_thread =
- g_thread_try_new("repeat_thread", __mmplayer_repeat_thread, (gpointer)player, NULL);
- if (!player->repeat_thread) {
- LOGE("failed to create repeat_thread(%s)");
- g_mutex_clear(&player->repeat_thread_mutex);
- g_cond_clear(&player->repeat_thread_cond);
- ret = MM_ERROR_PLAYER_RESOURCE_LIMIT;
- goto ERROR;
- }
-
/* create next play mutex */
g_mutex_init(&player->next_play_thread_mutex);
player->playback_rate = DEFAULT_PLAYBACK_RATE;
player->play_subtitle = FALSE;
- player->play_count = 0;
player->use_deinterleave = FALSE;
player->max_audio_channels = 0;
player->video_share_api_delta = 0;
/* free update tag lock */
g_mutex_clear(&player->update_tag_lock);
- /* free thread */
- if (player->repeat_thread) {
- MMPLAYER_REPEAT_THREAD_LOCK(player);
- player->repeat_thread_exit = TRUE;
- MMPLAYER_REPEAT_THREAD_SIGNAL(player);
- MMPLAYER_REPEAT_THREAD_UNLOCK(player);
-
- g_thread_join(player->repeat_thread);
- player->repeat_thread = NULL;
-
- g_mutex_clear(&player->repeat_thread_mutex);
- g_cond_clear(&player->repeat_thread_cond);
- }
-
/* free next play thread */
if (player->next_play_thread) {
MMPLAYER_NEXT_PLAY_THREAD_LOCK(player);
__mmplayer_destroy_streaming_ext(player);
- /* release repeat thread */
- if (player->repeat_thread) {
- MMPLAYER_REPEAT_THREAD_LOCK(player);
- player->repeat_thread_exit = TRUE;
- MMPLAYER_REPEAT_THREAD_SIGNAL(player);
- MMPLAYER_REPEAT_THREAD_UNLOCK(player);
-
- LOGD("waitting for repeat thread exit\n");
- g_thread_join(player->repeat_thread);
- g_mutex_clear(&player->repeat_thread_mutex);
- g_cond_clear(&player->repeat_thread_cond);
- LOGD("repeat thread released\n");
- }
-
/* release next play thread */
if (player->next_play_thread) {
MMPLAYER_NEXT_PLAY_THREAD_LOCK(player);
return ret;
}
-int
-__mmplayer_set_play_count(mm_player_t* player, gint count)
-{
- MMHandleType attrs = 0;
-
- MMPLAYER_FENTER();
-
- MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
- attrs = MMPLAYER_GET_ATTRS(player);
- if (!attrs) {
- LOGE("fail to get attributes.\n");
- return MM_ERROR_PLAYER_INTERNAL;
- }
-
- mm_attrs_set_int_by_name(attrs, "profile_play_count", count);
- if (mmf_attrs_commit(attrs)) /* return -1 if error */
- LOGE("failed to commit\n");
-
- MMPLAYER_FLEAVE();
-
- return MM_ERROR_NONE;
-}
-
-int
-_mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end)
-{
- mm_player_t* player = (mm_player_t*)hplayer;
- gint64 start_pos = 0;
- gint64 end_pos = 0;
- gint infinity = -1;
-
- MMPLAYER_FENTER();
-
- MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
- MMPLAYER_RETURN_VAL_IF_FAIL(end <= GST_TIME_AS_MSECONDS(player->duration), MM_ERROR_INVALID_ARGUMENT);
-
- player->section_repeat = TRUE;
- player->section_repeat_start = start;
- player->section_repeat_end = end;
-
- start_pos = player->section_repeat_start * G_GINT64_CONSTANT(1000000);
- end_pos = player->section_repeat_end * G_GINT64_CONSTANT(1000000);
-
- __mmplayer_set_play_count(player, infinity);
-
- if ((!__gst_seek(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst,
- player->playback_rate,
- GST_FORMAT_TIME,
- (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
- GST_SEEK_TYPE_SET, start_pos,
- GST_SEEK_TYPE_SET, end_pos))) {
- LOGE("failed to activate section repeat\n");
-
- return MM_ERROR_PLAYER_SEEK;
- }
-
- LOGD("succeeded to set section repeat from %d to %d\n",
- player->section_repeat_start, player->section_repeat_end);
-
- MMPLAYER_FLEAVE();
-
- return MM_ERROR_NONE;
-}
-
static int
__mmplayer_set_pcm_extraction(mm_player_t* player)
{
}
int
-_mmplayer_deactivate_section_repeat(MMHandleType hplayer)
-{
- mm_player_t* player = (mm_player_t*)hplayer;
- gint64 cur_pos = 0;
- gint onetime = 1;
-
- MMPLAYER_FENTER();
-
- MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
- player->section_repeat = FALSE;
-
- __mmplayer_set_play_count(player, onetime);
-
- gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &cur_pos);
-
- if ((!__gst_seek(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst,
- 1.0,
- GST_FORMAT_TIME,
- (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
- GST_SEEK_TYPE_SET, cur_pos,
- GST_SEEK_TYPE_SET, player->duration))) {
- LOGE("failed to deactivate section repeat\n");
-
- return MM_ERROR_PLAYER_SEEK;
- }
-
- MMPLAYER_FENTER();
-
- return MM_ERROR_NONE;
-}
-
-int
_mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming)
{
mm_player_t* player = (mm_player_t*)hplayer;
__mmplayer_eos_timer_cb(gpointer u_data)
{
mm_player_t* player = NULL;
+ MMHandleType attrs = 0;
+ int count = 0;
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(u_data, FALSE);
+
player = (mm_player_t*) u_data;
+ attrs = MMPLAYER_GET_ATTRS(player);
- MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
+ mm_attrs_get_int_by_name(attrs, "profile_play_count", &count);
- if (player->play_count > 1) {
+ if (count == -1) {
gint ret_value = 0;
ret_value = __gst_set_position(player, MM_PLAYER_POS_FORMAT_TIME, 0, TRUE);
- if (ret_value == MM_ERROR_NONE) {
- MMHandleType attrs = 0;
- attrs = MMPLAYER_GET_ATTRS(player);
-
- /* we successeded to rewind. update play count and then wait for next EOS */
- player->play_count--;
-
- mm_attrs_set_int_by_name(attrs, "profile_play_count", player->play_count);
- if (mmf_attrs_commit(attrs))
- LOGE("failed to update attributes\n");
- } else {
+ if (ret_value != MM_ERROR_NONE) {
LOGE("seeking to 0 failed in repeat play");
}
} else {
else
result = util_exist_file_path(filepath);
-
if (result != MM_ERROR_NONE) {
LOGE("invalid subtitle path 0x%X", result);
return result; /* file not found or permission denied */