LCOV - code coverage report
Current view: top level - src/media - decoder_finder.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 12 12 100.0 %
Date: 2024-12-21 08:56:24 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  *  Copyright (C) 2004-2024 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             : #pragma once
      18             : 
      19             : extern "C" {
      20             : #include <libavcodec/avcodec.h>
      21             : }
      22             : 
      23             : namespace jami {
      24             : 
      25             : /**
      26             :  * Attempt to find standalone AVCodec decoder using AVCodecID,
      27             :  * or fallback to the default decoder.
      28             :  */
      29             : const AVCodec*
      30         356 : findDecoder(const enum AVCodecID codec_id)
      31             : {
      32             :     const char* codec_name;
      33         356 :     switch (codec_id) {
      34             : #if 0 && defined(__ANDROID__) && defined(RING_ACCEL)
      35             :     case AV_CODEC_ID_MPEG4:
      36             :         codec_name = "mpeg4_mediacodec"; break;
      37             :     case AV_CODEC_ID_H264:
      38             :         codec_name = "h264_mediacodec"; break;
      39             :     case AV_CODEC_ID_HEVC:
      40             :         codec_name = "hevc_mediacodec"; break;
      41             :     case AV_CODEC_ID_VP8:
      42             :         codec_name = "vp8_mediacodec"; break;
      43             :     case AV_CODEC_ID_VP9:
      44             :         codec_name = "vp9_mediacodec"; break;
      45             : #endif
      46         199 :     case AV_CODEC_ID_OPUS:
      47         199 :         codec_name = "libopus"; break;
      48         157 :     default:
      49         157 :         codec_name = nullptr;
      50             :     }
      51         356 :     const AVCodec* codec = nullptr;
      52         356 :     if (codec_name)
      53         199 :         codec = avcodec_find_decoder_by_name(codec_name);
      54         356 :     if (not codec)
      55         157 :         codec = avcodec_find_decoder(codec_id);
      56         356 :     return codec;
      57             : }
      58             : 
      59             : } // namespace jami

Generated by: LCOV version 1.14