[longomatch/livecapturemerged: 78/84] Use a common header file for errors, encoders, and muxers types



commit 1ff6cc2fdd2e096924676eff0ca8d94545650c68
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun May 9 17:12:20 2010 +0200

    Use a common header file for errors, encoders, and muxers types

 libcesarplayer/src/Makefile.am                   |    1 +
 libcesarplayer/src/bacon-video-widget-gst-0.10.c |   49 +++++-----
 libcesarplayer/src/bacon-video-widget.h          |   60 -------------
 libcesarplayer/src/common.h                      |  104 ++++++++++++++++++++++
 libcesarplayer/src/gst-camera-capturer.c         |   61 +++++++------
 libcesarplayer/src/gst-camera-capturer.h         |   63 +------------
 libcesarplayer/src/gst-video-editor.c            |   40 +++++----
 libcesarplayer/src/gst-video-editor.h            |   38 +-------
 8 files changed, 192 insertions(+), 224 deletions(-)
---
diff --git a/libcesarplayer/src/Makefile.am b/libcesarplayer/src/Makefile.am
index 18b4872..0bc96b0 100644
--- a/libcesarplayer/src/Makefile.am
+++ b/libcesarplayer/src/Makefile.am
@@ -25,6 +25,7 @@ pkglib_LTLIBRARIES = \
 
 libcesarplayer_la_SOURCES = \
 	$(BVWMARSHALFILES) \
+	common.h\
 	bacon-video-widget.h\
 	bacon-video-widget-gst-0.10.c\
 	gstscreenshot.c \
diff --git a/libcesarplayer/src/bacon-video-widget-gst-0.10.c b/libcesarplayer/src/bacon-video-widget-gst-0.10.c
index 189429f..f7855c2 100644
--- a/libcesarplayer/src/bacon-video-widget-gst-0.10.c
+++ b/libcesarplayer/src/bacon-video-widget-gst-0.10.c
@@ -75,6 +75,7 @@
 
 #include "bacon-video-widget.h"
 #include "baconvideowidget-marshal.h"
+#include "common.h"
 #include "gstscreenshot.h"
 #include "bacon-resize.h"
 #include "video-utils.h"
@@ -2849,7 +2850,7 @@ bvw_error_from_gst_error (BaconVideoWidget * bvw, GstMessage * err_msg)
 	  (g_str_has_prefix (mrl, "dvd") ||
 	   g_str_has_prefix (mrl, "cd") || g_str_has_prefix (mrl, "vcd")))
 	{
-	  ret = g_error_new_literal (BVW_ERROR, BVW_ERROR_INVALID_DEVICE,
+	  ret = g_error_new_literal (BVW_ERROR, ERROR_INVALID_DEVICE,
 				     e->message);
 	}
       else
@@ -2860,7 +2861,7 @@ bvw_error_from_gst_error (BaconVideoWidget * bvw, GstMessage * err_msg)
 	      if (GST_IS_BASE_AUDIO_SINK (err_msg->src))
 		{
 		  ret =
-		    g_error_new_literal (BVW_ERROR, BVW_ERROR_AUDIO_PLUGIN,
+		    g_error_new_literal (BVW_ERROR, ERROR_AUDIO_PLUGIN,
 					 _
 					 ("The requested audio output was not found. "
 					  "Please select another audio output in the Multimedia "
@@ -2869,13 +2870,13 @@ bvw_error_from_gst_error (BaconVideoWidget * bvw, GstMessage * err_msg)
 	      else
 		{
 		  ret =
-		    g_error_new_literal (BVW_ERROR, BVW_ERROR_FILE_NOT_FOUND,
+		    g_error_new_literal (BVW_ERROR, ERROR_FILE_NOT_FOUND,
 					 _("Location not found."));
 		}
 	    }
 	  else
 	    {
-	      ret = g_error_new_literal (BVW_ERROR, BVW_ERROR_FILE_PERMISSION,
+	      ret = g_error_new_literal (BVW_ERROR, ERROR_FILE_PERMISSION,
 					 _("Could not open location; "
 					   "you might not have permission to open the file."));
 	    }
@@ -2889,7 +2890,7 @@ bvw_error_from_gst_error (BaconVideoWidget * bvw, GstMessage * err_msg)
 	{
 	  /* a somewhat evil check, but hey.. */
 	  ret = g_error_new_literal (BVW_ERROR,
-				     BVW_ERROR_VIDEO_PLUGIN,
+				     ERROR_VIDEO_PLUGIN,
 				     _
 				     ("The video output is in use by another application. "
 				      "Please close other video applications, or select "
@@ -2898,7 +2899,7 @@ bvw_error_from_gst_error (BaconVideoWidget * bvw, GstMessage * err_msg)
       else if (GST_IS_BASE_AUDIO_SINK (err_msg->src))
 	{
 	  ret = g_error_new_literal (BVW_ERROR,
-				     BVW_ERROR_AUDIO_BUSY,
+				     ERROR_AUDIO_BUSY,
 				     _
 				     ("The audio output is in use by another application. "
 				      "Please select another audio output in the Multimedia Systems Selector. "
@@ -2907,7 +2908,7 @@ bvw_error_from_gst_error (BaconVideoWidget * bvw, GstMessage * err_msg)
     }
   else if (e->domain == GST_RESOURCE_ERROR)
     {
-      ret = g_error_new_literal (BVW_ERROR, BVW_ERROR_FILE_GENERIC,
+      ret = g_error_new_literal (BVW_ERROR, ERROR_FILE_GENERIC,
 				 e->message);
     }
   else if (is_error (e, CORE, MISSING_PLUGIN) ||
@@ -2945,14 +2946,14 @@ bvw_error_from_gst_error (BaconVideoWidget * bvw, GstMessage * err_msg)
 	      g_free (desc_list);
 	    }
 	  ret =
-	    g_error_new_literal (BVW_ERROR, BVW_ERROR_CODEC_NOT_HANDLED, msg);
+	    g_error_new_literal (BVW_ERROR, ERROR_CODEC_NOT_HANDLED, msg);
 	  g_free (msg);
 	  g_strfreev (descs);
 	}
       else
 	{
 	  GST_LOG ("no missing plugin messages, posting generic error");
-	  ret = g_error_new_literal (BVW_ERROR, BVW_ERROR_CODEC_NOT_HANDLED,
+	  ret = g_error_new_literal (BVW_ERROR, ERROR_CODEC_NOT_HANDLED,
 				     e->message);
 	}
     }
@@ -2961,26 +2962,26 @@ bvw_error_from_gst_error (BaconVideoWidget * bvw, GstMessage * err_msg)
     {
       if (src_typename)
 	{
-	  ret = g_error_new (BVW_ERROR, BVW_ERROR_CODEC_NOT_HANDLED, "%s: %s",
+	  ret = g_error_new (BVW_ERROR, ERROR_CODEC_NOT_HANDLED, "%s: %s",
 			     src_typename, e->message);
 	}
       else
 	{
-	  ret = g_error_new_literal (BVW_ERROR, BVW_ERROR_CODEC_NOT_HANDLED,
+	  ret = g_error_new_literal (BVW_ERROR, ERROR_CODEC_NOT_HANDLED,
 				     e->message);
 	}
     }
   else if (is_error (e, STREAM, FAILED) &&
 	   src_typename && strncmp (src_typename, "GstTypeFind", 11) == 0)
     {
-      ret = g_error_new_literal (BVW_ERROR, BVW_ERROR_READ_ERROR,
+      ret = g_error_new_literal (BVW_ERROR, ERROR_READ_ERROR,
 				 _("Cannot play this file over the network. "
 				   "Try downloading it to disk first."));
     }
   else
     {
       /* generic error, no code; take message */
-      ret = g_error_new_literal (BVW_ERROR, BVW_ERROR_GENERIC, e->message);
+      ret = g_error_new_literal (BVW_ERROR, ERROR_GENERIC, e->message);
     }
   g_error_free (e);
   bvw_clear_missing_plugins_messages (bvw);
@@ -3059,7 +3060,7 @@ poll_for_state_change_full (BaconVideoWidget * bvw, GstElement * element,
 	    GError *e = NULL;
 
 	    gst_message_unref (message);
-	    e = g_error_new_literal (BVW_ERROR, BVW_ERROR_FILE_GENERIC,
+	    e = g_error_new_literal (BVW_ERROR, ERROR_FILE_GENERIC,
 				     _("Media file could not be played."));
 	    *err_msg =
 	      gst_message_new_error (GST_OBJECT (bvw->priv->play), e, NULL);
@@ -3112,7 +3113,7 @@ error:
  * by adding it after <literal>#subtitle:</literal>. For example:
  * <literal>http://example.com/video.mpg#subtitle:/home/user/subtitle.ass</literal>.
  *
- * If there was a filesystem error, a %BVW_ERROR_GENERIC error will be returned. Otherwise,
+ * If there was a filesystem error, a %ERROR_GENERIC error will be returned. Otherwise,
  * more specific #BvwError errors will be returned.
  *
  * On success, the MRL is loaded and waiting to be played with bacon_video_widget_play().
@@ -3221,7 +3222,7 @@ bacon_video_widget_open (BaconVideoWidget * bvw,
 	      gchar *cur_dir = g_get_current_dir ();
 	      if (!cur_dir)
 		{
-		  g_set_error_literal (error, BVW_ERROR, BVW_ERROR_GENERIC,
+		  g_set_error_literal (error, BVW_ERROR, ERROR_GENERIC,
 				       _
 				       ("Failed to retrieve working directory"));
 		  return FALSE;
@@ -5528,7 +5529,7 @@ bacon_video_widget_can_get_frames (BaconVideoWidget * bvw, GError ** error)
   if (!g_object_class_find_property
       (G_OBJECT_GET_CLASS (bvw->priv->play), "frame"))
     {
-      g_set_error_literal (error, BVW_ERROR, BVW_ERROR_GENERIC,
+      g_set_error_literal (error, BVW_ERROR, ERROR_GENERIC,
 			   _("Too old version of GStreamer installed."));
       return FALSE;
     }
@@ -5536,7 +5537,7 @@ bacon_video_widget_can_get_frames (BaconVideoWidget * bvw, GError ** error)
   /* check for video */
   if (!bvw->priv->media_has_video)
     {
-      g_set_error_literal (error, BVW_ERROR, BVW_ERROR_GENERIC,
+      g_set_error_literal (error, BVW_ERROR, ERROR_GENERIC,
 			   _("Media contains no supported video streams."));
       return FALSE;
     }
@@ -6002,7 +6003,7 @@ bacon_video_widget_new (int width, int height, BvwUseType type, GError ** err)
   if (!bvw->priv->play)
     {
 
-      g_set_error (err, BVW_ERROR, BVW_ERROR_PLUGIN_LOAD,
+      g_set_error (err, BVW_ERROR, ERROR_PLUGIN_LOAD,
 		   _("Failed to create a GStreamer play object. "
 		     "Please check your GStreamer installation."));
       g_object_ref_sink (bvw);
@@ -6090,7 +6091,7 @@ bacon_video_widget_new (int width, int height, BvwUseType type, GError ** err)
 		{
 		  g_warning
 		    ("Should have gotten an error message, please file a bug.");
-		  g_set_error (err, BVW_ERROR, BVW_ERROR_VIDEO_PLUGIN,
+		  g_set_error (err, BVW_ERROR, ERROR_VIDEO_PLUGIN,
 			       _
 			       ("Failed to open video output. It may not be available. "
 				"Please select another video output in the Multimedia "
@@ -6107,7 +6108,7 @@ bacon_video_widget_new (int width, int height, BvwUseType type, GError ** err)
     }
   else
     {
-      g_set_error (err, BVW_ERROR, BVW_ERROR_VIDEO_PLUGIN,
+      g_set_error (err, BVW_ERROR, ERROR_VIDEO_PLUGIN,
 		   _("Could not find the video output. "
 		     "You may need to install additional GStreamer plugins, "
 		     "or select another video output in the Multimedia Systems "
@@ -6147,7 +6148,7 @@ bacon_video_widget_new (int width, int height, BvwUseType type, GError ** err)
 		{
 		  g_warning
 		    ("Should have gotten an error message, please file a bug.");
-		  g_set_error (err, BVW_ERROR, BVW_ERROR_AUDIO_PLUGIN,
+		  g_set_error (err, BVW_ERROR, ERROR_AUDIO_PLUGIN,
 			       _
 			       ("Failed to open audio output. You may not have "
 				"permission to open the sound device, or the sound "
@@ -6172,7 +6173,7 @@ bacon_video_widget_new (int width, int height, BvwUseType type, GError ** err)
     }
   else
     {
-      g_set_error (err, BVW_ERROR, BVW_ERROR_AUDIO_PLUGIN,
+      g_set_error (err, BVW_ERROR, ERROR_AUDIO_PLUGIN,
 		   _("Could not find the audio output. "
 		     "You may need to install additional GStreamer plugins, or "
 		     "select another audio output in the Multimedia Systems "
@@ -6233,7 +6234,7 @@ bacon_video_widget_new (int width, int height, BvwUseType type, GError ** err)
       if (ret != GST_STATE_CHANGE_SUCCESS)
 	{
 	  GST_WARNING ("Timeout setting videosink to READY");
-	  g_set_error (err, BVW_ERROR, BVW_ERROR_VIDEO_PLUGIN,
+	  g_set_error (err, BVW_ERROR, ERROR_VIDEO_PLUGIN,
 		       _
 		       ("Failed to open video output. It may not be available. "
 			"Please select another video output in the Multimedia Systems Selector."));
diff --git a/libcesarplayer/src/bacon-video-widget.h b/libcesarplayer/src/bacon-video-widget.h
index 859faf6..cde269d 100644
--- a/libcesarplayer/src/bacon-video-widget.h
+++ b/libcesarplayer/src/bacon-video-widget.h
@@ -76,66 +76,6 @@ typedef struct
   void (*ready_to_seek) (BaconVideoWidget * bvw);
 } BaconVideoWidgetClass;
 
-/**
- * BvwError:
- * @BVW_ERROR_AUDIO_PLUGIN: Error loading audio output plugin or device.
- * @BVW_ERROR_NO_PLUGIN_FOR_FILE: A required GStreamer plugin or xine feature is missing.
- * @BVW_ERROR_VIDEO_PLUGIN: Error loading video output plugin or device.
- * @BVW_ERROR_AUDIO_BUSY: Audio output device is busy.
- * @BVW_ERROR_BROKEN_FILE: The movie file is broken and cannot be decoded.
- * @BVW_ERROR_FILE_GENERIC: A generic error for problems with movie files.
- * @BVW_ERROR_FILE_PERMISSION: Permission was refused to access the stream, or authentication was required.
- * @BVW_ERROR_FILE_ENCRYPTED: The stream is encrypted and cannot be played.
- * @BVW_ERROR_FILE_NOT_FOUND: The stream cannot be found.
- * @BVW_ERROR_DVD_ENCRYPTED: The DVD is encrypted and libdvdcss is not installed.
- * @BVW_ERROR_INVALID_DEVICE: The device given in an MRL (e.g. DVD drive or DVB tuner) did not exist.
- * @BVW_ERROR_DEVICE_BUSY: The device was busy.
- * @BVW_ERROR_UNKNOWN_HOST: The host for a given stream could not be resolved.
- * @BVW_ERROR_NETWORK_UNREACHABLE: The host for a given stream could not be reached.
- * @BVW_ERROR_CONNECTION_REFUSED: The server for a given stream refused the connection.
- * @BVW_ERROR_INVALID_LOCATION: An MRL was malformed, or CDDB playback was attempted (which is now unsupported).
- * @BVW_ERROR_GENERIC: A generic error occurred.
- * @BVW_ERROR_CODEC_NOT_HANDLED: The audio or video codec required by the stream is not supported.
- * @BVW_ERROR_AUDIO_ONLY: An audio-only stream could not be played due to missing audio output support.
- * @BVW_ERROR_CANNOT_CAPTURE: Error determining frame capture support for a video with bacon_video_widget_can_get_frames().
- * @BVW_ERROR_READ_ERROR: A generic error for problems reading streams.
- * @BVW_ERROR_PLUGIN_LOAD: A library or plugin could not be loaded.
- * @BVW_ERROR_EMPTY_FILE: A movie file was empty.
- *
- * Error codes for #BaconVideoWidget operations.
- **/
-typedef enum
-{
-  /* Plugins */
-  BVW_ERROR_AUDIO_PLUGIN,
-  BVW_ERROR_NO_PLUGIN_FOR_FILE,
-  BVW_ERROR_VIDEO_PLUGIN,
-  BVW_ERROR_AUDIO_BUSY,
-  /* File */
-  BVW_ERROR_BROKEN_FILE,
-  BVW_ERROR_FILE_GENERIC,
-  BVW_ERROR_FILE_PERMISSION,
-  BVW_ERROR_FILE_ENCRYPTED,
-  BVW_ERROR_FILE_NOT_FOUND,
-  /* Devices */
-  BVW_ERROR_DVD_ENCRYPTED,
-  BVW_ERROR_INVALID_DEVICE,
-  BVW_ERROR_DEVICE_BUSY,
-  /* Network */
-  BVW_ERROR_UNKNOWN_HOST,
-  BVW_ERROR_NETWORK_UNREACHABLE,
-  BVW_ERROR_CONNECTION_REFUSED,
-  /* Generic */
-  BVW_ERROR_INVALID_LOCATION,
-  BVW_ERROR_GENERIC,
-  BVW_ERROR_CODEC_NOT_HANDLED,
-  BVW_ERROR_AUDIO_ONLY,
-  BVW_ERROR_CANNOT_CAPTURE,
-  BVW_ERROR_READ_ERROR,
-  BVW_ERROR_PLUGIN_LOAD,
-  BVW_ERROR_EMPTY_FILE
-} BvwError;
-
 
 EXPORT GQuark
 bacon_video_widget_error_quark (void)
diff --git a/libcesarplayer/src/common.h b/libcesarplayer/src/common.h
new file mode 100644
index 0000000..03bcaa3
--- /dev/null
+++ b/libcesarplayer/src/common.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2010 Andoni Morales Alastruey <ylatuya gmail com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+/**
+ * Error:
+ * @ERROR_AUDIO_PLUGIN: Error loading audio output plugin or device.
+ * @ERROR_NO_PLUGIN_FOR_FILE: A required GStreamer plugin or xine feature is missing.
+ * @ERROR_VIDEO_PLUGIN: Error loading video output plugin or device.
+ * @ERROR_AUDIO_BUSY: Audio output device is busy.
+ * @ERROR_BROKEN_FILE: The movie file is broken and cannot be decoded.
+ * @ERROR_FILE_GENERIC: A generic error for problems with movie files.
+ * @ERROR_FILE_PERMISSION: Permission was refused to access the stream, or authentication was required.
+ * @ERROR_FILE_ENCRYPTED: The stream is encrypted and cannot be played.
+ * @ERROR_FILE_NOT_FOUND: The stream cannot be found.
+ * @ERROR_DVD_ENCRYPTED: The DVD is encrypted and libdvdcss is not installed.
+ * @ERROR_INVALID_DEVICE: The device given in an MRL (e.g. DVD drive or DVB tuner) did not exist.
+ * @ERROR_DEVICE_BUSY: The device was busy.
+ * @ERROR_UNKNOWN_HOST: The host for a given stream could not be resolved.
+ * @ERROR_NETWORK_UNREACHABLE: The host for a given stream could not be reached.
+ * @ERROR_CONNECTION_REFUSED: The server for a given stream refused the connection.
+ * @ERROR_INVALID_LOCATION: An MRL was malformed, or CDDB playback was attempted (which is now unsupported).
+ * @ERROR_GENERIC: A generic error occurred.
+ * @ERROR_CODEC_NOT_HANDLED: The audio or video codec required by the stream is not supported.
+ * @ERROR_AUDIO_ONLY: An audio-only stream could not be played due to missing audio output support.
+ * @ERROR_CANNOT_CAPTURE: Error determining frame capture support for a video with bacon_video_widget_can_get_frames().
+ * @ERROR_READ_ERROR: A generic error for problems reading streams.
+ * @ERROR_PLUGIN_LOAD: A library or plugin could not be loaded.
+ * @ERROR_EMPTY_FILE: A movie file was empty.
+ *
+ **/
+typedef enum
+{
+  /* Plugins */
+  ERROR_AUDIO_PLUGIN,
+  ERROR_NO_PLUGIN_FOR_FILE,
+  ERROR_VIDEO_PLUGIN,
+  ERROR_AUDIO_BUSY,
+  /* File */
+  ERROR_BROKEN_FILE,
+  ERROR_FILE_GENERIC,
+  ERROR_FILE_PERMISSION,
+  ERROR_FILE_ENCRYPTED,
+  ERROR_FILE_NOT_FOUND,
+  /* Devices */
+  ERROR_DVD_ENCRYPTED,
+  ERROR_INVALID_DEVICE,
+  ERROR_DEVICE_BUSY,
+  /* Network */
+  ERROR_UNKNOWN_HOST,
+  ERROR_NETWORK_UNREACHABLE,
+  ERROR_CONNECTION_REFUSED,
+  /* Generic */
+  ERROR_INVALID_LOCATION,
+  ERROR_GENERIC,
+  ERROR_CODEC_NOT_HANDLED,
+  ERROR_AUDIO_ONLY,
+  ERROR_CANNOT_CAPTURE,
+  ERROR_READ_ERROR,
+  ERROR_PLUGIN_LOAD,
+  ERROR_EMPTY_FILE
+} Error;
+
+
+typedef enum
+{
+  VIDEO_ENCODER_MPEG4,
+  VIDEO_ENCODER_XVID,
+  VIDEO_ENCODER_THEORA,
+  VIDEO_ENCODER_H264,
+  VIDEO_ENCODER_MPEG2
+} VideoEncoderType;
+
+typedef enum
+{
+  AUDIO_ENCODER_MP3,
+  AUDIO_ENCODER_AAC,
+  AUDIO_ENCODER_VORBIS
+} AudioEncoderType;
+
+typedef enum
+{
+  VIDEO_MUXER_AVI,
+  VIDEO_MUXER_MP4,
+  VIDEO_MUXER_MATROSKA,
+  VIDEO_MUXER_OGG,
+  VIDEO_MUXER_MPEG_PS
+} VideoMuxerType;
diff --git a/libcesarplayer/src/gst-camera-capturer.c b/libcesarplayer/src/gst-camera-capturer.c
index afce3af..3b83b84 100644
--- a/libcesarplayer/src/gst-camera-capturer.c
+++ b/libcesarplayer/src/gst-camera-capturer.c
@@ -83,8 +83,8 @@ struct GstCameraCapturerPrivate
   guint output_fps_d;
   guint audio_bitrate;
   guint video_bitrate;
-  GccVideoEncoderType video_encoder_type;
-  GccAudioEncoderType audio_encoder_type;
+  VideoEncoderType video_encoder_type;
+  AudioEncoderType audio_encoder_type;
 
   /*Video input info */
   gint video_width;             /* Movie width */
@@ -245,7 +245,7 @@ gst_camera_capturer_set_audio_bit_rate (GstCameraCapturer * gcc, gint bitrate)
 {
 
   gcc->priv->audio_bitrate = bitrate;
-  if (gcc->priv->audio_encoder_type != GCC_AUDIO_ENCODER_MP3)
+  if (gcc->priv->audio_encoder_type != AUDIO_ENCODER_MP3)
     g_object_set (gcc->priv->audioenc, "bitrate", bitrate, NULL);
   else  
     g_object_set (gcc->priv->audioenc, "bitrate", 1000 * bitrate, NULL);
@@ -914,7 +914,7 @@ gst_camera_capturer_new (gchar * filename, GError ** err)
 /* Missing plugin */
 missing_plugin:
   {
-    g_set_error (err, GCC_ERROR, GCC_ERROR_PLUGIN_LOAD,
+    g_set_error (err, GCC_ERROR, ERROR_PLUGIN_LOAD,
         ("Failed to create a GStreamer element. "
             "The element \"%s\" is missing. "
             "Please check your GStreamer installation."), plugin);
@@ -961,41 +961,43 @@ gst_camera_capturer_stop (GstCameraCapturer * gcc)
 
 gboolean
 gst_camera_capturer_set_video_encoder (GstCameraCapturer * gcc,
-    GccVideoEncoderType type, GError ** err)
+    VideoEncoderType type, GError ** err)
 {
   gchar *name = NULL;
 
   g_return_val_if_fail (GST_IS_CAMERA_CAPTURER (gcc), FALSE);
 
   switch (type) {
-    case GCC_VIDEO_ENCODER_TYPE_MPEG4:
+    case VIDEO_ENCODER_MPEG4:
       gcc->priv->videoenc =
           gst_element_factory_make ("ffenc_mpeg4", "video-encoder");
       name = "FFmpeg mpeg4 video encoder";
       break;
 
-    case GCC_VIDEO_ENCODER_TYPE_XVID:
+    case VIDEO_ENCODER_XVID:
       gcc->priv->videoenc =
           gst_element_factory_make ("xvidenc", "video-encoder");
       name = "Xvid video encoder";
       break;
 
-    case GCC_VIDEO_ENCODER_TYPE_THEORA:
+    case VIDEO_ENCODER_H264:
+      gcc->priv->videoenc =
+          gst_element_factory_make ("x264enc", "video-encoder");
+      name = "X264 video encoder";
+      break;
+    
+    case VIDEO_ENCODER_THEORA:
+    default:
       gcc->priv->videoenc =
           gst_element_factory_make ("theoraenc", "video-encoder");
       name = "Theora video encoder";
       break;
 
-    case GCC_VIDEO_ENCODER_TYPE_H264:
-      gcc->priv->videoenc =
-          gst_element_factory_make ("x264enc", "video-encoder");
-      name = "X264 video encoder";
-      break;
   }
   if (!gcc->priv->videoenc) {
     g_set_error (err,
         GCC_ERROR,
-        GCC_ERROR_PLUGIN_LOAD,
+        ERROR_PLUGIN_LOAD,
         "Failed to create the %s element. "
         "Please check your GStreamer installation.", name);
   } else {
@@ -1007,24 +1009,24 @@ gst_camera_capturer_set_video_encoder (GstCameraCapturer * gcc,
 
 gboolean
 gst_camera_capturer_set_audio_encoder (GstCameraCapturer * gcc,
-    GccAudioEncoderType type, GError ** err)
+    AudioEncoderType type, GError ** err)
 {
   gchar *name = NULL;
 
   g_return_val_if_fail (GST_IS_CAMERA_CAPTURER (gcc), FALSE);
 
   switch (type) {
-    case GCC_AUDIO_ENCODER_MP3:
+    case AUDIO_ENCODER_MP3:
       gcc->priv->audioenc = gst_element_factory_make ("lame", "audio-encoder");
       name = "Mp3 audio encoder";
       break;
 
-    case GCC_AUDIO_ENCODER_AAC:
+    case AUDIO_ENCODER_AAC:
       gcc->priv->audioenc = gst_element_factory_make ("faac", "audio-encoder");
       name = "AAC audio encoder";
       break;
 
-    case GCC_AUDIO_ENCODER_VORBIS:
+    case AUDIO_ENCODER_VORBIS:
       gcc->priv->audioenc =
           gst_element_factory_make ("vorbisenc", "audio-encoder");
       name = "Vorbis audio encoder";
@@ -1034,7 +1036,7 @@ gst_camera_capturer_set_audio_encoder (GstCameraCapturer * gcc,
   if (!gcc->priv->audioenc) {
     g_set_error (err,
         GCC_ERROR,
-        GCC_ERROR_PLUGIN_LOAD,
+        ERROR_PLUGIN_LOAD,
         "Failed to create the %s element. "
         "Please check your GStreamer installation.", name);
   } else {
@@ -1047,36 +1049,37 @@ gst_camera_capturer_set_audio_encoder (GstCameraCapturer * gcc,
 
 gboolean
 gst_camera_capturer_set_video_muxer (GstCameraCapturer * gcc,
-    GccVideoMuxerType type, GError ** err)
+    VideoMuxerType type, GError ** err)
 {
   gchar *name = NULL;
 
   g_return_val_if_fail (GST_IS_CAMERA_CAPTURER (gcc), FALSE);
 
   switch (type) {
-    case GCC_VIDEO_MUXER_OGG:
+    case VIDEO_MUXER_OGG:
       name = "OGG muxer";
       gcc->priv->videomux = gst_element_factory_make ("oggmux", "video-muxer");
       break;
-    case GCC_VIDEO_MUXER_AVI:
+    case VIDEO_MUXER_AVI:
       name = "AVI muxer";
       gcc->priv->videomux = gst_element_factory_make ("avimux", "video-muxer");
       break;
-    case GCC_VIDEO_MUXER_MP4:
-      name = "MP4 muxer";
-      gcc->priv->videomux = gst_element_factory_make ("qtmux", "video-muxer");
-      break;
-    case GCC_VIDEO_MUXER_MATROSKA:
+    case VIDEO_MUXER_MATROSKA:
       name = "Matroska muxer";
       gcc->priv->videomux =
           gst_element_factory_make ("matroskamux", "video-muxer");
       break;
+    case VIDEO_MUXER_MP4:
+    default:
+      name = "MP4 muxer";
+      gcc->priv->videomux = gst_element_factory_make ("qtmux", "video-muxer");
+      break;
   }
 
   if (!gcc->priv->videomux) {
     g_set_error (err,
         GCC_ERROR,
-        GCC_ERROR_PLUGIN_LOAD,
+        ERROR_PLUGIN_LOAD,
         "Failed to create the %s element. "
         "Please check your GStreamer installation.", name);
   } else {
@@ -1299,7 +1302,7 @@ gst_camera_capturer_can_get_frames (GstCameraCapturer * gcc, GError ** error)
 
   /* check for video */
   if (!gcc->priv->media_has_video) {
-    g_set_error_literal (error, GCC_ERROR, GCC_ERROR_GENERIC,
+    g_set_error_literal (error, GCC_ERROR, ERROR_GENERIC,
         "Media contains no supported video streams.");
     return FALSE;
   }
diff --git a/libcesarplayer/src/gst-camera-capturer.h b/libcesarplayer/src/gst-camera-capturer.h
index 20b807c..3227015 100644
--- a/libcesarplayer/src/gst-camera-capturer.h
+++ b/libcesarplayer/src/gst-camera-capturer.h
@@ -33,7 +33,7 @@
 
 #include <glib-object.h>
 #include <gtk/gtk.h>
-
+#include "common.h"
 
 G_BEGIN_DECLS
 #define GST_TYPE_CAMERA_CAPTURER             (gst_camera_capturer_get_type ())
@@ -63,61 +63,6 @@ struct _GstCameraCapturer
   GstCameraCapturerPrivate *priv;
 };
 
-typedef enum
-{
-  /* Plugins */
-  GCC_ERROR_AUDIO_PLUGIN,
-  GCC_ERROR_NO_PLUGIN_FOR_FILE,
-  GCC_ERROR_VIDEO_PLUGIN,
-  GCC_ERROR_AUDIO_BUSY,
-  /* File */
-  GCC_ERROR_BROKEN_FILE,
-  GCC_ERROR_FILE_GENERIC,
-  GCC_ERROR_FILE_PERMISSION,
-  GCC_ERROR_FILE_ENCRYPTED,
-  GCC_ERROR_FILE_NOT_FOUND,
-  /* Devices */
-  GCC_ERROR_DVD_ENCRYPTED,
-  GCC_ERROR_INVALID_DEVICE,
-  /* Network */
-  GCC_ERROR_UNKNOWN_HOST,
-  GCC_ERROR_NETWORK_UNREACHABLE,
-  GCC_ERROR_CONNECTION_REFUSED,
-  /* Generic */
-  GCC_ERROR_UNVALID_LOCATION,
-  GCC_ERROR_GENERIC,
-  GCC_ERROR_CODEC_NOT_HANDLED,
-  GCC_ERROR_AUDIO_ONLY,
-  GCC_ERROR_CANNOT_CAPTURE,
-  GCC_ERROR_READ_ERROR,
-  GCC_ERROR_PLUGIN_LOAD,
-  GCC_ERROR_EMPTY_FILE
-} GccError;
-
-typedef enum
-{
-  GCC_VIDEO_ENCODER_TYPE_MPEG4,
-  GCC_VIDEO_ENCODER_TYPE_XVID,
-  GCC_VIDEO_ENCODER_TYPE_THEORA,
-  GCC_VIDEO_ENCODER_TYPE_H264
-} GccVideoEncoderType;
-
-typedef enum
-{
-  GCC_AUDIO_ENCODER_MP3,
-  GCC_AUDIO_ENCODER_AAC,
-  GCC_AUDIO_ENCODER_VORBIS
-} GccAudioEncoderType;
-
-typedef enum
-{
-  GCC_VIDEO_MUXER_AVI,
-  GCC_VIDEO_MUXER_MP4,
-  GCC_VIDEO_MUXER_MATROSKA,
-  GCC_VIDEO_MUXER_OGG
-} GccVideoMuxerType;
-
-
 EXPORT GType gst_camera_capturer_get_type (void)  G_GNUC_CONST;
 
 EXPORT void gst_camera_capturer_init_backend (int *argc, char ***argv);
@@ -129,13 +74,13 @@ EXPORT void gst_camera_capturer_start (GstCameraCapturer * gcc);
 EXPORT void gst_camera_capturer_toggle_pause (GstCameraCapturer * gcc);
 EXPORT void gst_camera_capturer_stop (GstCameraCapturer * gcc);
 EXPORT gboolean gst_camera_capturer_set_video_encoder (GstCameraCapturer * gcc,
-                                                      GccVideoEncoderType type,
+                                                      VideoEncoderType type,
                                                       GError ** err);
 EXPORT gboolean gst_camera_capturer_set_audio_encoder (GstCameraCapturer * gcc,
-                                                      GccAudioEncoderType type,
+                                                      AudioEncoderType type,
                                                       GError ** err);
 EXPORT gboolean gst_camera_capturer_set_video_muxer (GstCameraCapturer * gcc,
-                                                    GccVideoMuxerType type,
+                                                    VideoMuxerType type,
                                                     GError ** err);
 EXPORT GList* gst_camera_capturer_enum_audio_devices (void);
 EXPORT GList* gst_camera_capturer_enum_video_devices (void);
diff --git a/libcesarplayer/src/gst-video-editor.c b/libcesarplayer/src/gst-video-editor.c
index 7b678e6..8f916e8 100644
--- a/libcesarplayer/src/gst-video-editor.c
+++ b/libcesarplayer/src/gst-video-editor.c
@@ -1022,7 +1022,7 @@ gst_video_editor_clear_segments_list (GstVideoEditor * gve)
 
 void
 gst_video_editor_set_video_encoder (GstVideoEditor * gve, gchar ** err,
-				    GvsVideoEncoderType codec)
+				    VideoEncoderType codec)
 {
   GstElement *encoder = NULL;
   GstState cur_state;
@@ -1039,29 +1039,29 @@ gst_video_editor_set_video_encoder (GstVideoEditor * gve, gchar ** err,
     {
       switch (codec)
 	{
-	case H264:
+	case VIDEO_ENCODER_H264:
 	  encoder_name = "x264enc";
 	  encoder = gst_element_factory_make (encoder_name, encoder_name);
 	  g_object_set (G_OBJECT (encoder), "pass", 17, NULL);	//Variable Bitrate-Pass 1
 	  break;
-	case MPEG4:
+	case VIDEO_ENCODER_MPEG4:
 	  encoder_name = "xvidenc";
 	  encoder = gst_element_factory_make (encoder_name, encoder_name);
 	  g_object_set (G_OBJECT (encoder), "pass", 1, NULL);	//Variable Bitrate-Pass 1
 	  break;
-	case XVID:
+	case VIDEO_ENCODER_XVID:
 	  encoder_name = "ffenc_mpeg4";
 	  encoder = gst_element_factory_make (encoder_name, encoder_name);
 	  g_object_set (G_OBJECT (encoder), "pass", 512, NULL);	//Variable Bitrate-Pass 1
 
 	  break;
-	case MPEG2_VIDEO:
+	case VIDEO_ENCODER_MPEG2:
 	  encoder_name = "mpeg2enc";
 	  encoder = gst_element_factory_make (encoder_name, encoder_name);
 	  g_object_set (G_OBJECT (encoder), "format", 9, NULL);	//DVD compilant
 	  g_object_set (G_OBJECT (encoder), "framerate", 3, NULL);	//25 FPS (PAL/SECAM)    
 	  break;
-	case THEORA:
+	case VIDEO_ENCODER_THEORA:
 	  encoder_name = "theoraenc";
 	  encoder = gst_element_factory_make (encoder_name, encoder_name);
 	  break;
@@ -1128,7 +1128,7 @@ gst_video_editor_set_video_encoder (GstVideoEditor * gve, gchar ** err,
 
 void
 gst_video_editor_set_audio_encoder (GstVideoEditor * gve, gchar ** err,
-				    GvsAudioEncoderType codec)
+				    AudioEncoderType codec)
 {
   GstElement *encoder = NULL;
   GstState cur_state;
@@ -1145,20 +1145,20 @@ gst_video_editor_set_audio_encoder (GstVideoEditor * gve, gchar ** err,
     {
       switch (codec)
 	{
-	case AAC:
+	case AUDIO_ENCODER_AAC:
 	  encoder_name = "faac";
 	  encoder = gst_element_factory_make (encoder_name, encoder_name);
 	  g_object_set (G_OBJECT (gve->priv->audiocapsfilter), "caps",
 			gst_caps_from_string (FAAC_CAPS), NULL);
 	  break;
-	case MP3:
+	case AUDIO_ENCODER_MP3:
 	  encoder_name = "lame";
 	  encoder = gst_element_factory_make (encoder_name, encoder_name);
 	  g_object_set (G_OBJECT (encoder), "vbr", 4, NULL);	//Variable Bitrate
 	  g_object_set (G_OBJECT (gve->priv->audiocapsfilter), "caps",
 			gst_caps_from_string (LAME_CAPS), NULL);
 	  break;
-	case VORBIS:
+	case AUDIO_ENCODER_VORBIS:
 	  encoder_name = "vorbisenc";
 	  encoder = gst_element_factory_make (encoder_name, encoder_name);
 	  g_object_set (G_OBJECT (gve->priv->audiocapsfilter), "caps",
@@ -1190,7 +1190,7 @@ gst_video_editor_set_audio_encoder (GstVideoEditor * gve, gchar ** err,
 
 	  /*Add new encoder element */
 	  gve->priv->audioencoder = encoder;
-	  if (codec == MP3)
+	  if (codec == AUDIO_ENCODER_MP3)
 	    g_object_set (G_OBJECT (gve->priv->audioencoder), "bitrate",
 			  gve->priv->audio_bitrate / 1000, NULL);
 	  else
@@ -1234,7 +1234,7 @@ gst_video_editor_set_audio_encoder (GstVideoEditor * gve, gchar ** err,
 
 void
 gst_video_editor_set_video_muxer (GstVideoEditor * gve, gchar ** err,
-				  GvsVideoMuxer muxerType)
+				  VideoMuxerType muxerType)
 {
   GstElement *muxer = NULL;
   GstState cur_state;
@@ -1249,19 +1249,23 @@ gst_video_editor_set_video_muxer (GstVideoEditor * gve, gchar ** err,
     {
       switch (muxerType)
 	{
-	case MKV:
+	case VIDEO_MUXER_MATROSKA:
 	  muxer_name = "matroskamux";
 	  muxer = gst_element_factory_make ("matroskamux", muxer_name);
 	  break;
-	case AVI:
+	case VIDEO_MUXER_AVI:
 	  muxer_name = "avimux";
 	  muxer = gst_element_factory_make ("avimux", muxer_name);
 	  break;
-	case OGG:
+	case VIDEO_MUXER_OGG:
 	  muxer_name = "oggmux";
 	  muxer = gst_element_factory_make ("oggmux", muxer_name);
 	  break;
-	case DVD:
+	case VIDEO_MUXER_MP4:
+	  muxer_name = "qtmux";
+	  muxer = gst_element_factory_make ("qtmux", muxer_name);
+	  break;
+	case VIDEO_MUXER_MPEG_PS:
 	  muxer_name = "ffmux_dvd";
 	  //We don't want to mux anything yet as ffmux_dvd is buggy
 	  //FIXME: Until we don't have audio save the mpeg-ps stream without mux.
@@ -1351,7 +1355,7 @@ gst_video_editor_new (GError ** err)
 
   if (!gve->priv->main_pipeline)
     {
-      g_set_error (err, GVC_ERROR, GVC_ERROR_PLUGIN_LOAD,
+      g_set_error (err, GVC_ERROR, ERROR_PLUGIN_LOAD,
 		   ("Failed to create a GStreamer Bin. "
 		    "Please check your GStreamer installation."));
       g_object_ref_sink (gve);
@@ -1367,7 +1371,7 @@ gst_video_editor_new (GError ** err)
     gst_element_factory_make ("gnlcomposition", "gnl-audio-composition");
   if (!gve->priv->gnl_video_composition || !gve->priv->gnl_audio_composition)
     {
-      g_set_error (err, GVC_ERROR, GVC_ERROR_PLUGIN_LOAD,
+      g_set_error (err, GVC_ERROR, ERROR_PLUGIN_LOAD,
 		   ("Failed to create a Gnonlin element. "
 		    "Please check your GStreamer installation."));
       g_object_ref_sink (gve);
diff --git a/libcesarplayer/src/gst-video-editor.h b/libcesarplayer/src/gst-video-editor.h
index 09bb738..9dd6915 100644
--- a/libcesarplayer/src/gst-video-editor.h
+++ b/libcesarplayer/src/gst-video-editor.h
@@ -33,6 +33,7 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 
+#include "common.h"
 
 G_BEGIN_DECLS
 #define GST_TYPE_VIDEO_EDITOR             (gst_video_editor_get_type ())
@@ -61,37 +62,6 @@ struct _GstVideoEditor
   GstVideoEditorPrivate *priv;
 };
 
-typedef enum
-{
-  GVC_ERROR_PLUGIN_LOAD,
-} GvcError;
-
-
-typedef enum
-{
-  MPEG4,
-  XVID,
-  THEORA,
-  H264,
-  MPEG2_VIDEO,
-} GvsVideoEncoderType;
-
-typedef enum
-{
-  MP3,
-  AAC,
-  VORBIS,
-} GvsAudioEncoderType;
-
-typedef enum
-{
-  AVI,
-  MKV,
-  OGG,
-  DVD,
-} GvsVideoMuxer;
-
-
 EXPORT GType
 gst_video_editor_get_type (void)
   G_GNUC_CONST;
@@ -102,13 +72,13 @@ gst_video_editor_get_type (void)
      EXPORT void gst_video_editor_cancel (GstVideoEditor * gve);
      EXPORT void gst_video_editor_set_video_encoder (GstVideoEditor * gve,
 						     gchar ** err,
-						     GvsVideoEncoderType codec);
+						     VideoEncoderType codec);
      EXPORT void gst_video_editor_set_audio_encoder (GstVideoEditor * gve,
 						     gchar ** err,
-						     GvsAudioEncoderType codec);
+						     AudioEncoderType codec);
      EXPORT void gst_video_editor_set_video_muxer (GstVideoEditor * gve,
 						   gchar ** err,
-						   GvsVideoMuxer codec);
+						   VideoMuxerType codec);
      EXPORT void gst_video_editor_clear_segments_list (GstVideoEditor * gve);
      EXPORT void gst_video_editor_add_segment (GstVideoEditor * gve,
 					       gchar * file, gint64 start,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]