Hi Rafael,

Rafael Maia wrote:
[...]
i am using ffmpeg to encode a H263 video stream that i later send with RTP.
Currently i am building the RTP packet on my own, and adding the H263 bitstream 
to the RTP packet's payload.
What kind of support does FFMpeg provides for sending RTP packets?

libavformat provides an RTP muxer (so, you can stream RTP by opening an output context with format "rtp" and file name "rtp://<destination ip>:<destination port>").
Unfortunately, not all the codecs are currently supported in the RTP muxer.


Is it possible to divide the H263 bitstream in RTP packets?

H.263 in RTP is currently not supported. However, if you search the ffmpeg-devel ml archives you can find a patch that has been posted few days ago. Or you can apply the attached patch, that I had in my local tree for some time (you might need to rebase it).


                        Luca
Index: libavformat/rtpenc.c
===================================================================
--- libavformat/rtpenc.c	(revision 13557)
+++ libavformat/rtpenc.c	(working copy)
@@ -30,6 +30,7 @@
 #include "rtp_mpv.h"
 #include "rtp_aac.h"
 #include "rtp_h264.h"
+#include "rtp_h263.h"
 
 //#define DEBUG
 
@@ -346,6 +347,10 @@
     case CODEC_ID_H264:
         ff_rtp_send_h264(s1, buf1, size);
         break;
+    case CODEC_ID_H263:
+    case CODEC_ID_H263P:
+        ff_rtp_send_h263(s1, buf1, size);
+        break;
     default:
         /* better than nothing : send the codec raw data */
         rtp_send_raw(s1, buf1, size);
Index: libavformat/rtp.c
===================================================================
--- libavformat/rtp.c	(revision 13557)
+++ libavformat/rtp.c	(working copy)
@@ -100,6 +100,8 @@
     /* compute the payload type */
     for (payload_type = -1, i = 0; AVRtpPayloadTypes[i].pt >= 0; ++i)
         if (AVRtpPayloadTypes[i].codec_id == codec->codec_id) {
+            if (codec->codec_id == CODEC_ID_H263)
+                continue;
             if (codec->codec_id == CODEC_ID_PCM_S16BE)
                 if (codec->channels != AVRtpPayloadTypes[i].audio_channels)
                     continue;
Index: libavformat/rtp_h263.c
===================================================================
--- libavformat/rtp_h263.c	(revision 0)
+++ libavformat/rtp_h263.c	(revision 0)
@@ -0,0 +1,38 @@
+#include "avformat.h"
+#include "rtp_internal.h"
+
+void ff_rtp_send_h263(AVFormatContext *s1, const uint8_t *buf1, int size)
+{
+    RTPDemuxContext *s = s1->priv_data;
+    int len, max_packet_size;
+    uint8_t *q;
+
+    max_packet_size = s->max_payload_size;
+
+    while (size > 0) {
+        q = s->buf;
+        if ((buf1[0] == 0) && (buf1[1] == 0)) {
+            *q++ = 0x04;
+	    buf1 += 2;
+	    size -= 2;
+	} else {
+	    *q++ = 0;
+	}
+	*q++ = 0;
+
+        len = max_packet_size - 2;
+        if (len >= size) {
+            len = size;
+        }
+
+        memcpy(q, buf1, len);
+        q += len;
+
+        /* 90 KHz time stamp */
+        s->timestamp = s->cur_timestamp;
+        ff_rtp_send_data(s1, s->buf, q - s->buf, (len == size));
+
+        buf1 += len;
+        size -= len;
+    }
+}
Index: libavformat/rtp_h263.h
===================================================================
--- libavformat/rtp_h263.h	(revision 0)
+++ libavformat/rtp_h263.h	(revision 0)
@@ -0,0 +1 @@
+void ff_rtp_send_h263(AVFormatContext *s1, const uint8_t *buf1, int size);
Index: libavformat/sdp.c
===================================================================
--- libavformat/sdp.c	(revision 13557)
+++ libavformat/sdp.c	(working copy)
@@ -191,6 +191,10 @@
                                      payload_type,
                                      payload_type, config ? config : "");
             break;
+        case CODEC_ID_H263:
+        case CODEC_ID_H263P:
+            av_strlcatf(buff, size, "a=rtpmap:%d H263-2000/90000\r\n", payload_type);
+	    break;
         case CODEC_ID_MPEG4:
             if (c->extradata_size) {
                 config = extradata2config(c);
Index: libavformat/Makefile
===================================================================
--- libavformat/Makefile	(revision 13557)
+++ libavformat/Makefile	(working copy)
@@ -150,6 +150,7 @@
 OBJS-$(CONFIG_RTP_MUXER)                 += rtp.o         \
                                             rtpenc.o      \
                                             rtp_mpv.o     \
+                                            rtp_h263.o    \
                                             rtp_aac.o     \
                                             rtpenc_h264.o \
                                             avc.o
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to