1

我应该使用 VLC 库在 c 编程中编写 RTSP 客户端,对此我有一些疑问:

  1. 我在 VLC 库中没有找到任何已经发送 RTSP SETUP 请求的函数,我应该从头开始编写它吗?
  2. 当我发送 RTSP SETUP 请求时,我必须为 RTP 和 RTCP 打开 2 个套接字以将其端口号发送到 live555 媒体服务器以通过这些端口接收数据,是否需要为 UDP 打开另一个套接字以接收 RTSP SETUP 的响应/PLAY/PAUSE/STOP 请求控制传输数据过程?
  3. 当我想在应用层暂停传输数据过程时,我应该向服务器发送RTSP PAUSE请求并向播放器发送PAUSE请求以暂时停止传输数据过程,但我不知道VLC库中的哪些函数用于此目的,你能告诉我这些功能是什么吗?

谢谢你。

4

1 回答 1

1

正如feepk 在评论中所说,您不需要手动进行任何RTSP 设置,因为VLC 使用live555 库为您完成了这项工作。您可以使用 libvlc_media_new_location 函数打开 RTSP 连接,然后传递给您的媒体播放器实例。

例如:

// You must create an instance of the VLC Library
libvlc_instance_t * vlc;
// You need a player to play media
libvlc_media_player_t *mediaPlayer;
// Media object to play.
libvlc_media_t *media;

// Configure options for this instance of VLC (global settings).
// See VLC command line documentation for options.
std::vector<const char*> options;
std::vector<const char*>::iterator option;
// Load the VLC engine
vlc = libvlc_new (int(options.size()), options.data());

// Create a media item from URL
media = libvlc_media_new_location (vlc, "RTSP_URL_HERE");
mediaPlayer = libvlc_media_player_new_from_media (media);
于 2015-07-07T03:17:30.460 回答