该篇内容简单的将前两篇内容组合在一起,创建了2个线程,分别播放音频和视频。 1 int main(int argc, char * argv[]) 2 { 3 RtspClient Client; 4 pthread_t audio_th; 5 pthread_t video_th; 6 7 if(argc != 2) { 8 cout <>'Usage: ' <>0] <>' ' endl; 9 cout <>'For example: ' endl;10 cout <>0] <>' rtsp://127.0.0.1/ansersion' endl;11 return 1;12 } 13 signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */14 signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */15 rtspClientRequest(&Client, argv[1]);16 av_register_all();17 if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)) {18 fprintf(stderr, 'Could not initialize SDL - %s\n', SDL_GetError());19 Client.DoTEARDOWN();20 exit(1);21 } 22 pthread_create(&audio_th, NULL, audio_thread, (void *)&Client);23 pthread_create(&video_th, NULL, video_thread, (void *)&Client);24 25 pthread_join(audio_th, NULL);26 pthread_join(video_th, NULL);27 Client.DoTEARDOWN();28 29 return 0;30 } 至此,“解码篇”内容告一段落,接下来将介绍myRTSPClient的具体实现,以便可以更好的理解音视频的传输机制。 注: 1, 示例源码编译需要SDL和ffmpeg,具体可参见解码视频的附录二; 2, 博主编译环境为 x86_64位ubuntu 16.04,以供参考。 myRtspClient-1.2.3 ffmpeg-2.8.5 下载源码以及Makefile 编译、配置和运行同上一篇:用ffmpeg解码视频 上一篇 回目录
|