LCOV - code coverage report
Current view: top level - src/media - media_io_handle.cpp (source / functions) Coverage Total Hit
Test: jami-coverage-filtered.info Lines: 100.0 % 11 11
Test Date: 2026-06-13 09:18:46 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /*
       2              :  *  Copyright (C) 2004-2026 Savoir-faire Linux Inc.
       3              :  *
       4              :  *  This program is free software: you can redistribute it and/or modify
       5              :  *  it under the terms of the GNU General Public License as published by
       6              :  *  the Free Software Foundation, either version 3 of the License, or
       7              :  *  (at your option) any later version.
       8              :  *
       9              :  *  This program is distributed in the hope that it will be useful,
      10              :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      11              :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      12              :  *  GNU General Public License for more details.
      13              :  *
      14              :  *  You should have received a copy of the GNU General Public License
      15              :  *  along with this program. If not, see <https://www.gnu.org/licenses/>.
      16              :  */
      17              : 
      18              : #include "libav_deps.h" // MUST BE INCLUDED FIRST
      19              : #include "media_io_handle.h"
      20              : 
      21              : namespace jami {
      22              : 
      23          940 : MediaIOHandle::MediaIOHandle(std::size_t buffer_size,
      24              :                              bool writeable,
      25              :                              io_readcallback read_cb,
      26              :                              io_writecallback write_cb,
      27              :                              io_seekcallback seek_cb,
      28          940 :                              void* opaque)
      29          940 :     : ctx_(0)
      30              : 
      31              : {
      32              :     /* FFmpeg doesn't alloc the buffer for the first time, but it does free and
      33              :      * alloc it afterwards.
      34              :      * Don't directly use malloc because av_malloc is optimized for memory alignment.
      35              :      */
      36          940 :     auto* buf = static_cast<uint8_t*>(av_malloc(buffer_size));
      37          940 :     ctx_ = avio_alloc_context(buf, static_cast<int>(buffer_size), writeable, opaque, read_cb, write_cb, seek_cb);
      38          940 :     ctx_->max_packet_size = static_cast<int>(buffer_size);
      39          940 : }
      40              : 
      41          939 : MediaIOHandle::~MediaIOHandle()
      42              : {
      43          939 :     av_free(ctx_->buffer);
      44          940 :     av_free(ctx_);
      45          940 : }
      46              : 
      47              : } // namespace jami
        

Generated by: LCOV version 2.0-1