Exemplo n.º 1
0
void process_tcp_packet(struct packet * pkt) {
  struct stream * s;
  /* does a stream already exist? */
  if ((s = find_stream(pkt->ip_header->ip_src,pkt->tcp_header->th_sport,pkt->ip_header->ip_dst,pkt->tcp_header->th_dport))==NULL) {
    /* no -> create one */
    s = create_stream(pkt->ip_header->ip_src,pkt->tcp_header->th_sport,pkt->ip_header->ip_dst,pkt->tcp_header->th_dport);
    /* set a module for the newly created stream */
    set_tcp_module(s,find_tcp_module(pkt->ip_header->ip_src,pkt->tcp_header->th_sport,pkt->ip_header->ip_dst,pkt->tcp_header->th_dport));
  }

  if (!stream_evaluated(s)) {
    stream_add_packet(s,pkt);
    if (stream_client_closed(s) && stream_server_closed(s)) {
      stream_set_bad(s);
    } else {
      stream_try_evaluate(s);
    }

    if (stream_evaluated(s)) {
      stream_output_all(s);
    }

  } else {
    do_output_packet(s,pkt);
  }

  remove_old_streams();
}
Exemplo n.º 2
0
static int demux_rtp_fill_buffer(demuxer_t* demuxer, demux_stream_t* ds)
{
    Nemesi_DemuxerStreamData * ndsd = demuxer->priv;
    Nemesi_SessionType stype;
    rtp_ssrc * ssrc;
    rtp_frame fr;

    if ( (!ndsd->rtsp->rtsp_queue) || (demuxer->stream->eof) ) {
        mp_msg(MSGT_DEMUX, MSGL_INFO, "End of Stream...\n");
        demuxer->stream->eof = 1;
        return 0;
    }

    memset(&fr, 0, sizeof(fr));

    stype = DS_TO_STYPE(demuxer, ds);
    if ( (ssrc = wait_for_packets(ndsd, stype)) == NULL ) {
        mp_msg(MSGT_DEMUX, MSGL_INFO, "Bye...\n");
        demuxer->stream->eof = 1;
        return 0;
    }

    if(!get_data_for_session(ndsd, stype, ssrc, &fr))
        stream_add_packet(ndsd, stype, ds, &fr);
    else {
        stype = INVERT_STYPE(stype);

        //Must check if we actually have a stream of the other type
        if (!ndsd->session[stype])
            return 1;

        ds = STYPE_TO_DS(demuxer, stype);
        ssrc = wait_for_packets(ndsd, stype);

        if(!get_data_for_session(ndsd, stype, ssrc, &fr))
            stream_add_packet(ndsd, stype, ds, &fr);
    }

    return 1;
}