From: <wt...@ke...> - 2007-04-14 16:24:47
|
CVS Root: /cvs/gstreamer Module: gst-phonon Changes by: wtay Date: Sat Apr 14 2007 16:24:41 UTC Log message: * gst-phonon/gpho-audiooutput.c: (gpho_audio_output_class_init), (gpho_audio_output_set_property), (gpho_audio_output_get_property), (gpho_audio_output_set_muted), (gpho_audio_output_is_muted): * gst-phonon/gpho-audiooutput.h: Add and implement muted property. * gst-phonon/gpho-mediaobject.c: (gpho_media_object_open_media), (gpho_media_object_get_media), (gpho_media_object_get_media_device): * gst-phonon/gpho-mediaobject.h: Add new open_media methods and type. * gst-phonon/gpho-mediaproducer.c: (gpho_media_producer_class_init), (gpho_media_producer_get_error_string), (gpho_media_producer_get_error_type): * gst-phonon/gpho-mediaproducer.h: Added new signals to inform about seekability, video and buffering. Added new methods and type for getting error string and type. Modified files: . : ChangeLog gst-phonon : gpho-audiooutput.c gpho-audiooutput.h gpho-mediaobject.c gpho-mediaobject.h gpho-mediaproducer.c gpho-mediaproducer.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-phonon/ChangeLog.diff?r1=1.20&r2=1.21 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-phonon/gst-phonon/gpho-audiooutput.c.diff?r1=1.5&r2=1.6 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-phonon/gst-phonon/gpho-audiooutput.h.diff?r1=1.1.1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-phonon/gst-phonon/gpho-mediaobject.c.diff?r1=1.2&r2=1.3 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-phonon/gst-phonon/gpho-mediaobject.h.diff?r1=1.1.1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-phonon/gst-phonon/gpho-mediaproducer.c.diff?r1=1.16&r2=1.17 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-phonon/gst-phonon/gpho-mediaproducer.h.diff?r1=1.4&r2=1.5 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-phonon/ChangeLog,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- ChangeLog 14 Apr 2007 14:22:04 -0000 1.20 +++ ChangeLog 14 Apr 2007 16:24:29 -0000 1.21 @@ -1,5 +1,27 @@ 2007-04-14 Wim Taymans <wi...@fl...> + * gst-phonon/gpho-audiooutput.c: (gpho_audio_output_class_init), + (gpho_audio_output_set_property), (gpho_audio_output_get_property), + (gpho_audio_output_set_muted), (gpho_audio_output_is_muted): + * gst-phonon/gpho-audiooutput.h: + Add and implement muted property. + + * gst-phonon/gpho-mediaobject.c: (gpho_media_object_open_media), + (gpho_media_object_get_media), + (gpho_media_object_get_media_device): + * gst-phonon/gpho-mediaobject.h: + Add new open_media methods and type. + * gst-phonon/gpho-mediaproducer.c: + (gpho_media_producer_class_init), + (gpho_media_producer_get_error_string), + (gpho_media_producer_get_error_type): + * gst-phonon/gpho-mediaproducer.h: + Added new signals to inform about seekability, video and buffering. + Added new methods and type for getting error string and type. +2007-04-14 Wim Taymans <wi...@fl...> * gst-phonon/gpho-abstractaudiooutput.c: (gpho_abstract_audio_output_get_element): Move audioconvert over here and do some more error checking. Index: gpho-audiooutput.c RCS file: /cvs/gstreamer/gst-phonon/gst-phonon/gpho-audiooutput.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- gpho-audiooutput.c 14 Apr 2007 14:22:05 -0000 1.5 +++ gpho-audiooutput.c 14 Apr 2007 16:24:29 -0000 1.6 @@ -69,6 +69,7 @@ enum { SIGNAL_VOLUME_CHANGED, + SIGNAL_MUTED_CHANGED, SIGNAL_DEVICE_CHANGED, SIGNAL_LAST }; @@ -77,6 +78,7 @@ #define DEFAULT_PROP_NAME NULL #define DEFAULT_PROP_VOLUME 1.0 #define DEFAULT_PROP_VOLUME_DECIBEL 0.0 +#define DEFAULT_PROP_MUTED FALSE #define DEFAULT_PROP_OUTPUT_DEVICE NULL @@ -86,6 +88,7 @@ PROP_NAME, PROP_VOLUME, PROP_VOLUME_DECIBEL, + PROP_MUTED, PROP_OUTPUT_DEVICE, PROP_LAST @@ -96,6 +99,7 @@ struct _GPhoAudioOutputPrivate gfloat volume_val; + gboolean muted; GstElement *volume; GstElement *sink; GstElement *elem; @@ -210,6 +214,15 @@ G_MAXDOUBLE, DEFAULT_PROP_VOLUME_DECIBEL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); /** + * GPhoAudioOutput::mute + * + * This property tells whether the output is muted. + */ + g_object_class_install_property (gobject_class, PROP_VOLUME_DECIBEL, + g_param_spec_boolean ("muted", "Muted", + "If the ouput is muted.", DEFAULT_PROP_MUTED, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + /** * GPhoAudioOutput::output-device * * This property holds the (hardware) destination for the output. @@ -242,6 +255,21 @@ volume_changed), NULL, NULL, g_cclosure_marshal_VOID__FLOAT, G_TYPE_NONE, 1, G_TYPE_FLOAT); + * GPhoAudioOutput::muted-changed: + * @output: a #GPhoAudioOutput + * @mute: the new muted state + * This signal is emitted when the muted property has changed. + * As this property can change by IPC (DBus) calls a UI element showing the + * muted property should listen to this signal. + gpho_audio_output_signals[SIGNAL_MUTED_CHANGED] = + g_signal_new ("muted-changed", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GPhoAudioOutputClass, + muted_changed), NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); * GPhoAudioOutput::device-changed: * @output: a #GPhoAudioOutput * @device: the new device #GPhoDescription @@ -308,6 +336,9 @@ case PROP_VOLUME_DECIBEL: gpho_audio_output_set_volume_decibel (output, g_value_get_double (value)); break; + case PROP_MUTED: + gpho_audio_output_set_muted (output, g_value_get_boolean (value)); + break; case PROP_OUTPUT_DEVICE: gpho_audio_output_set_output_device (output, g_value_get_pointer (value)); @@ -338,6 +369,9 @@ g_value_set_double (value, gpho_audio_output_get_volume_decibel (output)); + g_value_set_boolean (value, gpho_audio_output_is_muted (output)); g_value_set_pointer (value, gpho_audio_output_get_output_device (output)); @@ -531,6 +565,73 @@ } /** + * gpho_audio_output_set_muted: + * @output: a #GPhoAudioOutput + * @mute: new mute state. + * + * Mute or unmute @output. + */ +void +gpho_audio_output_set_muted (GPhoAudioOutput *output, gboolean mute) +{ + gboolean old; + gboolean emit = FALSE; + g_return_if_fail (GPHO_IS_AUDIO_OUTPUT (output)); + GPHO_OBJECT_LOCK (output); + old = output->priv->muted; + if (G_UNLIKELY (old == mute)) + goto was_ok; + GST_DEBUG ("%p: setting muted to %d", output, mute); + /* configure in the volume element */ + if (output->priv->volume) + g_object_set (output->priv->volume, "mute", mute, NULL); + output->priv->muted = mute; + emit = TRUE; +done: + GPHO_OBJECT_UNLOCK (output); + if (G_LIKELY (emit)) + g_signal_emit (output, gpho_audio_output_signals[SIGNAL_MUTED_CHANGED], 0, + mute); + return; + /* Special cases */ +was_ok: + { + GST_DEBUG ("%p: muted did not change", output); + goto done; + } +} +/** + * gpho_audio_output_is_muted: + * Check if @output is muted. + * Returns: %TRUE if @output is muted. +gboolean +gpho_audio_output_is_muted (GPhoAudioOutput *output) + gboolean result; + g_return_val_if_fail (GPHO_IS_AUDIO_OUTPUT (output), FALSE); + result = output->priv->muted; + return result; * gpho_audio_output_set_output_device: * @output: a #GPhoAudioOutput * @device: a #GPhoDescription Index: gpho-audiooutput.h RCS file: /cvs/gstreamer/gst-phonon/gst-phonon/gpho-audiooutput.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- gpho-audiooutput.h 14 Feb 2007 12:35:41 -0000 1.1.1.1 +++ gpho-audiooutput.h 14 Apr 2007 16:24:29 -0000 1.2 @@ -98,6 +98,7 @@ /* signals */ void (*volume_changed) (GPhoAudioOutput *output, gfloat volume); + void (*muted_changed) (GPhoAudioOutput *output, gboolean muted); void (*device_changed) (GPhoAudioOutput *output, GPhoDescription *device); /*< private >*/ @@ -121,6 +122,8 @@ gfloat gpho_audio_output_get_volume (GPhoAudioOutput *output); void gpho_audio_output_set_volume_decibel (GPhoAudioOutput *output, gdouble volume); gdouble gpho_audio_output_get_volume_decibel (GPhoAudioOutput *output); +void gpho_audio_output_set_muted (GPhoAudioOutput *output, gboolean mute); +gboolean gpho_audio_output_is_muted (GPhoAudioOutput *output); /* device */ void gpho_audio_output_set_output_device (GPhoAudioOutput *output, GPhoDescription *device); Index: gpho-mediaobject.c RCS file: /cvs/gstreamer/gst-phonon/gst-phonon/gpho-mediaobject.c,v retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gpho-mediaobject.c 12 Apr 2007 16:54:35 -0000 1.2 +++ gpho-mediaobject.c 14 Apr 2007 16:24:29 -0000 1.3 @@ -53,9 +53,12 @@ struct _GPhoMediaObjectPrivate - gchar *url; - gint64 total_time; - gint32 about_to_finish_time; + gchar *url; + GPhoMedia media; + gchar *media_device; + gint64 total_time; + gint32 about_to_finish_time; GstElement *source; @@ -433,6 +436,83 @@ + * gpho_media_object_open_media: + * @mobj: a #GPhoMediaObject. + * @media: a #GPhoMedia to open + * @media_device: the device name of the media + * Instead of a media file GPhoMediaObject can also handle other media like + * DVD, CD and so forth. + * To open such a media ignore the URL property and call this function instead. + * gpho_media_object_get_url() will return an empty URL then. +gpho_media_object_open_media (GPhoMediaObject *mobj, GPhoMedia media, + const gchar *media_device) + g_return_if_fail (GPHO_IS_MEDIA_OBJECT (mobj)); + g_return_if_fail (media_device != NULL); + GPHO_OBJECT_LOCK (mobj); + /* store values */ + mobj->priv->media = media; + if (mobj->priv->media_device) + g_free (mobj->priv->media_device); + mobj->priv->media_device = g_strdup (media_device); + /* reset URL */ + if (mobj->priv->url) + g_free (mobj->priv->url); + mobj->priv->url = NULL; + GPHO_OBJECT_UNLOCK (mobj); + * gpho_media_object_get_media: + * Get the current media being handled. + * Returns: a #GPhoMedia describing the media being handled. +GPhoMedia +gpho_media_object_get_media (GPhoMediaObject *mobj) + GPhoMedia result; + g_return_val_if_fail (GPHO_IS_MEDIA_OBJECT (mobj), GPHO_MEDIA_NONE); + result = mobj->priv->media; + * gpho_media_object_get_media_device: + * Get the current media device being handled. + * Returns: a #gchar* describing the media device being handled. g_free after + * usage. +gchar* +gpho_media_object_get_media_device (GPhoMediaObject *mobj) + gchar *result; + g_return_val_if_fail (GPHO_IS_MEDIA_OBJECT (mobj), NULL); + result = g_strdup (mobj->priv->media_device); * gpho_media_object_set_about_to_finish_time: * @mobj: a #GPhoMediaObject. * @time: a time in milliseconds; Index: gpho-mediaobject.h RCS file: /cvs/gstreamer/gst-phonon/gst-phonon/gpho-mediaobject.h,v --- gpho-mediaobject.h 14 Feb 2007 12:35:41 -0000 1.1.1.1 +++ gpho-mediaobject.h 14 Apr 2007 16:24:29 -0000 1.2 @@ -40,6 +40,22 @@ typedef struct _GPhoMediaObjectClass GPhoMediaObjectClass; typedef struct _GPhoMediaObjectPrivate GPhoMediaObjectPrivate; + * GPhoMedia: + * @GPHO_MEDIA_NONE: no media + * @GPHO_MEDIA_CD: a CD device + * @GPHO_MEDIA_DVD: a DVD device + * @GPHO_MEDIA_VCD: a Video CD device + * The different media that can be opened. +typedef enum { + GPHO_MEDIA_NONE = 0, + GPHO_MEDIA_CD = 1, + GPHO_MEDIA_DVD = 2, + GPHO_MEDIA_VCD = 3 +} GPhoMedia; struct _GPhoMediaObject { GPhoMediaProducer producer; @@ -67,6 +83,11 @@ void gpho_media_object_set_url (GPhoMediaObject *mobj, const gchar *url); gchar* gpho_media_object_get_url (GPhoMediaObject *mobj); +void gpho_media_object_open_media (GPhoMediaObject *mobj, GPhoMedia media, + const gchar *media_device); +GPhoMedia gpho_media_object_get_media (GPhoMediaObject *mobj); +gchar* gpho_media_object_get_media_device (GPhoMediaObject *mobj); /* getting signals when about to finish */ void gpho_media_object_set_about_to_finish_time (GPhoMediaObject *mobj, gint32 time); gint32 gpho_media_object_get_about_to_finish_time (GPhoMediaObject *mobj); Index: gpho-mediaproducer.c RCS file: /cvs/gstreamer/gst-phonon/gst-phonon/gpho-mediaproducer.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- gpho-mediaproducer.c 14 Apr 2007 13:13:36 -0000 1.16 +++ gpho-mediaproducer.c 14 Apr 2007 16:24:29 -0000 1.17 @@ -86,6 +86,9 @@ SIGNAL_STATE_CHANGED, SIGNAL_TICK, SIGNAL_METADATA_CHANGED, + SIGNAL_SEEKABLE_CHANGED, + SIGNAL_HAS_VIDEO_CHANGED, + SIGNAL_BUFFER_STATUS, @@ -133,6 +136,9 @@ gint num_valid; /* number of recognized streams */ GPhoMetadata *metadata; /* a list of metadata entries */ + gchar *last_error; + GPhoErrorType last_error_type; static GObjectClass *parent_class = NULL; @@ -244,6 +250,63 @@ metadata_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); + * GPhoCapabilites::seekable-changed: + * @prod: a #GPhoMediaProducer + * @seekable: new status + * Emitted whenever the return value of gpho_media_producer_is_seekable() + * changes. + * Normally you'll check gpho_media_producer_is_seekable() first and then + * let this signal tell you whether seeking is possible now or not. That way + * you don't have to poll gpho_media_producer_is_seekable(). + gpho_media_producer_signals[SIGNAL_METADATA_CHANGED] = + g_signal_new ("seekable-changed", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GPhoMediaProducerClass, + seekable_changed), NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, + * GPhoCapabilites::has-video-changed: + * @has_video: new status + * Emitted whenever the return value of gpho_media_producer_has_video() + * Normally you'll check gpho_media_producer_has_video() first and then let + * this signal tell you whether video is available now or not. That way you + * don't have to poll gpho_media_producer_has_video(). + * @has_video will be %TRUE when the stream contains video and adding a + * GPhoVideoWidget will show a video. %FALSE when there is no video data in + * the stream and adding a GPhoVideoWidget will show an empty (black) + * GPhoVideoWidget. + g_signal_new ("has-video-changed", G_TYPE_FROM_CLASS (klass), + has_video_changed), NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, + * GPhoCapabilites::buffer-status: + * @percent_filled: new status + * Tells about the status of the buffer. + * You can use this signal to show a progress bar to the user when in + * #GPHO_STATE_BUFFERING. + g_signal_new ("buffer-status", G_TYPE_FROM_CLASS (klass), + buffer_status), NULL, NULL, g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, G_TYPE_INT); GST_DEBUG_CATEGORY_INIT (gpho_media_producer_debug, "phomediaproducer", 0, "Phonon media producer"); @@ -1958,3 +2021,49 @@ return result; + * gpho_media_producer_get_error_string: + * @prod: a #GPhoMediaProducer + * Get a translated string describing the last error. + * Returns: A translated string describing the error or NULL when there was no + * error. g_free after usage. +gpho_media_producer_get_error_string (GPhoMediaProducer *prod) + g_return_val_if_fail (GPHO_IS_MEDIA_PRODUCER (prod), NULL); + + GPHO_OBJECT_LOCK (prod); + result = g_strdup (prod->priv->last_error); + GPHO_OBJECT_UNLOCK (prod); + * gpho_media_producer_get_error_type: + * Get the error type that tells your program what to do about the error. + * Returns: a #GPhoErrorType. +GPhoErrorType +gpho_media_producer_get_error_type (GPhoMediaProducer *prod) + GPhoErrorType result; + g_return_val_if_fail (GPHO_IS_MEDIA_PRODUCER (prod), GPHO_ERROR_FATAL); + result = prod->priv->last_error_type; Index: gpho-mediaproducer.h RCS file: /cvs/gstreamer/gst-phonon/gst-phonon/gpho-mediaproducer.h,v retrieving revision 1.4 diff -u -d -r1.4 -r1.5 --- gpho-mediaproducer.h 12 Apr 2007 16:54:35 -0000 1.4 +++ gpho-mediaproducer.h 14 Apr 2007 16:24:29 -0000 1.5 @@ -71,6 +71,24 @@ GPHO_STATE_ERROR, } GPhoState; + * GPhoErrorType: + * @GPHO_ERROR_NONE: No error + * @GPHO_ERROR_NORMAL: Playback should work, and trying with another URL should + * work. + * @GPHO_ERROR_FATAL: Something important does not work. Your program cannot + * continue playback or capture or whatever it was trying to do without help from + * the user. + * Tells your program how to recover from an error. +typedef enum + GPHO_ERROR_NONE = 0, + GPHO_ERROR_NORMAL = 1, + GPHO_ERROR_FATAL = 2 +} GPhoErrorType; struct _GPhoMediaProducer { GPhoObject object; @@ -97,9 +115,12 @@ gboolean (*finished) (GPhoMediaProducer * mp); - void (*state_changed) (GPhoMediaProducer * mp); + void (*state_changed) (GPhoMediaProducer * mp, GPhoState new_state, GPhoState old_state); void (*tick) (GPhoMediaProducer * mp, gint64 time); void (*metadata_changed) (GPhoMediaProducer * mp); + void (*seekable_changed) (GPhoMediaProducer * mp, gboolean seekable); + void (*has_video_changed) (GPhoMediaProducer * mp, gboolean has_video); + void (*buffer_status) (GPhoMediaProducer * mp, gint percent_filled); gpointer padding[8]; @@ -156,6 +177,11 @@ gchar* gpho_media_producer_meta_data_item (GPhoMediaProducer *prod, const gchar *key); GList* gpho_media_producer_meta_data_items (GPhoMediaProducer *prod, const gchar *key); +/* errors */ +gchar* gpho_media_producer_get_error_string (GPhoMediaProducer *prod); +GPhoErrorType gpho_media_producer_get_error_type (GPhoMediaProducer *prod); G_END_DECLS #endif /* __GPHO_MEDIA_PRODUCER_H__ */ |