Mercurial > libavformat.hg
annotate rtp_asf.c @ 5077:696b27c2791a libavformat
indent
author | michael |
---|---|
date | Mon, 29 Jun 2009 18:37:29 +0000 |
parents | c78617194786 |
children | aa0edc246bca |
rev | line source |
---|---|
4744
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
1 /* |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
2 * Microsoft RTP/ASF support. |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
3 * Copyright (c) 2008 Ronald S. Bultje |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
4 * |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
5 * This file is part of FFmpeg. |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
6 * |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
11 * |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
16 * |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
20 */ |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
21 |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
22 /** |
4746 | 23 * @file libavformat/rtp_asf.c |
4744
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
24 * @brief Microsoft RTP/ASF support |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
25 * @author Ronald S. Bultje <rbultje@ronald.bitfreak.net> |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
26 */ |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
27 |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
28 #include <libavutil/base64.h> |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
29 #include <libavutil/avstring.h> |
4754
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
30 #include "rtp.h" |
4744
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
31 #include "rtp_asf.h" |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
32 #include "rtsp.h" |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
33 #include "asf.h" |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
34 |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
35 void ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
36 { |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
37 if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) { |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
38 ByteIOContext pb; |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
39 RTSPState *rt = s->priv_data; |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
40 int len = strlen(p) * 6 / 8; |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
41 char *buf = av_mallocz(len); |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
42 av_base64_decode(buf, p, len); |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
43 |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
44 init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL); |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
45 if (rt->asf_ctx) { |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
46 av_close_input_stream(rt->asf_ctx); |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
47 rt->asf_ctx = NULL; |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
48 } |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
49 av_open_input_stream(&rt->asf_ctx, &pb, "", &asf_demuxer, NULL); |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
50 av_free(buf); |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
51 rt->asf_ctx->pb = NULL; |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
52 } |
51899c07a4f1
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
rbultje
parents:
diff
changeset
|
53 } |
4754
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
54 |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
55 static int |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
56 asfrtp_parse_sdp_line (AVFormatContext *s, int stream_index, |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
57 PayloadContext *asf, const char *line) |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
58 { |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
59 if (av_strstart(line, "stream:", &line)) { |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
60 RTSPState *rt = s->priv_data; |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
61 |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
62 s->streams[stream_index]->id = strtol(line, NULL, 10); |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
63 |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
64 if (rt->asf_ctx) { |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
65 int i; |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
66 |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
67 for (i = 0; i < rt->asf_ctx->nb_streams; i++) { |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
68 if (s->streams[stream_index]->id == rt->asf_ctx->streams[i]->id) { |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
69 *s->streams[stream_index]->codec = |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
70 *rt->asf_ctx->streams[i]->codec; |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
71 rt->asf_ctx->streams[i]->codec->extradata_size = 0; |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
72 rt->asf_ctx->streams[i]->codec->extradata = NULL; |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
73 av_set_pts_info(s->streams[stream_index], 32, 1, 1000); |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
74 } |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
75 } |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
76 } |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
77 } |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
78 |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
79 return 0; |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
80 } |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
81 |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
82 #define RTP_ASF_HANDLER(n, s, t) \ |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
83 RTPDynamicProtocolHandler ff_ms_rtp_ ## n ## _handler = { \ |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
84 s, \ |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
85 t, \ |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
86 CODEC_ID_NONE, \ |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
87 asfrtp_parse_sdp_line, \ |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
88 }; |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
89 |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
90 RTP_ASF_HANDLER(asf_pfv, "x-asf-pf", CODEC_TYPE_VIDEO); |
c78617194786
Assign the x-pf-asf payload string to be decoded by rtp_asf.c, and add a
rbultje
parents:
4746
diff
changeset
|
91 RTP_ASF_HANDLER(asf_pfa, "x-asf-pf", CODEC_TYPE_AUDIO); |