コード例 #1
0
void
rtsp_handle_options_request(RTSP_Client *client, RTSP_Ps *state)
{
	GstRTSPMethod options;
	gchar *str;

	rtsp_client_remove_dead_session(client);
	options = GST_RTSP_DESCRIBE |
		GST_RTSP_OPTIONS |
		GST_RTSP_PAUSE |
		GST_RTSP_PLAY |
		GST_RTSP_SETUP |
		GST_RTSP_GET_PARAMETER | GST_RTSP_SET_PARAMETER | GST_RTSP_TEARDOWN;

	str = gst_rtsp_options_as_text(options);

	gst_rtsp_message_init_response(
		state->response, 
		GST_RTSP_STS_OK,
		gst_rtsp_status_as_text(GST_RTSP_STS_OK),
		state->request
	);

	gst_rtsp_message_add_header(state->response, GST_RTSP_HDR_PUBLIC, str);
	g_free(str);

	rtsp_client_send_response(client, NULL, state->response);
}
コード例 #2
0
ファイル: nmp_dev_rtsp.c プロジェクト: dulton/nampu
static __inline__ void
nmp_rtsp_device_send_generic_response(NmpMediaDevice *device,
	GstRTSPStatusCode code, NmpRtspState *state)
{
	gst_rtsp_message_init_response(state->response, code,
		gst_rtsp_status_as_text(code), state->request);

	nmp_rtsp_device_send_response(device, state->response);
}
コード例 #3
0
/**
 * gst_rtsp_message_init_response:
 * @msg: a #GstRTSPMessage
 * @code: the status code
 * @reason: (transfer none) (allow-none): the status reason or %NULL
 * @request: (transfer none) (allow-none): the request that triggered the response or %NULL
 *
 * Initialize @msg with @code and @reason.
 *
 * When @reason is #NULL, the default reason for @code will be used.
 *
 * When @request is not #NULL, the relevant headers will be copied to the new
 * response message.
 *
 * Returns: a #GstRTSPResult.
 */
GstRTSPResult
gst_rtsp_message_init_response (GstRTSPMessage * msg, GstRTSPStatusCode code,
    const gchar * reason, const GstRTSPMessage * request)
{
  g_return_val_if_fail (msg != NULL, GST_RTSP_EINVAL);

  gst_rtsp_message_unset (msg);

  if (reason == NULL)
    reason = gst_rtsp_status_as_text (code);

  msg->type = GST_RTSP_MESSAGE_RESPONSE;
  msg->type_data.response.code = code;
  msg->type_data.response.reason = g_strdup (reason);
  msg->type_data.response.version = GST_RTSP_VERSION_1_0;
  msg->hdr_fields = g_array_new (FALSE, FALSE, sizeof (RTSPKeyValue));

  if (request) {
    if (request->type == GST_RTSP_MESSAGE_HTTP_REQUEST) {
      msg->type = GST_RTSP_MESSAGE_HTTP_RESPONSE;
      if (request->type_data.request.version != GST_RTSP_VERSION_INVALID)
        msg->type_data.response.version = request->type_data.request.version;
      else
        msg->type_data.response.version = GST_RTSP_VERSION_1_1;
    } else {
      gchar *header;

      /* copy CSEQ */
      if (gst_rtsp_message_get_header (request, GST_RTSP_HDR_CSEQ, &header,
              0) == GST_RTSP_OK) {
        gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CSEQ, header);
      }

      /* copy session id */
      if (gst_rtsp_message_get_header (request, GST_RTSP_HDR_SESSION, &header,
              0) == GST_RTSP_OK) {
        char *pos;

        header = g_strdup (header);
        if ((pos = strchr (header, ';'))) {
          *pos = '\0';
        }
        g_strchomp (header);
        gst_rtsp_message_take_header (msg, GST_RTSP_HDR_SESSION, header);
      }

      /* FIXME copy more headers? */
    }
  }

  return GST_RTSP_OK;
}
コード例 #4
0
/**
 * gst_rtsp_params_get:
 * @client: a #GstRTSPClient
 * @ctx: a #GstRTSPContext
 *
 * Get parameters (not implemented yet)
 *
 * Returns: a #GstRTSPResult
 */
GstRTSPResult
gst_rtsp_params_get (GstRTSPClient * client, GstRTSPContext * ctx)
{
  GstRTSPStatusCode code;

  /* FIXME, actually parse the request based on the mime type and try to repond
   * with a list of the parameters */
  code = GST_RTSP_STS_PARAMETER_NOT_UNDERSTOOD;

  gst_rtsp_message_init_response (ctx->response, code,
      gst_rtsp_status_as_text (code), ctx->request);

  return GST_RTSP_OK;
}
コード例 #5
0
ファイル: nmp_dev_rtsp.c プロジェクト: dulton/nampu
static __inline__ void
nmp_rtsp_give_options_response(NmpMediaDevice *device, 
	NmpRtspState *state, GstRTSPStatusCode code)
{
	GstRTSPMethod options;
	gchar *str;

	if (code == GST_RTSP_STS_OK)
	{
		options = GST_RTSP_OPTIONS | GST_RTSP_TEARDOWN;
		str = gst_rtsp_options_as_text(options);
		gst_rtsp_message_init_response(state->response, GST_RTSP_STS_OK,
	 		gst_rtsp_status_as_text(GST_RTSP_STS_OK), state->request);
		gst_rtsp_message_add_header(state->response, GST_RTSP_HDR_PUBLIC, str);
		g_free(str);
		nmp_rtsp_device_send_response(device, state->response);	
	}
	else
	{
		nmp_rtsp_device_send_generic_response(device, code, state);
	}
}