annotate rdt.c @ 3902:5f9bec099c69 libavformat

Add dynamic payload handlers to rdt.c. These follow the same API as the ones in rtpdec.c, so that they can be shared and used in the same way in rtsp.c. The handlers, since they are specific for RDT, are registered in rdt.c and a new registration function is thus called from allformats.c. The dynamic payload handler also implements RDT-specific SDP-line parsing for OpaqueData and StartTime, which are specific for RDT and needed for proper playback. OpaqueData contains one or a list ("MLTI") of "MDPR" chunks that can be parsed by the rmdec.c function ff_rm_read_mdpr_codecdata(). To use this function, we create a new rdt_demuxer, which has the same private data as the rm_demuxer. The resulting AVFormatContext created with _open_stream() can thus be used to call functions in the RM demuxer. See discussion in "Realmedia patch" thread on ML.
author rbultje
date Sun, 07 Sep 2008 01:21:24 +0000
parents 1026953d4ffe
children aeb79f68ba7e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3876
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
1 /*
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
2 * Realmedia RTSP protocol (RDT) support.
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
3 * Copyright (c) 2007 Ronald S. Bultje
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
4 *
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
5 * This file is part of FFmpeg.
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
6 *
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
11 *
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
15 * Lesser General Public License for more details.
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
16 *
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
20 */
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
21
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
22 /**
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
23 * @file rdt.c
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
24 * @brief Realmedia RTSP protocol (RDT) support
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
25 * @author Ronald S. Bultje <rbultje@ronald.bitfreak.net>
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
26 */
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
27
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
28 #include "avformat.h"
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
29 #include "libavutil/avstring.h"
3902
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
30 #include "rtp_internal.h"
3876
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
31 #include "rdt.h"
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
32 #include "libavutil/base64.h"
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
33 #include "libavutil/md5.h"
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
34 #include "rm.h"
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
35 #include "internal.h"
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
36
3902
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
37 typedef struct rdt_data {
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
38 AVFormatContext *rmctx;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
39 uint8_t *mlti_data;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
40 unsigned int mlti_data_size;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
41 } rdt_data;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
42
3876
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
43 void
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
44 ff_rdt_calc_response_and_checksum(char response[41], char chksum[9],
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
45 const char *challenge)
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
46 {
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
47 int ch_len = strlen (challenge), i;
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
48 unsigned char zres[16],
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
49 buf[64] = { 0xa1, 0xe9, 0x14, 0x9d, 0x0e, 0x6b, 0x3b, 0x59 };
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
50 #define XOR_TABLE_SIZE 37
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
51 const unsigned char xor_table[XOR_TABLE_SIZE] = {
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
52 0x05, 0x18, 0x74, 0xd0, 0x0d, 0x09, 0x02, 0x53,
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
53 0xc0, 0x01, 0x05, 0x05, 0x67, 0x03, 0x19, 0x70,
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
54 0x08, 0x27, 0x66, 0x10, 0x10, 0x72, 0x08, 0x09,
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
55 0x63, 0x11, 0x03, 0x71, 0x08, 0x08, 0x70, 0x02,
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
56 0x10, 0x57, 0x05, 0x18, 0x54 };
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
57
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
58 /* some (length) checks */
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
59 if (ch_len == 40) /* what a hack... */
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
60 ch_len = 32;
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
61 else if (ch_len > 56)
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
62 ch_len = 56;
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
63 memcpy(buf + 8, challenge, ch_len);
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
64
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
65 /* xor challenge bytewise with xor_table */
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
66 for (i = 0; i < XOR_TABLE_SIZE; i++)
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
67 buf[8 + i] ^= xor_table[i];
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
68
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
69 av_md5_sum(zres, buf, 64);
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
70 ff_data_to_hex(response, zres, 16);
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
71 for (i=0;i<32;i++) response[i] = tolower(response[i]);
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
72
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
73 /* add tail */
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
74 strcpy (response + 32, "01d0a8e3");
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
75
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
76 /* calculate checksum */
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
77 for (i = 0; i < 8; i++)
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
78 chksum[i] = response[i * 4];
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
79 chksum[8] = 0;
1026953d4ffe Implement Realmedia/RTSP-compatible SETUP command. This includes calculation
rbultje
parents:
diff changeset
80 }
3902
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
81
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
82 static int
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
83 rdt_load_mdpr (rdt_data *rdt, AVStream *st, int rule_nr)
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
84 {
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
85 ByteIOContext *pb;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
86 int size;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
87 uint32_t tag;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
88
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
89 /**
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
90 * Layout of the MLTI chunk:
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
91 * 4:MLTI
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
92 * 2:<number of streams>
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
93 * Then for each stream ([number_of_streams] times):
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
94 * 2:<mdpr index>
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
95 * 2:<number of mdpr chunks>
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
96 * Then for each mdpr chunk ([number_of_mdpr_chunks] times):
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
97 * 4:<size>
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
98 * [size]:<data>
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
99 * we skip MDPR chunks until we reach the one of the stream
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
100 * we're interested in, and forward that ([size]+[data]) to
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
101 * the RM demuxer to parse the stream-specific header data.
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
102 */
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
103 if (!rdt->mlti_data)
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
104 return -1;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
105 url_open_buf(&pb, rdt->mlti_data, rdt->mlti_data_size, URL_RDONLY);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
106 tag = get_le32(pb);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
107 if (tag == MKTAG('M', 'L', 'T', 'I')) {
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
108 int num, chunk_nr;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
109
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
110 /* read index of MDPR chunk numbers */
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
111 num = get_be16(pb);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
112 if (rule_nr < 0 || rule_nr >= num)
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
113 return -1;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
114 url_fskip(pb, rule_nr * 2);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
115 chunk_nr = get_be16(pb);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
116 url_fskip(pb, (num - 1 - rule_nr) * 2);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
117
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
118 /* read MDPR chunks */
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
119 num = get_be16(pb);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
120 if (chunk_nr >= num)
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
121 return -1;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
122 while (chunk_nr--)
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
123 url_fskip(pb, get_be32(pb));
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
124 size = get_be32(pb);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
125 } else {
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
126 size = rdt->mlti_data_size;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
127 url_fseek(pb, 0, SEEK_SET);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
128 }
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
129 rdt->rmctx->pb = pb;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
130 if (ff_rm_read_mdpr_codecdata(rdt->rmctx, st, size) < 0)
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
131 return -1;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
132
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
133 url_close_buf(pb);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
134 return 0;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
135 }
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
136
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
137 static unsigned char *
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
138 rdt_parse_b64buf (unsigned int *target_len, const char *p)
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
139 {
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
140 unsigned char *target;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
141 int len = strlen(p);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
142 if (*p == '\"') {
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
143 p++;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
144 len -= 2; /* skip embracing " at start/end */
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
145 }
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
146 *target_len = len * 3 / 4;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
147 target = av_mallocz(*target_len + FF_INPUT_BUFFER_PADDING_SIZE);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
148 av_base64_decode(target, p, *target_len);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
149 return target;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
150 }
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
151
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
152 static int
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
153 rdt_parse_sdp_line (AVStream *stream, void *d, const char *line)
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
154 {
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
155 rdt_data *rdt = d;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
156 const char *p = line;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
157
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
158 if (av_strstart(p, "OpaqueData:buffer;", &p)) {
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
159 rdt->mlti_data = rdt_parse_b64buf(&rdt->mlti_data_size, p);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
160 rdt_load_mdpr(rdt, stream, 0);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
161 } else if (av_strstart(p, "StartTime:integer;", &p))
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
162 stream->first_dts = atoi(p);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
163
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
164 return 0;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
165 }
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
166
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
167 static void *
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
168 rdt_new_extradata (void)
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
169 {
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
170 rdt_data *rdt = av_mallocz(sizeof(rdt_data));
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
171
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
172 av_open_input_stream(&rdt->rmctx, NULL, "", &rdt_demuxer, NULL);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
173
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
174 return rdt;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
175 }
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
176
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
177 static void
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
178 rdt_free_extradata (void *d)
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
179 {
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
180 rdt_data *rdt = d;
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
181
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
182 if (rdt->rmctx)
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
183 av_close_input_stream(rdt->rmctx);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
184 av_freep(&rdt->mlti_data);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
185 av_free(rdt);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
186 }
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
187
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
188 #define RDT_HANDLER(n, s, t) \
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
189 static RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
190 s, \
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
191 t, \
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
192 CODEC_ID_NONE, \
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
193 rdt_parse_sdp_line, \
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
194 rdt_new_extradata, \
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
195 rdt_free_extradata \
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
196 };
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
197
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
198 RDT_HANDLER(live_video, "x-pn-multirate-realvideo-live", CODEC_TYPE_VIDEO);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
199 RDT_HANDLER(live_audio, "x-pn-multirate-realaudio-live", CODEC_TYPE_AUDIO);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
200 RDT_HANDLER(video, "x-pn-realvideo", CODEC_TYPE_VIDEO);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
201 RDT_HANDLER(audio, "x-pn-realaudio", CODEC_TYPE_AUDIO);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
202
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
203 void av_register_rdt_dynamic_payload_handlers(void)
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
204 {
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
205 ff_register_dynamic_payload_handler(&ff_rdt_video_handler);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
206 ff_register_dynamic_payload_handler(&ff_rdt_audio_handler);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
207 ff_register_dynamic_payload_handler(&ff_rdt_live_video_handler);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
208 ff_register_dynamic_payload_handler(&ff_rdt_live_audio_handler);
5f9bec099c69 Add dynamic payload handlers to rdt.c. These follow the same API as the ones
rbultje
parents: 3876
diff changeset
209 }