[vlc-commits] [Git][videolan/vlc][master] 2 commits: mux: ts: allow reporting muxing errors

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jun 23 12:34:18 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
eed0d3e7 by Alaric Senat at 2023-06-23T11:55:27+00:00
mux: ts: allow reporting muxing errors

This allow the Mux function to fail due to various causes of error
(allocation, IO error...) instead of blindly continuing to mux.

- - - - -
99e6d78a by Alaric Senat at 2023-06-23T11:55:27+00:00
mux: ts: report access out errors

We should report irrecoverable errors from the access out to the caller,
previously those were just ignored.

- - - - -


1 changed file:

- modules/mux/mpeg/ts.c


Changes:

=====================================
modules/mux/mpeg/ts.c
=====================================
@@ -448,9 +448,9 @@ static int Mux      ( sout_mux_t * );
 
 static block_t *FixPES( sout_mux_t *p_mux, block_fifo_t *p_fifo );
 static block_t *Add_ADTS( block_t *, const es_format_t * );
-static void TSSchedule  ( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
+static int TSSchedule   ( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
                           vlc_tick_t i_pcr_length, vlc_tick_t i_pcr_dts );
-static void TSDate      ( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
+static int TSDate       ( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
                           vlc_tick_t i_pcr_length, vlc_tick_t i_pcr_dts );
 static void GetPAT( sout_mux_t *p_mux, sout_buffer_chain_t *c );
 static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c );
@@ -1129,8 +1129,7 @@ static block_t *Encap_J2K( block_t *p_data, const es_format_t *p_fmt )
     return p_data;
 }
 
-/* returns true if needs more data */
-static bool MuxStreams(sout_mux_t *p_mux )
+static int MuxStreams( sout_mux_t *p_mux )
 {
     sout_mux_sys_t  *p_sys = p_mux->p_sys;
     sout_input_sys_t *p_pcr_stream = (sout_input_sys_t*)p_sys->p_pcr_input->p_sys;
@@ -1175,8 +1174,7 @@ static bool MuxStreams(sout_mux_t *p_mux )
             if( ( p_input->p_fmt->i_cat == AUDIO_ES ) ||
                 ( p_input->p_fmt->i_cat == VIDEO_ES ) )
             {
-                /* We need more data */
-                return true;
+                return -EAGAIN;
             }
             else if( block_FifoCount( p_input->p_fifo ) <= 0 )
             {
@@ -1339,7 +1337,7 @@ static bool MuxStreams(sout_mux_t *p_mux )
                     msg_Warn( p_mux, "Unsupported interlaced J2K content. Expect broken result");
                 p_data = Encap_J2K( p_data, &p_input->fmt );
                 if( !p_data )
-                    return false;
+                    return VLC_EGENERIC;
             }
         }
         else if( p_data->i_length < 0 || p_data->i_length > VLC_TICK_FROM_SEC(2) )
@@ -1510,8 +1508,7 @@ static bool MuxStreams(sout_mux_t *p_mux )
     }
 
     /* 4: date and send */
-    TSSchedule( p_mux, &chain_ts, i_pcr_length, i_pcr_dts );
-    return false;
+    return TSSchedule( p_mux, &chain_ts, i_pcr_length, i_pcr_dts );
 }
 
 /*****************************************************************************
@@ -1533,9 +1530,9 @@ static int Mux( sout_mux_t *p_mux )
         return VLC_SUCCESS;
     }
 
-    while (!MuxStreams(p_mux))
-        ;
-    return VLC_SUCCESS;
+    int status; 
+    while( (status = MuxStreams( p_mux )) == VLC_SUCCESS );
+    return (status == -EAGAIN) ? VLC_SUCCESS : status;
 }
 
 #define STD_PES_PAYLOAD 170
@@ -1645,8 +1642,8 @@ static block_t *Add_ADTS( block_t *p_data, const es_format_t *p_fmt )
     return p_new_block;
 }
 
-static void TSSchedule( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
-                        vlc_tick_t i_pcr_length, vlc_tick_t i_pcr_dts )
+static int TSSchedule( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
+                       vlc_tick_t i_pcr_length, vlc_tick_t i_pcr_dts )
 {
     sout_mux_sys_t  *p_sys = p_mux->p_sys;
     sout_buffer_chain_t new_chain;
@@ -1686,20 +1683,28 @@ static void TSSchedule( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
         msg_Dbg( p_mux, "adjusting rate at %"PRId64"/%"PRId64" (%zu/%zu)",
                  i_cut_dts - i_pcr_dts, i_pcr_length, new_chain.i_depth,
                  p_chain_ts->i_depth );
-        if ( new_chain.i_depth )
-            TSDate( p_mux, &new_chain, i_cut_dts - i_pcr_dts, i_pcr_dts );
-        if ( p_chain_ts->i_depth )
-            TSSchedule( p_mux, p_chain_ts, i_pcr_dts + i_pcr_length - i_cut_dts,
-                        i_cut_dts );
-        return;
+        int status = VLC_SUCCESS;
+        if( new_chain.i_depth )
+        {
+            status = TSDate( p_mux, &new_chain, i_cut_dts - i_pcr_dts,
+                             i_pcr_dts );
+        }
+        if( p_chain_ts->i_depth && status == VLC_SUCCESS )
+        {
+            status = TSSchedule( p_mux, p_chain_ts,
+                                 i_pcr_dts + i_pcr_length - i_cut_dts,
+                                 i_cut_dts );
+        }
+        return status;
     }
 
     if ( new_chain.i_depth )
-        TSDate( p_mux, &new_chain, i_pcr_length, i_pcr_dts );
+        return TSDate( p_mux, &new_chain, i_pcr_length, i_pcr_dts );
+    return VLC_SUCCESS;
 }
 
-static void TSDate( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
-                    vlc_tick_t i_pcr_length, vlc_tick_t i_pcr_dts )
+static int TSDate( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
+                   vlc_tick_t i_pcr_length, vlc_tick_t i_pcr_dts )
 {
     sout_mux_sys_t  *p_sys = p_mux->p_sys;
     int i_packet_count = p_chain_ts->i_depth;
@@ -1739,8 +1744,10 @@ static void TSDate( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
 
         block_ChainLastAppend( &pp_last, p_ts );
     }
+    ssize_t written = 0;
     if ( p_list != NULL )
-        sout_AccessOutWrite( p_mux->p_access, p_list );
+        written = sout_AccessOutWrite( p_mux->p_access, p_list );
+    return ( written == -1 ) ? VLC_EGENERIC : VLC_SUCCESS;
 }
 
 static block_t *TSNew( sout_mux_t *p_mux, sout_input_sys_t *p_stream,



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c038375a31054a47c86cb90401fb7af7d1bffb8b...99e6d78a4955b9f2be7c6f7413cffe8c8e9f6982

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c038375a31054a47c86cb90401fb7af7d1bffb8b...99e6d78a4955b9f2be7c6f7413cffe8c8e9f6982
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list