iOS ijkplayer stream_open 函数详解

来源:互联网 发布:windows update打不开 编辑:程序博客网 时间:2024/05/29 17:27


创建存放video/audio解码前数据的videoq/audioq创建存放video/audio解码后数据的pictq/sampq/* start video display */    if (frame_queue_init(&is->pictq, &is->videoq, ffp->pictq_size, 1) < 0)        goto fail;    if (frame_queue_init(&is->subpq, &is->subtitleq, SUBPICTURE_QUEUE_SIZE, 0) < 0)        goto fail;    if (frame_queue_init(&is->sampq, &is->audioq, SAMPLE_QUEUE_SIZE, 1) < 0)        goto fail;FrameQueue video/audio解码后数据的pictq/sampqPacketQueue *pktq video/audio解码前数据的videoq/audioqstatic int frame_queue_init(FrameQueue *f, PacketQueue *pktq, int max_size, int keep_last)static VideoState *stream_open(FFPlayer *ffp, const char *filename, AVInputFormat *iformat){    assert(!ffp->is);    VideoState *is;    is = av_mallocz(sizeof(VideoState));    if (!is)        return NULL;    is->filename = av_strdup(filename);    if (!is->filename)        goto fail;    is->iformat = iformat;    is->ytop    = 0;    is->xleft   = 0;#if defined(__ANDROID__)    if (ffp->soundtouch_enable) {        is->handle = ijk_soundtouch_create();    }#endif    /* start video display */    if (frame_queue_init(&is->pictq, &is->videoq, ffp->pictq_size, 1) < 0)        goto fail;    if (frame_queue_init(&is->subpq, &is->subtitleq, SUBPICTURE_QUEUE_SIZE, 0) < 0)        goto fail;    if (frame_queue_init(&is->sampq, &is->audioq, SAMPLE_QUEUE_SIZE, 1) < 0)        goto fail;    if (packet_queue_init(&is->videoq) < 0 ||        packet_queue_init(&is->audioq) < 0 ||        packet_queue_init(&is->subtitleq) < 0)        goto fail;    if (!(is->continue_read_thread = SDL_CreateCond())) {        av_log(NULL, AV_LOG_FATAL, "SDL_CreateCond(): %s\n", SDL_GetError());        goto fail;    }    if (!(is->video_accurate_seek_cond = SDL_CreateCond())) {        av_log(NULL, AV_LOG_FATAL, "SDL_CreateCond(): %s\n", SDL_GetError());        ffp->enable_accurate_seek = 0;    }    if (!(is->audio_accurate_seek_cond = SDL_CreateCond())) {        av_log(NULL, AV_LOG_FATAL, "SDL_CreateCond(): %s\n", SDL_GetError());        ffp->enable_accurate_seek = 0;    }    init_clock(&is->vidclk, &is->videoq.serial);    init_clock(&is->audclk, &is->audioq.serial);    init_clock(&is->extclk, &is->extclk.serial);    is->audio_clock_serial = -1;    is->audio_volume = SDL_MIX_MAXVOLUME;    is->muted = 0;    is->av_sync_type = ffp->av_sync_type;    is->play_mutex = SDL_CreateMutex();    is->accurate_seek_mutex = SDL_CreateMutex();    ffp->is = is;    is->pause_req = !ffp->start_on_prepared;    is->video_refresh_tid = SDL_CreateThreadEx(&is->_video_refresh_tid, video_refresh_thread, ffp, "ff_vout");    if (!is->video_refresh_tid) {        av_freep(&ffp->is);        return NULL;    }    is->read_tid = SDL_CreateThreadEx(&is->_read_tid, read_thread, ffp, "ff_read");    if (!is->read_tid) {        av_log(NULL, AV_LOG_FATAL, "SDL_CreateThread(): %s\n", SDL_GetError());fail:        is->abort_request = true;        if (is->video_refresh_tid)            SDL_WaitThread(is->video_refresh_tid, NULL);        stream_close(ffp);        return NULL;    }    return is;}


原创粉丝点击