| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) The FFmpeg developers | ||
| 3 | * | ||
| 4 | * This file is part of FFmpeg. | ||
| 5 | * | ||
| 6 | * FFmpeg is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU Lesser General Public | ||
| 8 | * License as published by the Free Software Foundation; either | ||
| 9 | * version 2.1 of the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * Lesser General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU Lesser General Public | ||
| 17 | * License along with FFmpeg; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <stdarg.h> | ||
| 22 | #include <stdio.h> | ||
| 23 | #include <string.h> | ||
| 24 | |||
| 25 | #include "avtextwriters.h" | ||
| 26 | #include "libavutil/opt.h" | ||
| 27 | |||
| 28 | /* STDOUT Writer */ | ||
| 29 | |||
| 30 | # define WRITER_NAME "stdoutwriter" | ||
| 31 | |||
| 32 | typedef struct StdOutWriterContext { | ||
| 33 | const AVClass *class; | ||
| 34 | } StdOutWriterContext; | ||
| 35 | |||
| 36 | ✗ | static const char *stdoutwriter_get_name(void *ctx) | |
| 37 | { | ||
| 38 | ✗ | return WRITER_NAME; | |
| 39 | } | ||
| 40 | |||
| 41 | static const AVClass stdoutwriter_class = { | ||
| 42 | .class_name = WRITER_NAME, | ||
| 43 | .item_name = stdoutwriter_get_name, | ||
| 44 | }; | ||
| 45 | |||
| 46 | 61534 | static inline void stdout_w8(AVTextWriterContext *wctx, int b) | |
| 47 | { | ||
| 48 | 61534 | printf("%c", b); | |
| 49 | 61534 | } | |
| 50 | |||
| 51 | 31796 | static inline void stdout_put_str(AVTextWriterContext *wctx, const char *str) | |
| 52 | { | ||
| 53 | 31796 | printf("%s", str); | |
| 54 | 31796 | } | |
| 55 | |||
| 56 | 138104 | static inline void stdout_vprintf(AVTextWriterContext *wctx, const char *fmt, va_list vl) | |
| 57 | { | ||
| 58 | 138104 | vprintf(fmt, vl); | |
| 59 | 138104 | } | |
| 60 | |||
| 61 | |||
| 62 | static const AVTextWriter avtextwriter_stdout = { | ||
| 63 | .name = WRITER_NAME, | ||
| 64 | .priv_size = sizeof(StdOutWriterContext), | ||
| 65 | .priv_class = &stdoutwriter_class, | ||
| 66 | .writer_put_str = stdout_put_str, | ||
| 67 | .writer_vprintf = stdout_vprintf, | ||
| 68 | .writer_w8 = stdout_w8 | ||
| 69 | }; | ||
| 70 | |||
| 71 | 167 | int avtextwriter_create_stdout(AVTextWriterContext **pwctx) | |
| 72 | { | ||
| 73 | int ret; | ||
| 74 | |||
| 75 | 167 | ret = avtextwriter_context_open(pwctx, &avtextwriter_stdout); | |
| 76 | |||
| 77 | 167 | return ret; | |
| 78 | } | ||
| 79 |