*
* Returns: The number of bytes available.
*/
-gint
-tsmux_stream_bytes_avail (TsMuxStream * stream)
+static inline gint
+_tsmux_stream_bytes_avail (TsMuxStream * stream)
{
gint bytes_avail;
if (stream->cur_pes_payload_size != 0)
bytes_avail = stream->cur_pes_payload_size - stream->pes_bytes_written;
else
- bytes_avail = tsmux_stream_bytes_in_buffer (stream);
+ bytes_avail = stream->bytes_avail;
- bytes_avail = MIN (bytes_avail, tsmux_stream_bytes_in_buffer (stream));
+ bytes_avail = MIN (bytes_avail, stream->bytes_avail);
/* Calculate the number of bytes available in the current PES */
if (stream->state == TSMUX_STREAM_STATE_HEADER)
return bytes_avail;
}
+gint
+tsmux_stream_bytes_avail (TsMuxStream * stream)
+{
+ g_return_val_if_fail (stream != NULL, 0);
+
+ return _tsmux_stream_bytes_avail (stream);
+}
+
/**
* tsmux_stream_bytes_in_buffer:
* @stream: a #TsMuxStream
} else if (stream->is_video_stream) {
/* Unbounded for video streams */
stream->cur_pes_payload_size = 0;
- tsmux_stream_find_pts_dts_within (stream,
- tsmux_stream_bytes_in_buffer (stream), &stream->pts, &stream->dts);
+ tsmux_stream_find_pts_dts_within (stream, stream->bytes_avail, &stream->pts,
+ &stream->dts);
} else {
/* Output a PES packet of all currently available bytes otherwise */
- stream->cur_pes_payload_size = tsmux_stream_bytes_in_buffer (stream);
+ stream->cur_pes_payload_size = stream->bytes_avail;
tsmux_stream_find_pts_dts_within (stream, stream->cur_pes_payload_size,
&stream->pts, &stream->dts);
}
stream->state = TSMUX_STREAM_STATE_PACKET;
}
- if (len > (guint) tsmux_stream_bytes_avail (stream))
+ if (len > (guint) _tsmux_stream_bytes_avail (stream))
return FALSE;
stream->pes_bytes_written += len;