- detect the real audio stream codec (not audio container fourcc)

Original commit message from CVS:

- detect the real audio stream codec (not audio container fourcc)
- list all known audio/video codecs, bind them to FOURCC and pads
This commit is contained in:
Stéphane Loeuillet 2004-10-03 15:54:31 +00:00
parent d38f0983b0
commit 0bb14ff2f2
2 changed files with 118 additions and 13 deletions

View file

@ -505,23 +505,35 @@ gst_rmdemux_get_stream_by_id (GstRMDemux * rmdemux, int id)
void void
gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream)
{ {
int version = 0;
if (stream->subtype == GST_RMDEMUX_STREAM_VIDEO) { if (stream->subtype == GST_RMDEMUX_STREAM_VIDEO) {
stream->pad = stream->pad =
gst_pad_new_from_template (gst_static_pad_template_get gst_pad_new_from_template (gst_static_pad_template_get
(&gst_rmdemux_videosrc_template), g_strdup_printf ("video_%02d", (&gst_rmdemux_videosrc_template), g_strdup_printf ("video_%02d",
rmdemux->n_video_streams)); rmdemux->n_video_streams));
switch (stream->fourcc) { switch (stream->fourcc) {
case GST_MAKE_FOURCC ('R', 'V', '1', '0'): case GST_RM_VDO_RV10:
case GST_MAKE_FOURCC ('R', 'V', '2', '0'): version = 1;
case GST_MAKE_FOURCC ('R', 'V', '3', '0'): break;
case GST_MAKE_FOURCC ('R', 'V', '4', '0'): case GST_RM_VDO_RV20:
stream->caps = gst_caps_new_simple ("video/x-pn-realvideo", NULL); version = 2;
/* "systemstream", G_TYPE_BOOLEAN, FALSE, break;
"rmversion", G_TYPE_INT, version, NULL); */ case GST_RM_VDO_RV30:
version = 3;
break;
case GST_RM_VDO_RV40:
version = 4;
break; break;
default: default:
g_print ("Unknown video FOURCC code\n"); g_print ("Unknown video FOURCC code\n");
} }
if (version) {
stream->caps =
gst_caps_new_simple ("video/x-pn-realvideo", "rmversion", G_TYPE_INT,
(int) version, NULL);
}
if (stream->caps) { if (stream->caps) {
gst_caps_set_simple (stream->caps, gst_caps_set_simple (stream->caps,
"width", G_TYPE_INT, stream->width, "width", G_TYPE_INT, stream->width,
@ -534,14 +546,48 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream)
(&gst_rmdemux_audiosrc_template), g_strdup_printf ("audio_%02d", (&gst_rmdemux_audiosrc_template), g_strdup_printf ("audio_%02d",
rmdemux->n_audio_streams)); rmdemux->n_audio_streams));
switch (stream->fourcc) { switch (stream->fourcc) {
case GST_MAKE_FOURCC ('.', 'r', 'a', '4'): /* Older RealAudio Codecs */
case GST_MAKE_FOURCC ('.', 'r', 'a', '5'): case GST_RM_AUD_14_4:
stream->caps = gst_caps_new_simple ("audio/x-pn-realaudio", NULL); version = 1;
/* "raversion", G_TYPE_INT, version, NULL); */ case GST_RM_AUD_28_8:
version = 2;
break; break;
/* DolbyNet (Dolby AC3, low bitrate) */
case GST_RM_AUD_DNET:
stream->caps = gst_caps_new_simple ("audio/x-ac3", NULL);
break;
/* MPEG-4 based */
case GST_RM_AUD_RAAC:
case GST_RM_AUD_RACP:
stream->caps =
gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT,
(int) 4, NULL);
break;
/* RealAudio audio/RALF is lossless */
case GST_RM_AUD_COOK:
case GST_RM_AUD_RALF:
/* Sipro/ACELP-NET Voice Codec */
case GST_RM_AUD_SIPR:
/* Sony ATRAC3 */
case GST_RM_AUD_ATRC:
g_print ("Nothing known to decode this audio FOURCC code\n");
break;
default: default:
g_print ("Unknown audio FOURCC code\n"); g_print ("Unknown audio FOURCC code\n");
} }
if (version) {
stream->caps =
gst_caps_new_simple ("audio/x-pn-realaudio", "raversion", G_TYPE_INT,
(int) version, NULL);
}
if (stream->caps) { if (stream->caps) {
gst_caps_set_simple (stream->caps, gst_caps_set_simple (stream->caps,
"rate", G_TYPE_INT, (int) stream->rate, "rate", G_TYPE_INT, (int) stream->rate,
@ -731,6 +777,8 @@ gst_rmdemux_parse_mdpr (GstRMDemux * rmdemux, void *data, int length)
stream->subtype = stream_type; stream->subtype = stream_type;
switch (stream_type) { switch (stream_type) {
int audio_fourcc_offset;
case GST_RMDEMUX_STREAM_VIDEO: case GST_RMDEMUX_STREAM_VIDEO:
/* RV10/RV20/RV30/RV40 => video/x-pn-realvideo, version=1,2,3,4 */ /* RV10/RV20/RV30/RV40 => video/x-pn-realvideo, version=1,2,3,4 */
stream->fourcc = RMDEMUX_FOURCC_GET (data + offset + 8); stream->fourcc = RMDEMUX_FOURCC_GET (data + offset + 8);
@ -740,11 +788,25 @@ gst_rmdemux_parse_mdpr (GstRMDemux * rmdemux, void *data, int length)
stream->rate = RMDEMUX_GUINT16_GET (data + offset + 16); stream->rate = RMDEMUX_GUINT16_GET (data + offset + 16);
break; break;
case GST_RMDEMUX_STREAM_AUDIO: case GST_RMDEMUX_STREAM_AUDIO:
/* .ra4/.ra5 => audio/x-pn-realaudio, version=4,5 */ /* .ra4/.ra5 */
stream->fourcc = RMDEMUX_FOURCC_GET (data + offset + 8); stream->fourcc = RMDEMUX_FOURCC_GET (data + offset + 8);
stream->rate = RMDEMUX_GUINT32_GET (data + offset + 48); stream->rate = RMDEMUX_GUINT32_GET (data + offset + 48);
/* cook (cook), sipro (sipr), dnet (dnet) */
switch (stream->fourcc) {
case GST_RM_AUD_xRA4:
audio_fourcc_offset = 62;
break;
case GST_RM_AUD_xRA5:
audio_fourcc_offset = 66;
break;
default:
g_print ("Unknown audio stream format\n");
}
/* 14_4, 28_8, cook, dnet, sipr, raac, racp, ralf, atrc */
stream->fourcc = RMDEMUX_FOURCC_GET (data + offset + audio_fourcc_offset);
break; break;
case GST_RMDEMUX_STREAM_FILEINFO: case GST_RMDEMUX_STREAM_FILEINFO:
{ {

View file

@ -81,6 +81,49 @@ struct _GstRMDemuxClass {
GstElementClass parent_class; GstElementClass parent_class;
}; };
/* RealMedia VideoCodec FOURCC codes */
#define GST_RM_VDO_RV10 GST_MAKE_FOURCC('R','V','1','0') // RealVideo 1
#define GST_RM_VDO_RV20 GST_MAKE_FOURCC('R','V','2','0') // RealVideo G2
#define GST_RM_VDO_RV30 GST_MAKE_FOURCC('R','V','3','0') // RealVideo 8
#define GST_RM_VDO_RV40 GST_MAKE_FOURCC('R','V','4','0') // RealVideo 9+10
/* RealMedia AudioCodec FOURCC codes */
#define GST_RM_AUD_14_4 GST_MAKE_FOURCC('1','4','_','4') // 14.4 Audio Codec
#define GST_RM_AUD_28_8 GST_MAKE_FOURCC('2','8','_','8') // 28.8 Audio Codec
#define GST_RM_AUD_COOK GST_MAKE_FOURCC('c','o','o','k') // Cooker G2 Audio Codec
#define GST_RM_AUD_DNET GST_MAKE_FOURCC('d','n','e','t') // DolbyNet Audio Codec (low bitrate Dolby AC3)
#define GST_RM_AUD_SIPR GST_MAKE_FOURCC('s','i','p','r') // Sipro/ACELP-NET Voice Codec
#define GST_RM_AUD_RAAC GST_MAKE_FOURCC('r','a','a','c') // LE-AAC Audio Codec
#define GST_RM_AUD_RACP GST_MAKE_FOURCC('r','a','c','p') // HE-AAC Audio Codec
#define GST_RM_AUD_RALF GST_MAKE_FOURCC('r','a','l','f') // RealAudio Lossless
#define GST_RM_AUD_ATRC GST_MAKE_FOURCC('a','t','r','c') // Sony ATRAC3 Audio Codec
#define GST_RM_AUD_xRA4 GST_MAKE_FOURCC('.','r','a','4') // Not a real audio codec
#define GST_RM_AUD_xRA5 GST_MAKE_FOURCC('.','r','a','5') // Not a real audio codec
/*
enum GstRMVideoCodecs {
GST_RM_VDO_RV10,
GST_RM_VDO_RV20,
GST_RM_VDO_RV30,
GST_RM_VDO_RV40
};
enum GstRMAudioCodecs {
GST_RM_AUD_14_4,
GST_RM_AUD_28_8,
GST_RM_AUD_COOK,
GST_RM_AUD_DNET,
GST_RM_AUD_SIPR,
GST_RM_AUD_RAAC,
GST_RM_AUD_RACP,
GST_RM_AUD_RALF,
GST_RM_AUD_ATRC
};
*/
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */