From a96449173594d05a0b170ffa70a80b638694b1f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 26 Nov 2014 14:36:42 +0000 Subject: [PATCH] Remove unported and obsolete qtwrapper plugin code QuickTime is deprecated, we want new plugins based on avfoundation (osx) or dxva/mediafoundation (windows). --- configure.ac | 10 +- sys/Makefile.am | 10 +- sys/qtwrapper/Makefile.am | 24 - sys/qtwrapper/audiodecoders.c | 1101 ------------------------------ sys/qtwrapper/codecmapping.c | 157 ----- sys/qtwrapper/codecmapping.h | 61 -- sys/qtwrapper/imagedescription.c | 213 ------ sys/qtwrapper/imagedescription.h | 53 -- sys/qtwrapper/qtutils.c | 493 ------------- sys/qtwrapper/qtutils.h | 136 ---- sys/qtwrapper/qtwrapper.c | 87 --- sys/qtwrapper/qtwrapper.h | 69 -- sys/qtwrapper/videodecoders.c | 872 ----------------------- 13 files changed, 3 insertions(+), 3283 deletions(-) delete mode 100644 sys/qtwrapper/Makefile.am delete mode 100644 sys/qtwrapper/audiodecoders.c delete mode 100644 sys/qtwrapper/codecmapping.c delete mode 100644 sys/qtwrapper/codecmapping.h delete mode 100644 sys/qtwrapper/imagedescription.c delete mode 100644 sys/qtwrapper/imagedescription.h delete mode 100644 sys/qtwrapper/qtutils.c delete mode 100644 sys/qtwrapper/qtutils.h delete mode 100644 sys/qtwrapper/qtwrapper.c delete mode 100644 sys/qtwrapper/qtwrapper.h delete mode 100644 sys/qtwrapper/videodecoders.c diff --git a/configure.ac b/configure.ac index 58fa0904cf..2c12e97248 100644 --- a/configure.ac +++ b/configure.ac @@ -422,7 +422,7 @@ GST_PLUGINS_NONPORTED=" cdxaparse \ gsettings \ musepack nas sdl timidity \ directdraw acm wininet \ - xvid lv2 teletextdec sndio osx_video quicktime libvisual" + xvid lv2 teletextdec sndio osx_video libvisual" AC_SUBST(GST_PLUGINS_NONPORTED) dnl these are all the gst plug-ins, compilable without additional libs @@ -1710,13 +1710,6 @@ case "$host" in ;; esac -dnl check for QuickTime -translit(dnm, m, l) AM_CONDITIONAL(USE_QUICKTIME, true) -AG_GST_CHECK_FEATURE(QUICKTIME, [QuickTime wrapper], qtwrapper, [ - AC_CHECK_TYPE([SampleReferenceRecord], HAVE_QUICKTIME="yes", HAVE_QUICKTIME="no", - [#include ]) -]) - dnl check for shm_open (for shm plugin) translit(dnm, m, l) AM_CONDITIONAL(USE_SHM, true) AG_GST_CHECK_FEATURE(SHM, [POSIX shared memory source and sink], shm, [ @@ -3291,7 +3284,6 @@ sys/fbdev/Makefile sys/linsys/Makefile sys/opensles/Makefile sys/osxvideo/Makefile -sys/qtwrapper/Makefile sys/shm/Makefile sys/uvch264/Makefile sys/vcd/Makefile diff --git a/sys/Makefile.am b/sys/Makefile.am index 28528be4cd..fc21638cc9 100644 --- a/sys/Makefile.am +++ b/sys/Makefile.am @@ -124,12 +124,6 @@ endif # QCAM_DIR= # endif -if USE_QUICKTIME -QT_DIR=qtwrapper -else -QT_DIR= -endif - if USE_WININET WININET_DIR=wininet else @@ -160,9 +154,9 @@ else UVCH264_DIR= endif -SUBDIRS = $(ACM_DIR) $(ANDROID_MEDIA_DIR) $(APPLE_MEDIA_DIR) $(AVC_DIR) $(BLUEZ_DIR) $(D3DVIDEOSINK_DIR) $(DECKLINK_DIR) $(DIRECTDRAW_DIR) $(DIRECTSOUND_DIR) $(WINKS_DIR) $(DVB_DIR) $(FBDEV_DIR) $(LINSYS_DIR) $(OPENSLES_DIR) $(OSX_VIDEO_DIR) $(PVR_DIR) $(QT_DIR) $(SHM_DIR) $(UVCH264_DIR) $(VCD_DIR) $(VDPAU_DIR) $(WININET_DIR) $(WINSCREENCAP_DIR) $(WASAPI_DIR) +SUBDIRS = $(ACM_DIR) $(ANDROID_MEDIA_DIR) $(APPLE_MEDIA_DIR) $(AVC_DIR) $(BLUEZ_DIR) $(D3DVIDEOSINK_DIR) $(DECKLINK_DIR) $(DIRECTDRAW_DIR) $(DIRECTSOUND_DIR) $(WINKS_DIR) $(DVB_DIR) $(FBDEV_DIR) $(LINSYS_DIR) $(OPENSLES_DIR) $(OSX_VIDEO_DIR) $(PVR_DIR) $(SHM_DIR) $(UVCH264_DIR) $(VCD_DIR) $(VDPAU_DIR) $(WININET_DIR) $(WINSCREENCAP_DIR) $(WASAPI_DIR) DIST_SUBDIRS = acmenc acmmp3dec androidmedia applemedia applemedia-nonpublic avc bluez d3dvideosink decklink directdraw directsound dvb linsys fbdev dshowdecwrapper dshowsrcwrapper dshowvideosink \ - opensles osxvideo pvr2d qtwrapper shm uvch264 vcd vdpau wasapi wininet winks winscreencap + opensles osxvideo pvr2d shm uvch264 vcd vdpau wasapi wininet winks winscreencap include $(top_srcdir)/common/parallel-subdirs.mak diff --git a/sys/qtwrapper/Makefile.am b/sys/qtwrapper/Makefile.am deleted file mode 100644 index 29b894f6a7..0000000000 --- a/sys/qtwrapper/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -plugin_LTLIBRARIES = libgstqtwrapper.la - -# sources used to compile this plug-in -libgstqtwrapper_la_SOURCES = \ - qtwrapper.c \ - qtutils.c \ - codecmapping.c \ - audiodecoders.c \ - videodecoders.c \ - imagedescription.c - -# flags used to compile this plugin -# add other _CFLAGS and _LIBS as needed -libgstqtwrapper_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) -libgstqtwrapper_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) -libgstqtwrapper_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -Wl,-framework,CoreAudio,-framework,AudioToolbox,-framework,Carbon,-framework,QuickTime,-framework,QuartzCore -libgstqtwrapper_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) - -# headers we need but don't want installed -noinst_HEADERS = \ - codecmapping.h \ - qtwrapper.h \ - qtutils.h \ - imagedescription.h diff --git a/sys/qtwrapper/audiodecoders.c b/sys/qtwrapper/audiodecoders.c deleted file mode 100644 index 0a6ddbc15c..0000000000 --- a/sys/qtwrapper/audiodecoders.c +++ /dev/null @@ -1,1101 +0,0 @@ -/* - * GStreamer QuickTime audio decoder codecs wrapper - * Copyright <2006, 2007> Fluendo - * Copyright <2006, 2007, 2008> Pioneers of the Inevitable - * - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Alternatively, the contents of this file may be used under the - * GNU Lesser General Public License Version 2.1 (the "LGPL"), in - * which case the following provisions apply instead of the ones - * mentioned above: - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include -#include "qtwrapper.h" -#include "codecmapping.h" -#include "qtutils.h" - -#ifdef G_OS_WIN32 -#include -#else -#include -#endif - -#define QTWRAPPER_ADEC_PARAMS_QDATA g_quark_from_static_string("qtwrapper-adec-params") - -#define NO_MORE_INPUT_DATA 42 - -static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-float, " - "endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, " - "signed = (boolean) { TRUE }, " - "width = (int) 32, " - "depth = (int) 32, " "rate = (int) [1, MAX], " - "channels = (int) [1, MAX]") - ); - -typedef struct _QTWrapperAudioDecoder QTWrapperAudioDecoder; -typedef struct _QTWrapperAudioDecoderClass QTWrapperAudioDecoderClass; - -struct _QTWrapperAudioDecoder -{ - GstElement parent; - - GstPad *sinkpad; - GstPad *srcpad; - - /* FIXME : all following should be protected by a mutex */ - ComponentInstance adec; /* The Audio Decoder component */ - AudioStreamBasicDescription indesc, outdesc; - - guint samplerate; - guint channels; - - AudioBufferList *bufferlist; - AudioStreamPacketDescription aspd[1]; - - /* first time received after NEWSEGMENT */ - GstClockTime initial_time; - /* offset in samples from the initial time */ - guint64 cur_offset; - /* TRUE just after receiving a NEWSEGMENT */ - gboolean gotnewsegment; - - /* Data for StdAudio callbacks */ - GstBuffer *input_buffer; -}; - -struct _QTWrapperAudioDecoderClass -{ - GstElementClass parent_class; - - /* fourcc of the format */ - guint32 componentSubType; - - GstPadTemplate *sinktempl; -}; - -typedef struct _QTWrapperAudioDecoderParams QTWrapperAudioDecoderParams; - -struct _QTWrapperAudioDecoderParams -{ - Component component; - GstCaps *sinkcaps; -}; - -static gboolean qtwrapper_audio_decoder_sink_setcaps (GstPad * pad, - GstCaps * caps); -static GstFlowReturn qtwrapper_audio_decoder_chain (GstPad * pad, - GstBuffer * buf); -static gboolean qtwrapper_audio_decoder_sink_event (GstPad * pad, - GstEvent * event); - -static void -qtwrapper_audio_decoder_init (QTWrapperAudioDecoder * qtwrapper) -{ - QTWrapperAudioDecoderClass *oclass; - - oclass = (QTWrapperAudioDecoderClass *) (G_OBJECT_GET_CLASS (qtwrapper)); - - /* Sink pad */ - qtwrapper->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink"); - gst_pad_set_setcaps_function (qtwrapper->sinkpad, - GST_DEBUG_FUNCPTR (qtwrapper_audio_decoder_sink_setcaps)); - gst_pad_set_chain_function (qtwrapper->sinkpad, - GST_DEBUG_FUNCPTR (qtwrapper_audio_decoder_chain)); - gst_pad_set_event_function (qtwrapper->sinkpad, - GST_DEBUG_FUNCPTR (qtwrapper_audio_decoder_sink_event)); - gst_element_add_pad (GST_ELEMENT (qtwrapper), qtwrapper->sinkpad); - - /* Source pad */ - qtwrapper->srcpad = gst_pad_new_from_static_template (&src_templ, "src"); - gst_element_add_pad (GST_ELEMENT (qtwrapper), qtwrapper->srcpad); -} - -static void -clear_AudioStreamBasicDescription (AudioStreamBasicDescription * desc) -{ - desc->mSampleRate = 0; - desc->mFormatID = 0; - desc->mFormatFlags = 0; - desc->mBytesPerPacket = 0; - desc->mFramesPerPacket = 0; - desc->mBytesPerFrame = 0; - desc->mChannelsPerFrame = 0; - desc->mBitsPerChannel = 0; - desc->mReserved = 0; -} - -static void -fill_indesc_mp3 (QTWrapperAudioDecoder * qtwrapper, guint32 fourcc, gint rate, - gint channels) -{ - GST_INFO_OBJECT (qtwrapper, "Filling input description for MP3 data"); - clear_AudioStreamBasicDescription (&qtwrapper->indesc); - /* only the samplerate is needed apparently */ - qtwrapper->indesc.mSampleRate = (double) rate; - qtwrapper->indesc.mFormatID = kAudioFormatMPEGLayer3; - qtwrapper->indesc.mChannelsPerFrame = channels; -} - -static void -fill_indesc_aac (QTWrapperAudioDecoder * qtwrapper, guint32 fourcc, gint rate, - gint channels) -{ - clear_AudioStreamBasicDescription (&qtwrapper->indesc); - qtwrapper->indesc.mSampleRate = (double) rate; - qtwrapper->indesc.mFormatID = kAudioFormatMPEG4AAC; - /* aac always has 1024 frames per packet */ - qtwrapper->indesc.mFramesPerPacket = 1024; - qtwrapper->indesc.mChannelsPerFrame = channels; -} - -static void -fill_indesc_samr (QTWrapperAudioDecoder * qtwrapper, guint32 fourcc, - gint channels) -{ - clear_AudioStreamBasicDescription (&qtwrapper->indesc); - qtwrapper->indesc.mSampleRate = 8000; - qtwrapper->indesc.mFormatID = fourcc; - qtwrapper->indesc.mChannelsPerFrame = 1; - qtwrapper->indesc.mFramesPerPacket = 160; -} - -static void -fill_indesc_generic (QTWrapperAudioDecoder * qtwrapper, guint32 fourcc, - gint rate, gint channels) -{ - clear_AudioStreamBasicDescription (&qtwrapper->indesc); - qtwrapper->indesc.mSampleRate = rate; - qtwrapper->indesc.mFormatID = fourcc; - qtwrapper->indesc.mChannelsPerFrame = channels; -} - -static void -fill_indesc_alac (QTWrapperAudioDecoder * qtwrapper, guint32 fourcc, - gint rate, gint channels) -{ - clear_AudioStreamBasicDescription (&qtwrapper->indesc); - qtwrapper->indesc.mSampleRate = rate; - qtwrapper->indesc.mFormatID = fourcc; - qtwrapper->indesc.mChannelsPerFrame = channels; - - // This has to be set, but the particular value doesn't seem to matter much - qtwrapper->indesc.mFramesPerPacket = 4096; -} - -static gpointer -make_alac_magic_cookie (GstBuffer * codec_data, gsize * len) -{ - guint8 *res; - - if (GST_BUFFER_SIZE (codec_data) < 4) - return NULL; - - *len = 20 + GST_BUFFER_SIZE (codec_data); - res = g_malloc0 (*len); - - /* 12 first bytes are 'frma' (format) atom with 'alac' value */ - GST_WRITE_UINT32_BE (res, 0xc); /* Atom length: 12 bytes */ - GST_WRITE_UINT32_LE (res + 4, QT_MAKE_FOURCC_BE ('f', 'r', 'm', 'a')); - GST_WRITE_UINT32_LE (res + 8, QT_MAKE_FOURCC_BE ('a', 'l', 'a', 'c')); - - /* Write the codec_data, but with the first four bytes reversed (different - endianness). This is the 'alac' atom. */ - GST_WRITE_UINT32_BE (res + 12, - GST_READ_UINT32_LE (GST_BUFFER_DATA (codec_data))); - memcpy (res + 16, GST_BUFFER_DATA (codec_data) + 4, - GST_BUFFER_SIZE (codec_data) - 4); - - /* Terminator atom */ - GST_WRITE_UINT32_BE (res + 12 + GST_BUFFER_SIZE (codec_data), 8); - GST_WRITE_UINT32_BE (res + 12 + GST_BUFFER_SIZE (codec_data) + 4, 0); - - return res; -} - -static gpointer -make_samr_magic_cookie (GstBuffer * codec_data, gsize * len) -{ - guint8 *res; - - *len = 48; - res = g_malloc0 (0x30); - - /* 12 first bytes are 'frma' (format) atom with 'samr' value */ - GST_WRITE_UINT32_BE (res, 0xc); - GST_WRITE_UINT32_LE (res + 4, QT_MAKE_FOURCC_BE ('f', 'r', 'm', 'a')); - GST_WRITE_UINT32_LE (res + 8, QT_MAKE_FOURCC_BE ('s', 'a', 'm', 'r')); - - /* 10 bytes for 'enda' atom with 0 */ - GST_WRITE_UINT32_BE (res + 12, 10); - GST_WRITE_UINT32_LE (res + 16, QT_MAKE_FOURCC_BE ('e', 'n', 'd', 'a')); - - /* 17(+1) bytes for the codec_data contents */ - GST_WRITE_UINT32_BE (res + 22, 18); - memcpy (res + 26, GST_BUFFER_DATA (codec_data) + 4, 17); - - /* yes... we need to replace 'damr' by 'samr'. Blame Apple ! */ - GST_WRITE_UINT8 (res + 26, 's'); - - /* Terminator atom */ - GST_WRITE_UINT32_BE (res + 40, 8); - -#if DEBUG_DUMP - gst_util_dump_mem (res, 48); -#endif - - return res; -} - -static int -write_len (guint8 * buf, int val) -{ - /* This is some sort of variable-length coding, but the quicktime - * file(s) I have here all just use a 4-byte version, so we'll do that. - * Return the number of bytes written; - */ - buf[0] = ((val >> 21) & 0x7f) | 0x80; - buf[1] = ((val >> 14) & 0x7f) | 0x80; - buf[2] = ((val >> 7) & 0x7f) | 0x80; - buf[3] = ((val >> 0) & 0x7f); - - return 4; -} - -static void -aac_parse_codec_data (GstBuffer * codec_data, gint * channels) -{ - guint8 *data = GST_BUFFER_DATA (codec_data); - guint codec_channels; - - if (GST_BUFFER_SIZE (codec_data) < 2) { - GST_WARNING ("Cannot parse codec_data for channel count"); - return; - } - - codec_channels = (data[1] & 0x7f) >> 3; - - if (*channels != codec_channels) { - GST_INFO ("Overwriting channels %d with %d", *channels, codec_channels); - *channels = (gint) codec_channels; - } else { - GST_INFO ("Retaining channel count %d", codec_channels); - } -} - -/* The AAC decoder requires the entire mpeg4 audio elementary stream - * descriptor, which is the body (except the 4-byte version field) of - * the quicktime 'esds' atom. However, qtdemux only passes through the - * (two byte, normally) payload, so we need to reconstruct the ESD */ - -/* TODO: Get the AAC spec, and verify this implementation */ -static gpointer -make_aac_magic_cookie (GstBuffer * codec_data, gsize * len) -{ - guint8 *cookie; - int offset = 0; - int decoder_specific_len = GST_BUFFER_SIZE (codec_data); - int config_len = 13 + 5 + decoder_specific_len; - int es_len = 3 + 5 + config_len + 5 + 1; - int total_len = es_len + 5; - - cookie = g_malloc0 (total_len); - *len = total_len; - - /* Structured something like this: - * [ES Descriptor - * [Config Descriptor - * [Specific Descriptor]] - * [Unknown]] - */ - - QT_WRITE_UINT8 (cookie + offset, 0x03); - offset += 1; /* ES Descriptor tag */ - offset += write_len (cookie + offset, es_len); - QT_WRITE_UINT16 (cookie + offset, 0); - offset += 2; /* Track ID */ - QT_WRITE_UINT8 (cookie + offset, 0); - offset += 1; /* Flags */ - - QT_WRITE_UINT8 (cookie + offset, 0x04); - offset += 1; /* Config Descriptor tag */ - offset += write_len (cookie + offset, config_len); - - /* TODO: Fix these up */ - QT_WRITE_UINT8 (cookie + offset, 0x40); - offset += 1; /* object_type_id */ - QT_WRITE_UINT8 (cookie + offset, 0x15); - offset += 1; /* stream_type */ - QT_WRITE_UINT24 (cookie + offset, 0x1800); - offset += 3; /* buffer_size_db */ - QT_WRITE_UINT32 (cookie + offset, 128000); - offset += 4; /* max_bitrate */ - QT_WRITE_UINT32 (cookie + offset, 128000); - offset += 4; /* avg_bitrate */ - - QT_WRITE_UINT8 (cookie + offset, 0x05); - offset += 1; /* Specific Descriptor tag */ - offset += write_len (cookie + offset, decoder_specific_len); - memcpy (cookie + offset, GST_BUFFER_DATA (codec_data), decoder_specific_len); - offset += decoder_specific_len; - - /* TODO: What is this? 'SL descriptor' apparently, but what does that mean? */ - QT_WRITE_UINT8 (cookie + offset, 0x06); - offset += 1; /* SL Descriptor tag */ - offset += write_len (cookie + offset, 1); - QT_WRITE_UINT8 (cookie + offset, 2); - offset += 1; - - return cookie; -} - -static void -close_decoder (QTWrapperAudioDecoder * qtwrapper) -{ - if (qtwrapper->adec) { - CloseComponent (qtwrapper->adec); - qtwrapper->adec = NULL; - } - - if (qtwrapper->bufferlist) { - DestroyAudioBufferList (qtwrapper->bufferlist); - qtwrapper->bufferlist = NULL; - } -} - -static gboolean -open_decoder (QTWrapperAudioDecoder * qtwrapper, GstCaps * caps, - GstCaps ** othercaps) -{ - gboolean ret = FALSE; - QTWrapperAudioDecoderClass *oclass; - - /* TODO: these will be used as the output rate/channels for formats that - * don't supply these in the caps. This isn't very nice! - */ - gint channels = 2; - gint rate = 44100; - - OSStatus status; - GstStructure *s; - gchar *tmp; - const GValue *value; - GstBuffer *codec_data = NULL; - gboolean have_esds = FALSE; - - /* Clean up any existing decoder */ - close_decoder (qtwrapper); - - tmp = gst_caps_to_string (caps); - GST_LOG_OBJECT (qtwrapper, "caps: %s", tmp); - g_free (tmp); - - /* extract rate/channels information from the caps */ - s = gst_caps_get_structure (caps, 0); - gst_structure_get_int (s, "rate", &rate); - gst_structure_get_int (s, "channels", &channels); - - /* get codec_data */ - if ((value = gst_structure_get_value (s, "codec_data"))) { - codec_data = GST_BUFFER_CAST (gst_value_get_mini_object (value)); - } - - oclass = (QTWrapperAudioDecoderClass *) (G_OBJECT_GET_CLASS (qtwrapper)); - - if (codec_data - && oclass->componentSubType == QT_MAKE_FOURCC_LE ('m', 'p', '4', 'a')) { - /* QuickTime/iTunes creates AAC files with the wrong channel count in the header, - so parse that out of the codec data if we can. - */ - aac_parse_codec_data (codec_data, &channels); - } - - /* If the quicktime demuxer gives us a full esds atom, use that instead of - * the codec_data */ - if ((value = gst_structure_get_value (s, "quicktime_esds"))) { - have_esds = TRUE; - codec_data = GST_BUFFER_CAST (gst_value_get_mini_object (value)); - } -#if DEBUG_DUMP - if (codec_data) - gst_util_dump_mem (GST_BUFFER_DATA (codec_data), - GST_BUFFER_SIZE (codec_data)); -#endif - - - GST_INFO_OBJECT (qtwrapper, "rate:%d, channels:%d", rate, channels); - - GST_INFO_OBJECT (qtwrapper, "componentSubType is %" GST_FOURCC_FORMAT, - QT_FOURCC_ARGS (oclass->componentSubType)); - - /* Setup the input format description, some format require special handling */ - switch (oclass->componentSubType) { - case QT_MAKE_FOURCC_LE ('.', 'm', 'p', '3'): - fill_indesc_mp3 (qtwrapper, oclass->componentSubType, rate, channels); - break; - case QT_MAKE_FOURCC_LE ('m', 'p', '4', 'a'): - fill_indesc_aac (qtwrapper, oclass->componentSubType, rate, channels); - break; - case QT_MAKE_FOURCC_LE ('s', 'a', 'm', 'r'): - fill_indesc_samr (qtwrapper, oclass->componentSubType, channels); - rate = 8000; - break; - case QT_MAKE_FOURCC_LE ('a', 'l', 'a', 'c'): - fill_indesc_alac (qtwrapper, oclass->componentSubType, rate, channels); - break; - default: - fill_indesc_generic (qtwrapper, oclass->componentSubType, rate, channels); - break; - } - -#if DEBUG_DUMP - gst_util_dump_mem ((gpointer) & qtwrapper->indesc, - sizeof (AudioStreamBasicDescription)); -#endif - - qtwrapper->samplerate = rate; - qtwrapper->channels = channels; - - /* Create an instance of SCAudio */ - status = OpenADefaultComponent (StandardCompressionType, - StandardCompressionSubTypeAudio, &qtwrapper->adec); - if (status) { - GST_WARNING_OBJECT (qtwrapper, - "Error instantiating SCAudio component: %ld", status); - qtwrapper->adec = NULL; - goto beach; - } - - /* This is necessary to make setting the InputBasicDescription succeed; - without it SCAudio only accepts PCM as input. Presumably a bug in - QuickTime. Thanks to Arek for figuring this one out! - */ - { - QTAtomContainer audiosettings = NULL; - - SCGetSettingsAsAtomContainer (qtwrapper->adec, &audiosettings); - SCSetSettingsFromAtomContainer (qtwrapper->adec, audiosettings); - - /* TODO: Figure out if disposing of the QTAtomContainer is needed here */ - } - - /* Set the input description info on the SCAudio instance */ - status = QTSetComponentProperty (qtwrapper->adec, kQTPropertyClass_SCAudio, - kQTSCAudioPropertyID_InputBasicDescription, - sizeof (qtwrapper->indesc), &qtwrapper->indesc); - if (status) { - GST_WARNING_OBJECT (qtwrapper, - "Error setting input description on SCAudio: %ld", status); - - GST_ELEMENT_ERROR (qtwrapper, STREAM, NOT_IMPLEMENTED, - ("A QuickTime error occurred trying to decode this stream"), - ("QuickTime returned error status %lx", status)); - goto beach; - } - - /* TODO: we can select a channel layout here, figure out if we want to */ - - /* if we have codec_data, give it to the converter ! */ - if (codec_data) { - gsize len = 0; - gpointer magiccookie; - - switch (oclass->componentSubType) { - /* Some decoders want the 'magic cookie' in a different format from how - * gstreamer represents it. So, convert... - */ - case QT_MAKE_FOURCC_LE ('s', 'a', 'm', 'r'): - magiccookie = make_samr_magic_cookie (codec_data, &len); - break; - case QT_MAKE_FOURCC_LE ('a', 'l', 'a', 'c'): - magiccookie = make_alac_magic_cookie (codec_data, &len); - break; - case QT_MAKE_FOURCC_LE ('m', 'p', '4', 'a'): - if (!have_esds) { - magiccookie = make_aac_magic_cookie (codec_data, &len); - break; - } - /* Else: fallthrough */ - default: - len = GST_BUFFER_SIZE (codec_data); - magiccookie = GST_BUFFER_DATA (codec_data); - break; - } - - if (magiccookie) { - GST_LOG_OBJECT (qtwrapper, "Setting magic cookie %p of size %" - G_GSIZE_FORMAT, magiccookie, len); - -#if DEBUG_DUMP - gst_util_dump_mem (magiccookie, len); -#endif - - status = - QTSetComponentProperty (qtwrapper->adec, kQTPropertyClass_SCAudio, - kQTSCAudioPropertyID_InputMagicCookie, len, magiccookie); - if (status) { - GST_WARNING_OBJECT (qtwrapper, "Error setting extra codec data: %ld", - status); - goto beach; - } - - g_free (magiccookie); - } - } - - /* Set output to be interleaved raw PCM */ - { - OSType outputFormat = kAudioFormatLinearPCM; - SCAudioFormatFlagsRestrictions restrictions = { 0 }; - - /* Set the mask in order to set this flag to zero */ - restrictions.formatFlagsMask = - kAudioFormatFlagIsFloat | kAudioFormatFlagIsBigEndian; - restrictions.formatFlagsValues = kAudioFormatFlagIsFloat; - - status = QTSetComponentProperty (qtwrapper->adec, kQTPropertyClass_SCAudio, - kQTSCAudioPropertyID_ClientRestrictedLPCMFlags, - sizeof (restrictions), &restrictions); - if (status) { - GST_WARNING_OBJECT (qtwrapper, "Error setting PCM to interleaved: %ld", - status); - goto beach; - } - - status = QTSetComponentProperty (qtwrapper->adec, kQTPropertyClass_SCAudio, - kQTSCAudioPropertyID_ClientRestrictedCompressionFormatList, - sizeof (outputFormat), &outputFormat); - if (status) { - GST_WARNING_OBJECT (qtwrapper, "Error setting output to PCM: %ld", - status); - goto beach; - } - } - - qtwrapper->outdesc.mSampleRate = 0; /* Use recommended; we read this out later */ - qtwrapper->outdesc.mFormatID = kAudioFormatLinearPCM; - qtwrapper->outdesc.mFormatFlags = kAudioFormatFlagIsFloat; - qtwrapper->outdesc.mBytesPerPacket = 0; - qtwrapper->outdesc.mFramesPerPacket = 0; - qtwrapper->outdesc.mBytesPerFrame = 4 * channels; - qtwrapper->outdesc.mChannelsPerFrame = channels; - qtwrapper->outdesc.mBitsPerChannel = 32; - qtwrapper->outdesc.mReserved = 0; - - status = QTSetComponentProperty (qtwrapper->adec, kQTPropertyClass_SCAudio, - kQTSCAudioPropertyID_BasicDescription, - sizeof (qtwrapper->outdesc), &qtwrapper->outdesc); - if (status) { - GST_WARNING_OBJECT (qtwrapper, "Error setting output description: %ld", - status); - goto beach; - } - - status = QTGetComponentProperty (qtwrapper->adec, kQTPropertyClass_SCAudio, - kQTSCAudioPropertyID_BasicDescription, - sizeof (qtwrapper->outdesc), &qtwrapper->outdesc, NULL); - - if (status) { - GST_WARNING_OBJECT (qtwrapper, - "Failed to get output audio description: %ld", status); - ret = FALSE; - goto beach; - } - - if (qtwrapper->outdesc.mFormatID != kAudioFormatLinearPCM /*|| - (qtwrapper->outdesc.mFormatFlags & kAudioFormatFlagIsFloat) != - kAudioFormatFlagIsFloat */ ) { - GST_WARNING_OBJECT (qtwrapper, "Output is not floating point PCM"); - ret = FALSE; - goto beach; - } - - qtwrapper->samplerate = (int) qtwrapper->outdesc.mSampleRate; - qtwrapper->channels = qtwrapper->outdesc.mChannelsPerFrame; - GST_DEBUG_OBJECT (qtwrapper, "Output is %d Hz, %d channels", - qtwrapper->samplerate, qtwrapper->channels); - - /* Create output bufferlist, big enough for 200ms of audio */ - GST_DEBUG_OBJECT (qtwrapper, "Allocating bufferlist for %d channels", - channels); - qtwrapper->bufferlist = - AllocateAudioBufferList (channels, - qtwrapper->samplerate / 5 * qtwrapper->channels * 4); - - /* Create output caps matching the format the component is giving us */ - *othercaps = gst_caps_new_simple ("audio/x-raw-float", - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "signed", G_TYPE_BOOLEAN, TRUE, - "width", G_TYPE_INT, 32, - "depth", G_TYPE_INT, 32, - "rate", G_TYPE_INT, qtwrapper->samplerate, "channels", G_TYPE_INT, - qtwrapper->channels, NULL); - - ret = TRUE; - -beach: - return ret; -} - -static gboolean -qtwrapper_audio_decoder_sink_setcaps (GstPad * pad, GstCaps * caps) -{ - QTWrapperAudioDecoder *qtwrapper; - gboolean ret = FALSE; - GstCaps *othercaps = NULL; - - qtwrapper = (QTWrapperAudioDecoder *) gst_pad_get_parent (pad); - - GST_LOG_OBJECT (qtwrapper, "caps:%" GST_PTR_FORMAT, caps); - - /* 1. open decoder */ - if (!(open_decoder (qtwrapper, caps, &othercaps))) - goto beach; - - /* 2. set caps downstream */ - ret = gst_pad_set_caps (qtwrapper->srcpad, othercaps); - -beach: - if (othercaps) - gst_caps_unref (othercaps); - gst_object_unref (qtwrapper); - return ret; -} - -static OSStatus -process_buffer_cb (ComponentInstance inAudioConverter, - UInt32 * ioNumberDataPackets, - AudioBufferList * ioData, - AudioStreamPacketDescription ** outDataPacketDescription, - QTWrapperAudioDecoder * qtwrapper) -{ - GST_LOG_OBJECT (qtwrapper, - "ioNumberDataPackets:%lu, iodata:%p, outDataPacketDescription:%p", - *ioNumberDataPackets, ioData, outDataPacketDescription); - if (outDataPacketDescription) - GST_LOG ("*outDataPacketDescription:%p", *outDataPacketDescription); - - GST_LOG ("mNumberBuffers : %u", (guint32) ioData->mNumberBuffers); - GST_LOG ("mData:%p , mDataByteSize:%u", - ioData->mBuffers[0].mData, (guint32) ioData->mBuffers[0].mDataByteSize); - - ioData->mBuffers[0].mData = NULL; - ioData->mBuffers[0].mDataByteSize = 0; - - *ioNumberDataPackets = 1; - - if (qtwrapper->input_buffer && GST_BUFFER_SIZE (qtwrapper->input_buffer)) { - ioData->mBuffers[0].mData = GST_BUFFER_DATA (qtwrapper->input_buffer); - ioData->mBuffers[0].mDataByteSize = - GST_BUFFER_SIZE (qtwrapper->input_buffer); - - /* if we have a valid outDataPacketDescription, we need to fill it */ - if (outDataPacketDescription) { - qtwrapper->aspd[0].mStartOffset = 0; - qtwrapper->aspd[0].mVariableFramesInPacket = 0; - qtwrapper->aspd[0].mDataByteSize = - GST_BUFFER_SIZE (qtwrapper->input_buffer); - *outDataPacketDescription = qtwrapper->aspd; - } - - GST_LOG_OBJECT (qtwrapper, "returning %d bytes at %p", - GST_BUFFER_SIZE (qtwrapper->input_buffer), ioData->mBuffers[0].mData); - - qtwrapper->input_buffer = 0; - return noErr; - } - - GST_LOG_OBJECT (qtwrapper, - "No remaining input data, returning NO_MORE_INPUT_DATA"); - - return NO_MORE_INPUT_DATA; -} - -static GstFlowReturn -qtwrapper_audio_decoder_chain (GstPad * pad, GstBuffer * buf) -{ - GstFlowReturn ret = GST_FLOW_OK; - QTWrapperAudioDecoder *qtwrapper; - GstBuffer *outbuf; - OSStatus status; - guint32 outsamples; - guint32 savedbytes; - guint32 realbytes; - - qtwrapper = (QTWrapperAudioDecoder *) gst_pad_get_parent (pad); - - if (!qtwrapper->adec) { - GST_WARNING_OBJECT (qtwrapper, "QTWrapper not initialised"); - goto beach; - } - - GST_LOG_OBJECT (qtwrapper, - "buffer:%p , timestamp:%" GST_TIME_FORMAT " ,size:%d", buf, - GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_BUFFER_SIZE (buf)); - -#if DEBUG_DUMP - gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); -#endif - - if (qtwrapper->gotnewsegment) { - - GST_DEBUG_OBJECT (qtwrapper, "SCAudioReset()"); - - SCAudioReset (qtwrapper->adec); - - /* some formats can give us a better initial time using the buffer - * timestamp. */ - if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buf))) - qtwrapper->initial_time = GST_BUFFER_TIMESTAMP (buf); - - qtwrapper->gotnewsegment = FALSE; - } - - outsamples = qtwrapper->bufferlist->mBuffers[0].mDataByteSize / 8; - savedbytes = qtwrapper->bufferlist->mBuffers[0].mDataByteSize; - - qtwrapper->input_buffer = buf; - - do { - GST_LOG_OBJECT (qtwrapper, - "Calling SCAudioFillBuffer(outsamples:%d , outdata:%p)", outsamples, - qtwrapper->bufferlist->mBuffers[0].mData); - - /* Ask SCAudio to give us data ! */ - status = SCAudioFillBuffer (qtwrapper->adec, - (SCAudioInputDataProc) process_buffer_cb, - qtwrapper, (UInt32 *) & outsamples, qtwrapper->bufferlist, NULL); - - if ((status != noErr) && (status != NO_MORE_INPUT_DATA)) { - if (status < 0) - GST_WARNING_OBJECT (qtwrapper, - "Error in SCAudioFillBuffer() : %d", (gint32) status); - else - GST_WARNING_OBJECT (qtwrapper, - "Error in SCAudioFillBuffer() : %" GST_FOURCC_FORMAT, - QT_FOURCC_ARGS (status)); - ret = GST_FLOW_ERROR; - goto beach; - } - - realbytes = qtwrapper->bufferlist->mBuffers[0].mDataByteSize; - - GST_LOG_OBJECT (qtwrapper, "We now have %d samples [%d bytes]", - outsamples, realbytes); - - qtwrapper->bufferlist->mBuffers[0].mDataByteSize = savedbytes; - - if (!outsamples) - goto beach; - - /* 4. Create buffer and copy data in it */ - ret = gst_pad_alloc_buffer (qtwrapper->srcpad, qtwrapper->cur_offset, - realbytes, GST_PAD_CAPS (qtwrapper->srcpad), &outbuf); - if (ret != GST_FLOW_OK) - goto beach; - - /* copy data from bufferlist to output buffer */ - memmove (GST_BUFFER_DATA (outbuf), - qtwrapper->bufferlist->mBuffers[0].mData, realbytes); - - /* 5. calculate timestamp and duration */ - GST_BUFFER_TIMESTAMP (outbuf) = - qtwrapper->initial_time + gst_util_uint64_scale_int (GST_SECOND, - (gint) qtwrapper->cur_offset, qtwrapper->samplerate); - GST_BUFFER_SIZE (outbuf) = realbytes; - GST_BUFFER_DURATION (outbuf) = - gst_util_uint64_scale_int (GST_SECOND, - realbytes / (qtwrapper->channels * 4), qtwrapper->samplerate); - - GST_LOG_OBJECT (qtwrapper, - "timestamp:%" GST_TIME_FORMAT ", duration:%" GST_TIME_FORMAT - "offset:%lld, offset_end:%lld", - GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)), - GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)), - GST_BUFFER_OFFSET (outbuf), GST_BUFFER_OFFSET_END (outbuf)); - - qtwrapper->cur_offset += outsamples; - - /* 6. push buffer downstream */ - - ret = gst_pad_push (qtwrapper->srcpad, outbuf); - if (ret != GST_FLOW_OK) - goto beach; - - GST_DEBUG_OBJECT (qtwrapper, - "Read %d bytes, could have read up to %d bytes", realbytes, savedbytes); - } while (status != NO_MORE_INPUT_DATA); - -beach: - gst_buffer_unref (buf); - gst_object_unref (qtwrapper); - return ret; -} - -static gboolean -qtwrapper_audio_decoder_sink_event (GstPad * pad, GstEvent * event) -{ - QTWrapperAudioDecoder *qtwrapper; - gboolean ret = FALSE; - - qtwrapper = (QTWrapperAudioDecoder *) gst_pad_get_parent (pad); - - GST_LOG_OBJECT (qtwrapper, "event:%s", GST_EVENT_TYPE_NAME (event)); - - switch (GST_EVENT_TYPE (event)) { - /* TODO: Flush events should reset the decoder component */ - case GST_EVENT_NEWSEGMENT:{ - gint64 start, stop, position; - gboolean update; - gdouble rate; - GstFormat format; - - GST_LOG ("We've got a newsegment"); - gst_event_parse_new_segment (event, &update, &rate, &format, &start, - &stop, &position); - - /* if the format isn't time, we need to create a new time newsegment */ - /* FIXME : This is really bad, we should convert the values properly to time */ - if (format != GST_FORMAT_TIME) { - GstEvent *newevent; - - GST_WARNING_OBJECT (qtwrapper, - "Original event wasn't in GST_FORMAT_TIME, creating new fake one."); - - start = 0; - - newevent = - gst_event_new_new_segment (update, rate, GST_FORMAT_TIME, start, - GST_CLOCK_TIME_NONE, start); - gst_event_unref (event); - event = newevent; - } - - qtwrapper->initial_time = start; - qtwrapper->cur_offset = 0; - - GST_LOG ("initial_time is now %" GST_TIME_FORMAT, GST_TIME_ARGS (start)); - - if (qtwrapper->adec) - qtwrapper->gotnewsegment = TRUE; - - break; - } - default: - break; - } - - ret = gst_pad_push_event (qtwrapper->srcpad, event); - - gst_object_unref (qtwrapper); - return TRUE; -} - -static void -qtwrapper_audio_decoder_base_init (QTWrapperAudioDecoderClass * klass) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (klass); - gchar *name = NULL; - gchar *info = NULL; - char *longname, *description; - ComponentDescription desc; - QTWrapperAudioDecoderParams *params; - - params = (QTWrapperAudioDecoderParams *) - g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass), - QTWRAPPER_ADEC_PARAMS_QDATA); - g_assert (params); - - get_name_info_from_component (params->component, &desc, &name, &info); - - /* Fill in details */ - longname = - g_strdup_printf ("QTWrapper SCAudio Audio Decoder : %s", - GST_STR_NULL (name)); - description = - g_strdup_printf ("QTWrapper SCAudio wrapper for decoder: %s", - GST_STR_NULL (info)); - gst_element_class_set_metadata (element_class, - longname, "Codec/Decoder/Audio", description, - "Fluendo , " - "Pioneers of the Inevitable "); - - g_free (longname); - g_free (description); - g_free (name); - g_free (info); - - /* Add pad templates */ - klass->sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK, - GST_PAD_ALWAYS, params->sinkcaps); - gst_element_class_add_pad_template (element_class, klass->sinktempl); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&src_templ)); - - /* Store class-global values */ - klass->componentSubType = desc.componentSubType; -} - -static void -qtwrapper_audio_decoder_dispose (GObject * object) -{ - QTWrapperAudioDecoder *qtwrapper = (QTWrapperAudioDecoder *) object; - QTWrapperAudioDecoderClass *oclass = - (QTWrapperAudioDecoderClass *) (G_OBJECT_GET_CLASS (qtwrapper)); - GObjectClass *parent_class = g_type_class_peek_parent (oclass); - - close_decoder (qtwrapper); - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -qtwrapper_audio_decoder_class_init (QTWrapperAudioDecoderClass * klass) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) klass; - - object_class->dispose = qtwrapper_audio_decoder_dispose; -} - -gboolean -qtwrapper_audio_decoders_register (GstPlugin * plugin) -{ - gboolean res = TRUE; - Component componentID = NULL; - - ComponentDescription desc = { - kSoundDecompressor, 0, 0, 0, 0 - }; - - GTypeInfo typeinfo = { - sizeof (QTWrapperAudioDecoderClass), - (GBaseInitFunc) qtwrapper_audio_decoder_base_init, - NULL, - (GClassInitFunc) qtwrapper_audio_decoder_class_init, - NULL, - NULL, - sizeof (QTWrapperAudioDecoder), - 0, - (GInstanceInitFunc) qtwrapper_audio_decoder_init, - }; - - /* Find all SoundDecompressors ! */ - GST_DEBUG ("There are %ld decompressors available", CountComponents (&desc)); - - /* loop over SoundDecompressors */ - do { - componentID = FindNextComponent (componentID, &desc); - - GST_LOG ("componentID : %p", componentID); - - if (componentID) { - ComponentDescription thisdesc; - gchar *name = NULL, *info = NULL; - GstCaps *caps = NULL; - gchar *type_name = NULL; - GType type; - QTWrapperAudioDecoderParams *params = NULL; - - if (!(get_name_info_from_component (componentID, &thisdesc, &name, - &info))) - goto next; - - GST_LOG (" name:%s", GST_STR_NULL (name)); - GST_LOG (" info:%s", GST_STR_NULL (info)); - - GST_LOG (" type:%" GST_FOURCC_FORMAT, - QT_FOURCC_ARGS (thisdesc.componentType)); - GST_LOG (" subtype:%" GST_FOURCC_FORMAT, - QT_FOURCC_ARGS (thisdesc.componentSubType)); - GST_LOG (" manufacturer:%" GST_FOURCC_FORMAT, - QT_FOURCC_ARGS (thisdesc.componentManufacturer)); - - if (!(caps = - fourcc_to_caps (QT_READ_UINT32 (&thisdesc.componentSubType)))) - goto next; - - type_name = g_strdup_printf ("qtwrapperaudiodec_%" GST_FOURCC_FORMAT, - QT_FOURCC_ARGS (thisdesc.componentSubType)); - g_strdelimit (type_name, " .", '_'); - - if (g_type_from_name (type_name)) { - GST_WARNING ("We already have a registered plugin for %s", type_name); - goto next; - } - - params = g_new0 (QTWrapperAudioDecoderParams, 1); - params->component = componentID; - params->sinkcaps = gst_caps_ref (caps); - - type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0); - /* Store params in type qdata */ - g_type_set_qdata (type, QTWRAPPER_ADEC_PARAMS_QDATA, (gpointer) params); - - /* register type */ - if (!gst_element_register (plugin, type_name, GST_RANK_MARGINAL, type)) { - g_warning ("Failed to register %s", type_name);; - g_type_set_qdata (type, QTWRAPPER_ADEC_PARAMS_QDATA, NULL); - g_free (params); - res = FALSE; - goto next; - } - - next: - if (name) - g_free (name); - if (info) - g_free (info); - if (type_name) - g_free (type_name); - if (caps) - gst_caps_unref (caps); - } - - } while (componentID && res); - - return res; -} diff --git a/sys/qtwrapper/codecmapping.c b/sys/qtwrapper/codecmapping.c deleted file mode 100644 index a0a07960de..0000000000 --- a/sys/qtwrapper/codecmapping.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * GStreamer QuickTime codec mapping - * Copyright <2006, 2007> Fluendo - * Copyright <2006, 2007> Pioneers of the Inevitable - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Alternatively, the contents of this file may be used under the - * GNU Lesser General Public License Version 2.1 (the "LGPL"), in - * which case the following provisions apply instead of the ones - * mentioned above: - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "qtwrapper.h" -#include "codecmapping.h" -#include "qtutils.h" - -static GstCaps * -audio_caps_from_string (const gchar * str) -{ - GstCaps *res; - - res = gst_caps_from_string (str); - gst_caps_set_simple (res, - "rate", GST_TYPE_INT_RANGE, 8000, 96000, - "channels", GST_TYPE_INT_RANGE, 1, 2, NULL); - - return res; -} - -GstCaps * -fourcc_to_caps (guint32 fourcc) -{ - GstCaps *caps = NULL; - - GST_DEBUG ("%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc)); - - switch (fourcc) { - /* VIDEO */ - case QT_MAKE_FOURCC_LE ('S', 'V', 'Q', '1'): - caps = gst_caps_new_simple ("video/x-svq", - "svqversion", G_TYPE_INT, 1, NULL); - break; - case QT_MAKE_FOURCC_LE ('S', 'V', 'Q', '3'): - caps = gst_caps_new_simple ("video/x-svq", - "svqversion", G_TYPE_INT, 3, NULL); - break; - case QT_MAKE_FOURCC_LE ('a', 'v', 'c', '1'): - caps = gst_caps_from_string ("video/x-h264"); - break; - case QT_MAKE_FOURCC_LE ('m', 'p', '4', 'v'): - caps = - gst_caps_from_string - ("video/mpeg,mpegversion=4,systemstream=(boolean)false"); - break; - case QT_MAKE_FOURCC_LE ('m', 'p', 'e', 'g'): - caps = gst_caps_from_string ("video/mpeg, " - "systemstream = (boolean) false, " "mpegversion = (int) 1"); - break; - case QT_MAKE_FOURCC_LE ('h', '2', '6', '3'): - case QT_MAKE_FOURCC_LE ('H', '2', '6', '3'): - case QT_MAKE_FOURCC_LE ('s', '2', '6', '3'): - case QT_MAKE_FOURCC_LE ('U', '2', '6', '3'): - caps = gst_caps_from_string ("video/x-h263"); - break; - case QT_MAKE_FOURCC_LE ('c', 'v', 'i', 'd'): - caps = gst_caps_from_string ("video/x-cinepak"); - break; - case QT_MAKE_FOURCC_LE ('d', 'v', 'c', 'p'): - case QT_MAKE_FOURCC_LE ('d', 'v', 'c', ' '): - case QT_MAKE_FOURCC_LE ('d', 'v', 's', 'd'): - case QT_MAKE_FOURCC_LE ('D', 'V', 'S', 'D'): - case QT_MAKE_FOURCC_LE ('d', 'v', 'c', 's'): - case QT_MAKE_FOURCC_LE ('D', 'V', 'C', 'S'): - case QT_MAKE_FOURCC_LE ('d', 'v', '2', '5'): - case QT_MAKE_FOURCC_LE ('d', 'v', 'p', 'p'): - caps = gst_caps_from_string ("video/x-dv, systemstream=(boolean)false"); - break; - - /* AUDIO */ - case QT_MAKE_FOURCC_LE ('.', 'm', 'p', '3'): - caps = - audio_caps_from_string - ("audio/mpeg,mpegversion=1,layer=3,parsed=(boolean)true"); - break; - case QT_MAKE_FOURCC_LE ('Q', 'D', 'M', '2'): - caps = audio_caps_from_string ("audio/x-qdm2"); - break; - case QT_MAKE_FOURCC_LE ('a', 'g', 's', 'm'): - caps = audio_caps_from_string ("audio/x-gsm"); - break; - case QT_MAKE_FOURCC_LE ('a', 'l', 'a', 'c'): - caps = audio_caps_from_string ("audio/x-alac"); - break; - case QT_MAKE_FOURCC_LE ('a', 'l', 'a', 'w'): - caps = audio_caps_from_string ("audio/x-alaw"); - break; - case QT_MAKE_FOURCC_LE ('m', 'p', '4', 'a'): - case QT_MAKE_FOURCC_LE ('a', 'a', 'c', ' '): - caps = audio_caps_from_string ("audio/mpeg,mpegversion=4"); - break; - case QT_MAKE_FOURCC_LE ('s', 'a', 'm', 'r'): - caps = audio_caps_from_string ("audio/AMR"); - break; - case QT_MAKE_FOURCC_LE ('u', 'l', 'a', 'w'): - caps = audio_caps_from_string ("audio/x-mulaw"); - break; - case QT_MAKE_FOURCC_LE ('A', 'V', 'd', 'n'): - caps = audio_caps_from_string ("video/x-dnxhd"); - break; - case QT_MAKE_FOURCC_LE ('i', 'c', 'o', 'd'): - caps = audio_caps_from_string ("video/x-apple-intermediate-codec"); - break; - /* TO FILL !! */ - case QT_MAKE_FOURCC_LE ('M', 'A', 'C', '3'): - case QT_MAKE_FOURCC_LE ('M', 'A', 'C', '6'): - case QT_MAKE_FOURCC_LE ('Q', 'D', 'M', 'C'): - case QT_MAKE_FOURCC_LE ('Q', 'c', 'l', 'p'): - case QT_MAKE_FOURCC_LE ('Q', 'c', 'l', 'q'): - case QT_MAKE_FOURCC_LE ('d', 'v', 'c', 'a'): - default: - break; - } - - return caps; -} diff --git a/sys/qtwrapper/codecmapping.h b/sys/qtwrapper/codecmapping.h deleted file mode 100644 index 106ffe70e4..0000000000 --- a/sys/qtwrapper/codecmapping.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * GStreamer QuickTime codec mapping - * Copyright <2006, 2007> Fluendo - * Copyright <2006, 2007> Pioneers of the Inevitable - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Alternatively, the contents of this file may be used under the - * GNU Lesser General Public License Version 2.1 (the "LGPL"), in - * which case the following provisions apply instead of the ones - * mentioned above: - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include -#include "qtwrapper.h" - -#ifdef G_OS_WIN32 -#include -#else -#include -#endif - - -/* - * fourcc_to_caps: - * - * Return the caps for a given fourcc. - */ - -GstCaps *fourcc_to_caps (guint32 fourcc); diff --git a/sys/qtwrapper/imagedescription.c b/sys/qtwrapper/imagedescription.c deleted file mode 100644 index e14d60be9d..0000000000 --- a/sys/qtwrapper/imagedescription.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * GStreamer QuickTime video decoder codecs wrapper - * Copyright <2006, 2007> Fluendo - * Copyright <2006, 2007> Pioneers of the Inevitable - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Alternatively, the contents of this file may be used under the - * GNU Lesser General Public License Version 2.1 (the "LGPL"), in - * which case the following provisions apply instead of the ones - * mentioned above: - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include - -#include "imagedescription.h" - -static ImageDescription * -image_description_for_avc1 (GstBuffer * buf) -{ - ImageDescription *desc = NULL; - guint8 *pos; - - desc = g_malloc0 (sizeof (ImageDescription) + GST_BUFFER_SIZE (buf) + 8); - pos = (guint8 *) desc + sizeof (ImageDescription); - - desc->idSize = sizeof (ImageDescription) + GST_BUFFER_SIZE (buf) + 8; - /* write size in Big-Endian */ - GST_WRITE_UINT32_BE (pos, GST_BUFFER_SIZE (buf) + 8); - GST_WRITE_UINT32_LE (pos + 4, QT_MAKE_FOURCC_BE ('a', 'v', 'c', 'C')); - memmove (pos + 8, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); - - return desc; -} - -/* image_description_for_mp4v - * - * mpeg4 video has an 'esds' atom as extension for the ImageDescription. - * It is meant to contain the ES Description. - * We here create a fake one. - */ - -static ImageDescription * -image_description_for_mp4v (GstBuffer * buf) -{ - ImageDescription *desc = NULL; - guint32 offset = sizeof (ImageDescription); - guint8 *location; - - GST_LOG ("buf %p , size:%d", buf, GST_BUFFER_SIZE (buf)); - - /* this image description contains: - * ImageDescription sizeof(ImageDescription) - * esds atom 34 bytes - * buffer GST_BUFFER_SIZE (buf) - * ending 3 bytes - */ - - desc = g_malloc0 (offset + 37 + GST_BUFFER_SIZE (buf)); - desc->idSize = offset + 37 + GST_BUFFER_SIZE (buf); - - location = (guint8 *) desc + offset; - - /* Fill in ESDS */ - /* size */ - GST_WRITE_UINT32_BE (location, 37 + GST_BUFFER_SIZE (buf)); - /* atom */ - GST_WRITE_UINT32_LE (location + 4, GST_MAKE_FOURCC ('e', 's', 'd', 's')); - /* version + flags */ - QT_WRITE_UINT32 (location + 8, 0); - /* tag */ - QT_WRITE_UINT8 (location + 12, 0x3); - /* size (buffsize + 23) */ - QT_WRITE_UINT8 (location + 13, GST_BUFFER_SIZE (buf) + 23); - /* ESID */ - QT_WRITE_UINT16 (location + 14, 0); - /* priority */ - QT_WRITE_UINT8 (location + 16, 0); - /* tag */ - QT_WRITE_UINT8 (location + 17, 0x4); - /* size (buffsize + 8) */ - QT_WRITE_UINT8 (location + 18, GST_BUFFER_SIZE (buf) + 15); - /* object type */ - QT_WRITE_UINT8 (location + 19, 0x20); - /* stream type */ - QT_WRITE_UINT8 (location + 20, 0x11); - /* buffersize db */ - QT_WRITE_UINT24 (location + 21, 13640); - /* max bitrate */ - QT_WRITE_UINT32 (location + 24, 1849648); - /* avg bitrate */ - QT_WRITE_UINT32 (location + 28, 918191); - /* tag */ - QT_WRITE_UINT8 (location + 32, 0x05); - /* size */ - QT_WRITE_UINT8 (location + 33, GST_BUFFER_SIZE (buf)); - /* codec data */ - memmove (location + 34, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); - /* end */ - QT_WRITE_UINT8 (location + 34 + GST_BUFFER_SIZE (buf), 0x06); - QT_WRITE_UINT8 (location + 34 + GST_BUFFER_SIZE (buf) + 1, 0x01); - QT_WRITE_UINT8 (location + 34 + GST_BUFFER_SIZE (buf) + 2, 0x02); - - return desc; -} - -static ImageDescription * -image_description_from_stsd_buffer (GstBuffer * buf) -{ - ImageDescription *desc = NULL; - guint8 *content; - guint size; - gint imds; - - GST_LOG ("buffer %p, size:%u", buf, GST_BUFFER_SIZE (buf)); - - /* The buffer contains a full atom, we only need the contents */ - /* This buffer has data in big-endian, we need to read it as such. - * except for the fourcc which are ALWAYS big-endian. */ - content = GST_BUFFER_DATA (buf) + 16; - size = GST_BUFFER_SIZE (buf) - 16; - -#if DEBUG_DUMP - GST_LOG ("incoming data in big-endian"); - gst_util_dump_mem (content, size); -#endif - - desc = g_malloc0 (size); - desc->idSize = size; - desc->cType = GST_READ_UINT32_BE (content + 4); - desc->version = QT_UINT16 (content + 16); - desc->revisionLevel = QT_UINT16 (content + 18); - desc->vendor = GST_READ_UINT32_BE (content + 20); - desc->temporalQuality = QT_UINT32 (content + 24); - desc->spatialQuality = QT_UINT32 (content + 24); - desc->dataSize = QT_UINT32 (content + 44); - desc->frameCount = QT_UINT16 (content + 48); - desc->depth = QT_UINT16 (content + 82); - desc->clutID = QT_UINT16 (content + 84); - - imds = 86; /* sizeof (ImageDescription); */ - - if (desc->idSize > imds) { - GST_LOG ("Copying %d bytes from %p to %p", - size - imds, content + imds, desc + imds); - memcpy ((guint8 *) desc + imds, (guint8 *) content + imds, size - imds); - } -#if DEBUG_DUMP - GST_LOG ("outgoing data in machine-endian"); - dump_image_description (desc); -#endif - - return desc; -} - -ImageDescription * -image_description_from_codec_data (GstBuffer * buf, guint32 codectype) -{ - ImageDescription *desc = NULL; - - GST_LOG ("codectype:%" GST_FOURCC_FORMAT " buf:%p", - GST_FOURCC_ARGS (codectype), buf); - - if ((GST_BUFFER_SIZE (buf) == GST_READ_UINT32_BE (GST_BUFFER_DATA (buf))) && - (QT_MAKE_FOURCC_LE ('s', 't', 's', - 'd') == GST_READ_UINT32_BE (GST_BUFFER_DATA (buf) + 4))) { - /* We have the full stsd (ImageDescription) in our codec_data */ - desc = image_description_from_stsd_buffer (buf); - } else { - switch (codectype) { - case QT_MAKE_FOURCC_LE ('m', 'p', '4', 'v'): - desc = image_description_for_mp4v (buf); - break; - case QT_MAKE_FOURCC_LE ('a', 'v', 'c', '1'): - desc = image_description_for_avc1 (buf); - break; - default: - GST_WARNING ("Format not handled !"); - } - } - return desc; -} diff --git a/sys/qtwrapper/imagedescription.h b/sys/qtwrapper/imagedescription.h deleted file mode 100644 index cd5481ac61..0000000000 --- a/sys/qtwrapper/imagedescription.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * GStreamer QuickTime video decoder codecs wrapper - * Copyright <2006, 2007> Fluendo - * Copyright <2006, 2007> Pioneers of the Inevitable - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Alternatively, the contents of this file may be used under the - * GNU Lesser General Public License Version 2.1 (the "LGPL"), in - * which case the following provisions apply instead of the ones - * mentioned above: - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "qtwrapper.h" -#include "qtutils.h" - -ImageDescription *image_description_from_codec_data (GstBuffer * buf, - guint32 codec); diff --git a/sys/qtwrapper/qtutils.c b/sys/qtwrapper/qtutils.c deleted file mode 100644 index 506d761c58..0000000000 --- a/sys/qtwrapper/qtutils.c +++ /dev/null @@ -1,493 +0,0 @@ -/* - * GStreamer QuickTime codec mapping - * Copyright <2006, 2007> Fluendo - * Copyright <2006, 2007> Pioneers of the Inevitable - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Alternatively, the contents of this file may be used under the - * GNU Lesser General Public License Version 2.1 (the "LGPL"), in - * which case the following provisions apply instead of the ones - * mentioned above: - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include "qtutils.h" - -gboolean -get_name_info_from_component (Component componentID, - ComponentDescription * desc, gchar ** name, gchar ** info) -{ - Handle nameHandle = NewHandle (200); - Handle infoHandle = NewHandle (200); - gchar *tmpname; - gchar *tmpinfo; - OSErr result; - gboolean ret = TRUE; - - result = GetComponentInfo (componentID, desc, nameHandle, infoHandle, NULL); - if (result != noErr) { - ret = FALSE; - goto done; - } -#if DEBUG_DUMP - GST_LOG ("ComponentDescription dump"); - gst_util_dump_mem ((const guchar *) desc, sizeof (ComponentDescription)); - gst_util_dump_mem ((gpointer) * nameHandle, 200); - gst_util_dump_mem ((gpointer) * infoHandle, 200); - GST_LOG ("0x%x 0x%x", **((guint8 **) nameHandle), **((guint8 **) infoHandle)); -#endif - - if (*nameHandle && name) { - gsize read, written; - - tmpname = g_strndup ((*(char **) nameHandle) + 1, - **((guint8 **) nameHandle)); - *name = g_convert_with_fallback (tmpname, -1, "ASCII", "MAC", - (gchar *) " ", &read, &written, NULL); - if (!*name) - GST_WARNING ("read:%" G_GSIZE_FORMAT ", written:%" G_GSIZE_FORMAT, read, - written); - g_free (tmpname); - } - - if (*infoHandle && info) { - tmpinfo = - g_strndup ((*(char **) infoHandle) + 1, **((guint8 **) infoHandle)); - *info = - g_convert_with_fallback (tmpinfo, -1, "ASCII", "MAC", (gchar *) " ", - NULL, NULL, NULL); - g_free (tmpinfo); - } - -done: - DisposeHandle (nameHandle); - DisposeHandle (infoHandle); - - return ret; -} - -/* -struct CodecDecompressParams { - ImageSequence sequenceID; - ImageDescriptionHandle imageDescription; - Ptr data; - long bufferSize; - long frameNumber; - long startLine; - long stopLine; - long conditionFlags; - CodecFlags callerFlags; - CodecCapabilities * capabilities; - ICMProgressProcRecord progressProcRecord; - ICMCompletionProcRecord completionProcRecord; - ICMDataProcRecord dataProcRecord; - CGrafPtr port; - PixMap dstPixMap; - BitMapPtr maskBits; - PixMapPtr mattePixMap; - Rect srcRect; - MatrixRecord * matrix; - CodecQ accuracy; - short transferMode; - ICMFrameTimePtr frameTime; - long reserved[1]; - SInt8 matrixFlags; - SInt8 matrixType; - Rect dstRect; - UInt16 majorSourceChangeSeed; - UInt16 minorSourceChangeSeed; - CDSequenceDataSourcePtr sourceData; - RgnHandle maskRegion; - OSType ** wantedDestinationPixelTypes; - long screenFloodMethod; - long screenFloodValue; - short preferredOffscreenPixelSize; - ICMFrameTimeInfoPtr syncFrameTime; - Boolean needUpdateOnTimeChange; - Boolean enableBlackLining; - Boolean needUpdateOnSourceChange; - Boolean pad; - long unused; - CGrafPtr finalDestinationPort; - long requestedBufferWidth; - long requestedBufferHeight; - Rect displayableAreaOfRequestedBuffer; - Boolean requestedSingleField; - Boolean needUpdateOnNextIdle; - Boolean pad2[2]; - fixed bufferGammaLevel; - UInt32 taskWeight; - OSType taskName; -}; - */ - -/* struct ImageDescription { */ -/* long idSize; /\* total size of this structure *\/ */ -/* 4 CodecType cType; /\* compressor creator type *\/ */ -/* 8 long resvd1; /\* reserved--must be set to 0 *\/ */ -/* 12 short resvd2; /\* reserved--must be set to 0 *\/ */ -/* 14 short dataRefIndex; /\* reserved--must be set to 0 *\/ */ -/* 16 short version; /\* version of compressed data *\/ */ -/* 18 short revisionLevel; /\* compressor that created data *\/ */ -/* 20 long vendor; /\* compressor developer that created data *\/ */ -/* 24 CodecQ temporalQuality; */ -/* /\* degree of temporal compression *\/ */ -/* 28 CodecQ spatialQuality; */ -/* /\* degree of spatial compression *\/ */ -/* 32 short width; /\* width of source image in pixels *\/ */ -/* 34 short height; /\* height of source image in pixels *\/ */ -/* 36 Fixed hRes; /\* horizontal resolution of source image *\/ */ -/* 40 Fixed vRes; /\* vertical resolution of source image *\/ */ -/* 44 long dataSize; /\* size in bytes of compressed data *\/ */ -/* 48 short frameCount; /\* number of frames in image data *\/ */ -/* 50 Str31 name; /\* name of compression algorithm *\/ */ -/* 82 short depth; /\* pixel depth of source image *\/ */ -/* 84 short clutID; /\* ID number of the color table for image *\/ */ -/* }; */ - - -gboolean -get_output_info_from_component (Component componentID) -{ - gboolean ret = FALSE; - ComponentInstance instance; - ImageSubCodecDecompressCapabilities caps; - CodecInfo info; - - GST_LOG ("Creating an instance"); - - /* 1. Create an instance */ - if (!(instance = OpenComponent (componentID))) { - GST_WARNING ("Couldn't open component"); - return FALSE; - } - - /* 2. initialize */ - memset (&caps, 0, sizeof (ImageSubCodecDecompressCapabilities)); - if (ImageCodecInitialize (instance, &caps) != noErr) { - GST_WARNING ("ImageCodecInitialize() failed"); - goto beach; - } -#if DEBUG_DUMP - GST_LOG ("ImageSubCodecDecompressCapabilities"); - gst_util_dump_mem ((const guchar *) &caps, - sizeof (ImageSubCodecDecompressCapabilities)); -#endif - - GST_LOG ("recordSize:%ld", caps.recordSize); - GST_LOG ("decompressRecordSize:%ld", caps.decompressRecordSize); - GST_LOG ("canAsync:%d", caps.canAsync); - - /* 3. Get codec info */ - memset (&info, 0, sizeof (CodecInfo)); - if (ImageCodecGetCodecInfo (instance, &info) != noErr) { - GST_WARNING ("ImageCodecInfo() failed"); - goto beach; - }; - -#if DEBUG_DUMP - GST_LOG ("CodecInfo"); - gst_util_dump_mem ((const guchar *) &info, sizeof (CodecInfo)); -#endif - - GST_LOG ("version:%d", info.version); - GST_LOG ("revisionLevel:%d", info.revisionLevel); - GST_LOG ("vendor:%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (info.vendor)); - - /* Compression flags */ - /* Contains flags (see below) that specify the decompression capabilities of - * the component. Typically, these flags are of interest only to developers of - * image decompressors. */ - GST_LOG ("decompressFlags:%lx", info.decompressFlags); - if (info.decompressFlags & codecInfoDoes1) - GST_LOG ("Depth 1 OK"); - if (info.decompressFlags & codecInfoDoes2) - GST_LOG ("Depth 2 OK"); - if (info.decompressFlags & codecInfoDoes4) - GST_LOG ("Depth 4 OK"); - if (info.decompressFlags & codecInfoDoes8) - GST_LOG ("Depth 8 OK"); - if (info.decompressFlags & codecInfoDoes16) - GST_LOG ("Depth 16 OK"); - if (info.decompressFlags & codecInfoDoes32) - GST_LOG ("Depth 32 OK"); - GST_LOG ("compressFlags:%lx", info.compressFlags); - - /* Format FLAGS */ - /* Contains flags (see below) that describe the possible format for compressed - * data produced by this component and the format of compressed files that the - * component can handle during decompression. Typically, these flags are of - * interest only to developers of compressor components. - */ - GST_LOG ("formatFlags:%lx", info.formatFlags); - if (info.formatFlags & codecInfoDepth1) - GST_LOG ("Depth 1 OK"); - if (info.formatFlags & codecInfoDepth2) - GST_LOG ("Depth 2 OK"); - if (info.formatFlags & codecInfoDepth4) - GST_LOG ("Depth 4 OK"); - if (info.formatFlags & codecInfoDepth8) - GST_LOG ("Depth 8 OK"); - if (info.formatFlags & codecInfoDepth16) - GST_LOG ("Depth 16 OK"); - if (info.formatFlags & codecInfoDepth24) - GST_LOG ("Depth 24 OK"); - if (info.formatFlags & codecInfoDepth32) - GST_LOG ("Depth 32 OK"); - if (info.formatFlags & codecInfoDepth33) - GST_LOG ("Depth 33 OK"); - if (info.formatFlags & codecInfoDepth34) - GST_LOG ("Depth 34 OK"); - if (info.formatFlags & codecInfoDepth36) - GST_LOG ("Depth 36 OK"); - if (info.formatFlags & codecInfoDepth40) - GST_LOG ("Depth 40 OK"); - if (info.formatFlags & codecInfoStoresClut) - GST_LOG ("StoresClut OK"); - if (info.formatFlags & codecInfoDoesLossless) - GST_LOG ("Lossless OK"); - if (info.formatFlags & codecInfoSequenceSensitive) - GST_LOG ("SequenceSentitive OK"); - - - GST_LOG ("compressionAccuracy:%u", info.compressionAccuracy); - GST_LOG ("decompressionAccuracy:%u", info.decompressionAccuracy); - GST_LOG ("compressionSpeed:%d", info.compressionSpeed); - GST_LOG ("decompressionSpeed:%d", info.decompressionSpeed); - GST_LOG ("compressionLevel:%u", info.compressionLevel); - GST_LOG ("minimumHeight:%d", info.minimumHeight); - GST_LOG ("minimumWidth:%d", info.minimumWidth); - -/* /\* . Call ImageCodecPreDecompress *\/ */ -/* memset(¶ms, 0, sizeof(CodecDecompressParams)); */ -/* GST_LOG ("calling imagecodecpredecompress"); */ -/* if (ImageCodecPreDecompress (instance, ¶ms) != noErr) { */ -/* GST_WARNING ("Error in ImageCodecPreDecompress"); */ -/* goto beach; */ -/* } */ - -/* GST_INFO ("sequenceID : %d", params.sequenceID); */ - - ret = TRUE; - -beach: - /* Free instance */ - CloseComponent (instance); - return TRUE; -} - -void -dump_avcc_atom (guint8 * atom) -{ - /* first 8 bytes : length + atom */ - GST_LOG ("version:0x%x", QT_UINT8 (atom + 8)); - GST_LOG ("Profile:%d", QT_UINT8 (atom + 9)); - GST_LOG ("Compatible profiles : 0x%x", QT_UINT8 (atom + 10)); - GST_LOG ("Level:%d", QT_UINT8 (atom + 11)); -} - -void -dump_image_description (ImageDescription * desc) -{ - GST_LOG ("Description %p , size:%" G_GSIZE_FORMAT, desc, desc->idSize); - -#if DEBUG_DUMP - gst_util_dump_mem ((const guchar *) desc, desc->idSize); -#endif - - GST_LOG ("cType : %" GST_FOURCC_FORMAT, QT_FOURCC_ARGS (desc->cType)); - GST_LOG ("version:%d", desc->version); - GST_LOG ("revisionLevel:%d", desc->revisionLevel); - GST_LOG ("vendor:%" GST_FOURCC_FORMAT, QT_FOURCC_ARGS (desc->vendor)); - GST_LOG ("temporalQuality:%lu", desc->temporalQuality); - GST_LOG ("spatialQuality:%lu", desc->spatialQuality); - GST_LOG ("width:%u", desc->width); - GST_LOG ("height:%u", desc->height); - GST_LOG ("hres:%f", desc->hRes / 65536.0); - GST_LOG ("vres:%f", desc->vRes / 65536.0); - GST_LOG ("dataSize:%" G_GSIZE_FORMAT, desc->dataSize); - GST_LOG ("frameCount:%d", desc->frameCount); - GST_LOG ("name:%.*s", desc->name[0], desc->name + 1); - GST_LOG ("depth:%d", desc->depth); - GST_LOG ("clutID:%d", desc->clutID); - - if (desc->idSize > sizeof (ImageDescription)) { - guint8 *extradata = (guint8 *) desc + sizeof (ImageDescription); - guint32 type = QT_READ_UINT32 (extradata + 4); - - GST_LOG ("Extra Data size:%lu", - (gulong) desc->idSize - (gulong) sizeof (ImageDescription)); -#if DEBUG_DUMP - gst_util_dump_mem ((gpointer) (gulong) desc + - (gulong) sizeof (ImageDescription), - (gulong) desc->idSize - (gulong) sizeof (ImageDescription)); -#endif - GST_LOG ("Extra Data Type : %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (type)); - if (type == QT_MAKE_FOURCC ('a', 'v', 'c', 'C')) - dump_avcc_atom (extradata); - } -} - -void -dump_codec_decompress_params (CodecDecompressParams * params) -{ - GST_LOG ("params %p", params); - -#if DEBUG_DUMP - gst_util_dump_mem ((const guchar *) params, sizeof (CodecDecompressParams)); -#endif - - GST_LOG ("SequenceID:%ld", params->sequenceID); - GST_LOG ("imageDescription:%p", params->imageDescription); - GST_LOG ("data:%p", params->data); - GST_LOG ("bufferSize:%ld", params->bufferSize); - GST_LOG ("frameNumber:%ld", params->frameNumber); - GST_LOG ("startLine:%ld , StopLine:%ld", params->startLine, - params->stopLine); - GST_LOG ("conditionFlags:0x%lx", params->conditionFlags); - GST_LOG ("callerFlags:0x%x", params->callerFlags); - GST_LOG ("capabilities:%p", params->capabilities); - GST_LOG ("port:%p", params->port); - GST_LOG ("dstPixMap"); -#if DEBUG_DUMP - gst_util_dump_mem ((const guchar *) ¶ms->dstPixMap, sizeof (PixMap)); -#endif - - GST_LOG ("maskBits:%p", params->maskBits); - GST_LOG ("mattePixMap:%p", params->mattePixMap); - GST_LOG ("srcRect %d/%d/%d/%d", - params->srcRect.top, params->srcRect.bottom, - params->srcRect.left, params->srcRect.right); - - GST_LOG ("matrix:%p", params->matrix); - GST_LOG ("accuracy:%ld", params->accuracy); - GST_LOG ("transferMode:%d", params->transferMode); - GST_LOG ("frameTime:%p", params->frameTime); - GST_LOG ("matrixFlags:%x", params->matrixFlags); - - GST_LOG ("dstRect %d/%d/%d/%d", - params->dstRect.top, params->dstRect.bottom, - params->dstRect.left, params->dstRect.right); - - GST_LOG ("sourceData:%p", params->sourceData); - - if (params->wantedDestinationPixelTypes) { - OSType *tmp; - - for (tmp = *params->wantedDestinationPixelTypes; *tmp; tmp++) - GST_LOG ("Destination pixel %" GST_FOURCC_FORMAT, QT_FOURCC_ARGS (*tmp)); - } -} - -void -addSInt32ToDictionary (CFMutableDictionaryRef dictionary, CFStringRef key, - SInt32 numberSInt32) -{ - CFNumberRef number = - CFNumberCreate (NULL, kCFNumberSInt32Type, &numberSInt32); - if (!number) - return; - CFDictionaryAddValue (dictionary, key, number); - CFRelease (number); -} - -void -dump_cvpixel_buffer (CVPixelBufferRef pixbuf) -{ - gsize left, right, top, bottom; - - GST_LOG ("buffer %p", pixbuf); - if (CVPixelBufferLockBaseAddress (pixbuf, 0)) { - GST_WARNING ("Couldn't lock base adress on pixel buffer !"); - return; - } - GST_LOG ("Width:%" G_GSIZE_FORMAT " , Height:%" G_GSIZE_FORMAT, - CVPixelBufferGetWidth (pixbuf), CVPixelBufferGetHeight (pixbuf)); - GST_LOG ("Format:%" GST_FOURCC_FORMAT, - GST_FOURCC_ARGS (CVPixelBufferGetPixelFormatType (pixbuf))); - GST_LOG ("base address:%p", CVPixelBufferGetBaseAddress (pixbuf)); - GST_LOG ("Bytes per row:%" G_GSIZE_FORMAT, - CVPixelBufferGetBytesPerRow (pixbuf)); - GST_LOG ("Data Size:%" G_GSIZE_FORMAT, CVPixelBufferGetDataSize (pixbuf)); - GST_LOG ("Plane count:%" G_GSIZE_FORMAT, CVPixelBufferGetPlaneCount (pixbuf)); - CVPixelBufferGetExtendedPixels (pixbuf, &left, &right, &top, &bottom); - GST_LOG ("Extended pixels. left/right/top/bottom : %" G_GSIZE_FORMAT - "/%" G_GSIZE_FORMAT "/%" G_GSIZE_FORMAT "/%" G_GSIZE_FORMAT, - left, right, top, bottom); - CVPixelBufferUnlockBaseAddress (pixbuf, 0); -} - - -// Convenience function to dispose of our audio buffers -void -DestroyAudioBufferList (AudioBufferList * list) -{ - UInt32 i; - - if (list) { - for (i = 0; i < list->mNumberBuffers; i++) { - if (list->mBuffers[i].mData) - free (list->mBuffers[i].mData); - } - free (list); - } -} - -// Convenience function to allocate our audio buffers -AudioBufferList * -AllocateAudioBufferList (UInt32 numChannels, UInt32 size) -{ - AudioBufferList *list; - - list = (AudioBufferList *) calloc (1, sizeof (AudioBufferList)); - if (list == NULL) - return NULL; - - list->mNumberBuffers = 1; - list->mBuffers[0].mNumberChannels = numChannels; - list->mBuffers[0].mDataByteSize = size; - list->mBuffers[0].mData = malloc (size); - if (list->mBuffers[0].mData == NULL) { - DestroyAudioBufferList (list); - return NULL; - } - return list; -} diff --git a/sys/qtwrapper/qtutils.h b/sys/qtwrapper/qtutils.h deleted file mode 100644 index 287c31f220..0000000000 --- a/sys/qtwrapper/qtutils.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * GStreamer QuickTime codec mapping - * Copyright <2006, 2007> Fluendo - * Copyright <2006, 2007> Pioneers of the Inevitable - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Alternatively, the contents of this file may be used under the - * GNU Lesser General Public License Version 2.1 (the "LGPL"), in - * which case the following provisions apply instead of the ones - * mentioned above: - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef G_OS_WIN32 -#include -#else -#include -#endif -#include -#include "qtwrapper.h" - -#ifndef __QTUTILS_H__ -#define __QTUTILS_H__ - -#define QT_UINT32(a) (GST_READ_UINT32_BE(a)) -#define QT_UINT24(a) (GST_READ_UINT32_BE(a) >> 8) -#define QT_UINT16(a) (GST_READ_UINT16_BE(a)) -#define QT_UINT8(a) (GST_READ_UINT8(a)) -#define QT_FP32(a) ((GST_READ_UINT32_BE(a))/65536.0) -#define QT_FP16(a) ((GST_READ_UINT16_BE(a))/256.0) -#define QT_FOURCC(a) (GST_READ_UINT32_LE(a)) -#define QT_UINT64(a) ((((guint64)QT_UINT32(a))<<32)|QT_UINT32(((guint8 *)a)+4)) -#define QT_FOURCC_ARGS(fourcc) \ - ((gchar) (((fourcc)>>24)&0xff)), \ - ((gchar) (((fourcc)>>16)&0xff)), \ - ((gchar) (((fourcc)>>8 )&0xff)), \ - ((gchar) ((fourcc) &0xff)) - -#define QT_WRITE_UINT8(data, num) GST_WRITE_UINT8(data, num) - -#define QT_MAKE_FOURCC_BE(a,b,c,d) (guint32)((a)|(b)<<8|(c)<<16|(d)<<24) -#define QT_MAKE_FOURCC_LE(a,b,c,d) QT_MAKE_FOURCC_BE(d,c,b,a) - -#define _QT_PUT(__data, __idx, __size, __shift, __num) \ - (((guint8 *) (__data))[__idx] = (((guint##__size) __num) >> __shift) & 0xff) - -/* endianness-dependent macros */ -#if G_BYTE_ORDER == G_LITTLE_ENDIAN -#define QT_MAKE_FOURCC(a,b,c,d) QT_MAKE_FOURCC_LE(a,b,c,d) -#define QT_WRITE_UINT16(data, num) GST_WRITE_UINT16_LE(data, num) -#define QT_WRITE_UINT24(data, num) do { \ - _QT_PUT (data, 0, 32, 0, num); \ - _QT_PUT (data, 1, 32, 8, num); \ - _QT_PUT (data, 2, 32, 16, num); \ - } while (0) -#define QT_WRITE_UINT32(data, num) GST_WRITE_UINT32_LE(data, num) -#define QT_READ_UINT16(data) GST_READ_UINT16_LE(data) -#define QT_READ_UINT32(data) GST_READ_UINT32_LE(data) -#else -#define QT_MAKE_FOURCC(a,b,c,d) QT_MAKE_FOURCC_BE(a,b,c,d) -#define QT_WRITE_UINT16(data, num) GST_WRITE_UINT16_BE(data, num) -#define QT_WRITE_UINT24(data, num) do { \ - _QT_PUT (data, 0, 32, 16, num); \ - _QT_PUT (data, 1, 32, 8, num); \ - _QT_PUT (data, 2, 32, 0, num); \ - } while (0) -#define QT_WRITE_UINT32(data, num) GST_WRITE_UINT32_BE(data, num) -#define QT_READ_UINT16(data) GST_READ_UINT16_BE(data) -#define QT_READ_UINT32(data) GST_READ_UINT32_BE(data) -#endif - - -/* - * get_name_info_from_component: - * - * Fills name and info with the name and description from a Component - */ - -gboolean -get_name_info_from_component (Component component, ComponentDescription * desc, - gchar ** name, gchar ** info); - - - -gboolean get_output_info_from_component (Component component); - - - -void dump_image_description (ImageDescription * desc); -void dump_codec_decompress_params (CodecDecompressParams * params); - -guint32 destination_pixel_types_to_fourcc (OSType ** types); -void -addSInt32ToDictionary (CFMutableDictionaryRef dictionary, CFStringRef key, - SInt32 numberSInt32); - -void dump_cvpixel_buffer (CVPixelBufferRef pixbuf); - -void dump_avcc_atom (guint8 * atom); - -AudioBufferList *AllocateAudioBufferList(UInt32 numChannels, UInt32 size); - -void DestroyAudioBufferList(AudioBufferList* list); - -#endif /* __QTUTILS_H__ */ diff --git a/sys/qtwrapper/qtwrapper.c b/sys/qtwrapper/qtwrapper.c deleted file mode 100644 index b87573f538..0000000000 --- a/sys/qtwrapper/qtwrapper.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * GStreamer QuickTime codecs wrapper - * Copyright <2006, 2007> Fluendo - * Copyright <2006, 2007> Pioneers of the Inevitable - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Alternatively, the contents of this file may be used under the - * GNU Lesser General Public License Version 2.1 (the "LGPL"), in - * which case the following provisions apply instead of the ones - * mentioned above: - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "qtwrapper.h" -#include - -GST_DEBUG_CATEGORY (qtwrapper_debug); - -static gboolean -plugin_init (GstPlugin * plugin) -{ - gboolean res; - OSErr status; - - GST_DEBUG_CATEGORY_INIT (qtwrapper_debug, "qtwrapper", - 0, "QuickTime codecs wrappers"); - - /* Initialize quicktime environment */ -#ifdef G_OS_WIN32 - /* Only required on win32 */ - InitializeQTML (0); -#endif - - status = EnterMovies (); - if (status) { - GST_ERROR ("Error initializing QuickTime environment: %d", status); - return FALSE; - } - - GST_INFO ("Registering video decoders"); - res = qtwrapper_video_decoders_register (plugin); - GST_INFO ("Registering audio decoders"); - res &= qtwrapper_audio_decoders_register (plugin); - - return res; -} - -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, - GST_VERSION_MINOR, - qtwrapper, - "QuickTime codecs wrapper", - plugin_init, VERSION, "LGPL", "GStreamer", "http://gstreamer.net/") diff --git a/sys/qtwrapper/qtwrapper.h b/sys/qtwrapper/qtwrapper.h deleted file mode 100644 index 9e7d411154..0000000000 --- a/sys/qtwrapper/qtwrapper.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * GStreamer QuickTime codecs wrapper - * Copyright <2006, 2007> Fluendo - * Copyright <2006, 2007> Pioneers of the Inevitable - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Alternatively, the contents of this file may be used under the - * GNU Lesser General Public License Version 2.1 (the "LGPL"), in - * which case the following provisions apply instead of the ones - * mentioned above: - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_QTWRAPPER_H__ -#define __GST_QTWRAPPER_H__ - -#include -#ifdef G_OS_WIN32 -#include -#include -#else -#include -#endif - -/* Set following to 1 if you want to have extra debug in form of - * memory dumps */ -#define DEBUG_DUMP 0 - -GST_DEBUG_CATEGORY_EXTERN (qtwrapper_debug); -#define GST_CAT_DEFAULT qtwrapper_debug - -G_BEGIN_DECLS - -extern gboolean qtwrapper_video_decoders_register (GstPlugin *); -extern gboolean qtwrapper_audio_decoders_register (GstPlugin *); - -G_END_DECLS -#endif /* __GST_QTWRAPPER_H__ */ diff --git a/sys/qtwrapper/videodecoders.c b/sys/qtwrapper/videodecoders.c deleted file mode 100644 index 8c507e7790..0000000000 --- a/sys/qtwrapper/videodecoders.c +++ /dev/null @@ -1,872 +0,0 @@ -/* - * GStreamer QuickTime video decoder codecs wrapper - * Copyright <2006, 2007> Fluendo - * Copyright <2006, 2007> Pioneers of the Inevitable - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Alternatively, the contents of this file may be used under the - * GNU Lesser General Public License Version 2.1 (the "LGPL"), in - * which case the following provisions apply instead of the ones - * mentioned above: - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include "qtwrapper.h" -#include "codecmapping.h" -#include "qtutils.h" -#include "imagedescription.h" - -#define QTWRAPPER_VDEC_PARAMS_QDATA g_quark_from_static_string("qtwrapper-vdec-params") - -static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/x-raw-yuv")); - -typedef struct _QTWrapperVideoDecoder QTWrapperVideoDecoder; -typedef struct _QTWrapperVideoDecoderClass QTWrapperVideoDecoderClass; - -#define MAC_LOCK(qtwrapper) g_mutex_lock (qtwrapper->lock) -#define MAC_UNLOCK(qtwrapper) g_mutex_unlock (qtwrapper->lock) - -struct _QTWrapperVideoDecoder -{ - GstElement parent; - - GstPad *sinkpad; - GstPad *srcpad; - - GMutex *lock; - ComponentInstance instance; - CodecInfo codecinfo; - ImageDescriptionHandle idesc; - CodecDecompressParams *dparams; - CodecCapabilities codeccaps; - guint64 frameNumber; - ICMDecompressionSessionRef decsession; - GstFlowReturn lastret; - guint64 outsize; - guint width, height; - GstClockTime last_ts; - GstClockTime last_duration; - GstBuffer *prevbuf; - gboolean flushing; - gboolean framebuffering; - - /* width/height of output buffer */ - Rect rect; -}; - -struct _QTWrapperVideoDecoderClass -{ - GstElementClass parent_class; - - Component component; - guint32 componentType; - guint32 componentSubType; - - GstPadTemplate *sinktempl; -}; - -typedef struct _QTWrapperVideoDecoderParams QTWrapperVideoDecoderParams; - -struct _QTWrapperVideoDecoderParams -{ - Component component; - GstCaps *sinkcaps; -}; - -static GstElementClass *parent_class = NULL; - -static gboolean -qtwrapper_video_decoder_sink_setcaps (GstPad * pad, GstCaps * caps); -static GstFlowReturn qtwrapper_video_decoder_chain (GstPad * pad, - GstBuffer * buf); -static gboolean qtwrapper_video_decoder_sink_event (GstPad * pad, - GstEvent * event); - -static void qtwrapper_video_decoder_finalize (GObject * object); -static void decompressCb (void *decompressionTrackingRefCon, - OSStatus result, - ICMDecompressionTrackingFlags decompressionTrackingFlags, - CVPixelBufferRef pixelBuffer, - TimeValue64 displayTime, - TimeValue64 displayDuration, - ICMValidTimeFlags validTimeFlags, void *reserved, void *sourceFrameRefCon); - -/* - * Class setup - */ - -static void -qtwrapper_video_decoder_base_init (QTWrapperVideoDecoderClass * klass) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (klass); - gchar *name = NULL; - gchar *info = NULL; - char *longname, *description; - ComponentDescription desc; - QTWrapperVideoDecoderParams *params; - - params = (QTWrapperVideoDecoderParams *) - g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass), - QTWRAPPER_VDEC_PARAMS_QDATA); - g_assert (params); - - get_name_info_from_component (params->component, &desc, &name, &info); - - /* Fill in details */ - longname = - g_strdup_printf ("QTWrapper Video Decoder : %s", GST_STR_NULL (name)); - description = - g_strdup_printf ("QTWrapper SCAudio wrapper for decoder: %s", - GST_STR_NULL (info)); - gst_element_class_set_metadata (element_class, longname, - "Codec/Decoder/Video", description, - "Fluendo , " - "Pioneers of the Inevitable "); - g_free (longname); - g_free (description); - g_free (name); - g_free (info); - - klass->sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK, - GST_PAD_ALWAYS, params->sinkcaps); - - gst_element_class_add_pad_template (element_class, klass->sinktempl); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&src_templ)); - - /* Store class-global values */ - klass->component = params->component; - klass->componentType = desc.componentType; - klass->componentSubType = desc.componentSubType; -} - -static void -qtwrapper_video_decoder_class_init (QTWrapperVideoDecoderClass * klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - gobject_class->finalize = - GST_DEBUG_FUNCPTR (qtwrapper_video_decoder_finalize); -} - -static void -qtwrapper_video_decoder_init (QTWrapperVideoDecoder * qtwrapper) -{ - QTWrapperVideoDecoderClass *oclass; - ImageSubCodecDecompressCapabilities capabs; - - GST_LOG ("..."); - oclass = (QTWrapperVideoDecoderClass *) (G_OBJECT_GET_CLASS (qtwrapper)); - - /* 1. Create a ocmponent instance */ - if (!(qtwrapper->instance = OpenComponent (oclass->component))) { - GST_ERROR_OBJECT (qtwrapper, "Couldn't create a component instance !"); - return; - } - - /* 2. Initialize decoder */ - memset (&capabs, 0, sizeof (ImageSubCodecDecompressCapabilities)); - if (ImageCodecInitialize (qtwrapper->instance, &capabs) != noErr) { - GST_ERROR_OBJECT (qtwrapper, "Couldn't initialize the QT component !"); - return; - } - - /* 3. Get codec info */ - memset (&qtwrapper->codecinfo, 0, sizeof (CodecInfo)); - if (ImageCodecGetCodecInfo (qtwrapper->instance, - &qtwrapper->codecinfo) != noErr) { - GST_ERROR_OBJECT (qtwrapper, "Couldn't get Codec Information !"); - return; - } - - /* sink pad */ - qtwrapper->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink"); - gst_pad_set_setcaps_function (qtwrapper->sinkpad, - GST_DEBUG_FUNCPTR (qtwrapper_video_decoder_sink_setcaps)); - gst_pad_set_chain_function (qtwrapper->sinkpad, - GST_DEBUG_FUNCPTR (qtwrapper_video_decoder_chain)); - gst_pad_set_event_function (qtwrapper->sinkpad, - GST_DEBUG_FUNCPTR (qtwrapper_video_decoder_sink_event)); - gst_element_add_pad (GST_ELEMENT (qtwrapper), qtwrapper->sinkpad); - - /* src pad */ - qtwrapper->srcpad = gst_pad_new_from_static_template (&src_templ, "src"); - gst_element_add_pad (GST_ELEMENT (qtwrapper), qtwrapper->srcpad); - - qtwrapper->lock = g_mutex_new (); -} - -static void -qtwrapper_video_decoder_finalize (GObject * object) -{ - QTWrapperVideoDecoder *qtwrapper; - - qtwrapper = (QTWrapperVideoDecoder *) object; - - if (qtwrapper->lock) - g_mutex_free (qtwrapper->lock); - - if (G_OBJECT_CLASS (parent_class)->finalize) - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/* fill_image_description - * Fills an ImageDescription with codec-specific values - * - * Doesn't fill in the idSize, width and height. - */ - -static void -fill_image_description (QTWrapperVideoDecoder * qtwrapper, - ImageDescription * desc) -{ - QTWrapperVideoDecoderClass *oclass; - - oclass = (QTWrapperVideoDecoderClass *) (G_OBJECT_GET_CLASS (qtwrapper)); - - desc->cType = oclass->componentSubType; - desc->version = qtwrapper->codecinfo.version; - desc->revisionLevel = qtwrapper->codecinfo.revisionLevel; - desc->vendor = qtwrapper->codecinfo.vendor; - desc->temporalQuality = codecMaxQuality; - desc->spatialQuality = codecNormalQuality; - desc->hRes = Long2Fix (72); - desc->vRes = Long2Fix (72); - desc->frameCount = 1; - /* The following is a pure empiric calculation ... so there's are chances it - * might not work. To be fixed when we can figure out what the exact value should - * be. */ - desc->depth = 24; - /* no color table */ - desc->clutID = -1; -} - - -/* new_image_description - * - * Create an ImageDescription for the given 'codec_data' buffer. - */ - -static ImageDescription * -new_image_description (QTWrapperVideoDecoder * qtwrapper, GstBuffer * buf, - guint width, guint height) -{ - QTWrapperVideoDecoderClass *oclass; - ImageDescription *desc = NULL; - - oclass = (QTWrapperVideoDecoderClass *) (G_OBJECT_GET_CLASS (qtwrapper)); - - if (buf) { - GST_LOG ("buf %p , size:%d", buf, GST_BUFFER_SIZE (buf)); -#if DEBUG_DUMP - gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); -#endif - } - - if (!buf) { - /* standard case, no codec data */ - desc = g_new0 (ImageDescription, 1); - desc->idSize = sizeof (ImageDescription); - fill_image_description (qtwrapper, desc); - } else { - if ((desc = - image_description_from_codec_data (buf, oclass->componentSubType))) - fill_image_description (qtwrapper, desc); - else - goto beach; - } - - /* Fix up values */ - desc->width = width; - desc->height = height; - desc->hRes = Long2Fix (72); - desc->vRes = Long2Fix (72); - - /* if we have h264, we need frame buffering */ - if ((oclass->componentSubType == QT_MAKE_FOURCC_LE ('a', 'v', 'c', '1'))) - qtwrapper->framebuffering = TRUE; - else - qtwrapper->framebuffering = FALSE; - -beach: - return desc; -} - -/* close_decoder - * - * Close and free decoder - */ -#if 0 -static void -close_decoder (QTWrapperVideoDecoder * qtwrapper) -{ - if (qtwrapper->idesc) { - DisposeHandle ((Handle) qtwrapper->idesc); - qtwrapper->idesc = NULL; - } - - if (qtwrapper->prevbuf) { - gst_buffer_unref (qtwrapper->prevbuf); - qtwrapper->prevbuf = NULL; - } - - if (qtwrapper->dparams) { - g_free (qtwrapper->dparams); - qtwrapper->dparams = NULL; - } - -} -#endif -/* open_decoder - * - * Attempt to initialize the ImageDecompressorComponent with the given - * caps. - * - * Returns TRUE and fills *outcaps if the decoder was properly initialized - * Returns FALSE if something went wrong. - */ - -static gboolean -open_decoder (QTWrapperVideoDecoder * qtwrapper, GstCaps * caps, - GstCaps ** outcaps) -{ - ImageDescription *desc; - gint width, height; - GstStructure *s; - const GValue *par = NULL; - const GValue *rate = NULL; - const GValue *cdata = NULL; - OSStatus status; - gboolean res = FALSE; - guint32 outformat; - - ICMDecompressionSessionOptionsRef sessionoptions = NULL; - ICMDecompressionTrackingCallbackRecord cbrecord; - CFMutableDictionaryRef pixelBufferAttributes = NULL; - - - s = gst_caps_get_structure (caps, 0); - - /* 1. Extract information from incoming caps */ - if ((!gst_structure_get_int (s, "width", &width)) || - (!gst_structure_get_int (s, "height", &height)) || - (!(rate = gst_structure_get_value (s, "framerate")))) - goto beach; - par = gst_structure_get_value (s, "pixel-aspect-ratio"); - cdata = gst_structure_get_value (s, "codec_data"); - - /* 2. Create ImageDescription */ - if (cdata) { - GstBuffer *cdatabuf; - - cdatabuf = gst_value_get_buffer (cdata); - desc = new_image_description (qtwrapper, cdatabuf, width, height); - } else { - desc = new_image_description (qtwrapper, NULL, width, height); - } - -#if DEBUG_DUMP - dump_image_description (desc); -#endif - - /* 3.a. Create a handle to receive the ImageDescription */ - GST_LOG_OBJECT (qtwrapper, - "Creating a new ImageDescriptionHandle of %" G_GSIZE_FORMAT " bytes", - desc->idSize); - qtwrapper->idesc = (ImageDescriptionHandle) NewHandleClear (desc->idSize); - if (G_UNLIKELY (qtwrapper->idesc == NULL)) { - GST_WARNING_OBJECT (qtwrapper, - "Failed to create an ImageDescriptionHandle of size %" G_GSIZE_FORMAT, - desc->idSize); - g_free (desc); - goto beach; - } - - /* 3.b. Copy the ImageDescription to the handle */ - GST_LOG_OBJECT (qtwrapper, - "Copying %" G_GSIZE_FORMAT - " bytes from desc [%p] to *qtwrapper->video [%p]", desc->idSize, desc, - *qtwrapper->idesc); - memcpy (*qtwrapper->idesc, desc, desc->idSize); - g_free (desc); - -#if G_BYTE_ORDER == G_BIG_ENDIAN - outformat = kYUVSPixelFormat; -#else - outformat = k2vuyPixelFormat; -#endif - - /* 4. Put output pixel info in dictionnnary */ - pixelBufferAttributes = - CFDictionaryCreateMutable (NULL, 0, &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - - addSInt32ToDictionary (pixelBufferAttributes, kCVPixelBufferWidthKey, width); - addSInt32ToDictionary (pixelBufferAttributes, kCVPixelBufferHeightKey, - height); - addSInt32ToDictionary (pixelBufferAttributes, - kCVPixelBufferPixelFormatTypeKey, outformat); - - /* 5. fill in callback structure */ - - cbrecord.decompressionTrackingCallback = decompressCb; - cbrecord.decompressionTrackingRefCon = qtwrapper; - - /* 6. create decompressionsession */ - status = ICMDecompressionSessionCreate (NULL, - qtwrapper->idesc, - sessionoptions, pixelBufferAttributes, &cbrecord, &qtwrapper->decsession); - - qtwrapper->outsize = width * height * 2; - qtwrapper->width = width; - qtwrapper->height = height; - - if (status) { - GST_DEBUG_OBJECT (qtwrapper, - "Error when Calling ICMDecompressionSessionCreate : %ld", status); - goto beach; - } -#if G_BYTE_ORDER == G_BIG_ENDIAN - outformat = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'); -#else - outformat = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'); -#endif - - /* 9. Create output caps */ - *outcaps = gst_caps_new_simple ("video/x-raw-yuv", - "format", GST_TYPE_FOURCC, outformat, - "width", G_TYPE_INT, width, - "height", G_TYPE_INT, height, - "framerate", GST_TYPE_FRACTION, - gst_value_get_fraction_numerator (rate), - gst_value_get_fraction_denominator (rate), NULL); - if (par) - gst_structure_set_value (gst_caps_get_structure (*outcaps, 0), - "pixel-aspect-ratio", par); - res = TRUE; - -beach: - return res; -} - -static gboolean -qtwrapper_video_decoder_sink_setcaps (GstPad * pad, GstCaps * caps) -{ - QTWrapperVideoDecoder *qtwrapper; - gboolean ret = FALSE; - GstCaps *othercaps = NULL; - - qtwrapper = (QTWrapperVideoDecoder *) gst_pad_get_parent (pad); - - GST_LOG_OBJECT (qtwrapper, "caps:%" GST_PTR_FORMAT, caps); - - /* Setup the decoder with the given input caps */ - if (!(open_decoder (qtwrapper, caps, &othercaps))) { - goto beach; - } - - ret = gst_pad_set_caps (qtwrapper->srcpad, othercaps); - if (!ret) - goto beach; - -beach: - if (othercaps) - gst_caps_unref (othercaps); - gst_object_unref (qtwrapper); - return ret; -} - -static void -decompressCb (void *decompressionTrackingRefCon, - OSStatus result, - ICMDecompressionTrackingFlags decompressionTrackingFlags, - CVPixelBufferRef pixelBuffer, - TimeValue64 displayTime, - TimeValue64 displayDuration, - ICMValidTimeFlags validTimeFlags, void *reserved, void *sourceFrameRefCon) -{ - QTWrapperVideoDecoder *qtwrapper; - GstBuffer *origbuf = (GstBuffer *) sourceFrameRefCon; - - qtwrapper = (QTWrapperVideoDecoder *) decompressionTrackingRefCon; - - GST_LOG_OBJECT (qtwrapper, - "result:%d, flags:0x%x, pixelBuffer:%p, displayTime:%lld, displayDuration:%lld", - (guint32) result, (guint32) decompressionTrackingFlags, pixelBuffer, - displayTime, displayDuration); - - GST_LOG_OBJECT (qtwrapper, - "validTimeFlags:0x%x, reserved:%p, sourceFrameRefCon:%p", - (guint32) validTimeFlags, reserved, sourceFrameRefCon); - - if (decompressionTrackingFlags & kICMDecompressionTracking_ReleaseSourceData) { - GST_LOG ("removing previous buffer : %p", origbuf); - gst_buffer_unref (origbuf); - } - - if (decompressionTrackingFlags & kICMDecompressionTracking_EmittingFrame) - GST_LOG ("EMITTING FRAME"); - if (decompressionTrackingFlags & kICMDecompressionTracking_FrameDecoded) - GST_LOG ("FRAME DECODED"); - if (decompressionTrackingFlags & kICMDecompressionTracking_FrameDropped) - GST_LOG ("FRAME DROPPED"); - if (decompressionTrackingFlags & - kICMDecompressionTracking_FrameNeedsRequeueing) - GST_LOG ("FRAME NEEDS REQUEUING"); - - if ((decompressionTrackingFlags & kICMDecompressionTracking_EmittingFrame) - && pixelBuffer) { - guint8 *addr; - GstBuffer *outbuf; - size_t size; - GstClockTime outtime; - - size = CVPixelBufferGetDataSize (pixelBuffer); - outtime = gst_util_uint64_scale (displayTime, GST_SECOND, 600); - - GST_LOG ("Got a buffer ready outtime : %" GST_TIME_FORMAT, - GST_TIME_ARGS (outtime)); - - if (qtwrapper->flushing) { - CVPixelBufferRelease (pixelBuffer); - goto beach; - } - - dump_cvpixel_buffer (pixelBuffer); - - CVPixelBufferRetain (pixelBuffer); - if (CVPixelBufferLockBaseAddress (pixelBuffer, 0)) - GST_WARNING ("Couldn't lock base adress on pixel buffer !"); - addr = CVPixelBufferGetBaseAddress (pixelBuffer); - - /* allocate buffer */ - qtwrapper->lastret = - gst_pad_alloc_buffer (qtwrapper->srcpad, GST_BUFFER_OFFSET_NONE, - (gint) qtwrapper->outsize, GST_PAD_CAPS (qtwrapper->srcpad), &outbuf); - if (G_UNLIKELY (qtwrapper->lastret != GST_FLOW_OK)) { - GST_LOG ("gst_pad_alloc_buffer() returned %s", - gst_flow_get_name (qtwrapper->lastret)); - goto beach; - } - - /* copy data */ - GST_LOG ("copying data in buffer from %p to %p", - addr, GST_BUFFER_DATA (outbuf)); - if (G_UNLIKELY ((qtwrapper->width * 2) != - CVPixelBufferGetBytesPerRow (pixelBuffer))) { - guint i; - gulong realpixels; - size_t stride; - - stride = CVPixelBufferGetBytesPerRow (pixelBuffer); - realpixels = qtwrapper->width * 2; - - /* special copy for stride handling */ - for (i = 0; i < qtwrapper->height; i++) - memmove (GST_BUFFER_DATA (outbuf) + realpixels * i, - addr + stride * i, realpixels); - - } else - memmove (GST_BUFFER_DATA (outbuf), addr, (int) qtwrapper->outsize); - - /* Release CVPixelBuffer */ - CVPixelBufferUnlockBaseAddress (pixelBuffer, 0); - CVPixelBufferRelease (pixelBuffer); - - /* Set proper timestamp ! */ - gst_buffer_set_caps (outbuf, GST_PAD_CAPS (qtwrapper->srcpad)); - GST_BUFFER_TIMESTAMP (outbuf) = qtwrapper->last_ts; - GST_BUFFER_DURATION (outbuf) = qtwrapper->last_duration; - GST_BUFFER_SIZE (outbuf) = (int) qtwrapper->outsize; - - /* See if we push buffer downstream */ - if (G_LIKELY (!qtwrapper->framebuffering)) { - GST_LOG ("No buffering needed, pushing buffer downstream"); - MAC_UNLOCK (qtwrapper); - qtwrapper->lastret = gst_pad_push (qtwrapper->srcpad, outbuf); - MAC_LOCK (qtwrapper); - } else { - /* Check if we push the current buffer or the stored buffer */ - if (!qtwrapper->prevbuf) { - GST_LOG ("Storing buffer"); - qtwrapper->prevbuf = outbuf; - qtwrapper->lastret = GST_FLOW_OK; - } else if (GST_BUFFER_TIMESTAMP (qtwrapper->prevbuf) > - GST_BUFFER_TIMESTAMP (outbuf)) { - GST_LOG ("Newly decoded buffer is earliest, pushing that one !"); - MAC_UNLOCK (qtwrapper); - qtwrapper->lastret = gst_pad_push (qtwrapper->srcpad, outbuf); - MAC_LOCK (qtwrapper); - } else { - GstBuffer *tmp; - - tmp = qtwrapper->prevbuf; - qtwrapper->prevbuf = outbuf; - GST_LOG ("Stored buffer is earliest, pushing that one !"); - MAC_UNLOCK (qtwrapper); - qtwrapper->lastret = gst_pad_push (qtwrapper->srcpad, tmp); - MAC_LOCK (qtwrapper); - } - } - } else { - qtwrapper->lastret = GST_FLOW_OK; - } - -beach: - return; -} - -/* _chain - * - * Here we feed the data to the decoder and ask to decode frames. - * - * Known issues/questions are: - * * How can we be guaranteed that one frame in automatically gives one output - * frame ? - * * PTS/DTS timestamp issues. With mpeg-derivate formats, the incoming order is - * different from the output order. - */ - -static GstFlowReturn -qtwrapper_video_decoder_chain (GstPad * pad, GstBuffer * buf) -{ - QTWrapperVideoDecoder *qtwrapper; - GstFlowReturn ret = GST_FLOW_OK; - ICMFrameTimeRecord frameTime = { {0} }; - OSStatus status; - guint64 intime; - - qtwrapper = (QTWrapperVideoDecoder *) gst_pad_get_parent (pad); - - intime = gst_util_uint64_scale (GST_BUFFER_TIMESTAMP (buf), 600, GST_SECOND); - - GST_DEBUG_OBJECT (qtwrapper, - "buffer:%p timestamp:%" GST_TIME_FORMAT " intime:%llu Size:%d", buf, - GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), intime, - GST_BUFFER_SIZE (buf)); - - frameTime.recordSize = sizeof (ICMFrameTimeRecord); -/* *(TimeValue64 *)&frameTime.value = intime; */ - frameTime.value.lo = (guint32) (intime & 0xffffffff); - frameTime.value.hi = (guint32) (intime >> 32); - frameTime.base = 0; - frameTime.scale = 600; - frameTime.rate = fixed1; - frameTime.duration = 1; - frameTime.flags = icmFrameTimeDecodeImmediately; -/* frameTime.flags = icmFrameTimeIsNonScheduledDisplayTime; */ - frameTime.frameNumber = (long) (++qtwrapper->frameNumber); - - MAC_LOCK (qtwrapper); - - qtwrapper->last_ts = GST_BUFFER_TIMESTAMP (buf); - qtwrapper->last_duration = GST_BUFFER_DURATION (buf); - - status = ICMDecompressionSessionDecodeFrame (qtwrapper->decsession, - GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), NULL, &frameTime, buf); - MAC_UNLOCK (qtwrapper); - - if (status) { - GST_WARNING_OBJECT (qtwrapper, "Error when Calling DecodeFrame() : %ld", - status); - ret = GST_FLOW_ERROR; - goto beach; - } - -beach: - gst_object_unref (qtwrapper); - return qtwrapper->lastret; -} - -static gboolean -qtwrapper_video_decoder_sink_event (GstPad * pad, GstEvent * event) -{ - gboolean res; - QTWrapperVideoDecoder *qtwrapper; - - qtwrapper = (QTWrapperVideoDecoder *) gst_pad_get_parent (pad); - - GST_LOG_OBJECT (pad, "event : %s", GST_EVENT_TYPE_NAME (event)); - - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_FLUSH_START: - MAC_LOCK (qtwrapper); - qtwrapper->flushing = TRUE; - if (qtwrapper->prevbuf) { - GST_LOG ("About to unref buffer %p", qtwrapper->prevbuf); - gst_buffer_unref (qtwrapper->prevbuf); - qtwrapper->prevbuf = NULL; - } - ICMDecompressionSessionFlush (qtwrapper->decsession); - MAC_UNLOCK (qtwrapper); - break; - case GST_EVENT_FLUSH_STOP: - MAC_LOCK (qtwrapper); - qtwrapper->flushing = FALSE; - qtwrapper->prevbuf = NULL; - MAC_UNLOCK (qtwrapper); - break; - default: - break; - } - - res = gst_pad_push_event (qtwrapper->srcpad, event); - - gst_object_unref (qtwrapper); - return res; -} - -/* _register - * - * Scan through all available Image Decompressor components to find the ones we - * can handle and wrap in this plugin. - */ - -gboolean -qtwrapper_video_decoders_register (GstPlugin * plugin) -{ - gboolean res = TRUE; - Component componentID = NULL; - ComponentDescription desc = { - 'imdc', 0, 0, 0, 0 - }; - GTypeInfo typeinfo = { - sizeof (QTWrapperVideoDecoderClass), - (GBaseInitFunc) qtwrapper_video_decoder_base_init, - NULL, - (GClassInitFunc) qtwrapper_video_decoder_class_init, - NULL, - NULL, - sizeof (QTWrapperVideoDecoder), - 0, - (GInstanceInitFunc) qtwrapper_video_decoder_init, - }; - - /* Find all ImageDecoders ! */ - GST_DEBUG ("There are %ld decompressors available", CountComponents (&desc)); - - /* loop over ImageDecoders */ - do { - componentID = FindNextComponent (componentID, &desc); - - GST_LOG ("componentID : %p", componentID); - - if (componentID) { - ComponentDescription thisdesc; - gchar *name = NULL, *info = NULL; - GstCaps *caps = NULL; - gchar *type_name = NULL; - GType type; - QTWrapperVideoDecoderParams *params = NULL; - - if (!(get_name_info_from_component (componentID, &thisdesc, &name, - &info))) - goto next; - - if (!get_output_info_from_component (componentID)) { - GST_WARNING ("Couldn't get output info from component"); - goto next; - } - - GST_LOG (" name:%s", GST_STR_NULL (name)); - GST_LOG (" info:%s", GST_STR_NULL (info)); - - GST_LOG (" type:%" GST_FOURCC_FORMAT, - QT_FOURCC_ARGS (thisdesc.componentType)); - GST_LOG (" subtype:%" GST_FOURCC_FORMAT, - QT_FOURCC_ARGS (thisdesc.componentSubType)); - GST_LOG (" manufacturer:%" GST_FOURCC_FORMAT, - QT_FOURCC_ARGS (thisdesc.componentManufacturer)); - - if (!(caps = fourcc_to_caps (thisdesc.componentSubType))) { - GST_LOG - ("We can't find caps for this component, switching to the next one !"); - goto next; - } - - type_name = g_strdup_printf ("qtwrappervideodec_%" GST_FOURCC_FORMAT, - QT_FOURCC_ARGS (thisdesc.componentSubType)); - g_strdelimit (type_name, " ", '_'); - - if (g_type_from_name (type_name)) { - GST_WARNING ("We already have a registered plugin for %s", type_name); - goto next; - } - - params = g_new0 (QTWrapperVideoDecoderParams, 1); - params->component = componentID; - params->sinkcaps = gst_caps_ref (caps); - - GST_INFO ("Registering g_type for type_name: %s", type_name); - type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0); - /* Store params in type qdata */ - g_type_set_qdata (type, QTWRAPPER_VDEC_PARAMS_QDATA, (gpointer) params); - - /* register type */ - if (!gst_element_register (plugin, type_name, GST_RANK_MARGINAL, type)) { - g_warning ("Failed to register %s", type_name);; - g_type_set_qdata (type, QTWRAPPER_VDEC_PARAMS_QDATA, NULL); - g_free (params); - res = FALSE; - goto next; - } else { - GST_LOG ("Reigstered video plugin %s", type_name); - } - - next: - if (name) - g_free (name); - if (info) - g_free (info); - if (type_name) - g_free (type_name); - if (caps) - gst_caps_unref (caps); - } - - } while (componentID && res); - - return res; -}