示例#1
0
文件: rtsp.c 项目: clkao/msdl
static void free_rtsp_ctrl_t(struct rtsp_ctrl_t *ctrlt)
{
    if(ctrlt->rtsp_protocol == RTSP_REAL_PROTOCOL) {
	if(ctrlt->rmff_header) {
	    free_rmff_header_t(ctrlt->rmff_header);
	}
    }
    else if(ctrlt->rtsp_protocol == RTSP_WMS_PROTOCOL) {
	if(ctrlt->asf_headerinfo) {
	    free_asf_headerinfo_t(ctrlt->asf_headerinfo);
	}
    }

    if(ctrlt->mrl)   free(ctrlt->mrl);
    if(ctrlt->server) free(ctrlt->server);
    if(ctrlt->session) free(ctrlt->session);
    if(ctrlt->etag)     free(ctrlt->etag);
    if(ctrlt->challenge) free(ctrlt->challenge);
  
    free(ctrlt);
}
示例#2
0
/*
 * send SETUP,SEND_REQUEST,PLAY requests.
 *
 *      return value               1: success
 *                                -1: error
 */
int real_setup_and_get_header(struct stream_t *stream,
			      struct rmff_header_t **rmff_header_ret)
{
    struct stream_ctrl_t *stream_ctrl = stream->stream_ctrl;
    struct rmff_header_t *rmff_header = NULL;
    
    char *description = NULL;
    char *subscribe = NULL;

    /*
      !!!CAUTION!!!
      setting maxbw too high may cause download failure!!
    */
    
    /* don't use this value, its just for choosing highest rate stream */
    if(stream->dlopts->bandwidth) {
	stream_ctrl->bandwidth = stream->dlopts->bandwidth;
    }
    else {
	stream_ctrl->bandwidth = 10485800;
    }


    if(real_rtsp_describe(stream,&description) < 0) {
	goto failed;
    }
    
    /* parse sdp and get information about file to download */
    rmff_header = real_parse_sdp(description,&subscribe,stream_ctrl->bandwidth);
    if(!rmff_header) {
	goto failed;
    }


    display(MSDL_VER,"sdp parse done.\n");

    /* send SETUP request */
    if(real_rtsp_setup(stream,rmff_header) < 0) {
	goto failed;
    }
    
    /* send SET_PARAMETER request to download stream */
    if(real_rtsp_set_parameter(stream,subscribe) < 0) {
	goto failed;
    }
    
    /*  send PLAY request to download stream */
    if(real_rtsp_play(stream) < 0) {
	goto failed;
    }
    
    free(subscribe);
    free(description);
    
    *rmff_header_ret = rmff_header;
    return 1;
  
  failed:
    if(subscribe) free(subscribe);
    if(description) free(description);
    if(rmff_header) free_rmff_header_t(rmff_header);
    *rmff_header_ret = NULL;
    return -1;
}