[FFmpeg-devel] [PATCH] lavf/webm_chunk: Use dyn_buf to write chunks
Michael Niedermayer
michaelni at gmx.at
Thu Apr 30 20:10:26 CEST 2015
On Thu, Apr 30, 2015 at 09:55:59AM -0700, Vignesh Venkatasubramanian wrote:
> Use dyn_duf to write chunks so that we create the actual chunk
> file only after the entire chunk data is available. This will help
> not confuse other software looking at the chunk file (e.g. a web
> server) by seeing a zero length file when ffmpeg is writing into
> it.
>
> Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
> ---
> libavformat/webm_chunk.c | 46 ++++++++++++++++++++++++++++------------------
> 1 file changed, 28 insertions(+), 18 deletions(-)
>
> diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c
> index 6d3d5d6..892fd7f 100644
> --- a/libavformat/webm_chunk.c
> +++ b/libavformat/webm_chunk.c
> @@ -46,7 +46,6 @@ typedef struct WebMChunkContext {
> int chunk_start_index;
> char *header_filename;
> int chunk_duration;
> - int chunk_count;
> int chunk_index;
> uint64_t duration_written;
> int prev_pts;
> @@ -86,18 +85,21 @@ static int chunk_mux_init(AVFormatContext *s)
> return 0;
> }
>
> -static int set_chunk_filename(AVFormatContext *s, int is_header)
> +static int get_chunk_filename(AVFormatContext *s, int is_header, char *filename)
> {
> WebMChunkContext *wc = s->priv_data;
> AVFormatContext *oc = wc->avf;
> + if (!filename) {
> + return AVERROR(EINVAL);
> + }
> if (is_header) {
> if (!wc->header_filename) {
> return AVERROR(EINVAL);
> }
> - av_strlcpy(oc->filename, wc->header_filename, strlen(wc->header_filename) + 1);
> + av_strlcpy(filename, wc->header_filename, strlen(wc->header_filename) + 1);
> } else {
> - if (av_get_frame_filename(oc->filename, sizeof(oc->filename),
> - s->filename, wc->chunk_index) < 0) {
> + if (av_get_frame_filename(filename, 1024,
^^^^
please use a named identifer instead of the litteral number
[...]
> + char filename[1024];
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150430/3afde244/attachment.asc>
More information about the ffmpeg-devel
mailing list