/* --------------------------------------------------------------------------*/
int player_start(play_control_t *ctrl_p, unsigned long  priv)
{
    int ret;
    int pid = -1;
    play_para_t *p_para;
    //char stb_source[32];

    update_loglevel_setting();
    print_version_info();
    log_print("[player_start:enter]p=%p black=%d\n", ctrl_p, get_black_policy());

    if (ctrl_p == NULL) {
        return PLAYER_EMPTY_P;
    }

    /*keep last frame displaying --default*/
    set_black_policy(0);
    /* if not set keep last frame, or change file playback, clear display last frame */
    if (!ctrl_p->displast_frame) {
        set_black_policy(1);
    } else if (!check_file_same(ctrl_p->file_name)) {
        set_black_policy(1);
    }

    pid = player_request_pid();
    if (pid < 0) {
        return PLAYER_NOT_VALID_PID;
    }

    p_para = MALLOC(sizeof(play_para_t));
    if (p_para == NULL) {
        return PLAYER_NOMEM;
    }

    MEMSET(p_para, 0, sizeof(play_para_t));

    /* init time_point to a invalid value */
    p_para->playctrl_info.time_point = -1;

    player_init_pid_data(pid, p_para);

    message_pool_init(p_para);

    p_para->start_param = ctrl_p;
    p_para->player_id = pid;
    p_para->extern_priv = priv;
    log_debug1("[player_start]player_para=%p,start_param=%p pid=%d\n", p_para, p_para->start_param, pid);

    ret = player_thread_create(p_para) ;
    if (ret != PLAYER_SUCCESS) {
        FREE(p_para);
        player_release_pid(pid);
        return PLAYER_CAN_NOT_CREAT_THREADS;
    }
    log_print("[player_start:exit]pid = %d \n", pid);

    return pid;
}
Exemplo n.º 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;
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
0
static gboolean
gst_amlvdec_sink_event  (GstVideoDecoder * dec, GstEvent * event)
{
    gboolean ret = TRUE;
     GstAmlVdec *amlvdec = GST_AMLVDEC(dec);	
     GST_ERROR_OBJECT (amlvdec, "Got %s event on sink pad", GST_EVENT_TYPE_NAME (event));
    switch (GST_EVENT_TYPE (event)) {
      /*  case GST_EVENT_NEWSEGMENT:
        {
            gboolean update;
            GstFormat format;
            gdouble rate, arate;
            gint64 start, stop, time;
						
						stop_eos_task (amlvdec);
            gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format, &start, &stop, &time);

            if (format != GST_FORMAT_TIME)
                goto newseg_wrong_format;
            amlvdec_forward_process(amlvdec, update, rate, format, start, stop, time);
            gst_segment_set_newsegment_full (&amlvdec->segment, update, rate, arate, format, start, stop, time);

            GST_DEBUG_OBJECT (amlvdec,"Pushing newseg rate %g, applied rate %g, format %d, start %"
                G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT ", pos %" G_GINT64_FORMAT,
                rate, arate, format, start, stop, time);

            ret = gst_pad_push_event (amlvdec->srcpad, event);
            break;
        }*/
		
        case GST_EVENT_FLUSH_START:
            
            if(amlvdec->codec_init_ok){
                set_black_policy(0);
            }
            ret = TRUE;
            break;
	  
        case GST_EVENT_FLUSH_STOP:
        {
        		stop_eos_task (amlvdec);
            if(amlvdec->codec_init_ok){
                gint res = -1;
                res = codec_reset(amlvdec->pcodec);
                if (res < 0) {
                    GST_ERROR("reset vcodec failed, res= %x\n", res);
                    return FALSE;
                }            
                amlvdec->is_headerfeed = FALSE; 
            }
            GST_WARNING("vformat:%d\n", amlvdec->pcodec->video_type);          
            break;
        } 
		
        case GST_EVENT_EOS:
            GST_WARNING("get GST_EVENT_EOS,check for video end\n");
            if(amlvdec->codec_init_ok)	{
			start_eos_task(amlvdec);	
                amlvdec->is_eos = TRUE;
            }
                
     
            ret = TRUE;
            break;
		 
        default:           
            break;
    }

done:
     ret = GST_VIDEO_DECODER_CLASS (parent_class)->sink_event (amlvdec, event);

    return ret;
}