Esempio n. 1
0
int main(int argc, char **argv)
{
	int flags;
	VideoState *is;
	av_register_all();

	flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
	if (SDL_Init(flags)) {
		av_log(NULL, AV_LOG_FATAL, "Could not initialize SDL - %s\n", SDL_GetError());
		exit(1);
	}


	screen = SDL_SetVideoMode(640, 480, 0, 0);
	screen_mutex = SDL_CreateMutex();

	/* ffplay.c 把下述内容封装到了函数 stream_open() 里 */
	is = (VideoState*)av_mallocz(sizeof(VideoState));
	av_strlcpy(is->filename, argv[1], sizeof(is->filename));
	frame_queue_init(&is->pictq, &is->videoq);
	frame_queue_init(&is->sampq, &is->audioq);
	packet_queue_init(&is->videoq);
	packet_queue_init(&is->audioq);
	is->read_tid = SDL_CreateThread(read_thread, is); /* 开启读包线程,里面会再开启音频解码线程、音频播放线程、视频解码线程*/

	/* event_loop 目前只处理退出和 allocate Pictur*/
	event_loop(is);
	return 0;
}
Esempio n. 2
0
int video_init( void ) {
    avcodec_register_all();
    av_register_all();

    conv_frame = avcodec_alloc_frame();

    if( !conv_frame ) {
        fprintf( stderr, "Warning: Couldn't allocate video conversion frame\n" );
        return -1;
    }

    packet_queue_init( &audio_queue );
    frame_queue_init( &video_queue );

    url_set_interrupt_cb( video_stopped );

    return 0;
}