Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
* G.728 raw demuxer |
3 |
|
|
* |
4 |
|
|
* This file is part of FFmpeg. |
5 |
|
|
* |
6 |
|
|
* FFmpeg is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU Lesser General Public |
8 |
|
|
* License as published by the Free Software Foundation; either |
9 |
|
|
* version 2.1 of the License, or (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* FFmpeg is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
|
|
* Lesser General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU Lesser General Public |
17 |
|
|
* License along with FFmpeg; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include "avformat.h" |
22 |
|
|
#include "demux.h" |
23 |
|
|
#include "internal.h" |
24 |
|
|
|
25 |
|
✗ |
static int g728_read_header(AVFormatContext *s) |
26 |
|
|
{ |
27 |
|
✗ |
AVStream *st = avformat_new_stream(s, NULL); |
28 |
|
✗ |
if (!st) |
29 |
|
✗ |
return AVERROR(ENOMEM); |
30 |
|
|
|
31 |
|
✗ |
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; |
32 |
|
✗ |
st->codecpar->codec_id = ffifmt(s->iformat)->raw_codec_id; |
33 |
|
✗ |
st->codecpar->sample_rate = 8000; |
34 |
|
✗ |
st->codecpar->bit_rate = 16000; |
35 |
|
✗ |
st->codecpar->block_align = 5; |
36 |
|
✗ |
st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; |
37 |
|
✗ |
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); |
38 |
|
|
|
39 |
|
✗ |
return 0; |
40 |
|
|
} |
41 |
|
|
|
42 |
|
✗ |
static int g728_read_packet(AVFormatContext *s, AVPacket *pkt) |
43 |
|
|
{ |
44 |
|
✗ |
int ret = av_get_packet(s->pb, pkt, 1020); // a size similar to RAW_PACKET_SIZE divisible by 5 |
45 |
|
✗ |
pkt->flags &= ~AV_PKT_FLAG_CORRUPT; |
46 |
|
✗ |
pkt->duration = (pkt->size / 5) * 20; |
47 |
|
✗ |
return ret; |
48 |
|
|
} |
49 |
|
|
|
50 |
|
|
const FFInputFormat ff_g728_demuxer = { |
51 |
|
|
.p.name = "g728", |
52 |
|
|
.p.long_name = NULL_IF_CONFIG_SMALL("raw G.728"), |
53 |
|
|
.p.extensions = "g728", |
54 |
|
|
.p.flags = AVFMT_GENERIC_INDEX, |
55 |
|
|
.read_header = g728_read_header, |
56 |
|
|
.read_packet = g728_read_packet, |
57 |
|
|
.raw_codec_id = AV_CODEC_ID_G728, |
58 |
|
|
}; |
59 |
|
|
|