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:47:11.000000000 +0100
+++ ffmpeg/libavformat/rtp_h264.h       2008-01-07 10:47:29.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 */
Index: ffmpeg/libavformat/rtpenc.c
===================================================================
--- ffmpeg.orig/libavformat/rtpenc.c    2008-01-07 10:46:34.000000000 +0100
+++ ffmpeg/libavformat/rtpenc.c 2008-01-07 10:48:34.000000000 +0100
@@ -20,6 +20,7 @@
  */
 #include "avformat.h"
 #include "mpegts.h"
+#include "rtp_h264.h"
 #include "bitstream.h"
 
 #include <unistd.h>
@@ -334,6 +335,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/rtpenc_h264.c
===================================================================
--- ffmpeg.orig/libavformat/rtpenc_h264.c       2008-01-07 10:44:26.000000000 
+0100
+++ ffmpeg/libavformat/rtpenc_h264.c    2008-01-07 10:46:21.000000000 +0100
@@ -61,3 +61,54 @@
 
     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;
+        }
+    }
+}
+
+

Reply via email to