Revision accc248f libavformat/rdt.c

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
}

Also available in: Unified diff