Example #1
0
static int rtsp_get_answers(rtsp_t *s) {

  char *answer=NULL;
  unsigned int answer_seq;
  char **answer_ptr=s->answers;
  int code;
  int ans_count = 0;

  answer=rtsp_get(s);
  if (!answer)
    return 0;
  code=rtsp_get_code(s, answer);
  free(answer);

  rtsp_free_answers(s);

  do { /* while we get answer lines */

    answer=rtsp_get(s);
    if (!answer)
      return 0;

    if (!strncasecmp(answer,"Cseq: ",6)) {
      sscanf(answer+6,"%u",&answer_seq);
      if (s->cseq != answer_seq) {
        lprintf("warning: Cseq mismatch. got %u, assumed %u", answer_seq, s->cseq);

        s->cseq=answer_seq;
      }
    }
    if (!strncasecmp(answer,"Server: ",8)) {
      free(s->server);
      s->server = strdup(answer + 8);
    }
    if (!strncasecmp(answer,"Session: ",9)) {
      char *tmp = answer + 9;
      if (s->session) {
        if (strcmp(tmp, s->session)) {
          xprintf(s->stream->xine, XINE_VERBOSITY_DEBUG,
		  "rtsp: warning: setting NEW session: %s\n", tmp);
          s->session=strdup(tmp);
        }
      } else
      {
        lprintf("setting session id to: %s\n", tmp);

        s->session=strdup(tmp);
      }
    }
    *answer_ptr=answer;
    answer_ptr++;
  } while ((strlen(answer)!=0) && (++ans_count < MAX_FIELDS));

  s->cseq++;

  *answer_ptr=NULL;
  rtsp_schedule_standard(s);

  return code;
}
Example #2
0
static int rtsp_get_answers( rtsp_client_t *rtsp )
{
    char *answer = NULL;
    unsigned int answer_seq;
    char **answer_ptr = rtsp->p_private->answers;
    int code;
    int ans_count = 0;

    answer = rtsp_get( rtsp );
    if( !answer ) return 0;
    code = rtsp_get_status_code( rtsp, answer );
    free( answer );

    rtsp_free_answers( rtsp );

    do { /* while we get answer lines */

      answer = rtsp_get( rtsp );
      if( !answer ) return 0;

      if( !strncasecmp( answer, "CSeq:", 5 ) )
      {
          sscanf( answer, "%*s %u", &answer_seq );
          if( rtsp->p_private->cseq != answer_seq )
          {
            //fprintf( stderr, "warning: Cseq mismatch. got %u, assumed %u",
            //       answer_seq, rtsp->p_private->cseq );

              rtsp->p_private->cseq = answer_seq;
          }
      }
      if( !strncasecmp( answer, "Server:", 7 ) )
      {
          char *buf = xmalloc( strlen(answer) );
          sscanf( answer, "%*s %s", buf );
          free( rtsp->p_private->server );
          rtsp->p_private->server = buf;
      }
      if( !strncasecmp( answer, "Session:", 8 ) )
      {
          char *buf = xmalloc( strlen(answer) );
          sscanf( answer, "%*s %s", buf );
          if( rtsp->p_private->session )
          {
              if( strcmp( buf, rtsp->p_private->session ) )
              {
                  //fprintf( stderr,
                  //         "rtsp: warning: setting NEW session: %s\n", buf );
                  free( rtsp->p_private->session );
                  rtsp->p_private->session = strdup( buf );
              }
          }
          else
          {
              //fprintf( stderr, "setting session id to: %s\n", buf );
              rtsp->p_private->session = strdup( buf );
          }
          free( buf );
      }

      *answer_ptr = answer;
      answer_ptr++;
    } while( (strlen(answer) != 0) && (++ans_count < MAX_FIELDS) );

    rtsp->p_private->cseq++;

    *answer_ptr = NULL;
    rtsp_schedule_standard( rtsp );

    return code;
}
Example #3
0
static int rtsp_get_answers( rtsp_client_t *rtsp )
{
    access_t *p_access = (access_t*)rtsp->p_userdata;
    char *answer = NULL;
    unsigned int answer_seq;
    char **answer_ptr = rtsp->p_private->answers;
    int code;
    int ans_count = 0;

    answer = rtsp_get( rtsp );
    if( !answer ) return 0;
    code = rtsp_get_status_code( rtsp, answer );
    free( answer );

    rtsp_free_answers( rtsp );

    do { /* while we get answer lines */

      answer = rtsp_get( rtsp );
      if( !answer ) return 0;

      if( !strncasecmp( answer, "CSeq:", 5 ) )
      {
          if (sscanf( answer, "%*s %u", &answer_seq ) == 1) {
              if( rtsp->p_private->cseq != answer_seq )
              {
                msg_Warn (p_access, "Cseq mismatch, got %u, assumed %u", answer_seq, rtsp->p_private->cseq);
                rtsp->p_private->cseq = answer_seq;
              }
          } else {
            msg_Warn (p_access, "remote server sent CSeq without payload, ignoring.");
          }
      }
      if( !strncasecmp( answer, "Server:", 7 ) )
      {
          char *buf = xmalloc( strlen(answer) );
          if (sscanf( answer, "%*s %s", buf ) == 1) {
            free( rtsp->p_private->server );
            rtsp->p_private->server = buf;
          } else {
            msg_Warn(p_access, "remote server sent Server without payload, ignoring.");
          }
      }
      if( !strncasecmp( answer, "Session:", 8 ) )
      {
          char *buf = xmalloc( strlen(answer) );
          if (sscanf( answer, "%*s %s", buf ) == 1) { // TODO: ignore attributes "Session: ${session-id};${attribute=value...}"
              if( rtsp->p_private->session )
              {
                  if( strcmp( buf, rtsp->p_private->session ) )
                  {
                      msg_Warn (p_access, "setting NEW session: %s", buf);
                      free( rtsp->p_private->session );
                      rtsp->p_private->session = strdup( buf );
                  }
              }
              else
              {
                  msg_Dbg (p_access, "session id: '%s'", buf);
                  rtsp->p_private->session = strdup( buf );
              }
          } else {
            msg_Warn(p_access, "remote server sent Session without payload, ignoring.");
          }
          free( buf );
      }

      *answer_ptr = answer;
      answer_ptr++;
    } while( (strlen(answer) != 0) && (++ans_count < MAX_FIELDS) );

    rtsp->p_private->cseq++;

    if (ans_count != MAX_FIELDS) {
      *answer_ptr = NULL;
    }

    rtsp_schedule_standard( rtsp );

    return code;
}