gst-rtsp-server实现的rtsp服务器自定义sdp

在使用gst-rtsp-server开发rtsp 服务器时,有时候在服务端收到DESCRIBE命令之后,返回给客户端的sdp,需要进行定制。

但是,gst-rtsp-server并没有在发送sdp给客户端之前,给上层应用更改sdp信息的接口。

怎么办呢?

我们先看看gst-rtsp-server的源码中,从收到客户端的命令请求,到最终发送出去sdp信息,到底是怎么做的。

下面以gst-rtsp-server-1.10.5版本为例,其它更高版本实现差异并不大。

源码中如何发送sdp

gst-rtsp-server监听以后,每一个客户端连接上来,会挂接一个GstRTSPClient。

对这个GstRtspClient的挂接过程如下:

guint  
gst_rtsp_client_attach (GstRTSPClient * client, GMainContext * context)  
{  
  GstRTSPClientPrivate *priv;  
  guint res;  
  
  g_return_val_if_fail (GST_IS_RTSP_CLIENT (client), 0);  
  priv = client->priv;  
  g_return_val_if_fail (priv->connection != NULL, 0);  
  g_return_val_if_fail (priv->watch == NULL, 0);  
  
  /* make sure noone will free the context before the watch is destroyed */  
  priv->watch_context = g_main_context_ref (context);  
  
  /* create watch for the connection and attach */  
  priv->watch = gst_rtsp_watch_new (priv->connection, &watch_funcs,  
      g_object_ref (client), (GDestroyNotify) client_watch_notify);  
  gst_rtsp_client_set_send_func (client, do_send_message, priv->watch,  
      (GDestroyNotify) gst_rtsp_watch_unref);  
  
  gst_rtsp_watch_set_send_backlog (priv->watch, 0, WATCH_BACKLOG_SIZE);  
  
  GST_INFO ("client %p: attaching to context %p", client, context);  
  res = gst_rtsp_watch_attach (priv->watch, context);  
  
  return res;  
}

我们看到,在这个GstRTSPClient的Connection上,加了一个回调函数结构watch_funcs。

watch_funcs

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值