Luca Abeni <[EMAIL PROTECTED]> added the comment:
Update the patch
______________________________________________________
FFmpeg issue tracker <[EMAIL PROTECTED]>
<https://roundup.mplayerhq.hu/roundup/ffmpeg/issue306>
______________________________________________________
Index: ffmpeg/libavformat/rtp_h264.h
===================================================================
--- ffmpeg.orig/libavformat/rtp_h264.h 2008-01-07 10:31:57.000000000 +0100
+++ ffmpeg/libavformat/rtp_h264.h 2008-01-07 10:38:04.000000000 +0100
@@ -25,5 +25,6 @@
#include "rtp_internal.h"
extern RTPDynamicProtocolHandler ff_h264_dynamic_handler;
+const uint8_t *ff_nal_get(const uint8_t *buf, int *size);
#endif /* FFMPEG_RTP_H264_H */
Index: ffmpeg/libavformat/rtpenc_h264.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ ffmpeg/libavformat/rtpenc_h264.c 2008-01-07 10:37:38.000000000 +0100
@@ -0,0 +1,63 @@
+/*
+ * RTP packetization for H.264 (RFC3984)
+ * Copyright (c) 2008 Luca Abeni.
+ *
+ * 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
+ */
+
+/**
+* @file rtpenc_h264.c
+ * @brief H.264 packetization
+ * @author Luca Abeni <[EMAIL PROTECTED]>
+ */
+
+#include "avformat.h"
+
+#include "rtp_h264.h"
+
+static int nal_start(const uint8_t *p)
+{
+ if ((p[0] == 0x00) && (p[1] == 0x00) && (p[2] == 0x00) && (p[3] == 0x01)) {
+ return 4;
+ }
+ if ((p[0] == 0x00) && (p[1] == 0x00) && (p[2] == 0x01)) {
+ return 3;
+ }
+
+ return 0;
+}
+
+const uint8_t *ff_nal_get(const uint8_t *buf, int *size)
+{
+ int len = nal_start(buf);
+
+ if (len) {
+ const uint8_t *r1, *r = buf + len;
+
+ for(r1 = r; r1 < buf + *size; r1++) {
+ len = nal_start(r1);
+ if (len) {
+ break;
+ }
+ }
+
+ *size = r1 - r;
+ return r;
+ }
+
+ return NULL;
+}
Index: ffmpeg/libavformat/sdp.c
===================================================================
--- ffmpeg.orig/libavformat/sdp.c 2008-01-07 10:31:47.000000000 +0100
+++ ffmpeg/libavformat/sdp.c 2008-01-07 10:33:50.000000000 +0100
@@ -21,6 +21,8 @@
#include "avstring.h"
#include "avformat.h"
#include "rtp.h"
+#include "rtp_h264.h"
+#include "base64.h"
#ifdef CONFIG_RTP_MUXER
#define MAX_EXTRADATA_SIZE ((INT_MAX - 10) / 2)
@@ -111,6 +113,48 @@
return buff;
}
+static char *extradata2psets(const uint8_t *extradata, int extradata_size)
+{
+ char *psets, *p;
+ const uint8_t *r;
+
+ if (extradata_size > MAX_EXTRADATA_SIZE) {
+ av_log(NULL, AV_LOG_ERROR, "Too many extra data!\n");
+
+ return NULL;
+ }
+
+ psets = av_mallocz(1024);
+ if (psets == NULL) {
+ av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory for the parameter
sets\n");
+ return NULL;
+ }
+ memcpy(psets, "; sprop-parameter-sets=", 23);
+ p = psets + 23;
+ r = extradata;
+ while (r) {
+ int nal_size = extradata_size - (r - extradata);
+
+ r = ff_nal_get(r, &nal_size);
+ if (r) {
+ if (p != (psets + 23)) {
+ *p = ',';
+ p++;
+ }
+ if (av_base64_encode(p, 1024 - (p - psets), r, nal_size) == NULL) {
+ av_log(NULL, AV_LOG_ERROR, "Cannot BASE64 encode!\n");
+ av_free(psets);
+
+ return NULL;
+ }
+ p += strlen(p);
+ r += nal_size;
+ }
+ }
+
+ return psets;
+}
+
static char *extradata2config(const uint8_t *extradata, int extradata_size)
{
char *config;
@@ -137,6 +181,17 @@
char *config = NULL;
switch (c->codec_id) {
+ case CODEC_ID_H264:
+ if (c->extradata_size) {
+ config = extradata2psets(c->extradata, c->extradata_size);
+ }
+ av_strlcatf(buff, size, "a=rtpmap:%d H264/90000\r\n"
+ "a=fmtp:%d packetization-mode=1%s\r\n",
+/* "profile-level-id=%x%s\r\n", */
+ payload_type,
+ payload_type, /*profile_level_id, */
+ config ? config : "");
+ break;
case CODEC_ID_MPEG4:
if (c->extradata_size) {
config = extradata2config(c->extradata, c->extradata_size);
Index: ffmpeg/libavformat/Makefile
===================================================================
--- ffmpeg.orig/libavformat/Makefile 2008-01-07 10:42:46.000000000 +0100
+++ ffmpeg/libavformat/Makefile 2008-01-07 10:43:35.000000000 +0100
@@ -121,7 +121,7 @@
OBJS-$(CONFIG_RM_MUXER) += rmenc.o
OBJS-$(CONFIG_ROQ_DEMUXER) += idroq.o
OBJS-$(CONFIG_ROQ_MUXER) += raw.o
-OBJS-$(CONFIG_RTP_MUXER) += rtp.o rtpenc.o rtp_mpv.o rtp_aac.o
+OBJS-$(CONFIG_RTP_MUXER) += rtp.o rtpenc.o rtpenc_h264.o
rtp_mpv.o rtp_aac.o
OBJS-$(CONFIG_RTSP_DEMUXER) += rtsp.o
OBJS-$(CONFIG_SDP_DEMUXER) += rtsp.o rtp.o rtpdec.o rtp_h264.o
OBJS-$(CONFIG_SEGAFILM_DEMUXER) += segafilm.o