Example #1
0
static GstStateChangeReturn
gst_aml_vdec_change_state (GstElement * element, GstStateChange transition)
{
  GstStateChangeReturn result = GST_STATE_CHANGE_SUCCESS;
  gint ret = 0;
  GstAmlVdec *amlvdec= GST_AMLVDEC (element);
  GST_ERROR("%s,%d\n",__FUNCTION__,__LINE__);
  g_return_val_if_fail (GST_IS_AMLVDEC (element), GST_STATE_CHANGE_FAILURE);
  switch (transition) {
    case GST_STATE_CHANGE_NULL_TO_READY:
        GST_ERROR("%s,%d\n",__FUNCTION__,__LINE__);
        break;
  		
  case GST_STATE_CHANGE_READY_TO_PAUSED:
        GST_ERROR("%s,%d\n",__FUNCTION__,__LINE__);
        break;
  case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
  	       if (amlvdec->is_paused == TRUE && amlvdec->codec_init_ok) {
                ret=codec_resume (amlvdec->pcodec);
                if (ret != 0) {
                      GST_ERROR("[%s:%d]resume failed!ret=%d\n", __FUNCTION__, __LINE__, ret);
                }else
                amlvdec->is_paused = FALSE;
              }
        GST_ERROR("%s,%d\n",__FUNCTION__,__LINE__);
        break;

        default:
          break;
    }
  result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);

switch (transition) {
	case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
		  GST_ERROR("%s,%d\n",__FUNCTION__,__LINE__);
          if(!amlvdec->is_eos &&  amlvdec->codec_init_ok){ 
                ret=codec_pause(amlvdec->pcodec);
                if (ret != 0) {
                    GST_ERROR("[%s:%d]pause failed!ret=%d\n", __FUNCTION__, __LINE__, ret);
                }else
                    amlvdec->is_paused = TRUE;
            }
            break;
			
        case GST_STATE_CHANGE_PAUSED_TO_READY:
            GST_ERROR("%s,%d\n",__FUNCTION__,__LINE__);
          break;
		  
        case GST_STATE_CHANGE_READY_TO_NULL:
        	        GST_ERROR("%s,%d\n",__FUNCTION__,__LINE__);
            break;
			
        default:
            break;
    }
  GST_ERROR("%s,%d,ret=%d\n", __FUNCTION__,__LINE__,result);
  return result;
}
Example #2
0
static gboolean
gst_aml_vdec_close(GstVideoDecoder * dec)
{
	GstAmlVdec *amlvdec = GST_AMLVDEC(dec);
	gint ret=0;
	GST_ERROR("%s,%d\n",__FUNCTION__,__LINE__);
	stop_eos_task (amlvdec);
	if (amlvdec->codec_init_ok) {
		amlvdec->codec_init_ok = 0;
		if (amlvdec->is_paused == TRUE) {
			ret = codec_resume(amlvdec->pcodec);
			if (ret != 0) {
				GST_ERROR("[%s:%d]resume failed!ret=%d", __FUNCTION__, __LINE__, ret);
			} else
				amlvdec->is_paused = FALSE;
		}
		set_black_policy(1);
		codec_close(amlvdec->pcodec);

		amlvdec->is_headerfeed = FALSE;
		if (amlvdec->input_state) {
			gst_video_codec_state_unref(amlvdec->input_state);
			amlvdec->input_state = NULL;
		}
		
		set_fb0_blank(0);
		set_fb1_blank(0);
//T?		set_display_axis(1);
	}
	if (amlvdec->info) {
			amlvdec->info->finalize(amlvdec->info);
			amlvdec->info = NULL;
		}
#if DEBUG_DUMP
	if (amlvdec->dump_fd > 0) {
		codec_set_dump_fd(NULL, 0);
		close(amlvdec->dump_fd);
	}
#endif
	if (amlvdec->pcodec) {
		g_free(amlvdec->pcodec);
		amlvdec->pcodec = NULL;
	}
	return TRUE;
}
Example #3
0
bool CTsPlayer::Resume()
{
	codec_resume(pcodec);
	return true;
}
Example #4
0
static int player_mate_thread_cmd_proxy(play_para_t *player, struct player_mate *mate)
{
    player_cmd_t *cmd = NULL;
    int ret;
    play_para_t *p_para=player;
    /*
    check the cmd & do for main thread;
    */
      if (p_para->oldcmd.ctrl_cmd == CMD_SEARCH &&
        nextcmd_is_cmd(p_para, CMD_SEARCH) &&
        ((p_para->oldcmdtime >= player_get_systemtime_ms() - 400)) && /*lastcmd is not too old.*/
        ((p_para->stream_type == STREAM_ES && p_para->vcodec != NULL) || /*ES*/
         (p_para->stream_type != STREAM_ES  && p_para->codec && p_para->vstream_info.has_video))) { /*PS,RM,TS*/
        /*if latest cmd and next cmd are all search,we must wait the frame show.*/
        if (p_para->vcodec) {
            ret = codec_get_cntl_state(p_para->vcodec);    /*es*/
        } else {
            ret = codec_get_cntl_state(p_para->codec);    /*not es*/
        }
        if(p_para->avsynctmpchanged == 0) {
            p_para->oldavsyncstate = get_tsync_enable();
        }
        if (p_para->oldavsyncstate == 1) {
            set_tsync_enable(0);
            p_para->avsynctmpchanged = 1;
        }
        if (ret <= 0) {
            return NONO_FLAG;
        }
    }	
    cmd = get_message(player);
    if (!cmd) {
        return 0;    /*no cmds*/
    }

    p_para->oldcmd = *cmd;
    p_para->oldcmdtime = player_get_systemtime_ms();
    log_print("pid[%d]:: [check_flag:%d]cmd=%x set_mode=%x info=%x param=%d fparam=%f\n", p_para->player_id, __LINE__, cmd->ctrl_cmd, cmd->set_mode, cmd->info_cmd, cmd->param, cmd->f_param);
    if (cmd->ctrl_cmd != CMD_SEARCH && p_para->avsynctmpchanged > 0) {
		/*not search now,resore the sync states...*/
		set_tsync_enable(p_para->oldavsyncstate);
		p_para->avsynctmpchanged = 0;
    }	
    check_msg(player,cmd);
    message_free(cmd);
    if(player->playctrl_info.search_flag && !(p_para->pFormatCtx->iformat->flags & AVFMT_NOFILE) && p_para->pFormatCtx->pb!=NULL && p_para->pFormatCtx->pb->local_playback == 0){
        /*in mate thread seek,and interrupt the read thread.
              so we need to ignore the first ffmpeg erros. */
        player->playctrl_info.ignore_ffmpeg_errors=1;	
        player->playctrl_info.temp_interrupt_ffmpeg=1;
        log_print("ffmpeg_interrupt tmped by player mate!\n");
        ffmpeg_interrupt_light(player->thread_mgt.pthread_id);
        codec_resume(player->codec);  /*auto resume on*/
    }
    if (p_para->playctrl_info.search_flag) {
        set_black_policy(0);
    }
    if (p_para->playctrl_info.end_flag) {
        log_print("player_mate: end_flag! \n");
        update_playing_info(p_para);
        update_player_states(p_para, 1);
        return 0;
    }
    if (p_para->playctrl_info.pause_flag) {
        if (get_player_state(p_para) != PLAYER_PAUSE) {
            ret = codec_pause(p_para->codec);
            if (ret != 0) {
                log_error("[%s:%d]pause failed!ret=%d\n", __FUNCTION__, __LINE__, ret);
            }
            set_player_state(p_para, PLAYER_PAUSE);
            update_playing_info(p_para);
            update_player_states(p_para, 1);
        }
        return CONTINUE_FLAG;
    } else {
        if ((get_player_state(p_para) == PLAYER_PAUSE) || (get_player_state(p_para) == PLAYER_SEARCHOK)) {
            ret = codec_resume(p_para->codec);
            if (ret != 0) {
                log_error("[%s:%d]resume failed!ret=%d\n", __FUNCTION__, __LINE__, ret);
            }
            set_player_state(p_para, PLAYER_RUNNING);
            update_playing_info(p_para);
            update_player_states(p_para, 1);
        }
    }
    return 0;
}
Example #5
0
static int player_mate_thread_cmd_proxy(play_para_t *player, struct player_mate *mate)
{
    player_cmd_t *cmd = NULL;
    int ret;
    /*
    check the cmd & do for main thread;
    */
    lock_message_pool(player);
    cmd = peek_message_locked(player);
    if (cmd) {
        mate_print("[MATE]Get cmd-------------------------[%x],[%x]\n", cmd->ctrl_cmd, (CMD_START | CMD_PAUSE | CMD_RESUME | CMD_SWITCH_AID));
        if (((cmd->ctrl_cmd) & (CMD_START | CMD_PAUSE | CMD_RESUME | CMD_SWITCH_AID)) ||
            ((cmd->set_mode) & (CMD_LOOP | CMD_NOLOOP | CMD_EN_AUTOBUF | CMD_SET_AUTOBUF_LEV))) {
            cmd = get_message_locked(player);
        } else {
            cmd = NULL;
        }
    }
    unlock_message_pool(player);
    if (!cmd) {
        return 0;    /*no I can handle cmd*/
    }

    if (cmd->ctrl_cmd & CMD_PAUSE) {
        mate_print("[MATE]Get puase cmd\n");
        if (get_player_state(player) != PLAYER_PAUSE) {
            ret = codec_pause(player->codec);
            if (ret != 0) {
                log_error("[%s:%d]pause failed!ret=%d\n", __FUNCTION__, __LINE__, ret);
            }
            player->playctrl_info.pause_flag = 1;
            set_player_state(player, PLAYER_PAUSE);
            update_playing_info(player);
            update_player_states(player, 1);
        }
    } else if ((cmd->ctrl_cmd & CMD_RESUME) || (cmd->ctrl_cmd & CMD_START)) {
        mate_print("[MATE]Get resume cmd\n");
        if ((get_player_state(player) == PLAYER_PAUSE) || (get_player_state(player) == PLAYER_SEARCHOK)) {
            ret = codec_resume(player->codec);
            if (ret != 0) {
                log_error("[%s:%d]resume failed!ret=%d\n", __FUNCTION__, __LINE__, ret);
            }
            player->playctrl_info.pause_flag = 0;
            set_player_state(player, PLAYER_RUNNING);
            update_playing_info(player);
            update_player_states(player, 1);
        }
    } else if (cmd->ctrl_cmd & CMD_SWITCH_AID) {
        player->playctrl_info.seek_base_audio = 1;
        player->playctrl_info.switch_audio_id = cmd->param;
        set_black_policy(0);
    } else if (cmd->set_mode & CMD_LOOP) {
        player->playctrl_info.loop_flag = 1;
    } else if (cmd->set_mode & CMD_NOLOOP) {
        player->playctrl_info.loop_flag = 0;
    } else if (cmd->set_mode & CMD_EN_AUTOBUF) {
        player->buffering_enable = cmd->param;
    } else if (cmd->set_mode & CMD_SET_AUTOBUF_LEV) {
        player->buffering_threshhold_min = cmd->f_param;
        player->buffering_threshhold_middle = cmd->f_param1;
        player->buffering_threshhold_max = cmd->f_param2;
    }
    message_free(cmd);
    return 0;
}