sys/dshowdecwrapper/: Add AAC, AC3 to handled codecs.

Original commit message from CVS:
Based on patch by: Alessandro Decina <alessandro@nnva.org>
* sys/dshowdecwrapper/gstdshowaudiodec.c:
* sys/dshowdecwrapper/gstdshowdecwrapper.h:
* sys/dshowdecwrapper/gstdshowvideodec.c:
Add AAC, AC3 to handled codecs.
Fix handling of flush events.
Improve debug/error output.
Fix a number of typos in comments and variable names.
This commit is contained in:
Alessandro Decina 2008-07-08 17:41:55 +00:00 committed by Michael Smith
parent 7399002e2b
commit 50eafabdd5
4 changed files with 74 additions and 20 deletions

View file

@ -1,3 +1,14 @@
2008-07-08 Michael Smith <msmith@songbirdnest.com>
Based on patch by: Alessandro Decina <alessandro@nnva.org>
* sys/dshowdecwrapper/gstdshowaudiodec.c:
* sys/dshowdecwrapper/gstdshowdecwrapper.h:
* sys/dshowdecwrapper/gstdshowvideodec.c:
Add AAC, AC3 to handled codecs.
Fix handling of flush events.
Improve debug/error output.
Fix a number of typos in comments and variable names.
2008-07-08 Thijs Vermeir <thijsvermeir@gmail.com> 2008-07-08 Thijs Vermeir <thijsvermeir@gmail.com>
patch by: Ilja Pavkovic <illsen@gumblfarz.de> patch by: Ilja Pavkovic <illsen@gumblfarz.de>

View file

@ -79,9 +79,9 @@ static gboolean gst_dshowaudiodec_flush (GstDshowAudioDec * adec);
static gboolean gst_dshowaudiodec_get_filter_settings (GstDshowAudioDec * adec); static gboolean gst_dshowaudiodec_get_filter_settings (GstDshowAudioDec * adec);
static gboolean gst_dshowaudiodec_setup_graph (GstDshowAudioDec * adec); static gboolean gst_dshowaudiodec_setup_graph (GstDshowAudioDec * adec);
/* gobal variable */ /* global variable */
const long bitrates[2][3][16] = { static const long bitrates[2][3][16] = {
/* version 0 */ /* mpeg 1 */
{ {
/* one list per layer 1-3 */ /* one list per layer 1-3 */
{0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, {0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000,
@ -91,7 +91,7 @@ const long bitrates[2][3][16] = {
{0, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 96000, {0, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 96000,
112000, 128000, 144000, 160000, 0}, 112000, 128000, 144000, 160000, 0},
}, },
/* version 1 */ /* mpeg 2 */
{ {
/* one list per layer 1-3 */ /* one list per layer 1-3 */
{0, 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000, {0, 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000,
@ -112,6 +112,9 @@ const long bitrates[2][3][16] = {
#define GUID_MEDIASUBTYPE_WMS {0x0000000a, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }} #define GUID_MEDIASUBTYPE_WMS {0x0000000a, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }}
#define GUID_MEDIASUBTYPE_MP3 {0x00000055, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }} #define GUID_MEDIASUBTYPE_MP3 {0x00000055, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }}
#define GUID_MEDIASUBTYPE_MPEG1AudioPayload {0x00000050, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9b, 0x71 }} #define GUID_MEDIASUBTYPE_MPEG1AudioPayload {0x00000050, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9b, 0x71 }}
#define GUID_MEDIASUBTYPE_AAC {0x000000FF, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9b, 0x71 }}
#define GUID_MEDIASUBTYPE_AC3 {0x00002000, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9b, 0x71 }}
static const CodecEntry audio_dec_codecs[] = { static const CodecEntry audio_dec_codecs[] = {
{"dshowadec_wma1", {"dshowadec_wma1",
@ -176,7 +179,7 @@ static const CodecEntry audio_dec_codecs[] = {
}, },
{"dshowadec_mpeg1", {"dshowadec_mpeg1",
"MPEG-1 Layer 1,2,3 Audio", "MPEG-1 Layer 1,2,3 Audio",
"MPEG Layer-3 Decoder", "MPEG Layer-3 Decoder, MP3 Decoder DMO",
0x00000055, 0x00000055,
GUID_MEDIATYPE_AUDIO, GUID_MEDIASUBTYPE_MP3, GUID_MEDIATYPE_AUDIO, GUID_MEDIASUBTYPE_MP3,
"audio/mpeg, " "audio/mpeg, "
@ -189,13 +192,37 @@ static const CodecEntry audio_dec_codecs[] = {
"width = (int) { 1, 8, 16 }, depth = (int) { 1, 8, 16 }, " "width = (int) { 1, 8, 16 }, depth = (int) { 1, 8, 16 }, "
"signed = (boolean) true, endianness = (int) " "signed = (boolean) true, endianness = (int) "
G_STRINGIFY (G_LITTLE_ENDIAN) G_STRINGIFY (G_LITTLE_ENDIAN)
} },
{"dshowadec_aac",
"AAC decoder",
"ffdshow",
0x000000FF,
GUID_MEDIATYPE_AUDIO, GUID_MEDIASUBTYPE_AAC,
"audio/mpeg, mpegversion = { 2, 4 }",
GUID_MEDIATYPE_AUDIO, GUID_MEDIASUBTYPE_PCM,
"audio/x-raw-int, "
"width = (int) { 1, 8, 16 }, depth = (int) { 1, 8, 16 }, "
"signed = (boolean) true, endianness = (int) "
G_STRINGIFY (G_LITTLE_ENDIAN)
},
{"dshowadec_ac3",
"AC3 decoder",
NULL,
0x00002000,
GUID_MEDIATYPE_AUDIO, GUID_MEDIASUBTYPE_AC3,
"audio/x-ac3",
GUID_MEDIATYPE_AUDIO, GUID_MEDIASUBTYPE_PCM,
"audio/x-raw-int, "
"width = (int) { 1, 8, 16 }, depth = (int) { 1, 8, 16 }, "
"signed = (boolean) true, endianness = (int) "
G_STRINGIFY (G_LITTLE_ENDIAN)
},
}; };
/* Private map used when dshowadec_mpeg is loaded with layer=1 or 2. /* Private map used when dshowadec_mpeg is loaded with layer=1 or 2.
* The problem is that gstreamer don't care about caps like layer when connecting pads. * The problem is that gstreamer doesn't care about caps like layer when connecting pads.
* So I've only one element handling mpeg audio in the public codecs map and * So I've only one element handling mpeg audio in the public codecs map and
* when it's loaded for mp3, I'm releasing mpeg audio decoder and replace it by * when it's loaded for mp3, I release the mpeg audio decoder and replace it by
* the one described in this private map. * the one described in this private map.
*/ */
static const CodecEntry audio_mpeg_1_2[] = { "dshowadec_mpeg_1_2", static const CodecEntry audio_mpeg_1_2[] = { "dshowadec_mpeg_1_2",
@ -307,7 +334,6 @@ gst_dshowaudiodec_init (GstDshowAudioDec * adec,
adec->rate = 0; adec->rate = 0;
adec->layer = 0; adec->layer = 0;
adec->codec_data = NULL; adec->codec_data = NULL;
adec->last_ret = GST_FLOW_OK; adec->last_ret = GST_FLOW_OK;
CoInitializeEx (NULL, COINIT_MULTITHREADED); CoInitializeEx (NULL, COINIT_MULTITHREADED);
@ -582,6 +608,7 @@ gst_dshowaudiodec_sink_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_STOP:{ case GST_EVENT_FLUSH_STOP:{
gst_dshowaudiodec_flush (adec); gst_dshowaudiodec_flush (adec);
adec->last_ret = GST_FLOW_OK;
ret = gst_pad_event_default (pad, event); ret = gst_pad_event_default (pad, event);
break; break;
} }
@ -650,6 +677,7 @@ gst_dshowaudiodec_setup_graph (GstDshowAudioDec * adec)
IPin *output_pin = NULL, *input_pin = NULL; IPin *output_pin = NULL, *input_pin = NULL;
IGstDshowInterface *gstdshowinterface = NULL; IGstDshowInterface *gstdshowinterface = NULL;
CodecEntry *codec_entry = klass->entry; CodecEntry *codec_entry = klass->entry;
char err_buf[1024];
if (adec->layer != 0) { if (adec->layer != 0) {
if (adec->layer == 1 || adec->layer == 2) { if (adec->layer == 1 || adec->layer == 2) {
@ -663,10 +691,10 @@ gst_dshowaudiodec_setup_graph (GstDshowAudioDec * adec)
codec_entry->input_subtype, codec_entry->input_subtype,
codec_entry->output_majortype, codec_entry->output_majortype,
codec_entry->output_subtype, codec_entry->output_subtype,
codec_entry->prefered_filter_substring, &adec->decfilter); codec_entry->preferred_filter_substring, &adec->decfilter);
IFilterGraph_AddFilter (adec->filtergraph, adec->decfilter, L"decoder"); IFilterGraph_AddFilter (adec->filtergraph, adec->decfilter, L"decoder");
} else { } else {
/* mp3 don't need to negociate with MPEG1WAVEFORMAT */ /* mp3 doesn't need to negotiate with MPEG1WAVEFORMAT */
adec->layer = 0; adec->layer = 0;
} }
} }
@ -812,8 +840,13 @@ gst_dshowaudiodec_setup_graph (GstDshowAudioDec * adec)
IFilterGraph_ConnectDirect (adec->filtergraph, output_pin, input_pin, IFilterGraph_ConnectDirect (adec->filtergraph, output_pin, input_pin,
NULL); NULL);
if (hres != S_OK) { if (hres != S_OK) {
if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM,
0, hres, 0, err_buf, 1024, NULL))
err_buf[0] = 0;
GST_ELEMENT_ERROR (adec, CORE, NEGOTIATION, GST_ELEMENT_ERROR (adec, CORE, NEGOTIATION,
("Can't connect fakesrc with decoder (error=%d)", hres), (NULL)); ("Can't connect fakesrc with decoder (error=%d %s)", hres, err_buf),
(NULL));
goto end; goto end;
} }
@ -858,7 +891,7 @@ gst_dshowaudiodec_setup_graph (GstDshowAudioDec * adec)
IGstDshowInterface_gst_set_media_type (gstdshowinterface, &output_mediatype); IGstDshowInterface_gst_set_media_type (gstdshowinterface, &output_mediatype);
IGstDshowInterface_gst_set_buffer_callback (gstdshowinterface, IGstDshowInterface_gst_set_buffer_callback (gstdshowinterface,
gst_dshowaudiodec_push_buffer, (byte *) adec); (byte *) gst_dshowaudiodec_push_buffer, (byte *) adec);
IGstDshowInterface_Release (gstdshowinterface); IGstDshowInterface_Release (gstdshowinterface);
gstdshowinterface = NULL; gstdshowinterface = NULL;
@ -895,15 +928,25 @@ gst_dshowaudiodec_setup_graph (GstDshowAudioDec * adec)
IFilterGraph_ConnectDirect (adec->filtergraph, output_pin, input_pin, IFilterGraph_ConnectDirect (adec->filtergraph, output_pin, input_pin,
NULL); NULL);
if (hres != S_OK) { if (hres != S_OK) {
if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM,
0, hres, 0, err_buf, 1024, NULL))
err_buf[0] = 0;
GST_ELEMENT_ERROR (adec, CORE, NEGOTIATION, GST_ELEMENT_ERROR (adec, CORE, NEGOTIATION,
("Can't connect decoder with fakesink (error=%d)", hres), (NULL)); ("Can't connect decoder with fakesink (error=%d %s)", hres, err_buf),
(NULL));
goto end; goto end;
} }
hres = IMediaFilter_Run (adec->mediafilter, -1); hres = IMediaFilter_Run (adec->mediafilter, -1);
if (hres != S_OK) { if (hres != S_OK) {
if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM,
0, hres, 0, err_buf, 1024, NULL))
err_buf[0] = 0;
GST_ELEMENT_ERROR (adec, CORE, NEGOTIATION, GST_ELEMENT_ERROR (adec, CORE, NEGOTIATION,
("Can't run the directshow graph (error=%d)", hres), (NULL)); ("Can't run the directshow graph (error=%d %s)", hres, err_buf),
(NULL));
goto end; goto end;
} }
@ -1017,7 +1060,7 @@ gst_dshowaudiodec_create_graph_and_filters (GstDshowAudioDec * adec)
klass->entry->input_subtype, klass->entry->input_subtype,
klass->entry->output_majortype, klass->entry->output_majortype,
klass->entry->output_subtype, klass->entry->output_subtype,
klass->entry->prefered_filter_substring, &adec->decfilter)) { klass->entry->preferred_filter_substring, &adec->decfilter)) {
GST_ELEMENT_ERROR (adec, STREAM, FAILED, GST_ELEMENT_ERROR (adec, STREAM, FAILED,
("Can't create an instance of the decoder filter"), (NULL)); ("Can't create an instance of the decoder filter"), (NULL));
goto error; goto error;
@ -1153,7 +1196,7 @@ dshow_adec_register (GstPlugin * plugin)
audio_dec_codecs[i].input_subtype, audio_dec_codecs[i].input_subtype,
audio_dec_codecs[i].output_majortype, audio_dec_codecs[i].output_majortype,
audio_dec_codecs[i].output_subtype, audio_dec_codecs[i].output_subtype,
audio_dec_codecs[i].prefered_filter_substring, NULL)) { audio_dec_codecs[i].preferred_filter_substring, NULL)) {
GST_CAT_DEBUG (dshowaudiodec_debug, "Registering %s", GST_CAT_DEBUG (dshowaudiodec_debug, "Registering %s",
audio_dec_codecs[i].element_name); audio_dec_codecs[i].element_name);

View file

@ -58,7 +58,7 @@
typedef struct _CodecEntry { typedef struct _CodecEntry {
gchar *element_name; gchar *element_name;
gchar *element_longname; gchar *element_longname;
gchar *prefered_filter_substring; gchar *preferred_filter_substring;
gint32 format; gint32 format;
GUID input_majortype; GUID input_majortype;
GUID input_subtype; GUID input_subtype;

View file

@ -978,7 +978,7 @@ gst_dshowvideodec_create_graph_and_filters (GstDshowVideoDec * vdec)
klass->entry->input_subtype, klass->entry->input_subtype,
klass->entry->output_majortype, klass->entry->output_majortype,
klass->entry->output_subtype, klass->entry->output_subtype,
klass->entry->prefered_filter_substring, &vdec->decfilter)) { klass->entry->preferred_filter_substring, &vdec->decfilter)) {
GST_ELEMENT_ERROR (vdec, STREAM, FAILED, ("Can't create an instance " GST_ELEMENT_ERROR (vdec, STREAM, FAILED, ("Can't create an instance "
"of the decoder filter"), (NULL)); "of the decoder filter"), (NULL));
goto error; goto error;
@ -1111,7 +1111,7 @@ dshow_vdec_register (GstPlugin * plugin)
video_dec_codecs[i].input_subtype, video_dec_codecs[i].input_subtype,
video_dec_codecs[i].output_majortype, video_dec_codecs[i].output_majortype,
video_dec_codecs[i].output_subtype, video_dec_codecs[i].output_subtype,
video_dec_codecs[i].prefered_filter_substring, NULL)) { video_dec_codecs[i].preferred_filter_substring, NULL)) {
GST_CAT_DEBUG (dshowvideodec_debug, "Registering %s", GST_CAT_DEBUG (dshowvideodec_debug, "Registering %s",
video_dec_codecs[i].element_name); video_dec_codecs[i].element_name);