Luca Abeni <[EMAIL PROTECTED]> added the comment:

And here is the patch for supporting the H.264 payload in the RTP muxer

______________________________________________________
FFmpeg issue tracker <[EMAIL PROTECTED]>
<https://roundup.mplayerhq.hu/roundup/ffmpeg/issue306>
______________________________________________________
Index: ffmpeg/libavformat/rtp_h264.c
===================================================================
--- ffmpeg.orig/libavformat/rtp_h264.c	2007-11-16 13:04:07.000000000 +0100
+++ ffmpeg/libavformat/rtp_h264.c	2007-11-16 13:58:27.000000000 +0100
@@ -433,6 +433,55 @@
     return NULL;
 }
 
+static void nal_send(AVFormatContext *s1, const uint8_t *buf, int size, int last)
+{
+    RTPDemuxContext *s = s1->priv_data;
+
+//    av_log(s1, AV_LOG_INFO, "Sending NAL %x of len %d M=%d\n", buf[0] & 0x1F, size, last);
+    if (size <= s->max_payload_size) {
+        ff_rtp_send_data(s1, buf, size, last);
+    } else {
+        uint8_t type = buf[0] & 0x1F;
+        uint8_t nri = buf[0] & 0x60;
+
+//        av_log(s1, AV_LOG_INFO, "NAL size %d > %d\n", size, s->max_payload_size);
+        s->buf[0] = 28;	/* FU Indicator; Type = 28 ---> FU-A */
+        s->buf[0] |= nri;
+        s->buf[1] = type;
+	s->buf[1] |= 1 << 7;
+	buf += 1;
+	size -= 1;
+        while (size + 2 > s->max_payload_size) {
+            memcpy(&s->buf[2], buf, s->max_payload_size - 2);
+            ff_rtp_send_data(s1, s->buf, s->max_payload_size, 0);
+	    buf += s->max_payload_size - 2;
+	    size -= s->max_payload_size - 2;
+	    s->buf[1] &= ~(1 << 7);
+        }
+	s->buf[1] |= 1 << 6;
+        memcpy(&s->buf[2], buf, size);
+        ff_rtp_send_data(s1, s->buf, size + 2, 1);
+    }
+}
+
+void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size)
+{
+    const uint8_t *r;
+    RTPDemuxContext *s = s1->priv_data;
+
+    s->timestamp = s->cur_timestamp;
+    r = buf1;
+    while (r) {
+        int nal_size = size - (r - buf1);
+
+        r = ff_nal_get(r, &nal_size);
+	if (r) {
+            nal_send(s1, r, nal_size, (r + nal_size == buf1 + size));
+            r += nal_size;
+        }
+    }
+}
+
 /**
 This is the structure for expanding on the dynamic rtp protocols (makes everything static. yay!)
 */
Index: ffmpeg/libavformat/rtp.c
===================================================================
--- ffmpeg.orig/libavformat/rtp.c	2007-11-16 12:44:19.000000000 +0100
+++ ffmpeg/libavformat/rtp.c	2007-11-16 13:58:51.000000000 +0100
@@ -1048,6 +1048,9 @@
     case CODEC_ID_MPEG2TS:
         rtp_send_mpegts_raw(s1, buf1, size);
         break;
+    case CODEC_ID_H264:
+        ff_rtp_send_h264(s1, buf1, size);
+        break;
     default:
         /* better than nothing : send the codec raw data */
         rtp_send_raw(s1, buf1, size);
Index: ffmpeg/libavformat/rtp_h264.h
===================================================================
--- ffmpeg.orig/libavformat/rtp_h264.h	2007-11-16 12:54:40.000000000 +0100
+++ ffmpeg/libavformat/rtp_h264.h	2007-11-16 13:11:06.000000000 +0100
@@ -26,5 +26,6 @@
 
 extern RTPDynamicProtocolHandler ff_h264_dynamic_handler;
 const uint8_t *ff_nal_get(const uint8_t *buf, int *size);
+void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size);
 
 #endif /* FFMPEG_RTP_H264_H */

Reply via email to