test_media_lib.h (2956B)
1 /* 2 This file is part of libextractor. 3 Copyright (C) 2026 Vidyut Samanta and Christian Grothoff 4 5 libextractor is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published 7 by the Free Software Foundation; either version 3, or (at your 8 option) any later version. 9 10 libextractor is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with libextractor; see the file COPYING. If not, write to the 17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 /** 21 * @file plugins/test_media_lib.h 22 * @brief helpers for testing the video thumbnail and audio preview plugins 23 * @author Christian Grothoff 24 * 25 * Checking that a thumbnailer emitted *a* JPEG only proves that the 26 * plugin ran, not that it looked where it was told to. The test videos 27 * therefore change colour at a known point in time and these helpers 28 * inspect the pixel that comes back. 29 */ 30 #ifndef TEST_MEDIA_LIB_H 31 #define TEST_MEDIA_LIB_H 32 33 #include <stdint.h> 34 #include <stdlib.h> 35 36 /** 37 * Decode the PNG in @a data and return its centre pixel. 38 * 39 * Only the subset of PNG our own encoders produce is understood: 8 bits 40 * per channel, RGB or RGBA, not interlaced. Requires zlib; without it 41 * this always fails and the caller should treat the check as skipped 42 * (see #TEST_MEDIA_HAVE_PNG). 43 * 44 * @param data the PNG image 45 * @param data_len number of bytes in @a data 46 * @param[out] rgb set to the red, green and blue value of the centre pixel 47 * @return 1 on success 48 */ 49 int 50 TEST_media_png_center (const void *data, 51 size_t data_len, 52 uint8_t rgb[3]); 53 54 55 /** 56 * Check that @a data is an Ogg stream whose first page carries the 57 * OpusHead identification header of RFC 7845. 58 * 59 * @param data the stream 60 * @param data_len number of bytes in @a data 61 * @return 1 if this is Ogg Opus 62 */ 63 int 64 TEST_media_is_ogg_opus (const void *data, 65 size_t data_len); 66 67 68 /** 69 * Is the centre pixel of the PNG in @a data approximately @a r, @a g, 70 * @a b? Scaling and re-encoding move colours around a little, hence the 71 * generous tolerance. 72 * 73 * @param data the PNG image 74 * @param data_len number of bytes in @a data 75 * @param r expected red value 76 * @param g expected green value 77 * @param b expected blue value 78 * @return 1 if the pixel matches (or if PNG support was compiled out) 79 */ 80 int 81 TEST_media_png_center_is (const void *data, 82 size_t data_len, 83 uint8_t r, 84 uint8_t g, 85 uint8_t b); 86 87 #endif 88 89 /* end of test_media_lib.h */