Revision accc248f

View differences:

libavformat/rdt.c
34 34
#include "rm.h"
35 35
#include "internal.h"
36 36

  
37
struct RDTDemuxContext {
38
    AVFormatContext *ic;
39
    AVStream *st;
40
    void *dynamic_protocol_context;
41
    DynamicPayloadPacketHandlerProc parse_packet;
42
    uint32_t prev_sn, prev_ts;
43
};
44

  
45
RDTDemuxContext *
46
ff_rdt_parse_open(AVFormatContext *ic, AVStream *st,
47
                  void *priv_data, RTPDynamicProtocolHandler *handler)
48
{
49
    RDTDemuxContext *s = av_mallocz(sizeof(RDTDemuxContext));
50
    if (!s)
51
        return NULL;
52

  
53
    s->ic = ic;
54
    s->st = st;
55
    s->prev_sn = -1;
56
    s->prev_ts = -1;
57
    s->parse_packet = handler->parse_packet;
58
    s->dynamic_protocol_context = priv_data;
59

  
60
    return s;
61
}
62

  
63
void
64
ff_rdt_parse_close(RDTDemuxContext *s)
65
{
66
    av_free(s);
67
}
68

  
37 69
struct PayloadContext {
38 70
    AVFormatContext *rmctx;
39 71
    uint8_t *mlti_data;
40 72
    unsigned int mlti_data_size;
41
    uint32_t prev_sn, prev_ts;
42 73
    char buffer[RTP_MAX_PACKET_LENGTH + FF_INPUT_BUFFER_PADDING_SIZE];
43 74
};
44 75

  
......
202 233
}
203 234

  
204 235
int
205
ff_rdt_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
236
ff_rdt_parse_packet(RDTDemuxContext *s, AVPacket *pkt,
206 237
                    const uint8_t *buf, int len)
207 238
{
208
    PayloadContext *rdt = s->dynamic_protocol_context;
209 239
    int seq, flags = 0, rule, sn;
210 240
    uint32_t timestamp;
211 241
    int rv= 0;
......
226 256
    rv = ff_rdt_parse_header(buf, len, &sn, &seq, &rule, &timestamp);
227 257
    if (rv < 0)
228 258
        return rv;
229
    if (!(rule & 1) && (sn != rdt->prev_sn || timestamp != rdt->prev_ts)) {
259
    if (!(rule & 1) && (sn != s->prev_sn || timestamp != s->prev_ts)) {
230 260
        flags |= PKT_FLAG_KEY;
231
        rdt->prev_sn = sn;
232
        rdt->prev_ts = timestamp;
261
        s->prev_sn = sn;
262
        s->prev_ts = timestamp;
233 263
    }
234 264
    buf += rv;
235 265
    len -= rv;
236
    s->seq = seq;
237 266

  
238 267
    rv = s->parse_packet(s->dynamic_protocol_context,
239 268
                         s->st, pkt, &timestamp, buf, len, flags);
......
250 279
}
251 280

  
252 281
void
253
ff_rdt_subscribe_rule2 (RTPDemuxContext *s, char *cmd, int size,
282
ff_rdt_subscribe_rule2 (RDTDemuxContext *s, char *cmd, int size,
254 283
                        int stream_nr, int rule_nr)
255 284
{
256 285
    PayloadContext *rdt = s->dynamic_protocol_context;
......
292 321
    PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));
293 322

  
294 323
    av_open_input_stream(&rdt->rmctx, NULL, "", &rdt_demuxer, NULL);
295
    rdt->prev_ts = -1;
296
    rdt->prev_sn = -1;
297 324

  
298 325
    return rdt;
299 326
}
libavformat/rdt.h
22 22
#ifndef AVFORMAT_RDT_H
23 23
#define AVFORMAT_RDT_H
24 24

  
25
typedef struct RDTDemuxContext RDTDemuxContext;
26

  
27
RDTDemuxContext *ff_rdt_parse_open(AVFormatContext *ic, AVStream *st,
28
                                   void *priv_data,
29
                                   RTPDynamicProtocolHandler *handler);
30
void ff_rdt_parse_close(RDTDemuxContext *s);
31

  
25 32
/**
26 33
 * Calculate the response (RealChallenge2 in the RTSP header) to the
27 34
 * challenge (RealChallenge1 in the RTSP header from the Real/Helix
......
53 60
void ff_rdt_subscribe_rule(char *cmd, int size,
54 61
                           int stream_nr, int rule_nr);
55 62
// FIXME this will be removed ASAP
56
void ff_rdt_subscribe_rule2(RTPDemuxContext *s, char *cmd, int size,
63
void ff_rdt_subscribe_rule2(RDTDemuxContext *s, char *cmd, int size,
57 64
                            int stream_nr, int rule_nr);
58 65

  
59 66
/**
......
74 81
 * Parse RDT-style packet data (header + media data).
75 82
 * Usage similar to rtp_parse_packet().
76 83
 */
77
int ff_rdt_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
84
int ff_rdt_parse_packet(RDTDemuxContext *s, AVPacket *pkt,
78 85
                        const uint8_t *buf, int len);
79 86

  
80 87
#endif /* AVFORMAT_RDT_H */
libavformat/rtsp.c
873 873
    for(i=0;i<rt->nb_rtsp_streams;i++) {
874 874
        rtsp_st = rt->rtsp_streams[i];
875 875
        if (rtsp_st) {
876
            if (rtsp_st->tx_ctx)
876
            if (rtsp_st->tx_ctx) {
877
                if (rt->transport == RTSP_TRANSPORT_RDT)
878
                    ff_rdt_parse_close(rtsp_st->tx_ctx);
879
                else
877 880
                rtp_parse_close(rtsp_st->tx_ctx);
881
            }
878 882
            if (rtsp_st->rtp_handle)
879 883
                url_close(rtsp_st->rtp_handle);
880 884
            if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)
......
887 891
static int
888 892
rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
889 893
{
894
    RTSPState *rt = s->priv_data;
890 895
    AVStream *st = NULL;
891 896

  
892 897
    /* open the RTP context */
......
894 899
        st = s->streams[rtsp_st->stream_index];
895 900
    if (!st)
896 901
        s->ctx_flags |= AVFMTCTX_NOHEADER;
902

  
903
    if (rt->transport == RTSP_TRANSPORT_RDT)
904
        rtsp_st->tx_ctx = ff_rdt_parse_open(s, st,
905
                                            rtsp_st->dynamic_protocol_context,
906
                                            rtsp_st->dynamic_handler);
907
    else
897 908
    rtsp_st->tx_ctx = rtp_parse_open(s, st, rtsp_st->rtp_handle, rtsp_st->sdp_payload_type, &rtsp_st->rtp_payload_data);
898 909

  
899 910
    if (!rtsp_st->tx_ctx) {
900 911
         return AVERROR(ENOMEM);
901
    } else {
912
    } else if (rt->transport != RTSP_TRANSPORT_RDT) {
902 913
        if(rtsp_st->dynamic_handler) {
903 914
            rtp_parse_set_dynamic_protocol(rtsp_st->tx_ctx,
904 915
                                           rtsp_st->dynamic_protocol_context,

Also available in: Unified diff