[FFmpeg-cvslog] r23207 - in trunk/libavformat: internal.h utils.c

mstorsjo subversion
Fri May 21 09:07:58 CEST 2010


Author: mstorsjo
Date: Fri May 21 09:07:57 2010
New Revision: 23207

Log:
Add a libavformat internal function ff_write_chained

Modified:
   trunk/libavformat/internal.h
   trunk/libavformat/utils.c

Modified: trunk/libavformat/internal.h
==============================================================================
--- trunk/libavformat/internal.h	Fri May 21 01:09:11 2010	(r23206)
+++ trunk/libavformat/internal.h	Fri May 21 09:07:57 2010	(r23207)
@@ -154,4 +154,18 @@ int ff_url_join(char *str, int size, con
 void ff_sdp_write_media(char *buff, int size, AVCodecContext *c,
                         const char *dest_addr, int port, int ttl);
 
+/**
+ * Write a packet to another muxer than the one the user originally
+ * intended. Useful when chaining muxers, where one muxer internally
+ * writes a received packet to another muxer.
+ *
+ * @param dst the muxer to write the packet to
+ * @param dst_stream the stream index within dst to write the packet to
+ * @param pkt the packet to be written
+ * @param src the muxer the packet originally was intended for
+ * @return the value av_write_frame returned
+ */
+int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
+                     AVFormatContext *src);
+
 #endif /* AVFORMAT_INTERNAL_H */

Modified: trunk/libavformat/utils.c
==============================================================================
--- trunk/libavformat/utils.c	Fri May 21 01:09:11 2010	(r23206)
+++ trunk/libavformat/utils.c	Fri May 21 09:07:57 2010	(r23207)
@@ -3591,3 +3591,22 @@ int ff_url_join(char *str, int size, con
     }
     return strlen(str);
 }
+
+int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
+                     AVFormatContext *src)
+{
+    AVPacket local_pkt;
+
+    local_pkt = *pkt;
+    local_pkt.stream_index = dst_stream;
+    if (pkt->pts != AV_NOPTS_VALUE)
+        local_pkt.pts = av_rescale_q(pkt->pts,
+                                     src->streams[pkt->stream_index]->time_base,
+                                     dst->streams[dst_stream]->time_base);
+    if (pkt->dts != AV_NOPTS_VALUE)
+        local_pkt.dts = av_rescale_q(pkt->dts,
+                                     src->streams[pkt->stream_index]->time_base,
+                                     dst->streams[dst_stream]->time_base);
+    return av_write_frame(dst, &local_pkt);
+}
+



More information about the ffmpeg-cvslog mailing list