Hi,
in the modified-by-me version of libnemesi I'm using, i've added some code
to
keep the values of first rtp timestamp (and sequence number) announced
during
the PLAY response: mostly the first I needed to drop
packets-before-session-begin
sent me by an Axis encoder.

I know I should use git to post code patches, but I'm blocked by company
firewall, sry

I proceeded this way:

in rtsp.h, when defining rtsp_medium_s, I've added a
    int64_t  rtp_first_timestamp;
//    int64_t first_cseq;


in rtsp_handlers.c, function handle_play_response, BEFORE the original code
(due to the strtok_r),
I've put this ugly block:

    char *prev_tkn, *rtp_info, *step = NULL;
    char *path, *track, *beg, *end, *url, *rtptime/*, *seq*/;

    rtsp_session *rtsp_sess;
    rtsp_medium *rtsp_med;

    // EMILIANO
    if (!(rtsp_sess = get_curr_sess(GCS_CUR_SESS)))
      return 1;

    if ((rtp_info = strstrcase(rtsp_th->in_buffer.data, "RTP-Info")) ==
NULL) {
      nms_printf(NMSML_WARN, "Missing RTP-info header in RTSP-PLAY
response\n");
    } else {

      while(rtp_info[0] != '\n')
      {
        url = track = path = rtptime = /*seq = */NULL;

        // url per il nome traccia
        beg = strstrcase(rtp_info, "url=") + 4;
        end = strpbrk(beg, ",;" RTSP_EL);
        url = (char*)malloc(sizeof(char) * (end - beg + 1));
        strncpy(url, beg, end - beg);
        url[end - beg] = '\0';

        urltokenize(url, NULL, NULL, &path);
        if (path == NULL) path = url;
        for(track = path; track[0] == '/'; track++);
/*
        // seq
        if ((beg = strstrcase(rtp_info, "seq=")) != NULL) {
          beg += 4;
          end = strpbrk(beg, ",;" RTSP_EL);
          seq = (char*)malloc(sizeof(char) * (end - beg + 1));
          strncpy(seq, beg, end - beg);
          seq[end - beg] = '\0';
        } else {
          nms_printf(NMSML_WARN, "Missing SEQ in RTP-Info header\n");
        }
*/
        // rtptime
        if ((beg = strstrcase(rtp_info, "rtptime=")) != NULL) {
          beg += 8;
          end = strpbrk(beg, ",;" RTSP_EL);
          rtptime = (char*)malloc(sizeof(char) * (end - beg + 1));
          strncpy(rtptime, beg, end - beg);
          rtptime[end - beg] = '\0';
        } else {
          nms_printf(NMSML_WARN, "Missing RTPTIME in RTP-Info header\n");
        }

        // cerchiamo il medium ...
        for(rtsp_med = rtsp_sess->media_queue;
            rtsp_med && strcmp(rtsp_med->filename, track) != 0;
            rtsp_med = rtsp_med -> next);
        if (rtsp_med) {
          rtsp_med->rtp_first_timestamp = (rtptime == NULL ? -1 :
(uint32_t)atoll(rtptime));
//           rtsp_med->first_cseq = (seq == NULL ? -1 :
(uint32_t)atoll(seq));
        } else {
          nms_printf(NMSML_ERR, "Track %s not found in media queue\n",
track);
          return 1;
        }

        if (url != path) {
          free(url);
          free(path);
        } else {
          free(url);
        }
        free(rtptime);
//         free(seq);

        rtp_info = end + 1;
      }

    }
    // FINE EMILIANO

as you can see actually i register just the first rtp timestamp, since i
don't need sequence number.

useful ? misplaced ?

regards

Emiliano Leporati
_______________________________________________
LScube-devel mailing list
[email protected]
http://live.polito.it/mailman/listinfo/lscube-devel

Reply via email to