annotate cdg.c @ 6026:785444452e93 libavformat

Change the default codecs for the rtsp muxer to mpeg4 and aac These codecs in RTP are supported by many players.
author mstorsjo
date Fri, 21 May 2010 07:12:33 +0000
parents 536e5527c1e0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5469
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
1 /*
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
2 * CD Graphics Demuxer
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
3 * Copyright (c) 2009 Michael Tison
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
4 *
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
5 * This file is part of FFmpeg.
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
6 *
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
11 *
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
15 * Lesser General Public License for more details.
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
16 *
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
20 */
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
21
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
22 #include "avformat.h"
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
23
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
24 #define CDG_PACKET_SIZE 24
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
25
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
26 static int read_header(AVFormatContext *s, AVFormatParameters *ap)
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
27 {
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
28 AVStream *vst;
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
29 int ret;
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
30
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
31 vst = av_new_stream(s, 0);
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
32 if (!vst)
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
33 return AVERROR(ENOMEM);
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
34
5910
536e5527c1e0 Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 5469
diff changeset
35 vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
5469
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
36 vst->codec->codec_id = CODEC_ID_CDGRAPHICS;
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
37
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
38 /// 75 sectors/sec * 4 packets/sector = 300 packets/sec
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
39 av_set_pts_info(vst, 32, 1, 300);
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
40
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
41 ret = url_fsize(s->pb);
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
42 if (ret > 0)
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
43 vst->duration = (ret * vst->time_base.den) / (CDG_PACKET_SIZE * 300);
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
44
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
45 return 0;
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
46 }
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
47
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
48 static int read_packet(AVFormatContext *s, AVPacket *pkt)
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
49 {
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
50 int ret;
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
51
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
52 ret = av_get_packet(s->pb, pkt, CDG_PACKET_SIZE);
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
53
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
54 pkt->stream_index = 0;
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
55 return ret;
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
56 }
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
57
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
58 AVInputFormat cdg_demuxer = {
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
59 "cdg",
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
60 NULL_IF_CONFIG_SMALL("CD Graphics Format"),
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
61 0,
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
62 NULL,
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
63 read_header,
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
64 read_packet,
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
65 .extensions = "cdg"
ea579ec43456 CD+G demuxer and decoder
vitor
parents:
diff changeset
66 };