Mercurial > libavformat.hg
annotate rtp.c @ 3194:96372faff5f2 libavformat
Remove useless entries from AVRtpPayloadTypes
| author | lucabe |
|---|---|
| date | Mon, 31 Mar 2008 09:48:04 +0000 |
| parents | 64d885714dff |
| children | a859757a057b |
| rev | line source |
|---|---|
| 0 | 1 /* |
| 2 * RTP input/output format | |
| 3 * Copyright (c) 2002 Fabrice Bellard. | |
| 4 * | |
|
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1332
diff
changeset
|
5 * This file is part of FFmpeg. |
|
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1332
diff
changeset
|
6 * |
|
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1332
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
| 0 | 8 * modify it under the terms of the GNU Lesser General Public |
| 9 * License as published by the Free Software Foundation; either | |
|
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1332
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
| 0 | 11 * |
|
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1332
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
| 0 | 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 | |
|
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1332
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
|
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
885
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 0 | 20 */ |
| 21 #include "avformat.h" | |
| 774 | 22 #include "bitstream.h" |
| 0 | 23 |
| 24 #include <unistd.h> | |
| 1754 | 25 #include "network.h" |
| 0 | 26 |
| 1419 | 27 #include "rtp_internal.h" |
| 28 | |
| 0 | 29 //#define DEBUG |
| 30 | |
| 774 | 31 /* from http://www.iana.org/assignments/rtp-parameters last updated 05 January 2005 */ |
| 2901 | 32 static const struct |
| 33 { | |
| 34 int pt; | |
| 35 const char enc_name[50]; /* XXX: why 50 ? */ | |
| 36 enum CodecType codec_type; | |
| 37 enum CodecID codec_id; | |
| 38 int clock_rate; | |
| 39 int audio_channels; | |
| 40 } AVRtpPayloadTypes[]= | |
| 774 | 41 { |
| 42 {0, "PCMU", CODEC_TYPE_AUDIO, CODEC_ID_PCM_MULAW, 8000, 1}, | |
| 43 {3, "GSM", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1}, | |
| 44 {4, "G723", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1}, | |
| 45 {5, "DVI4", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1}, | |
| 46 {6, "DVI4", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 16000, 1}, | |
| 47 {7, "LPC", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1}, | |
| 48 {8, "PCMA", CODEC_TYPE_AUDIO, CODEC_ID_PCM_ALAW, 8000, 1}, | |
| 49 {9, "G722", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1}, | |
| 50 {10, "L16", CODEC_TYPE_AUDIO, CODEC_ID_PCM_S16BE, 44100, 2}, | |
| 51 {11, "L16", CODEC_TYPE_AUDIO, CODEC_ID_PCM_S16BE, 44100, 1}, | |
| 1259 | 52 {12, "QCELP", CODEC_TYPE_AUDIO, CODEC_ID_QCELP, 8000, 1}, |
| 774 | 53 {13, "CN", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1}, |
| 54 {14, "MPA", CODEC_TYPE_AUDIO, CODEC_ID_MP2, 90000, -1}, | |
| 3193 | 55 {14, "MPA", CODEC_TYPE_AUDIO, CODEC_ID_MP3, 90000, -1}, |
| 774 | 56 {15, "G728", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1}, |
| 57 {16, "DVI4", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 11025, 1}, | |
| 58 {17, "DVI4", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 22050, 1}, | |
| 59 {18, "G729", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1}, | |
| 60 {25, "CelB", CODEC_TYPE_VIDEO, CODEC_ID_NONE, 90000, -1}, | |
| 61 {26, "JPEG", CODEC_TYPE_VIDEO, CODEC_ID_MJPEG, 90000, -1}, | |
| 62 {28, "nv", CODEC_TYPE_VIDEO, CODEC_ID_NONE, 90000, -1}, | |
| 63 {31, "H261", CODEC_TYPE_VIDEO, CODEC_ID_H261, 90000, -1}, | |
| 64 {32, "MPV", CODEC_TYPE_VIDEO, CODEC_ID_MPEG1VIDEO, 90000, -1}, | |
| 2760 | 65 {32, "MPV", CODEC_TYPE_VIDEO, CODEC_ID_MPEG2VIDEO, 90000, -1}, |
| 774 | 66 {33, "MP2T", CODEC_TYPE_DATA, CODEC_ID_MPEG2TS, 90000, -1}, |
| 67 {34, "H263", CODEC_TYPE_VIDEO, CODEC_ID_H263, 90000, -1}, | |
| 68 {-1, "", CODEC_TYPE_UNKNOWN, CODEC_ID_NONE, -1, -1} | |
| 69 }; | |
| 0 | 70 |
| 71 int rtp_get_codec_info(AVCodecContext *codec, int payload_type) | |
| 72 { | |
|
2759
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
73 int i = 0; |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
74 |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
75 for (i = 0; AVRtpPayloadTypes[i].pt >= 0; i++) |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
76 if (AVRtpPayloadTypes[i].pt == payload_type) { |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
77 if (AVRtpPayloadTypes[i].codec_id != CODEC_ID_NONE) { |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
78 codec->codec_type = AVRtpPayloadTypes[i].codec_type; |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
79 codec->codec_id = AVRtpPayloadTypes[i].codec_id; |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
80 if (AVRtpPayloadTypes[i].audio_channels > 0) |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
81 codec->channels = AVRtpPayloadTypes[i].audio_channels; |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
82 if (AVRtpPayloadTypes[i].clock_rate > 0) |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
83 codec->sample_rate = AVRtpPayloadTypes[i].clock_rate; |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
84 return 0; |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
85 } |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
86 } |
| 774 | 87 return -1; |
| 0 | 88 } |
| 89 | |
| 90 int rtp_get_payload_type(AVCodecContext *codec) | |
| 91 { | |
| 774 | 92 int i, payload_type; |
| 0 | 93 |
| 94 /* compute the payload type */ | |
| 774 | 95 for (payload_type = -1, i = 0; AVRtpPayloadTypes[i].pt >= 0; ++i) |
| 96 if (AVRtpPayloadTypes[i].codec_id == codec->codec_id) { | |
| 97 if (codec->codec_id == CODEC_ID_PCM_S16BE) | |
| 98 if (codec->channels != AVRtpPayloadTypes[i].audio_channels) | |
| 99 continue; | |
| 100 payload_type = AVRtpPayloadTypes[i].pt; | |
| 0 | 101 } |
| 102 return payload_type; | |
| 103 } | |
| 104 | |
|
2759
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
105 const char *ff_rtp_enc_name(int payload_type) |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
106 { |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
107 int i; |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
108 |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
109 for (i = 0; AVRtpPayloadTypes[i].pt >= 0; i++) |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
110 if (AVRtpPayloadTypes[i].pt == payload_type) { |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
111 return AVRtpPayloadTypes[i].enc_name; |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
112 } |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
113 |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
114 return ""; |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
115 } |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
116 |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
117 enum CodecID ff_rtp_codec_id(const char *buf, enum CodecType codec_type) |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
118 { |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
119 int i; |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
120 |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
121 for (i = 0; AVRtpPayloadTypes[i].pt >= 0; i++) |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
122 if (!strcmp(buf, AVRtpPayloadTypes[i].enc_name) && (codec_type == AVRtpPayloadTypes[i].codec_type)){ |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
123 return AVRtpPayloadTypes[i].codec_id; |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
124 } |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
125 |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
126 return CODEC_ID_NONE; |
|
b252e318023a
Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents:
2706
diff
changeset
|
127 } |
