]> git.sesse.net Git - vlc/blobdiff - modules/mux/mpeg/pes.c
ts-mux: repeat sps/pps on keyframes, should fix h264/ts streaming issues (hopefully)
[vlc] / modules / mux / mpeg / pes.c
index 9e14037dc0f5b5139ba2a5fb9ac165efe59d5561..d926af6564ecc4b3cdbacb29f54ebd40f251fdb6 100644 (file)
 # include "config.h"
 #endif
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <fcntl.h>
-
 #include <vlc_common.h>
 #include <vlc_sout.h>
 #include <vlc_block.h>
+#include <assert.h>
 
-#ifdef HAVE_UNISTD_H
-#   include <unistd.h>
-#endif
-
-#include <vlc_codecs.h>
 #include "pes.h"
 #include "bits.h"
 
@@ -119,7 +110,7 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
 
                 if( i_pts > 0 && i_dts > 0 &&
                     ( i_pts != i_dts || ( p_fmt->i_cat == VIDEO_ES &&
-                      p_fmt->i_codec != VLC_FOURCC('m','p','g','v') ) ) )
+                      p_fmt->i_codec != VLC_CODEC_MPGV ) ) )
                 {
                     i_pts_dts = 0x03;
                     if ( !i_header_size ) i_header_size = 0xa;
@@ -327,6 +318,7 @@ int  EStoPES ( sout_instance_t *p_sout, block_t **pp_pes, block_t *p_es,
                    int b_mpeg2, int b_data_alignment, int i_header_size,
                    int i_max_pes_size )
 {
+    VLC_UNUSED(p_sout);
     block_t *p_pes;
     mtime_t i_pts, i_dts, i_length;
 
@@ -349,10 +341,12 @@ int  EStoPES ( sout_instance_t *p_sout, block_t **pp_pes, block_t *p_es,
         i_max_pes_size = PES_PAYLOAD_SIZE_MAX;
     }
 
-    if( p_fmt->i_codec == VLC_FOURCC( 'm', 'p','4', 'v' ) &&
+    if( ( p_fmt->i_codec == VLC_CODEC_MP4V ||
+          p_fmt->i_codec == VLC_CODEC_H264 ) &&
         p_es->i_flags & BLOCK_FLAG_TYPE_I )
     {
-        /* For MPEG4 video, add VOL before I-frames */
+        /* For MPEG4 video, add VOL before I-frames,
+           for H264 add SPS/PPS before keyframes*/
         p_es = block_Realloc( p_es, p_fmt->i_extra, p_es->i_buffer );
 
         memcpy( p_es->p_buffer, p_fmt->p_extra, p_fmt->i_extra );