static int rtsp_send_request( rtsp_client_t *rtsp, const char *psz_type, const char *psz_what ) { char **ppsz_payload = rtsp->p_private->scheduled; char *psz_buffer; int i_ret; psz_buffer = xmalloc( strlen(psz_type) + strlen(psz_what) + sizeof("RTSP/1.0") + 2 ); sprintf( psz_buffer, "%s %s %s", psz_type, psz_what, "RTSP/1.0" ); i_ret = rtsp_put( rtsp, psz_buffer ); free( psz_buffer ); if( ppsz_payload ) while( *ppsz_payload ) { rtsp_put( rtsp, *ppsz_payload ); ppsz_payload++; } rtsp_put( rtsp, "" ); rtsp_unschedule_all( rtsp ); return i_ret; }
static int rtsp_send_request( rtsp_client_t *rtsp, const char *psz_type, const char *psz_what ) { char **ppsz_payload = rtsp->p_private->scheduled; char *psz_buffer; int i_ret; psz_buffer =(char*) malloc( strlen(psz_type) + strlen(psz_what) + sizeof("RTSP/1.0") + 2 ); sprintf( psz_buffer, "%s %s %s", psz_type, psz_what, "RTSP/1.0" ); i_ret = rtsp_put( rtsp, psz_buffer ); free( psz_buffer ); if( ppsz_payload ){ PRINTF("rtsp_send_request:pp sz_payload = %s\n",*ppsz_payload); while( *ppsz_payload ) { rtsp_put( rtsp, *ppsz_payload ); ppsz_payload++; } } if(rtsp->p_private->user_agent != NULL && strlen(rtsp->p_private->user_agent) != 0) rtsp_put(rtsp,rtsp->p_private->user_agent); rtsp_put( rtsp, "" ); rtsp_unschedule_all( rtsp ); PRINTF("rtsp_send_request:rtsp_send_request END\n"); return i_ret; }
static int rtsp_send_request( rtsp_client_t *rtsp, const char *psz_type, const char *psz_what ) { char **ppsz_payload; char *psz_buffer; int i_ret, i; if (rtsp->p_private == NULL) return -1; ppsz_payload = rtsp->p_private->scheduled; psz_buffer = xmalloc( strlen(psz_type) + strlen(psz_what) + sizeof("RTSP/1.0") + 2 ); sprintf( psz_buffer, "%s %s %s", psz_type, psz_what, "RTSP/1.0" ); i_ret = rtsp_put( rtsp, psz_buffer ); free( psz_buffer ); for (i = 0; i < MAX_FIELDS; ++i) { if (!ppsz_payload[i]) break; rtsp_put (rtsp, ppsz_payload[i]); } rtsp_put( rtsp, "" ); rtsp_unschedule_all( rtsp ); return i_ret; }
int rtsp_send_ok(rtsp_t *s) { char cseq[16]; rtsp_put(s, "RTSP/1.0 200 OK"); sprintf(cseq,"CSeq: %u", s->cseq); rtsp_put(s, cseq); rtsp_put(s, ""); return 0; }
int rtsp_send_ok( rtsp_client_t *rtsp ) { char cseq[sizeof("CSeq: ") + 3 * sizeof(int)]; rtsp_put( rtsp, "RTSP/1.0 200 OK" ); sprintf( cseq, "CSeq: %u", rtsp->p_private->cseq ); rtsp_put( rtsp, cseq ); rtsp_put( rtsp, "" ); return 0; }
int rtsp_read_data( rtsp_client_t *rtsp, uint8_t *buffer, unsigned int size ) { int i, seq; if( size >= 4 ) { i = rtsp->pf_read( rtsp->p_userdata, (uint8_t*)buffer, (unsigned int) 4 ); if( i < 4 ) return i; if( buffer[0]=='S' && buffer[1]=='E' && buffer[2]=='T' && buffer[3]=='_' ) { char *rest = rtsp_get( rtsp ); if( !rest ) return -1; seq = -1; do { free( rest ); rest = rtsp_get( rtsp ); if( !rest ) return -1; if( !strncasecmp( rest, "CSeq:", 5 ) ) sscanf( rest, "%*s %u", &seq ); } while( *rest ); free( rest ); if( seq < 0 ) { //fprintf(stderr, "warning: cseq not recognized!\n"); seq = 1; } /* lets make the server happy */ rtsp_put( rtsp, "RTSP/1.0 451 Parameter Not Understood" ); rest = xmalloc(sizeof("Cseq: ") + 3 * sizeof(int)); sprintf( rest,"CSeq: %u", seq ); rtsp_put( rtsp, rest ); rtsp_put( rtsp, "" ); free( rest ); i = rtsp->pf_read( rtsp->p_userdata, (unsigned char*)buffer, size ); } else { i = rtsp->pf_read( rtsp->p_userdata, (unsigned char*)buffer + 4, size - 4 ); i += 4; } } else i = rtsp->pf_read( rtsp->p_userdata, (unsigned char*)buffer, size ); //fprintf( stderr, "<< %d of %d bytes\n", i, size ); return i; }
int rtsp_read_data(rtsp_t *s, void *buffer_gen, unsigned int size) { uint8_t *buffer = buffer_gen; int i,seq; if (size>=4) { i=_x_io_tcp_read(s->stream, s->s, buffer, 4); if (i<4) return i; if ((buffer[0]=='S')&&(buffer[1]=='E')&&(buffer[2]=='T')&&(buffer[3]=='_')) { char *rest=rtsp_get(s); if (!rest) return -1; seq=-1; do { free(rest); rest=rtsp_get(s); if (!rest) return -1; if (!strncasecmp(rest,"Cseq:",5)) sscanf(rest,"%*s %u",&seq); } while (strlen(rest)!=0); free(rest); if (seq<0) { lprintf("warning: cseq not recognized!\n"); seq=1; } /* lets make the server happy */ rtsp_put(s, "RTSP/1.0 451 Parameter Not Understood"); rest = _x_asprintf("CSeq: %u", seq); rtsp_put(s, rest); free(rest); rtsp_put(s, ""); i=_x_io_tcp_read(s->stream, s->s, buffer, size); } else { i=_x_io_tcp_read(s->stream, s->s, buffer+4, size-4); i+=4; } } else i=_x_io_tcp_read(s->stream, s->s, buffer, size); lprintf("<< %d of %d bytes\n", i, size); return i; }
static void rtsp_send_request(rtsp_t *s, const char *type, const char *what) { char **payload=s->scheduled; char *buf; buf = _x_asprintf("%s %s %s",type, what, rtsp_protocol_version); rtsp_put(s,buf); if (s->auth) { rtsp_put(s, s->auth); } if (payload) while (*payload) { rtsp_put(s,*payload); payload++; } rtsp_put(s,""); rtsp_unschedule_all(s); }