diff options
Diffstat (limited to 'src/cam/sdl_texture_mjpg.cpp')
-rw-r--r-- | src/cam/sdl_texture_mjpg.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/cam/sdl_texture_mjpg.cpp b/src/cam/sdl_texture_mjpg.cpp new file mode 100644 index 00000000..69e99ad3 --- /dev/null +++ b/src/cam/sdl_texture_mjpg.cpp @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2022, Ideas on Board Oy + * + * sdl_texture_mjpg.cpp - SDL Texture MJPG + */ + +#include "sdl_texture_mjpg.h" + +#include <SDL2/SDL_image.h> + +using namespace libcamera; + +SDLTextureMJPG::SDLTextureMJPG(const SDL_Rect &rect) + : SDLTexture(rect, SDL_PIXELFORMAT_RGB24, 0) +{ +} + +void SDLTextureMJPG::update(const Span<uint8_t> &data) +{ + SDL_RWops *bufferStream = SDL_RWFromMem(data.data(), data.size()); + SDL_Surface *frame = IMG_Load_RW(bufferStream, 0); + SDL_UpdateTexture(ptr_, nullptr, frame->pixels, frame->pitch); + SDL_FreeSurface(frame); +} |