On 2 August 2010 06:20, Martin Storsjö <mar...@martin.st> wrote: > On Fri, 30 Jul 2010, Josh Allmann wrote: > >> On 30 July 2010 00:22, Martin Storsjö <mar...@martin.st> wrote: >> > On Thu, 29 Jul 2010, Josh Allmann wrote: >> > >> > [vp8 @ 0x10188fe00] Unknown profile 6 >> > [vp8 @ 0x10188fe00] Header size larger than data provided >> > [rtsp @ 0x10202dc00] Received no start marker; dropping frame >> > >> >> -noframedrop helped, but the last message is what I am concerned with; >> it really should not happen. Those seem like phantom packets. > > >> @@ -393,6 +418,8 @@ static int rtp_write_packet(AVFormatContext *s1, >> AVPacket *pkt) >> case CODEC_ID_H263P: >> ff_rtp_send_h263(s1, pkt->data, size); >> break; >> + case CODEC_ID_VP8: >> + rtp_send_vp8(s1, pkt->data, size); >> default: >> /* better than nothing : send the codec raw data */ >> rtp_send_raw(s1, pkt->data, size); > > Take a look at this chunk and guess why you're getting phanton packets. > :-) >
1000l for not realizing this sooner. > I'll take another look at the new version of the patches sometimes soon, > but adding a break there seems to fix most of the issues :-) > Indeed, updated patches attached, along with the fixes requested by Luca. Valgrind checks out cleanly. Josh
From d021865a63c97ee51a6a77a385f3e7993b154d80 Mon Sep 17 00:00:00 2001 From: Josh Allmann <joshua.allm...@gmail.com> Date: Wed, 28 Jul 2010 00:30:09 -0700 Subject: [PATCH 1/2] Add RTP packetization of VP8. --- libavformat/rtpenc.c | 28 ++++++++++++++++++++++++++++ libavformat/sdp.c | 4 ++++ 2 files changed, 32 insertions(+), 0 deletions(-) diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index 4453f65..6f75017 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -53,6 +53,7 @@ static int is_supported(enum CodecID id) case CODEC_ID_MPEG2TS: case CODEC_ID_AMR_NB: case CODEC_ID_AMR_WB: + case CODEC_ID_VP8: return 1; default: return 0; @@ -291,6 +292,30 @@ static void rtp_send_mpegaudio(AVFormatContext *s1, } } +static void rtp_send_vp8(AVFormatContext *s1, const uint8_t *buf, int size) +{ + RTPMuxContext *s = s1->priv_data; + int len, max_packet_size, keyframe; + + s->buf_ptr = s->buf; + s->timestamp = s->cur_timestamp; + max_packet_size = s->max_payload_size - 1; // minus one for header byte + keyframe = *buf & 1 ? 0 : 16; // 0b10000 indicates keyframe + + *s->buf_ptr++ = keyframe | 8; // 0b1000 indicates start of frame + while (size > 0) { + len = FFMIN(size, max_packet_size); + + memcpy(s->buf_ptr, buf, len); + ff_rtp_send_data(s1, s->buf, len+1, size == len); // marker bit is last packet in frame + + size -= len; + buf += len; + s->buf_ptr = s->buf; + *s->buf_ptr++ = keyframe; + } +} + static void rtp_send_raw(AVFormatContext *s1, const uint8_t *buf1, int size) { @@ -393,6 +418,9 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) case CODEC_ID_H263P: ff_rtp_send_h263(s1, pkt->data, size); break; + case CODEC_ID_VP8: + rtp_send_vp8(s1, pkt->data, size); + break; default: /* better than nothing : send the codec raw data */ rtp_send_raw(s1, pkt->data, size); diff --git a/libavformat/sdp.c b/libavformat/sdp.c index b34b944..a7a3c13 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -297,6 +297,10 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, payload_type, c->sample_rate, c->channels, payload_type); break; + case CODEC_ID_VP8: + av_strlcatf(buff, size, "a=rtpmap:%d VP8/90000\r\n", + payload_type); + break; default: /* Nothing special to do here... */ break; -- 1.7.0.4
From 2641745fc3d73ab8fd82cf58f68238029f629860 Mon Sep 17 00:00:00 2001 From: Josh Allmann <joshua.allm...@gmail.com> Date: Thu, 29 Jul 2010 03:51:36 -0700 Subject: [PATCH 2/2] Add RTP depacketization of VP8. --- libavformat/Makefile | 1 + libavformat/rtpdec.c | 1 + libavformat/rtpdec_formats.h | 1 + libavformat/rtpdec_vp8.c | 104 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 0 deletions(-) create mode 100644 libavformat/rtpdec_vp8.c diff --git a/libavformat/Makefile b/libavformat/Makefile index f73bc54..7258a55 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -233,6 +233,7 @@ OBJS-$(CONFIG_SDP_DEMUXER) += rtsp.o \ rtpdec_mpeg4.o \ rtpdec_qdm2.o \ rtpdec_svq3.o \ + rtpdec_vp8.o \ rtpdec_xiph.o OBJS-$(CONFIG_SEGAFILM_DEMUXER) += segafilm.o OBJS-$(CONFIG_SHORTEN_DEMUXER) += raw.o diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index c17dc2d..2c5243a 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -65,6 +65,7 @@ void av_register_rtp_dynamic_payload_handlers(void) ff_register_dynamic_payload_handler(&ff_theora_dynamic_handler); ff_register_dynamic_payload_handler(&ff_qdm2_dynamic_handler); ff_register_dynamic_payload_handler(&ff_svq3_dynamic_handler); + ff_register_dynamic_payload_handler(&ff_vp8_dynamic_handler); ff_register_dynamic_payload_handler(&ff_ms_rtp_asf_pfv_handler); ff_register_dynamic_payload_handler(&ff_ms_rtp_asf_pfa_handler); diff --git a/libavformat/rtpdec_formats.h b/libavformat/rtpdec_formats.h index eac1b52..a96ffa6 100644 --- a/libavformat/rtpdec_formats.h +++ b/libavformat/rtpdec_formats.h @@ -44,5 +44,6 @@ extern RTPDynamicProtocolHandler ff_qdm2_dynamic_handler; extern RTPDynamicProtocolHandler ff_svq3_dynamic_handler; extern RTPDynamicProtocolHandler ff_theora_dynamic_handler; extern RTPDynamicProtocolHandler ff_vorbis_dynamic_handler; +extern RTPDynamicProtocolHandler ff_vp8_dynamic_handler; #endif /* AVFORMAT_RTPDEC_FORMATS_H */ diff --git a/libavformat/rtpdec_vp8.c b/libavformat/rtpdec_vp8.c new file mode 100644 index 0000000..6f0a930 --- /dev/null +++ b/libavformat/rtpdec_vp8.c @@ -0,0 +1,104 @@ +/* + * RTP VP8 Depacketizer + * Copyright (c) 2010 Josh Allmann + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "rtpdec_formats.h" + +struct PayloadContext { + ByteIOContext *data; + uint32_t timestamp; + int is_keyframe; // this is rather unused +}; + +static int vp8_handle_packet(AVFormatContext *ctx, + PayloadContext *vp8, + AVStream *st, + AVPacket *pkt, + uint32_t *timestamp, + const uint8_t *buf, + int len, int flags) +{ + int start_packet, end_packet, is_keyframe; + if (!buf) + return AVERROR_INVALIDDATA; + + start_packet = *buf & 8; + end_packet = flags & RTP_FLAG_MARKER; + is_keyframe = *buf & 16; + buf++; + len--; + + if (start_packet) { + int res; + if (vp8->data) { // drop previous frame if needed + uint8_t *tmp; + url_close_dyn_buf(vp8->data, &tmp); + vp8->data = NULL; + av_free(tmp); + } + if ((res = url_open_dyn_buf(&vp8->data)) < 0) + return res; + vp8->is_keyframe = is_keyframe; + vp8->timestamp = *timestamp; + } + + if (!vp8->data || vp8->timestamp != *timestamp) { + av_log(ctx, AV_LOG_WARNING, + "Received no start marker; dropping frame\n"); + return AVERROR(EAGAIN); + } + + put_buffer(vp8->data, buf, len); + + if (end_packet) { + av_init_packet(pkt); + pkt->stream_index = st->index; + pkt->size = url_close_dyn_buf(vp8->data, &pkt->data); + pkt->destruct = av_destruct_packet; + vp8->data = NULL; + return 0; + } + + return AVERROR(EAGAIN); +} + +static PayloadContext *vp8_new_context(void) +{ + return av_mallocz(sizeof(PayloadContext)); +} + +static void vp8_free_context(PayloadContext *vp8) +{ + if (vp8->data) { + uint8_t *tmp; + url_close_dyn_buf(vp8->data, &tmp); + av_free(tmp); + } + av_free(vp8); +} + +RTPDynamicProtocolHandler ff_vp8_dynamic_handler = { + .enc_name = "VP8", + .codec_type = AVMEDIA_TYPE_VIDEO, + .codec_id = CODEC_ID_VP8, + .open = vp8_new_context, + .close = vp8_free_context, + .parse_packet = vp8_handle_packet, +}; -- 1.7.0.4
_______________________________________________ FFmpeg-soc mailing list FFmpeg-soc@mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc