summaryrefslogtreecommitdiffstats
path: root/tdefile-plugins/theora
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:04:32 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:04:32 -0600
commit793cf2dff35dffe3ec4c7b24252947dde758a1b2 (patch)
tree7d9972d99ed281a36418ae9f5fc128e3c951532c /tdefile-plugins/theora
parent04f764aaf273340e1d5811d4216dd8127cacc5db (diff)
downloadtdemultimedia-793cf2dff35dffe3ec4c7b24252947dde758a1b2.tar.gz
tdemultimedia-793cf2dff35dffe3ec4c7b24252947dde758a1b2.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdefile-plugins/theora')
-rw-r--r--tdefile-plugins/theora/Makefile.am22
-rw-r--r--tdefile-plugins/theora/configure.in.bot7
-rw-r--r--tdefile-plugins/theora/configure.in.in26
-rw-r--r--tdefile-plugins/theora/tdefile_theora.cpp322
-rw-r--r--tdefile-plugins/theora/tdefile_theora.desktop60
-rw-r--r--tdefile-plugins/theora/tdefile_theora.h43
6 files changed, 480 insertions, 0 deletions
diff --git a/tdefile-plugins/theora/Makefile.am b/tdefile-plugins/theora/Makefile.am
new file mode 100644
index 00000000..c44a102d
--- /dev/null
+++ b/tdefile-plugins/theora/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile.am for ogg/vorbis file meta info plugin
+
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+# these are the headers for your project
+noinst_HEADERS = tdefile_theora.h
+
+kde_module_LTLIBRARIES = tdefile_theora.la
+
+tdefile_theora_la_SOURCES = tdefile_theora.cpp
+tdefile_theora_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -module $(KDE_PLUGIN)
+tdefile_theora_la_LIBADD = $(LIB_KIO) -logg -lvorbis -ltheora
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) tdefile_theora.cpp -o $(podir)/tdefile_theora.pot
+
+services_DATA = tdefile_theora.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/tdefile-plugins/theora/configure.in.bot b/tdefile-plugins/theora/configure.in.bot
new file mode 100644
index 00000000..926a39e9
--- /dev/null
+++ b/tdefile-plugins/theora/configure.in.bot
@@ -0,0 +1,7 @@
+if test "x$with_theora" = xcheck && test "x$have_theora" = xno; then
+ echo ""
+ echo "Ogg Theora support was not found."
+ echo "a KFile-plugin for displaying Ogg Theora Information"
+ echo "has been disabled from compilation."
+ all_tests=bad
+fi
diff --git a/tdefile-plugins/theora/configure.in.in b/tdefile-plugins/theora/configure.in.in
new file mode 100644
index 00000000..b9d8836d
--- /dev/null
+++ b/tdefile-plugins/theora/configure.in.in
@@ -0,0 +1,26 @@
+AC_DEFUN([KDE_CHECK_THEORA],
+[
+have_theora=yes
+
+KDE_CHECK_HEADER(theora/theora.h,
+ [], [have_theora=no])
+
+KDE_CHECK_LIB(theora, theora_info_init,
+ [], [have_theora=no], [-lvorbis -logg])
+])
+
+AC_ARG_WITH(theora,
+ [AC_HELP_STRING(--with-theora,
+ [enable support for Ogg Theora @<:@default=check@:>@])],
+ [], with_theora=check)
+
+have_theora=no
+if test "x$with_theora" != xno; then
+ KDE_CHECK_THEORA
+
+ if test "x$with_theora" != xcheck && test "x$have_theora" != xyes; then
+ AC_MSG_ERROR([--with-theora was given, but test for Theora failed])
+ fi
+fi
+
+AM_CONDITIONAL(include_theora_SUBDIR, test "x$have_theora" = xyes)
diff --git a/tdefile-plugins/theora/tdefile_theora.cpp b/tdefile-plugins/theora/tdefile_theora.cpp
new file mode 100644
index 00000000..20e4e337
--- /dev/null
+++ b/tdefile-plugins/theora/tdefile_theora.cpp
@@ -0,0 +1,322 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Jean-Baptiste Mardelle *
+ * bj@altern.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <tqfile.h>
+#include <config.h>
+#include "tdefile_theora.h"
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kgenericfactory.h>
+
+#include "theora/theora.h"
+#include "vorbis/codec.h"
+
+ogg_stream_state t_stream_state;
+ogg_stream_state v_stream_state;
+
+int theora_p=0;
+int vorbis_p=0;
+
+static int queue_page(ogg_page *page)
+{
+ if(theora_p)
+ ogg_stream_pagein(&t_stream_state,page);
+ if(vorbis_p)
+ ogg_stream_pagein(&v_stream_state,page);
+ return 0;
+}
+
+static int buffer_data(FILE *in,ogg_sync_state *oy)
+{
+ char *buffer=ogg_sync_buffer(oy,4096);
+ int bytes=fread(buffer,1,4096,in);
+ ogg_sync_wrote(oy,bytes);
+ return(bytes);
+}
+
+typedef KGenericFactory<theoraPlugin> theoraFactory;
+
+K_EXPORT_COMPONENT_FACTORY(tdefile_theora, theoraFactory( "tdefile_theora" ))
+
+theoraPlugin::theoraPlugin(TQObject *parent, const char *name,
+ const TQStringList &args)
+ : KFilePlugin(parent, name, args)
+{
+// kdDebug(7034) << "theora plugin\n";
+
+ KFileMimeTypeInfo* info = addMimeTypeInfo( "video/x-theora" );
+
+ KFileMimeTypeInfo::GroupInfo* group = 0;
+ KFileMimeTypeInfo::ItemInfo* item;
+
+ // video group
+
+ group = addGroupInfo(info, "Video", i18n("Video Details"));
+ setAttributes(group, 0);
+ item = addItemInfo(group, "Length", i18n("Length"), TQVariant::Int);
+ setUnit(item, KFileMimeTypeInfo::Seconds);
+ setHint(item, KFileMimeTypeInfo::Length);
+ item = addItemInfo(group, "Resolution", i18n("Resolution"), TQVariant::Size);
+ setHint(item, KFileMimeTypeInfo::Size);
+ setUnit(item, KFileMimeTypeInfo::Pixels);
+ item = addItemInfo(group, "FrameRate", i18n("Frame Rate"), TQVariant::Int);
+ setUnit(item, KFileMimeTypeInfo::FramesPerSecond);
+ item = addItemInfo(group, "TargetBitrate", i18n("Target Bitrate"), TQVariant::Int);
+ setUnit(item, KFileMimeTypeInfo::Bitrate);
+ item = addItemInfo(group, "Quality", i18n("Quality"), TQVariant::Int);
+
+ // audio group
+
+ group = addGroupInfo(info, "Audio", i18n("Audio Details"));
+ setAttributes(group, 0);
+ addItemInfo(group, "Channels", i18n("Channels"), TQVariant::Int);
+
+ item = addItemInfo(group, "SampleRate", i18n("Sample Rate"), TQVariant::Int);
+ setUnit(item, KFileMimeTypeInfo::Hertz);
+}
+
+bool theoraPlugin::readInfo( KFileMetaInfo& info, uint what)
+{
+ // most of the ogg stuff was borrowed from libtheora/examples/player_example.c
+ FILE *fp;
+
+ ogg_sync_state o_sync_state;
+ ogg_packet o_packet;
+ ogg_page o_page;
+
+ theora_info t_info;
+ theora_comment t_comment;
+ theora_state t_state;
+ vorbis_info v_info;
+ vorbis_comment v_comment;
+
+ theora_p=0;
+ vorbis_p=0;
+ int theora_serial=0;
+ int stateflag=0;
+
+ ogg_int64_t duration=0;
+
+ // libtheora is still a bit unstable and sadly the init_ functions don't
+ // take care of things the way one would expect. So, let's do some explicit
+ // clearing of these fields.
+
+ memset(&t_info, 0, sizeof(theora_info));
+ memset(&t_comment, 0, sizeof(theora_comment));
+ memset(&t_state, 0, sizeof(theora_state));
+
+ bool readTech = false;
+
+ if (what & (KFileMetaInfo::Fastest |
+ KFileMetaInfo::DontCare |
+ KFileMetaInfo::TechnicalInfo))
+ readTech = true;
+
+ if ( info.path().isEmpty() ) // remote file
+ return false;
+
+ fp = fopen(TQFile::encodeName(info.path()),"rb");
+ if (!fp)
+ {
+ kdDebug(7034) << "Unable to open " << TQFile::encodeName(info.path()).data() << endl;
+ return false;
+ }
+
+ ogg_sync_init(&o_sync_state);
+
+ /* init supporting Vorbis structures needed in header parsing */
+ vorbis_info_init(&v_info);
+ vorbis_comment_init(&v_comment);
+
+ /* init supporting Theora structures needed in header parsing */
+ theora_comment_init(&t_comment);
+ theora_info_init(&t_info);
+
+ while(!stateflag && buffer_data(fp,&o_sync_state)!=0)
+ {
+ while (ogg_sync_pageout(&o_sync_state,&o_page)>0)
+ {
+ ogg_stream_state stream_test;
+ /* is this a mandated initial header? If not, stop parsing */
+ if(!ogg_page_bos(&o_page))
+ {
+ queue_page(&o_page);
+ stateflag=1;
+ break;
+ }
+
+ ogg_stream_init(&stream_test,ogg_page_serialno(&o_page));
+ ogg_stream_pagein(&stream_test,&o_page);
+ ogg_stream_packetout(&stream_test,&o_packet);
+
+ /* identify the codec: try theora */
+ if(!theora_p && theora_decode_header(&t_info,&t_comment,&o_packet)>=0)
+ {
+ /* it is theora */
+ memcpy(&t_stream_state,&stream_test,sizeof(stream_test));
+ theora_serial=ogg_page_serialno(&o_page);
+ theora_p=1;
+ }
+ else if(!vorbis_p && vorbis_synthesis_headerin(&v_info,&v_comment,&o_packet)>=0)
+ {
+ /* it is vorbis */
+ memcpy(&v_stream_state,&stream_test,sizeof(stream_test));
+ vorbis_p=1;
+ }
+ else
+ {
+ /* whatever it is, we don't care about it */
+ ogg_stream_clear(&stream_test);
+ }
+ }
+ }
+
+ /* we're expecting more header packets. */
+ bool corruptedHeaders=false;
+
+ while((theora_p && theora_p<3) || (vorbis_p && vorbis_p<3))
+ {
+ int ret;
+ /* look for further theora headers */
+ while(theora_p && (theora_p<3) && (ret=ogg_stream_packetout(&t_stream_state,&o_packet)))
+ {
+ if(ret<0)
+ {
+ kdDebug(7034)<<"Error parsing Theora stream headers; corrupt stream?\n"<<endl;
+ corruptedHeaders=true;
+ }
+ if(theora_decode_header(&t_info,&t_comment,&o_packet))
+ {
+ kdDebug(7034)<<"Error parsing Theora stream headers; corrupt stream?"<<endl;
+ corruptedHeaders=true;
+ }
+ theora_p++;
+ if(theora_p==3)
+ break;
+ }
+
+ /* look for more vorbis header packets */
+ while(vorbis_p && (vorbis_p<3) && (ret=ogg_stream_packetout(&v_stream_state,&o_packet)))
+ {
+ if(ret<0)
+ {
+ kdDebug(7034)<<"Error parsing Vorbis stream headers; corrupt stream"<<endl;
+ corruptedHeaders=true;
+ }
+ if(vorbis_synthesis_headerin(&v_info,&v_comment,&o_packet))
+ {
+ kdDebug(7034)<<"Error parsing Vorbis stream headers; corrupt stream?"<<endl;
+ corruptedHeaders=true;
+ }
+ vorbis_p++;
+ if(vorbis_p==3)
+ break;
+ }
+ /* The header pages/packets will arrive before anything else we
+ care about, or the stream is not obeying spec */
+
+ if(ogg_sync_pageout(&o_sync_state,&o_page)>0)
+ {
+ queue_page(&o_page);
+ /* demux into the appropriate stream */
+ }
+ else
+ {
+ int ret=buffer_data(fp,&o_sync_state); /* someone needs more data */
+ if(ret==0)
+ {
+ kdDebug(7034)<<"End of file while searching for codec headers."<<endl;
+ corruptedHeaders=true;
+ }
+ }
+ }
+
+ /* and now we have it all. initialize decoders */
+ if(theora_p && !corruptedHeaders)
+ {
+ theora_decode_init(&t_state,&t_info);
+ }
+ else
+ {
+ /* tear down the partial theora setup */
+ theora_info_clear(&t_info);
+ theora_comment_clear(&t_comment);
+
+ vorbis_info_clear(&v_info);
+ vorbis_comment_clear(&v_comment);
+ ogg_sync_clear(&o_sync_state);
+ fclose(fp);
+ return false;
+ }
+ //queue_page(&o_page);
+
+ while (buffer_data(fp,&o_sync_state))
+ {
+ while (ogg_sync_pageout(&o_sync_state,&o_page)>0)
+ {
+ // The following line was commented out by Scott Wheeler <wheeler@kde.org>
+ // We don't actually need to store all of the pages / packets in memory since
+ // (a) libtheora doesn't use them anyway in the one call that we make after this
+ // that usese t_state and (b) it basically buffers the entire file to memory if
+ // we queue them up like this and that sucks where a typical file size is a few
+ // hundred megs.
+
+ // queue_page(&o_page);
+ }
+ if (theora_serial==ogg_page_serialno(&o_page))
+ duration=(ogg_int64_t) theora_granule_time(&t_state,ogg_page_granulepos(&o_page));
+ }
+
+ if (readTech)
+ {
+ int stream_fps=0;
+ if (t_info.fps_denominator!=0)
+ stream_fps=t_info.fps_numerator/t_info.fps_denominator;
+ KFileMetaInfoGroup videogroup = appendGroup(info, "Video");
+ appendItem(videogroup, "Length", int (duration));
+ appendItem(videogroup, "Resolution", TQSize(t_info.frame_width,t_info.frame_height));
+ appendItem(videogroup, "FrameRate", stream_fps);
+ appendItem(videogroup, "Quality", (int) t_info.quality);
+
+ KFileMetaInfoGroup audiogroup = appendGroup(info, "Audio");
+ appendItem(audiogroup, "Channels", v_info.channels);
+ appendItem(audiogroup, "SampleRate", int(v_info.rate));
+ }
+ fclose(fp);
+
+ if (vorbis_p)
+ {
+ ogg_stream_clear(&v_stream_state);
+ vorbis_comment_clear(&v_comment);
+ vorbis_info_clear(&v_info);
+ }
+
+ ogg_stream_clear(&t_stream_state);
+ theora_clear(&t_state);
+ theora_comment_clear(&t_comment);
+ theora_info_clear(&t_info);
+ ogg_sync_clear(&o_sync_state);
+
+ return true;
+}
+
+#include "tdefile_theora.moc"
+
diff --git a/tdefile-plugins/theora/tdefile_theora.desktop b/tdefile-plugins/theora/tdefile_theora.desktop
new file mode 100644
index 00000000..e3adfa26
--- /dev/null
+++ b/tdefile-plugins/theora/tdefile_theora.desktop
@@ -0,0 +1,60 @@
+[Desktop Entry]
+Type=Service
+Name=theora Info
+Name[bg]=Информация за theora
+Name[bn]=থিওরা তথ্য
+Name[br]=Titouroù diwar-benn theora
+Name[bs]=theora informacije
+Name[ca]=Informació theora
+Name[cs]=theora info
+Name[de]=Theora-Info
+Name[el]=Πληροφορίες theora
+Name[eo]=theora-informo
+Name[es]=Info Theora
+Name[et]=Theora info
+Name[eu]=theora informazioa
+Name[fa]=اطلاعات theora
+Name[fi]=Theoran tiedot
+Name[fr]=Informations theora
+Name[ga]=Eolas faoi theora
+Name[gl]=Información theora
+Name[he]=מידע theora
+Name[hu]=Theora-jellemzők
+Name[is]=theora upplýsingar
+Name[it]=Informazioni su theora
+Name[ja]=theora 情報
+Name[kk]=theora мәліметі
+Name[km]=ព័ត៌មាន theora
+Name[ko]=theora 정보
+Name[lt]=theora Informacija
+Name[mk]=theora информации
+Name[nb]=theora-info
+Name[nds]=Theora-Info
+Name[ne]=थिवरा सूचना
+Name[nl]=theora-informatie
+Name[nn]=theora-info
+Name[pa]=theora (ਥੋਰਾ) ਜਾਣਕਾਰੀ
+Name[pl]=Informacja o pliku theora
+Name[pt]=Informação do theora
+Name[pt_BR]=Informação sobre theora
+Name[ru]=Сведения о theora
+Name[sk]=theora info
+Name[sl]=Podatki o Theora
+Name[sr]=Информације о theora-и
+Name[sr@Latn]=Informacije o theora-i
+Name[sv]=Theora-information
+Name[ta]= தியோரா தகவல்
+Name[th]=ข้อมูล theora
+Name[tr]=theora Bilgisi
+Name[uk]=Інформація по theora
+Name[zh_CN]=theora 信息
+Name[zh_HK]=theora 資訊
+Name[zh_TW]=theora 資訊
+ServiceTypes=KFilePlugin
+X-TDE-Library=tdefile_theora
+# change MimeType here! (example: inode/directory)
+MimeType=video/x-theora
+# change PreferredGroups here! (example: FolderInfo)
+PreferredGroups=
+# change PreferredItems here! (example: Items;Size)
+PreferredItems=Size,Length
diff --git a/tdefile-plugins/theora/tdefile_theora.h b/tdefile-plugins/theora/tdefile_theora.h
new file mode 100644
index 00000000..88e465c2
--- /dev/null
+++ b/tdefile-plugins/theora/tdefile_theora.h
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Jean-Baptiste Mardelle *
+ * bj@altern.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef __KFILE_THEORA_H__
+#define __KFILE_THEORA_H__
+
+/**
+ * Note: For further information look into <$TDEDIR/include/tdefilemetainfo.h>
+ */
+#include <tdefilemetainfo.h>
+
+class TQStringList;
+
+class theoraPlugin: public KFilePlugin
+{
+ Q_OBJECT
+
+
+public:
+ theoraPlugin( TQObject *parent, const char *name, const TQStringList& args );
+
+ virtual bool readInfo( KFileMetaInfo& info, uint what);
+};
+
+#endif // __KFILE_THEORA_H__
+