Coverage Report

Created: 2026-01-16 07:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavformat/rtpdec_ilbc.c
Line
Count
Source
1
/*
2
 * RTP iLBC Depacketizer, RFC 3952
3
 * Copyright (c) 2012 Martin Storsjo
4
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21
22
#include "avformat.h"
23
#include "rtpdec_formats.h"
24
#include "libavutil/avstring.h"
25
26
static int ilbc_parse_fmtp(AVFormatContext *s,
27
                           AVStream *stream, PayloadContext *data,
28
                           const char *attr, const char *value)
29
0
{
30
0
    if (!strcmp(attr, "mode")) {
31
0
        int mode = atoi(value);
32
0
        switch (mode) {
33
0
        case 20:
34
0
            stream->codecpar->block_align = 38;
35
0
            break;
36
0
        case 30:
37
0
            stream->codecpar->block_align = 50;
38
0
            break;
39
0
        default:
40
0
            av_log(s, AV_LOG_ERROR, "Unsupported iLBC mode %d\n", mode);
41
0
            return AVERROR(EINVAL);
42
0
        }
43
0
    }
44
0
    return 0;
45
0
}
46
47
static int ilbc_parse_sdp_line(AVFormatContext *s, int st_index,
48
                               PayloadContext *data, const char *line)
49
0
{
50
0
    const char *p;
51
0
    AVStream *st;
52
53
0
    if (st_index < 0)
54
0
        return 0;
55
0
    st = s->streams[st_index];
56
57
0
    if (av_strstart(line, "fmtp:", &p)) {
58
0
        int ret = ff_parse_fmtp(s, st, data, p, ilbc_parse_fmtp);
59
0
        if (ret < 0)
60
0
            return ret;
61
0
        if (!st->codecpar->block_align) {
62
0
            av_log(s, AV_LOG_ERROR, "No iLBC mode set\n");
63
0
            return AVERROR(EINVAL);
64
0
        }
65
0
    }
66
0
    return 0;
67
0
}
68
69
const RTPDynamicProtocolHandler ff_ilbc_dynamic_handler = {
70
    .enc_name         = "iLBC",
71
    .codec_type       = AVMEDIA_TYPE_AUDIO,
72
    .codec_id         = AV_CODEC_ID_ILBC,
73
    .parse_sdp_a_line = ilbc_parse_sdp_line,
74
};