# HG changeset patch
# User hgs
# Date 1277504326 18000
# Node ID 8d4f92b9230e4eeed2bdb459f2c8c6ee76e3b30f
# Parent 5cb7d96a68874a62cb8060d0ab4906ef16ce1594
201025
diff -r 5cb7d96a6887 -r 8d4f92b9230e QtGSTPlayer/QtGSTPlayer.pro
--- a/QtGSTPlayer/QtGSTPlayer.pro Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-######################################################################
-# Automatically generated by qmake (2.01a) Wed Feb 17 14:34:47 2010
-######################################################################
-
-
-# ============================================================================
-# Name : QtGSTPlayer.pro
-# Part of : LibHb / gstplayer
-# Description : Project definition file for simple gstplayer
-# Version : %version: 1 %
-#
-# Copyright ? 2008 Nokia. All rights reserved.
-# This material, including documentation and any related computer
-# programs, is protected by copyright controlled by Nokia. All
-# rights are reserved. Copying, including reproducing, storing,
-# adapting or translating, any or all of this material requires the
-# prior written consent of Nokia. This material also contains
-# confidential information which may not be disclosed to others
-# without the prior written consent of Nokia.
-# ============================================================================
-#
-
-TEMPLATE = app
-TARGET =
-DEPENDPATH += .
-INCLUDEPATH += .
-
-# Input
-SOURCES += main.cpp folderview.cpp views.cpp record_play.c
-HEADERS += folderview.h views.h
-
-RESOURCES += QtGSTPlayer.qrc
-
diff -r 5cb7d96a6887 -r 8d4f92b9230e QtGSTPlayer/QtGSTPlayer.qrc
--- a/QtGSTPlayer/QtGSTPlayer.qrc Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-
-
- folder.png
- settings.png
-
-
diff -r 5cb7d96a6887 -r 8d4f92b9230e QtGSTPlayer/folder.png
Binary file QtGSTPlayer/folder.png has changed
diff -r 5cb7d96a6887 -r 8d4f92b9230e QtGSTPlayer/folderview.cpp
--- a/QtGSTPlayer/folderview.cpp Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,357 +0,0 @@
-#include
-#include
-#include
-
-//#include
-//#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include "folderview.h"
-#include "views.h"
-#include
-#include
-#include
-/*! Constructor of FolderView.
- */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-int mCurrentState = 0;
-
-#ifdef __cplusplus
-}
-#endif
-//extern int mCurrentState;
-
-FolderView::FolderView(QGraphicsItem *parent)
- : HbView(parent),mModel( NULL ), mFolderPath("c:\\data\\Sounds\\Digital\\"),mTimer(NULL),mIsRecording( FALSE )
-{
- mCurrentState = NONE;
-
- // Create a main widget for this view
- // In this case, list view is appropriate
- // Note: HbListView is not derived from HbView,
- // this is just like any other Hb widget but with a feature of
- // model-view separation
- mFileList = new HbListView(this);
-
- // Create a model to set for the list view
- mModel = new QDirModel(this);
- mFileList->setModel(mModel);
-
- // Setting initial path for folder list
- mFileList->setRootIndex(mModel->index(mFolderPath));
- //mFileList->
- // Setting the main widget for this view
- setWidget(mFileList);
- //int x = mFileList->indexCount();
- QObject::connect(mFileList, SIGNAL(pressed(const QModelIndex)), this, SLOT(item_pressed(const QModelIndex)));
-
- // add menu
- HbMenu* menu1 = menu()->addMenu(tr("Record"));
-
- HbAction* menu1_Action = new HbAction(tr("RAW"), this);
- connect(menu1_Action, SIGNAL(triggered()), this, SLOT(record_RAW()));
- menu1->addAction( menu1_Action );
-
- menu1_Action = new HbAction(tr("WAV"), this);
- connect(menu1_Action, SIGNAL(triggered()), this, SLOT(record_WAV()));
- menu1->addAction( menu1_Action );
-
- //create action Nokia India sub menu item.
- menu1_Action = new HbAction(tr("AMR"), this);
- connect(menu1_Action, SIGNAL(triggered()), this, SLOT(record_AMR()));
- menu1->addAction( menu1_Action );
-
- menu1_Action = new HbAction(tr("G711"), this);
- connect(menu1_Action, SIGNAL(triggered()), this, SLOT(record_G711()));
- menu1->addAction( menu1_Action );
-
- menu1_Action = new HbAction(tr("AAC"), this);
- connect(menu1_Action, SIGNAL(triggered()), this, SLOT(record_AAC()));
- menu1->addAction( menu1_Action );
- menu1_Action = new HbAction(tr("G729"), this);
- connect(menu1_Action, SIGNAL(triggered()), this, SLOT(record_G729()));
- menu1->addAction( menu1_Action );
-
- menu1_Action = new HbAction(tr("ILBC"), this);
- connect(menu1_Action, SIGNAL(triggered()), this, SLOT(record_ILBC()));
- menu1->addAction( menu1_Action );
-
-
-
- //menu()->addAction(tr("Play"), this, SLOT(play()));
- menu()->addAction(tr("Stop"), this, SLOT(stop()));
- menu()->addAction(tr("Pause"), this, SLOT(pause()));
- menu()->addAction(tr("Resume"), this, SLOT(resume()));
- menu()->addAction(tr("Exit"), qApp, SLOT(quit()));
-
-
- /// timer required to get the glib events
- mTimer = new QTimer(this);
- connect(mTimer, SIGNAL(timeout()), this, SLOT(timertimeout()));
- mTimer->start(10);
-
-}
-
-FolderView::~FolderView()
-{
- if(mCurrentState != NONE)
- gst_unref();
-delete mFileList;
-delete mModel;
-mTimer->stop();
-delete mTimer;
-}
-
-
-void FolderView::folderViewTriggered()
-{
- mainWindow()->setCurrentView(Views::folderView());
-}
-
-/*void FolderView::settingsViewTriggered()
-{
- mainWindow()->setCurrentView(Views::settingsView());
-}*/
-
-void FolderView::showNote(const int err)
-{
- if(err)
- {
- HbNotificationDialog* notifyDialog = new HbNotificationDialog;
- notifyDialog->setTimeout(HbPopup::StandardTimeout);
- QString strong;
- QString sprint= strong.sprintf("Format Not supported(%d)",err);
- notifyDialog->setTitleTextWrapping(Hb::TextWordWrap);
- notifyDialog->setTitle(QString("Error"));
- notifyDialog->setWrapMode(Hb::TextWordWrap);
- notifyDialog->setText(sprint);
-
- notifyDialog->exec();
- delete notifyDialog;
- }
-}
-void FolderView::item_pressed(const QModelIndex &index)
-{
- if( mIsRecording )
- {
- return;
- }
- QVariant variant=index.data();
- QString str = variant.toString();
-
-
- QString fullpath = mFolderPath;
- fullpath.append( str );
-
- TBuf16<1024> buf16;
- buf16.Copy( (TUint16*)fullpath.data_ptr()->data ,fullpath.data_ptr()->size );
- TBuf8<1024> buf8;
- buf8.Copy( buf16 );
-
- if( NONE != mCurrentState )
- {
- gst_unref();
- }
-
- int err = gst_play_file( (char*)buf8.PtrZ() );
- if(err)
- {
- showNote(err);
- mCurrentState = NONE;
- }
- else
- {
- mCurrentState = PLAYING;
- }
-
-}
-void FolderView::pause()
-{
- if( PLAYING == mCurrentState ){
- gst_pause();
- mCurrentState = PAUSE;
- }
-}
-
-void FolderView::resume()
-{
- if( PAUSE == mCurrentState ){
- gst_resume();
- mCurrentState = PLAYING;
- }
-}
-
-void FolderView::stop()
-{
- if( mIsRecording == TRUE )
- {
- gst_record_stop();
-
- if( mModel )
- delete mModel;
-
- mModel = new QDirModel(this);
- mFileList->setModel(mModel);
-
- mFileList->reset();
- mFileList->setRootIndex(mModel->index(mFolderPath));
-// mFileList->show();
-// int x = mFileList->indexCount();
- //setWidget(mFileList);
- mIsRecording = FALSE;
- return;
- }
- if( PLAYING == mCurrentState || PAUSE == mCurrentState ){
- gst_unref();
- mCurrentState = NONE;
- }
-}
-
-void FolderView::record_AMR()
-{
- if( mCurrentState == NONE ){
- int err = gst_record_file( RECORD_AMR );
- if(err)
- {
- showNote(err);
- mCurrentState = NONE;
- mIsRecording = FALSE;
- }
- else
- {
- mCurrentState = PLAYING;
- mIsRecording = TRUE;
- }
- }
-}
-
-void FolderView::record_WAV()
-{
- if( mCurrentState == NONE ){
- int err = gst_record_file( RECORD_WAV );
- if(err)
- {
- showNote(err);
- mCurrentState = NONE;
- mIsRecording = FALSE;
- }
- else
- {
- mCurrentState = PLAYING;
- mIsRecording = TRUE;
- }
- //gst_record_wav();
- }
-}
-
-void FolderView::record_RAW()
-{
- if( mCurrentState == NONE ){
- int err = gst_record_file( RECORD_RAW );
- if(err)
- {
- showNote(err);
- mCurrentState = NONE;
- mIsRecording = FALSE;
- }
- else
- {
- mCurrentState = PLAYING;
- mIsRecording = TRUE;
- }
- }
-}
-
-void FolderView::record_G711()
-{
- if( mCurrentState == NONE ){
- int err = gst_record_file( RECORD_G711 );
- if(err)
- {
- showNote(err);
- mCurrentState = NONE;
- mIsRecording = FALSE;
- }
- else
- {
- mCurrentState = PLAYING;
- mIsRecording = TRUE;
- }
- }
-}
-
-void FolderView::record_G729()
-{
- if( mCurrentState == NONE ){
- int err = gst_record_file( RECORD_G729 );
- if(err)
- {
- showNote(err);
- mCurrentState = NONE;
- mIsRecording = FALSE;
- }
- else
- {
- mCurrentState = PLAYING;
- mIsRecording = TRUE;
- }
- }
-}
-
-void FolderView::record_ILBC()
-{
- if( mCurrentState == NONE ){
- int err = gst_record_file( RECORD_ILBC );
- if(err)
- {
- showNote(err);
- mCurrentState = NONE;
- mIsRecording = FALSE;
- }
- else
- {
- mCurrentState = PLAYING;
- mIsRecording = TRUE;
- }
- }
-}
-
-void FolderView::record_AAC()
-{
- if( mCurrentState == NONE ){
- int err = gst_record_file( RECORD_AAC );
- if(err)
- {
- showNote(err);
- mCurrentState = NONE;
- mIsRecording = FALSE;
- }
- else
- {
- mCurrentState = PLAYING;
- mIsRecording = TRUE;
- }
- }
-}
-void FolderView::timertimeout()
-{
- if( PLAYING == mCurrentState ){
- gst_get_events();
- }
-
- if( STOP == mCurrentState ){
- gst_unref();
- mCurrentState = NONE;
- mIsRecording = FALSE;
- }
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e QtGSTPlayer/folderview.h
--- a/QtGSTPlayer/folderview.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-#ifndef FOLDERVIEW_H
-#define FOLDERVIEW_H
-
-#include
-//#include
-
-#include "record_play.h"
-
-QT_BEGIN_NAMESPACE
-class QDirModel;
-QT_END_NAMESPACE
-
-//class HbFormItem;
-class HbListView;
-
-class FolderView : public HbView
-{
- Q_OBJECT
-
-public:
- explicit FolderView(QGraphicsItem *parent = 0);
- ~FolderView();
-public slots:
- void folderViewTriggered();
- //void settingsViewTriggered();
- void item_pressed(const QModelIndex &index);
-//
- void record_AMR();
- void record_WAV();
- void record_RAW();
- void record_G711();
- void record_G729();
- void record_ILBC();
- void record_AAC();
-
- void pause();
- void resume();
- void stop();
- void timertimeout();
- void showNote(const int err);
-
-//void record_file( int type );
-
-
-private:
- HbListView *mFileList;
-
-//signals:
-// void pressed(const QModelIndex &index);
-// void released(const QModelIndex &index);
-// void activated(const QModelIndex &index);
-// void longPressed(HbAbstractViewItem *item, const QPointF &coords);
-
- QDirModel *mModel;
- QString mFolderPath;
- QTimer *mTimer;
- bool mIsRecording;
-
-
- //state st;
-
-};
-
-#endif // FOLDERVIEW_H
diff -r 5cb7d96a6887 -r 8d4f92b9230e QtGSTPlayer/main.cpp
--- a/QtGSTPlayer/main.cpp Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*! This is an example application demonstrating how a simple Hb
- application is created. This application implements a folder
- browser. The application creates two views. The main view (Folder
- view) shows the folder contents. The second view (Settings view) can
- be used to set the path which is shown in the Folder view. Settings
- view uses the HbFormView. Folder view inherits HbView and implements
- a couple of methods to populate the Folder view. */
-
-#include
-#include
-#include
-#include
-#include
-
-
-#include
-#include
-#include
-
-#include "folderview.h"
-#include "views.h"
-
-int main(int argc, char *argv[])
-{
- // Create HbApplication
- gst_init (&argc, &argv);
- HbApplication a(argc, argv);
- a.setApplicationName(QObject::tr("Folder Browser"));
- //LOG(_L("Entering main.cpp"));
-
- // Create main window
- HbMainWindow mainWindow;
-
- // Create View#1 : Folder view
- HbView *folderView = new FolderView;
- // Title pane text
- folderView->setTitle(QObject::tr("QtGSTPlayer"));
-
- // Add two views to main window,
- // the adding order determines which one is shown first
-
- mainWindow.addView(folderView);
- /*mainWindow.addView(settingsView);*/
-
- // Store the mainwindow ptr.
- Views::win = &mainWindow;
-
- // Show main window
- mainWindow.show();
-
- return a.exec();
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e QtGSTPlayer/record_play.c
--- a/QtGSTPlayer/record_play.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,855 +0,0 @@
-
-
-#include
-#include
-#include
-#include "record_play.h"
-
-
-GstElement *bin;
-extern int mCurrentState;
-
-static GstElement *
-create_video_output ()
-{
- static gboolean have_video = FALSE;
- GstBin *bin;
- GstElement *queue, *sink;
- GstPad *pad;
-
- if (have_video) {
- //g_print ("Already playing a video stream. Ignoring this one\n");
- return NULL;
- }
-
- /* create a new bin to hold the elements */
- if((bin = (GstBin*) gst_bin_new (NULL)) == NULL)
- //bin = (GstBin*) gst_pipeline_new("pipeline");
- return NULL;
-
- /* Queue to ensure all streams can push data */
- queue = gst_element_factory_make ("queue", "q");
- if(queue == NULL)
- return NULL;/* Queue should always be available */
- /* Set the queue to buffer 1/10 of a second of raw video */
- g_object_set (queue, "max-size-time", (GstClockTime) GST_SECOND / 10,
- "max-size-bytes", 0, "max-size-buffers", 0, NULL);
-
-// cs = gst_element_factory_make ("ffmpegcolorspace", "cs");
-// if (!cs)
-// goto no_output;
-
- /* and a video sink */
- sink = gst_element_factory_make ("fakesink"/*autovideosink*/, "sink");
- if (!sink)
- goto no_output;
-
- /* add objects to the main pipeline */
- gst_bin_add_many (GST_BIN (bin), queue, sink, NULL);
-
- /* Link the elements */
- gst_element_link_many (queue, sink, NULL);
-
- /* Retrieve the sinkpad from the queue and 'ghost' it onto
- * the bin so that the caller can find it generically */
- pad = gst_element_get_pad (queue, "sink");
- gst_element_add_pad (GST_ELEMENT (bin), gst_ghost_pad_new ("sink", pad));
- gst_object_unref (pad);
-
- //have_video = TRUE;
-
- return GST_ELEMENT (bin);
-
- /* ERRORS */
-no_output:
- {
- //g_print ("Could not create either ffmpegcolorspace or autovideosink for output");
- return NULL;
- }
-}
-
-static GstElement *
-create_audio_output ()
-{
- static gboolean have_audio = FALSE;
- GstBin *bin;
- GstElement *queue, *audioconvert,*audioresample, *sink;
- GstPad *pad;
-
- if (have_audio) {
- //g_print ("Already playing an audio stream. Ignoring this one\n");
- return NULL;
- }
-
- /* create a new bin to hold the elements */
- bin = (GstBin*) gst_bin_new (NULL);
- if(!bin)
- goto no_output;
-
- /* Queue to ensure all streams can push data */
- queue = gst_element_factory_make ("queue", "q");
- if (!queue) /* Queue should always be available */
- goto no_output;
- /* Set the queue to buffer 1/10 of a second of raw audio */
- g_object_set (queue, "max-size-time", (GstClockTime) GST_SECOND / 10,
- "max-size-bytes", 0, "max-size-buffers", 0, NULL);
-
- /* an audio converter to convert floating-point audio samples to int format */
- audioconvert = gst_element_factory_make ("audioconvert", "ac");
- if (!audioconvert)
- goto no_output;
-
- /* an audio converter to convert floating-point audio samples to int format */
- audioresample = gst_element_factory_make ("audioresample", "audioresample");
- if (!audioresample)
- goto no_output;
-
- /* and an audio sink */
- sink = gst_element_factory_make ("autoaudiosink", "sink");
- if (!sink)
- goto no_output;
-
- /* add objects to the bin */
- gst_bin_add_many (GST_BIN (bin), queue, audioconvert,audioresample, sink, NULL);
-
- /* link the elements */
- gst_element_link_many (queue, audioconvert,audioresample, sink, NULL);
-
- /* Retrieve the sinkpad from the queue element and 'ghost' it onto
- * the bin so that the caller can find it generically */
- pad = gst_element_get_pad (queue, "sink");
- gst_element_add_pad (GST_ELEMENT (bin), gst_ghost_pad_new ("sink", pad));
- gst_object_unref (pad);
-
- //have_audio = TRUE;
-
- return GST_ELEMENT (bin);
-
- /* ERRORS */
-no_output:
- {
- //g_print ("Could not create either ffmpegcolorspace or autovideosink for output");
- return NULL;
- }
-}
-
-static void
-new_decoded_pad (GstElement * element, GstPad * pad, gboolean last,
- GstBin *top_pipeline)
-{
- GstPad *out_pad;
- GstElement *output = NULL;
- GstCaps *caps;
- GstStructure *s;
- const gchar *stream_type;
-
- /* Decide which output we are creating based on the stream contents */
- caps = gst_pad_get_caps (pad);
- if (caps == NULL) {
- //g_print ("Decodebin produced an unknown stream - ignoring\n");
- return;
- }
-
- s = gst_caps_get_structure (caps, 0);
- if(s == NULL)/* Caps on a pad should always have exactly one entry */
- return;
-
- stream_type = gst_structure_get_name (s);
-
- if (g_str_has_prefix (stream_type, "video/x-raw-")) {
- /* Is a new video stream */
- //g_print ("Encountered a new video stream\n");
- output = create_video_output ();
- }
- else if (g_str_has_prefix (stream_type, "audio/x-raw-")) {
- //g_print ("Encountered a new audio stream\n");
- output = create_audio_output ();
- }
- else {
- //g_print ("Found unknown stream of type %s - ignoring\n", stream_type);
- }
-
- /* If no renderer was created, ignore this stream */
- if (output == NULL)
- return;
-
- /* Add the output into our pipeline */
- gst_bin_add (top_pipeline, output);
-
- /* If we created a output pipeline, retrieve the sink pad from it */
- out_pad = gst_element_get_pad (output, "sink");
- g_return_if_fail (out_pad != NULL);
-
- /* Attempt to link the new pad to the output */
- if (gst_pad_link (pad, out_pad) != GST_PAD_LINK_OK) {
- //g_print ("Failed to add the rendering pipeline for this new data stream\n");
- gst_bin_remove (top_pipeline, output);
- gst_object_unref (out_pad);
- return;
- }
- gst_object_unref (out_pad);
-
- /* New output renderer is successfully linked in the pipeline.
- * Change its state to playing so it is ready to receive data */
- gst_element_set_state (output, GST_STATE_PLAYING);
-}
-
-static void
-print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
-{
- gint i, count;
-
- count = gst_tag_list_get_tag_size (list, tag);
-
- for (i = 0; i < count; i++) {
- gchar *str;
-
- if (gst_tag_get_type (tag) == G_TYPE_STRING) {
- if (!gst_tag_list_get_string_index (list, tag, i, &str))
- g_assert_not_reached ();
- } else {
- str =
- g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
- }
-
- if (i == 0) {
- //g_print (" %15s: %s\n", gst_tag_get_nick (tag), str);
- } else {
- //g_print (" : %s\n", str);
- }
-
- g_free (str);
- }
-}
-
-
-
-static gboolean
-bus_call (GstBus *bus,
- GstMessage *message,
- gpointer data)
-{
- switch (GST_MESSAGE_TYPE (message)){
- case GST_MESSAGE_EOS:
- gst_message_unref (message);
- gst_element_set_state (bin, GST_STATE_NULL);
- /* Unreffing the bin will clean up all its children too */
- gst_object_unref (bin);
- mCurrentState = NONE;
- break;
- case GST_MESSAGE_ERROR:{
- GError *gerror;
- gchar *debug;
-
- gst_message_parse_error (message, &gerror, &debug);
- gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
- gst_message_unref (message);
- g_error_free (gerror);
- g_free (debug);
- gst_element_set_state (bin, GST_STATE_NULL);
- /* Unreffing the bin will clean up all its children too */
- gst_object_unref (bin);
- mCurrentState = NONE;
- break;
- }
- case GST_MESSAGE_WARNING:{
- GError *gerror;
- gchar *debug;
-
- gst_message_parse_warning (message, &gerror, &debug);
- gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
- gst_message_unref (message);
- g_error_free (gerror);
- g_free (debug);
- break;
- }
- case GST_MESSAGE_TAG:
- {
- GstTagList *tags;
-
- gst_message_parse_tag (message, &tags);
- if (tags) {
- //g_print ("TAGS received from element \"%s\".\n",
- // GST_STR_NULL (GST_ELEMENT_NAME (GST_MESSAGE_SRC (message))));
-
- gst_tag_list_foreach (tags, print_tag, NULL);
- gst_tag_list_free (tags);
- tags = NULL;
- }
- break;
- }
- default:
- gst_message_unref (message);
- break;
- }
- return TRUE;
-}
-
-
-
-//static void
-//event_loop (GstElement * pipe)
-//{
-// GstBus *bus;
-// GstMessage *message = NULL;
-//
-// bus = gst_element_get_bus (GST_ELEMENT (pipe));
-//
-// while (TRUE) {
-// message = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
-//
-// g_assert (message != NULL);
-//
-// switch (message->type) {
-// case GST_MESSAGE_EOS:
-// gst_message_unref (message);
-// return;
-// case GST_MESSAGE_ERROR:{
-// GError *gerror;
-// gchar *debug;
-//
-// gst_message_parse_error (message, &gerror, &debug);
-// gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
-// gst_message_unref (message);
-// g_error_free (gerror);
-// g_free (debug);
-// return;
-// }
-// case GST_MESSAGE_WARNING:{
-// GError *gerror;
-// gchar *debug;
-//
-// gst_message_parse_warning (message, &gerror, &debug);
-// gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
-// gst_message_unref (message);
-// g_error_free (gerror);
-// g_free (debug);
-// break;
-// }
-// case GST_MESSAGE_TAG:
-// {
-// GstTagList *tags;
-//
-// gst_message_parse_tag (message, &tags);
-// if (tags) {
-// //g_print ("TAGS received from element \"%s\".\n",
-// GST_STR_NULL (GST_ELEMENT_NAME (GST_MESSAGE_SRC (message))));
-//
-// gst_tag_list_foreach (tags, print_tag, NULL);
-// gst_tag_list_free (tags);
-// tags = NULL;
-// }
-// break;
-// }
-// default:
-// gst_message_unref (message);
-// break;
-// }
-// }
-//}
-
-int
-gst_play_file (const char* file)
-{
- GstElement *filesrc, *decodebin, *sink;
- GstCaps* caps;
- //int length = strlen( file );
- //gst_init (&argc, &argv);
-
- if (file == NULL) {
- //g_print ("file is not present");
- goto no_output;
- }
-
- //g_print ("Constructing pipeline\n");
-
- /* create a new bin to hold the elements */
- bin = gst_pipeline_new ("pipeline");
- if(!bin)
- goto no_output;
-
- /* create a disk reader */
- filesrc = gst_element_factory_make ("filesrc", "disk_source");
- if(!filesrc)
- goto no_output;
-
- g_object_set (G_OBJECT (filesrc), "location", file, NULL);
-
- if( g_str_has_suffix (file, "raw") )
- {
- sink = gst_element_factory_make ("devsoundsink", "sink");
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "signed",G_TYPE_BOOLEAN, TRUE,
- "endianness",G_TYPE_INT, G_BYTE_ORDER,
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1, NULL);
- gst_bin_add_many (GST_BIN (bin), filesrc, sink, NULL);
-
- gst_element_link_filtered (filesrc, sink, caps);
- }
- else if( g_str_has_suffix (file, "g711") )
- {
- sink = gst_element_factory_make ("devsoundsink", "sink");
- caps = gst_caps_new_simple ("audio/x-alaw",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "signed",G_TYPE_BOOLEAN, TRUE,
- "endianness",G_TYPE_INT, G_BYTE_ORDER,
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1, NULL);
- gst_bin_add_many (GST_BIN (bin), filesrc, sink, NULL);
-
- gst_element_link_filtered (filesrc, sink, caps);
- }
- else if( g_str_has_suffix (file, "g729") )
- {
- sink = gst_element_factory_make ("devsoundsink", "sink");
- caps = gst_caps_new_simple ("audio/g729",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "signed",G_TYPE_BOOLEAN, TRUE,
- "endianness",G_TYPE_INT, G_BYTE_ORDER,
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1, NULL);
- gst_bin_add_many (GST_BIN (bin), filesrc, sink, NULL);
-
- gst_element_link_filtered (filesrc, sink, caps);
- }
- else if( g_str_has_suffix (file, "ilbc") )
- {
- sink = gst_element_factory_make ("devsoundsink", "sink");
-
- caps = gst_caps_new_simple ("audio/ilbc",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "signed",G_TYPE_BOOLEAN, TRUE,
- "endianness",G_TYPE_INT, G_BYTE_ORDER,
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1, NULL);
-
- gst_bin_add_many (GST_BIN (bin), filesrc, sink, NULL);
-
- gst_element_link_filtered (filesrc, sink, caps);
- }
- else if( g_str_has_suffix (file, "amr") )
- {
- sink = gst_element_factory_make ("devsoundsink", "sink");
- caps = gst_caps_new_simple ("audio/amr",
- "width", G_TYPE_INT, 8,
- "depth", G_TYPE_INT, 8,
- "signed",G_TYPE_BOOLEAN, TRUE,
- "endianness",G_TYPE_INT, G_BYTE_ORDER,
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1, NULL);
- gst_bin_add_many (GST_BIN (bin), filesrc, sink, NULL);
-
- //gst_element_link (source, sink);
- gst_element_link_filtered (filesrc, sink, caps);
- }
-
- else
- {
- /* Create the decodebin */
- decodebin = gst_element_factory_make ("decodebin", NULL);
- if (!decodebin) {
- //g_print ("could not find the \"decodebin\" element\n");
- return -1;
- }
-
- /* add objects to the main pipeline */
- gst_bin_add_many (GST_BIN (bin), filesrc, decodebin, NULL);
-
- /* link the elements. */
- gst_element_link_many (filesrc, decodebin, NULL);
-
- /* Connect to decodebin's 'new-decoded-pad' signal to detect when it produces
- * a new stream */
- g_signal_connect (G_OBJECT (decodebin), "new-decoded-pad",
- G_CALLBACK (new_decoded_pad), bin);
- }
-
- gst_bus_add_watch( gst_pipeline_get_bus (GST_PIPELINE (bin)), bus_call, NULL);
- //g_print ("Starting playback\n");
- /* start playing */
- gst_element_set_state (bin, GST_STATE_PLAYING);
- return 0;
-
-no_output:
- return -1;
-
-}
-
-
-int
-gst_record_file (int type)
-{
- GstElement *audiosrc, *filesink;
- char* carray = NULL;
- GstCaps* caps;
- //g_print ("Constructing pipeline\n");
-
- /* switch case for recording type*/
- switch( type )
- {
- case RECORD_RAW:
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "signed",G_TYPE_BOOLEAN, TRUE,
- "endianness",G_TYPE_INT, G_BYTE_ORDER,
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1, NULL);
-
- carray = "c:\\data\\sounds\\Digital\\record.raw";
- break;
-
- case RECORD_AMR:
- {
- return gst_record_amr();
- }
- break;
-
- case RECORD_G711:
-
- caps = gst_caps_new_simple ("audio/x-alaw",
- "width", G_TYPE_INT, 8,
- "depth", G_TYPE_INT, 8,
- "signed",G_TYPE_BOOLEAN, TRUE,
- "endianness",G_TYPE_INT, G_BYTE_ORDER,
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1, NULL);
-
- carray = "c:\\data\\sounds\\Digital\\record.g711";
- break;
-
- case RECORD_G729: //
-
- caps = gst_caps_new_simple ("audio/g729",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "signed",G_TYPE_BOOLEAN, TRUE,
- "endianness",G_TYPE_INT, G_BYTE_ORDER,
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1, NULL);
-
- carray = "c:\\data\\sounds\\Digital\\record.g729";
- break;
-
- case RECORD_ILBC: //
-
- caps = gst_caps_new_simple ("audio/ilbc",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "signed",G_TYPE_BOOLEAN, TRUE,
- "endianness",G_TYPE_INT, G_BYTE_ORDER,
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1, NULL);
-
- carray = "c:\\data\\sounds\\Digital\\record.ilbc";
- break;
- case RECORD_WAV:
- {
- return gst_record_wav();
- }
- break;
- case RECORD_AAC:
- {
- return gst_record_aac();
- }
- break;
- default:
- return -1;
- break;
- }
- /* create a new bin to hold the elements */
- bin = gst_pipeline_new ("pipeline");
- if(!bin)
- goto no_output;
-
- /* create a disk reader */
- audiosrc = gst_element_factory_make ("devsoundsrc", "audio_source");
- if(!audiosrc)
- goto no_output;
-
- /* Create the decodebin */
- filesink = gst_element_factory_make ("filesink", NULL);
- if(!filesink)
- goto no_output;
-
- g_object_set (G_OBJECT (audiosrc),
- "blocksize", 1280,
- NULL);
-
- g_object_set (G_OBJECT (filesink), "location", carray,"buffer-size",1280, NULL);
-
- /* add objects to the main pipeline */
- gst_bin_add_many (GST_BIN (bin), audiosrc, filesink, NULL);
-
- /* link the elements. */
- gst_element_link_filtered (audiosrc, filesink, caps);
- //gst_element_link_many (audiosrc, filesink, NULL);
- gst_bus_add_watch( gst_pipeline_get_bus (GST_PIPELINE (bin)), bus_call, NULL);
-
- //g_print ("Starting recoring\n");
- /* start playing */
- gst_element_set_state (bin, GST_STATE_PLAYING);
-
- /* Run event loop listening for bus messages until EOS or ERROR */
- //event_loop (bin);
-
-// //g_print ("Finished playback - stopping pipeline\n");
-//
-// /* stop the bin */
-// gst_element_set_state (bin, GST_STATE_NULL);
-//
-// /* Unreffing the bin will clean up all its children too */
-// gst_object_unref (bin);
-//
- return 0;
-no_output:
- return -1;
-
-}
-
-
-int
-gst_record_wav ()
-{
- GstElement *audiosrc, *filesink, *wavenc;
- char* carray = NULL;
- GstCaps* caps;
-
- //g_print ("Constructing pipeline\n");
-
- /* create a new bin to hold the elements */
- bin = gst_pipeline_new ("pipeline");
- if(!bin)
- goto no_output;
-
- /* create a disk reader */
- audiosrc = gst_element_factory_make ("devsoundsrc", "audio_source");
- if(!audiosrc)
- goto no_output;
-
- /* Create the decodebin */
- filesink = gst_element_factory_make ("filesink", NULL);
- if(!filesink)
- goto no_output;
-
- wavenc = gst_element_factory_make ("wavenc", NULL);
- if(!wavenc)
- goto no_output;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "signed",G_TYPE_BOOLEAN, TRUE,
- "endianness",G_TYPE_INT, G_BYTE_ORDER,
- "rate", G_TYPE_INT, 16000,
- "channels", G_TYPE_INT, 1, NULL);
-
- carray = "c:\\data\\sounds\\Digital\\record.wav";
-
- g_object_set (G_OBJECT (audiosrc),
- "blocksize", 1280,
- NULL);
-
- g_object_set (G_OBJECT (filesink), "location", carray,"buffer-size",1280, NULL);
-
- /* add objects to the main pipeline */
- gst_bin_add_many (GST_BIN (bin), audiosrc,wavenc, filesink, NULL);
-
- /* link the elements. */
- gst_element_link_filtered (audiosrc, wavenc, caps);
- gst_element_link (wavenc, filesink);
- gst_bus_add_watch( gst_pipeline_get_bus (GST_PIPELINE (bin)), bus_call, NULL);
- //g_print ("Starting recoring\n");
- /* start playing */
- gst_element_set_state (bin, GST_STATE_PLAYING);
-
- return 0;
-
-no_output:
- return -1;
-}
-
-int gst_pause()
-{
- gst_element_set_state (bin, GST_STATE_PAUSED);
- return 0;
-}
-
-int gst_resume()
-{
- gst_element_set_state (bin, GST_STATE_PLAYING);
- return 0;
-}
-
-
-int gst_record_stop()
-{
- gst_element_send_event (bin, gst_event_new_eos ());
- //gst_element_set_state (bin, GST_STATE_NULL);
- return 0;
-}
-
-
-int gst_seek()
-{
-// need to implement..
-}
-
-int gst_get_events()
-{
- return g_main_context_iteration(NULL, FALSE);
- //return 0;
-}
-
-int gst_unref()
-{
- //g_print ("Finished playback - stopping pipeline\n");
- /* stop the bin */
- gst_element_set_state (bin, GST_STATE_NULL);
- /* Unreffing the bin will clean up all its children too */
- gst_object_unref (bin);
- return 0;
-}
-
-int gst_record_aac()
-{
- GstElement *audiosrc,*filesink,*aacenc, *mp4mux;
- GstBus *bus;
- GstPad *mp4sinkpad,*aacencsrcpad;
- char* carray = NULL;
- GstCaps* caps;
-
- /*create a pipeline*/
- bin = gst_pipeline_new ("pipeline");
- if(!bin)
- goto no_output;
- /* create a disk reader */
- audiosrc = gst_element_factory_make ("devsoundsrc", "audio_source");
- if(!audiosrc)
- goto no_output;
-
- /* Create the decodebin */
- filesink = gst_element_factory_make ("filesink", NULL);
- if(!filesink)
- goto no_output;
- //setting num-buffers
- //g_object_set (G_OBJECT (audiosrc), "num-buffers", 5000 , NULL);
- g_object_set (G_OBJECT (audiosrc),
- "blocksize", 1280,
- NULL);
-
- aacenc = gst_element_factory_make("nokiaaacenc", "nokiaaacenc");
- if(!aacenc)
- goto no_output;
- mp4mux = gst_element_factory_make("mp4mux", "mp4mux");
- if(!mp4mux)
- goto no_output;
- caps = gst_caps_new_simple("audio/x-raw-int",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "signed",G_TYPE_BOOLEAN, TRUE,
- "endianness",G_TYPE_INT, G_BYTE_ORDER,
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1, NULL);
- carray = "c:\\data\\sounds\\Digital\\record.mp4";
-
-
- g_object_set(G_OBJECT (filesink), "location", carray, NULL);
- bus = gst_pipeline_get_bus(GST_PIPELINE (bin));
-
- gst_bus_add_watch(bus, bus_call, NULL);
-
- gst_object_unref(bus);
-
-
- //add objects to the main pipeline
- gst_bin_add_many(GST_BIN (bin),audiosrc,aacenc,mp4mux,filesink, NULL);
-
- gst_element_link_filtered (audiosrc, aacenc, caps);
-
- mp4sinkpad = gst_element_get_request_pad( mp4mux, "audio_%d");
-
- aacencsrcpad = gst_element_get_pad( aacenc, "src");
- if (gst_pad_link (aacencsrcpad,mp4sinkpad) != GST_PAD_LINK_OK) {
-
- g_print("gst_pad_link (aacencsrcpad,mp4sinkpad) failed");
-
- return -1;
- }
- //gst_element_link (aacenc, filesink);
- gst_element_link (mp4mux, filesink);
-
- gst_caps_unref (caps);
-
-
- gst_element_set_state(bin, GST_STATE_PLAYING);
-
- return 0;
-no_output:
- return -1;
-}
-
-int gst_record_amr()
-{
- GstElement *audiosrc, *filesink, *amrmux;
- GstBus *bus;
- char* carray = NULL;
- GstCaps* caps;
- /* create a new bin to hold the elements */
- bin = gst_pipeline_new ("pipeline");
- if(!bin)
- goto no_output;
- //g_print ("pipeline created");
- audiosrc = gst_element_factory_make ("devsoundsrc", "audio_source");
- // encoder = gst_element_factory_make ("wavenc", NULL);
- if(!audiosrc)
- goto no_output;
-
- amrmux = gst_element_factory_make ("amrmux", "muxer");
- if(!amrmux)
- goto no_output;
-
- filesink = gst_element_factory_make("filesink", "filesink");
- if(!filesink)
- goto no_output;
-
- caps = gst_caps_new_simple ("audio/amr",
- "width", G_TYPE_INT, 8,
- "depth", G_TYPE_INT, 8,
- "signed",G_TYPE_BOOLEAN, TRUE,
- "endianness",G_TYPE_INT, G_BYTE_ORDER,
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1, NULL);
- carray = "c:\\data\\sounds\\Digital\\record.amr";
-
- g_object_set (G_OBJECT (audiosrc),
- "blocksize", 1280,
- NULL);
-
- g_object_set(G_OBJECT (filesink), "location", carray, NULL);
-
- bus = gst_pipeline_get_bus (GST_PIPELINE (bin));
- gst_bus_add_watch (bus, bus_call, NULL);
- gst_object_unref (bus);
-
-
- /* add objects to the main pipeline */
- gst_bin_add_many(GST_BIN (bin),audiosrc,amrmux,filesink , NULL);
- /* link the elements */
- gst_element_link_filtered (audiosrc, amrmux, caps);
-
- gst_element_link( amrmux, filesink );
-
- gst_element_set_state (bin, GST_STATE_PLAYING);
-
- return 0;
-no_output:
- return -1;
-
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e QtGSTPlayer/record_play.h
--- a/QtGSTPlayer/record_play.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the
-* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-* Boston, MA 02111-1307, USA.
-*
-* Description:
-*
-*/
-
-#ifndef __HELP_FILE_H__
-#define __HELP_FILE_H__
-#include
-#include
-
-enum
-{
- NONE,
- PLAYING,
- STOP,
- PAUSE,
- /*RESUME,
- RECORDING*/
-};
-
-enum
-{
- RECORD_NONE,
- RECORD_AMR,
- RECORD_WAV,
- RECORD_RAW,
- RECORD_G711,
- RECORD_G729,
- RECORD_ILBC,
- RECORD_AAC
-};
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-int gst_play_file( const char* file );
-
-int gst_record_file( int type );
-
-int gst_record_wav();
-
-int gst_pause();
-
-int gst_resume();
-
-int gst_record_stop();
-
-int gst_seek();
-
-int gst_unref();
-
-int gst_get_events();
-
-int gst_record_aac();
-
-int gst_record_amr();
-
-#ifdef __cplusplus
-}
-#endif
-#endif //__HELP_FILE_H__
-
diff -r 5cb7d96a6887 -r 8d4f92b9230e QtGSTPlayer/settings.png
Binary file QtGSTPlayer/settings.png has changed
diff -r 5cb7d96a6887 -r 8d4f92b9230e QtGSTPlayer/views.cpp
--- a/QtGSTPlayer/views.cpp Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#include
-#include
-//#include
-
-#include "views.h"
-
-// Helper methods for retrieving the views used in this application
-namespace Views {
-
- // Store the mainwindow ptr here because we cannot call HbWidget::mainWindow() from these static functions.
- HbMainWindow *win;
-
-/*!
- Returns the pointer to folder view.
-*/
- HbView *folderView()
- {
- // 0 since folderView was added first to the main window
- return win->viewAt(0);
- }
-
-/*!
- Returns the pointer to settings view.
-*/
- /* HbFormView *settingsView()
- {
- // 1 since settingsView was the second view added
- return static_cast(win->viewAt(1));
- }
- */
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e QtGSTPlayer/views.h
--- a/QtGSTPlayer/views.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-#ifndef VIEWS_H
-#define VIEWS_H
-
-class HbView;
-//class HbFormView;
-class HbMainWindow;
-
-namespace Views
-{
- extern HbMainWindow *win;
- HbView *folderView();
- //HbFormView *settingsView();
-}
-
-#endif // VIEWS_H
diff -r 5cb7d96a6887 -r 8d4f92b9230e data/gst_dll_2001F41F.txt
--- a/data/gst_dll_2001F41F.txt Fri May 28 18:11:17 2010 -0500
+++ b/data/gst_dll_2001F41F.txt Fri Jun 25 17:18:46 2010 -0500
@@ -7,7 +7,6 @@
libgstdecodebin2.dll
libgstdevsoundsink.dll
libgstdevsoundsrc.dll
-libgstapp.dll
libgstqueue2.dll
libgstadder.dll
libgsttypefindfunctions.dll
@@ -15,29 +14,13 @@
libgstwavparse.dll
libgstaudiotestsrc.dll
libgstautodetect.dll
-libgstmad.dll
-libgstvideorate.dll
-libgstvideoscale.dll
-libgstvideotestsrc.dll
-libgstavi.dll
-libgstffmpegcolorspace.dll
-libgstmpegstream.dll
-libgstmpeg2dec.dll
-libgstsdlvideosink.dll
-libgstauparse.dll
-libgstqtdemux.dll
+libgstsubparse.dll
+libgsttcp.dll
+libgstvolume.dll
+libgstplaybin.dll
+libgstgdp.dll
+libgstapp.dll
gstqtmux.dll
libgstnokiaaacenc.dll
-libgstlibgstqueue2.dll
-libgstjpeg.dll
-libgstplaybin.dll
-libgstgdp.dll
-libgstvolume.dll
-libgsttcp.dll
-libgstsubparse.dll
-libgstaudiofx.dll
-libgstmulaw.dll
-libgstalaw.dll
libgstamrmux.dll
-libgstmpegaudioparse.dll
-libgstnokiaaacdec.dll
+
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_nokia_speech/bwins/libgstnokiaaacencu.def
--- a/gst_nokia_speech/bwins/libgstnokiaaacencu.def Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-EXPORTS
- _GST_PLUGIN_DESC @ 1 NONAME
- gst_aac_enc_get_type @ 2 NONAME
-
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_nokia_speech/config.h
--- a/gst_nokia_speech/config.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,274 +0,0 @@
-/* config.h. Generated by configure. */
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* defined if cdda headers are in a cdda/ directory */
-/* #undef CDPARANOIA_HEADERS_IN_DIR */
-
-/* Default audio sink */
-#define DEFAULT_AUDIOSINK "autoaudiosink"
-
-/* Default audio source */
-#define DEFAULT_AUDIOSRC "alsasrc"
-
-/* Default video sink */
-#define DEFAULT_VIDEOSINK "autovideosink"
-
-/* Default video source */
-#define DEFAULT_VIDEOSRC "v4lsrc"
-
-/* Default visualizer */
-#define DEFAULT_VISUALIZER "goom"
-
-/* Define to 1 if translation of program messages to the user's native
- language is requested. */
-#ifdef __SYMBIAN32__
-#undef ENABLE_NLS
-#else
-#define ENABLE_NLS 1
-#endif
-
-
-/* gettext package name */
-#define GETTEXT_PACKAGE "gst-plugins-base-0.10"
-
-/* macro to use to show function name */
-#define GST_FUNCTION __PRETTY_FUNCTION__
-
-/* Defined if gcov is enabled to force a rebuild due to config.h changing */
-/* #undef GST_GCOV_ENABLED */
-
-/* Default errorlevel to use */
-#define GST_LEVEL_DEFAULT GST_LEVEL_NONE
-
-/* GStreamer license */
-#define GST_LICENSE "LGPL"
-
-/* package name in plugins */
-#define GST_PACKAGE_NAME "GStreamer Base Plug-ins source release"
-
-/* package origin */
-#define GST_PACKAGE_ORIGIN "Unknown package origin"
-
-/* support for features: gstalsa */
-#define HAVE_ALSA
-
-/* support for features: cdparanoia */
-/* #undef HAVE_CDPARANOIA */
-
-/* Define if the host CPU is an Alpha */
-/* #undef HAVE_CPU_ALPHA */
-
-/* Define if the host CPU is an ARM */
-/* #undef HAVE_CPU_ARM */
-#ifdef __SYMBIAN32__
-#define HAVE_CPU_ARM 1
-#endif
-
-/* Define if the host CPU is a CRIS */
-/* #undef HAVE_CPU_CRIS */
-
-/* Define if the host CPU is a CRISv32 */
-/* #undef HAVE_CPU_CRISV32 */
-
-/* Define if the host CPU is a HPPA */
-/* #undef HAVE_CPU_HPPA */
-
-/* Define if the host CPU is an x86 */
-#ifndef __SYMBIAN32__
-#define HAVE_CPU_I386 1
-#endif
-/* Define if the host CPU is a IA64 */
-/* #undef HAVE_CPU_IA64 */
-
-/* Define if the host CPU is a M68K */
-/* #undef HAVE_CPU_M68K */
-
-/* Define if the host CPU is a MIPS */
-/* #undef HAVE_CPU_MIPS */
-
-/* Define if the host CPU is a PowerPC */
-/* #undef HAVE_CPU_PPC */
-
-/* Define if the host CPU is a 64 bit PowerPC */
-/* #undef HAVE_CPU_PPC64 */
-
-/* Define if the host CPU is a S390 */
-/* #undef HAVE_CPU_S390 */
-
-/* Define if the host CPU is a SPARC */
-/* #undef HAVE_CPU_SPARC */
-
-/* Define if the host CPU is a x86_64 */
-/* #undef HAVE_CPU_X86_64 */
-
-/* Define if the GNU dcgettext() function is already present or preinstalled.
- */
-#define HAVE_DCGETTEXT 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_DLFCN_H 1
-
-/* support for features: */
-#define HAVE_EXTERNAL
-
-/* FIONREAD ioctl found in sys/filio.h */
-/* #undef HAVE_FIONREAD_IN_SYS_FILIO */
-
-/* FIONREAD ioctl found in sys/ioclt.h */
-#define HAVE_FIONREAD_IN_SYS_IOCTL 1
-
-/* defined if the compiler implements __func__ */
-#define HAVE_FUNC 1
-
-/* defined if the compiler implements __FUNCTION__ */
-#define HAVE_FUNCTION 1
-
-/* Define if the GNU gettext() function is already present or preinstalled. */
-#define HAVE_GETTEXT 1
-
-/* support for features: gnomevfssrc */
-#define HAVE_GNOME_VFS
-
-/* support for features: v4lsrc v4lmjpegsrc v4lmjpegsink */
-#define HAVE_GST_V4L
-
-/* Define if you have the iconv() function. */
-/* #undef HAVE_ICONV */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `asound' library (-lasound). */
-/* #undef HAVE_LIBASOUND */
-
-/* support for features: libvisual */
-/* #undef HAVE_LIBVISUAL */
-
-/* Define if you have C99's lrint function. */
-#define HAVE_LRINT 1
-
-/* Define if you have C99's lrintf function. */
-#define HAVE_LRINTF 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_MALLOC_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_MEMORY_H 1
-
-/* support for features: oggdemux oggmux */
-#define HAVE_OGG
-
-/* support for features: pango */
-#define HAVE_PANGO
-
-/* defined if the compiler implements __PRETTY_FUNCTION__ */
-#define HAVE_PRETTY_FUNCTION 1
-
-/* Define if RDTSC is available */
-#define HAVE_RDTSC 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_REGEX_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_SOCKET_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* support for features: theoradec theoraenc */
-/* #undef HAVE_THEORA */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define if valgrind should be used */
-#define HAVE_VALGRIND 1
-
-/* support for features: vorbisenc vorbisdec */
-#define HAVE_VORBIS
-
-/* defined if vorbis_synthesis_restart is present */
-#define HAVE_VORBIS_SYNTHESIS_RESTART 1
-
-/* support for features: ximagesink */
-#define HAVE_X
-
-/* support for features: xshm */
-#define HAVE_XSHM
-
-/* support for features: xvimagesink */
-#define HAVE_XVIDEO
-
-/* gettext locale dir */
-#define LOCALEDIR "/home/datha/gst-plugins-base-0.10.8/share/locale"
-
-/* Name of package */
-#define PACKAGE "gst-plugins-base"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "GStreamer nokia speech"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "GStreamer nokia speech"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "gst_nokia_speech"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.10.0"
-
-/* directory where plugins are located */
-
-/* The size of a `char', as computed by sizeof. */
-/* #undef SIZEOF_CHAR */
-
-/* The size of a `int', as computed by sizeof. */
-/* #undef SIZEOF_INT */
-
-/* The size of a `long', as computed by sizeof. */
-/* #undef SIZEOF_LONG */
-
-/* The size of a `short', as computed by sizeof. */
-/* #undef SIZEOF_SHORT */
-
-/* The size of a `void*', as computed by sizeof. */
-/* #undef SIZEOF_VOIDP */
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "0.10.0"
-
-/* Define to 1 if your processor stores words with the most significant byte
- first (like Motorola and SPARC, unlike Intel and VAX). */
-/* #undef WORDS_BIGENDIAN */
-
-/* Define to 1 if the X Window System is missing or not being used. */
-/* #undef X_DISPLAY_MISSING */
-
-/* Define to `__inline__' or `__inline' if that's what the C compiler
- calls it, or to nothing if 'inline' is not supported under any name. */
-#ifndef __cplusplus
-/* #undef inline */
-#endif
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_nokia_speech/eabi/libgstnokiaaacencu.def
--- a/gst_nokia_speech/eabi/libgstnokiaaacencu.def Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-EXPORTS
- _GST_PLUGIN_DESC @ 1 NONAME
- gst_aac_enc_get_type @ 2 NONAME
-
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_nokia_speech/group/bld.inf
--- a/gst_nokia_speech/group/bld.inf Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-PRJ_PLATFORMS
-DEFAULT
-
-PRJ_EXPORTS
-
-PRJ_MMPFILES
-#ifndef WINSCW
-gstaacenc.mmp
-#endif
\ No newline at end of file
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_nokia_speech/group/gstaacenc.mmp
--- a/gst_nokia_speech/group/gstaacenc.mmp Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-// Gstreamer.MMP
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the
-* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-* Boston, MA 02111-1307, USA.
-*
-* Description:
-*
-*/
-
-#include
-
-TARGET libgstnokiaaacenc.dll
-TARGETTYPE DLL
-UID 0x20004c45 0x0FE80A1C
-
-#ifdef EKA2
-LANG SC
-CAPABILITY All -Tcb
-VENDORID VID_DEFAULT
-#endif
-
-#if !defined(__WINSCW__) && !defined(__WINS__)
-EpocAllowDllData
-#endif
-
-MACRO HAVE_CONFIG_H //RAW_FRAME_SIZE
-
-
-USERINCLUDE ..
-
-MW_LAYER_SYSTEMINCLUDE
-OS_LAYER_LIBC_SYSTEMINCLUDE
-OS_LAYER_GLIB_SYSTEMINCLUDE
-
-USERINCLUDE ../../include/gstreamer
-USERINCLUDE ../../include/gstreamer/gst
-USERINCLUDE ../../include/gstreamer/gst/base
-USERINCLUDE ../../include/gstreamer/gst/controller
-USERINCLUDE ../../include/gstreamer/gst/dataprotocol
-USERINCLUDE ../../include/gstreamer/gst/net
-USERINCLUDE ../../include/gstreamer/gst/audio
-USERINCLUDE ../../include/gstreamer/gst/cdda
-USERINCLUDE ../../include/gstreamer/gst/floatcast
-USERINCLUDE ../../include/gstreamer/gst/interfaces
-USERINCLUDE ../../include/gstreamer/gst/netbuffer
-USERINCLUDE ../../include/gstreamer/gst/riff
-USERINCLUDE ../../include/gstreamer/gst/rtp
-USERINCLUDE ../../include/gstreamer/gst/tag
-USERINCLUDE ../../include/gstreamer/gst/video
-SYSTEMINCLUDE /epoc32/include/internal
-SOURCEPATH ..
-SOURCE gstaacenc.c gstframedaudioenc.c
-LIBRARY euser.lib
-LIBRARY libc.lib
-LIBRARY libdl.lib
-LIBRARY libglib.lib
-LIBRARY libgmodule.lib
-
-LIBRARY libgobject.lib
-LIBRARY libgthread.lib
-LIBRARY libm.lib
-LIBRARY libz.lib
-LIBRARY libgstreamer.lib
-LIBRARY enhaacplusencoder.lib
-LIBRARY libgstbase.lib
-
-#ifdef WINSCW
-LIBRARY ewsd.lib //wsd solution
-#endif
-
-
-
-SMPSAFE
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_nokia_speech/gstaacenc.c
--- a/gst_nokia_speech/gstaacenc.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,603 +0,0 @@
-/* GStreamer AAC encoder
- * Copyright 2009 Collabora Multimedia,
- * Copyright 2009 Nokia Corporation
- * @author: Mark Nauwelaerts .
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/* TODO non-GPL license */
-
-/**
- * SECTION:element-nokiaaacenc
- * @seealso: nokiaaacdec
- *
- * nokiaaacenc encodes raw audio to AAC streams.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include
-#include
-#include
-
-#include "gstaacenc.h"
-
-GST_DEBUG_CATEGORY_STATIC (aac_enc);
-#define GST_CAT_DEFAULT aac_enc
-
-enum
-{
- AAC_PROFILE_AUTO = 0,
- AAC_PROFILE_LC = 2,
- AAC_PROFILE_HE = 5
-};
-
-#define GST_TYPE_AAC_ENC_PROFILE (gst_aac_enc_profile_get_type ())
-static GType
-gst_aac_enc_profile_get_type (void)
-{
- static GType gst_aac_enc_profile_type = 0;
-
- if (!gst_aac_enc_profile_type) {
- static GEnumValue gst_aac_enc_profile[] = {
- {AAC_PROFILE_AUTO, "Codec selects LC or HE", "AUTO"},
- {AAC_PROFILE_LC, "Low complexity profile", "LC"},
- {AAC_PROFILE_HE, "High Efficiency", "HE"},
- {0, NULL, NULL},
- };
-
- gst_aac_enc_profile_type = g_enum_register_static ("GstNokiaAacEncProfile",
- gst_aac_enc_profile);
- }
-
- return gst_aac_enc_profile_type;
-}
-
-#define GST_TYPE_AAC_ENC_OUTPUTFORMAT (gst_aac_enc_outputformat_get_type ())
-static GType
-gst_aac_enc_outputformat_get_type (void)
-{
- static GType gst_aac_enc_outputformat_type = 0;
-
- if (!gst_aac_enc_outputformat_type) {
- static GEnumValue gst_aac_enc_outputformat[] = {
- {RAW, "AAC Raw format", "RAW"},
- {USE_ADTS, "Audio Data Transport Stream format", "ADTS"},
- {USE_ADIF, "Audio Data Interchange Format", "ADIF"},
- {0, NULL, NULL},
- };
-
- gst_aac_enc_outputformat_type =
- g_enum_register_static ("GstNokiaAacEncOutputFormat",
- gst_aac_enc_outputformat);
- }
-
- return gst_aac_enc_outputformat_type;
-}
-
-enum
-{
- PROP_0,
- PROP_BITRATE,
- PROP_PROFILE,
- PROP_FORMAT
-};
-
-static GstStaticPadTemplate gst_aac_enc_sink_template =
-GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (bool) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 8000, 96000 ], channels = (int) [ 1, 2 ] ")
- );
-
-static GstStaticPadTemplate gst_aac_enc_src_template =
-GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/mpeg, " "mpegversion = (int) 4, "
- "rate = (int) [ 8000, 96000 ], channels = (int) [ 1, 2 ] ")
- );
-
-static void gst_aac_enc_base_init (gpointer g_class);
-static void gst_aac_enc_class_init (GstAACEncClass * klass);
-static void gst_aac_enc_init (GstAACEnc * filter, GstAACEncClass * klass);
-
-static void gst_aac_enc_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_aac_enc_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static void gst_aac_enc_finalize (GObject * object);
-static void gst_aac_enc_reset (GstAACEnc * enc);
-static GstStateChangeReturn gst_aac_enc_change_state (GstElement * element,
- GstStateChange transition);
-static gboolean gst_aac_enc_sink_setcaps (GstPad * pad, GstCaps * caps);
-static GstFlowReturn gst_aac_enc_chain (GstPad * pad, GstBuffer * buffer);
-
-GST_BOILERPLATE (GstNokiaAACEnc, gst_aac_enc, GstElement, GST_TYPE_ELEMENT);
-
-static void
-gst_aac_enc_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_set_details_simple (element_class,
- "Nokia AAC encoder", "Codec/Encoder/Audio",
- "Nokia AAC encoder",
- "MCC, Mark Nauwelaerts ");
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_aac_enc_src_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_aac_enc_sink_template));
-}
-
-/* initialize the plugin's class */
-static void
-gst_aac_enc_class_init (GstAACEncClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
-
- GST_DEBUG_CATEGORY_INIT (aac_enc, "nokiaaacenc", 0, "Nokia AAC encoder");
-
- gobject_class->set_property = gst_aac_enc_set_property;
- gobject_class->get_property = gst_aac_enc_get_property;
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_aac_enc_finalize);
-
- /* properties */
- g_object_class_install_property (gobject_class, PROP_BITRATE,
- g_param_spec_int ("bitrate", "Bitrate (bps)", "Bitrate in bits/sec",
- 8 * 1000, 320 * 1000, 128 * 1000,
- (GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT)));
- g_object_class_install_property (gobject_class, PROP_PROFILE,
- g_param_spec_enum ("profile", "Profile",
- "MPEG/AAC encoding profile",
- GST_TYPE_AAC_ENC_PROFILE, AAC_PROFILE_LC,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (gobject_class, PROP_FORMAT,
- g_param_spec_enum ("output-format", "Output format",
- "Format of output frames",
- GST_TYPE_AAC_ENC_OUTPUTFORMAT, RAW,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_aac_enc_change_state);
-}
-
-static void
-gst_aac_enc_init (GstAACEnc * enc, GstAACEncClass * klass)
-{
- enc->sinkpad =
- gst_pad_new_from_static_template (&gst_aac_enc_sink_template, "sink");
- gst_pad_set_setcaps_function (enc->sinkpad,
- GST_DEBUG_FUNCPTR (gst_aac_enc_sink_setcaps));
- gst_pad_set_chain_function (enc->sinkpad,
- GST_DEBUG_FUNCPTR (gst_aac_enc_chain));
- gst_element_add_pad (GST_ELEMENT (enc), enc->sinkpad);
-
- enc->srcpad =
- gst_pad_new_from_static_template (&gst_aac_enc_src_template, "src");
- gst_pad_use_fixed_caps (enc->srcpad);
- gst_element_add_pad (GST_ELEMENT (enc), enc->srcpad);
-
-#ifndef GST_DISABLE_GST_DEBUG
- gst_framed_audio_enc_init (&enc->enc, GST_ELEMENT (enc), aac_enc);
-#else
- gst_framed_audio_enc_init (&enc->enc, GST_ELEMENT (enc), NULL);
-#endif
-
- gst_aac_enc_reset (enc);
-}
-
-static void
-gst_aac_enc_reset (GstAACEnc * enc)
-{
- gst_framed_audio_enc_reset (&enc->enc);
- if (enc->encoder)
- EnAACPlus_Enc_Delete (enc->encoder);
- enc->encoder = NULL;
- g_free (enc->buffer);
- enc->buffer = NULL;
-}
-
-static void
-gst_aac_enc_finalize (GObject * object)
-{
- GstAACEnc *enc = (GstAACEnc *) object;
-
- gst_framed_audio_enc_finalize (&enc->enc);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static gboolean
-gst_aac_enc_setup_encoder (GstAACEnc * enc)
-{
- AACPLUS_ENC_CONFIG enc_params;
- AACPLUS_ENC_MODE mode;
- gint rate, channels;
- guint maxbitrate;
-
- rate = enc->rate;
- channels = enc->channels;
-
- /* only up to 2 channels supported */
- enc_params.sampleRate = rate;
- enc_params.bitRate = enc->bitrate;
- enc_params.nChannels = channels;
- enc_params.aac_tools = USE_ALL;
- enc_params.pcm_mode = 16;
- enc_params.format = enc->format;
-
- /* check, warn and correct if the max bitrate for the given samplerate is
- * exceeded. Maximum of 6144 bit for a channel */
- maxbitrate =
- (guint) (6144.0 * (gdouble) rate / (gdouble) 1024.0 + .5) * channels;
- if (enc_params.bitRate > maxbitrate) {
- GST_ELEMENT_INFO (enc, RESOURCE, SETTINGS, (NULL),
- ("bitrate %d exceeds maximum allowed bitrate of %d for samplerate %d "
- "and %d channels. Setting bitrate to %d",
- enc_params.bitRate, maxbitrate, rate, channels, maxbitrate));
- enc_params.bitRate = maxbitrate;
- }
-
- /* set up encoder */
- if (enc->encoder)
- EnAACPlus_Enc_Delete (enc->encoder);
-
- /* only these profiles are really known to and supported by codec */
- switch (enc->profile) {
- case AAC_PROFILE_LC:
- mode = MODE_AACLC;
- break;
- case AAC_PROFILE_HE:
- mode = MODE_EAACPLUS;
- break;
- case AAC_PROFILE_AUTO:
- mode = MODE_AUTO;
- break;
- default:
- mode = MODE_AACLC;
- g_assert_not_reached ();
- break;
- }
- enc->encoder = EnAACPlus_Enc_Create (&enc_params, mode);
-
- if (!enc->encoder)
- goto setup_failed;
-
- /* query and setup params,
- * also set up some buffers for fancy HE */
- EnAACPlus_Enc_GetSetParam (enc->encoder, &enc->info);
-
-#define DUMP_FIELD(f) \
- GST_DEBUG_OBJECT (enc, "encoder info: " G_STRINGIFY (f) " = %d", enc->info.f);
-
- DUMP_FIELD (InBufSize);
- DUMP_FIELD (OutBufSize);
- DUMP_FIELD (Frame_Size);
- DUMP_FIELD (writeOffset);
- DUMP_FIELD (InBufSize);
-
- enc->raw_frame_size = enc->info.Frame_Size;
- enc->codec_frame_size = enc->info.OutBufSize;
- enc->frame_duration =
- GST_FRAMES_TO_CLOCK_TIME (enc->raw_frame_size / enc->channels / 2,
- enc->rate);
-
- g_free (enc->buffer);
- /* safety margin */
- enc->buffer = g_malloc (enc->info.InBufSize * 2);
-
- return TRUE;
-
- /* ERRORS */
-setup_failed:
- {
- GST_ELEMENT_ERROR (enc, LIBRARY, SETTINGS, (NULL), (NULL));
- return FALSE;
- }
-}
-
-static gint
-gst_aac_enc_rate_idx (gint rate)
-{
- static int rates[] = {
- 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025,
- 8000, 7350
- };
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (rates); ++i)
- if (rates[i] == rate)
- return i;
-
- return 0xF;
-}
-
-static gboolean
-gst_aac_enc_sink_setcaps (GstPad * pad, GstCaps * caps)
-{
- GstAACEnc *enc;
- gboolean ret = TRUE;
- GstStructure *s;
- GstBuffer *buf = NULL;
- gint rate, channels;
-
- enc = GST_AAC_ENC (GST_PAD_PARENT (pad));
-
- /* extract stream properties */
- s = gst_caps_get_structure (caps, 0);
-
- if (!s)
- goto refuse_caps;
-
- ret = gst_structure_get_int (s, "rate", &rate);
- ret &= gst_structure_get_int (s, "channels", &channels);
-
- if (!ret)
- goto refuse_caps;
-
- enc->rate = rate;
- enc->channels = channels;
-
- /* NOTE:
- * - codec only supports LC or HE (= LC + SBR etc)
- * - HE has (more) restrictive samplerate/channels/bitrate combination
- * - AUTO makes codec select between LC or HE (depending on settings)
- */
-
- gst_aac_enc_setup_encoder (enc);
- if (!enc->encoder)
- return FALSE;
-
- /* HE iff writeOffset <> 0 iff Frame_Size <> 1024 * 2 * channels */
- if (enc->info.writeOffset)
- rate /= 2;
-
- /* create codec_data if raw output */
- if (enc->format == RAW) {
- gint rate_idx;
- guint8 *data;
-
- buf = gst_buffer_new_and_alloc (5);
- data = GST_BUFFER_DATA (buf);
- rate_idx = gst_aac_enc_rate_idx (rate);
-
- GST_DEBUG_OBJECT (enc, "codec_data: profile=%d, sri=%d, channels=%d",
- enc->profile, rate_idx, enc->channels);
-
- /* always write LC profile, and use implicit signaling for HE SBR */
- data[0] = ((2 & 0x1F) << 3) | ((rate_idx & 0xE) >> 1);
- data[1] = ((rate_idx & 0x1) << 7);
- if (rate_idx != 0x0F) {
- data[1] |= ((channels & 0xF) << 3);
- GST_BUFFER_SIZE (buf) = 2;
- } else {
- gint srate;
-
- srate = rate << 7;
- data[1] |= ((srate >> 24) & 0xFF);
- data[2] = ((srate >> 16) & 0xFF);
- data[3] = ((srate >> 8) & 0xFF);
- data[4] = (srate & 0xFF);
- data[4] |= ((channels & 0xF) << 3);
- GST_BUFFER_SIZE (buf) = 5;
- }
- }
-
- /* fix some in src template */
- caps = gst_caps_copy (gst_pad_get_pad_template_caps (enc->srcpad));
- gst_caps_set_simple (caps, "rate", G_TYPE_INT, rate,
- "channels", G_TYPE_INT, channels, NULL);
- if (buf) {
- gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
- gst_buffer_unref (buf);
- }
- ret = gst_pad_set_caps (enc->srcpad, caps);
- gst_caps_unref (caps);
-
- return ret;
-
- /* ERRORS */
-refuse_caps:
- {
- GST_WARNING_OBJECT (enc, "refused caps %" GST_PTR_FORMAT, caps);
- return FALSE;
- }
-}
-
-static gint
-gst_aac_enc_get_data (GstElement * element, const guint8 * in, guint8 * out,
- GstDtxDecision * dtx)
-{
- GstAACEnc *enc;
- gint res;
- gint offset;
- UWord32 used, encoded;
- Word8 *inbuffer;
-
- enc = GST_AAC_ENC_CAST (element);
-
- offset = enc->info.writeOffset;
- if (offset) {
- memcpy (enc->buffer + offset, in, enc->raw_frame_size);
- inbuffer = (Word8 *) enc->buffer;
- } else {
- inbuffer = (Word8 *) in;
- }
-
- res = EnAACPlus_Enc_Encode (enc->encoder, &enc->info, inbuffer, &used,
- (UWord8 *) out, &encoded);
-
- if (offset) {
- memcpy (enc->buffer, enc->buffer + used, offset);
- }
-
- return res == 0 ? encoded : -1;
-}
-
-/* set parameters */
-#define AUDIO_SAMPLE_RATE ((GST_AAC_ENC (enc->element))->rate)
-#define RAW_FRAME_SIZE ((GST_AAC_ENC (enc->element))->raw_frame_size)
-/* safe maximum frame size */
-#define CODEC_FRAME_SIZE ((GST_AAC_ENC (enc->element))->codec_frame_size)
-/* do not set variable frame;
- * this will make every frame act as a silence frame and force output */
-/* #define CODEC_FRAME_VARIABLE 1 */
-#define FRAME_DURATION ((GST_AAC_ENC (enc->element))->frame_duration)
-#define codec_get_data(enc, in, out, dtx) \
- gst_aac_enc_get_data (enc, in, out, dtx)
-
-/* and include code */
-#include "gstframedaudioenc.c"
-
-static GstFlowReturn
-gst_aac_enc_chain (GstPad * pad, GstBuffer * buf)
-{
- GstAACEnc *enc;
-
- enc = GST_AAC_ENC (GST_PAD_PARENT (pad));
-
- if (G_UNLIKELY (enc->encoder == NULL))
- goto not_negotiated;
-
- return gst_framed_audio_enc_chain (&enc->enc, buf, enc->srcpad, &enc->cnpad);
-
- /* ERRORS */
-not_negotiated:
- {
- GST_ELEMENT_ERROR (enc, CORE, NEGOTIATION, (NULL),
- ("format wasn't negotiated before chain function"));
- gst_buffer_unref (buf);
- return GST_FLOW_NOT_NEGOTIATED;
- }
-}
-
-static void
-gst_aac_enc_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstAACEnc *enc;
-
- enc = GST_AAC_ENC (object);
-
- switch (prop_id) {
- case PROP_BITRATE:
- enc->bitrate = g_value_get_int (value);
- break;
- case PROP_PROFILE:
- enc->profile = g_value_get_enum (value);
- break;
- case PROP_FORMAT:
- enc->format = g_value_get_enum (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_aac_enc_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstAACEnc *enc;
-
- enc = GST_AAC_ENC (object);
-
- switch (prop_id) {
- case PROP_BITRATE:
- g_value_set_int (value, enc->bitrate);
- break;
- case PROP_PROFILE:
- g_value_set_enum (value, enc->profile);
- break;
- case PROP_FORMAT:
- g_value_set_enum (value, enc->format);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GstStateChangeReturn
-gst_aac_enc_change_state (GstElement * element, GstStateChange transition)
-{
- GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
- GstAACEnc *enc = GST_AAC_ENC (element);
-
- switch (transition) {
- case GST_STATE_CHANGE_NULL_TO_READY:
- break;
- case GST_STATE_CHANGE_READY_TO_PAUSED:
- break;
- default:
- break;
- }
-
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- if (ret == GST_STATE_CHANGE_FAILURE)
- return ret;
-
- switch (transition) {
- case GST_STATE_CHANGE_PAUSED_TO_READY:
- gst_aac_enc_reset (enc);
- break;
- case GST_STATE_CHANGE_READY_TO_NULL:
- break;
- default:
- break;
- }
-
- return ret;
-}
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
-
- if (!gst_element_register (plugin, "nokiaaacenc", GST_RANK_SECONDARY,
- GST_TYPE_AAC_ENC))
- return FALSE;
-
- return TRUE;
-}
-
-/* this is the structure that gst-register looks for
- * so keep the name plugin_desc, or you cannot get your plug-in registered */
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "nokiaaacenc",
- "Nokia AAC MCC codec",
- plugin_init, VERSION, "Proprietary", "gst-nokia-speech", "")
-
-EXPORT_C GstPluginDesc* _GST_PLUGIN_DESC()
- {
- return &gst_plugin_desc;
- }
-
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_nokia_speech/gstaacenc.h
--- a/gst_nokia_speech/gstaacenc.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/* GStreamer AAC encoder
- * Copyright 2009 Collabora Multimedia,
- * Copyright 2009 Nokia Corporation
- * @author: Mark Nauwelaerts .
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/* TODO non-GPL license */
-
-#ifndef __GST_AAC_ENC_H__
-#define __GST_AAC_ENC_H__
-
-#include
-
-#include
-
-#include "gstframedaudioenc.h"
-
-G_BEGIN_DECLS
-
-/* #define's don't like whitespacey bits */
-#define GST_TYPE_AAC_ENC \
- (gst_aac_enc_get_type())
-#define GST_AAC_ENC(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AAC_ENC,GstAACEnc))
-#define GST_AAC_ENC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AAC_ENC,GstAACEncClass))
-#define GST_IS_AAC_ENC(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AAC_ENC))
-#define GST_IS_AAC_ENC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AAC_ENC))
-#define GST_AAC_ENC_CAST(obj) ((GstAACEnc*)(obj))
-
-
-typedef struct _GstNokiaAACEnc GstNokiaAACEnc;
-typedef struct _GstNokiaAACEncClass GstNokiaAACEncClass;
-
-typedef GstNokiaAACEnc GstAACEnc;
-typedef GstNokiaAACEncClass GstAACEncClass;
-
-struct _GstNokiaAACEnc
-{
- GstElement element;
-
- GstPad *sinkpad, *srcpad, *cnpad;
-
- GstFramedAudioEnc enc;
- HANDLE_AACPLUS_ENC encoder;
- AACPLUS_ENC_INFO info;
-
- /* mode selection */
- GstClockTime frame_duration;
- gint raw_frame_size;
- gint codec_frame_size;
-
- /* optional helper (history) buffer */
- guint8 *buffer;
-
- /* stream description */
- gint rate;
- gint channels;
-
- /* properties */
- gint bitrate;
- guint profile;
- guint format;
-};
-
-struct _GstNokiaAACEncClass
-{
- GstElementClass parent_class;
-};
-
-GType gst_aac_enc_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_AAC_ENC_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_nokia_speech/gstframedaudioenc.c
--- a/gst_nokia_speech/gstframedaudioenc.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,439 +0,0 @@
-/* GStreamer Framed Audio Encoder
- * Copyright 2009 Collabora Ltd,
- * Copyright 2009 Nokia Corporation
- * @author: Mark Nauwelaerts .
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include
-#include
-#include
-
-#include "gstframedaudioenc.h"
-
-/* generic part */
-#ifndef RAW_FRAME_SIZE
-
-/* this will reference caller's debug category;
- * there is a copy of this per plugin lib (= debug category) */
-GST_DEBUG_CATEGORY_STATIC (framedaudioenc_debug);
-#define GST_CAT_DEFAULT framedaudioenc_debug
-
-void
-gst_framed_audio_enc_reset (GstFramedAudioEnc * enc)
-{
- gst_adapter_clear (enc->adapter);
- enc->next_ts = GST_CLOCK_TIME_NONE;
-}
-
-/* installs @enc as element private for @element's pad,
- * and possibly some event and query handler.
- * if these need overriding, chain up to them
- * chain and setcaps still need to be set by @element */
-void
-gst_framed_audio_enc_init (GstFramedAudioEnc * enc, GstElement * element,
- GstDebugCategory * cat)
-{
- enc->element = element;
-#ifndef GST_DISABLE_GST_DEBUG
- framedaudioenc_debug = cat;
-#endif
-
- enc->adapter = gst_adapter_new ();
-
- /* hook some */
- enc->sinkpad = gst_element_get_pad (enc->element, "sink");
- g_assert (enc->sinkpad);
- gst_pad_set_element_private (enc->sinkpad, enc);
-
- /* watch downstream events */
- gst_pad_set_event_function (enc->sinkpad,
- GST_DEBUG_FUNCPTR (gst_framed_audio_enc_sink_event));
-
- gst_framed_audio_enc_reset (enc);
-}
-
-void
-gst_framed_audio_enc_finalize (GstFramedAudioEnc * enc)
-{
- gst_object_unref (enc->adapter);
-
- gst_pad_set_element_private (enc->sinkpad, NULL);
- gst_object_unref (enc->sinkpad);
-}
-
-GstPad *
-gst_framed_audio_enc_request_new_pad (GstFramedAudioEnc * enc,
- GstPadTemplate * templ, const gchar * req_name, GstPad ** pad_p)
-{
- GstElement *element;
- GstPad *newpad;
- GstElementClass *klass;
- GstCaps *caps;
-
- g_return_val_if_fail (templ != NULL, NULL);
-
- element = enc->element;
- klass = GST_ELEMENT_GET_CLASS (element);
-
- if (templ != gst_element_class_get_pad_template (klass, "cn"))
- goto wrong_template;
-
- GST_DEBUG_OBJECT (enc->element, "adding cn pad");
- newpad = gst_pad_new_from_template (templ, "cn");
- /* set template caps */
- caps = gst_caps_copy (gst_pad_get_pad_template_caps (newpad));
- gst_pad_set_caps (newpad, caps);
- gst_caps_unref (caps);
- gst_pad_use_fixed_caps (newpad);
- gst_pad_set_active (newpad, TRUE);
- /* only 1 pad by name can be added */
- if (gst_element_add_pad (element, newpad)) {
- GST_OBJECT_LOCK (element);
- gst_object_replace ((GstObject **) pad_p, GST_OBJECT_CAST (newpad));
- GST_OBJECT_UNLOCK (element);
- GST_DEBUG_OBJECT (enc->element, "cn pad added");
- } else {
- gst_object_unref (newpad);
- goto already_requested;
- }
-
- return newpad;
-
- /* ERRORS */
-wrong_template:
- {
- GST_ERROR_OBJECT (element, "not our template!");
- return NULL;
- }
-already_requested:
- {
- GST_ERROR_OBJECT (element, "only 1 instance of a pad can be requested");
- return NULL;
- }
-}
-
-void
-gst_framed_audio_enc_release_pad (GstFramedAudioEnc * enc, GstPad * pad,
- GstPad ** pad_p, void (disable_cn) (GstElement *))
-{
- GstElement *element = enc->element;
-
- GST_DEBUG_OBJECT (enc->element, "releasing cn pad");
-
- GST_OBJECT_LOCK (element);
- if (pad != *pad_p)
- goto wrong_pad;
- GST_OBJECT_UNLOCK (element);
-
- /* reconfigure encoder */
- disable_cn (element);
-
- if (gst_element_remove_pad (element, pad)) {
- GST_OBJECT_LOCK (element);
- gst_object_replace ((GstObject **) pad_p, NULL);
- GST_OBJECT_UNLOCK (element);
- GST_DEBUG_OBJECT (enc->element, "cn pad released");
- }
-
- /* ERRORS */
-wrong_pad:
- {
- GST_OBJECT_UNLOCK (element);
- GST_ERROR_OBJECT (element, "pad not requested; can not be released!");
- return;
- }
-}
-
-gboolean
-gst_framed_audio_enc_sink_event (GstPad * pad, GstEvent * event)
-{
- GstFramedAudioEnc *enc;
-
- enc = gst_pad_get_element_private (pad);
- g_return_val_if_fail (enc, FALSE);
-
- GST_LOG_OBJECT (enc->element, "received %s", GST_EVENT_TYPE_NAME (event));
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_FLUSH_STOP:
- /* fall-through */
- case GST_EVENT_EOS:
- gst_adapter_clear (enc->adapter);
- enc->next_ts = GST_CLOCK_TIME_NONE;
- break;
- default:
- break;
- }
-
- return gst_pad_event_default (pad, event);
-}
-
-#else
-/* included part */
-
-/* parameters:
- RAW_FRAME_SIZE
- CODEC_FRAME_SIZE
- FRAME_DURATION
- AUDIO_SAMPLE_RATE (optional)
- callback:
- codec_get_data(enc, in, out, dtx)
-
- If one does not mind a few cycles, include'ing can also be replaced by
- a regular include & call, at the expense of some additional parameters
- passed some way or another.
-*/
-
-#ifndef AUDIO_SAMPLE_RATE
-#define AUDIO_SAMPLE_RATE (8000)
-#endif
-
-/* quite some conditional stuff;
- * the (ugly?) cost of trying to stay inner loop optimal */
-
-static GstFlowReturn
-gst_framed_audio_enc_chain (GstFramedAudioEnc * enc, GstBuffer * buf,
- GstPad * srcpad, GstPad ** _cnpad)
-{
- GstFlowReturn ret = GST_FLOW_OK;
- GstBuffer *obuf = NULL;
-#ifdef CN_PAD
- GstBuffer *cnbuf = NULL;
- GstPad *cnpad = NULL;
-#endif
- gboolean discont = FALSE;
- const guint8 *data;
- guint8 *odata;
- gint av, flush, osize;
-
-#ifdef CN_PAD
- GST_OBJECT_LOCK (enc->element);
- if (_cnpad)
- cnpad = *_cnpad;
- if (cnpad)
- gst_object_ref (cnpad);
- GST_OBJECT_UNLOCK (enc->element);
-#endif
-
- if (G_LIKELY (buf)) {
- GST_LOG_OBJECT (enc->element, "input buffer of size %d with ts: %"
- GST_TIME_FORMAT, GST_BUFFER_SIZE (buf),
- GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
- discont = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT);
-
- /* reposition to the new buffer's timestamp,
- * while correcting for some minor left-over */
- if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
- if (GST_CLOCK_TIME_IS_VALID (enc->next_ts)) {
- GstClockTimeDiff diff, limit;
- GstClockTime tleft;
-
- tleft = GST_FRAMES_TO_CLOCK_TIME
- (gst_adapter_available (enc->adapter) / 2, AUDIO_SAMPLE_RATE);
- diff =
- GST_CLOCK_DIFF (enc->next_ts + tleft, GST_BUFFER_TIMESTAMP (buf));
- limit = GST_SECOND / AUDIO_SAMPLE_RATE / 2;
- /* try for a perfect stream if possible, do not act on rounding errors */
- if (diff > limit || diff < -limit) {
- enc->next_ts = GST_BUFFER_TIMESTAMP (buf);
- if (enc->next_ts > tleft)
- enc->next_ts -= tleft;
- GST_LOG_OBJECT (enc->element, "marking discont based on timestamps");
- discont = TRUE;
- }
- } else
- enc->next_ts = GST_BUFFER_TIMESTAMP (buf);
- }
-
- gst_adapter_push (enc->adapter, buf);
- buf = NULL;
- }
-
- av = gst_adapter_available (enc->adapter);
- if (G_UNLIKELY (av < RAW_FRAME_SIZE))
- goto done;
-
- data = gst_adapter_peek (enc->adapter, av);
- obuf = gst_buffer_new_and_alloc (av / RAW_FRAME_SIZE * CODEC_FRAME_SIZE);
- odata = GST_BUFFER_DATA (obuf);
- osize = 0;
- flush = 0;
-
- while (TRUE) {
- gint esize;
-#ifdef CN_PAD
- GstDtxDecision dtx;
-
- /* safe default to start with, should get set */
- dtx = GST_DTX_DECISION_VOICE;
- esize = codec_get_data (enc->element, data + flush, odata, &dtx);
-#else
- esize = codec_get_data (enc->element, data + flush, odata, NULL);
-#endif
-
- if (G_UNLIKELY (esize < 0))
- goto encode_failed;
-
-#ifdef CN_PAD
- /* cn in a separate stream */
- switch (dtx) {
- case GST_DTX_DECISION_VOICE:
-#endif
- flush += RAW_FRAME_SIZE;
- av -= RAW_FRAME_SIZE;
-
- odata += esize;
- osize += esize;
-#ifdef CN_PAD
- break;
- case GST_DTX_DECISION_SID_UPDATE:
- GST_LOG_OBJECT (enc->element, "dtx: SID_UPDATE %d", esize);
- /* if already data before, need to put SID data separately */
- if (G_UNLIKELY (osize)) {
- cnbuf = gst_buffer_new_and_alloc (esize);
- memcpy (GST_BUFFER_DATA (cnbuf), data + osize, esize);
- } else {
- cnbuf = obuf;
- obuf = NULL;
- }
- /* and send one or both */
- goto send;
- break;
- case GST_DTX_DECISION_SID_NONE:
- GST_LOG_OBJECT (enc->element, "dtx: SID_NONE %d", esize);
- /* maybe send preceding voice, if any */
- goto send;
- break;
- }
-#endif
-
-#ifdef CODEC_FRAME_VARIABLE
- /* flush output after insufficient data */
- if (av >= RAW_FRAME_SIZE)
- continue;
-#else
- /* ... or some reduced (e.g. silence) frame */
- if (esize >= CODEC_FRAME_SIZE && av >= RAW_FRAME_SIZE)
- continue;
-#endif
-
-#ifdef CN_PAD
- send:
-#endif
- /* maybe a silent discarded frame */
- if (G_LIKELY (osize)) {
- GST_BUFFER_SIZE (obuf) = osize;
- GST_BUFFER_DURATION (obuf)
- = FRAME_DURATION * (flush / RAW_FRAME_SIZE);
- GST_BUFFER_TIMESTAMP (obuf) = enc->next_ts;
- if (G_UNLIKELY (discont)) {
- GST_BUFFER_FLAG_SET (obuf, GST_BUFFER_FLAG_DISCONT);
- discont = FALSE;
- }
-
- GST_LOG_OBJECT (enc->element,
- "pushing buffer of size %d with ts: %" GST_TIME_FORMAT,
- GST_BUFFER_SIZE (obuf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (obuf)));
- gst_buffer_set_caps (obuf, GST_PAD_CAPS (srcpad));
- ret = gst_pad_push (srcpad, obuf);
- obuf = NULL;
- } else {
- ret = GST_FLOW_OK;
- }
-
-#ifdef CN_PAD
- /* check for stuff to send on cn pad */
- if (cnbuf && cnpad) {
- /* only at most 1 SID update per buffer */
- GST_BUFFER_SIZE (cnbuf) = esize;
- GST_BUFFER_DURATION (cnbuf) = FRAME_DURATION;
- GST_BUFFER_TIMESTAMP (cnbuf) = enc->next_ts;
-
- GST_LOG_OBJECT (enc->element,
- "pushing cn buffer of size %d with ts: %" GST_TIME_FORMAT,
- GST_BUFFER_SIZE (cnbuf),
- GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (cnbuf)));
- gst_buffer_set_caps (cnbuf, GST_PAD_CAPS (cnpad));
- if (G_LIKELY (ret == GST_FLOW_OK)) {
- ret = gst_pad_push (cnpad, cnbuf);
- /* cn pad may not be linked */
- if (G_UNLIKELY (ret == GST_FLOW_NOT_LINKED))
- ret = GST_FLOW_OK;
- } else
- gst_pad_push (cnpad, cnbuf);
- cnbuf = NULL;
- } else if (G_UNLIKELY (cnbuf)) {
- /* should not occur */
- gst_buffer_unref (cnbuf);
- cnbuf = NULL;
- }
-
- if (dtx != GST_DTX_DECISION_VOICE) {
- /* still need to count non-voice encoded frame */
- flush += RAW_FRAME_SIZE;
- av -= RAW_FRAME_SIZE;
- }
-#endif /* CN_PAD */
-
- /* remove used part */
- gst_adapter_flush (enc->adapter, flush);
- if (GST_CLOCK_TIME_IS_VALID (enc->next_ts))
- enc->next_ts += FRAME_DURATION * (flush / RAW_FRAME_SIZE);
-
- /* end if insufficient left or error */
- if (av < RAW_FRAME_SIZE || ret != GST_FLOW_OK)
- break;
-
- /* allocate new buffer */
- if (!obuf) {
- obuf = gst_buffer_new_and_alloc (av / RAW_FRAME_SIZE * CODEC_FRAME_SIZE);
- odata = GST_BUFFER_DATA (obuf);
- osize = 0;
- }
- /* and prepare to consume again */
- data = gst_adapter_peek (enc->adapter, av);
- flush = 0;
- }
-
- if (!av) {
- enc->next_ts = GST_CLOCK_TIME_NONE;
- }
-
-done:
-#ifdef CN_PAD
- GST_OBJECT_LOCK (enc->element);
- if (cnpad)
- gst_object_unref (cnpad);
- GST_OBJECT_UNLOCK (enc->element);
-#endif
-
- return ret;
-
- /* ERRORS */
-encode_failed:
- {
- GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL), (NULL));
- ret = GST_FLOW_ERROR;
- gst_buffer_unref (obuf);
- goto done;
- }
-}
-#endif
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_nokia_speech/gstframedaudioenc.h
--- a/gst_nokia_speech/gstframedaudioenc.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/* GStreamer Framed Audio Encoder
- * Copyright 2009 Collabora Ltd,
- * Copyright 2009 Nokia Corporation
- * @author: Mark Nauwelaerts .
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_FRAMED_AUDIO_ENC_H__
-#define __GST_FRAMED_AUDIO_ENC_H__
-
-#include
-#include
-
-G_BEGIN_DECLS
-
-typedef struct _GstNokiaFramedAudioEnc GstNokiaFramedAudioEnc;
-typedef struct _GstNokiaFramedAudioEncClass GstNokiaFramedAudioEncClass;
-
-typedef GstNokiaFramedAudioEnc GstFramedAudioEnc;
-typedef GstNokiaFramedAudioEncClass GstFramedAudioEncClass;
-
-struct _GstNokiaFramedAudioEnc
-{
- /* helper for this element */
- GstElement *element;
-
- /* private stuff */
-
- /* pad with incoming data */
- GstPad *sinkpad;
-
- GstAdapter *adapter;
- GstClockTime next_ts;
-};
-
-typedef enum _GstDtxDecision {
- GST_DTX_DECISION_VOICE,
- GST_DTX_DECISION_SID_UPDATE,
- GST_DTX_DECISION_SID_NONE
-} GstDtxDecision;
-
-void gst_framed_audio_enc_init (GstFramedAudioEnc * enc, GstElement * element,
- GstDebugCategory * cat);
-void gst_framed_audio_enc_reset (GstFramedAudioEnc * enc);
-void gst_framed_audio_enc_finalize (GstFramedAudioEnc * enc);
-GstPad * gst_framed_audio_enc_request_new_pad (GstFramedAudioEnc * enc,
- GstPadTemplate * templ, const gchar * req_name, GstPad ** pad_p);
-void gst_framed_audio_enc_release_pad (GstFramedAudioEnc * enc, GstPad * pad,
- GstPad ** pad_p, void (disable_cn) (GstElement *));
-gboolean gst_framed_audio_enc_sink_event (GstPad * pad, GstEvent * event);
-
-G_END_DECLS
-
-#endif /* __GST_FRAMED_AUDIO_ENC_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsa.c
--- a/gst_plugins_base/ext/alsa/gstalsa.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,556 +0,0 @@
-/* Copyright (C) 2006 Tim-Philipp Müller
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "gstalsa.h"
-
-#include
-
-static GstCaps *
-gst_alsa_detect_rates (GstObject * obj, snd_pcm_hw_params_t * hw_params,
- GstCaps * in_caps)
-{
- GstCaps *caps;
- guint min, max;
- gint err, dir, min_rate, max_rate, i;
-
- GST_LOG_OBJECT (obj, "probing sample rates ...");
-
- if ((err = snd_pcm_hw_params_get_rate_min (hw_params, &min, &dir)) < 0)
- goto min_rate_err;
-
- if ((err = snd_pcm_hw_params_get_rate_max (hw_params, &max, &dir)) < 0)
- goto max_rate_err;
-
- min_rate = min;
- max_rate = max;
-
- if (min_rate < 4000)
- min_rate = 4000; /* random 'sensible minimum' */
-
- if (max_rate <= 0)
- max_rate = G_MAXINT; /* or maybe just use 192400 or so? */
- else if (max_rate > 0 && max_rate < 4000)
- max_rate = MAX (4000, min_rate);
-
- GST_DEBUG_OBJECT (obj, "Min. rate = %u (%d)", min_rate, min);
- GST_DEBUG_OBJECT (obj, "Max. rate = %u (%d)", max_rate, max);
-
- caps = gst_caps_make_writable (in_caps);
-
- for (i = 0; i < gst_caps_get_size (caps); ++i) {
- GstStructure *s;
-
- s = gst_caps_get_structure (caps, i);
- if (min_rate == max_rate) {
- gst_structure_set (s, "rate", G_TYPE_INT, min_rate, NULL);
- } else {
- gst_structure_set (s, "rate", GST_TYPE_INT_RANGE,
- min_rate, max_rate, NULL);
- }
- }
-
- return caps;
-
- /* ERRORS */
-min_rate_err:
- {
- GST_ERROR_OBJECT (obj, "failed to query minimum sample rate: %s",
- snd_strerror (err));
- gst_caps_unref (in_caps);
- return NULL;
- }
-max_rate_err:
- {
- GST_ERROR_OBJECT (obj, "failed to query maximum sample rate: %s",
- snd_strerror (err));
- gst_caps_unref (in_caps);
- return NULL;
- }
-}
-
-static const struct
-{
- const int width;
- const int depth;
- const int sformat;
- const int uformat;
-} pcmformats[] = {
- {
- 8, 8, SND_PCM_FORMAT_S8, SND_PCM_FORMAT_U8}, {
- 16, 16, SND_PCM_FORMAT_S16, SND_PCM_FORMAT_U16}, {
- 32, 24, SND_PCM_FORMAT_S24, SND_PCM_FORMAT_U24}, {
-#if (G_BYTE_ORDER == G_LITTLE_ENDIAN) /* no endian-unspecific enum available */
- 24, 24, SND_PCM_FORMAT_S24_3LE, SND_PCM_FORMAT_U24_3LE}, {
-#else
- 24, 24, SND_PCM_FORMAT_S24_3BE, SND_PCM_FORMAT_U24_3BE}, {
-#endif
- 32, 32, SND_PCM_FORMAT_S32, SND_PCM_FORMAT_U32}
-};
-
-static GstCaps *
-gst_alsa_detect_formats (GstObject * obj, snd_pcm_hw_params_t * hw_params,
- GstCaps * in_caps)
-{
- snd_pcm_format_mask_t *mask;
- GstStructure *s;
- GstCaps *caps;
- gint i;
-
- snd_pcm_format_mask_malloc (&mask);
- snd_pcm_hw_params_get_format_mask (hw_params, mask);
-
- caps = gst_caps_new_empty ();
-
- for (i = 0; i < gst_caps_get_size (in_caps); ++i) {
- GstStructure *scopy;
- gint w, width = 0, depth = 0;
-
- s = gst_caps_get_structure (in_caps, i);
- if (!gst_structure_has_name (s, "audio/x-raw-int")) {
- GST_WARNING_OBJECT (obj, "skipping non-int format");
- continue;
- }
- if (!gst_structure_get_int (s, "width", &width) ||
- !gst_structure_get_int (s, "depth", &depth))
- continue;
- if (width == 0 || (width % 8) != 0)
- continue; /* Only full byte widths are valid */
- for (w = 0; w < G_N_ELEMENTS (pcmformats); w++)
- if (pcmformats[w].width == width && pcmformats[w].depth == depth)
- break;
- if (w == G_N_ELEMENTS (pcmformats))
- continue; /* Unknown format */
-
- if (snd_pcm_format_mask_test (mask, pcmformats[w].sformat) &&
- snd_pcm_format_mask_test (mask, pcmformats[w].uformat)) {
- /* template contains { true, false } or just one, leave it as it is */
- scopy = gst_structure_copy (s);
- } else if (snd_pcm_format_mask_test (mask, pcmformats[w].sformat)) {
- scopy = gst_structure_copy (s);
- gst_structure_set (scopy, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
- } else if (snd_pcm_format_mask_test (mask, pcmformats[w].uformat)) {
- scopy = gst_structure_copy (s);
- gst_structure_set (scopy, "signed", G_TYPE_BOOLEAN, FALSE, NULL);
- } else {
- scopy = NULL;
- }
- if (scopy) {
- if (width > 8) {
- /* TODO: proper endianness detection, for now it's CPU endianness only */
- gst_structure_set (scopy, "endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
- }
- gst_caps_append_structure (caps, scopy);
- }
- }
-
- snd_pcm_format_mask_free (mask);
- gst_caps_unref (in_caps);
- return caps;
-}
-
-/* we don't have channel mappings for more than this many channels */
-#define GST_ALSA_MAX_CHANNELS 8
-
-static GstStructure *
-get_channel_free_structure (const GstStructure * in_structure)
-{
- GstStructure *s = gst_structure_copy (in_structure);
-
- gst_structure_remove_field (s, "channels");
- return s;
-}
-
-static void
-caps_add_channel_configuration (GstCaps * caps,
- const GstStructure * in_structure, gint min_chans, gint max_chans)
-{
- GstAudioChannelPosition pos[8] = {
- GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
- GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
- GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
- GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
- GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
- GST_AUDIO_CHANNEL_POSITION_LFE,
- GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
- GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT
- };
- GstStructure *s = NULL;
- gint c;
-
- if (min_chans == max_chans && max_chans <= 2) {
- s = get_channel_free_structure (in_structure);
- gst_structure_set (s, "channels", G_TYPE_INT, max_chans, NULL);
- gst_caps_append_structure (caps, s);
- return;
- }
-
- g_assert (min_chans >= 1);
-
- /* mono and stereo don't need channel configurations */
- if (min_chans == 2) {
- s = get_channel_free_structure (in_structure);
- gst_structure_set (s, "channels", G_TYPE_INT, 2, NULL);
- gst_caps_append_structure (caps, s);
- } else if (min_chans == 1 && max_chans >= 2) {
- s = get_channel_free_structure (in_structure);
- gst_structure_set (s, "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
- gst_caps_append_structure (caps, s);
- }
-
- /* don't know whether to use 2.1 or 3.0 here - but I suspect
- * alsa might work around that/fix it somehow. Can we tell alsa
- * what our channel layout is like? */
- if (max_chans >= 3 && min_chans <= 3) {
- GstAudioChannelPosition pos_21[3] = {
- GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
- GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
- GST_AUDIO_CHANNEL_POSITION_LFE
- };
-
- s = get_channel_free_structure (in_structure);
- gst_structure_set (s, "channels", G_TYPE_INT, 3, NULL);
- gst_audio_set_channel_positions (s, pos_21);
- gst_caps_append_structure (caps, s);
- }
-
- /* everything else (4, 6, 8 channels) needs a channel layout */
- for (c = MAX (4, min_chans); c <= 8; c += 2) {
- if (max_chans >= c) {
- s = get_channel_free_structure (in_structure);
- gst_structure_set (s, "channels", G_TYPE_INT, c, NULL);
- gst_audio_set_channel_positions (s, pos);
- gst_caps_append_structure (caps, s);
- }
- }
-
- for (c = MAX (9, min_chans); c <= max_chans; ++c) {
- GstAudioChannelPosition *ch_layout;
- guint i;
-
- ch_layout = g_new (GstAudioChannelPosition, c);
- for (i = 0; i < c; ++i) {
- ch_layout[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
- }
- s = get_channel_free_structure (in_structure);
- gst_structure_set (s, "channels", G_TYPE_INT, c, NULL);
- gst_audio_set_channel_positions (s, ch_layout);
- gst_caps_append_structure (caps, s);
- g_free (ch_layout);
- }
-}
-
-static GstCaps *
-gst_alsa_detect_channels (GstObject * obj, snd_pcm_hw_params_t * hw_params,
- GstCaps * in_caps)
-{
- GstCaps *caps;
- guint min, max;
- gint min_chans, max_chans;
- gint err, i;
-
- GST_LOG_OBJECT (obj, "probing channels ...");
-
- if ((err = snd_pcm_hw_params_get_channels_min (hw_params, &min)) < 0)
- goto min_chan_error;
-
- if ((err = snd_pcm_hw_params_get_channels_max (hw_params, &max)) < 0)
- goto max_chan_error;
-
- /* note: the above functions may return (guint) -1 */
- min_chans = min;
- max_chans = max;
-
- if (min_chans < 0) {
- min_chans = 1;
- max_chans = GST_ALSA_MAX_CHANNELS;
- } else if (max_chans < 0) {
- max_chans = GST_ALSA_MAX_CHANNELS;
- }
-
- if (min_chans > max_chans) {
- gint temp;
-
- GST_WARNING_OBJECT (obj, "minimum channels > maximum channels (%d > %d), "
- "please fix your soundcard drivers", min, max);
- temp = min_chans;
- min_chans = max_chans;
- max_chans = temp;
- }
-
- /* pro cards seem to return large numbers for min_channels */
- if (min_chans > GST_ALSA_MAX_CHANNELS) {
- GST_DEBUG_OBJECT (obj, "min_chans = %u, looks like a pro card", min_chans);
- if (max_chans < min_chans) {
- max_chans = min_chans;
- } else {
- /* only support [max_chans; max_chans] for these cards for now
- * to avoid inflating the source caps with loads of structures ... */
- min_chans = max_chans;
- }
- } else {
- min_chans = MAX (min_chans, 1);
- max_chans = MIN (GST_ALSA_MAX_CHANNELS, max_chans);
- }
-
- GST_DEBUG_OBJECT (obj, "Min. channels = %d (%d)", min_chans, min);
- GST_DEBUG_OBJECT (obj, "Max. channels = %d (%d)", max_chans, max);
-
- caps = gst_caps_new_empty ();
-
- for (i = 0; i < gst_caps_get_size (in_caps); ++i) {
- GstStructure *s;
- GType field_type;
- gint c_min = min_chans;
- gint c_max = max_chans;
-
- s = gst_caps_get_structure (in_caps, i);
- /* the template caps might limit the number of channels (like alsasrc),
- * in which case we don't want to return a superset, so hack around this
- * for the two common cases where the channels are either a fixed number
- * or a min/max range). Example: alsasrc template has channels = [1,2] and
- * the detection will claim to support 8 channels for device 'plughw:0' */
- field_type = gst_structure_get_field_type (s, "channels");
- if (field_type == G_TYPE_INT) {
- gst_structure_get_int (s, "channels", &c_min);
- gst_structure_get_int (s, "channels", &c_max);
- } else if (field_type == GST_TYPE_INT_RANGE) {
- const GValue *val;
-
- val = gst_structure_get_value (s, "channels");
- c_min = CLAMP (gst_value_get_int_range_min (val), min_chans, max_chans);
- c_max = CLAMP (gst_value_get_int_range_max (val), min_chans, max_chans);
- } else {
- c_min = min_chans;
- c_max = max_chans;
- }
-
- caps_add_channel_configuration (caps, s, c_min, c_max);
- }
-
- gst_caps_unref (in_caps);
-
- return caps;
-
- /* ERRORS */
-min_chan_error:
- {
- GST_ERROR_OBJECT (obj, "failed to query minimum channel count: %s",
- snd_strerror (err));
- return NULL;
- }
-max_chan_error:
- {
- GST_ERROR_OBJECT (obj, "failed to query maximum channel count: %s",
- snd_strerror (err));
- return NULL;
- }
-}
-
-snd_pcm_t *
-gst_alsa_open_iec958_pcm (GstObject * obj)
-{
- char *iec958_pcm_name = NULL;
- snd_pcm_t *pcm = NULL;
- int res;
- char devstr[256]; /* Storage for local 'default' device string */
-
- /*
- * Try and open our default iec958 device. Fall back to searching on card x
- * if this fails, which should only happen on older alsa setups
- */
-
- /* The string will be one of these:
- * SPDIF_CON: Non-audio flag not set:
- * spdif:{AES0 0x0 AES1 0x82 AES2 0x0 AES3 0x2}
- * SPDIF_CON: Non-audio flag set:
- * spdif:{AES0 0x2 AES1 0x82 AES2 0x0 AES3 0x2}
- */
- sprintf (devstr,
- "iec958:{AES0 0x%02x AES1 0x%02x AES2 0x%02x AES3 0x%02x}",
- IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO,
- IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER,
- 0, IEC958_AES3_CON_FS_48000);
-
- GST_DEBUG_OBJECT (obj, "Generated device string \"%s\"", devstr);
- iec958_pcm_name = devstr;
-
- res = snd_pcm_open (&pcm, iec958_pcm_name, SND_PCM_STREAM_PLAYBACK, 0);
- if (G_UNLIKELY (res < 0)) {
- GST_DEBUG_OBJECT (obj, "failed opening IEC958 device: %s",
- snd_strerror (res));
- pcm = NULL;
- }
-
- return pcm;
-}
-
-
-/*
- * gst_alsa_probe_supported_formats:
- *
- * Takes the template caps and returns the subset which is actually
- * supported by this device.
- *
- */
-
-GstCaps *
-gst_alsa_probe_supported_formats (GstObject * obj, snd_pcm_t * handle,
- const GstCaps * template_caps)
-{
- snd_pcm_hw_params_t *hw_params;
- snd_pcm_stream_t stream_type;
- GstCaps *caps;
- gint err;
-
- snd_pcm_hw_params_malloc (&hw_params);
- if ((err = snd_pcm_hw_params_any (handle, hw_params)) < 0)
- goto error;
-
- stream_type = snd_pcm_stream (handle);
-
- caps = gst_caps_copy (template_caps);
-
- if (!(caps = gst_alsa_detect_formats (obj, hw_params, caps)))
- goto subroutine_error;
-
- if (!(caps = gst_alsa_detect_rates (obj, hw_params, caps)))
- goto subroutine_error;
-
- if (!(caps = gst_alsa_detect_channels (obj, hw_params, caps)))
- goto subroutine_error;
-
- /* Try opening IEC958 device to see if we can support that format (playback
- * only for now but we could add SPDIF capture later) */
- if (stream_type == SND_PCM_STREAM_PLAYBACK) {
- snd_pcm_t *pcm = gst_alsa_open_iec958_pcm (obj);
-
- if (G_LIKELY (pcm)) {
- gst_caps_append (caps, gst_caps_new_simple ("audio/x-iec958", NULL));
- snd_pcm_close (pcm);
- }
- }
-
- snd_pcm_hw_params_free (hw_params);
- return caps;
-
- /* ERRORS */
-error:
- {
- GST_ERROR_OBJECT (obj, "failed to query formats: %s", snd_strerror (err));
- snd_pcm_hw_params_free (hw_params);
- return NULL;
- }
-subroutine_error:
- {
- GST_ERROR_OBJECT (obj, "failed to query formats");
- snd_pcm_hw_params_free (hw_params);
- return NULL;
- }
-}
-
-static gchar *
-gst_alsa_find_device_name_no_handle (GstObject * obj, const gchar * devcard,
- gint device_num, snd_pcm_stream_t stream)
-{
- snd_ctl_card_info_t *info = NULL;
- snd_ctl_t *ctl = NULL;
- gchar *ret = NULL;
- gint dev = -1;
-
- GST_LOG_OBJECT (obj, "[%s] device=%d", devcard, device_num);
-
- if (snd_ctl_open (&ctl, devcard, 0) < 0)
- return NULL;
-
- snd_ctl_card_info_malloc (&info);
- if (snd_ctl_card_info (ctl, info) < 0)
- goto done;
-
- while (snd_ctl_pcm_next_device (ctl, &dev) == 0 && dev >= 0) {
- if (dev == device_num) {
- snd_pcm_info_t *pcminfo;
-
- snd_pcm_info_malloc (&pcminfo);
- snd_pcm_info_set_device (pcminfo, dev);
- snd_pcm_info_set_subdevice (pcminfo, 0);
- snd_pcm_info_set_stream (pcminfo, stream);
- if (snd_ctl_pcm_info (ctl, pcminfo) < 0) {
- snd_pcm_info_free (pcminfo);
- break;
- }
-
- ret = g_strdup (snd_pcm_info_get_name (pcminfo));
- snd_pcm_info_free (pcminfo);
- GST_LOG_OBJECT (obj, "name from pcminfo: %s", GST_STR_NULL (ret));
- }
- }
-
- if (ret == NULL) {
- char *name = NULL;
- gint card;
-
- GST_LOG_OBJECT (obj, "no luck so far, trying backup");
- card = snd_ctl_card_info_get_card (info);
- snd_card_get_name (card, &name);
- ret = g_strdup (name);
- free (name);
- }
-
-done:
- snd_ctl_card_info_free (info);
- snd_ctl_close (ctl);
-
- return ret;
-}
-
-gchar *
-gst_alsa_find_device_name (GstObject * obj, const gchar * device,
- snd_pcm_t * handle, snd_pcm_stream_t stream)
-{
- gchar *ret = NULL;
-
- if (device != NULL) {
- gchar *dev, *comma;
- gint devnum;
-
- GST_LOG_OBJECT (obj, "Trying to get device name from string '%s'", device);
-
- /* only want name:card bit, but not devices and subdevices */
- dev = g_strdup (device);
- if ((comma = strchr (dev, ','))) {
- *comma = '\0';
- devnum = atoi (comma + 1);
- ret = gst_alsa_find_device_name_no_handle (obj, dev, devnum, stream);
- }
- g_free (dev);
- }
-
- if (ret == NULL && handle != NULL) {
- snd_pcm_info_t *info;
-
- GST_LOG_OBJECT (obj, "Trying to get device name from open handle");
- snd_pcm_info_malloc (&info);
- snd_pcm_info (handle, info);
- ret = g_strdup (snd_pcm_info_get_name (info));
- snd_pcm_info_free (info);
- }
-
- GST_LOG_OBJECT (obj, "Device name for device '%s': %s",
- GST_STR_NULL (device), GST_STR_NULL (ret));
-
- return ret;
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsa.h
--- a/gst_plugins_base/ext/alsa/gstalsa.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2001 CodeFactory AB
- * Copyright (C) 2001 Thomas Nyberg
- * Copyright (C) 2001-2002 Andy Wingo
- * Copyright (C) 2003 Benjamin Otte
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-
-#ifndef __GST_ALSA_H__
-#define __GST_ALSA_H__
-
-
-#define ALSA_PCM_NEW_HW_PARAMS_API
-#define ALSA_PCM_NEW_SW_PARAMS_API
-
-#include
-#include
-#include
-#include
-
-#define GST_CHECK_ALSA_VERSION(major,minor,micro) \
- (SND_LIB_MAJOR > (major) || \
- (SND_LIB_MAJOR == (major) && SND_LIB_MINOR > (minor)) || \
- (SND_LIB_MAJOR == (major) && SND_LIB_MINOR == (minor) && \
- SND_LIB_SUBMINOR >= (micro)))
-
-GST_DEBUG_CATEGORY_EXTERN (alsa_debug);
-#define GST_CAT_DEFAULT alsa_debug
-
-snd_pcm_t * gst_alsa_open_iec958_pcm (GstObject * obj);
-
-GstCaps * gst_alsa_probe_supported_formats (GstObject * obj,
- snd_pcm_t * handle,
- const GstCaps * template_caps);
-
-gchar * gst_alsa_find_device_name (GstObject * obj,
- const gchar * device,
- snd_pcm_t * handle,
- snd_pcm_stream_t stream);
-
-#endif /* __GST_ALSA_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsadeviceprobe.c
--- a/gst_plugins_base/ext/alsa/gstalsadeviceprobe.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,208 +0,0 @@
-/* Copyright (C) 2001 CodeFactory AB
- * Copyright (C) 2001 Thomas Nyberg
- * Copyright (C) 2001-2002 Andy Wingo
- * Copyright (C) 2003 Benjamin Otte
- * Copyright (C) 2005 Tim-Philipp Müller
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstalsadeviceprobe.h"
-#include "gst/interfaces/propertyprobe.h"
-
-static const GList *
-gst_alsa_device_property_probe_get_properties (GstPropertyProbe * probe)
-{
- GObjectClass *klass = G_OBJECT_GET_CLASS (probe);
- static GList *list = NULL;
-
- /* well, not perfect, but better than no locking at all.
- * In the worst case we leak a list node, so who cares? */
- GST_CLASS_LOCK (GST_OBJECT_CLASS (klass));
-
- if (!list) {
- GParamSpec *pspec;
-
- pspec = g_object_class_find_property (klass, "device");
- list = g_list_append (NULL, pspec);
- }
-
- GST_CLASS_UNLOCK (GST_OBJECT_CLASS (klass));
-
- return list;
-}
-
-static GList *
-gst_alsa_get_device_list (snd_pcm_stream_t stream)
-{
- snd_ctl_t *handle;
- int card, err, dev;
- snd_ctl_card_info_t *info;
- snd_pcm_info_t *pcminfo;
- gboolean mixer = (stream == -1);
- GList *list = NULL;
-
- if (stream == -1)
- stream = 0;
-
- snd_ctl_card_info_malloc (&info);
- snd_pcm_info_malloc (&pcminfo);
- card = -1;
-
- if (snd_card_next (&card) < 0 || card < 0) {
- /* no soundcard found */
- return NULL;
- }
-
- while (card >= 0) {
- gchar name[32];
-
- g_snprintf (name, sizeof (name), "hw:%d", card);
- if ((err = snd_ctl_open (&handle, name, 0)) < 0) {
- goto next_card;
- }
- if ((err = snd_ctl_card_info (handle, info)) < 0) {
- snd_ctl_close (handle);
- goto next_card;
- }
-
- if (mixer) {
- list = g_list_append (list, g_strdup (name));
- } else {
- dev = -1;
- while (1) {
- gchar *gst_device;
-
- snd_ctl_pcm_next_device (handle, &dev);
-
- if (dev < 0)
- break;
- snd_pcm_info_set_device (pcminfo, dev);
- snd_pcm_info_set_subdevice (pcminfo, 0);
- snd_pcm_info_set_stream (pcminfo, stream);
- if ((err = snd_ctl_pcm_info (handle, pcminfo)) < 0) {
- continue;
- }
-
- gst_device = g_strdup_printf ("hw:%d,%d", card, dev);
- list = g_list_append (list, gst_device);
- }
- }
- snd_ctl_close (handle);
- next_card:
- if (snd_card_next (&card) < 0) {
- break;
- }
- }
-
- snd_ctl_card_info_free (info);
- snd_pcm_info_free (pcminfo);
-
- return list;
-}
-
-static void
-gst_alsa_device_property_probe_probe_property (GstPropertyProbe * probe,
- guint prop_id, const GParamSpec * pspec)
-{
- if (!g_str_equal (pspec->name, "device")) {
- G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
- }
-}
-
-static gboolean
-gst_alsa_device_property_probe_needs_probe (GstPropertyProbe * probe,
- guint prop_id, const GParamSpec * pspec)
-{
- /* don't cache probed data */
- return TRUE;
-}
-
-static GValueArray *
-gst_alsa_device_property_probe_get_values (GstPropertyProbe * probe,
- guint prop_id, const GParamSpec * pspec)
-{
- GstElementClass *klass;
- const GList *templates;
- snd_pcm_stream_t mode = -1;
- GValueArray *array;
- GValue value = { 0, };
- GList *l, *list;
-
- if (!g_str_equal (pspec->name, "device")) {
- G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
- return NULL;
- }
-
- klass = GST_ELEMENT_GET_CLASS (GST_ELEMENT (probe));
-
- /* I'm pretty sure ALSA has a good way to do this. However, their cool
- * auto-generated documentation is pretty much useless if you try to
- * do function-wise look-ups. */
- /* we assume one pad template at max [zero=mixer] */
- templates = gst_element_class_get_pad_template_list (klass);
- if (templates) {
- if (GST_PAD_TEMPLATE_DIRECTION (templates->data) == GST_PAD_SRC)
- mode = SND_PCM_STREAM_CAPTURE;
- else
- mode = SND_PCM_STREAM_PLAYBACK;
- }
-
- list = gst_alsa_get_device_list (mode);
-
- if (list == NULL) {
- GST_LOG_OBJECT (probe, "No devices found");
- return NULL;
- }
-
- array = g_value_array_new (g_list_length (list));
- g_value_init (&value, G_TYPE_STRING);
- for (l = list; l != NULL; l = l->next) {
- GST_LOG_OBJECT (probe, "Found device: %s", (gchar *) l->data);
- g_value_take_string (&value, (gchar *) l->data);
- l->data = NULL;
- g_value_array_append (array, &value);
- }
- g_value_unset (&value);
- g_list_free (list);
-
- return array;
-}
-
-static void
-gst_alsa_property_probe_interface_init (GstPropertyProbeInterface * iface)
-{
- iface->get_properties = gst_alsa_device_property_probe_get_properties;
- iface->probe_property = gst_alsa_device_property_probe_probe_property;
- iface->needs_probe = gst_alsa_device_property_probe_needs_probe;
- iface->get_values = gst_alsa_device_property_probe_get_values;
-}
-
-void
-gst_alsa_type_add_device_property_probe_interface (GType type)
-{
- static const GInterfaceInfo probe_iface_info = {
- (GInterfaceInitFunc) gst_alsa_property_probe_interface_init,
- NULL,
- NULL,
- };
-
- g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE,
- &probe_iface_info);
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsadeviceprobe.h
--- a/gst_plugins_base/ext/alsa/gstalsadeviceprobe.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/* Copyright (C) 2001 CodeFactory AB
- * Copyright (C) 2001 Thomas Nyberg
- * Copyright (C) 2001-2002 Andy Wingo
- * Copyright (C) 2003 Benjamin Otte
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __GST_ALSA_DEVICE_PROBE_H__
-#define __GST_ALSA_DEVICE_PROBE_H__
-
-#include "gstalsa.h"
-
-G_BEGIN_DECLS
-
-void gst_alsa_type_add_device_property_probe_interface (GType type);
-
-G_END_DECLS
-
-#endif /* __GST_ALSA_DEVICE_PROBE_H__ */
-
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsamixer.c
--- a/gst_plugins_base/ext/alsa/gstalsamixer.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,887 +0,0 @@
-/* ALSA mixer implementation.
- * Copyright (C) 2003 Leif Johnson
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:element-alsamixer
- * @short_description: control properties of an audio device
- * @see_also: alsasink, alsasrc
- *
- *
- *
- * This element controls various aspects such as the volume and balance
- * of an audio device using the ALSA api.
- *
- *
- * The application should query and use the interfaces provided by this
- * element to control the device.
- *
- *
- *
- * Last reviewed on 2006-03-01 (0.10.4)
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstalsamixer.h"
-
-static void gst_alsa_mixer_update_option (GstAlsaMixer * mixer,
- GstAlsaMixerOptions * alsa_opts);
-static void gst_alsa_mixer_update_track (GstAlsaMixer * mixer,
- GstAlsaMixerTrack * alsa_track);
-static int gst_alsa_mixer_handle_callback (snd_mixer_t * handle,
- unsigned int mask, snd_mixer_elem_t * elem);
-
-/* First some utils, then the mixer implementation */
-static gboolean
-gst_alsa_mixer_open (GstAlsaMixer * mixer)
-{
- gint err;
- snd_ctl_t *ctl;
- snd_ctl_card_info_t *card_info;
-
- g_return_val_if_fail (mixer->handle == NULL, FALSE);
-
- /* open and initialize the mixer device */
- err = snd_mixer_open (&mixer->handle, 0);
- if (err < 0 || mixer->handle == NULL)
- goto open_failed;
-
- if ((err = snd_mixer_attach (mixer->handle, mixer->device)) < 0) {
- GST_WARNING ("Cannot open mixer for sound device '%s': %s", mixer->device,
- snd_strerror (err));
- goto error;
- }
-
- if ((err = snd_mixer_selem_register (mixer->handle, NULL, NULL)) < 0) {
- GST_WARNING ("Cannot register mixer elements: %s", snd_strerror (err));
- goto error;
- }
-
- if ((err = snd_mixer_load (mixer->handle)) < 0) {
- GST_WARNING ("Cannot load mixer settings: %s", snd_strerror (err));
- goto error;
- }
-
- snd_mixer_set_callback_private (mixer->handle, mixer);
- snd_mixer_set_callback (mixer->handle, gst_alsa_mixer_handle_callback);
-
- /* now get the device name, any of this is not fatal */
- g_free (mixer->cardname);
- if ((err = snd_ctl_open (&ctl, mixer->device, 0)) < 0) {
- GST_WARNING ("Cannot open CTL: %s", snd_strerror (err));
- goto no_card_name;
- }
-
- snd_ctl_card_info_malloc (&card_info);
- if ((err = snd_ctl_card_info (ctl, card_info)) < 0) {
- GST_WARNING ("Cannot get card info: %s", snd_strerror (err));
- snd_ctl_close (ctl);
- goto no_card_name;
- }
-
- mixer->cardname = g_strdup (snd_ctl_card_info_get_name (card_info));
- GST_DEBUG ("Card name = %s", GST_STR_NULL (mixer->cardname));
- snd_ctl_card_info_free (card_info);
- snd_ctl_close (ctl);
-
-no_card_name:
- if (mixer->cardname == NULL) {
- mixer->cardname = g_strdup ("Unknown");
- GST_DEBUG ("Cannot find card name");
- }
-
- GST_INFO ("Successfully opened mixer for device '%s'.", mixer->device);
-
- return TRUE;
-
- /* ERROR */
-open_failed:
- {
- GST_WARNING ("Cannot open mixer: %s", snd_strerror (err));
- mixer->handle = NULL;
- return FALSE;
- }
-error:
- {
- snd_mixer_close (mixer->handle);
- mixer->handle = NULL;
- return FALSE;
- }
-}
-
-static snd_mixer_elem_t *
-gst_alsa_mixer_find_master_mixer (GstAlsaMixer * mixer, snd_mixer_t * handle)
-{
- snd_mixer_elem_t *element;
- gint i, count;
-
- count = snd_mixer_get_count (handle);
-
- /* Check if we have a playback mixer labelled as 'Master' */
- element = snd_mixer_first_elem (handle);
- for (i = 0; i < count; i++) {
- if (snd_mixer_selem_has_playback_volume (element) &&
- strcmp (snd_mixer_selem_get_name (element), "Master") == 0) {
- return element;
- }
- element = snd_mixer_elem_next (element);
- }
-
- /* If not, check if we have a playback mixer labelled as 'Front' */
- element = snd_mixer_first_elem (handle);
- for (i = 0; i < count; i++) {
- if (snd_mixer_selem_has_playback_volume (element) &&
- strcmp (snd_mixer_selem_get_name (element), "Front") == 0) {
- return element;
- }
- element = snd_mixer_elem_next (element);
- }
-
- /* If not, check if we have a playback mixer labelled as 'PCM' */
- element = snd_mixer_first_elem (handle);
- for (i = 0; i < count; i++) {
- if (snd_mixer_selem_has_playback_volume (element) &&
- strcmp (snd_mixer_selem_get_name (element), "PCM") == 0) {
- return element;
- }
- element = snd_mixer_elem_next (element);
- }
-
- /* If not, check if we have a playback mixer with both volume and switch */
- element = snd_mixer_first_elem (handle);
- for (i = 0; i < count; i++) {
- if (snd_mixer_selem_has_playback_volume (element) &&
- snd_mixer_selem_has_playback_switch (element)) {
- return element;
- }
- element = snd_mixer_elem_next (element);
- }
-
- /* If not, take any playback mixer with a volume control */
- element = snd_mixer_first_elem (handle);
- for (i = 0; i < count; i++) {
- if (snd_mixer_selem_has_playback_volume (element)) {
- return element;
- }
- element = snd_mixer_elem_next (element);
- }
-
- /* Looks like we're out of luck ... */
- return NULL;
-}
-
-static void
-gst_alsa_mixer_update (GstAlsaMixer * mixer, snd_mixer_elem_t * elem)
-{
- GList *item;
-
- g_return_if_fail (mixer != NULL);
-
- g_static_rec_mutex_lock (mixer->rec_mutex);
-
- for (item = mixer->tracklist; item != NULL; item = item->next) {
- if (GST_IS_ALSA_MIXER_TRACK (item->data)) {
- if (elem && (GST_ALSA_MIXER_TRACK (item->data)->element != elem))
- continue;
-
- gst_alsa_mixer_update_track (mixer, GST_ALSA_MIXER_TRACK (item->data));
- } else if (GST_IS_ALSA_MIXER_OPTIONS (item->data)) {
- if (elem && (GST_ALSA_MIXER_OPTIONS (item->data)->element != elem))
- continue;
-
- gst_alsa_mixer_update_option (mixer, GST_ALSA_MIXER_OPTIONS (item->data));
- }
- }
-
- g_static_rec_mutex_unlock (mixer->rec_mutex);
-}
-
-static int
-gst_alsa_mixer_elem_handle_callback (snd_mixer_elem_t * elem, unsigned int mask)
-{
- GstAlsaMixer *mixer =
- (GstAlsaMixer *) snd_mixer_elem_get_callback_private (elem);
-
- GST_LOG ("ALSA elem cb");
-
- g_return_val_if_fail (mixer != NULL, 1);
-
- gst_alsa_mixer_update (mixer, elem);
-
- return 0;
-}
-
-static int
-gst_alsa_mixer_handle_callback (snd_mixer_t * handle, unsigned int mask,
- snd_mixer_elem_t * elem)
-{
- GstAlsaMixer *mixer =
- (GstAlsaMixer *) snd_mixer_get_callback_private (handle);
-
- GST_LOG ("ALSA cb");
-
- g_return_val_if_fail (mixer != NULL, 1);
-
- /* Hopefully won't be call recursively and will handle pending elem events */
- snd_mixer_handle_events (mixer->handle);
-
- gst_alsa_mixer_update (mixer, elem);
-
- return 0;
-}
-
-static void
-gst_alsa_mixer_ensure_track_list (GstAlsaMixer * mixer)
-{
- gint i, count;
- snd_mixer_elem_t *element, *master;
- GList *item;
-
- g_return_if_fail (mixer->handle != NULL);
-
- if (mixer->tracklist)
- return;
-
- g_static_rec_mutex_lock (mixer->rec_mutex);
-
- master = gst_alsa_mixer_find_master_mixer (mixer, mixer->handle);
-
- count = snd_mixer_get_count (mixer->handle);
- element = snd_mixer_first_elem (mixer->handle);
-
- /* build track list
- *
- * Some ALSA tracks may have playback and capture capabilities.
- * Here we model them as two separate GStreamer tracks.
- */
-
- for (i = 0; i < count; i++) {
- GstMixerTrack *play_track = NULL;
- GstMixerTrack *cap_track = NULL;
- const gchar *name;
- GList *item;
- gint samename = 0;
-
- name = snd_mixer_selem_get_name (element);
-
- /* prevent dup names */
- for (item = mixer->tracklist; item != NULL; item = item->next) {
- snd_mixer_elem_t *temp;
-
- if (GST_IS_ALSA_MIXER_OPTIONS (item->data))
- temp = GST_ALSA_MIXER_OPTIONS (item->data)->element;
- else
- temp = GST_ALSA_MIXER_TRACK (item->data)->element;
-
- if (strcmp (name, snd_mixer_selem_get_name (temp)) == 0)
- samename++;
- }
-
- GST_LOG ("[%s] probing element #%u, mixer->dir=%u", name, i, mixer->dir);
-
- if (mixer->dir & GST_ALSA_MIXER_PLAYBACK) {
- gboolean has_playback_switch, has_playback_volume;
-
- has_playback_switch = snd_mixer_selem_has_playback_switch (element);
- has_playback_volume = snd_mixer_selem_has_playback_volume (element);
-
- GST_LOG ("[%s] PLAYBACK: has_playback_volume=%d, has_playback_switch=%d"
- "%s", name, has_playback_volume, has_playback_switch,
- (element == master) ? " MASTER" : "");
-
- if (has_playback_volume) {
- gint flags = GST_MIXER_TRACK_OUTPUT;
-
- if (element == master)
- flags |= GST_MIXER_TRACK_MASTER;
-
- play_track = gst_alsa_mixer_track_new (element, samename, i,
- flags, FALSE, NULL, FALSE);
-
- } else if (has_playback_switch) {
- /* simple mute switch */
- play_track = gst_alsa_mixer_track_new (element, samename, i,
- GST_MIXER_TRACK_OUTPUT, TRUE, NULL, FALSE);
- }
-
- if (snd_mixer_selem_is_enumerated (element)) {
- GstMixerOptions *opts = gst_alsa_mixer_options_new (element, i);
-
- GST_LOG ("[%s] is enumerated (%d)", name, i);
- mixer->tracklist = g_list_append (mixer->tracklist, opts);
- }
- }
-
- if (mixer->dir & GST_ALSA_MIXER_CAPTURE) {
- gboolean has_capture_switch, has_common_switch;
- gboolean has_capture_volume, has_common_volume;
-
- has_capture_switch = snd_mixer_selem_has_capture_switch (element);
- has_common_switch = snd_mixer_selem_has_common_switch (element);
- has_capture_volume = snd_mixer_selem_has_capture_volume (element);
- has_common_volume = snd_mixer_selem_has_common_volume (element);
-
- GST_LOG ("[%s] CAPTURE: has_capture_volume=%d, has_common_volume=%d, "
- "has_capture_switch=%d, has_common_switch=%d, play_track=%p", name,
- has_capture_volume, has_common_volume, has_capture_switch,
- has_common_switch, play_track);
-
- if (has_capture_volume && !(play_track && has_common_volume)) {
- cap_track = gst_alsa_mixer_track_new (element, samename, i,
- GST_MIXER_TRACK_INPUT, FALSE, NULL, play_track != NULL);
- } else if (has_capture_switch && !(play_track && has_common_switch)) {
- cap_track = gst_alsa_mixer_track_new (element, samename, i,
- GST_MIXER_TRACK_INPUT, TRUE, NULL, play_track != NULL);
- }
- }
-
-
- if (play_track && cap_track) {
- GST_ALSA_MIXER_TRACK (play_track)->shared_mute =
- GST_ALSA_MIXER_TRACK (cap_track);
- GST_ALSA_MIXER_TRACK (cap_track)->shared_mute =
- GST_ALSA_MIXER_TRACK (play_track);
- }
-
- if (play_track)
- mixer->tracklist = g_list_append (mixer->tracklist, play_track);
-
- if (cap_track)
- mixer->tracklist = g_list_append (mixer->tracklist, cap_track);
-
- element = snd_mixer_elem_next (element);
- }
-
- for (item = mixer->tracklist; item != NULL; item = item->next) {
- snd_mixer_elem_t *temp;
-
- if (GST_IS_ALSA_MIXER_OPTIONS (item->data))
- temp = GST_ALSA_MIXER_OPTIONS (item->data)->element;
- else
- temp = GST_ALSA_MIXER_TRACK (item->data)->element;
-
- snd_mixer_elem_set_callback (temp, gst_alsa_mixer_elem_handle_callback);
- snd_mixer_elem_set_callback_private (temp, mixer);
- }
-
- g_static_rec_mutex_unlock (mixer->rec_mutex);
-}
-
-static void
-task_monitor_alsa (gpointer data)
-{
- struct pollfd *pfds;
- unsigned int nfds, rnfds;
- unsigned short revents;
- GstAlsaMixer *mixer = (GstAlsaMixer *) data;
-
- g_static_rec_mutex_lock (mixer->rec_mutex);
-
- nfds = snd_mixer_poll_descriptors_count (mixer->handle);
- if (nfds <= 0) {
- GST_ERROR ("snd_mixer_poll_descriptors_count <= 0: %d", nfds);
- /* FIXME: sleep ? stop monitoring ? */
- return;
- }
-
- pfds = g_newa (struct pollfd, nfds + 1);
- rnfds = snd_mixer_poll_descriptors (mixer->handle, pfds, nfds);
- g_assert (rnfds <= nfds);
-
- pfds[rnfds].fd = mixer->pfd[0];
- pfds[rnfds].events = POLLIN | POLLPRI | POLLHUP | POLLERR;
- pfds[rnfds].revents = 0;
-
- g_static_rec_mutex_unlock (mixer->rec_mutex);
-
- GST_LOG ("task loop");
- poll (pfds, rnfds + 1, -1);
-
- g_static_rec_mutex_lock (mixer->rec_mutex);
-
- snd_mixer_poll_descriptors_revents (mixer->handle, pfds, nfds, &revents);
- if (revents & POLLIN || revents & POLLPRI) {
- GST_DEBUG ("Handling events");
- snd_mixer_handle_events (mixer->handle);
- }
-
- g_static_rec_mutex_unlock (mixer->rec_mutex);
-}
-
-/* API */
-
-GstAlsaMixer *
-gst_alsa_mixer_new (const char *device, GstAlsaMixerDirection dir)
-{
- GstAlsaMixer *ret = NULL;
-
- g_return_val_if_fail (device != NULL, NULL);
-
- ret = g_new0 (GstAlsaMixer, 1);
-
- if (pipe (ret->pfd) == -1)
- goto error;
-
- ret->rec_mutex = g_new (GStaticRecMutex, 1);
- g_static_rec_mutex_init (ret->rec_mutex);
-
- ret->task_mutex = g_new (GStaticRecMutex, 1);
- g_static_rec_mutex_init (ret->task_mutex);
-
- ret->task = gst_task_create (task_monitor_alsa, ret);
- gst_task_set_lock (ret->task, ret->task_mutex);
-
- ret->device = g_strdup (device);
- ret->dir = dir;
-
- if (!gst_alsa_mixer_open (ret))
- goto error;
-
- if (gst_task_start (ret->task) == FALSE) {
- GST_WARNING ("Could not start alsamixer task");
- }
-
- return ret;
-
- /* ERRORS */
-error:
- {
- gst_alsa_mixer_free (ret);
- return NULL;
- }
-}
-
-void
-gst_alsa_mixer_free (GstAlsaMixer * mixer)
-{
- g_return_if_fail (mixer != NULL);
-
- if (mixer->task) {
- if (write (mixer->pfd[1], "stop", 5) <= 0) {
- GST_ERROR ("Cannot send " "stop" " to alsamixer task");
- close (mixer->pfd[1]);
- mixer->pfd[1] = -1;
- }
-
- if (gst_task_join (mixer->task) == FALSE) {
- GST_ERROR ("Cannot join alsamixer task");
- }
-
- gst_object_unref (mixer->task);
- mixer->task = NULL;
- }
-
- g_static_rec_mutex_free (mixer->task_mutex);
- g_free (mixer->task_mutex);
- mixer->task_mutex = NULL;
-
- if (mixer->pfd[0] > 0) {
- close (mixer->pfd[0]);
- mixer->pfd[0] = -1;
- }
-
- if (mixer->pfd[1] > 0) {
- close (mixer->pfd[1]);
- mixer->pfd[1] = -1;
- }
-
- if (mixer->interface) {
- g_object_unref (G_OBJECT (mixer->interface));
- mixer->interface = NULL;
- }
-
- if (mixer->device) {
- g_free (mixer->device);
- mixer->device = NULL;
- }
-
- if (mixer->cardname) {
- g_free (mixer->cardname);
- mixer->cardname = NULL;
- }
-
- if (mixer->tracklist) {
- g_list_foreach (mixer->tracklist, (GFunc) g_object_unref, NULL);
- g_list_free (mixer->tracklist);
- mixer->tracklist = NULL;
- }
-
- if (mixer->handle) {
- snd_mixer_close (mixer->handle);
- mixer->handle = NULL;
- }
-
- g_static_rec_mutex_free (mixer->rec_mutex);
- g_free (mixer->rec_mutex);
- mixer->rec_mutex = NULL;
-
- g_free (mixer);
-}
-
-const GList *
-gst_alsa_mixer_list_tracks (GstAlsaMixer * mixer)
-{
- g_return_val_if_fail (mixer->handle != NULL, NULL);
-
- gst_alsa_mixer_ensure_track_list (mixer);
-
- return (const GList *) mixer->tracklist;
-}
-
-void
-gst_alsa_mixer_get_volume (GstAlsaMixer * mixer, GstMixerTrack * track,
- gint * volumes)
-{
- gint i;
- GstAlsaMixerTrack *alsa_track = GST_ALSA_MIXER_TRACK (track);
-
- g_return_if_fail (mixer->handle != NULL);
-
- gst_alsa_mixer_track_update (alsa_track);
-
- if (track->flags & GST_MIXER_TRACK_OUTPUT) { /* return playback volume */
-
- /* Is emulated mute flag activated? */
- if (track->flags & GST_MIXER_TRACK_MUTE &&
- !(alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_PSWITCH)) {
- for (i = 0; i < track->num_channels; i++)
- volumes[i] = alsa_track->volumes[i];
- } else {
- for (i = 0; i < track->num_channels; i++) {
- long tmp = 0;
-
- snd_mixer_selem_get_playback_volume (alsa_track->element, i, &tmp);
- alsa_track->volumes[i] = volumes[i] = (gint) tmp;
- }
- }
-
- } else if (track->flags & GST_MIXER_TRACK_INPUT) { /* return capture volume */
-
- /* Is emulated record flag activated? */
- if (alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_CSWITCH ||
- track->flags & GST_MIXER_TRACK_RECORD) {
- for (i = 0; i < track->num_channels; i++) {
- long tmp = 0;
-
- snd_mixer_selem_get_capture_volume (alsa_track->element, i, &tmp);
- alsa_track->volumes[i] = volumes[i] = (gint) tmp;
- }
- } else {
- for (i = 0; i < track->num_channels; i++)
- volumes[i] = alsa_track->volumes[i];
- }
- }
-}
-
-static gboolean
-check_if_volumes_are_the_same (guint num_channels, gint * volumes)
-{
- guint i;
-
- if (num_channels <= 1)
- return TRUE;
-
- for (i = 1; i < num_channels; i++) {
- if (volumes[i] != volumes[0])
- return FALSE;
- }
-
- return TRUE;
-}
-
-void
-gst_alsa_mixer_set_volume (GstAlsaMixer * mixer, GstMixerTrack * track,
- gint * volumes)
-{
- GstAlsaMixerTrack *alsa_track = GST_ALSA_MIXER_TRACK (track);
- gint i;
-
- g_return_if_fail (mixer->handle != NULL);
-
- gst_alsa_mixer_track_update (alsa_track);
-
- if (track->flags & GST_MIXER_TRACK_OUTPUT) {
-
- /* Is emulated mute flag activated? */
- if (track->flags & GST_MIXER_TRACK_MUTE &&
- !(alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_PSWITCH)) {
- for (i = 0; i < track->num_channels; i++)
- alsa_track->volumes[i] = volumes[i];
- } else {
- if (check_if_volumes_are_the_same (track->num_channels, volumes)) {
- snd_mixer_selem_set_playback_volume_all (alsa_track->element,
- volumes[0]);
- for (i = 0; i < track->num_channels; i++)
- alsa_track->volumes[i] = volumes[0];
- } else {
- for (i = 0; i < track->num_channels; i++) {
- alsa_track->volumes[i] = volumes[i];
- snd_mixer_selem_set_playback_volume (alsa_track->element, i,
- volumes[i]);
- }
- }
- }
-
- } else if (track->flags & GST_MIXER_TRACK_INPUT) {
-
- /* Is emulated record flag activated? */
- if (track->flags & GST_MIXER_TRACK_RECORD ||
- alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_CSWITCH) {
- if (check_if_volumes_are_the_same (track->num_channels, volumes)) {
- snd_mixer_selem_set_capture_volume_all (alsa_track->element,
- volumes[0]);
- for (i = 0; i < track->num_channels; i++)
- alsa_track->volumes[i] = volumes[0];
- } else {
- for (i = 0; i < track->num_channels; i++) {
- alsa_track->volumes[i] = volumes[i];
- snd_mixer_selem_set_capture_volume (alsa_track->element, i,
- volumes[i]);
- }
- }
- } else {
- for (i = 0; i < track->num_channels; i++)
- alsa_track->volumes[i] = volumes[i];
- }
- }
-}
-
-void
-gst_alsa_mixer_set_mute (GstAlsaMixer * mixer, GstMixerTrack * track,
- gboolean mute)
-{
- GstAlsaMixerTrack *alsa_track = GST_ALSA_MIXER_TRACK (track);
-
- g_return_if_fail (mixer->handle != NULL);
-
- gst_alsa_mixer_track_update (alsa_track);
-
- if (!!(mute) == !!(track->flags & GST_MIXER_TRACK_MUTE))
- return;
-
- if (mute) {
- track->flags |= GST_MIXER_TRACK_MUTE;
-
- if (alsa_track->shared_mute)
- ((GstMixerTrack *) (alsa_track->shared_mute))->flags |=
- GST_MIXER_TRACK_MUTE;
- } else {
- track->flags &= ~GST_MIXER_TRACK_MUTE;
-
- if (alsa_track->shared_mute)
- ((GstMixerTrack *) (alsa_track->shared_mute))->flags &=
- ~GST_MIXER_TRACK_MUTE;
- }
-
- if (alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_PSWITCH) {
- snd_mixer_selem_set_playback_switch_all (alsa_track->element, mute ? 0 : 1);
- } else {
- gint i;
- GstAlsaMixerTrack *ctrl_track;
-
- if ((track->flags & GST_MIXER_TRACK_INPUT)
- && alsa_track->shared_mute != NULL)
- ctrl_track = alsa_track->shared_mute;
- else
- ctrl_track = alsa_track;
-
- for (i = 0; i < ((GstMixerTrack *) ctrl_track)->num_channels; i++) {
- long vol =
- mute ? ((GstMixerTrack *) ctrl_track)->min_volume : ctrl_track->
- volumes[i];
- snd_mixer_selem_set_playback_volume (ctrl_track->element, i, vol);
- }
- }
-}
-
-void
-gst_alsa_mixer_set_record (GstAlsaMixer * mixer,
- GstMixerTrack * track, gboolean record)
-{
- GstAlsaMixerTrack *alsa_track = GST_ALSA_MIXER_TRACK (track);
-
- g_return_if_fail (mixer->handle != NULL);
-
- gst_alsa_mixer_track_update (alsa_track);
-
- if (!!(record) == !!(track->flags & GST_MIXER_TRACK_RECORD))
- return;
-
- if (record) {
- track->flags |= GST_MIXER_TRACK_RECORD;
- } else {
- track->flags &= ~GST_MIXER_TRACK_RECORD;
- }
-
- if (alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_CSWITCH) {
- snd_mixer_selem_set_capture_switch_all (alsa_track->element,
- record ? 1 : 0);
-
- /* update all tracks in same exlusive cswitch group */
- if (alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_CSWITCH_EXCL) {
- GList *item;
-
- for (item = mixer->tracklist; item != NULL; item = item->next) {
-
- if (GST_IS_ALSA_MIXER_TRACK (item->data)) {
- GstAlsaMixerTrack *item_alsa_track =
- GST_ALSA_MIXER_TRACK (item->data);
-
- if (item_alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_CSWITCH_EXCL &&
- item_alsa_track->capture_group == alsa_track->capture_group) {
- gst_alsa_mixer_track_update (item_alsa_track);
- }
- }
- }
- }
- } else {
- gint i;
-
- for (i = 0; i < track->num_channels; i++) {
- long vol = record ? alsa_track->volumes[i] : track->min_volume;
-
- snd_mixer_selem_set_capture_volume (alsa_track->element, i, vol);
- }
- }
-}
-
-void
-gst_alsa_mixer_set_option (GstAlsaMixer * mixer,
- GstMixerOptions * opts, gchar * value)
-{
- gint idx = -1, n = 0;
- GList *item;
- GstAlsaMixerOptions *alsa_opts = GST_ALSA_MIXER_OPTIONS (opts);
-
- g_return_if_fail (mixer->handle != NULL);
-
- for (item = opts->values; item != NULL; item = item->next, n++) {
- if (!strcmp (item->data, value)) {
- idx = n;
- break;
- }
- }
- if (idx == -1)
- return;
-
- snd_mixer_selem_set_enum_item (alsa_opts->element, 0, idx);
-}
-
-const gchar *
-gst_alsa_mixer_get_option (GstAlsaMixer * mixer, GstMixerOptions * opts)
-{
- gint ret;
- guint idx;
- GstAlsaMixerOptions *alsa_opts = GST_ALSA_MIXER_OPTIONS (opts);
-
- g_return_val_if_fail (mixer->handle != NULL, NULL);
-
- ret = snd_mixer_selem_get_enum_item (alsa_opts->element, 0, &idx);
- if (ret == 0)
- return g_list_nth_data (opts->values, idx);
- else
- return snd_strerror (ret); /* feeble attempt at error handling */
-}
-
-GstMixerFlags
-gst_alsa_mixer_get_mixer_flags (GstAlsaMixer * mixer)
-{
- g_return_val_if_fail (mixer != NULL, GST_MIXER_FLAG_NONE);
-
- return GST_MIXER_FLAG_AUTO_NOTIFICATIONS;
-}
-
-static void
-gst_alsa_mixer_update_option (GstAlsaMixer * mixer,
- GstAlsaMixerOptions * alsa_opts)
-{
- gint ret;
- guint idx;
- /* const */ gchar *option;
-
- if (mixer->interface == NULL) {
- GST_WARNING ("Cannot send update notifications, no GstMixer * given");
- return;
- }
-
- ret = snd_mixer_selem_get_enum_item (alsa_opts->element, 0, &idx);
- if (ret == 0) {
- option = g_list_nth_data (GST_MIXER_OPTIONS (alsa_opts)->values, idx);
- gst_mixer_option_changed (mixer->interface, GST_MIXER_OPTIONS (alsa_opts),
- option);
- }
-}
-
-static void
-gst_alsa_mixer_update_track (GstAlsaMixer * mixer,
- GstAlsaMixerTrack * alsa_track)
-{
- GstMixerTrack *track = (GstMixerTrack *) alsa_track;
- gboolean old_mute;
- gboolean old_record;
- gint i, n_channels;
- gint *old_volumes;
-
- GST_DEBUG ("Updating track %" GST_PTR_FORMAT, alsa_track);
-
- if (mixer->interface == NULL) {
- GST_WARNING ("Cannot send update notifications, no GstMixer * given");
- return;
- }
-
- old_mute = !!(GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_MUTE));
- old_record = !!(GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_RECORD));
- old_volumes = g_new (gint, track->num_channels);
- n_channels = track->num_channels;
- memcpy (old_volumes, alsa_track->volumes,
- sizeof (gint) * track->num_channels);
-
- gst_alsa_mixer_track_update (alsa_track);
-
- if (old_record !=
- !!(GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_RECORD))) {
- gst_mixer_record_toggled (mixer->interface, track,
- !!GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_RECORD));
- }
- if (old_mute != !!(GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_MUTE))) {
- gst_mixer_mute_toggled (mixer->interface, track,
- !!GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_MUTE));
- }
-
- n_channels = MIN (n_channels, track->num_channels);
- for (i = 0; i < n_channels; i++) {
- if (old_volumes[i] != alsa_track->volumes[i]) {
- gst_mixer_volume_changed (mixer->interface, track, alsa_track->volumes);
- break;
- }
- }
- g_free (old_volumes);
-}
-
-/* utility function for gstalsamixerelement to set the interface */
-void
-_gst_alsa_mixer_set_interface (GstAlsaMixer * mixer, GstMixer * interface)
-{
- g_return_if_fail (mixer != NULL && mixer->interface == NULL);
- g_return_if_fail (interface != NULL);
-
- mixer->interface = g_object_ref (G_OBJECT (interface));
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsamixer.h
--- a/gst_plugins_base/ext/alsa/gstalsamixer.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,217 +0,0 @@
-/* ALSA mixer interface implementation.
- * Copyright (C) 2003 Leif Johnson
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-
-#ifndef __GST_ALSA_MIXER_H__
-#define __GST_ALSA_MIXER_H__
-
-
-#include "gstalsa.h"
-
-#include
-#include "gstalsamixeroptions.h"
-#include "gstalsamixertrack.h"
-
-
-G_BEGIN_DECLS
-
-/* This does not get you what you think it does, use obj->mixer */
-/* #define GST_ALSA_MIXER(obj) ((GstAlsaMixer*)(obj)) */
-
-typedef struct _GstAlsaMixer GstAlsaMixer;
-
-typedef enum {
- GST_ALSA_MIXER_CAPTURE = 1<<0,
- GST_ALSA_MIXER_PLAYBACK = 1<<1,
- GST_ALSA_MIXER_ALL = GST_ALSA_MIXER_CAPTURE | GST_ALSA_MIXER_PLAYBACK
-} GstAlsaMixerDirection;
-
-/**
- * GstAlsaMixer:
- *
- * Opaque data structure
- */
-struct _GstAlsaMixer
-{
- GList * tracklist; /* list of available tracks */
-
- snd_mixer_t * handle;
-
- GstTask * task;
- GStaticRecMutex * task_mutex;
- GStaticRecMutex * rec_mutex;
-
- int pfd[2];
-
- GstMixer * interface;
- gchar * device;
- gchar * cardname;
-
- GstAlsaMixerDirection dir;
-};
-
-
-GstAlsaMixer* gst_alsa_mixer_new (const gchar *device,
- GstAlsaMixerDirection dir);
-void gst_alsa_mixer_free (GstAlsaMixer *mixer);
-
-const GList* gst_alsa_mixer_list_tracks (GstAlsaMixer * mixer);
-void gst_alsa_mixer_set_volume (GstAlsaMixer * mixer,
- GstMixerTrack * track,
- gint * volumes);
-void gst_alsa_mixer_get_volume (GstAlsaMixer * mixer,
- GstMixerTrack * track,
- gint * volumes);
-void gst_alsa_mixer_set_record (GstAlsaMixer * mixer,
- GstMixerTrack * track,
- gboolean record);
-void gst_alsa_mixer_set_mute (GstAlsaMixer * mixer,
- GstMixerTrack * track,
- gboolean mute);
-void gst_alsa_mixer_set_option (GstAlsaMixer * mixer,
- GstMixerOptions * opts,
- gchar * value);
-const gchar* gst_alsa_mixer_get_option (GstAlsaMixer * mixer,
- GstMixerOptions * opts);
-void _gst_alsa_mixer_set_interface (GstAlsaMixer * mixer,
- GstMixer * interface);
-GstMixerFlags gst_alsa_mixer_get_mixer_flags (GstAlsaMixer *mixer);
-
-#define GST_IMPLEMENT_ALSA_MIXER_METHODS(Type, interface_as_function) \
-static gboolean \
-interface_as_function ## _supported (Type *this, GType iface_type) \
-{ \
- g_assert (iface_type == GST_TYPE_MIXER); \
- \
- return (this->mixer != NULL); \
-} \
- \
-static const GList* \
-interface_as_function ## _list_tracks (GstMixer * mixer) \
-{ \
- Type *this = (Type*) mixer; \
- \
- g_return_val_if_fail (this != NULL, NULL); \
- g_return_val_if_fail (this->mixer != NULL, NULL); \
- \
- return gst_alsa_mixer_list_tracks (this->mixer); \
-} \
- \
-static void \
-interface_as_function ## _set_volume (GstMixer * mixer, GstMixerTrack * track, \
- gint * volumes) \
-{ \
- Type *this = (Type*) mixer; \
- \
- g_return_if_fail (this != NULL); \
- g_return_if_fail (this->mixer != NULL); \
- \
- gst_alsa_mixer_set_volume (this->mixer, track, volumes); \
-} \
- \
-static void \
-interface_as_function ## _get_volume (GstMixer * mixer, GstMixerTrack * track, \
- gint * volumes) \
-{ \
- Type *this = (Type*) mixer; \
- \
- g_return_if_fail (this != NULL); \
- g_return_if_fail (this->mixer != NULL); \
- \
- gst_alsa_mixer_get_volume (this->mixer, track, volumes); \
-} \
- \
-static void \
-interface_as_function ## _set_record (GstMixer * mixer, GstMixerTrack * track, \
- gboolean record) \
-{ \
- Type *this = (Type*) mixer; \
- \
- g_return_if_fail (this != NULL); \
- g_return_if_fail (this->mixer != NULL); \
- \
- gst_alsa_mixer_set_record (this->mixer, track, record); \
-} \
- \
-static void \
-interface_as_function ## _set_mute (GstMixer * mixer, GstMixerTrack * track, \
- gboolean mute) \
-{ \
- Type *this = (Type*) mixer; \
- \
- g_return_if_fail (this != NULL); \
- g_return_if_fail (this->mixer != NULL); \
- \
- gst_alsa_mixer_set_mute (this->mixer, track, mute); \
-} \
- \
-static void \
-interface_as_function ## _set_option (GstMixer * mixer, GstMixerOptions * opts, \
- gchar * value) \
-{ \
- Type *this = (Type*) mixer; \
- \
- g_return_if_fail (this != NULL); \
- g_return_if_fail (this->mixer != NULL); \
- \
- gst_alsa_mixer_set_option (this->mixer, opts, value); \
-} \
- \
-static const gchar* \
-interface_as_function ## _get_option (GstMixer * mixer, GstMixerOptions * opts) \
-{ \
- Type *this = (Type*) mixer; \
- \
- g_return_val_if_fail (this != NULL, NULL); \
- g_return_val_if_fail (this->mixer != NULL, NULL); \
- \
- return gst_alsa_mixer_get_option (this->mixer, opts); \
-} \
- \
-static GstMixerFlags \
-interface_as_function ## _get_mixer_flags (GstMixer * mixer) \
-{ \
- Type *this = (Type*) mixer; \
- \
- g_return_val_if_fail (this != NULL, GST_MIXER_FLAG_NONE); \
- g_return_val_if_fail (this->mixer != NULL, GST_MIXER_FLAG_NONE); \
- \
- return gst_alsa_mixer_get_mixer_flags (this->mixer); \
-} \
- \
-static void \
-interface_as_function ## _interface_init (GstMixerClass * klass) \
-{ \
- GST_MIXER_TYPE (klass) = GST_MIXER_HARDWARE; \
- \
- /* set up the interface hooks */ \
- klass->list_tracks = interface_as_function ## _list_tracks; \
- klass->set_volume = interface_as_function ## _set_volume; \
- klass->get_volume = interface_as_function ## _get_volume; \
- klass->set_mute = interface_as_function ## _set_mute; \
- klass->set_record = interface_as_function ## _set_record; \
- klass->set_option = interface_as_function ## _set_option; \
- klass->get_option = interface_as_function ## _get_option; \
- klass->get_mixer_flags = interface_as_function ## _get_mixer_flags; \
-}
-
-
-G_END_DECLS
-
-
-#endif /* __GST_ALSA_MIXER_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsamixerelement.c
--- a/gst_plugins_base/ext/alsa/gstalsamixerelement.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,248 +0,0 @@
-/* ALSA mixer implementation.
- * Copyright (C) 2003 Leif Johnson
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstalsamixerelement.h"
-#include "gstalsadeviceprobe.h"
-
-#define DEFAULT_PROP_DEVICE "default"
-#define DEFAULT_PROP_DEVICE_NAME ""
-
-enum
-{
- PROP_0,
- PROP_DEVICE,
- PROP_DEVICE_NAME
-};
-
-static const GstElementDetails gst_alsa_mixer_element_details =
-GST_ELEMENT_DETAILS ("Alsa mixer",
- "Generic/Audio",
- "Control sound input and output levels with ALSA",
- "Leif Johnson ");
-
-static void gst_alsa_mixer_element_init_interfaces (GType type);
-
-GST_BOILERPLATE_FULL (GstAlsaMixerElement, gst_alsa_mixer_element,
- GstElement, GST_TYPE_ELEMENT, gst_alsa_mixer_element_init_interfaces);
-
-/* massive macro that takes care of all the GstMixer stuff */
-GST_IMPLEMENT_ALSA_MIXER_METHODS (GstAlsaMixerElement, gst_alsa_mixer_element);
-
-static void gst_alsa_mixer_element_get_property (GObject * object,
- guint prop_id, GValue * value, GParamSpec * pspec);
-static void gst_alsa_mixer_element_set_property (GObject * object,
- guint prop_id, const GValue * value, GParamSpec * pspec);
-static void gst_alsa_mixer_element_finalize (GObject * object);
-
-static GstStateChangeReturn gst_alsa_mixer_element_change_state (GstElement
- * element, GstStateChange transition);
-
-static gboolean
-gst_alsa_mixer_element_interface_supported (GstAlsaMixerElement * this,
- GType interface_type)
-{
- if (interface_type == GST_TYPE_MIXER) {
- return gst_alsa_mixer_element_supported (this, interface_type);
- }
-
- g_return_val_if_reached (FALSE);
-}
-
-static void
-gst_implements_interface_init (GstImplementsInterfaceClass * klass)
-{
- klass->supported = (gpointer) gst_alsa_mixer_element_interface_supported;
-}
-
-static void
-gst_alsa_mixer_element_init_interfaces (GType type)
-{
- static const GInterfaceInfo implements_iface_info = {
- (GInterfaceInitFunc) gst_implements_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo mixer_iface_info = {
- (GInterfaceInitFunc) gst_alsa_mixer_element_interface_init,
- NULL,
- NULL,
- };
-
- g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE,
- &implements_iface_info);
- g_type_add_interface_static (type, GST_TYPE_MIXER, &mixer_iface_info);
-
- gst_alsa_type_add_device_property_probe_interface (type);
-}
-
-static void
-gst_alsa_mixer_element_base_init (gpointer klass)
-{
- gst_element_class_set_details (GST_ELEMENT_CLASS (klass),
- &gst_alsa_mixer_element_details);
-}
-
-static void
-gst_alsa_mixer_element_class_init (GstAlsaMixerElementClass * klass)
-{
- GstElementClass *element_class;
- GObjectClass *gobject_class;
-
- element_class = (GstElementClass *) klass;
- gobject_class = (GObjectClass *) klass;
-
- gobject_class->finalize = gst_alsa_mixer_element_finalize;
- gobject_class->get_property = gst_alsa_mixer_element_get_property;
- gobject_class->set_property = gst_alsa_mixer_element_set_property;
-
- g_object_class_install_property (gobject_class, PROP_DEVICE,
- g_param_spec_string ("device", "Device",
- "ALSA device, as defined in an asound configuration file",
- DEFAULT_PROP_DEVICE, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_DEVICE_NAME,
- g_param_spec_string ("device-name", "Device name",
- "Human-readable name of the sound device",
- DEFAULT_PROP_DEVICE_NAME, G_PARAM_READABLE));
-
- element_class->change_state =
- GST_DEBUG_FUNCPTR (gst_alsa_mixer_element_change_state);
-}
-
-static void
-gst_alsa_mixer_element_finalize (GObject * obj)
-{
- GstAlsaMixerElement *this = GST_ALSA_MIXER_ELEMENT (obj);
-
- g_free (this->device);
-
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-static void
-gst_alsa_mixer_element_init (GstAlsaMixerElement * this,
- GstAlsaMixerElementClass * klass)
-{
- this->mixer = NULL;
- this->device = g_strdup (DEFAULT_PROP_DEVICE);
-}
-
-static void
-gst_alsa_mixer_element_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstAlsaMixerElement *this = GST_ALSA_MIXER_ELEMENT (object);
-
- switch (prop_id) {
- case PROP_DEVICE:{
- GST_OBJECT_LOCK (this);
- g_free (this->device);
- this->device = g_value_dup_string (value);
- /* make sure we never set NULL, this is nice when we want to open the
- * device. */
- if (this->device == NULL)
- this->device = g_strdup (DEFAULT_PROP_DEVICE);
- GST_OBJECT_UNLOCK (this);
- break;
- }
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_alsa_mixer_element_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstAlsaMixerElement *this = GST_ALSA_MIXER_ELEMENT (object);
-
- switch (prop_id) {
- case PROP_DEVICE:{
- GST_OBJECT_LOCK (this);
- g_value_set_string (value, this->device);
- GST_OBJECT_UNLOCK (this);
- break;
- }
- case PROP_DEVICE_NAME:{
- GST_OBJECT_LOCK (this);
- if (this->mixer) {
- g_value_set_string (value, this->mixer->cardname);
- } else {
- g_value_set_string (value, NULL);
- }
- GST_OBJECT_UNLOCK (this);
- break;
- }
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GstStateChangeReturn
-gst_alsa_mixer_element_change_state (GstElement * element,
- GstStateChange transition)
-{
- GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
- GstAlsaMixerElement *this = GST_ALSA_MIXER_ELEMENT (element);
-
- switch (transition) {
- case GST_STATE_CHANGE_NULL_TO_READY:
- if (!this->mixer) {
- this->mixer = gst_alsa_mixer_new (this->device, GST_ALSA_MIXER_ALL);
- if (!this->mixer)
- goto open_failed;
- _gst_alsa_mixer_set_interface (this->mixer, GST_MIXER (element));
- }
- break;
- default:
- break;
- }
-
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- if (ret == GST_STATE_CHANGE_FAILURE)
- return ret;
-
- switch (transition) {
- case GST_STATE_CHANGE_READY_TO_NULL:
- if (this->mixer) {
- gst_alsa_mixer_free (this->mixer);
- this->mixer = NULL;
- }
- break;
- default:
- break;
- }
-
- return ret;
-
- /* ERRORS */
-open_failed:
- {
- GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ_WRITE, (NULL),
- ("Failed to open alsa mixer device '%s'", this->device));
- return GST_STATE_CHANGE_FAILURE;
- }
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsamixerelement.h
--- a/gst_plugins_base/ext/alsa/gstalsamixerelement.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/* ALSA mixer interface implementation.
- * Copyright (C) 2003 Leif Johnson
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-
-#ifndef __GST_ALSA_MIXER_ELEMENT_H__
-#define __GST_ALSA_MIXER_ELEMENT_H__
-
-
-#include "gstalsa.h"
-#include "gstalsamixer.h"
-
-G_BEGIN_DECLS
-
-#define GST_ALSA_MIXER_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_MIXER_ELEMENT,GstAlsaMixerElement))
-#define GST_ALSA_MIXER_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_MIXER_ELEMENT,GstAlsaMixerElementClass))
-#define GST_IS_ALSA_MIXER_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_MIXER_ELEMENT))
-#define GST_IS_ALSA_MIXER_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_MIXER_ELEMENT))
-#define GST_TYPE_ALSA_MIXER_ELEMENT (gst_alsa_mixer_element_get_type())
-
-typedef struct _GstAlsaMixerElement GstAlsaMixerElement;
-typedef struct _GstAlsaMixerElementClass GstAlsaMixerElementClass;
-
-/**
- * GstAlsaMixerElement
- *
- * Opaque datastructure.
- */
-struct _GstAlsaMixerElement {
- GstElement parent;
-
- GstAlsaMixer *mixer;
- gchar *device;
-};
-
-struct _GstAlsaMixerElementClass {
- GstElementClass parent;
-};
-
-
-GType gst_alsa_mixer_element_get_type (void);
-
-
-G_END_DECLS
-
-
-#endif /* __GST_ALSA_MIXER_ELEMENT_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsamixeroptions.c
--- a/gst_plugins_base/ext/alsa/gstalsamixeroptions.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/* ALSA mixer object implementation.
- * Copyright (C) 2003 Leif Johnson
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstalsamixeroptions.h"
-
-static void gst_alsa_mixer_options_init (GstAlsaMixerOptions * alsa_opts);
-static void gst_alsa_mixer_options_class_init (gpointer g_class,
- gpointer class_data);
-
-static GstMixerOptionsClass *parent_class = NULL;
-
-GType
-gst_alsa_mixer_options_get_type (void)
-{
- static GType opts_type = 0;
-
- if (!opts_type) {
- static const GTypeInfo opts_info = {
- sizeof (GstAlsaMixerOptionsClass),
- NULL,
- NULL,
- gst_alsa_mixer_options_class_init,
- NULL,
- NULL,
- sizeof (GstAlsaMixerOptions),
- 0,
- (GInstanceInitFunc) gst_alsa_mixer_options_init,
- };
-
- opts_type =
- g_type_register_static (GST_TYPE_MIXER_OPTIONS, "GstAlsaMixerOptions",
- &opts_info, 0);
- }
-
- return opts_type;
-}
-
-static void
-gst_alsa_mixer_options_class_init (gpointer g_class, gpointer class_data)
-{
- parent_class = g_type_class_peek_parent (g_class);
-}
-
-static void
-gst_alsa_mixer_options_init (GstAlsaMixerOptions * alsa_opts)
-{
-}
-
-GstMixerOptions *
-gst_alsa_mixer_options_new (snd_mixer_elem_t * element, gint track_num)
-{
- GstMixerOptions *opts;
- GstAlsaMixerOptions *alsa_opts;
- GstMixerTrack *track;
- const gchar *label;
- gint num, i;
- gchar str[256];
-
- label = snd_mixer_selem_get_name (element);
-
- opts = g_object_new (GST_ALSA_MIXER_OPTIONS_TYPE,
- "untranslated-label", label, NULL);
- alsa_opts = (GstAlsaMixerOptions *) opts;
- track = (GstMixerTrack *) opts;
-
- /* set basic information */
- track->label = g_strdup (label); /* FIXME: translate this? */
- track->num_channels = 0;
- track->flags = 0;
- alsa_opts->element = element;
- alsa_opts->track_num = track_num;
-
- /* get enumerations for switch/options object */
- num = snd_mixer_selem_get_enum_items (element);
- for (i = 0; i < num; i++) {
- if (snd_mixer_selem_get_enum_item_name (element, i, 255, str) < 0) {
- g_object_unref (G_OBJECT (alsa_opts));
- return NULL;
- }
-
- opts->values = g_list_append (opts->values, g_strdup (str));
- }
-
- return opts;
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsamixeroptions.h
--- a/gst_plugins_base/ext/alsa/gstalsamixeroptions.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/* ALSA mixer options object.
- * Copyright (C) 2003 Leif Johnson
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-
-#ifndef __GST_ALSA_MIXER_OPTIONS_H__
-#define __GST_ALSA_MIXER_OPTIONS_H__
-
-
-#include "gstalsa.h"
-#include
-
-
-G_BEGIN_DECLS
-
-
-#define GST_ALSA_MIXER_OPTIONS_TYPE (gst_alsa_mixer_options_get_type ())
-#define GST_ALSA_MIXER_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_MIXER_OPTIONS,GstAlsaMixerOptions))
-#define GST_ALSA_MIXER_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_MIXER_OPTIONS,GstAlsaMixerOptionsClass))
-#define GST_IS_ALSA_MIXER_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_MIXER_OPTIONS))
-#define GST_IS_ALSA_MIXER_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_MIXER_OPTIONS))
-#define GST_TYPE_ALSA_MIXER_OPTIONS (gst_alsa_mixer_options_get_type())
-
-
-typedef struct _GstAlsaMixerOptions GstAlsaMixerOptions;
-typedef struct _GstAlsaMixerOptionsClass GstAlsaMixerOptionsClass;
-
-
-struct _GstAlsaMixerOptions {
- GstMixerOptions parent;
- snd_mixer_elem_t *element; /* the ALSA mixer element for this track */
- gint track_num;
-};
-
-struct _GstAlsaMixerOptionsClass {
- GstMixerOptionsClass parent;
-};
-
-
-GType gst_alsa_mixer_options_get_type (void);
-GstMixerOptions *gst_alsa_mixer_options_new (snd_mixer_elem_t * element,
- gint track_num);
-
-
-G_END_DECLS
-
-
-#endif /* __GST_ALSA_MIXER_OPTIONS_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsamixertrack.c
--- a/gst_plugins_base/ext/alsa/gstalsamixertrack.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,339 +0,0 @@
-/* ALSA mixer track implementation.
- * Copyright (C) 2003 Leif Johnson
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include
-
-#include "gstalsamixertrack.h"
-
-static void gst_alsa_mixer_track_init (GstAlsaMixerTrack * alsa_track);
-static void gst_alsa_mixer_track_class_init (gpointer g_class,
- gpointer class_data);
-
-static GstMixerTrackClass *parent_class = NULL;
-
-GType
-gst_alsa_mixer_track_get_type (void)
-{
- static GType track_type = 0;
-
- if (!track_type) {
- static const GTypeInfo track_info = {
- sizeof (GstAlsaMixerTrackClass),
- NULL,
- NULL,
- gst_alsa_mixer_track_class_init,
- NULL,
- NULL,
- sizeof (GstAlsaMixerTrack),
- 0,
- (GInstanceInitFunc) gst_alsa_mixer_track_init,
- NULL
- };
-
- track_type =
- g_type_register_static (GST_TYPE_MIXER_TRACK, "GstAlsaMixerTrack",
- &track_info, 0);
- }
-
- return track_type;
-}
-
-static void
-gst_alsa_mixer_track_class_init (gpointer g_class, gpointer class_data)
-{
- parent_class = g_type_class_peek_parent (g_class);
-}
-
-static void
-gst_alsa_mixer_track_init (GstAlsaMixerTrack * alsa_track)
-{
-}
-
-static void
-gst_alsa_mixer_track_update_alsa_capabilities (GstAlsaMixerTrack * alsa_track)
-{
- alsa_track->alsa_flags = 0;
- alsa_track->capture_group = -1;
-
- if (snd_mixer_selem_has_common_volume (alsa_track->element))
- alsa_track->alsa_flags |= GST_ALSA_MIXER_TRACK_VOLUME;
-
- if (snd_mixer_selem_has_playback_volume (alsa_track->element))
- alsa_track->alsa_flags |= GST_ALSA_MIXER_TRACK_PVOLUME;
-
- if (snd_mixer_selem_has_capture_volume (alsa_track->element))
- alsa_track->alsa_flags |= GST_ALSA_MIXER_TRACK_CVOLUME;
-
- if (snd_mixer_selem_has_common_switch (alsa_track->element))
- alsa_track->alsa_flags |= GST_ALSA_MIXER_TRACK_SWITCH;
-
- if (snd_mixer_selem_has_playback_switch (alsa_track->element))
- alsa_track->alsa_flags |= GST_ALSA_MIXER_TRACK_PSWITCH;
-
- if (snd_mixer_selem_has_capture_switch (alsa_track->element)) {
- alsa_track->alsa_flags |= GST_ALSA_MIXER_TRACK_CSWITCH;
-
- if (snd_mixer_selem_has_capture_switch_exclusive (alsa_track->element)) {
- alsa_track->alsa_flags |= GST_ALSA_MIXER_TRACK_CSWITCH_EXCL;
- alsa_track->capture_group =
- snd_mixer_selem_get_capture_group (alsa_track->element);
- }
- }
-
- GST_LOG ("[%s] alsa_flags=0x%08x, capture_group=%d",
- snd_mixer_selem_get_name (alsa_track->element),
- alsa_track->alsa_flags, alsa_track->capture_group);
-}
-
-inline static gboolean
-alsa_track_has_cap (GstAlsaMixerTrack * alsa_track, guint32 flag)
-{
- return ((alsa_track->alsa_flags & flag) != 0);
-}
-
-GstMixerTrack *
-gst_alsa_mixer_track_new (snd_mixer_elem_t * element,
- gint num, gint track_num, gint flags, gboolean sw,
- GstAlsaMixerTrack * shared_mute_track, gboolean append_capture)
-{
- GstAlsaMixerTrack *alsa_track;
- GstMixerTrack *track;
- const gchar *name;
- const gchar *label;
- gint i;
- long min = 0, max = 0;
- const struct
- {
- const gchar orig[12];
- const gchar trans[12];
- } alsa_track_labels[] = {
- {
- "Master", N_("Master")}, {
- "Bass", N_("Bass")}, {
- "Treble", N_("Treble")}, {
- "PCM", N_("PCM")}, {
- "Synth", N_("Synth")}, {
- "Line", N_("Line-in")}, {
- "CD", N_("CD")}, {
- "Mic", N_("Microphone")}, {
- "PC Speaker", N_("PC Speaker")}, {
- "Playback", N_("Playback")}, {
- "Capture", N_("Capture")}
- };
-
- name = snd_mixer_selem_get_name (element);
-
- GST_LOG ("[%s] num=%d,track_num=%d,flags=0x%08x,sw=%s,shared_mute_track=%p",
- name, num, track_num, flags, (sw) ? "true" : "false", shared_mute_track);
-
- track = (GstMixerTrack *) g_object_new (GST_ALSA_MIXER_TRACK_TYPE,
- "untranslated-label", name, NULL);
-
- alsa_track = (GstAlsaMixerTrack *) track;
-
- GST_LOG ("[%s] created new mixer track %p", name, track);
-
- /* This reflects the assumptions used for GstAlsaMixerTrack */
- if (!(!!(flags & GST_MIXER_TRACK_OUTPUT) ^ !!(flags & GST_MIXER_TRACK_INPUT))) {
- GST_ERROR ("Mixer track must be either output or input!");
- g_return_val_if_reached (NULL);
- }
-
- track->flags = flags;
- alsa_track->element = element;
- alsa_track->shared_mute = shared_mute_track;
- alsa_track->track_num = track_num;
- alsa_track->alsa_channels = 0;
-
- gst_alsa_mixer_track_update_alsa_capabilities (alsa_track);
-
- if (flags & GST_MIXER_TRACK_OUTPUT) {
- while (alsa_track->alsa_channels < GST_ALSA_MAX_CHANNELS &&
- snd_mixer_selem_has_playback_channel (element,
- alsa_track->alsa_channels)) {
- alsa_track->alsa_channels++;
- }
- GST_LOG ("[%s] %d output channels", name, alsa_track->alsa_channels);
- } else if (flags & GST_MIXER_TRACK_INPUT) {
- while (alsa_track->alsa_channels < GST_ALSA_MAX_CHANNELS &&
- snd_mixer_selem_has_capture_channel (element,
- alsa_track->alsa_channels)) {
- alsa_track->alsa_channels++;
- }
- GST_LOG ("[%s] %d input channels", name, alsa_track->alsa_channels);
- } else {
- g_assert_not_reached ();
- }
-
- if (sw)
- track->num_channels = 0;
- else
- track->num_channels = alsa_track->alsa_channels;
-
- /* translate the name if we can */
- label = name;
- for (i = 0; i < G_N_ELEMENTS (alsa_track_labels); ++i) {
- if (g_utf8_collate (label, alsa_track_labels[i].orig) == 0) {
- label = _(alsa_track_labels[i].trans);
- break;
- }
- }
-
- if (num == 0) {
- track->label = g_strdup_printf ("%s%s%s", label,
- append_capture ? " " : "", append_capture ? _("Capture") : "");
- } else {
- track->label = g_strdup_printf ("%s%s%s %d", label,
- append_capture ? " " : "", append_capture ? _("Capture") : "", num);
- }
-
- /* set volume information */
- if (track->num_channels > 0) {
- if ((flags & GST_MIXER_TRACK_OUTPUT))
- snd_mixer_selem_get_playback_volume_range (element, &min, &max);
- else
- snd_mixer_selem_get_capture_volume_range (element, &min, &max);
- }
- track->min_volume = (gint) min;
- track->max_volume = (gint) max;
-
- for (i = 0; i < track->num_channels; i++) {
- long tmp = 0;
-
- if (flags & GST_MIXER_TRACK_OUTPUT)
- snd_mixer_selem_get_playback_volume (element, i, &tmp);
- else
- snd_mixer_selem_get_capture_volume (element, i, &tmp);
-
- alsa_track->volumes[i] = (gint) tmp;
- }
-
- gst_alsa_mixer_track_update (alsa_track);
-
- return track;
-}
-
-void
-gst_alsa_mixer_track_update (GstAlsaMixerTrack * alsa_track)
-{
- GstMixerTrack *track = (GstMixerTrack *) alsa_track;
- gint i;
- gint audible = !(track->flags & GST_MIXER_TRACK_MUTE);
-
- if (alsa_track_has_cap (alsa_track, GST_ALSA_MIXER_TRACK_PVOLUME)) {
- /* update playback volume */
- for (i = 0; i < track->num_channels; i++) {
- long vol = 0;
-
- snd_mixer_selem_get_playback_volume (alsa_track->element, i, &vol);
- alsa_track->volumes[i] = (gint) vol;
- }
- }
-
- if (alsa_track_has_cap (alsa_track, GST_ALSA_MIXER_TRACK_CVOLUME)) {
- /* update capture volume */
- for (i = 0; i < track->num_channels; i++) {
- long vol = 0;
-
- snd_mixer_selem_get_capture_volume (alsa_track->element, i, &vol);
- alsa_track->volumes[i] = (gint) vol;
- }
- }
-
- /* Any updates in flags? */
- if (alsa_track_has_cap (alsa_track, GST_ALSA_MIXER_TRACK_PSWITCH)) {
- int v = 0;
-
- audible = 0;
- for (i = 0; i < alsa_track->alsa_channels; ++i) {
- snd_mixer_selem_get_playback_switch (alsa_track->element, i, &v);
- audible += v;
- }
-
- } else if (alsa_track_has_cap (alsa_track, GST_ALSA_MIXER_TRACK_PVOLUME) &&
- track->flags & GST_MIXER_TRACK_MUTE) {
- /* check if user has raised volume with a parallel running application */
-
- for (i = 0; i < track->num_channels; i++) {
- long vol = 0;
-
- snd_mixer_selem_get_playback_volume (alsa_track->element, i, &vol);
-
- if (vol > track->min_volume) {
- audible = 1;
- break;
- }
- }
- }
-
- if (!!(audible) != !(track->flags & GST_MIXER_TRACK_MUTE)) {
- if (audible) {
- track->flags &= ~GST_MIXER_TRACK_MUTE;
-
- if (alsa_track->shared_mute)
- ((GstMixerTrack *) (alsa_track->shared_mute))->flags &=
- ~GST_MIXER_TRACK_MUTE;
- } else {
- track->flags |= GST_MIXER_TRACK_MUTE;
-
- if (alsa_track->shared_mute)
- ((GstMixerTrack *) (alsa_track->shared_mute))->flags |=
- GST_MIXER_TRACK_MUTE;
- }
- }
-
- if (track->flags & GST_MIXER_TRACK_INPUT) {
- gint recording = track->flags & GST_MIXER_TRACK_RECORD;
-
- if (alsa_track_has_cap (alsa_track, GST_ALSA_MIXER_TRACK_CSWITCH)) {
- int v = 0;
-
- recording = 0;
- for (i = 0; i < alsa_track->alsa_channels; ++i) {
- snd_mixer_selem_get_capture_switch (alsa_track->element, i, &v);
- recording += v;
- }
-
- } else if (alsa_track_has_cap (alsa_track, GST_ALSA_MIXER_TRACK_CVOLUME) &&
- !(track->flags & GST_MIXER_TRACK_RECORD)) {
- /* check if user has raised volume with a parallel running application */
-
- for (i = 0; i < track->num_channels; i++) {
- long vol = 0;
-
- snd_mixer_selem_get_capture_volume (alsa_track->element, i, &vol);
-
- if (vol > track->min_volume) {
- recording = 1;
- break;
- }
- }
- }
-
- if (recording)
- track->flags |= GST_MIXER_TRACK_RECORD;
- else
- track->flags &= ~GST_MIXER_TRACK_RECORD;
- }
-
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsamixertrack.h
--- a/gst_plugins_base/ext/alsa/gstalsamixertrack.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/* ALSA mixer track object.
- * Copyright (C) 2003 Leif Johnson
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-
-#ifndef __GST_ALSA_MIXER_TRACK_H__
-#define __GST_ALSA_MIXER_TRACK_H__
-
-
-#include "gstalsa.h"
-#include
-
-
-G_BEGIN_DECLS
-
-
-#define GST_ALSA_MIXER_TRACK_TYPE (gst_alsa_mixer_track_get_type ())
-#define GST_ALSA_MIXER_TRACK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_MIXER_TRACK,GstAlsaMixerTrack))
-#define GST_ALSA_MIXER_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_MIXER_TRACK,GstAlsaMixerTrackClass))
-#define GST_IS_ALSA_MIXER_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_MIXER_TRACK))
-#define GST_IS_ALSA_MIXER_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_MIXER_TRACK))
-#define GST_TYPE_ALSA_MIXER_TRACK (gst_alsa_mixer_track_get_type())
-
-typedef struct _GstAlsaMixerTrack GstAlsaMixerTrack;
-typedef struct _GstAlsaMixerTrackClass GstAlsaMixerTrackClass;
-
-#define GST_ALSA_MIXER_TRACK_VOLUME (1<<0) /* common volume */
-#define GST_ALSA_MIXER_TRACK_PVOLUME (1<<1)
-#define GST_ALSA_MIXER_TRACK_CVOLUME (1<<2)
-#define GST_ALSA_MIXER_TRACK_SWITCH (1<<3) /* common switch */
-#define GST_ALSA_MIXER_TRACK_PSWITCH (1<<4)
-#define GST_ALSA_MIXER_TRACK_CSWITCH (1<<5)
-#define GST_ALSA_MIXER_TRACK_CSWITCH_EXCL (1<<6)
-
-#define GST_ALSA_MAX_CHANNELS (SND_MIXER_SCHN_LAST+1)
-
-struct _GstAlsaMixerTrack {
- GstMixerTrack parent;
- snd_mixer_elem_t *element; /* the ALSA mixer element for this track */
- GstAlsaMixerTrack *shared_mute;
- gint track_num;
- guint32 alsa_flags; /* alsa track capabilities */
- gint alsa_channels;
- gint capture_group;
- gint volumes[GST_ALSA_MAX_CHANNELS];
-};
-
-struct _GstAlsaMixerTrackClass {
- GstMixerTrackClass parent;
-};
-
-GType gst_alsa_mixer_track_get_type (void);
-GstMixerTrack * gst_alsa_mixer_track_new (snd_mixer_elem_t * element,
- gint num,
- gint track_num,
- gint flags,
- gboolean sw, /* is simple switch? */
- GstAlsaMixerTrack * shared_mute_track,
- gboolean label_append_capture);
-void gst_alsa_mixer_track_update (GstAlsaMixerTrack * alsa_track);
-
-G_END_DECLS
-
-
-#endif /* __GST_ALSA_MIXER_TRACK_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsaplugin.c
--- a/gst_plugins_base/ext/alsa/gstalsaplugin.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2001 CodeFactory AB
- * Copyright (C) 2001 Thomas Nyberg
- * Copyright (C) 2001-2002 Andy Wingo
- * Copyright (C) 2003 Benjamin Otte
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstalsasink.h"
-#include "gstalsasrc.h"
-#include "gstalsamixerelement.h"
-
-#include
-
-GST_DEBUG_CATEGORY (alsa_debug);
-
-/* ALSA debugging wrapper */
-static void
-gst_alsa_error_wrapper (const char *file, int line, const char *function,
- int err, const char *fmt, ...)
-{
-#ifndef GST_DISABLE_GST_DEBUG
- va_list args;
- gchar *str;
-
- va_start (args, fmt);
- str = g_strdup_vprintf (fmt, args);
- va_end (args);
- /* FIXME: use GST_LEVEL_ERROR here? Currently warning is used because we're
- * able to catch enough of the errors that would be printed otherwise
- */
- gst_debug_log (alsa_debug, GST_LEVEL_WARNING, file, function, line, NULL,
- "alsalib error: %s%s%s", str, err ? ": " : "",
- err ? snd_strerror (err) : "");
- g_free (str);
-#endif
-}
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
- int err;
-
- if (!gst_element_register (plugin, "alsamixer", GST_RANK_NONE,
- GST_TYPE_ALSA_MIXER_ELEMENT))
- return FALSE;
- if (!gst_element_register (plugin, "alsasrc", GST_RANK_PRIMARY,
- GST_TYPE_ALSA_SRC))
- return FALSE;
- if (!gst_element_register (plugin, "alsasink", GST_RANK_PRIMARY,
- GST_TYPE_ALSA_SINK))
- return FALSE;
-
- GST_DEBUG_CATEGORY_INIT (alsa_debug, "alsa", 0, "alsa plugins");
-
-#if ENABLE_NLS
- GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
- LOCALEDIR);
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-#endif
-
- err = snd_lib_error_set_handler (gst_alsa_error_wrapper);
- if (err != 0)
- GST_WARNING ("failed to set alsa error handler");
-
- return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "alsa",
- "ALSA plugin library",
- plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsasink.c
--- a/gst_plugins_base/ext/alsa/gstalsasink.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,983 +0,0 @@
-/* GStreamer
- * Copyright (C) 2005 Wim Taymans
- * Copyright (C) 2006 Tim-Philipp Müller
- *
- * gstalsasink.c:
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:element-alsasink
- * @short_description: play audio to an ALSA device
- * @see_also: alsasrc, alsamixer
- *
- *
- *
- * This element renders raw audio samples using the ALSA api.
- *
- * Example pipelines
- *
- * Play an Ogg/Vorbis file.
- *
- *
- * gst-launch -v filesrc location=sine.ogg ! oggdemux ! vorbisdec ! audioconvert ! audioresample ! alsasink
- *
- *
- *
- * Last reviewed on 2006-03-01 (0.10.4)
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "gstalsa.h"
-#include "gstalsasink.h"
-#include "gstalsadeviceprobe.h"
-
-#include
-
-/* elementfactory information */
-static const GstElementDetails gst_alsasink_details =
-GST_ELEMENT_DETAILS ("Audio sink (ALSA)",
- "Sink/Audio",
- "Output to a sound card via ALSA",
- "Wim Taymans ");
-
-#define DEFAULT_DEVICE "default"
-#define DEFAULT_DEVICE_NAME ""
-#define SPDIF_PERIOD_SIZE 1536
-#define SPDIF_BUFFER_SIZE 15360
-
-enum
-{
- PROP_0,
- PROP_DEVICE,
- PROP_DEVICE_NAME
-};
-
-static void gst_alsasink_init_interfaces (GType type);
-
-GST_BOILERPLATE_FULL (GstAlsaSink, gst_alsasink, GstAudioSink,
- GST_TYPE_AUDIO_SINK, gst_alsasink_init_interfaces);
-
-static void gst_alsasink_finalise (GObject * object);
-static void gst_alsasink_set_property (GObject * object,
- guint prop_id, const GValue * value, GParamSpec * pspec);
-static void gst_alsasink_get_property (GObject * object,
- guint prop_id, GValue * value, GParamSpec * pspec);
-
-static GstCaps *gst_alsasink_getcaps (GstBaseSink * bsink);
-
-static gboolean gst_alsasink_open (GstAudioSink * asink);
-static gboolean gst_alsasink_prepare (GstAudioSink * asink,
- GstRingBufferSpec * spec);
-static gboolean gst_alsasink_unprepare (GstAudioSink * asink);
-static gboolean gst_alsasink_close (GstAudioSink * asink);
-static guint gst_alsasink_write (GstAudioSink * asink, gpointer data,
- guint length);
-static guint gst_alsasink_delay (GstAudioSink * asink);
-static void gst_alsasink_reset (GstAudioSink * asink);
-
-static gint output_ref; /* 0 */
-static snd_output_t *output; /* NULL */
-static GStaticMutex output_mutex = G_STATIC_MUTEX_INIT;
-
-
-#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
-# define ALSA_SINK_FACTORY_ENDIANNESS "LITTLE_ENDIAN, BIG_ENDIAN"
-#else
-# define ALSA_SINK_FACTORY_ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN"
-#endif
-
-static GstStaticPadTemplate alsasink_sink_factory =
- GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) { " ALSA_SINK_FACTORY_ENDIANNESS " }, "
- "signed = (boolean) { TRUE, FALSE }, "
- "width = (int) 32, "
- "depth = (int) 32, "
- "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
- "audio/x-raw-int, "
- "endianness = (int) { " ALSA_SINK_FACTORY_ENDIANNESS " }, "
- "signed = (boolean) { TRUE, FALSE }, "
- "width = (int) 24, "
- "depth = (int) 24, "
- "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
- "audio/x-raw-int, "
- "endianness = (int) { " ALSA_SINK_FACTORY_ENDIANNESS " }, "
- "signed = (boolean) { TRUE, FALSE }, "
- "width = (int) 32, "
- "depth = (int) 24, "
- "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
- "audio/x-raw-int, "
- "endianness = (int) { " ALSA_SINK_FACTORY_ENDIANNESS " }, "
- "signed = (boolean) { TRUE, FALSE }, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
- "audio/x-raw-int, "
- "signed = (boolean) { TRUE, FALSE }, "
- "width = (int) 8, "
- "depth = (int) 8, "
- "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ];"
- "audio/x-iec958")
- );
-
-static void
-gst_alsasink_finalise (GObject * object)
-{
- GstAlsaSink *sink = GST_ALSA_SINK (object);
-
- g_free (sink->device);
- g_mutex_free (sink->alsa_lock);
-
- g_static_mutex_lock (&output_mutex);
- --output_ref;
- if (output_ref == 0) {
- snd_output_close (output);
- output = NULL;
- }
- g_static_mutex_unlock (&output_mutex);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-gst_alsasink_init_interfaces (GType type)
-{
- gst_alsa_type_add_device_property_probe_interface (type);
-}
-
-static void
-gst_alsasink_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_set_details (element_class, &gst_alsasink_details);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&alsasink_sink_factory));
-}
-static void
-gst_alsasink_class_init (GstAlsaSinkClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
- GstBaseSinkClass *gstbasesink_class;
- GstBaseAudioSinkClass *gstbaseaudiosink_class;
- GstAudioSinkClass *gstaudiosink_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstbasesink_class = (GstBaseSinkClass *) klass;
- gstbaseaudiosink_class = (GstBaseAudioSinkClass *) klass;
- gstaudiosink_class = (GstAudioSinkClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_alsasink_finalise);
- gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_alsasink_get_property);
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_alsasink_set_property);
-
- gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_alsasink_getcaps);
-
- gstaudiosink_class->open = GST_DEBUG_FUNCPTR (gst_alsasink_open);
- gstaudiosink_class->prepare = GST_DEBUG_FUNCPTR (gst_alsasink_prepare);
- gstaudiosink_class->unprepare = GST_DEBUG_FUNCPTR (gst_alsasink_unprepare);
- gstaudiosink_class->close = GST_DEBUG_FUNCPTR (gst_alsasink_close);
- gstaudiosink_class->write = GST_DEBUG_FUNCPTR (gst_alsasink_write);
- gstaudiosink_class->delay = GST_DEBUG_FUNCPTR (gst_alsasink_delay);
- gstaudiosink_class->reset = GST_DEBUG_FUNCPTR (gst_alsasink_reset);
-
- g_object_class_install_property (gobject_class, PROP_DEVICE,
- g_param_spec_string ("device", "Device",
- "ALSA device, as defined in an asound configuration file",
- DEFAULT_DEVICE, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_DEVICE_NAME,
- g_param_spec_string ("device-name", "Device name",
- "Human-readable name of the sound device", DEFAULT_DEVICE_NAME,
- G_PARAM_READABLE));
-}
-
-static void
-gst_alsasink_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstAlsaSink *sink;
-
- sink = GST_ALSA_SINK (object);
-
- switch (prop_id) {
- case PROP_DEVICE:
- g_free (sink->device);
- sink->device = g_value_dup_string (value);
- /* setting NULL restores the default device */
- if (sink->device == NULL) {
- sink->device = g_strdup (DEFAULT_DEVICE);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_alsasink_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstAlsaSink *sink;
-
- sink = GST_ALSA_SINK (object);
-
- switch (prop_id) {
- case PROP_DEVICE:
- g_value_set_string (value, sink->device);
- break;
- case PROP_DEVICE_NAME:
- g_value_take_string (value,
- gst_alsa_find_device_name (GST_OBJECT_CAST (sink),
- sink->device, sink->handle, SND_PCM_STREAM_PLAYBACK));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_alsasink_init (GstAlsaSink * alsasink, GstAlsaSinkClass * g_class)
-{
- GST_DEBUG_OBJECT (alsasink, "initializing alsasink");
-
- alsasink->device = g_strdup (DEFAULT_DEVICE);
- alsasink->handle = NULL;
- alsasink->cached_caps = NULL;
- alsasink->alsa_lock = g_mutex_new ();
-
- g_static_mutex_lock (&output_mutex);
- if (output_ref == 0) {
- snd_output_stdio_attach (&output, stdout, 0);
- ++output_ref;
- }
- g_static_mutex_unlock (&output_mutex);
-}
-
-#define CHECK(call, error) \
-G_STMT_START { \
-if ((err = call) < 0) \
- goto error; \
-} G_STMT_END;
-
-static GstCaps *
-gst_alsasink_getcaps (GstBaseSink * bsink)
-{
- GstElementClass *element_class;
- GstPadTemplate *pad_template;
- GstAlsaSink *sink = GST_ALSA_SINK (bsink);
- GstCaps *caps;
-
- if (sink->handle == NULL) {
- GST_DEBUG_OBJECT (sink, "device not open, using template caps");
- return NULL; /* base class will get template caps for us */
- }
-
- if (sink->cached_caps) {
- GST_LOG_OBJECT (sink, "Returning cached caps");
- return gst_caps_ref (sink->cached_caps);
- }
-
- element_class = GST_ELEMENT_GET_CLASS (sink);
- pad_template = gst_element_class_get_pad_template (element_class, "sink");
- g_return_val_if_fail (pad_template != NULL, NULL);
-
- caps = gst_alsa_probe_supported_formats (GST_OBJECT (sink), sink->handle,
- gst_pad_template_get_caps (pad_template));
-
- if (caps) {
- sink->cached_caps = gst_caps_ref (caps);
- }
-
- GST_INFO_OBJECT (sink, "returning caps %" GST_PTR_FORMAT, caps);
-
- return caps;
-}
-
-static int
-set_hwparams (GstAlsaSink * alsa)
-{
- guint rrate;
- gint err, dir;
- snd_pcm_hw_params_t *params;
- guint period_time, buffer_time;
-
- snd_pcm_hw_params_malloc (¶ms);
-
- GST_DEBUG_OBJECT (alsa, "Negotiating to %d channels @ %d Hz (format = %s) "
- "SPDIF (%d)", alsa->channels, alsa->rate,
- snd_pcm_format_name (alsa->format), alsa->iec958);
-
- /* start with requested values, if we cannot configure alsa for those values,
- * we set these values to -1, which will leave the default alsa values */
- buffer_time = alsa->buffer_time;
- period_time = alsa->period_time;
-
-retry:
- /* choose all parameters */
- CHECK (snd_pcm_hw_params_any (alsa->handle, params), no_config);
- /* set the interleaved read/write format */
- CHECK (snd_pcm_hw_params_set_access (alsa->handle, params, alsa->access),
- wrong_access);
- /* set the sample format */
- if (alsa->iec958) {
- /* Try to use big endian first else fallback to le and swap bytes */
- if (snd_pcm_hw_params_set_format (alsa->handle, params, alsa->format) < 0) {
- alsa->format = SND_PCM_FORMAT_S16_LE;
- alsa->need_swap = TRUE;
- GST_DEBUG_OBJECT (alsa, "falling back to little endian with swapping");
- } else {
- alsa->need_swap = FALSE;
- }
- }
- CHECK (snd_pcm_hw_params_set_format (alsa->handle, params, alsa->format),
- no_sample_format);
- /* set the count of channels */
- CHECK (snd_pcm_hw_params_set_channels (alsa->handle, params, alsa->channels),
- no_channels);
- /* set the stream rate */
- rrate = alsa->rate;
- CHECK (snd_pcm_hw_params_set_rate_near (alsa->handle, params, &rrate, NULL),
- no_rate);
- if (rrate != alsa->rate)
- goto rate_match;
-
- /* get and dump some limits */
- {
- guint min, max;
-
- snd_pcm_hw_params_get_buffer_time_min (params, &min, &dir);
- snd_pcm_hw_params_get_buffer_time_max (params, &max, &dir);
-
- GST_DEBUG_OBJECT (alsa, "buffer time %u, min %u, max %u",
- alsa->buffer_time, min, max);
-
- snd_pcm_hw_params_get_period_time_min (params, &min, &dir);
- snd_pcm_hw_params_get_period_time_max (params, &max, &dir);
-
- GST_DEBUG_OBJECT (alsa, "period time %u, min %u, max %u",
- alsa->period_time, min, max);
-
- snd_pcm_hw_params_get_periods_min (params, &min, &dir);
- snd_pcm_hw_params_get_periods_max (params, &max, &dir);
-
- GST_DEBUG_OBJECT (alsa, "periods min %u, max %u", min, max);
- }
-
- /* now try to configure the buffer time and period time, if one
- * of those fail, we fall back to the defaults and emit a warning. */
- if (buffer_time != -1 && !alsa->iec958) {
- /* set the buffer time */
- if ((err = snd_pcm_hw_params_set_buffer_time_near (alsa->handle, params,
- &buffer_time, &dir)) < 0) {
- GST_ELEMENT_WARNING (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set buffer time %i for playback: %s",
- buffer_time, snd_strerror (err)));
- /* disable buffer_time the next round */
- buffer_time = -1;
- goto retry;
- }
- GST_DEBUG_OBJECT (alsa, "buffer time %u", buffer_time);
- }
- if (period_time != -1 && !alsa->iec958) {
- /* set the period time */
- if ((err = snd_pcm_hw_params_set_period_time_near (alsa->handle, params,
- &period_time, &dir)) < 0) {
- GST_ELEMENT_WARNING (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set period time %i for playback: %s",
- period_time, snd_strerror (err)));
- /* disable period_time the next round */
- period_time = -1;
- goto retry;
- }
- GST_DEBUG_OBJECT (alsa, "period time %u", period_time);
- }
-
- /* Set buffer size and period size manually for SPDIF */
- if (G_UNLIKELY (alsa->iec958)) {
- snd_pcm_uframes_t buffer_size = SPDIF_BUFFER_SIZE;
- snd_pcm_uframes_t period_size = SPDIF_PERIOD_SIZE;
-
- CHECK (snd_pcm_hw_params_set_buffer_size_near (alsa->handle, params,
- &buffer_size), buffer_size);
- CHECK (snd_pcm_hw_params_set_period_size_near (alsa->handle, params,
- &period_size, NULL), period_size);
- }
-
- /* write the parameters to device */
- CHECK (snd_pcm_hw_params (alsa->handle, params), set_hw_params);
-
- /* now get the configured values */
- CHECK (snd_pcm_hw_params_get_buffer_size (params, &alsa->buffer_size),
- buffer_size);
- CHECK (snd_pcm_hw_params_get_period_size (params, &alsa->period_size, &dir),
- period_size);
-
- GST_DEBUG_OBJECT (alsa, "buffer size %lu, period size %lu", alsa->buffer_size,
- alsa->period_size);
-
- snd_pcm_hw_params_free (params);
- return 0;
-
- /* ERRORS */
-no_config:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Broken configuration for playback: no configurations available: %s",
- snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-wrong_access:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Access type not available for playback: %s", snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-no_sample_format:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Sample format not available for playback: %s", snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-no_channels:
- {
- gchar *msg = NULL;
-
- if ((alsa->channels) == 1)
- msg = g_strdup (_("Could not open device for playback in mono mode."));
- if ((alsa->channels) == 2)
- msg = g_strdup (_("Could not open device for playback in stereo mode."));
- if ((alsa->channels) > 2)
- msg =
- g_strdup_printf (_
- ("Could not open device for playback in %d-channel mode."),
- alsa->channels);
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (msg), (snd_strerror (err)));
- g_free (msg);
- snd_pcm_hw_params_free (params);
- return err;
- }
-no_rate:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Rate %iHz not available for playback: %s",
- alsa->rate, snd_strerror (err)));
- return err;
- }
-rate_match:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Rate doesn't match (requested %iHz, get %iHz)", alsa->rate, err));
- snd_pcm_hw_params_free (params);
- return -EINVAL;
- }
-buffer_size:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to get buffer size for playback: %s", snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-period_size:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to get period size for playback: %s", snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-set_hw_params:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set hw params for playback: %s", snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-}
-
-static int
-set_swparams (GstAlsaSink * alsa)
-{
- int err;
- snd_pcm_sw_params_t *params;
-
- snd_pcm_sw_params_malloc (¶ms);
-
- /* get the current swparams */
- CHECK (snd_pcm_sw_params_current (alsa->handle, params), no_config);
- /* start the transfer when the buffer is almost full: */
- /* (buffer_size / avail_min) * avail_min */
- CHECK (snd_pcm_sw_params_set_start_threshold (alsa->handle, params,
- (alsa->buffer_size / alsa->period_size) * alsa->period_size),
- start_threshold);
-
- /* allow the transfer when at least period_size samples can be processed */
- CHECK (snd_pcm_sw_params_set_avail_min (alsa->handle, params,
- alsa->period_size), set_avail);
-
-#if GST_CHECK_ALSA_VERSION(1,0,16)
- /* snd_pcm_sw_params_set_xfer_align() is deprecated, alignment is always 1 */
-#else
- /* align all transfers to 1 sample */
- CHECK (snd_pcm_sw_params_set_xfer_align (alsa->handle, params, 1), set_align);
-#endif
-
- /* write the parameters to the playback device */
- CHECK (snd_pcm_sw_params (alsa->handle, params), set_sw_params);
-
- snd_pcm_sw_params_free (params);
- return 0;
-
- /* ERRORS */
-no_config:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to determine current swparams for playback: %s",
- snd_strerror (err)));
- snd_pcm_sw_params_free (params);
- return err;
- }
-start_threshold:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set start threshold mode for playback: %s",
- snd_strerror (err)));
- snd_pcm_sw_params_free (params);
- return err;
- }
-set_avail:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set avail min for playback: %s", snd_strerror (err)));
- snd_pcm_sw_params_free (params);
- return err;
- }
-#if !GST_CHECK_ALSA_VERSION(1,0,16)
-set_align:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set transfer align for playback: %s", snd_strerror (err)));
- snd_pcm_sw_params_free (params);
- return err;
- }
-#endif
-set_sw_params:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set sw params for playback: %s", snd_strerror (err)));
- snd_pcm_sw_params_free (params);
- return err;
- }
-}
-
-static gboolean
-alsasink_parse_spec (GstAlsaSink * alsa, GstRingBufferSpec * spec)
-{
- /* Initialize our boolean */
- alsa->iec958 = FALSE;
-
- switch (spec->type) {
- case GST_BUFTYPE_LINEAR:
- GST_DEBUG_OBJECT (alsa,
- "Linear format : depth=%d, width=%d, sign=%d, bigend=%d", spec->depth,
- spec->width, spec->sign, spec->bigend);
-
- alsa->format = snd_pcm_build_linear_format (spec->depth, spec->width,
- spec->sign ? 0 : 1, spec->bigend ? 1 : 0);
- break;
- case GST_BUFTYPE_FLOAT:
- switch (spec->format) {
- case GST_FLOAT32_LE:
- alsa->format = SND_PCM_FORMAT_FLOAT_LE;
- break;
- case GST_FLOAT32_BE:
- alsa->format = SND_PCM_FORMAT_FLOAT_BE;
- break;
- case GST_FLOAT64_LE:
- alsa->format = SND_PCM_FORMAT_FLOAT64_LE;
- break;
- case GST_FLOAT64_BE:
- alsa->format = SND_PCM_FORMAT_FLOAT64_BE;
- break;
- default:
- goto error;
- }
- break;
- case GST_BUFTYPE_A_LAW:
- alsa->format = SND_PCM_FORMAT_A_LAW;
- break;
- case GST_BUFTYPE_MU_LAW:
- alsa->format = SND_PCM_FORMAT_MU_LAW;
- break;
- case GST_BUFTYPE_IEC958:
- alsa->format = SND_PCM_FORMAT_S16_BE;
- alsa->iec958 = TRUE;
- break;
- default:
- goto error;
-
- }
- alsa->rate = spec->rate;
- alsa->channels = spec->channels;
- alsa->buffer_time = spec->buffer_time;
- alsa->period_time = spec->latency_time;
- alsa->access = SND_PCM_ACCESS_RW_INTERLEAVED;
-
- return TRUE;
-
- /* ERRORS */
-error:
- {
- return FALSE;
- }
-}
-
-static gboolean
-gst_alsasink_open (GstAudioSink * asink)
-{
- GstAlsaSink *alsa;
- gint err;
-
- alsa = GST_ALSA_SINK (asink);
-
- CHECK (snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_PLAYBACK,
- SND_PCM_NONBLOCK), open_error);
- GST_LOG_OBJECT (alsa, "Opened device %s", alsa->device);
-
- return TRUE;
-
- /* ERRORS */
-open_error:
- {
- if (err == -EBUSY) {
- GST_ELEMENT_ERROR (alsa, RESOURCE, BUSY,
- (_("Could not open audio device for playback. "
- "Device is being used by another application.")),
- ("Device '%s' is busy", alsa->device));
- } else {
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_WRITE,
- (_("Could not open audio device for playback.")),
- ("Playback open error on device '%s': %s", alsa->device,
- snd_strerror (err)));
- }
- return FALSE;
- }
-}
-
-static gboolean
-gst_alsasink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
-{
- GstAlsaSink *alsa;
- gint err;
-
- alsa = GST_ALSA_SINK (asink);
-
- if (spec->format == GST_IEC958) {
- snd_pcm_close (alsa->handle);
- alsa->handle = gst_alsa_open_iec958_pcm (GST_OBJECT (alsa));
- if (G_UNLIKELY (!alsa->handle)) {
- goto no_iec958;
- }
- }
-
- if (!alsasink_parse_spec (alsa, spec))
- goto spec_parse;
-
- CHECK (snd_pcm_nonblock (alsa->handle, 0), non_block);
-
- CHECK (set_hwparams (alsa), hw_params_failed);
- CHECK (set_swparams (alsa), sw_params_failed);
-
- alsa->bytes_per_sample = spec->bytes_per_sample;
- spec->segsize = alsa->period_size * spec->bytes_per_sample;
- spec->segtotal = alsa->buffer_size / alsa->period_size;
-
- {
- snd_output_t *out_buf = NULL;
- char *msg = NULL;
-
- snd_output_buffer_open (&out_buf);
- snd_pcm_dump_hw_setup (alsa->handle, out_buf);
- snd_output_buffer_string (out_buf, &msg);
- GST_DEBUG_OBJECT (alsa, "Hardware setup: \n%s", msg);
- snd_output_close (out_buf);
- snd_output_buffer_open (&out_buf);
- snd_pcm_dump_sw_setup (alsa->handle, out_buf);
- snd_output_buffer_string (out_buf, &msg);
- GST_DEBUG_OBJECT (alsa, "Software setup: \n%s", msg);
- snd_output_close (out_buf);
- }
-
- return TRUE;
-
- /* ERRORS */
-no_iec958:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_WRITE, (NULL),
- ("Could not open IEC958 (SPDIF) device for playback"));
- return FALSE;
- }
-spec_parse:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Error parsing spec"));
- return FALSE;
- }
-non_block:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Could not set device to blocking: %s", snd_strerror (err)));
- return FALSE;
- }
-hw_params_failed:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Setting of hwparams failed: %s", snd_strerror (err)));
- return FALSE;
- }
-sw_params_failed:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Setting of swparams failed: %s", snd_strerror (err)));
- return FALSE;
- }
-}
-
-static gboolean
-gst_alsasink_unprepare (GstAudioSink * asink)
-{
- GstAlsaSink *alsa;
- gint err;
-
- alsa = GST_ALSA_SINK (asink);
-
- CHECK (snd_pcm_drop (alsa->handle), drop);
-
- CHECK (snd_pcm_hw_free (alsa->handle), hw_free);
-
- CHECK (snd_pcm_nonblock (alsa->handle, 1), non_block);
-
- return TRUE;
-
- /* ERRORS */
-drop:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Could not drop samples: %s", snd_strerror (err)));
- return FALSE;
- }
-hw_free:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Could not free hw params: %s", snd_strerror (err)));
- return FALSE;
- }
-non_block:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Could not set device to nonblocking: %s", snd_strerror (err)));
- return FALSE;
- }
-}
-
-static gboolean
-gst_alsasink_close (GstAudioSink * asink)
-{
- GstAlsaSink *alsa = GST_ALSA_SINK (asink);
- gint err;
-
- if (alsa->handle) {
- CHECK (snd_pcm_close (alsa->handle), close_error);
- alsa->handle = NULL;
- }
- gst_caps_replace (&alsa->cached_caps, NULL);
-
- return TRUE;
-
- /* ERRORS */
-close_error:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, CLOSE, (NULL),
- ("Playback close error: %s", snd_strerror (err)));
- return FALSE;
- }
-}
-
-
-/*
- * Underrun and suspend recovery
- */
-static gint
-xrun_recovery (GstAlsaSink * alsa, snd_pcm_t * handle, gint err)
-{
- GST_DEBUG_OBJECT (alsa, "xrun recovery %d", err);
-
- if (err == -EPIPE) { /* under-run */
- err = snd_pcm_prepare (handle);
- if (err < 0)
- GST_WARNING_OBJECT (alsa,
- "Can't recovery from underrun, prepare failed: %s",
- snd_strerror (err));
- return 0;
- } else if (err == -ESTRPIPE) {
- while ((err = snd_pcm_resume (handle)) == -EAGAIN)
- g_usleep (100); /* wait until the suspend flag is released */
-
- if (err < 0) {
- err = snd_pcm_prepare (handle);
- if (err < 0)
- GST_WARNING_OBJECT (alsa,
- "Can't recovery from suspend, prepare failed: %s",
- snd_strerror (err));
- }
- return 0;
- }
- return err;
-}
-
-static guint
-gst_alsasink_write (GstAudioSink * asink, gpointer data, guint length)
-{
- GstAlsaSink *alsa;
- gint err;
- gint cptr;
- gint16 *ptr = data;
-
- alsa = GST_ALSA_SINK (asink);
-
- if (alsa->iec958 && alsa->need_swap) {
- guint i;
-
- GST_DEBUG_OBJECT (asink, "swapping bytes");
- for (i = 0; i < length / 2; i++) {
- ptr[i] = GUINT16_SWAP_LE_BE (ptr[i]);
- }
- }
-
- GST_LOG_OBJECT (asink, "received audio samples buffer of %u bytes", length);
-
- cptr = length / alsa->bytes_per_sample;
-
- GST_ALSA_SINK_LOCK (asink);
- while (cptr > 0) {
- err = snd_pcm_writei (alsa->handle, ptr, cptr);
-
- GST_DEBUG_OBJECT (asink, "written %d frames out of %d", err, cptr);
- if (err < 0) {
- GST_DEBUG_OBJECT (asink, "Write error: %s", snd_strerror (err));
- if (err == -EAGAIN) {
- continue;
- } else if (xrun_recovery (alsa, alsa->handle, err) < 0) {
- goto write_error;
- }
- continue;
- }
-
- ptr += snd_pcm_frames_to_bytes (alsa->handle, err);
- cptr -= err;
- }
- GST_ALSA_SINK_UNLOCK (asink);
-
- return length - (cptr * alsa->bytes_per_sample);
-
-write_error:
- {
- GST_ALSA_SINK_UNLOCK (asink);
- return length; /* skip one period */
- }
-}
-
-static guint
-gst_alsasink_delay (GstAudioSink * asink)
-{
- GstAlsaSink *alsa;
- snd_pcm_sframes_t delay;
- int res;
-
- alsa = GST_ALSA_SINK (asink);
-
- res = snd_pcm_delay (alsa->handle, &delay);
- if (G_UNLIKELY (res < 0)) {
- /* on errors, report 0 delay */
- GST_DEBUG_OBJECT (alsa, "snd_pcm_delay returned %d", res);
- delay = 0;
- }
- if (G_UNLIKELY (delay < 0)) {
- /* make sure we never return a negative delay */
- GST_WARNING_OBJECT (alsa, "snd_pcm_delay returned negative delay");
- delay = 0;
- }
-
- return delay;
-}
-
-static void
-gst_alsasink_reset (GstAudioSink * asink)
-{
- GstAlsaSink *alsa;
- gint err;
-
- alsa = GST_ALSA_SINK (asink);
-
- GST_ALSA_SINK_LOCK (asink);
- GST_DEBUG_OBJECT (alsa, "drop");
- CHECK (snd_pcm_drop (alsa->handle), drop_error);
- GST_DEBUG_OBJECT (alsa, "prepare");
- CHECK (snd_pcm_prepare (alsa->handle), prepare_error);
- GST_DEBUG_OBJECT (alsa, "reset done");
- GST_ALSA_SINK_UNLOCK (asink);
-
- return;
-
- /* ERRORS */
-drop_error:
- {
- GST_ERROR_OBJECT (alsa, "alsa-reset: pcm drop error: %s",
- snd_strerror (err));
- GST_ALSA_SINK_UNLOCK (asink);
- return;
- }
-prepare_error:
- {
- GST_ERROR_OBJECT (alsa, "alsa-reset: pcm prepare error: %s",
- snd_strerror (err));
- GST_ALSA_SINK_UNLOCK (asink);
- return;
- }
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsasink.h
--- a/gst_plugins_base/ext/alsa/gstalsasink.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/* GStreamer
- * Copyright (C) 2005 Wim Taymans
- *
- * gstalsasink.h:
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-#ifndef __GST_ALSASINK_H__
-#define __GST_ALSASINK_H__
-
-#include
-#include
-#include
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_ALSA_SINK (gst_alsasink_get_type())
-#define GST_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_SINK,GstAlsaSink))
-#define GST_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_SINK,GstAlsaSinkClass))
-#define GST_IS_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_SINK))
-#define GST_IS_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_SINK))
-#define GST_ALSA_SINK_CAST(obj) ((GstAlsaSink *) (obj))
-
-typedef struct _GstAlsaSink GstAlsaSink;
-typedef struct _GstAlsaSinkClass GstAlsaSinkClass;
-
-#define GST_ALSA_SINK_GET_LOCK(obj) (GST_ALSA_SINK_CAST (obj)->alsa_lock)
-#define GST_ALSA_SINK_LOCK(obj) (g_mutex_lock (GST_ALSA_SINK_GET_LOCK (obj)))
-#define GST_ALSA_SINK_UNLOCK(obj) (g_mutex_unlock (GST_ALSA_SINK_GET_LOCK (obj)))
-
-/**
- * GstAlsaSink:
- *
- * Opaque data structure
- */
-struct _GstAlsaSink {
- GstAudioSink sink;
-
- gchar *device;
-
- snd_pcm_t *handle;
- snd_pcm_hw_params_t *hwparams;
- snd_pcm_sw_params_t *swparams;
-
- snd_pcm_access_t access;
- snd_pcm_format_t format;
- guint rate;
- guint channels;
- gint bytes_per_sample;
- gboolean iec958;
- gboolean need_swap;
-
- guint buffer_time;
- guint period_time;
- snd_pcm_uframes_t buffer_size;
- snd_pcm_uframes_t period_size;
-
- GstCaps *cached_caps;
-
- GMutex *alsa_lock;
-};
-
-struct _GstAlsaSinkClass {
- GstAudioSinkClass parent_class;
-};
-
-GType gst_alsasink_get_type(void);
-
-G_END_DECLS
-
-#endif /* __GST_ALSASINK_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsasrc.c
--- a/gst_plugins_base/ext/alsa/gstalsasrc.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,881 +0,0 @@
-/* GStreamer
- * Copyright (C) 2005 Wim Taymans
- *
- * gstalsasrc.c:
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:element-alsasrc
- * @short_description: capture audio from an alsa device
- * @see_also: alsasink, alsamixer
- *
- *
- *
- * This element reads data from an audio card using the ALSA API.
- *
- * Example pipelines
- *
- * Record from a sound card using ALSA and encode to Ogg/Vorbis.
- *
- *
- * gst-launch -v alsasrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=alsasrc.ogg
- *
- *
- *
- * Last reviewed on 2006-03-01 (0.10.4)
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "gstalsasrc.h"
-#include "gstalsadeviceprobe.h"
-
-#include
-
-/* elementfactory information */
-static const GstElementDetails gst_alsasrc_details =
-GST_ELEMENT_DETAILS ("Audio source (ALSA)",
- "Source/Audio",
- "Read from a sound card via ALSA",
- "Wim Taymans ");
-
-#define DEFAULT_PROP_DEVICE "default"
-#define DEFAULT_PROP_DEVICE_NAME ""
-
-enum
-{
- PROP_0,
- PROP_DEVICE,
- PROP_DEVICE_NAME,
-};
-
-static void gst_alsasrc_init_interfaces (GType type);
-
-GST_BOILERPLATE_FULL (GstAlsaSrc, gst_alsasrc, GstAudioSrc,
- GST_TYPE_AUDIO_SRC, gst_alsasrc_init_interfaces);
-
-GST_IMPLEMENT_ALSA_MIXER_METHODS (GstAlsaSrc, gst_alsasrc_mixer);
-
-static void gst_alsasrc_finalize (GObject * object);
-static void gst_alsasrc_set_property (GObject * object,
- guint prop_id, const GValue * value, GParamSpec * pspec);
-static void gst_alsasrc_get_property (GObject * object,
- guint prop_id, GValue * value, GParamSpec * pspec);
-
-static GstCaps *gst_alsasrc_getcaps (GstBaseSrc * bsrc);
-
-static gboolean gst_alsasrc_open (GstAudioSrc * asrc);
-static gboolean gst_alsasrc_prepare (GstAudioSrc * asrc,
- GstRingBufferSpec * spec);
-static gboolean gst_alsasrc_unprepare (GstAudioSrc * asrc);
-static gboolean gst_alsasrc_close (GstAudioSrc * asrc);
-static guint gst_alsasrc_read (GstAudioSrc * asrc, gpointer data, guint length);
-static guint gst_alsasrc_delay (GstAudioSrc * asrc);
-static void gst_alsasrc_reset (GstAudioSrc * asrc);
-
-/* AlsaSrc signals and args */
-enum
-{
- LAST_SIGNAL
-};
-
-#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
-# define ALSA_SRC_FACTORY_ENDIANNESS "LITTLE_ENDIAN, BIG_ENDIAN"
-#else
-# define ALSA_SRC_FACTORY_ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN"
-#endif
-
-static GstStaticPadTemplate alsasrc_src_factory =
- GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
- "signed = (boolean) { TRUE, FALSE }, "
- "width = (int) 32, "
- "depth = (int) 32, "
- "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
- "audio/x-raw-int, "
- "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
- "signed = (boolean) { TRUE, FALSE }, "
- "width = (int) 32, "
- "depth = (int) 24, "
- "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
- "audio/x-raw-int, "
- "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
- "signed = (boolean) { TRUE, FALSE }, "
- "width = (int) 24, "
- "depth = (int) 24, "
- "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
- "audio/x-raw-int, "
- "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, "
- "signed = (boolean) { TRUE, FALSE }, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
- "audio/x-raw-int, "
- "signed = (boolean) { TRUE, FALSE }, "
- "width = (int) 8, "
- "depth = (int) 8, "
- "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
- );
-
-static void
-gst_alsasrc_finalize (GObject * object)
-{
- GstAlsaSrc *src = GST_ALSA_SRC (object);
-
- g_free (src->device);
- g_mutex_free (src->alsa_lock);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static gboolean
-gst_alsasrc_interface_supported (GstAlsaSrc * this, GType interface_type)
-{
- /* only support this one interface (wrapped by GstImplementsInterface) */
- g_assert (interface_type == GST_TYPE_MIXER);
-
- return gst_alsasrc_mixer_supported (this, interface_type);
-}
-
-static void
-gst_implements_interface_init (GstImplementsInterfaceClass * klass)
-{
- klass->supported = (gpointer) gst_alsasrc_interface_supported;
-}
-
-static void
-gst_alsasrc_init_interfaces (GType type)
-{
- static const GInterfaceInfo implements_iface_info = {
- (GInterfaceInitFunc) gst_implements_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo mixer_iface_info = {
- (GInterfaceInitFunc) gst_alsasrc_mixer_interface_init,
- NULL,
- NULL,
- };
-
- g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE,
- &implements_iface_info);
- g_type_add_interface_static (type, GST_TYPE_MIXER, &mixer_iface_info);
-
- gst_alsa_type_add_device_property_probe_interface (type);
-}
-
-static void
-gst_alsasrc_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_set_details (element_class, &gst_alsasrc_details);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&alsasrc_src_factory));
-}
-
-static void
-gst_alsasrc_class_init (GstAlsaSrcClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
- GstBaseSrcClass *gstbasesrc_class;
- GstBaseAudioSrcClass *gstbaseaudiosrc_class;
- GstAudioSrcClass *gstaudiosrc_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstbasesrc_class = (GstBaseSrcClass *) klass;
- gstbaseaudiosrc_class = (GstBaseAudioSrcClass *) klass;
- gstaudiosrc_class = (GstAudioSrcClass *) klass;
-
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_alsasrc_finalize);
- gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_alsasrc_get_property);
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_alsasrc_set_property);
-
- gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_alsasrc_getcaps);
-
- gstaudiosrc_class->open = GST_DEBUG_FUNCPTR (gst_alsasrc_open);
- gstaudiosrc_class->prepare = GST_DEBUG_FUNCPTR (gst_alsasrc_prepare);
- gstaudiosrc_class->unprepare = GST_DEBUG_FUNCPTR (gst_alsasrc_unprepare);
- gstaudiosrc_class->close = GST_DEBUG_FUNCPTR (gst_alsasrc_close);
- gstaudiosrc_class->read = GST_DEBUG_FUNCPTR (gst_alsasrc_read);
- gstaudiosrc_class->delay = GST_DEBUG_FUNCPTR (gst_alsasrc_delay);
- gstaudiosrc_class->reset = GST_DEBUG_FUNCPTR (gst_alsasrc_reset);
-
- g_object_class_install_property (gobject_class, PROP_DEVICE,
- g_param_spec_string ("device", "Device",
- "ALSA device, as defined in an asound configuration file",
- DEFAULT_PROP_DEVICE, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_DEVICE_NAME,
- g_param_spec_string ("device-name", "Device name",
- "Human-readable name of the sound device",
- DEFAULT_PROP_DEVICE_NAME, G_PARAM_READABLE));
-}
-
-static void
-gst_alsasrc_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstAlsaSrc *src;
-
- src = GST_ALSA_SRC (object);
-
- switch (prop_id) {
- case PROP_DEVICE:
- g_free (src->device);
- src->device = g_value_dup_string (value);
- if (src->device == NULL) {
- src->device = g_strdup (DEFAULT_PROP_DEVICE);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_alsasrc_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstAlsaSrc *src;
-
- src = GST_ALSA_SRC (object);
-
- switch (prop_id) {
- case PROP_DEVICE:
- g_value_set_string (value, src->device);
- break;
- case PROP_DEVICE_NAME:
- g_value_take_string (value,
- gst_alsa_find_device_name (GST_OBJECT_CAST (src),
- src->device, src->handle, SND_PCM_STREAM_CAPTURE));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_alsasrc_init (GstAlsaSrc * alsasrc, GstAlsaSrcClass * g_class)
-{
- GST_DEBUG_OBJECT (alsasrc, "initializing");
-
- alsasrc->device = g_strdup (DEFAULT_PROP_DEVICE);
- alsasrc->cached_caps = NULL;
-
- alsasrc->alsa_lock = g_mutex_new ();
-}
-
-#define CHECK(call, error) \
-G_STMT_START { \
-if ((err = call) < 0) \
- goto error; \
-} G_STMT_END;
-
-
-static GstCaps *
-gst_alsasrc_getcaps (GstBaseSrc * bsrc)
-{
- GstElementClass *element_class;
- GstPadTemplate *pad_template;
- GstAlsaSrc *src;
- GstCaps *caps;
-
- src = GST_ALSA_SRC (bsrc);
-
- if (src->handle == NULL) {
- GST_DEBUG_OBJECT (src, "device not open, using template caps");
- return NULL; /* base class will get template caps for us */
- }
-
- if (src->cached_caps) {
- GST_LOG_OBJECT (src, "Returning cached caps");
- return gst_caps_ref (src->cached_caps);
- }
-
- element_class = GST_ELEMENT_GET_CLASS (src);
- pad_template = gst_element_class_get_pad_template (element_class, "src");
- g_return_val_if_fail (pad_template != NULL, NULL);
-
- caps = gst_alsa_probe_supported_formats (GST_OBJECT (src), src->handle,
- gst_pad_template_get_caps (pad_template));
-
- if (caps) {
- src->cached_caps = gst_caps_ref (caps);
- }
-
- GST_INFO_OBJECT (src, "returning caps %" GST_PTR_FORMAT, caps);
-
- return caps;
-}
-
-static int
-set_hwparams (GstAlsaSrc * alsa)
-{
- guint rrate;
- gint err, dir;
- snd_pcm_hw_params_t *params;
-
- snd_pcm_hw_params_malloc (¶ms);
-
- /* choose all parameters */
- CHECK (snd_pcm_hw_params_any (alsa->handle, params), no_config);
- /* set the interleaved read/write format */
- CHECK (snd_pcm_hw_params_set_access (alsa->handle, params, alsa->access),
- wrong_access);
- /* set the sample format */
- CHECK (snd_pcm_hw_params_set_format (alsa->handle, params, alsa->format),
- no_sample_format);
- /* set the count of channels */
- CHECK (snd_pcm_hw_params_set_channels (alsa->handle, params, alsa->channels),
- no_channels);
- /* set the stream rate */
- rrate = alsa->rate;
- CHECK (snd_pcm_hw_params_set_rate_near (alsa->handle, params, &rrate, NULL),
- no_rate);
- if (rrate != alsa->rate)
- goto rate_match;
-
- if (alsa->buffer_time != -1) {
- /* set the buffer time */
- CHECK (snd_pcm_hw_params_set_buffer_time_near (alsa->handle, params,
- &alsa->buffer_time, &dir), buffer_time);
- }
- if (alsa->period_time != -1) {
- /* set the period time */
- CHECK (snd_pcm_hw_params_set_period_time_near (alsa->handle, params,
- &alsa->period_time, &dir), period_time);
- }
-
- /* write the parameters to device */
- CHECK (snd_pcm_hw_params (alsa->handle, params), set_hw_params);
-
- CHECK (snd_pcm_hw_params_get_buffer_size (params, &alsa->buffer_size),
- buffer_size);
-
- CHECK (snd_pcm_hw_params_get_period_size (params, &alsa->period_size, &dir),
- period_size);
-
- snd_pcm_hw_params_free (params);
- return 0;
-
- /* ERRORS */
-no_config:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Broken configuration for recording: no configurations available: %s",
- snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-wrong_access:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Access type not available for recording: %s", snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-no_sample_format:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Sample format not available for recording: %s", snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-no_channels:
- {
- gchar *msg = NULL;
-
- if ((alsa->channels) == 1)
- msg = g_strdup (_("Could not open device for recording in mono mode."));
- if ((alsa->channels) == 2)
- msg = g_strdup (_("Could not open device for recording in stereo mode."));
- if ((alsa->channels) > 2)
- msg =
- g_strdup_printf (_
- ("Could not open device for recording in %d-channel mode"),
- alsa->channels);
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (msg), (snd_strerror (err)));
- g_free (msg);
- snd_pcm_hw_params_free (params);
- return err;
- }
-no_rate:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Rate %iHz not available for recording: %s",
- alsa->rate, snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-rate_match:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Rate doesn't match (requested %iHz, get %iHz)", alsa->rate, err));
- snd_pcm_hw_params_free (params);
- return -EINVAL;
- }
-buffer_time:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set buffer time %i for recording: %s",
- alsa->buffer_time, snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-buffer_size:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to get buffer size for recording: %s", snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-period_time:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set period time %i for recording: %s", alsa->period_time,
- snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-period_size:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to get period size for recording: %s", snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-set_hw_params:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set hw params for recording: %s", snd_strerror (err)));
- snd_pcm_hw_params_free (params);
- return err;
- }
-}
-
-static int
-set_swparams (GstAlsaSrc * alsa)
-{
- int err;
- snd_pcm_sw_params_t *params;
-
- snd_pcm_sw_params_malloc (¶ms);
-
- /* get the current swparams */
- CHECK (snd_pcm_sw_params_current (alsa->handle, params), no_config);
- /* allow the transfer when at least period_size samples can be processed */
- CHECK (snd_pcm_sw_params_set_avail_min (alsa->handle, params,
- alsa->period_size), set_avail);
- /* start the transfer on first read */
- CHECK (snd_pcm_sw_params_set_start_threshold (alsa->handle, params,
- 0), start_threshold);
-
-#if GST_CHECK_ALSA_VERSION(1,0,16)
- /* snd_pcm_sw_params_set_xfer_align() is deprecated, alignment is always 1 */
-#else
- /* align all transfers to 1 sample */
- CHECK (snd_pcm_sw_params_set_xfer_align (alsa->handle, params, 1), set_align);
-#endif
-
- /* write the parameters to the recording device */
- CHECK (snd_pcm_sw_params (alsa->handle, params), set_sw_params);
-
- snd_pcm_sw_params_free (params);
- return 0;
-
- /* ERRORS */
-no_config:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to determine current swparams for playback: %s",
- snd_strerror (err)));
- snd_pcm_sw_params_free (params);
- return err;
- }
-start_threshold:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set start threshold mode for playback: %s",
- snd_strerror (err)));
- snd_pcm_sw_params_free (params);
- return err;
- }
-set_avail:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set avail min for playback: %s", snd_strerror (err)));
- snd_pcm_sw_params_free (params);
- return err;
- }
-#if !GST_CHECK_ALSA_VERSION(1,0,16)
-set_align:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set transfer align for playback: %s", snd_strerror (err)));
- snd_pcm_sw_params_free (params);
- return err;
- }
-#endif
-set_sw_params:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Unable to set sw params for playback: %s", snd_strerror (err)));
- snd_pcm_sw_params_free (params);
- return err;
- }
-}
-
-static gboolean
-alsasrc_parse_spec (GstAlsaSrc * alsa, GstRingBufferSpec * spec)
-{
- switch (spec->type) {
- case GST_BUFTYPE_LINEAR:
- alsa->format = snd_pcm_build_linear_format (spec->depth, spec->width,
- spec->sign ? 0 : 1, spec->bigend ? 1 : 0);
- break;
- case GST_BUFTYPE_FLOAT:
- switch (spec->format) {
- case GST_FLOAT32_LE:
- alsa->format = SND_PCM_FORMAT_FLOAT_LE;
- break;
- case GST_FLOAT32_BE:
- alsa->format = SND_PCM_FORMAT_FLOAT_BE;
- break;
- case GST_FLOAT64_LE:
- alsa->format = SND_PCM_FORMAT_FLOAT64_LE;
- break;
- case GST_FLOAT64_BE:
- alsa->format = SND_PCM_FORMAT_FLOAT64_BE;
- break;
- default:
- goto error;
- }
- break;
- case GST_BUFTYPE_A_LAW:
- alsa->format = SND_PCM_FORMAT_A_LAW;
- break;
- case GST_BUFTYPE_MU_LAW:
- alsa->format = SND_PCM_FORMAT_MU_LAW;
- break;
- default:
- goto error;
-
- }
- alsa->rate = spec->rate;
- alsa->channels = spec->channels;
- alsa->buffer_time = spec->buffer_time;
- alsa->period_time = spec->latency_time;
- alsa->access = SND_PCM_ACCESS_RW_INTERLEAVED;
-
- return TRUE;
-
- /* ERRORS */
-error:
- {
- return FALSE;
- }
-}
-
-static gboolean
-gst_alsasrc_open (GstAudioSrc * asrc)
-{
- GstAlsaSrc *alsa;
- gint err;
-
- alsa = GST_ALSA_SRC (asrc);
-
- CHECK (snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_CAPTURE,
- SND_PCM_NONBLOCK), open_error);
-
- if (!alsa->mixer)
- alsa->mixer = gst_alsa_mixer_new (alsa->device, GST_ALSA_MIXER_CAPTURE);
-
- return TRUE;
-
- /* ERRORS */
-open_error:
- {
- if (err == -EBUSY) {
- GST_ELEMENT_ERROR (alsa, RESOURCE, BUSY,
- (_("Could not open audio device for recording. "
- "Device is being used by another application.")),
- ("Device '%s' is busy", alsa->device));
- } else {
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- (_("Could not open audio device for recording.")),
- ("Recording open error on device '%s': %s", alsa->device,
- snd_strerror (err)));
- }
- return FALSE;
- }
-}
-
-static gboolean
-gst_alsasrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
-{
- GstAlsaSrc *alsa;
- gint err;
-
- alsa = GST_ALSA_SRC (asrc);
-
- if (!alsasrc_parse_spec (alsa, spec))
- goto spec_parse;
-
- CHECK (snd_pcm_nonblock (alsa->handle, 0), non_block);
-
- CHECK (set_hwparams (alsa), hw_params_failed);
- CHECK (set_swparams (alsa), sw_params_failed);
- CHECK (snd_pcm_prepare (alsa->handle), prepare_failed);
-
- alsa->bytes_per_sample = spec->bytes_per_sample;
- spec->segsize = alsa->period_size * spec->bytes_per_sample;
- spec->segtotal = alsa->buffer_size / alsa->period_size;
- spec->silence_sample[0] = 0;
- spec->silence_sample[1] = 0;
- spec->silence_sample[2] = 0;
- spec->silence_sample[3] = 0;
-
- return TRUE;
-
- /* ERRORS */
-spec_parse:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Error parsing spec"));
- return FALSE;
- }
-non_block:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Could not set device to blocking: %s", snd_strerror (err)));
- return FALSE;
- }
-hw_params_failed:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Setting of hwparams failed: %s", snd_strerror (err)));
- return FALSE;
- }
-sw_params_failed:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Setting of swparams failed: %s", snd_strerror (err)));
- return FALSE;
- }
-prepare_failed:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Prepare failed: %s", snd_strerror (err)));
- return FALSE;
- }
-}
-
-static gboolean
-gst_alsasrc_unprepare (GstAudioSrc * asrc)
-{
- GstAlsaSrc *alsa;
- gint err;
-
- alsa = GST_ALSA_SRC (asrc);
-
- CHECK (snd_pcm_drop (alsa->handle), drop);
-
- CHECK (snd_pcm_hw_free (alsa->handle), hw_free);
-
- CHECK (snd_pcm_nonblock (alsa->handle, 1), non_block);
-
- return TRUE;
-
- /* ERRORS */
-drop:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Could not drop samples: %s", snd_strerror (err)));
- return FALSE;
- }
-hw_free:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Could not free hw params: %s", snd_strerror (err)));
- return FALSE;
- }
-non_block:
- {
- GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
- ("Could not set device to nonblocking: %s", snd_strerror (err)));
- return FALSE;
- }
-}
-
-static gboolean
-gst_alsasrc_close (GstAudioSrc * asrc)
-{
- GstAlsaSrc *alsa = GST_ALSA_SRC (asrc);
-
- snd_pcm_close (alsa->handle);
-
- if (alsa->mixer) {
- gst_alsa_mixer_free (alsa->mixer);
- alsa->mixer = NULL;
- }
-
- gst_caps_replace (&alsa->cached_caps, NULL);
-
- return TRUE;
-}
-
-/*
- * Underrun and suspend recovery
- */
-static gint
-xrun_recovery (GstAlsaSrc * alsa, snd_pcm_t * handle, gint err)
-{
- GST_DEBUG_OBJECT (alsa, "xrun recovery %d", err);
-
- if (err == -EPIPE) { /* under-run */
- err = snd_pcm_prepare (handle);
- if (err < 0)
- GST_WARNING_OBJECT (alsa,
- "Can't recovery from underrun, prepare failed: %s",
- snd_strerror (err));
- return 0;
- } else if (err == -ESTRPIPE) {
- while ((err = snd_pcm_resume (handle)) == -EAGAIN)
- g_usleep (100); /* wait until the suspend flag is released */
-
- if (err < 0) {
- err = snd_pcm_prepare (handle);
- if (err < 0)
- GST_WARNING_OBJECT (alsa,
- "Can't recovery from suspend, prepare failed: %s",
- snd_strerror (err));
- }
- return 0;
- }
- return err;
-}
-
-static guint
-gst_alsasrc_read (GstAudioSrc * asrc, gpointer data, guint length)
-{
- GstAlsaSrc *alsa;
- gint err;
- gint cptr;
- gint16 *ptr;
-
- alsa = GST_ALSA_SRC (asrc);
-
- cptr = length / alsa->bytes_per_sample;
- ptr = data;
-
- GST_ALSA_SRC_LOCK (asrc);
- while (cptr > 0) {
- if ((err = snd_pcm_readi (alsa->handle, ptr, cptr)) < 0) {
- if (err == -EAGAIN) {
- GST_DEBUG_OBJECT (asrc, "Read error: %s", snd_strerror (err));
- continue;
- } else if (xrun_recovery (alsa, alsa->handle, err) < 0) {
- goto read_error;
- }
- continue;
- }
-
- ptr += err * alsa->channels;
- cptr -= err;
- }
- GST_ALSA_SRC_UNLOCK (asrc);
-
- return length - cptr;
-
-read_error:
- {
- GST_ALSA_SRC_UNLOCK (asrc);
- return length; /* skip one period */
- }
-}
-
-static guint
-gst_alsasrc_delay (GstAudioSrc * asrc)
-{
- GstAlsaSrc *alsa;
- snd_pcm_sframes_t delay;
- int res;
-
- alsa = GST_ALSA_SRC (asrc);
-
- res = snd_pcm_delay (alsa->handle, &delay);
- if (G_UNLIKELY (res < 0)) {
- GST_DEBUG_OBJECT (alsa, "snd_pcm_delay returned %d", res);
- delay = 0;
- }
-
- return CLAMP (delay, 0, alsa->buffer_size);
-}
-
-static void
-gst_alsasrc_reset (GstAudioSrc * asrc)
-{
- GstAlsaSrc *alsa;
- gint err;
-
- alsa = GST_ALSA_SRC (asrc);
-
- GST_ALSA_SRC_LOCK (asrc);
- GST_DEBUG_OBJECT (alsa, "drop");
- CHECK (snd_pcm_drop (alsa->handle), drop_error);
- GST_DEBUG_OBJECT (alsa, "prepare");
- CHECK (snd_pcm_prepare (alsa->handle), prepare_error);
- GST_DEBUG_OBJECT (alsa, "reset done");
- GST_ALSA_SRC_UNLOCK (asrc);
-
- return;
-
- /* ERRORS */
-drop_error:
- {
- GST_ERROR_OBJECT (alsa, "alsa-reset: pcm drop error: %s",
- snd_strerror (err));
- GST_ALSA_SRC_UNLOCK (asrc);
- return;
- }
-prepare_error:
- {
- GST_ERROR_OBJECT (alsa, "alsa-reset: pcm prepare error: %s",
- snd_strerror (err));
- GST_ALSA_SRC_UNLOCK (asrc);
- return;
- }
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/alsa/gstalsasrc.h
--- a/gst_plugins_base/ext/alsa/gstalsasrc.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/* GStreamer
- * Copyright (C) 2005 Wim Taymans
- *
- * gstalsasrc.h:
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-#ifndef __GST_ALSASRC_H__
-#define __GST_ALSASRC_H__
-
-#include
-#include "gstalsa.h"
-#include "gstalsamixer.h"
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_ALSA_SRC (gst_alsasrc_get_type())
-#define GST_ALSA_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_SRC,GstAlsaSrc))
-#define GST_ALSA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_SRC,GstAlsaSrcClass))
-#define GST_IS_ALSA_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_SRC))
-#define GST_IS_ALSA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_SRC))
-#define GST_ALSA_SRC_CAST(obj) ((GstAlsaSrc *)(obj))
-
-#define GST_ALSA_SRC_GET_LOCK(obj) (GST_ALSA_SRC_CAST (obj)->alsa_lock)
-#define GST_ALSA_SRC_LOCK(obj) (g_mutex_lock (GST_ALSA_SRC_GET_LOCK (obj)))
-#define GST_ALSA_SRC_UNLOCK(obj) (g_mutex_unlock (GST_ALSA_SRC_GET_LOCK (obj)))
-
-typedef struct _GstAlsaSrc GstAlsaSrc;
-typedef struct _GstAlsaSrcClass GstAlsaSrcClass;
-
-/**
- * GstAlsaSrc:
- *
- * Opaque data structure
- */
-struct _GstAlsaSrc {
- GstAudioSrc src;
-
- gchar *device;
-
- snd_pcm_t *handle;
- snd_pcm_hw_params_t *hwparams;
- snd_pcm_sw_params_t *swparams;
-
- GstCaps *cached_caps;
-
- snd_pcm_access_t access;
- snd_pcm_format_t format;
- guint rate;
- guint channels;
- gint bytes_per_sample;
-
- guint buffer_time;
- guint period_time;
- snd_pcm_uframes_t buffer_size;
- snd_pcm_uframes_t period_size;
-
- GstAlsaMixer *mixer;
-
- GMutex *alsa_lock;
-};
-
-struct _GstAlsaSrcClass {
- GstAudioSrcClass parent_class;
-};
-
-GType gst_alsasrc_get_type(void);
-
-G_END_DECLS
-
-#endif /* __GST_ALSASRC_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/cdparanoia/gstcdparanoiasrc.c
--- a/gst_plugins_base/ext/cdparanoia/gstcdparanoiasrc.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,490 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
-/* GStreamer
- * Copyright (C) <1999> Erik Walthinsen
- * <2005> Wim Taymans
- * <2005> Tim-Philipp Müller
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include
-#include
-
-#include "gstcdparanoiasrc.h"
-#include "gst/gst-i18n-plugin.h"
-
-enum
-{
- TRANSPORT_ERROR,
- UNCORRECTED_ERROR,
- NUM_SIGNALS
-};
-
-enum
-{
- PROP_0,
- PROP_READ_SPEED,
- PROP_PARANOIA_MODE,
- PROP_SEARCH_OVERLAP,
- PROP_GENERIC_DEVICE
-};
-
-#define DEFAULT_READ_SPEED -1
-#define DEFAULT_SEARCH_OVERLAP -1
-#define DEFAULT_PARANOIA_MODE PARANOIA_MODE_FRAGMENT
-#define DEFAULT_GENERIC_DEVICE NULL
-
-GST_DEBUG_CATEGORY_STATIC (gst_cd_paranoia_src_debug);
-#define GST_CAT_DEFAULT gst_cd_paranoia_src_debug
-
-GST_BOILERPLATE (GstCdParanoiaSrc, gst_cd_paranoia_src, GstCddaBaseSrc,
- GST_TYPE_CDDA_BASE_SRC);
-
-static void gst_cd_paranoia_src_finalize (GObject * obj);
-static void gst_cd_paranoia_src_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-static void gst_cd_paranoia_src_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static GstBuffer *gst_cd_paranoia_src_read_sector (GstCddaBaseSrc * src,
- gint sector);
-static gboolean gst_cd_paranoia_src_open (GstCddaBaseSrc * src,
- const gchar * device);
-static void gst_cd_paranoia_src_close (GstCddaBaseSrc * src);
-
-static const GstElementDetails cdparanoia_details =
-GST_ELEMENT_DETAILS ("CD Audio (cdda) Source, Paranoia IV",
- "Source/File",
- "Read audio from CD in paranoid mode",
- "Erik Walthinsen , " "Wim Taymans ");
-
-/* We use these to serialize calls to paranoia_read() among several
- * cdparanoiasrc instances. We do this because it's the only reasonably
- * easy way to find out the calling object from within the paranoia
- * callback, and we need the object instance in there to emit our signals */
-static GstCdParanoiaSrc *cur_cb_source;
-static GStaticMutex cur_cb_mutex = G_STATIC_MUTEX_INIT;
-
-static gint cdpsrc_signals[NUM_SIGNALS]; /* all 0 */
-
-#define GST_TYPE_CD_PARANOIA_MODE (gst_cd_paranoia_mode_get_type())
-static GType
-gst_cd_paranoia_mode_get_type (void)
-{
- static const GFlagsValue paranoia_modes[] = {
- {PARANOIA_MODE_DISABLE, "PARANOIA_MODE_DISABLE", "disable"},
- {PARANOIA_MODE_FRAGMENT, "PARANOIA_MODE_FRAGMENT", "fragment"},
- {PARANOIA_MODE_OVERLAP, "PARANOIA_MODE_OVERLAP", "overlap"},
- {PARANOIA_MODE_SCRATCH, "PARANOIA_MODE_SCRATCH", "scratch"},
- {PARANOIA_MODE_REPAIR, "PARANOIA_MODE_REPAIR", "repair"},
- {PARANOIA_MODE_FULL, "PARANOIA_MODE_FULL", "full"},
- {0, NULL, NULL},
- };
-
- static GType type; /* 0 */
-
- if (!type) {
- type = g_flags_register_static ("GstCdParanoiaMode", paranoia_modes);
- }
-
- return type;
-}
-
-static void
-gst_cd_paranoia_src_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_set_details (element_class, &cdparanoia_details);
-}
-
-static void
-gst_cd_paranoia_src_init (GstCdParanoiaSrc * src, GstCdParanoiaSrcClass * klass)
-{
- src->d = NULL;
- src->p = NULL;
- src->next_sector = -1;
-
- src->search_overlap = DEFAULT_SEARCH_OVERLAP;
- src->paranoia_mode = DEFAULT_PARANOIA_MODE;
- src->read_speed = DEFAULT_READ_SPEED;
- src->generic_device = g_strdup (DEFAULT_GENERIC_DEVICE);
-}
-
-static void
-gst_cd_paranoia_src_class_init (GstCdParanoiaSrcClass * klass)
-{
- GstCddaBaseSrcClass *cddabasesrc_class = GST_CDDA_BASE_SRC_CLASS (klass);
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->set_property = gst_cd_paranoia_src_set_property;
- gobject_class->get_property = gst_cd_paranoia_src_get_property;
- gobject_class->finalize = gst_cd_paranoia_src_finalize;
-
- cddabasesrc_class->open = gst_cd_paranoia_src_open;
- cddabasesrc_class->close = gst_cd_paranoia_src_close;
- cddabasesrc_class->read_sector = gst_cd_paranoia_src_read_sector;
-
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_GENERIC_DEVICE,
- g_param_spec_string ("generic-device", "Generic device",
- "Use specified generic scsi device", DEFAULT_GENERIC_DEVICE,
- G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_READ_SPEED,
- g_param_spec_int ("read-speed", "Read speed",
- "Read from device at specified speed", -1, G_MAXINT,
- DEFAULT_READ_SPEED, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PARANOIA_MODE,
- g_param_spec_flags ("paranoia-mode", "Paranoia mode",
- "Type of checking to perform", GST_TYPE_CD_PARANOIA_MODE,
- DEFAULT_PARANOIA_MODE, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SEARCH_OVERLAP,
- g_param_spec_int ("search-overlap", "Search overlap",
- "Force minimum overlap search during verification to n sectors", -1,
- 75, DEFAULT_SEARCH_OVERLAP, G_PARAM_READWRITE));
-
- /* FIXME: we don't really want signals for this, but messages on the bus,
- * but then we can't check any longer whether anyone is interested in them */
- cdpsrc_signals[TRANSPORT_ERROR] =
- g_signal_new ("transport-error", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstCdParanoiaSrcClass, transport_error),
- NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
- cdpsrc_signals[UNCORRECTED_ERROR] =
- g_signal_new ("uncorrected-error", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstCdParanoiaSrcClass, uncorrected_error),
- NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
-}
-
-static gboolean
-gst_cd_paranoia_src_open (GstCddaBaseSrc * cddabasesrc, const gchar * device)
-{
- GstCdParanoiaSrc *src = GST_CD_PARANOIA_SRC (cddabasesrc);
- gint i;
-
- GST_DEBUG_OBJECT (src, "trying to open device %s (generic-device=%s) ...",
- device, GST_STR_NULL (src->generic_device));
-
- /* find the device */
- if (src->generic_device != NULL) {
- src->d = cdda_identify_scsi (src->generic_device, device, FALSE, NULL);
- } else {
- if (device != NULL) {
- src->d = cdda_identify (device, FALSE, NULL);
- } else {
- src->d = cdda_identify ("/dev/cdrom", FALSE, NULL);
- }
- }
-
- /* fail if the device couldn't be found */
- if (src->d == NULL)
- goto no_device;
-
- /* set verbosity mode */
- cdda_verbose_set (src->d, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT);
-
- /* open the disc */
- if (cdda_open (src->d))
- goto open_failed;
-
- if (src->read_speed != -1) {
- cdda_speed_set (src->d, src->read_speed);
- }
-
- for (i = 1; i < src->d->tracks + 1; i++) {
- GstCddaBaseSrcTrack track = { 0, };
-
- track.num = i;
- track.is_audio = IS_AUDIO (src->d, i - 1);
- track.start = cdda_track_firstsector (src->d, i);
- track.end = cdda_track_lastsector (src->d, i);
- track.tags = NULL;
-
- gst_cdda_base_src_add_track (GST_CDDA_BASE_SRC (src), &track);
- }
-
- /* create the paranoia struct and set it up */
- src->p = paranoia_init (src->d);
- if (src->p == NULL)
- goto init_failed;
-
- paranoia_modeset (src->p, src->paranoia_mode);
-
- if (src->search_overlap != -1)
- paranoia_overlapset (src->p, src->search_overlap);
-
- src->next_sector = -1;
-
- return TRUE;
-
- /* ERRORS */
-no_device:
- {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("Could not open CD device for reading.")), ("cdda_identify failed"));
- return FALSE;
- }
-open_failed:
- {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("Could not open CD device for reading.")), ("cdda_open failed"));
- cdda_close (src->d);
- src->d = NULL;
- return FALSE;
- }
-init_failed:
- {
- GST_ELEMENT_ERROR (src, LIBRARY, INIT,
- ("failed to initialize paranoia"), ("failed to initialize paranoia"));
- return FALSE;
- }
-}
-
-static void
-gst_cd_paranoia_src_close (GstCddaBaseSrc * cddabasesrc)
-{
- GstCdParanoiaSrc *src = GST_CD_PARANOIA_SRC (cddabasesrc);
-
- if (src->p) {
- paranoia_free (src->p);
- src->p = NULL;
- }
-
- if (src->d) {
- cdda_close (src->d);
- src->d = NULL;
- }
-
- src->next_sector = -1;
-}
-
-static void
-gst_cd_paranoia_dummy_callback (long inpos, int function)
-{
- /* Used by instanced where no one is interested what's happening here */
-}
-
-static void
-gst_cd_paranoia_paranoia_callback (long inpos, int function)
-{
- GstCdParanoiaSrc *src = cur_cb_source;
- gint sector = (gint) (inpos / CD_FRAMEWORDS);
-
- switch (function) {
- case PARANOIA_CB_SKIP:
- GST_INFO_OBJECT (src, "Skip at sector %d", sector);
- g_signal_emit (src, cdpsrc_signals[UNCORRECTED_ERROR], 0, sector);
- break;
- case PARANOIA_CB_READERR:
- GST_INFO_OBJECT (src, "Transport error at sector %d", sector);
- g_signal_emit (src, cdpsrc_signals[TRANSPORT_ERROR], 0, sector);
- break;
- default:
- break;
- }
-}
-
-static gboolean
-gst_cd_paranoia_src_signal_is_being_watched (GstCdParanoiaSrc * src, gint sig)
-{
- return g_signal_has_handler_pending (src, cdpsrc_signals[sig], 0, FALSE);
-}
-
-static GstBuffer *
-gst_cd_paranoia_src_read_sector (GstCddaBaseSrc * cddabasesrc, gint sector)
-{
- GstCdParanoiaSrc *src = GST_CD_PARANOIA_SRC (cddabasesrc);
- GstBuffer *buf;
- gboolean do_serialize;
- gint16 *cdda_buf;
-
-#if 0
- /* Do we really need to output this? (tpm) */
- /* Due to possible autocorrections of start sectors of audio tracks on
- * multisession cds, we can maybe not compute the correct discid.
- * So issue a warning.
- * See cdparanoia/interface/common-interface.c:FixupTOC */
- if (src->d && src->d->cd_extra) {
- g_message
- ("DiscID on multisession discs might be broken. Use at own risk.");
- }
-#endif
-
- if (src->next_sector == -1 || src->next_sector != sector) {
- if (paranoia_seek (src->p, sector, SEEK_SET) == -1)
- goto seek_failed;
-
- GST_DEBUG_OBJECT (src, "successfully seeked to sector %d", sector);
- src->next_sector = sector;
- }
-
- do_serialize =
- gst_cd_paranoia_src_signal_is_being_watched (src, TRANSPORT_ERROR) ||
- gst_cd_paranoia_src_signal_is_being_watched (src, UNCORRECTED_ERROR);
-
- if (do_serialize) {
- GST_LOG_OBJECT (src, "Signal handlers connected, serialising access");
- g_static_mutex_lock (&cur_cb_mutex);
- GST_LOG_OBJECT (src, "Got lock");
- cur_cb_source = src;
-
- cdda_buf = paranoia_read (src->p, gst_cd_paranoia_paranoia_callback);
-
- cur_cb_source = NULL;
- GST_LOG_OBJECT (src, "Releasing lock");
- g_static_mutex_unlock (&cur_cb_mutex);
- } else {
- cdda_buf = paranoia_read (src->p, gst_cd_paranoia_dummy_callback);
- }
-
- if (cdda_buf == NULL)
- goto read_failed;
-
- buf = gst_buffer_new_and_alloc (CD_FRAMESIZE_RAW);
- memcpy (GST_BUFFER_DATA (buf), cdda_buf, CD_FRAMESIZE_RAW);
-
- /* cdda base class will take care of timestamping etc. */
- ++src->next_sector;
-
- return buf;
-
- /* ERRORS */
-seek_failed:
- {
- GST_WARNING_OBJECT (src, "seek to sector %d failed!", sector);
- GST_ELEMENT_ERROR (src, RESOURCE, SEEK,
- (_("Could not seek CD.")),
- ("paranoia_seek to %d failed: %s", sector, g_strerror (errno)));
- return NULL;
- }
-read_failed:
- {
- GST_WARNING_OBJECT (src, "read at sector %d failed!", sector);
- GST_ELEMENT_ERROR (src, RESOURCE, READ,
- (_("Could not read CD.")),
- ("paranoia_read at %d failed: %s", sector, g_strerror (errno)));
- return NULL;
- }
-}
-
-static void
-gst_cd_paranoia_src_finalize (GObject * obj)
-{
- GstCdParanoiaSrc *src = GST_CD_PARANOIA_SRC (obj);
-
- g_free (src->generic_device);
-
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-static void
-gst_cd_paranoia_src_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstCdParanoiaSrc *src = GST_CD_PARANOIA_SRC (object);
-
- GST_OBJECT_LOCK (src);
-
- switch (prop_id) {
- case PROP_GENERIC_DEVICE:{
- g_free (src->generic_device);
- src->generic_device = g_value_dup_string (value);
- if (src->generic_device && src->generic_device[0] == '\0') {
- g_free (src->generic_device);
- src->generic_device = NULL;
- }
- break;
- }
- case PROP_READ_SPEED:{
- src->read_speed = g_value_get_int (value);
- if (src->read_speed == 0)
- src->read_speed = -1;
- break;
- }
- case PROP_PARANOIA_MODE:{
- src->paranoia_mode = g_value_get_flags (value) & PARANOIA_MODE_FULL;
- break;
- }
- case PROP_SEARCH_OVERLAP:{
- src->search_overlap = g_value_get_int (value);
- break;
- }
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
- GST_OBJECT_UNLOCK (src);
-}
-
-static void
-gst_cd_paranoia_src_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstCdParanoiaSrc *src = GST_CD_PARANOIA_SRC (object);
-
- GST_OBJECT_LOCK (src);
-
- switch (prop_id) {
- case PROP_READ_SPEED:
- g_value_set_int (value, src->read_speed);
- break;
- case PROP_PARANOIA_MODE:
- g_value_set_flags (value, src->paranoia_mode);
- break;
- case PROP_GENERIC_DEVICE:
- g_value_set_string (value, src->generic_device);
- break;
- case PROP_SEARCH_OVERLAP:
- g_value_set_int (value, src->search_overlap);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
- GST_OBJECT_UNLOCK (src);
-}
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
- GST_DEBUG_CATEGORY_INIT (gst_cd_paranoia_src_debug, "cdparanoiasrc", 0,
- "CD Paranoia Source");
-
- if (!gst_element_register (plugin, "cdparanoiasrc", GST_RANK_SECONDARY,
- GST_TYPE_CD_PARANOIA_SRC))
- return FALSE;
-
-#ifdef ENABLE_NLS
- GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
- LOCALEDIR);
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-#endif
-
-
- return TRUE;
-}
-
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "cdparanoia",
- "Read audio from CD in paranoid mode",
- plugin_init, VERSION, "GPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/cdparanoia/gstcdparanoiasrc.h
--- a/gst_plugins_base/ext/cdparanoia/gstcdparanoiasrc.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/* GStreamer
- * Copyright (C) 1999 Erik Walthinsen
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_CD_PARANOIA_SRC_H__
-#define __GST_CD_PARANOIA_SRC_H__
-
-#include "gst/cdda/gstcddabasesrc.h"
-
-G_BEGIN_DECLS
-
-#define size16 gint16
-#define size32 gint32
-
-#ifdef CDPARANOIA_HEADERS_IN_DIR
- #include
- #include
-#else
- #include
- #include
-#endif
-
-#define GST_TYPE_CD_PARANOIA_SRC (gst_cd_paranoia_src_get_type())
-#define GST_CD_PARANOIA_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CD_PARANOIA_SRC,GstCdParanoiaSrc))
-#define GST_CD_PARANOIA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CD_PARANOIA_SRC,GstCdParanoiaSrcClass))
-#define GST_IS_CD_PARANOIA_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CD_PARANOIA_SRC))
-#define GST_IS_CD_PARANOIA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CD_PARANOIA_SRC))
-#define GST_CD_PARANOIA_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_CDDA_BASAE_SRC, GstCdParanoiaSrcClass))
-
-typedef struct _GstCdParanoiaSrc GstCdParanoiaSrc;
-typedef struct _GstCdParanoiaSrcClass GstCdParanoiaSrcClass;
-
-/**
- * GstCdParanoiaSrc:
- *
- * The cdparanoia object structure.
- */
-struct _GstCdParanoiaSrc {
- GstCddaBaseSrc cddabasesrc;
-
- /*< private >*/
- cdrom_drive *d;
- cdrom_paranoia *p;
-
- gint next_sector; /* -1 or next sector we expect to
- * read, so we know when to do a seek */
-
- gint paranoia_mode;
- gint read_speed;
- gint search_overlap;
-
- gchar *generic_device;
-};
-
-struct _GstCdParanoiaSrcClass {
- GstCddaBaseSrcClass parent_class;
-
- /* signal callbacks */
- /**
- * GstCdParanoiaSrcClass::transport-error:
- * @src: the GstCddaBaseSrc source element object
- * @sector: the sector at which the error happened
- *
- * This signal is emitted when a sector could not be read
- * because of a transport error.
- */
- void (*transport_error) (GstCdParanoiaSrc * src, gint sector);
- /**
- * GstCdParanoiaSrcClass::uncorrected-error:
- * @src: the GstCddaBaseSrc source element object
- * @sector: the sector at which the error happened
- *
- * This signal is emitted when a sector could not be read
- * because of a transport error.
- */
- void (*uncorrected_error) (GstCdParanoiaSrc * src, gint sector);
-};
-
-GType gst_cd_paranoia_src_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_CD_PARANOIA_SRC_H__ */
-
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgio.c
--- a/gst_plugins_base/ext/gio/gstgio.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,214 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstgio.h"
-#include "gstgiosink.h"
-#include "gstgiosrc.h"
-#include "gstgiostreamsink.h"
-#include "gstgiostreamsrc.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_gio_debug);
-#define GST_CAT_DEFAULT gst_gio_debug
-
-/* @func_name: Name of the GIO function, for debugging messages.
- * @err: Error location. *err may be NULL, but err must be non-NULL.
- * @ret: Flow return location. May be NULL. Is set to either #GST_FLOW_ERROR
- * or #GST_FLOW_WRONG_STATE.
- *
- * Returns: TRUE to indicate a handled error. Error at given location err will
- * be freed and *err will be set to NULL. A FALSE return indicates an unhandled
- * error: The err location is unchanged and guaranteed to be != NULL. ret, if
- * given, is set to GST_FLOW_ERROR.
- */
-gboolean
-gst_gio_error (gpointer element, const gchar * func_name, GError ** err,
- GstFlowReturn * ret)
-{
- gboolean handled = TRUE;
-
- if (ret)
- *ret = GST_FLOW_ERROR;
-
- if (GST_GIO_ERROR_MATCHES (*err, CANCELLED)) {
- GST_DEBUG_OBJECT (element, "blocking I/O call cancelled (%s)", func_name);
- if (ret)
- *ret = GST_FLOW_WRONG_STATE;
- } else if (*err != NULL) {
- handled = FALSE;
- } else {
- GST_ELEMENT_ERROR (element, LIBRARY, FAILED, (NULL),
- ("%s call failed without error set", func_name));
- }
-
- if (handled)
- g_clear_error (err);
-
- return handled;
-}
-
-GstFlowReturn
-gst_gio_seek (gpointer element, GSeekable * stream, guint64 offset,
- GCancellable * cancel)
-{
- gboolean success;
- GstFlowReturn ret;
- GError *err = NULL;
-
- GST_LOG_OBJECT (element, "seeking to offset %" G_GINT64_FORMAT, offset);
-
- success = g_seekable_seek (stream, offset, G_SEEK_SET, cancel, &err);
-
- if (success)
- ret = GST_FLOW_OK;
- else if (!gst_gio_error (element, "g_seekable_seek", &err, &ret)) {
- GST_ELEMENT_ERROR (element, RESOURCE, SEEK, (NULL),
- ("Could not seek: %s", err->message));
- g_clear_error (&err);
- }
-
- return ret;
-}
-
-static gchar **
-gst_gio_get_supported_protocols (void)
-{
- return g_strdupv ((gchar **)
- g_vfs_get_supported_uri_schemes (g_vfs_get_default ()));
-}
-
-static GstURIType
-gst_gio_uri_handler_get_type_sink (void)
-{
- return GST_URI_SINK;
-}
-
-static GstURIType
-gst_gio_uri_handler_get_type_src (void)
-{
- return GST_URI_SRC;
-}
-
-static gchar **
-gst_gio_uri_handler_get_protocols (void)
-{
- static gchar **protocols = NULL;
-
- if (!protocols)
- protocols = gst_gio_get_supported_protocols ();
-
- return protocols;
-}
-
-static const gchar *
-gst_gio_uri_handler_get_uri (GstURIHandler * handler)
-{
- GstElement *element = GST_ELEMENT (handler);
- const gchar *uri;
-
- g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
-
- g_object_get (G_OBJECT (element), "location", &uri, NULL);
-
- return uri;
-}
-
-static gboolean
-gst_gio_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri)
-{
- GstElement *element = GST_ELEMENT (handler);
-
- g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
-
- if (GST_STATE (element) == GST_STATE_PLAYING ||
- GST_STATE (element) == GST_STATE_PAUSED)
- return FALSE;
-
- g_object_set (G_OBJECT (element), "location", uri, NULL);
-
- return TRUE;
-}
-
-static void
-gst_gio_uri_handler_init (gpointer g_iface, gpointer iface_data)
-{
- GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
- gboolean sink = GPOINTER_TO_INT (iface_data); /* See in do_init below. */
-
- if (sink)
- iface->get_type = gst_gio_uri_handler_get_type_sink;
- else
- iface->get_type = gst_gio_uri_handler_get_type_src;
- iface->get_protocols = gst_gio_uri_handler_get_protocols;
- iface->get_uri = gst_gio_uri_handler_get_uri;
- iface->set_uri = gst_gio_uri_handler_set_uri;
-}
-
-void
-gst_gio_uri_handler_do_init (GType type)
-{
- GInterfaceInfo uri_handler_info = {
- gst_gio_uri_handler_init,
- NULL,
- NULL
- };
-
- /* Store information for uri_handler_init to use for distinguishing the
- * element types. This lets us use a single interface implementation for both
- * classes. */
- uri_handler_info.interface_data = GINT_TO_POINTER (g_type_is_a (type,
- GST_TYPE_BASE_SINK));
-
- g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &uri_handler_info);
-}
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
- gboolean ret = TRUE;
-
- GST_DEBUG_CATEGORY_INIT (gst_gio_debug, "gio", 0, "GIO elements");
-
- /* FIXME: Rank is MARGINAL for now, should be at least SECONDARY+1 in the future
- * to replace gnomevfssink/src. For testing purposes PRIMARY+1 one makes sense
- * so it gets autoplugged and preferred over filesrc/sink. */
-
- ret &= gst_element_register (plugin, "giosink", GST_RANK_MARGINAL,
- GST_TYPE_GIO_SINK);
-
- ret &= gst_element_register (plugin, "giosrc", GST_RANK_MARGINAL,
- GST_TYPE_GIO_SRC);
-
- ret &= gst_element_register (plugin, "giostreamsink", GST_RANK_NONE,
- GST_TYPE_GIO_STREAM_SINK);
-
- ret &= gst_element_register (plugin, "giostreamsrc", GST_RANK_NONE,
- GST_TYPE_GIO_STREAM_SRC);
-
- return ret;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, "gio",
- "GIO elements", plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME,
- GST_PACKAGE_ORIGIN)
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgio.h
--- a/gst_plugins_base/ext/gio/gstgio.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_GIO_H__
-#define __GST_GIO_H__
-
-#include
-#include
-
-G_BEGIN_DECLS
-
-#define GST_GIO_ERROR_MATCHES(err, code) g_error_matches (err, G_IO_ERROR, G_IO_ERROR_##code)
-
-#define GST_GIO_STREAM_IS_SEEKABLE(stream) (G_IS_SEEKABLE (stream) && g_seekable_can_seek (G_SEEKABLE (stream)))
-
-gboolean gst_gio_error (gpointer element, const gchar *func_name,
- GError **err, GstFlowReturn *ret);
-GstFlowReturn gst_gio_seek (gpointer element, GSeekable *stream, guint64 offset,
- GCancellable *cancel);
-void gst_gio_uri_handler_do_init (GType type);
-
-G_END_DECLS
-
-#endif /* __GST_GIO_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgiobasesink.c
--- a/gst_plugins_base/ext/gio/gstgiobasesink.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,349 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-#include "gstgiobasesink.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_gio_base_sink_debug);
-#define GST_CAT_DEFAULT gst_gio_base_sink_debug
-
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY);
-
-GST_BOILERPLATE (GstGioBaseSink, gst_gio_base_sink, GstBaseSink,
- GST_TYPE_BASE_SINK);
-
-static void gst_gio_base_sink_finalize (GObject * object);
-static gboolean gst_gio_base_sink_start (GstBaseSink * base_sink);
-static gboolean gst_gio_base_sink_stop (GstBaseSink * base_sink);
-static gboolean gst_gio_base_sink_unlock (GstBaseSink * base_sink);
-static gboolean gst_gio_base_sink_unlock_stop (GstBaseSink * base_sink);
-static gboolean gst_gio_base_sink_event (GstBaseSink * base_sink,
- GstEvent * event);
-static GstFlowReturn gst_gio_base_sink_render (GstBaseSink * base_sink,
- GstBuffer * buffer);
-static gboolean gst_gio_base_sink_query (GstPad * pad, GstQuery * query);
-
-static void
-gst_gio_base_sink_base_init (gpointer gclass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- GST_DEBUG_CATEGORY_INIT (gst_gio_base_sink_debug, "gio_base_sink", 0,
- "GIO base sink");
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_factory));
-}
-
-static void
-gst_gio_base_sink_class_init (GstGioBaseSinkClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
- GstBaseSinkClass *gstbasesink_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstbasesink_class = (GstBaseSinkClass *) klass;
-
- gobject_class->finalize = gst_gio_base_sink_finalize;
-
- gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_gio_base_sink_start);
- gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_gio_base_sink_stop);
- gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_gio_base_sink_unlock);
- gstbasesink_class->unlock_stop =
- GST_DEBUG_FUNCPTR (gst_gio_base_sink_unlock_stop);
- gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_gio_base_sink_event);
- gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_gio_base_sink_render);
-}
-
-static void
-gst_gio_base_sink_init (GstGioBaseSink * sink, GstGioBaseSinkClass * gclass)
-{
- gst_pad_set_query_function (GST_BASE_SINK_PAD (sink),
- GST_DEBUG_FUNCPTR (gst_gio_base_sink_query));
-
- gst_base_sink_set_sync (GST_BASE_SINK (sink), FALSE);
-
- sink->cancel = g_cancellable_new ();
-}
-
-static void
-gst_gio_base_sink_finalize (GObject * object)
-{
- GstGioBaseSink *sink = GST_GIO_BASE_SINK (object);
-
- if (sink->cancel) {
- g_object_unref (sink->cancel);
- sink->cancel = NULL;
- }
-
- if (sink->stream) {
- g_object_unref (sink->stream);
- sink->stream = NULL;
- }
-
- GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-static gboolean
-gst_gio_base_sink_start (GstBaseSink * base_sink)
-{
- GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
-
- if (!G_IS_OUTPUT_STREAM (sink->stream)) {
- GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
- ("No stream given yet"));
- return FALSE;
- }
-
- sink->position = 0;
-
- GST_DEBUG_OBJECT (sink, "started stream");
-
- return TRUE;
-}
-
-static gboolean
-gst_gio_base_sink_stop (GstBaseSink * base_sink)
-{
- GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
- gboolean success;
- GError *err = NULL;
-
- if (G_IS_OUTPUT_STREAM (sink->stream)) {
- GST_DEBUG_OBJECT (sink, "closing stream");
-
- /* FIXME: can block but unfortunately we can't use async operations
- * here because they require a running main loop */
- success = g_output_stream_close (sink->stream, sink->cancel, &err);
-
- if (!success && !gst_gio_error (sink, "g_output_stream_close", &err, NULL)) {
- GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, (NULL),
- ("g_ooutput_stream_close failed: %s", err->message));
- g_clear_error (&err);
- } else if (!success) {
- GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, (NULL),
- ("g_output_stream_close failed"));
- } else {
- GST_DEBUG_OBJECT (sink, "g_outut_stream_close succeeded");
- }
-
- g_object_unref (sink->stream);
- sink->stream = NULL;
- }
-
- return TRUE;
-}
-
-static gboolean
-gst_gio_base_sink_unlock (GstBaseSink * base_sink)
-{
- GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
-
- GST_LOG_OBJECT (sink, "triggering cancellation");
-
- g_cancellable_cancel (sink->cancel);
-
- return TRUE;
-}
-
-static gboolean
-gst_gio_base_sink_unlock_stop (GstBaseSink * base_sink)
-{
- GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
-
- GST_LOG_OBJECT (sink, "resetting cancellable");
-
- g_cancellable_reset (sink->cancel);
-
- return TRUE;
-}
-
-static gboolean
-gst_gio_base_sink_event (GstBaseSink * base_sink, GstEvent * event)
-{
- GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
- GstFlowReturn ret = GST_FLOW_OK;
-
- if (sink->stream == NULL)
- return TRUE;
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_NEWSEGMENT:
- if (G_IS_OUTPUT_STREAM (sink->stream)) {
- GstFormat format;
- gint64 offset;
-
- gst_event_parse_new_segment (event, NULL, NULL, &format, &offset, NULL,
- NULL);
-
- if (format != GST_FORMAT_BYTES) {
- GST_WARNING_OBJECT (sink, "ignored NEWSEGMENT event in %s format",
- gst_format_get_name (format));
- break;
- }
-
- if (GST_GIO_STREAM_IS_SEEKABLE (sink->stream)) {
- ret = gst_gio_seek (sink, G_SEEKABLE (sink->stream), offset,
- sink->cancel);
- if (ret == GST_FLOW_OK)
- sink->position = offset;
- } else {
- ret = GST_FLOW_NOT_SUPPORTED;
- }
- }
- break;
-
- case GST_EVENT_EOS:
- case GST_EVENT_FLUSH_START:
- if (G_IS_OUTPUT_STREAM (sink->stream)) {
- gboolean success;
- GError *err = NULL;
-
- success = g_output_stream_flush (sink->stream, sink->cancel, &err);
-
- if (!success && !gst_gio_error (sink, "g_output_stream_flush", &err,
- &ret)) {
- GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
- ("flush failed: %s", err->message));
- g_clear_error (&err);
- }
- }
- break;
-
- default:
- break;
- }
-
- return (ret == GST_FLOW_OK);
-}
-
-static GstFlowReturn
-gst_gio_base_sink_render (GstBaseSink * base_sink, GstBuffer * buffer)
-{
- GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
- gssize written;
- gboolean success;
- GError *err = NULL;
-
- g_return_val_if_fail (G_IS_OUTPUT_STREAM (sink->stream), GST_FLOW_ERROR);
-
- GST_LOG_OBJECT (sink, "writing %u bytes to offset %" G_GUINT64_FORMAT,
- GST_BUFFER_SIZE (buffer), sink->position);
-
- written = g_output_stream_write (sink->stream,
- GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer), sink->cancel, &err);
-
- success = (written >= 0);
-
- if (G_UNLIKELY (success && written < GST_BUFFER_SIZE (buffer))) {
- /* FIXME: Can this happen? Should we handle it gracefully? gnomevfssink
- * doesn't... */
- GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
- ("Could not write to stream: (short write, only %"
- G_GUINT64_FORMAT " bytes of %d bytes written)",
- written, GST_BUFFER_SIZE (buffer)));
- return GST_FLOW_ERROR;
- }
-
- if (success) {
- sink->position += written;
- return GST_FLOW_OK;
-
- } else {
- GstFlowReturn ret;
-
- if (!gst_gio_error (sink, "g_output_stream_write", &err, &ret)) {
- GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
- ("Could not write to stream: %s", err->message));
- g_clear_error (&err);
- }
-
- return ret;
- }
-}
-
-static gboolean
-gst_gio_base_sink_query (GstPad * pad, GstQuery * query)
-{
- GstGioBaseSink *sink = GST_GIO_BASE_SINK (GST_PAD_PARENT (pad));
- GstFormat format;
-
- switch (GST_QUERY_TYPE (query)) {
- case GST_QUERY_POSITION:
- gst_query_parse_position (query, &format, NULL);
- switch (format) {
- case GST_FORMAT_BYTES:
- case GST_FORMAT_DEFAULT:
- gst_query_set_position (query, GST_FORMAT_BYTES, sink->position);
- return TRUE;
- default:
- return FALSE;
- }
- case GST_QUERY_FORMATS:
- gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
- return TRUE;
- default:
- return gst_pad_query_default (pad, query);
- }
-}
-
-void
-gst_gio_base_sink_set_stream (GstGioBaseSink * sink, GOutputStream * stream)
-{
- g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
- g_return_if_fail ((GST_STATE (sink) != GST_STATE_PLAYING &&
- GST_STATE (sink) != GST_STATE_PAUSED));
-
- if (G_IS_OUTPUT_STREAM (sink->stream)) {
- gboolean success;
- GError *err = NULL;
-
- GST_DEBUG_OBJECT (sink, "closing old stream");
-
- /* FIXME: can block but unfortunately we can't use async operations
- * here because they require a running main loop */
- success = g_output_stream_close (sink->stream, sink->cancel, &err);
-
- if (!success && !gst_gio_error (sink, "g_output_stream_close", &err, NULL)) {
- GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, (NULL),
- ("g_output_stream_close failed: %s", err->message));
- g_clear_error (&err);
- } else if (!success) {
- GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, (NULL),
- ("g_output_stream_close failed"));
- } else {
- GST_DEBUG_OBJECT (sink, "g_output_stream_close succeeded");
- }
-
- g_object_unref (sink->stream);
- sink->stream = NULL;
- }
-
- sink->stream = stream;
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgiobasesink.h
--- a/gst_plugins_base/ext/gio/gstgiobasesink.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_GIO_BASE_SINK_H__
-#define __GST_GIO_BASE_SINK_H__
-
-#include "gstgio.h"
-
-#include
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GIO_BASE_SINK \
- (gst_gio_base_sink_get_type())
-#define GST_GIO_BASE_SINK(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GIO_BASE_SINK,GstGioBaseSink))
-#define GST_GIO_BASE_SINK_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GIO_BASE_SINK,GstGioBaseSinkClass))
-#define GST_IS_GIO_BASE_SINK(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GIO_BASE_SINK))
-#define GST_IS_GIO_BASE_SINK_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GIO_BASE_SINK))
-
-typedef struct _GstGioBaseSink GstGioBaseSink;
-typedef struct _GstGioBaseSinkClass GstGioBaseSinkClass;
-
-struct _GstGioBaseSink
-{
- GstBaseSink sink;
-
- GCancellable *cancel;
- guint64 position;
- GOutputStream *stream;
-};
-
-struct _GstGioBaseSinkClass
-{
- GstBaseSinkClass parent_class;
-};
-
-GType gst_gio_base_sink_get_type (void);
-
-void gst_gio_base_sink_set_stream (GstGioBaseSink *sink, GOutputStream *stream);
-
-G_END_DECLS
-
-#endif /* __GST_GIO_BASE_SINK_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgiobasesrc.c
--- a/gst_plugins_base/ext/gio/gstgiobasesrc.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,383 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-#include "gstgiobasesrc.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_gio_base_src_debug);
-#define GST_CAT_DEFAULT gst_gio_base_src_debug
-
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY);
-
-GST_BOILERPLATE (GstGioBaseSrc, gst_gio_base_src, GstBaseSrc,
- GST_TYPE_BASE_SRC);
-
-static void gst_gio_base_src_finalize (GObject * object);
-static gboolean gst_gio_base_src_start (GstBaseSrc * base_src);
-static gboolean gst_gio_base_src_stop (GstBaseSrc * base_src);
-static gboolean gst_gio_base_src_get_size (GstBaseSrc * base_src,
- guint64 * size);
-static gboolean gst_gio_base_src_is_seekable (GstBaseSrc * base_src);
-static gboolean gst_gio_base_src_unlock (GstBaseSrc * base_src);
-static gboolean gst_gio_base_src_unlock_stop (GstBaseSrc * base_src);
-static gboolean gst_gio_base_src_check_get_range (GstBaseSrc * base_src);
-static GstFlowReturn gst_gio_base_src_create (GstBaseSrc * base_src,
- guint64 offset, guint size, GstBuffer ** buf);
-
-static void
-gst_gio_base_src_base_init (gpointer gclass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- GST_DEBUG_CATEGORY_INIT (gst_gio_base_src_debug, "gio_base_src", 0,
- "GIO base source");
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_factory));
-}
-
-static void
-gst_gio_base_src_class_init (GstGioBaseSrcClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
- GstBaseSrcClass *gstbasesrc_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstbasesrc_class = (GstBaseSrcClass *) klass;
-
- gobject_class->finalize = gst_gio_base_src_finalize;
-
- gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_gio_base_src_start);
- gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_gio_base_src_stop);
- gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_gio_base_src_get_size);
- gstbasesrc_class->is_seekable =
- GST_DEBUG_FUNCPTR (gst_gio_base_src_is_seekable);
- gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_gio_base_src_unlock);
- gstbasesrc_class->unlock_stop =
- GST_DEBUG_FUNCPTR (gst_gio_base_src_unlock_stop);
- gstbasesrc_class->check_get_range =
- GST_DEBUG_FUNCPTR (gst_gio_base_src_check_get_range);
- gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_gio_base_src_create);
-}
-
-static void
-gst_gio_base_src_init (GstGioBaseSrc * src, GstGioBaseSrcClass * gclass)
-{
- src->cancel = g_cancellable_new ();
-}
-
-static void
-gst_gio_base_src_finalize (GObject * object)
-{
- GstGioBaseSrc *src = GST_GIO_BASE_SRC (object);
-
- if (src->cancel) {
- g_object_unref (src->cancel);
- src->cancel = NULL;
- }
-
- if (src->stream) {
- g_object_unref (src->stream);
- src->stream = NULL;
- }
-
- GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-static gboolean
-gst_gio_base_src_start (GstBaseSrc * base_src)
-{
- GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
-
- if (!G_IS_INPUT_STREAM (src->stream)) {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
- ("No stream given yet"));
- return FALSE;
- }
-
- src->position = 0;
-
- GST_DEBUG_OBJECT (src, "started stream");
-
- return TRUE;
-}
-
-static gboolean
-gst_gio_base_src_stop (GstBaseSrc * base_src)
-{
- GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
- gboolean success;
- GError *err = NULL;
-
- if (G_IS_INPUT_STREAM (src->stream)) {
- GST_DEBUG_OBJECT (src, "closing stream");
-
- /* FIXME: can block but unfortunately we can't use async operations
- * here because they require a running main loop */
- success = g_input_stream_close (src->stream, src->cancel, &err);
-
- if (!success && !gst_gio_error (src, "g_input_stream_close", &err, NULL)) {
- GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL),
- ("g_input_stream_close failed: %s", err->message));
- g_clear_error (&err);
- } else if (!success) {
- GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL),
- ("g_input_stream_close failed"));
- } else {
- GST_DEBUG_OBJECT (src, "g_input_stream_close succeeded");
- }
-
- g_object_unref (src->stream);
- src->stream = NULL;
- }
-
- return TRUE;
-}
-
-static gboolean
-gst_gio_base_src_get_size (GstBaseSrc * base_src, guint64 * size)
-{
- GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
-
- if (G_IS_FILE_INPUT_STREAM (src->stream)) {
- GFileInfo *info;
- GError *err = NULL;
-
- info = g_file_input_stream_query_info (G_FILE_INPUT_STREAM (src->stream),
- G_FILE_ATTRIBUTE_STANDARD_SIZE, src->cancel, &err);
-
- if (info != NULL) {
- *size = g_file_info_get_size (info);
- g_object_unref (info);
- GST_DEBUG_OBJECT (src, "found size: %" G_GUINT64_FORMAT, *size);
- return TRUE;
- }
-
- if (!gst_gio_error (src, "g_file_input_stream_query_info", &err, NULL)) {
-
- if (GST_GIO_ERROR_MATCHES (err, NOT_SUPPORTED))
- GST_DEBUG_OBJECT (src, "size information not available");
- else
- GST_WARNING_OBJECT (src, "size information retrieval failed: %s",
- err->message);
-
- g_clear_error (&err);
- }
- } else if (GST_GIO_STREAM_IS_SEEKABLE (src->stream)) {
- goffset old;
- goffset stream_size;
- gboolean ret;
- GSeekable *seekable = G_SEEKABLE (src->stream);
- GError *err = NULL;
-
- old = g_seekable_tell (seekable);
-
- ret = g_seekable_seek (seekable, 0, G_SEEK_END, src->cancel, &err);
- if (!ret) {
- if (!gst_gio_error (src, "g_seekable_seek", &err, NULL)) {
- if (GST_GIO_ERROR_MATCHES (err, NOT_SUPPORTED))
- GST_DEBUG_OBJECT (src,
- "Seeking to the end of stream is not supported");
- else
- GST_WARNING_OBJECT (src, "Seeking to end of stream failed: %s",
- err->message);
- g_clear_error (&err);
- } else {
- GST_WARNING_OBJECT (src, "Seeking to end of stream failed");
- }
-
- return FALSE;
- }
-
- stream_size = g_seekable_tell (seekable);
-
- ret = g_seekable_seek (seekable, old, G_SEEK_SET, src->cancel, &err);
- if (!ret) {
- if (!gst_gio_error (src, "g_seekable_seek", &err, NULL)) {
- if (GST_GIO_ERROR_MATCHES (err, NOT_SUPPORTED))
- GST_ERROR_OBJECT (src, "Seeking to the old position not supported");
- else
- GST_ERROR_OBJECT (src, "Seeking to the old position failed: %s",
- err->message);
- g_clear_error (&err);
- } else {
- GST_ERROR_OBJECT (src, "Seeking to the old position faile");
- }
-
- return FALSE;
- }
-
- if (stream_size >= 0) {
- *size = stream_size;
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static gboolean
-gst_gio_base_src_is_seekable (GstBaseSrc * base_src)
-{
- GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
- gboolean seekable;
-
- seekable = GST_GIO_STREAM_IS_SEEKABLE (src->stream);
-
- GST_DEBUG_OBJECT (src, "can seek: %d", seekable);
-
- return seekable;
-}
-
-static gboolean
-gst_gio_base_src_unlock (GstBaseSrc * base_src)
-{
- GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
-
- GST_LOG_OBJECT (src, "triggering cancellation");
-
- g_cancellable_cancel (src->cancel);
-
- return TRUE;
-}
-
-static gboolean
-gst_gio_base_src_unlock_stop (GstBaseSrc * base_src)
-{
- GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
-
- GST_LOG_OBJECT (src, "resetting cancellable");
-
- g_cancellable_reset (src->cancel);
-
- return TRUE;
-}
-
-static gboolean
-gst_gio_base_src_check_get_range (GstBaseSrc * base_src)
-{
- /* FIXME: Implement dry-run variant using guesswork like gnomevfssrc? */
-
- return GST_CALL_PARENT_WITH_DEFAULT (GST_BASE_SRC_CLASS,
- check_get_range, (base_src), FALSE);
-}
-
-static GstFlowReturn
-gst_gio_base_src_create (GstBaseSrc * base_src, guint64 offset, guint size,
- GstBuffer ** buf_return)
-{
- GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
- GstBuffer *buf;
- gssize read;
- gboolean success, eos;
- GstFlowReturn ret = GST_FLOW_OK;
- GError *err = NULL;
-
- g_return_val_if_fail (G_IS_INPUT_STREAM (src->stream), GST_FLOW_ERROR);
-
- if (G_UNLIKELY (offset != src->position)) {
- if (!GST_GIO_STREAM_IS_SEEKABLE (src->stream))
- return GST_FLOW_NOT_SUPPORTED;
-
- ret = gst_gio_seek (src, G_SEEKABLE (src->stream), offset, src->cancel);
-
- if (ret == GST_FLOW_OK)
- src->position = offset;
- else
- return ret;
- }
-
- buf = gst_buffer_new_and_alloc (size);
-
- GST_LOG_OBJECT (src, "reading %u bytes from offset %" G_GUINT64_FORMAT,
- size, offset);
-
- read =
- g_input_stream_read (G_INPUT_STREAM (src->stream), GST_BUFFER_DATA (buf),
- size, src->cancel, &err);
-
- success = (read >= 0);
- eos = (size > 0 && read == 0);
-
- if (!success && !gst_gio_error (src, "g_input_stream_read", &err, &ret)) {
- GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
- ("Could not read from stream: %s", err->message));
- g_clear_error (&err);
- }
-
- if (success && !eos) {
- src->position += read;
- GST_BUFFER_OFFSET (buf) = offset;
- GST_BUFFER_SIZE (buf) = read;
- *buf_return = buf;
- } else {
- /* !success || eos */
- gst_buffer_unref (buf);
- }
-
- if (eos)
- ret = GST_FLOW_UNEXPECTED;
-
- return ret;
-}
-
-void
-gst_gio_base_src_set_stream (GstGioBaseSrc * src, GInputStream * stream)
-{
- gboolean success;
- GError *err = NULL;
-
- g_return_if_fail (G_IS_INPUT_STREAM (stream));
- g_return_if_fail ((GST_STATE (src) != GST_STATE_PLAYING &&
- GST_STATE (src) != GST_STATE_PAUSED));
-
- if (G_IS_INPUT_STREAM (src->stream)) {
- GST_DEBUG_OBJECT (src, "closing old stream");
-
- /* FIXME: can block but unfortunately we can't use async operations
- * here because they require a running main loop */
- success = g_input_stream_close (src->stream, src->cancel, &err);
-
- if (!success && !gst_gio_error (src, "g_input_stream_close", &err, NULL)) {
- GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL),
- ("g_input_stream_close failed: %s", err->message));
- g_clear_error (&err);
- } else if (!success) {
- GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL),
- ("g_input_stream_close failed"));
- } else {
- GST_DEBUG_OBJECT (src, "g_input_stream_close succeeded");
- }
-
- g_object_unref (src->stream);
- src->stream = NULL;
- }
-
- src->stream = stream;
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgiobasesrc.h
--- a/gst_plugins_base/ext/gio/gstgiobasesrc.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_GIO_BASE_SRC_H__
-#define __GST_GIO_BASE_SRC_H__
-
-#include "gstgio.h"
-
-#include
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GIO_BASE_SRC \
- (gst_gio_base_src_get_type())
-#define GST_GIO_BASE_SRC(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GIO_BASE_SRC,GstGioBaseSrc))
-#define GST_GIO_BASE_SRC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GIO_BASE_SRC,GstGioBaseSrcClass))
-#define GST_IS_GIO_BASE_SRC(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GIO_BASE_SRC))
-#define GST_IS_GIO_BASE_SRC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GIO_BASE_SRC))
-
-typedef struct _GstGioBaseSrc GstGioBaseSrc;
-typedef struct _GstGioBaseSrcClass GstGioBaseSrcClass;
-
-struct _GstGioBaseSrc
-{
- GstBaseSrc src;
-
- GCancellable *cancel;
- guint64 position;
- GInputStream *stream;
-};
-
-struct _GstGioBaseSrcClass
-{
- GstBaseSrcClass parent_class;
-};
-
-GType gst_gio_base_src_get_type (void);
-
-void gst_gio_base_src_set_stream (GstGioBaseSrc *src, GInputStream *stream);
-
-G_END_DECLS
-
-#endif /* __GST_GIO_BASE_SRC_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgiosink.c
--- a/gst_plugins_base/ext/gio/gstgiosink.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,250 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:element-giosink
- * @short_description: Write a stream to any GIO-supported location
- * @see_also: #GstFileSink, #GstGnomeVFSSink, #GstGioSrc
- *
- *
- *
- * This plugin writes incoming data to a local or remote location specified
- * by an URI. This location can be specified using any protocol supported by
- * the GIO library or it's VFS backends. Common protocols are 'file', 'ftp',
- * or 'smb'.
- *
- *
- * Example pipeline:
- *
- * gst-launch -v filesrc location=input.xyz ! giosink location=file:///home/joe/out.xyz
- *
- * The above pipeline will simply copy a local file. Instead of giosink,
- * we could just as well have used the filesink element here.
- *
- *
- * Another example pipeline:
- *
- * gst-launch -v filesrc location=foo.mp3 ! mad ! flacenc ! giosink location=smb://othercomputer/foo.flac
- *
- * The above pipeline will re-encode an mp3 file into FLAC format and store
- * it on a remote host using the Samba protocol.
- *
- *
- * Another example pipeline:
- *
- * gst-launch -v audiotestsrc num-buffers=100 ! vorbisenc ! oggmux ! giosink location=file:///home/foo/bar.ogg
- *
- * The above pipeline will encode a 440Hz sine wave to Ogg Vorbis and stores
- * it in the home directory of user foo.
- *
- *
- */
-
-/* FIXME: We would like to mount the enclosing volume of an URL
- * if it isn't mounted yet but this is possible async-only.
- * Unfortunately this requires a running main loop from the
- * default context and we can't guarantuee this!
- *
- * We would also like to do authentication while mounting.
- */
-
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-#include "gstgiosink.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_gio_sink_debug);
-#define GST_CAT_DEFAULT gst_gio_sink_debug
-
-/* Filter signals and args */
-enum
-{
- LAST_SIGNAL
-};
-
-enum
-{
- ARG_0,
- ARG_LOCATION
-};
-
-GST_BOILERPLATE_FULL (GstGioSink, gst_gio_sink, GstGioBaseSink,
- GST_TYPE_GIO_BASE_SINK, gst_gio_uri_handler_do_init);
-
-static void gst_gio_sink_finalize (GObject * object);
-static void gst_gio_sink_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_gio_sink_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-static gboolean gst_gio_sink_start (GstBaseSink * base_sink);
-
-static void
-gst_gio_sink_base_init (gpointer gclass)
-{
- static GstElementDetails element_details = {
- "GIO sink",
- "Sink/File",
- "Write to any GIO-supported location",
- "Ren\xc3\xa9 Stadler , "
- "Sebastian Dröge "
- };
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- GST_DEBUG_CATEGORY_INIT (gst_gio_sink_debug, "gio_sink", 0, "GIO sink");
-
- gst_element_class_set_details (element_class, &element_details);
-}
-
-static void
-gst_gio_sink_class_init (GstGioSinkClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
- GstBaseSinkClass *gstbasesink_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstbasesink_class = (GstBaseSinkClass *) klass;
-
- gobject_class->finalize = gst_gio_sink_finalize;
- gobject_class->set_property = gst_gio_sink_set_property;
- gobject_class->get_property = gst_gio_sink_get_property;
-
- g_object_class_install_property (gobject_class, ARG_LOCATION,
- g_param_spec_string ("location", "Location", "URI location to write to",
- NULL, G_PARAM_READWRITE));
-
- gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_gio_sink_start);
-}
-
-static void
-gst_gio_sink_init (GstGioSink * sink, GstGioSinkClass * gclass)
-{
-}
-
-static void
-gst_gio_sink_finalize (GObject * object)
-{
- GstGioSink *sink = GST_GIO_SINK (object);
-
- if (sink->location) {
- g_free (sink->location);
- sink->location = NULL;
- }
-
- GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-static void
-gst_gio_sink_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstGioSink *sink = GST_GIO_SINK (object);
-
- switch (prop_id) {
- case ARG_LOCATION:
- if (GST_STATE (sink) == GST_STATE_PLAYING ||
- GST_STATE (sink) == GST_STATE_PAUSED)
- break;
-
- g_free (sink->location);
- sink->location = g_strdup (g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_gio_sink_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstGioSink *sink = GST_GIO_SINK (object);
-
- switch (prop_id) {
- case ARG_LOCATION:
- g_value_set_string (value, sink->location);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static gboolean
-gst_gio_sink_start (GstBaseSink * base_sink)
-{
- GstGioSink *sink = GST_GIO_SINK (base_sink);
- GFile *file;
- GOutputStream *stream;
- GCancellable *cancel = GST_GIO_BASE_SINK (sink)->cancel;
- gboolean success;
- GError *err = NULL;
-
- if (sink->location == NULL) {
- GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
- ("No location given"));
- return FALSE;
- }
-
- file = g_file_new_for_uri (sink->location);
-
- if (file == NULL) {
- GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
- ("Malformed URI or protocol not supported (%s)", sink->location));
- return FALSE;
- }
-
- stream =
- G_OUTPUT_STREAM (g_file_create (file, G_FILE_CREATE_NONE, cancel, &err));
-
- success = (stream != NULL);
-
- g_object_unref (file);
-
- if (!success && !gst_gio_error (sink, "g_file_create", &err, NULL)) {
-
- /*if (GST_GIO_ERROR_MATCHES (err, EXISTS)) */
- /* FIXME: Retry with replace if overwrite == TRUE! */
-
- if (GST_GIO_ERROR_MATCHES (err, NOT_FOUND))
- GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND, (NULL),
- ("Could not open location %s for writing: %s",
- sink->location, err->message));
- else
- GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_READ, (NULL),
- ("Could not open location %s for writing: %s",
- sink->location, err->message));
-
- g_clear_error (&err);
- }
-
- if (!success)
- return FALSE;
-
- GST_DEBUG_OBJECT (sink, "opened location %s", sink->location);
-
- gst_gio_base_sink_set_stream (GST_GIO_BASE_SINK (sink), stream);
-
- return GST_BASE_SINK_CLASS (parent_class)->start (base_sink);
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgiosink.h
--- a/gst_plugins_base/ext/gio/gstgiosink.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_GIO_SINK_H__
-#define __GST_GIO_SINK_H__
-
-#include "gstgio.h"
-#include "gstgiobasesink.h"
-
-#include
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GIO_SINK \
- (gst_gio_sink_get_type())
-#define GST_GIO_SINK(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GIO_SINK,GstGioSink))
-#define GST_GIO_SINK_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GIO_SINK,GstGioSinkClass))
-#define GST_IS_GIO_SINK(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GIO_SINK))
-#define GST_IS_GIO_SINK_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GIO_SINK))
-
-typedef struct _GstGioSink GstGioSink;
-typedef struct _GstGioSinkClass GstGioSinkClass;
-
-/**
- * GstGioSink:
- *
- * Opaque data structure.
- */
-struct _GstGioSink
-{
- GstGioBaseSink sink;
-
- /*< private >*/
- gchar *location;
-
- GMainLoop *loop;
- gboolean mount_successful;
-};
-
-struct _GstGioSinkClass
-{
- GstGioBaseSinkClass parent_class;
-};
-
-GType gst_gio_sink_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_GIO_SINK_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgiosrc.c
--- a/gst_plugins_base/ext/gio/gstgiosrc.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,238 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:element-giosrc
- * @short_description: Read from any GIO-supported location
- * @see_also: #GstFileSrc, #GstGnomeVFSSrc, #GstGioSink
- *
- *
- *
- * This plugin reads data from a local or remote location specified
- * by an URI. This location can be specified using any protocol supported by
- * the GIO library or it's VFS backends. Common protocols are 'file', 'http',
- * 'ftp', or 'smb'.
- *
- *
- * Example pipeline:
- *
- * gst-launch -v giosrc location=file:///home/joe/foo.xyz ! fakesink
- *
- * The above pipeline will simply read a local file and do nothing with the
- * data read. Instead of giosrc, we could just as well have used the
- * filesrc element here.
- *
- *
- * Another example pipeline:
- *
- * gst-launch -v giosrc location=smb://othercomputer/foo.xyz ! filesink location=/home/joe/foo.xyz
- *
- * The above pipeline will copy a file from a remote host to the local file
- * system using the Samba protocol.
- *
- *
- * Yet another example pipeline:
- *
- * gst-launch -v giosrc location=http://music.foobar.com/demo.mp3 ! mad ! audioconvert ! audioresample ! alsasink
- *
- * The above pipeline will read and decode and play an mp3 file from a
- * web server using the http protocol.
- *
- *
- */
-
-/* FIXME: We would like to mount the enclosing volume of an URL
- * if it isn't mounted yet but this is possible async-only.
- * Unfortunately this requires a running main loop from the
- * default context and we can't guarantuee this!
- *
- * We would also like to do authentication while mounting.
- */
-
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-#include "gstgiosrc.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_gio_src_debug);
-#define GST_CAT_DEFAULT gst_gio_src_debug
-
-enum
-{
- ARG_0,
- ARG_LOCATION
-};
-
-GST_BOILERPLATE_FULL (GstGioSrc, gst_gio_src, GstGioBaseSrc,
- GST_TYPE_GIO_BASE_SRC, gst_gio_uri_handler_do_init);
-
-static void gst_gio_src_finalize (GObject * object);
-static void gst_gio_src_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_gio_src_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-static gboolean gst_gio_src_start (GstBaseSrc * base_src);
-
-static void
-gst_gio_src_base_init (gpointer gclass)
-{
- static GstElementDetails element_details = {
- "GIO source",
- "Source/File",
- "Read from any GIO-supported location",
- "Ren\xc3\xa9 Stadler , "
- "Sebastian Dröge "
- };
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- GST_DEBUG_CATEGORY_INIT (gst_gio_src_debug, "gio_src", 0, "GIO source");
-
- gst_element_class_set_details (element_class, &element_details);
-}
-
-static void
-gst_gio_src_class_init (GstGioSrcClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
- GstBaseSrcClass *gstbasesrc_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstbasesrc_class = (GstBaseSrcClass *) klass;
-
- gobject_class->finalize = gst_gio_src_finalize;
- gobject_class->set_property = gst_gio_src_set_property;
- gobject_class->get_property = gst_gio_src_get_property;
-
- g_object_class_install_property (gobject_class, ARG_LOCATION,
- g_param_spec_string ("location", "Location", "URI location to read from",
- NULL, G_PARAM_READWRITE));
-
- gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_gio_src_start);
-}
-
-static void
-gst_gio_src_init (GstGioSrc * src, GstGioSrcClass * gclass)
-{
-}
-
-static void
-gst_gio_src_finalize (GObject * object)
-{
- GstGioSrc *src = GST_GIO_SRC (object);
-
- if (src->location) {
- g_free (src->location);
- src->location = NULL;
- }
-
- GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-static void
-gst_gio_src_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstGioSrc *src = GST_GIO_SRC (object);
-
- switch (prop_id) {
- case ARG_LOCATION:
- if (GST_STATE (src) == GST_STATE_PLAYING ||
- GST_STATE (src) == GST_STATE_PAUSED)
- break;
-
- g_free (src->location);
- src->location = g_strdup (g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_gio_src_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstGioSrc *src = GST_GIO_SRC (object);
-
- switch (prop_id) {
- case ARG_LOCATION:
- g_value_set_string (value, src->location);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static gboolean
-gst_gio_src_start (GstBaseSrc * base_src)
-{
- GstGioSrc *src = GST_GIO_SRC (base_src);
- GFile *file;
- GError *err = NULL;
- GInputStream *stream;
- GCancellable *cancel = GST_GIO_BASE_SRC (src)->cancel;
-
- if (src->location == NULL) {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), ("No location given"));
- return FALSE;
- }
-
- file = g_file_new_for_uri (src->location);
-
- if (file == NULL) {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
- ("Malformed URI or protocol not supported (%s)", src->location));
- return FALSE;
- }
-
- stream = G_INPUT_STREAM (g_file_read (file, cancel, &err));
-
- g_object_unref (file);
-
- if (stream == NULL && !gst_gio_error (src, "g_file_read", &err, NULL)) {
-
- if (GST_GIO_ERROR_MATCHES (err, NOT_FOUND)) {
- GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL),
- ("Could not open location %s for reading: %s",
- src->location, err->message));
- } else {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
- ("Could not open location %s for reading: %s",
- src->location, err->message));
- }
-
- g_clear_error (&err);
- return FALSE;
- } else if (stream == NULL) {
- return FALSE;
- }
-
- gst_gio_base_src_set_stream (GST_GIO_BASE_SRC (src), stream);
-
- GST_DEBUG_OBJECT (src, "opened location %s", src->location);
-
- return GST_BASE_SRC_CLASS (parent_class)->start (base_src);
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgiosrc.h
--- a/gst_plugins_base/ext/gio/gstgiosrc.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_GIO_SRC_H__
-#define __GST_GIO_SRC_H__
-
-#include "gstgio.h"
-#include "gstgiobasesrc.h"
-
-#include
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GIO_SRC \
- (gst_gio_src_get_type())
-#define GST_GIO_SRC(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GIO_SRC,GstGioSrc))
-#define GST_GIO_SRC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GIO_SRC,GstGioSrcClass))
-#define GST_IS_GIO_SRC(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GIO_SRC))
-#define GST_IS_GIO_SRC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GIO_SRC))
-
-typedef struct _GstGioSrc GstGioSrc;
-typedef struct _GstGioSrcClass GstGioSrcClass;
-
-/**
- * GstGioSrc:
- *
- * Opaque data structure.
- */
-struct _GstGioSrc
-{
- GstGioBaseSrc src;
-
- /*< private >*/
- gchar *location;
-
- GMainLoop *loop;
- gboolean mount_successful;
-};
-
-struct _GstGioSrcClass
-{
- GstGioBaseSrcClass parent_class;
-};
-
-GType gst_gio_src_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_GIO_SRC_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgiostreamsink.c
--- a/gst_plugins_base/ext/gio/gstgiostreamsink.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:element-giostreamsink
- * @short_description: Write to a GIO GOutputStream
- *
- *
- *
- * This plugin writes incoming data to a custom GIO #GOutputStream.
- *
- *
- * It can, for example, be used to write a stream to memory with a
- * #GMemoryOuputStream or to write to a file with a #GFileOuputStream.
- *
- * Example code
- *
- * The following example writes the received data to a #GMemoryOutputStream.
- *
-
-#include <gst/gst.h>
-#include <gio/gio.h>
-
-...
-
-GstElement *sink;
-GMemoryOuputStream *stream;
-// out_data will contain the received data
-guint8 *out_data;
-
-...
-
-stream = G_MEMORY_OUTPUT_STREAM (g_memory_output_stream_new (NULL, 0,
- (GReallocFunc) g_realloc, (GDestroyNotify) g_free));
-sink = gst_element_factory_make ("giostreamsink", "sink");
-g_object_set (G_OBJECT (sink), "stream", stream, NULL);
-
-...
-
-// after processing get the written data
-out_data = g_memory_ouput_stream_get_data (G_MEMORY_OUTPUT_STREAM (stream));
-
-...
-
- *
- *
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-#include "gstgiostreamsink.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_gio_stream_sink_debug);
-#define GST_CAT_DEFAULT gst_gio_stream_sink_debug
-
-/* Filter signals and args */
-enum
-{
- LAST_SIGNAL
-};
-
-enum
-{
- ARG_0,
- ARG_STREAM
-};
-
-GST_BOILERPLATE (GstGioStreamSink, gst_gio_stream_sink, GstGioBaseSink,
- GST_TYPE_GIO_BASE_SINK);
-
-static void gst_gio_stream_sink_finalize (GObject * object);
-static void gst_gio_stream_sink_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_gio_stream_sink_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static void
-gst_gio_stream_sink_base_init (gpointer gclass)
-{
- static GstElementDetails element_details = {
- "GIO stream sink",
- "Sink",
- "Write to any GIO stream",
- "Sebastian Dröge "
- };
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- GST_DEBUG_CATEGORY_INIT (gst_gio_stream_sink_debug, "gio_stream_sink", 0,
- "GIO stream sink");
-
- gst_element_class_set_details (element_class, &element_details);
-}
-
-static void
-gst_gio_stream_sink_class_init (GstGioStreamSinkClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
- GstBaseSinkClass *gstbasesink_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstbasesink_class = (GstBaseSinkClass *) klass;
-
- gobject_class->finalize = gst_gio_stream_sink_finalize;
- gobject_class->set_property = gst_gio_stream_sink_set_property;
- gobject_class->get_property = gst_gio_stream_sink_get_property;
-
- g_object_class_install_property (gobject_class, ARG_STREAM,
- g_param_spec_object ("stream", "Stream", "Stream to write to",
- G_TYPE_OUTPUT_STREAM, G_PARAM_READWRITE));
-}
-
-static void
-gst_gio_stream_sink_init (GstGioStreamSink * sink,
- GstGioStreamSinkClass * gclass)
-{
-}
-
-static void
-gst_gio_stream_sink_finalize (GObject * object)
-{
- GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-static void
-gst_gio_stream_sink_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstGioStreamSink *sink = GST_GIO_STREAM_SINK (object);
-
- switch (prop_id) {
- case ARG_STREAM:{
- GObject *stream;
-
- if (GST_STATE (sink) == GST_STATE_PLAYING ||
- GST_STATE (sink) == GST_STATE_PAUSED)
- break;
-
- stream = g_value_dup_object (value);
- if (G_IS_OUTPUT_STREAM (stream))
- gst_gio_base_sink_set_stream (GST_GIO_BASE_SINK (sink),
- G_OUTPUT_STREAM (stream));
-
- break;
- }
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_gio_stream_sink_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstGioStreamSink *sink = GST_GIO_STREAM_SINK (object);
-
- switch (prop_id) {
- case ARG_STREAM:
- g_value_set_object (value, GST_GIO_BASE_SINK (sink)->stream);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgiostreamsink.h
--- a/gst_plugins_base/ext/gio/gstgiostreamsink.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_GIO_STREAM_SINK_H__
-#define __GST_GIO_STREAM_SINK_H__
-
-#include "gstgio.h"
-#include "gstgiobasesink.h"
-
-#include
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GIO_STREAM_SINK \
- (gst_gio_stream_sink_get_type())
-#define GST_GIO_STREAM_SINK(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GIO_STREAM_SINK,GstGioStreamSink))
-#define GST_GIO_STREAM_SINK_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GIO_STREAM_SINK,GstGioStreamSinkClass))
-#define GST_IS_GIO_STREAM_SINK(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GIO_STREAM_SINK))
-#define GST_IS_GIO_STREAM_SINK_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GIO_STREAM_SINK))
-
-typedef struct _GstGioStreamSink GstGioStreamSink;
-typedef struct _GstGioStreamSinkClass GstGioStreamSinkClass;
-
-/**
- * GstGioStreamSink:
- *
- * Opaque data structure.
- */
-struct _GstGioStreamSink
-{
- GstGioBaseSink sink;
-};
-
-struct _GstGioStreamSinkClass
-{
- GstGioBaseSinkClass parent_class;
-};
-
-GType gst_gio_stream_sink_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_GIO_STREAM_SINK_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgiostreamsrc.c
--- a/gst_plugins_base/ext/gio/gstgiostreamsrc.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:element-giostreamsrc
- * @short_description: Reads data from a GIO GInputStream
- *
- *
- *
- * This plugin reads data from a custom GIO #GInputStream.
- *
- *
- * It can, for example, be used to read data from memory with a
- * #GMemoryInputStream or to read from a file with a
- * #GFileInputStream.
- *
- * Example code
- *
- * The following example reads data from a #GMemoryOutputStream.
- *
-
-#include <gst/gst.h>
-#include <gio/gio.h>
-
-...
-
-GstElement *src;
-GMemoryInputStream *stream;
-// in_data will contain the data to send
-guint8 *in_data;
-gint i;
-
-...
-in_data = g_new (guint8, 512);
-for (i = 0; i < 512; i++)
- in_data[i] = i % 256;
-
-stream = G_MEMORY_INPUT_STREAM (g_memory_input_stream_new_from_data (in_data, 512,
- (GDestroyNotify) g_free));
-src = gst_element_factory_make ("giostreamsrc", "src");
-g_object_set (G_OBJECT (src), "stream", stream, NULL);
-
-...
-
- *
- *
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-#include "gstgiostreamsrc.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_gio_stream_src_debug);
-#define GST_CAT_DEFAULT gst_gio_stream_src_debug
-
-enum
-{
- ARG_0,
- ARG_STREAM
-};
-
-GST_BOILERPLATE (GstGioStreamSrc, gst_gio_stream_src, GstGioBaseSrc,
- GST_TYPE_GIO_BASE_SRC);
-
-static void gst_gio_stream_src_finalize (GObject * object);
-static void gst_gio_stream_src_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_gio_stream_src_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static void
-gst_gio_stream_src_base_init (gpointer gclass)
-{
- static GstElementDetails element_details = {
- "GIO stream source",
- "Source",
- "Read from any GIO stream",
- "Sebastian Dröge "
- };
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- GST_DEBUG_CATEGORY_INIT (gst_gio_stream_src_debug, "gio_stream_src", 0,
- "GIO source");
-
- gst_element_class_set_details (element_class, &element_details);
-}
-
-static void
-gst_gio_stream_src_class_init (GstGioStreamSrcClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
- GstBaseSrcClass *gstbasesrc_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstbasesrc_class = (GstBaseSrcClass *) klass;
-
- gobject_class->finalize = gst_gio_stream_src_finalize;
- gobject_class->set_property = gst_gio_stream_src_set_property;
- gobject_class->get_property = gst_gio_stream_src_get_property;
-
- g_object_class_install_property (gobject_class, ARG_STREAM,
- g_param_spec_object ("stream", "Stream", "Stream to read from",
- G_TYPE_INPUT_STREAM, G_PARAM_READWRITE));
-}
-
-static void
-gst_gio_stream_src_init (GstGioStreamSrc * src, GstGioStreamSrcClass * gclass)
-{
-}
-
-static void
-gst_gio_stream_src_finalize (GObject * object)
-{
- GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-static void
-gst_gio_stream_src_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstGioStreamSrc *src = GST_GIO_STREAM_SRC (object);
-
- switch (prop_id) {
- case ARG_STREAM:{
- GObject *stream;
-
- if (GST_STATE (src) == GST_STATE_PLAYING ||
- GST_STATE (src) == GST_STATE_PAUSED)
- break;
-
- stream = g_value_dup_object (value);
- if (G_IS_INPUT_STREAM (stream))
- gst_gio_base_src_set_stream (GST_GIO_BASE_SRC (src),
- G_INPUT_STREAM (stream));
-
- break;
- }
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_gio_stream_src_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstGioStreamSrc *src = GST_GIO_STREAM_SRC (object);
-
- switch (prop_id) {
- case ARG_STREAM:
- g_value_set_object (value, GST_GIO_BASE_SRC (src)->stream);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gio/gstgiostreamsrc.h
--- a/gst_plugins_base/ext/gio/gstgiostreamsrc.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2007 Rene Stadler
- * Copyright (C) 2007 Sebastian Dröge
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_GIO_STREAM_SRC_H__
-#define __GST_GIO_STREAM_SRC_H__
-
-#include "gstgio.h"
-#include "gstgiobasesrc.h"
-
-#include
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GIO_STREAM_SRC \
- (gst_gio_stream_src_get_type())
-#define GST_GIO_STREAM_SRC(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GIO_STREAM_SRC,GstGioStreamSrc))
-#define GST_GIO_STREAM_SRC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GIO_STREAM_SRC,GstGioStreamSrcClass))
-#define GST_IS_GIO_STREAM_SRC(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GIO_STREAM_SRC))
-#define GST_IS_GIO_STREAM_SRC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GIO_STREAM_SRC))
-
-typedef struct _GstGioStreamSrc GstGioStreamSrc;
-typedef struct _GstGioStreamSrcClass GstGioStreamSrcClass;
-
-/**
- * GstGioStreamSrc:
- *
- * Opaque data structure.
- */
-struct _GstGioStreamSrc
-{
- GstGioBaseSrc src;
-};
-
-struct _GstGioStreamSrcClass
-{
- GstGioBaseSrcClass parent_class;
-};
-
-GType gst_gio_stream_src_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_GIO_STREAM_SRC_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gnomevfs/gstgnomevfs.c
--- a/gst_plugins_base/ext/gnomevfs/gstgnomevfs.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/* GStreamer
- * Copyright (C) 2003 Benjamin Otte
- *
- * gnomevfs.c: register gnomevfs elements
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "gst/gst-i18n-plugin.h"
-
-#include "gstgnomevfs.h"
-#include "gstgnomevfssrc.h"
-#include "gstgnomevfssink.h"
-
-#include
-#include
-
-#include
-
-gchar *
-gst_gnome_vfs_location_to_uri_string (const gchar * location)
-{
- gchar *newloc, *ret;
-
- if (location == NULL)
- return NULL;
-
- /* already an URI string? */
- if (strstr (location, "://"))
- return g_strdup (location);
-
- newloc = gnome_vfs_escape_path_string (location);
-
- if (newloc && *newloc == '/') {
- ret = g_strdup_printf ("file://%s", newloc);
- } else {
- gchar *curdir;
-
- curdir = g_get_current_dir ();
- ret = g_strdup_printf ("file://%s/%s", curdir, newloc);
- g_free (curdir);
- }
-
- g_free (newloc);
- return ret;
-}
-
-GType
-gst_gnome_vfs_uri_get_type (void)
-{
- static GType type; /* 0 */
-
- if (type == 0) {
- type = g_boxed_type_register_static ("GnomeVFSURI",
- (GBoxedCopyFunc) gnome_vfs_uri_ref,
- (GBoxedFreeFunc) gnome_vfs_uri_unref);
- }
-
- return type;
-}
-
-static gpointer
-gst_gnome_vfs_handle_copy (gpointer handle)
-{
- return handle;
-}
-
-static void
-gst_gnome_vfs_handle_free (gpointer handle)
-{
- return;
-}
-
-GType
-gst_gnome_vfs_handle_get_type (void)
-{
- static GType type; /* 0 */
-
- if (type == 0) {
- /* hackish, but makes it show up nicely in gst-inspect */
- type = g_boxed_type_register_static ("GnomeVFSHandle",
- (GBoxedCopyFunc) gst_gnome_vfs_handle_copy,
- (GBoxedFreeFunc) gst_gnome_vfs_handle_free);
- }
-
- return type;
-}
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
- /* gnome vfs engine init */
- if (!gnome_vfs_initialized ()) {
- if (!gnome_vfs_init ()) {
- GST_WARNING ("Failed to initialize GnomeVFS - not registering plugin!");
- return FALSE;
- }
- }
-
- if (!gst_element_register (plugin, "gnomevfssrc", GST_RANK_SECONDARY,
- gst_gnome_vfs_src_get_type ()))
- return FALSE;
-
- if (!gst_element_register (plugin, "gnomevfssink", GST_RANK_SECONDARY,
- gst_gnome_vfs_sink_get_type ()))
- return FALSE;
-
-#ifdef ENABLE_NLS
-/* FIXME: add category
- GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE, LOCALEDIR);
- */
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-#endif /* ENABLE_NLS */
-
- return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gnomevfs",
- "elements to read from and write to Gnome-VFS uri's",
- plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gnomevfs/gstgnomevfs.h
--- a/gst_plugins_base/ext/gnomevfs/gstgnomevfs.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/* GStreamer
- * Copyright (C) 2003 Benjamin Otte
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-#ifndef __GST_GNOME_VFS_H__
-#define __GST_GNOME_VFS_H__
-
-#include
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GNOME_VFS_URI (gst_gnome_vfs_uri_get_type ())
-#define GST_TYPE_GNOME_VFS_HANDLE (gst_gnome_vfs_handle_get_type ())
-
-GType gst_gnome_vfs_uri_get_type (void);
-GType gst_gnome_vfs_handle_get_type (void);
-
-gchar * gst_gnome_vfs_location_to_uri_string (const gchar * location);
-
-G_END_DECLS
-
-#endif /* __GST_GNOME_VFS_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gnomevfs/gstgnomevfssink.c
--- a/gst_plugins_base/ext/gnomevfs/gstgnomevfssink.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,641 +0,0 @@
-/* GStreamer
- * Copyright (C) 1999,2000 Erik Walthinsen
- * 2000 Wim Taymans
- * 2001 Bastien Nocera
- * 2003 Colin Walters
- * 2005 Tim-Philipp Müller
- *
- * gstgnomevfssink.c:
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:element-gnomevfssink
- * @short_description: Write a stream to a GnomeVFS URI
- * @see_also: #GstFileSink, #GstGnomeVFSSrc
- *
- *
- *
- * This plugin writes incoming data to a local or remote location specified
- * by an URI. This location can be specified using any protocol supported by
- * the GnomeVFS library. Common protocols are 'file', 'ftp', or 'smb'.
- *
- *
- * Example pipeline:
- *
- * gst-launch -v filesrc location=input.xyz ! gnomevfssink location=file:///home/joe/out.xyz
- *
- * The above pipeline will simply copy a local file. Instead of gnomevfssink,
- * we could just as well have used the filesink element here.
- *
- *
- * Another example pipeline:
- *
- * gst-launch -v filesrc location=foo.mp3 ! mad ! flacenc ! gnomevfssink location=smb://othercomputer/foo.flac
- *
- * The above pipeline will re-encode an mp3 file into FLAC format and store
- * it on a remote host using the Samba protocol.
- *
- *
- * Applications can connect to the allow-overwrite signal to receive a callback when an
- * existing file will be overwritten. The return value of the signal will determine if
- * gnomevfssink will overwrite the resource or abort with an error.
- *
- *
- *
- * Last reviewed on 2006-02-28 (0.10.4)
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstgnomevfssink.h"
-
-#include "gst/gst-i18n-plugin.h"
-
-#include
-#include
-#include
-#include
-
-static const GstElementDetails gst_gnome_vfs_sink_details =
-GST_ELEMENT_DETAILS ("GnomeVFS Sink",
- "Sink/File",
- "Write a stream to a GnomeVFS URI",
- "Bastien Nocera ");
-
-enum
-{
- SIGNAL_ERASE_ASK,
- LAST_SIGNAL
-};
-
-enum
-{
- ARG_0,
- ARG_LOCATION,
- ARG_URI,
- ARG_HANDLE
-};
-
-static void gst_gnome_vfs_sink_finalize (GObject * obj);
-
-static void gst_gnome_vfs_sink_uri_handler_init (gpointer g_iface,
- gpointer iface_data);
-
-static void gst_gnome_vfs_sink_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_gnome_vfs_sink_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static gboolean gst_gnome_vfs_sink_open_file (GstGnomeVFSSink * sink);
-static void gst_gnome_vfs_sink_close_file (GstGnomeVFSSink * sink);
-static gboolean gst_gnome_vfs_sink_start (GstBaseSink * basesink);
-static gboolean gst_gnome_vfs_sink_stop (GstBaseSink * basesink);
-static GstFlowReturn gst_gnome_vfs_sink_render (GstBaseSink * basesink,
- GstBuffer * buffer);
-static gboolean gst_gnome_vfs_sink_handle_event (GstBaseSink * basesink,
- GstEvent * event);
-static gboolean gst_gnome_vfs_sink_query (GstPad * pad, GstQuery * query);
-
-static guint gst_gnome_vfs_sink_signals[LAST_SIGNAL]; /* all 0 */
-
-static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY);
-
-GST_DEBUG_CATEGORY_STATIC (gst_gnome_vfs_sink_debug);
-#define GST_CAT_DEFAULT gst_gnome_vfs_sink_debug
-
-static void
-gst_gnome_vfs_sink_do_init (GType type)
-{
- static const GInterfaceInfo urihandler_info = {
- gst_gnome_vfs_sink_uri_handler_init,
- NULL,
- NULL
- };
-
- g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
-
- GST_DEBUG_CATEGORY_INIT (gst_gnome_vfs_sink_debug, "gnomevfssink", 0,
- "Gnome VFS sink element");
-}
-
-GST_BOILERPLATE_FULL (GstGnomeVFSSink, gst_gnome_vfs_sink, GstBaseSink,
- GST_TYPE_BASE_SINK, gst_gnome_vfs_sink_do_init);
-
-static void
-gst_gnome_vfs_sink_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sinktemplate));
-
- gst_element_class_set_details (element_class, &gst_gnome_vfs_sink_details);
-}
-
-static gboolean
-_gst_boolean_allow_overwrite_accumulator (GSignalInvocationHint * ihint,
- GValue * return_accu, const GValue * handler_return, gpointer dummy)
-{
- gboolean allow_overwrite;
-
- allow_overwrite = g_value_get_boolean (handler_return);
- if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP))
- g_value_set_boolean (return_accu, allow_overwrite);
-
- /* stop emission if signal doesn't allow overwriting */
- return allow_overwrite;
-}
-
-static void
-gst_gnome_vfs_sink_class_init (GstGnomeVFSSinkClass * klass)
-{
- GstBaseSinkClass *basesink_class;
- GObjectClass *gobject_class;
-
- gobject_class = (GObjectClass *) klass;
- basesink_class = (GstBaseSinkClass *) klass;
-
- gobject_class->set_property = gst_gnome_vfs_sink_set_property;
- gobject_class->get_property = gst_gnome_vfs_sink_get_property;
- gobject_class->finalize = gst_gnome_vfs_sink_finalize;
-
- g_object_class_install_property (gobject_class, ARG_LOCATION,
- g_param_spec_string ("location", "File Location",
- "Location of the file to write", NULL, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, ARG_URI,
- g_param_spec_boxed ("uri", "GnomeVFSURI", "URI for GnomeVFS",
- GST_TYPE_GNOME_VFS_URI, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, ARG_HANDLE,
- g_param_spec_boxed ("handle",
- "GnomeVFSHandle", "Handle for GnomeVFS",
- GST_TYPE_GNOME_VFS_HANDLE, G_PARAM_READWRITE));
-
- /**
- * GstGnomeVFSSink::allow-overwrite
- * @sink: the object which received the signal
- * @uri: the URI to be overwritten
- *
- * This signal is fired when gnomevfssink is about to overwrite an
- * existing resource. The application can connect to this signal and ask
- * the user if the resource may be overwritten.
- *
- * Returns: A boolean indicating that the resource may be overwritten.
- */
- gst_gnome_vfs_sink_signals[SIGNAL_ERASE_ASK] =
- g_signal_new ("allow-overwrite", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_CLEANUP, G_STRUCT_OFFSET (GstGnomeVFSSinkClass, erase_ask),
- _gst_boolean_allow_overwrite_accumulator, NULL,
- gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GST_TYPE_GNOME_VFS_URI);
-
- basesink_class->stop = GST_DEBUG_FUNCPTR (gst_gnome_vfs_sink_stop);
- basesink_class->start = GST_DEBUG_FUNCPTR (gst_gnome_vfs_sink_start);
- basesink_class->event = GST_DEBUG_FUNCPTR (gst_gnome_vfs_sink_handle_event);
- basesink_class->render = GST_DEBUG_FUNCPTR (gst_gnome_vfs_sink_render);
- basesink_class->get_times = NULL;
-}
-
-static void
-gst_gnome_vfs_sink_finalize (GObject * obj)
-{
- GstGnomeVFSSink *sink = GST_GNOME_VFS_SINK (obj);
-
- if (sink->uri) {
- gnome_vfs_uri_unref (sink->uri);
- sink->uri = NULL;
- }
-
- if (sink->uri_name) {
- g_free (sink->uri_name);
- sink->uri_name = NULL;
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-static void
-gst_gnome_vfs_sink_init (GstGnomeVFSSink * sink, GstGnomeVFSSinkClass * klass)
-{
- gst_pad_set_query_function (GST_BASE_SINK_PAD (sink),
- GST_DEBUG_FUNCPTR (gst_gnome_vfs_sink_query));
-
- sink->uri = NULL;
- sink->uri_name = NULL;
- sink->handle = NULL;
- sink->own_handle = FALSE;
- sink->current_pos = 0;
-
- GST_BASE_SINK (sink)->sync = FALSE;
-}
-
-static void
-gst_gnome_vfs_sink_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstGnomeVFSSink *sink;
- GstState cur_state;
-
- sink = GST_GNOME_VFS_SINK (object);
-
- gst_element_get_state (GST_ELEMENT (sink), &cur_state, NULL, 0);
-
- if (cur_state == GST_STATE_PLAYING || cur_state == GST_STATE_PAUSED) {
- GST_WARNING_OBJECT (sink, "cannot set property when PAUSED or PLAYING");
- return;
- }
-
- GST_OBJECT_LOCK (sink);
-
- switch (prop_id) {
- case ARG_LOCATION:{
- const gchar *new_location;
-
- if (sink->uri) {
- gnome_vfs_uri_unref (sink->uri);
- sink->uri = NULL;
- }
- if (sink->uri_name) {
- g_free (sink->uri_name);
- sink->uri_name = NULL;
- }
-
- new_location = g_value_get_string (value);
- if (new_location) {
- sink->uri_name = gst_gnome_vfs_location_to_uri_string (new_location);
- sink->uri = gnome_vfs_uri_new (sink->uri_name);
- }
- break;
- }
- case ARG_URI:{
- if (sink->uri) {
- gnome_vfs_uri_unref (sink->uri);
- sink->uri = NULL;
- }
- if (sink->uri_name) {
- g_free (sink->uri_name);
- sink->uri_name = NULL;
- }
- if (g_value_get_boxed (value)) {
- sink->uri = (GnomeVFSURI *) g_value_dup_boxed (value);
- sink->uri_name = gnome_vfs_uri_to_string (sink->uri, 0);
- }
- break;
- }
- case ARG_HANDLE:{
- if (sink->uri) {
- gnome_vfs_uri_unref (sink->uri);
- sink->uri = NULL;
- }
- if (sink->uri_name) {
- g_free (sink->uri_name);
- sink->uri_name = NULL;
- }
- sink->handle = g_value_get_boxed (value);
- break;
- }
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
- GST_OBJECT_UNLOCK (sink);
-}
-
-static void
-gst_gnome_vfs_sink_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstGnomeVFSSink *sink;
-
- sink = GST_GNOME_VFS_SINK (object);
-
- GST_OBJECT_LOCK (sink);
-
- switch (prop_id) {
- case ARG_LOCATION:
- g_value_set_string (value, sink->uri_name);
- break;
- case ARG_URI:
- g_value_set_boxed (value, sink->uri);
- break;
- case ARG_HANDLE:
- g_value_set_boxed (value, sink->handle);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
- GST_OBJECT_UNLOCK (sink);
-}
-
-static gboolean
-gst_gnome_vfs_sink_open_file (GstGnomeVFSSink * sink)
-{
- GnomeVFSResult result;
-
- if (sink->uri) {
- /* open the file, all permissions, umask will apply */
- result = gnome_vfs_create_uri (&(sink->handle), sink->uri,
- GNOME_VFS_OPEN_WRITE, TRUE,
- GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE |
- GNOME_VFS_PERM_GROUP_READ | GNOME_VFS_PERM_GROUP_WRITE |
- GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_OTHER_WRITE);
-
- /* if the file existed and the property says to ask, then ask! */
- if (result == GNOME_VFS_ERROR_FILE_EXISTS) {
- gboolean erase_anyway = FALSE;
-
- g_signal_emit (G_OBJECT (sink),
- gst_gnome_vfs_sink_signals[SIGNAL_ERASE_ASK], 0, sink->uri,
- &erase_anyway);
- if (erase_anyway) {
- result = gnome_vfs_create_uri (&(sink->handle), sink->uri,
- GNOME_VFS_OPEN_WRITE, FALSE,
- GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE |
- GNOME_VFS_PERM_GROUP_READ | GNOME_VFS_PERM_GROUP_WRITE |
- GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_OTHER_WRITE);
- }
- }
-
- GST_DEBUG_OBJECT (sink, "open: %s", gnome_vfs_result_to_string (result));
-
- if (result != GNOME_VFS_OK) {
- gchar *filename = gnome_vfs_uri_to_string (sink->uri,
- GNOME_VFS_URI_HIDE_PASSWORD);
-
- GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open vfs file \"%s\" for writing: %s."),
- filename, gnome_vfs_result_to_string (result)), GST_ERROR_SYSTEM);
- g_free (filename);
- return FALSE;
- }
- sink->own_handle = TRUE;
- } else if (!sink->handle) {
- GST_ELEMENT_ERROR (sink, RESOURCE, FAILED, (_("No filename given")),
- (NULL));
- return FALSE;
- } else {
- sink->own_handle = FALSE;
- }
-
- sink->current_pos = 0;
-
- return TRUE;
-}
-
-static void
-gst_gnome_vfs_sink_close_file (GstGnomeVFSSink * sink)
-{
- GnomeVFSResult result;
-
- if (sink->own_handle) {
- /* close the file */
- result = gnome_vfs_close (sink->handle);
-
- if (result != GNOME_VFS_OK) {
- gchar *filename = gnome_vfs_uri_to_string (sink->uri,
- GNOME_VFS_URI_HIDE_PASSWORD);
-
- GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close vfs file \"%s\"."), filename), GST_ERROR_SYSTEM);
- g_free (filename);
- }
-
- sink->own_handle = FALSE;
- sink->handle = NULL;
- }
-}
-
-static gboolean
-gst_gnome_vfs_sink_start (GstBaseSink * basesink)
-{
- gboolean ret;
-
- ret = gst_gnome_vfs_sink_open_file (GST_GNOME_VFS_SINK (basesink));
-
- return ret;
-}
-
-static gboolean
-gst_gnome_vfs_sink_stop (GstBaseSink * basesink)
-{
- GST_DEBUG_OBJECT (basesink, "closing ...");
- gst_gnome_vfs_sink_close_file (GST_GNOME_VFS_SINK (basesink));
- return TRUE;
-}
-
-static gboolean
-gst_gnome_vfs_sink_handle_event (GstBaseSink * basesink, GstEvent * event)
-{
- GstGnomeVFSSink *sink;
- gboolean ret = TRUE;
-
- sink = GST_GNOME_VFS_SINK (basesink);
-
- GST_DEBUG_OBJECT (sink, "processing %s event", GST_EVENT_TYPE_NAME (event));
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_NEWSEGMENT:{
- GnomeVFSResult res;
- GstFormat format;
- gint64 offset;
-
- gst_event_parse_new_segment (event, NULL, NULL, &format, &offset,
- NULL, NULL);
-
- if (format != GST_FORMAT_BYTES) {
- GST_WARNING_OBJECT (sink, "ignored NEWSEGMENT event in %s format",
- gst_format_get_name (format));
- break;
- }
-
- GST_LOG_OBJECT (sink, "seeking to offset %" G_GINT64_FORMAT, offset);
- res = gnome_vfs_seek (sink->handle, GNOME_VFS_SEEK_START, offset);
-
- if (res != GNOME_VFS_OK) {
- GST_ERROR_OBJECT (sink, "Failed to seek to offset %"
- G_GINT64_FORMAT ": %s", offset, gnome_vfs_result_to_string (res));
- ret = FALSE;
- } else {
- sink->current_pos = offset;
- }
-
- break;
- }
-
- case GST_EVENT_FLUSH_START:
- case GST_EVENT_EOS:{
- /* No need to flush with GnomeVfs */
- break;
- }
- default:
- break;
- }
-
- return ret;
-}
-
-static gboolean
-gst_gnome_vfs_sink_query (GstPad * pad, GstQuery * query)
-{
- GstGnomeVFSSink *sink;
- GstFormat format;
-
- sink = GST_GNOME_VFS_SINK (GST_PAD_PARENT (pad));
-
- switch (GST_QUERY_TYPE (query)) {
- case GST_QUERY_POSITION:
- gst_query_parse_position (query, &format, NULL);
- switch (format) {
- case GST_FORMAT_DEFAULT:
- case GST_FORMAT_BYTES:
- gst_query_set_position (query, GST_FORMAT_BYTES, sink->current_pos);
- return TRUE;
- default:
- return FALSE;
- }
-
- case GST_QUERY_FORMATS:
- gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
- return TRUE;
-
- default:
- return gst_pad_query_default (pad, query);
- }
-}
-
-static GstFlowReturn
-gst_gnome_vfs_sink_render (GstBaseSink * basesink, GstBuffer * buf)
-{
- GnomeVFSFileSize written, cur_pos;
- GstGnomeVFSSink *sink;
- GnomeVFSResult result;
- GstFlowReturn ret;
-
- sink = GST_GNOME_VFS_SINK (basesink);
-
- if (gnome_vfs_tell (sink->handle, &cur_pos) == GNOME_VFS_OK) {
- /* bring up to date with current position for proper reporting */
- sink->current_pos = cur_pos;
- }
-
- result = gnome_vfs_write (sink->handle, GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf), &written);
-
- switch (result) {
- case GNOME_VFS_OK:{
- GST_DEBUG_OBJECT (sink, "wrote %" G_GINT64_FORMAT " bytes at %"
- G_GINT64_FORMAT, (gint64) written, (gint64) cur_pos);
-
- if (written < GST_BUFFER_SIZE (buf)) {
- /* FIXME: what to do here? (tpm) */
- g_warning ("%s: %d bytes should be written, only %"
- G_GUINT64_FORMAT " bytes written", G_STRLOC,
- GST_BUFFER_SIZE (buf), written);
- }
-
- sink->current_pos += GST_BUFFER_SIZE (buf);
- ret = GST_FLOW_OK;
- break;
- }
- case GNOME_VFS_ERROR_NO_SPACE:{
- /* TODO: emit signal/send msg on out-of-diskspace and
- * handle this gracefully (see open bug) (tpm) */
- GST_ELEMENT_ERROR (sink, RESOURCE, NO_SPACE_LEFT, (NULL),
- ("bufsize=%u, written=%u", GST_BUFFER_SIZE (buf), (guint) written));
- ret = GST_FLOW_ERROR;
- break;
- }
- default:{
- gchar *filename = gnome_vfs_uri_to_string (sink->uri,
- GNOME_VFS_URI_HIDE_PASSWORD);
-
- GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
- (_("Error while writing to file \"%s\"."), filename),
- ("%s, bufsize=%u, written=%u", gnome_vfs_result_to_string (result),
- GST_BUFFER_SIZE (buf), (guint) written));
-
- g_free (filename);
- ret = GST_FLOW_ERROR;
- break;
- }
- }
-
- return GST_FLOW_OK;
-}
-
-/*** GSTURIHANDLER INTERFACE *************************************************/
-
-static GstURIType
-gst_gnome_vfs_sink_uri_get_type (void)
-{
- return GST_URI_SINK;
-}
-
-static gchar **
-gst_gnome_vfs_sink_uri_get_protocols (void)
-{
- static gchar **protocols = NULL;
-
- if (!protocols)
- protocols = gst_gnomevfs_get_supported_uris ();
-
- return protocols;
-}
-
-static const gchar *
-gst_gnome_vfs_sink_uri_get_uri (GstURIHandler * handler)
-{
- GstGnomeVFSSink *sink = GST_GNOME_VFS_SINK (handler);
-
- return sink->uri_name;
-}
-
-static gboolean
-gst_gnome_vfs_sink_uri_set_uri (GstURIHandler * handler, const gchar * uri)
-{
- GstGnomeVFSSink *sink = GST_GNOME_VFS_SINK (handler);
- GstState cur_state;
-
- gst_element_get_state (GST_ELEMENT (sink), &cur_state, NULL, 0);
-
- if (cur_state == GST_STATE_PLAYING || cur_state == GST_STATE_PAUSED) {
- GST_WARNING_OBJECT (sink, "cannot set uri when PAUSED or PLAYING");
- return FALSE;
- }
-
- g_object_set (sink, "location", uri, NULL);
-
- return TRUE;
-}
-
-static void
-gst_gnome_vfs_sink_uri_handler_init (gpointer g_iface, gpointer iface_data)
-{
- GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
-
- iface->get_type = gst_gnome_vfs_sink_uri_get_type;
- iface->get_protocols = gst_gnome_vfs_sink_uri_get_protocols;
- iface->get_uri = gst_gnome_vfs_sink_uri_get_uri;
- iface->set_uri = gst_gnome_vfs_sink_uri_set_uri;
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gnomevfs/gstgnomevfssink.h
--- a/gst_plugins_base/ext/gnomevfs/gstgnomevfssink.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/* GStreamer
- * Copyright (C) 1999,2000 Erik Walthinsen
- * 2000 Wim Taymans
- * 2001 Bastien Nocera
- * 2003 Colin Walters
- * 2005 Tim-Philipp Müller
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_GNOME_VFS_SINK_H__
-#define __GST_GNOME_VFS_SINK_H__
-
-#include "gstgnomevfs.h"
-#include "gstgnomevfsuri.h"
-#include
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GNOME_VFS_SINK \
- (gst_gnome_vfs_sink_get_type())
-#define GST_GNOME_VFS_SINK(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GNOME_VFS_SINK,GstGnomeVFSSink))
-#define GST_GNOME_VFS_SINK_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GNOME_VFS_SINK,GstGnomeVFSSinkClass))
-#define GST_IS_GNOME_VFS_SINK(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GNOME_VFS_SINK))
-#define GST_IS_GNOME_VFS_SINK_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GNOME_VFS_SINK))
-
-typedef struct _GstGnomeVFSSink GstGnomeVFSSink;
-typedef struct _GstGnomeVFSSinkClass GstGnomeVFSSinkClass;
-
-/**
- * GstGnomeVFSSink:
- *
- * Opaque data structure.
- */
-struct _GstGnomeVFSSink
-{
- GstBaseSink basesink;
-
- /*< private >*/
-
- /* uri */
- GnomeVFSURI *uri;
- gchar *uri_name;
-
- /* handle */
- GnomeVFSHandle *handle;
-
- /* whether we opened the handle ourselves */
- gboolean own_handle;
-
- guint64 current_pos;
-};
-
-struct _GstGnomeVFSSinkClass
-{
- GstBaseSinkClass basesink_class;
-
- /* signals */
- gboolean (*erase_ask) (GstElement * element, GnomeVFSURI * uri);
-};
-
-GType gst_gnome_vfs_sink_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_GNOME_VFS_SINK_H__ */
-
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gnomevfs/gstgnomevfssrc.c
--- a/gst_plugins_base/ext/gnomevfs/gstgnomevfssrc.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,880 +0,0 @@
-/* GStreamer
- * Copyright (C) 1999,2000 Erik Walthinsen
- * 2000 Wim Taymans
- * 2001 Bastien Nocera
- * 2002 Kristian Rietveld
- * 2002,2003 Colin Walters
- *
- * gnomevfssrc.c:
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:element-gnomevfssrc
- * @short_description: Read from any GnomeVFS-supported location
- * @see_also: #GstFileSrc, #GstGnomeVFSSink
- *
- *
- *
- * This plugin reads data from a local or remote location specified
- * by an URI. This location can be specified using any protocol supported by
- * the GnomeVFS library. Common protocols are 'file', 'http', 'ftp', or 'smb'.
- *
- *
- * In case the element-gnomevfssrc::iradio-mode property is set and the
- * location is a http resource, gnomevfssrc will send special icecast http
- * headers to the server to request additional icecast metainformation. If
- * the server is not an icecast server, it will display the same behaviour
- * as if the element-gnomevfssrc::iradio-mode property was not set. However,
- * if the server is in fact an icecast server, gnomevfssrc will output
- * data with a media type of application/x-icy, in which case you will
- * need to use the #ICYDemux element as follow-up element to extract
- * the icecast meta data and to determine the underlying media type.
- *
- *
- * Example pipeline:
- *
- * gst-launch -v gnomevfssrc location=file:///home/joe/foo.xyz ! fakesink
- *
- * The above pipeline will simply read a local file and do nothing with the
- * data read. Instead of gnomevfssrc, we could just as well have used the
- * filesrc element here.
- *
- *
- * Another example pipeline:
- *
- * gst-launch -v gnomevfssrc location=smb://othercomputer/foo.xyz ! filesink location=/home/joe/foo.xyz
- *
- * The above pipeline will copy a file from a remote host to the local file
- * system using the Samba protocol.
- *
- *
- * Yet another example pipeline:
- *
- * gst-launch -v gnomevfssrc location=http://music.foobar.com/demo.mp3 ! mad ! audioconvert ! audioresample ! alsasink
- *
- * The above pipeline will read and decode and play an mp3 file from a
- * web server using the http protocol.
- *
- *
- *
- */
-
-
-#define BROKEN_SIG 1
-/*#undef BROKEN_SIG */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gst/gst-i18n-plugin.h"
-
-#include "gstgnomevfssrc.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-/* gnome-vfs.h doesn't include the following header, which we need: */
-#include
-
-GST_DEBUG_CATEGORY_STATIC (gnomevfssrc_debug);
-#define GST_CAT_DEFAULT gnomevfssrc_debug
-
-static const GstElementDetails gst_gnome_vfs_src_details =
-GST_ELEMENT_DETAILS ("GnomeVFS Source",
- "Source/File",
- "Read from any GnomeVFS-supported file",
- "Bastien Nocera \n"
- "Ronald S. Bultje ");
-
-static GStaticMutex count_lock = G_STATIC_MUTEX_INIT;
-static gint ref_count = 0;
-static gboolean vfs_owner = FALSE;
-
-static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY);
-
-enum
-{
- ARG_0,
- ARG_HANDLE,
- ARG_LOCATION,
- ARG_IRADIO_MODE,
- ARG_IRADIO_NAME,
- ARG_IRADIO_GENRE,
- ARG_IRADIO_URL,
- ARG_IRADIO_TITLE
-};
-
-static void gst_gnome_vfs_src_base_init (gpointer g_class);
-static void gst_gnome_vfs_src_class_init (GstGnomeVFSSrcClass * klass);
-static void gst_gnome_vfs_src_init (GstGnomeVFSSrc * gnomevfssrc);
-static void gst_gnome_vfs_src_finalize (GObject * object);
-static void gst_gnome_vfs_src_uri_handler_init (gpointer g_iface,
- gpointer iface_data);
-
-static void gst_gnome_vfs_src_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_gnome_vfs_src_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static gboolean gst_gnome_vfs_src_stop (GstBaseSrc * src);
-static gboolean gst_gnome_vfs_src_start (GstBaseSrc * src);
-static gboolean gst_gnome_vfs_src_is_seekable (GstBaseSrc * src);
-static gboolean gst_gnome_vfs_src_check_get_range (GstBaseSrc * src);
-static gboolean gst_gnome_vfs_src_get_size (GstBaseSrc * src, guint64 * size);
-static GstFlowReturn gst_gnome_vfs_src_create (GstBaseSrc * basesrc,
- guint64 offset, guint size, GstBuffer ** buffer);
-
-static GstElementClass *parent_class = NULL;
-
-GType
-gst_gnome_vfs_src_get_type (void)
-{
- static GType gnomevfssrc_type = 0;
-
- if (!gnomevfssrc_type) {
- static const GTypeInfo gnomevfssrc_info = {
- sizeof (GstGnomeVFSSrcClass),
- gst_gnome_vfs_src_base_init,
- NULL,
- (GClassInitFunc) gst_gnome_vfs_src_class_init,
- NULL,
- NULL,
- sizeof (GstGnomeVFSSrc),
- 0,
- (GInstanceInitFunc) gst_gnome_vfs_src_init,
- };
- static const GInterfaceInfo urihandler_info = {
- gst_gnome_vfs_src_uri_handler_init,
- NULL,
- NULL
- };
-
- gnomevfssrc_type =
- g_type_register_static (GST_TYPE_BASE_SRC,
- "GstGnomeVFSSrc", &gnomevfssrc_info, 0);
- g_type_add_interface_static (gnomevfssrc_type, GST_TYPE_URI_HANDLER,
- &urihandler_info);
- }
- return gnomevfssrc_type;
-}
-
-static void
-gst_gnome_vfs_src_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&srctemplate));
- gst_element_class_set_details (element_class, &gst_gnome_vfs_src_details);
-
- GST_DEBUG_CATEGORY_INIT (gnomevfssrc_debug, "gnomevfssrc", 0,
- "Gnome-VFS Source");
-}
-
-static void
-gst_gnome_vfs_src_class_init (GstGnomeVFSSrcClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
- GstBaseSrcClass *gstbasesrc_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
- gstelement_class = GST_ELEMENT_CLASS (klass);
- gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class->finalize = gst_gnome_vfs_src_finalize;
- gobject_class->set_property = gst_gnome_vfs_src_set_property;
- gobject_class->get_property = gst_gnome_vfs_src_get_property;
-
- /* properties */
- gst_element_class_install_std_props (GST_ELEMENT_CLASS (klass),
- "location", ARG_LOCATION, G_PARAM_READWRITE, NULL);
- g_object_class_install_property (gobject_class,
- ARG_HANDLE,
- g_param_spec_boxed ("handle",
- "GnomeVFSHandle", "Handle for GnomeVFS",
- GST_TYPE_GNOME_VFS_HANDLE, G_PARAM_READWRITE));
-
- /* icecast stuff */
- g_object_class_install_property (gobject_class,
- ARG_IRADIO_MODE,
- g_param_spec_boolean ("iradio-mode",
- "iradio-mode",
- "Enable internet radio mode (extraction of shoutcast/icecast metadata)",
- FALSE, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
- ARG_IRADIO_NAME,
- g_param_spec_string ("iradio-name",
- "iradio-name", "Name of the stream", NULL, G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
- ARG_IRADIO_GENRE,
- g_param_spec_string ("iradio-genre",
- "iradio-genre", "Genre of the stream", NULL, G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
- ARG_IRADIO_URL,
- g_param_spec_string ("iradio-url",
- "iradio-url",
- "Homepage URL for radio stream", NULL, G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
- ARG_IRADIO_TITLE,
- g_param_spec_string ("iradio-title",
- "iradio-title",
- "Name of currently playing song", NULL, G_PARAM_READABLE));
-
- gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_start);
- gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_stop);
- gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_get_size);
- gstbasesrc_class->is_seekable =
- GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_is_seekable);
- gstbasesrc_class->check_get_range =
- GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_check_get_range);
- gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_create);
-}
-
-static void
-gst_gnome_vfs_src_init (GstGnomeVFSSrc * gnomevfssrc)
-{
- gnomevfssrc->uri = NULL;
- gnomevfssrc->uri_name = NULL;
- gnomevfssrc->handle = NULL;
- gnomevfssrc->curoffset = 0;
- gnomevfssrc->seekable = FALSE;
-
- gnomevfssrc->icy_caps = NULL;
- gnomevfssrc->iradio_mode = FALSE;
- gnomevfssrc->http_callbacks_pushed = FALSE;
- gnomevfssrc->iradio_name = NULL;
- gnomevfssrc->iradio_genre = NULL;
- gnomevfssrc->iradio_url = NULL;
- gnomevfssrc->iradio_title = NULL;
-
- g_static_mutex_lock (&count_lock);
- if (ref_count == 0) {
- /* gnome vfs engine init */
- if (gnome_vfs_initialized () == FALSE) {
- gnome_vfs_init ();
- vfs_owner = TRUE;
- }
- }
- ref_count++;
- g_static_mutex_unlock (&count_lock);
-}
-
-static void
-gst_gnome_vfs_src_finalize (GObject * object)
-{
- GstGnomeVFSSrc *src = GST_GNOME_VFS_SRC (object);
-
- g_static_mutex_lock (&count_lock);
- ref_count--;
- if (ref_count == 0 && vfs_owner) {
- if (gnome_vfs_initialized () == TRUE) {
- gnome_vfs_shutdown ();
- }
- }
- g_static_mutex_unlock (&count_lock);
-
- if (src->uri) {
- gnome_vfs_uri_unref (src->uri);
- src->uri = NULL;
- }
-
- g_free (src->uri_name);
- src->uri_name = NULL;
-
- g_free (src->iradio_name);
- src->iradio_name = NULL;
-
- g_free (src->iradio_genre);
- src->iradio_genre = NULL;
-
- g_free (src->iradio_url);
- src->iradio_url = NULL;
-
- g_free (src->iradio_title);
- src->iradio_title = NULL;
-
- if (src->icy_caps) {
- gst_caps_unref (src->icy_caps);
- src->icy_caps = NULL;
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-/*
- * URI interface support.
- */
-
-static GstURIType
-gst_gnome_vfs_src_uri_get_type (void)
-{
- return GST_URI_SRC;
-}
-
-static gchar **
-gst_gnome_vfs_src_uri_get_protocols (void)
-{
- static gchar **protocols = NULL;
-
- if (!protocols)
- protocols = gst_gnomevfs_get_supported_uris ();
-
- return protocols;
-}
-
-static const gchar *
-gst_gnome_vfs_src_uri_get_uri (GstURIHandler * handler)
-{
- GstGnomeVFSSrc *src = GST_GNOME_VFS_SRC (handler);
-
- return src->uri_name;
-}
-
-static gboolean
-gst_gnome_vfs_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
-{
- GstGnomeVFSSrc *src = GST_GNOME_VFS_SRC (handler);
-
- if (GST_STATE (src) == GST_STATE_PLAYING ||
- GST_STATE (src) == GST_STATE_PAUSED)
- return FALSE;
-
- g_object_set (G_OBJECT (src), "location", uri, NULL);
-
- return TRUE;
-}
-
-static void
-gst_gnome_vfs_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
-{
- GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
-
- iface->get_type = gst_gnome_vfs_src_uri_get_type;
- iface->get_protocols = gst_gnome_vfs_src_uri_get_protocols;
- iface->get_uri = gst_gnome_vfs_src_uri_get_uri;
- iface->set_uri = gst_gnome_vfs_src_uri_set_uri;
-}
-
-static void
-gst_gnome_vfs_src_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstGnomeVFSSrc *src;
-
- src = GST_GNOME_VFS_SRC (object);
-
- switch (prop_id) {
- case ARG_LOCATION:{
- const gchar *new_location;
-
- /* the element must be stopped or paused in order to do this */
- if (GST_STATE (src) == GST_STATE_PLAYING ||
- GST_STATE (src) == GST_STATE_PAUSED)
- break;
-
- if (src->uri) {
- gnome_vfs_uri_unref (src->uri);
- src->uri = NULL;
- }
- if (src->uri_name) {
- g_free (src->uri_name);
- src->uri_name = NULL;
- }
-
- new_location = g_value_get_string (value);
- if (new_location) {
- src->uri_name = gst_gnome_vfs_location_to_uri_string (new_location);
- src->uri = gnome_vfs_uri_new (src->uri_name);
- }
- break;
- }
- case ARG_HANDLE:
- if (GST_STATE (src) == GST_STATE_NULL ||
- GST_STATE (src) == GST_STATE_READY) {
- if (src->uri) {
- gnome_vfs_uri_unref (src->uri);
- src->uri = NULL;
- }
- if (src->uri_name) {
- g_free (src->uri_name);
- src->uri_name = NULL;
- }
- src->handle = g_value_get_boxed (value);
- }
- break;
- case ARG_IRADIO_MODE:
- src->iradio_mode = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_gnome_vfs_src_get_property (GObject * object, guint prop_id, GValue * value,
- GParamSpec * pspec)
-{
- GstGnomeVFSSrc *src;
-
- src = GST_GNOME_VFS_SRC (object);
-
- switch (prop_id) {
- case ARG_LOCATION:
- g_value_set_string (value, src->uri_name);
- break;
- case ARG_HANDLE:
- g_value_set_boxed (value, src->handle);
- break;
- case ARG_IRADIO_MODE:
- g_value_set_boolean (value, src->iradio_mode);
- break;
- case ARG_IRADIO_NAME:
- g_value_set_string (value, src->iradio_name);
- break;
- case ARG_IRADIO_GENRE:
- g_value_set_string (value, src->iradio_genre);
- break;
- case ARG_IRADIO_URL:
- g_value_set_string (value, src->iradio_url);
- break;
- case ARG_IRADIO_TITLE:
- g_value_set_string (value, src->iradio_title);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static char *
-gst_gnome_vfs_src_unicodify (const char *str)
-{
- const gchar *env_vars[] = { "GST_ICY_TAG_ENCODING",
- "GST_TAG_ENCODING", NULL
- };
-
- return gst_tag_freeform_string_to_utf8 (str, -1, env_vars);
-}
-
-static void
-gst_gnome_vfs_src_send_additional_headers_callback (gconstpointer in,
- gsize in_size, gpointer out, gsize out_size, gpointer callback_data)
-{
- GstGnomeVFSSrc *src = GST_GNOME_VFS_SRC (callback_data);
- GnomeVFSModuleCallbackAdditionalHeadersOut *out_args =
- (GnomeVFSModuleCallbackAdditionalHeadersOut *) out;
-
- if (!src->iradio_mode)
- return;
- GST_DEBUG_OBJECT (src, "sending headers\n");
-
- out_args->headers = g_list_append (out_args->headers,
- g_strdup ("icy-metadata:1\r\n"));
-}
-
-static void
-gst_gnome_vfs_src_received_headers_callback (gconstpointer in,
- gsize in_size, gpointer out, gsize out_size, gpointer callback_data)
-{
- GList *i;
- gint icy_metaint;
- GstGnomeVFSSrc *src = GST_GNOME_VFS_SRC (callback_data);
- GnomeVFSModuleCallbackReceivedHeadersIn *in_args =
- (GnomeVFSModuleCallbackReceivedHeadersIn *) in;
-
- /* This is only used for internet radio stuff right now */
- if (!src->iradio_mode)
- return;
-
- for (i = in_args->headers; i; i = i->next) {
- char *data = (char *) i->data;
- char *key = data;
- char *value = strchr (data, ':');
-
- if (!value)
- continue;
-
- value++;
- g_strstrip (value);
- if (!strlen (value))
- continue;
-
- /* Icecast stuff */
- if (strncmp (data, "icy-metaint:", 12) == 0) { /* ugh */
- if (sscanf (data + 12, "%d", &icy_metaint) == 1) {
- if (icy_metaint > 0)
- src->icy_caps = gst_caps_new_simple ("application/x-icy",
- "metadata-interval", G_TYPE_INT, icy_metaint, NULL);
- }
- continue;
- }
-
- if (!strncmp (data, "icy-", 4))
- key = data + 4;
- else
- continue;
-
- GST_DEBUG_OBJECT (src, "key: %s", key);
- if (!strncmp (key, "name", 4)) {
- g_free (src->iradio_name);
- src->iradio_name = gst_gnome_vfs_src_unicodify (value);
- if (src->iradio_name)
- g_object_notify (G_OBJECT (src), "iradio-name");
- } else if (!strncmp (key, "genre", 5)) {
- g_free (src->iradio_genre);
- src->iradio_genre = gst_gnome_vfs_src_unicodify (value);
- if (src->iradio_genre)
- g_object_notify (G_OBJECT (src), "iradio-genre");
- } else if (!strncmp (key, "url", 3)) {
- g_free (src->iradio_url);
- src->iradio_url = gst_gnome_vfs_src_unicodify (value);
- if (src->iradio_url)
- g_object_notify (G_OBJECT (src), "iradio-url");
- }
- }
-}
-
-static void
-gst_gnome_vfs_src_push_callbacks (GstGnomeVFSSrc * src)
-{
- if (src->http_callbacks_pushed)
- return;
-
- GST_DEBUG_OBJECT (src, "pushing callbacks");
- gnome_vfs_module_callback_push
- (GNOME_VFS_MODULE_CALLBACK_HTTP_SEND_ADDITIONAL_HEADERS,
- gst_gnome_vfs_src_send_additional_headers_callback, src, NULL);
- gnome_vfs_module_callback_push
- (GNOME_VFS_MODULE_CALLBACK_HTTP_RECEIVED_HEADERS,
- gst_gnome_vfs_src_received_headers_callback, src, NULL);
-
- src->http_callbacks_pushed = TRUE;
-}
-
-static void
-gst_gnome_vfs_src_pop_callbacks (GstGnomeVFSSrc * src)
-{
- if (!src->http_callbacks_pushed)
- return;
-
- GST_DEBUG_OBJECT (src, "popping callbacks");
- gnome_vfs_module_callback_pop
- (GNOME_VFS_MODULE_CALLBACK_HTTP_SEND_ADDITIONAL_HEADERS);
- gnome_vfs_module_callback_pop
- (GNOME_VFS_MODULE_CALLBACK_HTTP_RECEIVED_HEADERS);
-
- src->http_callbacks_pushed = FALSE;
-}
-
-/*
- * Read a new buffer from src->reqoffset, takes care of events
- * and seeking and such.
- */
-static GstFlowReturn
-gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
- GstBuffer ** buffer)
-{
- GnomeVFSResult res;
- GstBuffer *buf;
- GnomeVFSFileSize readbytes;
- guint8 *data;
- GstGnomeVFSSrc *src;
-
- src = GST_GNOME_VFS_SRC (basesrc);
-
- GST_DEBUG ("now at %llu, reading from %lld, size %u", src->curoffset, offset,
- size);
-
- /* seek if required */
- if (G_UNLIKELY (src->curoffset != offset)) {
- GST_DEBUG ("need to seek");
- if (src->seekable) {
- GST_DEBUG ("seeking to %lld", offset);
- res = gnome_vfs_seek (src->handle, GNOME_VFS_SEEK_START, offset);
- if (res != GNOME_VFS_OK)
- goto seek_failed;
- src->curoffset = offset;
- } else {
- goto cannot_seek;
- }
- }
-
- buf = gst_buffer_new_and_alloc (size);
-
- if (src->icy_caps)
- gst_buffer_set_caps (buf, src->icy_caps);
-
- data = GST_BUFFER_DATA (buf);
- GST_BUFFER_OFFSET (buf) = src->curoffset;
-
- res = gnome_vfs_read (src->handle, data, size, &readbytes);
-
- if (G_UNLIKELY (res == GNOME_VFS_ERROR_EOF || (res == GNOME_VFS_OK
- && readbytes == 0)))
- goto eos;
-
- GST_BUFFER_SIZE (buf) = readbytes;
-
- if (G_UNLIKELY (res != GNOME_VFS_OK))
- goto read_failed;
-
- src->curoffset += readbytes;
-
- /* we're done, return the buffer */
- *buffer = buf;
-
- return GST_FLOW_OK;
-
-seek_failed:
- {
- GST_ELEMENT_ERROR (src, RESOURCE, SEEK, (NULL),
- ("Failed to seek to requested position %" G_GINT64_FORMAT ": %s",
- offset, gnome_vfs_result_to_string (res)));
- return GST_FLOW_ERROR;
- }
-cannot_seek:
- {
- GST_ELEMENT_ERROR (src, RESOURCE, SEEK, (NULL),
- ("Requested seek from %" G_GINT64_FORMAT " to %" G_GINT64_FORMAT
- " on non-seekable stream", src->curoffset, offset));
- return GST_FLOW_ERROR;
- }
-read_failed:
- {
- gst_buffer_unref (buf);
- GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
- ("Failed to read data: %s", gnome_vfs_result_to_string (res)));
- return GST_FLOW_ERROR;
- }
-eos:
- {
- gst_buffer_unref (buf);
- GST_DEBUG_OBJECT (src, "Reading data gave EOS");
- return GST_FLOW_UNEXPECTED;
- }
-}
-
-static gboolean
-gst_gnome_vfs_src_is_seekable (GstBaseSrc * basesrc)
-{
- GstGnomeVFSSrc *src;
-
- src = GST_GNOME_VFS_SRC (basesrc);
-
- return src->seekable;
-}
-
-static gboolean
-gst_gnome_vfs_src_check_get_range (GstBaseSrc * basesrc)
-{
- GstGnomeVFSSrc *src;
- const gchar *protocol;
-
- src = GST_GNOME_VFS_SRC (basesrc);
-
- if (src->uri == NULL) {
- GST_WARNING_OBJECT (src, "no URI set yet");
- return FALSE;
- }
-
- if (gnome_vfs_uri_is_local (src->uri)) {
- GST_LOG_OBJECT (src, "local URI (%s), assuming random access is possible",
- GST_STR_NULL (src->uri_name));
- return TRUE;
- }
-
- /* blacklist certain protocols we know won't work getrange-based */
- protocol = gnome_vfs_uri_get_scheme (src->uri);
- if (protocol == NULL)
- goto undecided;
-
- if (strcmp (protocol, "http") == 0 || strcmp (protocol, "https") == 0) {
- GST_LOG_OBJECT (src, "blacklisted protocol '%s', no random access possible"
- " (URI=%s)", protocol, GST_STR_NULL (src->uri_name));
- return FALSE;
- }
-
- /* fall through to undecided */
-
-undecided:
- {
- /* don't know what to do, let the basesrc class decide for us */
- GST_LOG_OBJECT (src, "undecided about URI '%s', let base class handle it",
- GST_STR_NULL (src->uri_name));
-
- if (GST_BASE_SRC_CLASS (parent_class)->check_get_range)
- return GST_BASE_SRC_CLASS (parent_class)->check_get_range (basesrc);
-
- return FALSE;
- }
-}
-
-static gboolean
-gst_gnome_vfs_src_get_size (GstBaseSrc * basesrc, guint64 * size)
-{
- GstGnomeVFSSrc *src;
- GnomeVFSFileInfo *info;
- GnomeVFSFileInfoOptions options;
- GnomeVFSResult res;
-
- src = GST_GNOME_VFS_SRC (basesrc);
-
- *size = -1;
- info = gnome_vfs_file_info_new ();
- options = GNOME_VFS_FILE_INFO_DEFAULT | GNOME_VFS_FILE_INFO_FOLLOW_LINKS;
- res = gnome_vfs_get_file_info_from_handle (src->handle, info, options);
- if (res == GNOME_VFS_OK) {
- if ((info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) {
- *size = info->size;
- GST_DEBUG_OBJECT (src, "from handle: %" G_GUINT64_FORMAT " bytes", *size);
- } else if (src->own_handle && gnome_vfs_uri_is_local (src->uri)) {
- GST_DEBUG_OBJECT (src,
- "file size not known, file local, trying fallback");
- res = gnome_vfs_get_file_info_uri (src->uri, info, options);
- if (res == GNOME_VFS_OK &&
- (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) {
- *size = info->size;
- GST_DEBUG_OBJECT (src, "from uri: %" G_GUINT64_FORMAT " bytes", *size);
- }
- }
- } else {
- GST_WARNING_OBJECT (src, "getting info failed: %s",
- gnome_vfs_result_to_string (res));
- }
- gnome_vfs_file_info_unref (info);
-
- if (*size == (GnomeVFSFileSize) - 1)
- return FALSE;
-
- GST_DEBUG_OBJECT (src, "return size %" G_GUINT64_FORMAT, *size);
-
- return TRUE;
-}
-
-/* open the file, do stuff necessary to go to PAUSED state */
-static gboolean
-gst_gnome_vfs_src_start (GstBaseSrc * basesrc)
-{
- GnomeVFSResult res;
- GstGnomeVFSSrc *src;
-
- src = GST_GNOME_VFS_SRC (basesrc);
-
- gst_gnome_vfs_src_push_callbacks (src);
-
- if (src->uri != NULL) {
- GnomeVFSOpenMode mode = GNOME_VFS_OPEN_READ;
-
- /* this can block... */
- res = gnome_vfs_open_uri (&src->handle, src->uri, mode);
- if (res != GNOME_VFS_OK)
- goto open_failed;
- src->own_handle = TRUE;
- } else if (!src->handle) {
- goto no_filename;
- } else {
- src->own_handle = FALSE;
- }
-
- if (gnome_vfs_seek (src->handle, GNOME_VFS_SEEK_CURRENT, 0) == GNOME_VFS_OK) {
- src->seekable = TRUE;
- } else {
- src->seekable = FALSE;
- }
-
- return TRUE;
-
- /* ERRORS */
-open_failed:
- {
- gchar *filename = gnome_vfs_uri_to_string (src->uri,
- GNOME_VFS_URI_HIDE_PASSWORD);
-
- gst_gnome_vfs_src_pop_callbacks (src);
-
- if (res == GNOME_VFS_ERROR_NOT_FOUND ||
- res == GNOME_VFS_ERROR_HOST_NOT_FOUND ||
- res == GNOME_VFS_ERROR_SERVICE_NOT_AVAILABLE) {
- GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL),
- ("Could not open vfs file \"%s\" for reading: %s (%d)",
- filename, gnome_vfs_result_to_string (res), res));
- } else {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
- ("Could not open vfs file \"%s\" for reading: %s (%d)",
- filename, gnome_vfs_result_to_string (res), res));
- }
- g_free (filename);
- return FALSE;
- }
-no_filename:
- {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), ("No filename given"));
- return FALSE;
- }
-}
-
-static gboolean
-gst_gnome_vfs_src_stop (GstBaseSrc * basesrc)
-{
- GstGnomeVFSSrc *src;
-
- src = GST_GNOME_VFS_SRC (basesrc);
-
- gst_gnome_vfs_src_pop_callbacks (src);
-
- if (src->own_handle) {
- GnomeVFSResult res;
-
- res = gnome_vfs_close (src->handle);
- if (res != GNOME_VFS_OK) {
- GST_ELEMENT_ERROR (src, RESOURCE, CLOSE, (NULL),
- ("Could not close vfs handle: %s", gnome_vfs_result_to_string (res)));
- }
- src->handle = NULL;
- }
- src->curoffset = 0;
-
- if (src->icy_caps) {
- gst_caps_unref (src->icy_caps);
- src->icy_caps = NULL;
- }
-
- return TRUE;
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gnomevfs/gstgnomevfssrc.h
--- a/gst_plugins_base/ext/gnomevfs/gstgnomevfssrc.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/* GStreamer
- * Copyright (C) 1999,2000 Erik Walthinsen
- * 2000 Wim Taymans
- * 2001 Bastien Nocera
- * 2002 Kristian Rietveld
- * 2002,2003 Colin Walters
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_GNOME_VFS_SRC_H__
-#define __GST_GNOME_VFS_SRC_H__
-
-#include
-
-#include "gstgnomevfs.h"
-#include "gstgnomevfsuri.h"
-#include
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GNOME_VFS_SRC \
- (gst_gnome_vfs_src_get_type())
-#define GST_GNOME_VFS_SRC(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GNOME_VFS_SRC,GstGnomeVFSSrc))
-#define GST_GNOME_VFS_SRC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GNOME_VFS_SRC,GstGnomeVFSSrcClass))
-#define GST_IS_GNOME_VFS_SRC(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GNOME_VFS_SRC))
-#define GST_IS_GNOME_VFS_SRC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GNOME_VFS_SRC))
-
-typedef struct _GstGnomeVFSSrc GstGnomeVFSSrc;
-typedef struct _GstGnomeVFSSrcClass GstGnomeVFSSrcClass;
-
-/**
- * GstGnomeVFSSrc:
- *
- * Opaque data structure.
- */
-struct _GstGnomeVFSSrc
-{
- GstBaseSrc basesrc;
-
- /* uri, file, ... */
- GnomeVFSURI *uri;
- gchar *uri_name;
- GnomeVFSHandle *handle;
- gboolean own_handle;
- GnomeVFSFileOffset curoffset; /* current offset in file */
- gboolean seekable;
-
- /* shoutcast/icecast metadata extraction handling */
- gboolean iradio_mode;
- gboolean http_callbacks_pushed;
-
- GstCaps *icy_caps;
-
- gchar *iradio_name;
- gchar *iradio_genre;
- gchar *iradio_url;
- gchar *iradio_title;
-};
-
-struct _GstGnomeVFSSrcClass
-{
- GstBaseSrcClass basesrc_class;
-};
-
-GType gst_gnome_vfs_src_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_GNOME_VFS_SRC_H__ */
-
-
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gnomevfs/gstgnomevfsuri.c
--- a/gst_plugins_base/ext/gnomevfs/gstgnomevfsuri.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/* GStreamer
- * Copyright (C) 1999,2000 Erik Walthinsen
- * 2000 Wim Taymans
- * 2001 Bastien Nocera
- * 2003 Colin Walters
- *
- * gstgnomevfssink.c:
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include
-#include "gstgnomevfsuri.h"
-
-#include
-
-gchar **
-gst_gnomevfs_get_supported_uris (void)
-{
- /* no dav/davs in the list, because they don't appear to be reliable enough */
- const gchar *uris[] = {
- "http://localhost/bla",
- "https://localhost/bla",
- "file:///bla",
- "smb://localhost/bla",
- "ftp://localhost/bla",
- "sftp://localhost/bla",
- "nfs://localhost/bla",
- "ssh://localhost/bla",
- "burn://"
- };
- GnomeVFSURI *uri;
- gchar **result;
- gint n, r = 0;
-
- result = g_new0 (gchar *, G_N_ELEMENTS (uris) + 1);
- for (n = 0; n < G_N_ELEMENTS (uris); n++) {
- uri = gnome_vfs_uri_new (uris[n]);
- if (uri != NULL) {
- gchar *protocol = g_strdup (uris[n]);
- gint n;
-
- gnome_vfs_uri_unref (uri);
- for (n = 0; protocol[n] != '\0'; n++) {
- if (protocol[n] == ':') {
- protocol[n] = '\0';
- break;
- }
- }
-
- GST_DEBUG ("adding protocol '%s'", protocol);
- result[r++] = protocol;
- } else {
- GST_DEBUG ("could not create GnomeVfsUri from '%s'", uris[n]);
- }
- }
- result[r] = NULL;
-
- return result;
-}
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/gnomevfs/gstgnomevfsuri.h
--- a/gst_plugins_base/ext/gnomevfs/gstgnomevfsuri.h Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/* GStreamer
- * Copyright (C) 2003 Benjamin Otte
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-#ifndef __GST_GNOME_VFS_URI_H__
-#define __GST_GNOME_VFS_URI_H__
-
-#include
-
-G_BEGIN_DECLS
-
-gchar **gst_gnomevfs_get_supported_uris (void);
-
-G_END_DECLS
-
-#endif /* __GST_GNOME_VFS_URI_H__ */
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/libvisual/visual.c
--- a/gst_plugins_base/ext/libvisual/visual.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,957 +0,0 @@
-/* GStreamer
- * Copyright (C) 2004 Benjamin Otte
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include
-#include
-#include
-#include
-#include
-
-#define GST_TYPE_VISUAL (gst_visual_get_type())
-#define GST_IS_VISUAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VISUAL))
-#define GST_VISUAL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VISUAL,GstVisual))
-#define GST_IS_VISUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VISUAL))
-#define GST_VISUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VISUAL,GstVisualClass))
-#define GST_VISUAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VISUAL, GstVisualClass))
-
-typedef struct _GstVisual GstVisual;
-typedef struct _GstVisualClass GstVisualClass;
-
-GST_DEBUG_CATEGORY_STATIC (libvisual_debug);
-#define GST_CAT_DEFAULT (libvisual_debug)
-
-struct _GstVisual
-{
- GstElement element;
-
- /* pads */
- GstPad *sinkpad;
- GstPad *srcpad;
- GstClockTime next_ts;
- GstSegment segment;
-
- /* libvisual stuff */
- VisAudio *audio;
- VisVideo *video;
- VisActor *actor;
-
- /* audio/video state */
- gint channels;
- gint rate; /* Input samplerate */
- gint bps;
-
- /* framerate numerator & denominator */
- gint fps_n;
- gint fps_d;
- gint width;
- gint height;
- GstClockTime duration;
- guint outsize;
-
- /* samples per frame based on caps */
- guint spf;
-
- /* state stuff */
- GstAdapter *adapter;
- guint count;
-
- /* QoS stuff *//* with LOCK */
- gdouble proportion;
- GstClockTime earliest_time;
-};
-
-struct _GstVisualClass
-{
- GstElementClass parent_class;
-
- VisPluginRef *plugin;
-};
-
-GType gst_visual_get_type (void);
-
-
-static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN "; "
-#if G_BYTE_ORDER == G_BIG_ENDIAN
- GST_VIDEO_CAPS_RGB "; "
-#else
- GST_VIDEO_CAPS_BGR "; "
-#endif
- GST_VIDEO_CAPS_RGB_16)
- );
-
-static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, " "channels = (int) { 1, 2 }, "
-#if defined(VISUAL_API_VERSION) && VISUAL_API_VERSION >= 4000 && VISUAL_API_VERSION < 5000
- "rate = (int) { 8000, 11250, 22500, 32000, 44100, 48000, 96000 }"
-#else
- "rate = (int) [ 1000, MAX ]"
-#endif
- )
- );
-
-
-static void gst_visual_class_init (gpointer g_class, gpointer class_data);
-static void gst_visual_init (GstVisual * visual);
-static void gst_visual_dispose (GObject * object);
-
-static GstStateChangeReturn gst_visual_change_state (GstElement * element,
- GstStateChange transition);
-static GstFlowReturn gst_visual_chain (GstPad * pad, GstBuffer * buffer);
-static gboolean gst_visual_sink_event (GstPad * pad, GstEvent * event);
-static gboolean gst_visual_src_event (GstPad * pad, GstEvent * event);
-
-static gboolean gst_visual_sink_setcaps (GstPad * pad, GstCaps * caps);
-static gboolean gst_visual_src_setcaps (GstPad * pad, GstCaps * caps);
-static GstCaps *gst_visual_getcaps (GstPad * pad);
-static void libvisual_log_handler (const char *message, const char *funcname,
- void *priv);
-
-static GstElementClass *parent_class = NULL;
-
-GType
-gst_visual_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo info = {
- sizeof (GstVisualClass),
- NULL,
- NULL,
- gst_visual_class_init,
- NULL,
- NULL,
- sizeof (GstVisual),
- 0,
- (GInstanceInitFunc) gst_visual_init,
- };
-
- type = g_type_register_static (GST_TYPE_ELEMENT, "GstVisual", &info, 0);
- }
- return type;
-}
-
-static void
-libvisual_log_handler (const char *message, const char *funcname, void *priv)
-{
- GST_CAT_LEVEL_LOG (libvisual_debug, (GstDebugLevel) (priv), NULL, "%s - %s",
- funcname, message);
-}
-
-static void
-gst_visual_class_init (gpointer g_class, gpointer class_data)
-{
- GstVisualClass *klass = GST_VISUAL_CLASS (g_class);
- GstElementClass *element = GST_ELEMENT_CLASS (g_class);
- GObjectClass *object = G_OBJECT_CLASS (g_class);
-
- klass->plugin = class_data;
-
- element->change_state = gst_visual_change_state;
-
- if (class_data == NULL) {
- parent_class = g_type_class_peek_parent (g_class);
- } else {
- GstElementDetails details = {
- NULL,
- "Visualization",
- klass->plugin->info->about,
- "Benjamin Otte "
- };
-
- details.longname = g_strdup_printf ("libvisual %s plugin v.%s",
- klass->plugin->info->name, klass->plugin->info->version);
-
- /* FIXME: improve to only register what plugin supports? */
- gst_element_class_add_pad_template (element,
- gst_static_pad_template_get (&src_template));
- gst_element_class_add_pad_template (element,
- gst_static_pad_template_get (&sink_template));
- gst_element_class_set_details (element, &details);
- g_free (details.longname);
- }
-
- object->dispose = gst_visual_dispose;
-}
-
-static void
-gst_visual_init (GstVisual * visual)
-{
- /* create the sink and src pads */
- visual->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
- gst_pad_set_setcaps_function (visual->sinkpad, gst_visual_sink_setcaps);
- gst_pad_set_chain_function (visual->sinkpad, gst_visual_chain);
- gst_pad_set_event_function (visual->sinkpad, gst_visual_sink_event);
- gst_element_add_pad (GST_ELEMENT (visual), visual->sinkpad);
-
- visual->srcpad = gst_pad_new_from_static_template (&src_template, "src");
- gst_pad_set_setcaps_function (visual->srcpad, gst_visual_src_setcaps);
- gst_pad_set_getcaps_function (visual->srcpad, gst_visual_getcaps);
- gst_pad_set_event_function (visual->srcpad, gst_visual_src_event);
- gst_element_add_pad (GST_ELEMENT (visual), visual->srcpad);
-
- visual->adapter = gst_adapter_new ();
-}
-
-static void
-gst_visual_clear_actors (GstVisual * visual)
-{
- if (visual->actor) {
- visual_object_unref (VISUAL_OBJECT (visual->actor));
- visual->actor = NULL;
- }
- if (visual->video) {
- visual_object_unref (VISUAL_OBJECT (visual->video));
- visual->video = NULL;
- }
- if (visual->audio) {
- visual_object_unref (VISUAL_OBJECT (visual->audio));
- visual->audio = NULL;
- }
-}
-
-static void
-gst_visual_dispose (GObject * object)
-{
- GstVisual *visual = GST_VISUAL (object);
-
- if (visual->adapter) {
- g_object_unref (visual->adapter);
- visual->adapter = NULL;
- }
- gst_visual_clear_actors (visual);
-
- GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
-}
-
-static void
-gst_visual_reset (GstVisual * visual)
-{
- visual->next_ts = -1;
- gst_adapter_clear (visual->adapter);
- gst_segment_init (&visual->segment, GST_FORMAT_UNDEFINED);
-
- GST_OBJECT_LOCK (visual);
- visual->proportion = 1.0;
- visual->earliest_time = -1;
- GST_OBJECT_UNLOCK (visual);
-}
-
-static GstCaps *
-gst_visual_getcaps (GstPad * pad)
-{
- GstCaps *ret;
- GstVisual *visual = GST_VISUAL (gst_pad_get_parent (pad));
- int depths;
-
- if (!visual->actor) {
- ret = gst_caps_copy (gst_pad_get_pad_template_caps (visual->srcpad));
- goto beach;
- }
-
- ret = gst_caps_new_empty ();
- depths = visual_actor_get_supported_depth (visual->actor);
- if (depths < 0) {
- /* FIXME: set an error */
- goto beach;
- }
- if (depths == VISUAL_VIDEO_DEPTH_GL) {
- /* We can't handle GL only plugins */
- goto beach;
- }
-
- GST_DEBUG_OBJECT (visual, "libvisual plugin supports depths %u (0x%04x)",
- depths, depths);
- /* if (depths & VISUAL_VIDEO_DEPTH_32BIT) Always supports 32bit output */
- gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN));
-
- if (depths & VISUAL_VIDEO_DEPTH_24BIT) {
-#if G_BYTE_ORDER == G_BIG_ENDIAN
- gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_RGB));
-#else
- gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_BGR));
-#endif
- }
- if (depths & VISUAL_VIDEO_DEPTH_16BIT) {
- gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_RGB_16));
- }
-
-beach:
-
- GST_DEBUG_OBJECT (visual, "returning caps %" GST_PTR_FORMAT, ret);
- gst_object_unref (visual);
- return ret;
-}
-
-static gboolean
-gst_visual_src_setcaps (GstPad * pad, GstCaps * caps)
-{
- GstVisual *visual = GST_VISUAL (gst_pad_get_parent (pad));
- GstStructure *structure;
- gint depth, pitch;
-
- structure = gst_caps_get_structure (caps, 0);
-
- GST_DEBUG_OBJECT (visual, "src pad got caps %" GST_PTR_FORMAT, caps);
-
- if (!gst_structure_get_int (structure, "width", &visual->width))
- goto error;
- if (!gst_structure_get_int (structure, "height", &visual->height))
- goto error;
- if (!gst_structure_get_int (structure, "bpp", &depth))
- goto error;
- if (!gst_structure_get_fraction (structure, "framerate", &visual->fps_n,
- &visual->fps_d))
- goto error;
-
- visual_video_set_depth (visual->video,
- visual_video_depth_enum_from_value (depth));
- visual_video_set_dimension (visual->video, visual->width, visual->height);
- pitch = GST_ROUND_UP_4 (visual->width * visual->video->bpp);
- visual_video_set_pitch (visual->video, pitch);
- visual_actor_video_negotiate (visual->actor, 0, FALSE, FALSE);
-
- /* precalc some values */
- visual->outsize = visual->video->height * pitch;
- visual->spf =
- gst_util_uint64_scale_int (visual->rate, visual->fps_d, visual->fps_n);
- visual->duration =
- gst_util_uint64_scale_int (GST_SECOND, visual->fps_d, visual->fps_n);
-
- gst_object_unref (visual);
- return TRUE;
-
- /* ERRORS */
-error:
- {
- GST_DEBUG_OBJECT (visual, "error parsing caps");
- gst_object_unref (visual);
- return FALSE;
- }
-}
-
-static gboolean
-gst_visual_sink_setcaps (GstPad * pad, GstCaps * caps)
-{
- GstVisual *visual = GST_VISUAL (gst_pad_get_parent (pad));
- GstStructure *structure;
-
- structure = gst_caps_get_structure (caps, 0);
-
- gst_structure_get_int (structure, "channels", &visual->channels);
- gst_structure_get_int (structure, "rate", &visual->rate);
-
- /* this is how many samples we need to fill one frame at the requested
- * framerate. */
- if (visual->fps_n != 0) {
- visual->spf =
- gst_util_uint64_scale_int (visual->rate, visual->fps_d, visual->fps_n);
- }
- visual->bps = visual->channels * sizeof (gint16);
-
- gst_object_unref (visual);
- return TRUE;
-}
-
-static gboolean
-gst_vis_src_negotiate (GstVisual * visual)
-{
- GstCaps *othercaps, *target, *intersect;
- GstStructure *structure;
- GstCaps *caps;
-
- caps = gst_pad_get_caps (visual->srcpad);
-
- /* see what the peer can do */
- othercaps = gst_pad_peer_get_caps (visual->srcpad);
- if (othercaps) {
- intersect = gst_caps_intersect (othercaps, caps);
- gst_caps_unref (othercaps);
- gst_caps_unref (caps);
-
- if (gst_caps_is_empty (intersect))
- goto no_format;
-
- target = gst_caps_copy_nth (intersect, 0);
- gst_caps_unref (intersect);
- } else {
- /* need a copy, we'll be modifying it when fixating */
- target = gst_caps_copy (caps);
- gst_caps_unref (caps);
- }
-
- /* fixate in case something is not fixed. This does nothing if the value is
- * already fixed. For video we always try to fixate to something like
- * 320x240x30 by convention. */
- structure = gst_caps_get_structure (target, 0);
- gst_structure_fixate_field_nearest_int (structure, "width", 320);
- gst_structure_fixate_field_nearest_int (structure, "height", 240);
- gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1);
-
- gst_pad_set_caps (visual->srcpad, target);
- gst_caps_unref (target);
-
- return TRUE;
-
- /* ERRORS */
-no_format:
- {
- GST_ELEMENT_ERROR (visual, STREAM, FORMAT, (NULL),
- ("could not negotiate output format"));
- gst_caps_unref (intersect);
- return FALSE;
- }
-}
-
-static gboolean
-gst_visual_sink_event (GstPad * pad, GstEvent * event)
-{
- GstVisual *visual;
- gboolean res;
-
- visual = GST_VISUAL (gst_pad_get_parent (pad));
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_FLUSH_START:
- res = gst_pad_push_event (visual->srcpad, event);
- break;
- case GST_EVENT_FLUSH_STOP:
- /* reset QoS and adapter. */
- gst_visual_reset (visual);
- res = gst_pad_push_event (visual->srcpad, event);
- break;
- case GST_EVENT_NEWSEGMENT:
- {
- GstFormat format;
- gdouble rate, arate;
- gint64 start, stop, time;
- gboolean update;
-
- /* the newsegment values are used to clip the input samples
- * and to convert the incomming timestamps to running time so
- * we can do QoS */
- gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
- &start, &stop, &time);
-
- /* now configure the values */
- gst_segment_set_newsegment_full (&visual->segment, update,
- rate, arate, format, start, stop, time);
-
- /* and forward */
- res = gst_pad_push_event (visual->srcpad, event);
- break;
- }
- default:
- res = gst_pad_push_event (visual->srcpad, event);
- break;
- }
-
- gst_object_unref (visual);
- return res;
-}
-
-static gboolean
-gst_visual_src_event (GstPad * pad, GstEvent * event)
-{
- GstVisual *visual;
- gboolean res;
-
- visual = GST_VISUAL (gst_pad_get_parent (pad));
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_QOS:
- {
- gdouble proportion;
- GstClockTimeDiff diff;
- GstClockTime timestamp;
-
- gst_event_parse_qos (event, &proportion, &diff, ×tamp);
-
- /* save stuff for the _chain function */
- GST_OBJECT_LOCK (visual);
- visual->proportion = proportion;
- if (diff >= 0)
- /* we're late, this is a good estimate for next displayable
- * frame (see part-qos.txt) */
- visual->earliest_time = timestamp + 2 * diff + visual->duration;
- else
- visual->earliest_time = timestamp + diff;
-
- GST_OBJECT_UNLOCK (visual);
-
- res = gst_pad_push_event (visual->sinkpad, event);
- break;
- }
- default:
- res = gst_pad_push_event (visual->sinkpad, event);
- break;
- }
-
- gst_object_unref (visual);
- return res;
-}
-
-/* allocate and output buffer, if no format was negotiated, this
- * function will negotiate one. After calling this function, a
- * reverse negotiation could have happened. */
-static GstFlowReturn
-get_buffer (GstVisual * visual, GstBuffer ** outbuf)
-{
- GstFlowReturn ret;
-
- /* we don't know an output format yet, pick one */
- if (GST_PAD_CAPS (visual->srcpad) == NULL) {
- if (!gst_vis_src_negotiate (visual))
- return GST_FLOW_NOT_NEGOTIATED;
- }
-
- GST_DEBUG_OBJECT (visual, "allocating output buffer with caps %"
- GST_PTR_FORMAT, GST_PAD_CAPS (visual->srcpad));
-
- /* now allocate a buffer with the last negotiated format.
- * Downstream could renegotiate a new format, which will trigger
- * our setcaps function on the source pad. */
- ret =
- gst_pad_alloc_buffer_and_set_caps (visual->srcpad,
- GST_BUFFER_OFFSET_NONE, visual->outsize,
- GST_PAD_CAPS (visual->srcpad), outbuf);
-
- /* no buffer allocated, we don't care why. */
- if (ret != GST_FLOW_OK)
- return ret;
-
- return GST_FLOW_OK;
-}
-
-static GstFlowReturn
-gst_visual_chain (GstPad * pad, GstBuffer * buffer)
-{
- GstBuffer *outbuf = NULL;
- guint i;
- GstVisual *visual = GST_VISUAL (gst_pad_get_parent (pad));
- GstFlowReturn ret = GST_FLOW_OK;
- guint avail;
-
- GST_DEBUG_OBJECT (visual, "chain function called");
-
- /* If we don't have an output format yet, preallocate a buffer to try and
- * set one */
- if (GST_PAD_CAPS (visual->srcpad) == NULL) {
- ret = get_buffer (visual, &outbuf);
- if (ret != GST_FLOW_OK) {
- gst_buffer_unref (buffer);
- goto beach;
- }
- }
-
- /* resync on DISCONT */
- if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
- gst_adapter_clear (visual->adapter);
- visual->next_ts = -1;
- }
-
- /* Match timestamps from the incoming audio */
- if (GST_BUFFER_TIMESTAMP (buffer) != GST_CLOCK_TIME_NONE)
- visual->next_ts = GST_BUFFER_TIMESTAMP (buffer);
-
- GST_DEBUG_OBJECT (visual,
- "Input buffer has %d samples, time=%" G_GUINT64_FORMAT,
- GST_BUFFER_SIZE (buffer) / visual->bps, GST_BUFFER_TIMESTAMP (buffer));
-
- gst_adapter_push (visual->adapter, buffer);
-
- while (TRUE) {
- gboolean need_skip;
- const guint16 *data;
-
- GST_DEBUG_OBJECT (visual, "processing buffer");
-
- avail = gst_adapter_available (visual->adapter);
- GST_DEBUG_OBJECT (visual, "avail now %u", avail);
-
- /* we need at least 512 samples */
- if (avail < 512 * visual->bps)
- break;
-
- /* we need at least enough samples to make one frame */
- if (avail < visual->spf * visual->bps)
- break;
-
- if (visual->next_ts != -1) {
- gint64 qostime;
-
- /* QoS is done on running time */
- qostime = gst_segment_to_running_time (&visual->segment, GST_FORMAT_TIME,
- visual->next_ts);
-
- GST_OBJECT_LOCK (visual);
- /* check for QoS, don't compute buffers that are known to be late */
- need_skip = visual->earliest_time != -1 &&
- qostime <= visual->earliest_time;
- GST_OBJECT_UNLOCK (visual);
-
- if (need_skip) {
- GST_WARNING_OBJECT (visual,
- "QoS: skip ts: %" GST_TIME_FORMAT ", earliest: %" GST_TIME_FORMAT,
- GST_TIME_ARGS (qostime), GST_TIME_ARGS (visual->earliest_time));
- goto skip;
- }
- }
-
- /* Read 512 samples per channel */
- data =
- (const guint16 *) gst_adapter_peek (visual->adapter, 512 * visual->bps);
-
-#if defined(VISUAL_API_VERSION) && VISUAL_API_VERSION >= 4000 && VISUAL_API_VERSION < 5000
- {
- VisBuffer *lbuf, *rbuf;
- guint16 ldata[512], rdata[512];
- VisAudioSampleRateType rate;
-
- lbuf = visual_buffer_new_with_buffer (ldata, sizeof (ldata), NULL);
- rbuf = visual_buffer_new_with_buffer (rdata, sizeof (rdata), NULL);
-
- if (visual->channels == 2) {
- for (i = 0; i < 512; i++) {
- ldata[i] = *data++;
- rdata[i] = *data++;
- }
- } else {
- for (i = 0; i < 512; i++) {
- ldata[i] = *data;
- rdata[i] = *data++;
- }
- }
-
- switch (visual->rate) {
- case 8000:
- rate = VISUAL_AUDIO_SAMPLE_RATE_8000;
- break;
- case 11250:
- rate = VISUAL_AUDIO_SAMPLE_RATE_11250;
- break;
- case 22500:
- rate = VISUAL_AUDIO_SAMPLE_RATE_22500;
- break;
- case 32000:
- rate = VISUAL_AUDIO_SAMPLE_RATE_32000;
- break;
- case 44100:
- rate = VISUAL_AUDIO_SAMPLE_RATE_44100;
- break;
- case 48000:
- rate = VISUAL_AUDIO_SAMPLE_RATE_48000;
- break;
- case 96000:
- rate = VISUAL_AUDIO_SAMPLE_RATE_96000;
- break;
- default:
- visual_object_unref (VISUAL_OBJECT (lbuf));
- visual_object_unref (VISUAL_OBJECT (rbuf));
- GST_ERROR_OBJECT (visual, "unsupported rate %d", visual->rate);
- ret = GST_FLOW_ERROR;
- goto beach;
- break;
- }
-
- visual_audio_samplepool_input_channel (visual->audio->samplepool,
- lbuf,
- rate, VISUAL_AUDIO_SAMPLE_FORMAT_S16, VISUAL_AUDIO_CHANNEL_LEFT);
- visual_audio_samplepool_input_channel (visual->audio->samplepool,
- rbuf,
- rate, VISUAL_AUDIO_SAMPLE_FORMAT_S16, VISUAL_AUDIO_CHANNEL_RIGHT);
-
- visual_object_unref (VISUAL_OBJECT (lbuf));
- visual_object_unref (VISUAL_OBJECT (rbuf));
-
- }
-#else
- if (visual->channels == 2) {
- for (i = 0; i < 512; i++) {
- visual->audio->plugpcm[0][i] = *data++;
- visual->audio->plugpcm[1][i] = *data++;
- }
- } else {
- for (i = 0; i < 512; i++) {
- visual->audio->plugpcm[0][i] = *data;
- visual->audio->plugpcm[1][i] = *data++;
- }
- }
-#endif
-
- /* alloc a buffer if we don't have one yet, this happens
- * when we pushed a buffer in this while loop before */
- if (outbuf == NULL) {
- ret = get_buffer (visual, &outbuf);
- if (ret != GST_FLOW_OK) {
- goto beach;
- }
- }
- visual_video_set_buffer (visual->video, GST_BUFFER_DATA (outbuf));
- visual_audio_analyze (visual->audio);
- visual_actor_run (visual->actor, visual->audio);
- visual_video_set_buffer (visual->video, NULL);
- GST_DEBUG_OBJECT (visual, "rendered one frame");
-
- GST_BUFFER_TIMESTAMP (outbuf) = visual->next_ts;
- GST_BUFFER_DURATION (outbuf) = visual->duration;
-
- ret = gst_pad_push (visual->srcpad, outbuf);
- outbuf = NULL;
-
- skip:
- /* interpollate next timestamp */
- if (visual->next_ts != -1)
- visual->next_ts += visual->duration;
-
- GST_DEBUG_OBJECT (visual, "finished frame, flushing %u samples from input",
- visual->spf);
-
- /* Flush out the number of samples per frame */
- gst_adapter_flush (visual->adapter, visual->spf * visual->bps);
-
- /* quit the loop if something was wrong */
- if (ret != GST_FLOW_OK)
- break;
- }
-
-beach:
-
- if (outbuf != NULL)
- gst_buffer_unref (outbuf);
-
- gst_object_unref (visual);
-
- return ret;
-}
-
-static GstStateChangeReturn
-gst_visual_change_state (GstElement * element, GstStateChange transition)
-{
- GstVisual *visual = GST_VISUAL (element);
- GstStateChangeReturn ret;
-
- switch (transition) {
- case GST_STATE_CHANGE_NULL_TO_READY:
- visual->actor =
- visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->info->
- plugname);
- visual->video = visual_video_new ();
- visual->audio = visual_audio_new ();
- /* can't have a play without actors */
- if (!visual->actor || !visual->video)
- goto no_actors;
-
- if (visual_actor_realize (visual->actor) != 0)
- goto no_realize;
-
- visual_actor_set_video (visual->actor, visual->video);
- break;
- case GST_STATE_CHANGE_READY_TO_PAUSED:
- gst_visual_reset (visual);
- break;
- case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
- break;
- default:
- break;
- }
-
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
-
- switch (transition) {
- case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
- break;
- case GST_STATE_CHANGE_PAUSED_TO_READY:
- break;
- case GST_STATE_CHANGE_READY_TO_NULL:
- gst_visual_clear_actors (visual);
- break;
- default:
- break;
- }
-
- return ret;
-
- /* ERRORS */
-no_actors:
- {
- GST_ELEMENT_ERROR (visual, LIBRARY, INIT, (NULL),
- ("could not create actors"));
- gst_visual_clear_actors (visual);
- return GST_STATE_CHANGE_FAILURE;
- }
-no_realize:
- {
- GST_ELEMENT_ERROR (visual, LIBRARY, INIT, (NULL),
- ("could not realize actor"));
- gst_visual_clear_actors (visual);
- return GST_STATE_CHANGE_FAILURE;
- }
-}
-
-static void
-make_valid_name (char *name)
-{
- /*
- * Replace invalid chars with _ in the type name
- */
- static const gchar extra_chars[] = "-_+";
- gchar *p = name;
-
- for (; *p; p++) {
- int valid = ((p[0] >= 'A' && p[0] <= 'Z') ||
- (p[0] >= 'a' && p[0] <= 'z') ||
- (p[0] >= '0' && p[0] <= '9') || strchr (extra_chars, p[0]));
- if (!valid)
- *p = '_';
- }
-}
-
-static gboolean
-gst_visual_actor_plugin_is_gl (VisObject * plugin, const gchar * name)
-{
- gboolean is_gl;
- gint depth;
-
-#if !defined(VISUAL_API_VERSION)
-
- depth = VISUAL_PLUGIN_ACTOR (plugin)->depth;
- is_gl = (depth == VISUAL_VIDEO_DEPTH_GL);
-
-#elif VISUAL_API_VERSION >= 4000 && VISUAL_API_VERSION < 5000
-
- depth = VISUAL_ACTOR_PLUGIN (plugin)->vidoptions.depth;
- /* FIXME: how to figure this out correctly in 0.4? */
- is_gl = (depth & VISUAL_VIDEO_DEPTH_GL) == VISUAL_VIDEO_DEPTH_GL;
-
-#else
-# error what libvisual version is this?
-#endif
-
- if (!is_gl) {
- GST_DEBUG ("plugin %s is not a GL plugin (%d), registering", name, depth);
- } else {
- GST_DEBUG ("plugin %s is a GL plugin (%d), ignoring", name, depth);
- }
-
- return is_gl;
-}
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
- guint i, count;
- VisList *list;
-
- GST_DEBUG_CATEGORY_INIT (libvisual_debug, "libvisual", 0,
- "libvisual audio visualisations");
-
- visual_log_set_verboseness (VISUAL_LOG_VERBOSENESS_LOW);
- visual_log_set_info_handler (libvisual_log_handler, (void *) GST_LEVEL_INFO);
- visual_log_set_warning_handler (libvisual_log_handler,
- (void *) GST_LEVEL_WARNING);
- visual_log_set_critical_handler (libvisual_log_handler,
- (void *) GST_LEVEL_ERROR);
- visual_log_set_error_handler (libvisual_log_handler,
- (void *) GST_LEVEL_ERROR);
-
- if (!visual_is_initialized ())
- if (visual_init (NULL, NULL) != 0)
- return FALSE;
-
- list = visual_actor_get_list ();
-
-#if !defined(VISUAL_API_VERSION)
- count = visual_list_count (list);
-#elif VISUAL_API_VERSION >= 4000 && VISUAL_API_VERSION < 5000
- count = visual_collection_size (VISUAL_COLLECTION (list));
-#endif
-
- for (i = 0; i < count; i++) {
- VisPluginRef *ref = visual_list_get (list, i);
- VisPluginData *visplugin = NULL;
- gboolean skip = FALSE;
- GType type;
- gchar *name;
- GTypeInfo info = {
- sizeof (GstVisualClass),
- NULL,
- NULL,
- gst_visual_class_init,
- NULL,
- ref,
- sizeof (GstVisual),
- 0,
- NULL
- };
-
- visplugin = visual_plugin_load (ref);
-
- if (ref->info->plugname == NULL)
- continue;
-
- /* Blacklist some plugins */
- if (strcmp (ref->info->plugname, "gstreamer") == 0 ||
- strcmp (ref->info->plugname, "gdkpixbuf") == 0) {
- skip = TRUE;
- } else {
- /* Ignore plugins that only support GL output for now */
- skip = gst_visual_actor_plugin_is_gl (visplugin->info->plugin,
- visplugin->info->plugname);
- }
-
- visual_plugin_unload (visplugin);
-
- if (!skip) {
- name = g_strdup_printf ("GstVisual%s", ref->info->plugname);
- make_valid_name (name);
- type = g_type_register_static (GST_TYPE_VISUAL, name, &info, 0);
- g_free (name);
-
- name = g_strdup_printf ("libvisual_%s", ref->info->plugname);
- make_valid_name (name);
- if (!gst_element_register (plugin, name, GST_RANK_NONE, type)) {
- g_free (name);
- return FALSE;
- }
- g_free (name);
- }
- }
-
- return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "libvisual",
- "libvisual visualization plugins",
- plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/ogg/gstogg.c
--- a/gst_plugins_base/ext/ogg/gstogg.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/* GStreamer
- * Copyright (C) <1999> Erik Walthinsen
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include
-
-extern gboolean gst_ogg_demux_plugin_init (GstPlugin * plugin);
-extern gboolean gst_ogg_mux_plugin_init (GstPlugin * plugin);
-extern gboolean gst_ogm_parse_plugin_init (GstPlugin * plugin);
-extern gboolean gst_ogg_parse_plugin_init (GstPlugin * plugin);
-extern gboolean gst_ogg_avi_parse_plugin_init (GstPlugin * plugin);
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
- gst_ogg_demux_plugin_init (plugin);
- gst_ogg_mux_plugin_init (plugin);
- gst_ogm_parse_plugin_init (plugin);
- gst_ogg_parse_plugin_init (plugin);
- gst_ogg_avi_parse_plugin_init (plugin);
-
- return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "ogg",
- "ogg stream manipulation (info about ogg: http://xiph.org)",
- plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff -r 5cb7d96a6887 -r 8d4f92b9230e gst_plugins_base/ext/ogg/gstoggaviparse.c
--- a/gst_plugins_base/ext/ogg/gstoggaviparse.c Fri May 28 18:11:17 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,478 +0,0 @@
-/* GStreamer
- * Copyright (C) 2006 Wim Taymans
- *
- * gstoggaviparse.c: ogg avi stream parser
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Ogg in AVI is mostly done for vorbis audio. In the codec_data we receive the
- * first 3 packets of the raw vorbis data. On the sinkpad we receive full-blown Ogg
- * pages.
- * Before extracting the packets out of the ogg pages, we push the raw vorbis
- * header packets to the decoder.
- * We don't use the incomming timestamps but use the ganulepos on the ogg pages
- * directly.
- * This parser only does ogg/vorbis for now.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include
-#include