Patch by Josh Allmann, joshua dot allmann at gmail
Originally committed as revision 23941 to svn://svn.ffmpeg.org/ffmpeg/trunk
... | ... |
@@ -22,7 +22,7 @@ |
22 | 22 |
#define AVFORMAT_AVFORMAT_H |
23 | 23 |
|
24 | 24 |
#define LIBAVFORMAT_VERSION_MAJOR 52 |
25 |
-#define LIBAVFORMAT_VERSION_MINOR 71 |
|
25 |
+#define LIBAVFORMAT_VERSION_MINOR 72 |
|
26 | 26 |
#define LIBAVFORMAT_VERSION_MICRO 0 |
27 | 27 |
|
28 | 28 |
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
... | ... |
@@ -35,6 +35,7 @@ |
35 | 35 |
#include "rtpdec_h263.h" |
36 | 36 |
#include "rtpdec_h264.h" |
37 | 37 |
#include "rtpdec_mpeg4.h" |
38 |
+#include "rtpdec_svq3.h" |
|
38 | 39 |
#include "rtpdec_xiph.h" |
39 | 40 |
|
40 | 41 |
//#define DEBUG |
... | ... |
@@ -68,6 +69,7 @@ void av_register_rtp_dynamic_payload_handlers(void) |
68 | 68 |
ff_register_dynamic_payload_handler(&ff_h264_dynamic_handler); |
69 | 69 |
ff_register_dynamic_payload_handler(&ff_vorbis_dynamic_handler); |
70 | 70 |
ff_register_dynamic_payload_handler(&ff_theora_dynamic_handler); |
71 |
+ ff_register_dynamic_payload_handler(&ff_svq3_dynamic_handler); |
|
71 | 72 |
|
72 | 73 |
ff_register_dynamic_payload_handler(&ff_ms_rtp_asf_pfv_handler); |
73 | 74 |
ff_register_dynamic_payload_handler(&ff_ms_rtp_asf_pfa_handler); |
74 | 75 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,138 @@ |
0 |
+/* |
|
1 |
+ * Sorenson-3 (SVQ3/SV3V) payload for RTP |
|
2 |
+ * Copyright (c) 2010 Ronald S. Bultje |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+/** |
|
22 |
+ * @file |
|
23 |
+ * @brief RTP support for the SV3V (SVQ3) payload |
|
24 |
+ * (http://wiki.multimedia.cx/index.php?title=Sorenson_Video_3#Packetization) |
|
25 |
+ * @author Ronald S. Bultje <rbultje@ronald.bitfreak.net> |
|
26 |
+ */ |
|
27 |
+ |
|
28 |
+#include <string.h> |
|
29 |
+#include <libavcodec/get_bits.h> |
|
30 |
+#include "rtp.h" |
|
31 |
+#include "rtpdec.h" |
|
32 |
+#include "rtpdec_svq3.h" |
|
33 |
+ |
|
34 |
+struct PayloadContext { |
|
35 |
+ ByteIOContext *pktbuf; |
|
36 |
+ int64_t timestamp; |
|
37 |
+ int is_keyframe; |
|
38 |
+}; |
|
39 |
+ |
|
40 |
+/** return 0 on packet, <0 on partial packet or error... */ |
|
41 |
+static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv, |
|
42 |
+ AVStream *st, AVPacket *pkt, |
|
43 |
+ uint32_t *timestamp, |
|
44 |
+ const uint8_t *buf, int len, int flags) |
|
45 |
+{ |
|
46 |
+ int config_packet, start_packet, end_packet; |
|
47 |
+ |
|
48 |
+ if (len < 2) |
|
49 |
+ return AVERROR_INVALIDDATA; |
|
50 |
+ |
|
51 |
+ config_packet = buf[0] & 0x40; |
|
52 |
+ start_packet = buf[0] & 0x20; |
|
53 |
+ end_packet = buf[0] & 0x10; |
|
54 |
+ buf += 2; // ignore buf[1] |
|
55 |
+ len -= 2; |
|
56 |
+ |
|
57 |
+ if (config_packet) { |
|
58 |
+ |
|
59 |
+ av_freep(&st->codec->extradata); |
|
60 |
+ st->codec->extradata_size = 0; |
|
61 |
+ |
|
62 |
+ if (len < 2 || !(st->codec->extradata = |
|
63 |
+ av_malloc(len + 8 + FF_INPUT_BUFFER_PADDING_SIZE))) |
|
64 |
+ return AVERROR_INVALIDDATA; |
|
65 |
+ |
|
66 |
+ st->codec->extradata_size = len + 8; |
|
67 |
+ memcpy(st->codec->extradata, "SEQH", 4); |
|
68 |
+ AV_WB32(st->codec->extradata + 4, len); |
|
69 |
+ memcpy(st->codec->extradata + 8, buf, len); |
|
70 |
+ |
|
71 |
+ /* We set codec_id to CODEC_ID_NONE initially to |
|
72 |
+ * delay decoder initialization since extradata is |
|
73 |
+ * carried within the RTP stream, not SDP. Here, |
|
74 |
+ * by setting codec_id to CODEC_ID_SVQ3, we are signalling |
|
75 |
+ * to the decoder that it is OK to initialize. */ |
|
76 |
+ st->codec->codec_id = CODEC_ID_SVQ3; |
|
77 |
+ |
|
78 |
+ return AVERROR(EAGAIN); |
|
79 |
+ } |
|
80 |
+ |
|
81 |
+ if (start_packet) { |
|
82 |
+ int res; |
|
83 |
+ |
|
84 |
+ if (sv->pktbuf) { |
|
85 |
+ uint8_t *tmp; |
|
86 |
+ url_close_dyn_buf(sv->pktbuf, &tmp); |
|
87 |
+ av_free(tmp); |
|
88 |
+ } |
|
89 |
+ if ((res = url_open_dyn_buf(&sv->pktbuf)) < 0) |
|
90 |
+ return res; |
|
91 |
+ sv->timestamp = *timestamp; |
|
92 |
+ sv->is_keyframe = flags & RTP_FLAG_KEY; |
|
93 |
+ } |
|
94 |
+ |
|
95 |
+ if (!sv->pktbuf) |
|
96 |
+ return AVERROR_INVALIDDATA; |
|
97 |
+ |
|
98 |
+ put_buffer(sv->pktbuf, buf, len); |
|
99 |
+ |
|
100 |
+ if (end_packet) { |
|
101 |
+ av_init_packet(pkt); |
|
102 |
+ pkt->stream_index = st->index; |
|
103 |
+ pkt->pts = sv->timestamp; |
|
104 |
+ pkt->flags = sv->is_keyframe ? AV_PKT_FLAG_KEY : 0; |
|
105 |
+ pkt->size = url_close_dyn_buf(sv->pktbuf, &pkt->data); |
|
106 |
+ pkt->destruct = av_destruct_packet; |
|
107 |
+ sv->pktbuf = NULL; |
|
108 |
+ return 0; |
|
109 |
+ } |
|
110 |
+ |
|
111 |
+ return AVERROR(EAGAIN); |
|
112 |
+} |
|
113 |
+ |
|
114 |
+static PayloadContext *svq3_extradata_new(void) |
|
115 |
+{ |
|
116 |
+ return av_mallocz(sizeof(PayloadContext)); |
|
117 |
+} |
|
118 |
+ |
|
119 |
+static void svq3_extradata_free(PayloadContext *sv) |
|
120 |
+{ |
|
121 |
+ if (sv->pktbuf) { |
|
122 |
+ uint8_t *buf; |
|
123 |
+ url_close_dyn_buf(sv->pktbuf, &buf); |
|
124 |
+ av_free(buf); |
|
125 |
+ } |
|
126 |
+ av_free(sv); |
|
127 |
+} |
|
128 |
+ |
|
129 |
+RTPDynamicProtocolHandler ff_svq3_dynamic_handler = { |
|
130 |
+ "X-SV3V-ES", |
|
131 |
+ CODEC_TYPE_VIDEO, |
|
132 |
+ CODEC_ID_NONE, // see if (config_packet) above |
|
133 |
+ NULL, // parse sdp line |
|
134 |
+ svq3_extradata_new, |
|
135 |
+ svq3_extradata_free, |
|
136 |
+ svq3_parse_packet, |
|
137 |
+}; |
0 | 138 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,33 @@ |
0 |
+/* |
|
1 |
+ * Sorenson-3 (SVQ3/SV3V) payload for RTP |
|
2 |
+ * Copyright (c) 2010 Ronald S. Bultje |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#ifndef AVFORMAT_RTPDEC_SVQ3_H |
|
22 |
+#define AVFORMAT_RTPDEC_SVQ3_H |
|
23 |
+ |
|
24 |
+#include "libavcodec/avcodec.h" |
|
25 |
+#include "rtpdec.h" |
|
26 |
+ |
|
27 |
+/** |
|
28 |
+ * Sorenson-3 RTP callbacks. |
|
29 |
+ */ |
|
30 |
+extern RTPDynamicProtocolHandler ff_svq3_dynamic_handler; |
|
31 |
+ |
|
32 |
+#endif /* AVFORMAT_RTPDEC_SVQ3_H */ |