mediastream: Rename an api to avoid name collisions

Some bindings can't handle the coexistence of
GtkMediaStream:prepared and gtk_media_stream_prepared.
Help them out by renaming the function to
gtk_media_stream_set_prepared, and rename
gtk_media_stream_unprepared as well, to match.

The existing entry points still exist, deprecated.

Update all internal uses.

Fixes: #4023
This commit is contained in:
Matthias Clasen 2021-06-14 07:25:06 -04:00
parent e888364d3c
commit 86b5dba43b
6 changed files with 82 additions and 33 deletions

View File

@ -267,11 +267,11 @@ gtk_nuclear_media_stream_init (GtkNuclearMediaStream *nuclear)
* However, media streams need to tell GTK once they are initialized, * However, media streams need to tell GTK once they are initialized,
* so we do that here. * so we do that here.
*/ */
gtk_media_stream_prepared (GTK_MEDIA_STREAM (nuclear), gtk_media_stream_set_prepared (GTK_MEDIA_STREAM (nuclear),
FALSE, FALSE,
TRUE, TRUE,
TRUE, TRUE,
DURATION); DURATION);
} }
/* And finally, we add the simple constructor we declared in the header. */ /* And finally, we add the simple constructor we declared in the header. */

View File

@ -72,7 +72,7 @@ gtk_media_file_default_open (GtkMediaFile *self)
static void static void
gtk_media_file_default_close (GtkMediaFile *self) gtk_media_file_default_close (GtkMediaFile *self)
{ {
gtk_media_stream_unprepared (GTK_MEDIA_STREAM (self)); gtk_media_stream_unset_prepared (GTK_MEDIA_STREAM (self));
} }
static void static void

View File

@ -1012,7 +1012,7 @@ gtk_media_stream_unrealize (GtkMediaStream *self,
} }
/** /**
* gtk_media_stream_prepared: * gtk_media_stream_set_prepared:
* @self: a `GtkMediaStream` * @self: a `GtkMediaStream`
* @has_audio: %TRUE if the stream should advertise audio support * @has_audio: %TRUE if the stream should advertise audio support
* @has_video: %TRUE if the stream should advertise video support * @has_video: %TRUE if the stream should advertise video support
@ -1029,13 +1029,15 @@ gtk_media_stream_unrealize (GtkMediaStream *self,
* *
* This function may not be called again until the stream has been * This function may not be called again until the stream has been
* reset via [method@Gtk.MediaStream.unprepared]. * reset via [method@Gtk.MediaStream.unprepared].
*
* Since: 4.4
*/ */
void void
gtk_media_stream_prepared (GtkMediaStream *self, gtk_media_stream_set_prepared (GtkMediaStream *self,
gboolean has_audio, gboolean has_audio,
gboolean has_video, gboolean has_video,
gboolean seekable, gboolean seekable,
gint64 duration) gint64 duration)
{ {
GtkMediaStreamPrivate *priv = gtk_media_stream_get_instance_private (self); GtkMediaStreamPrivate *priv = gtk_media_stream_get_instance_private (self);
@ -1072,7 +1074,7 @@ gtk_media_stream_prepared (GtkMediaStream *self,
} }
/** /**
* gtk_media_stream_unprepared: * gtk_media_stream_unset_prepared:
* @self: a `GtkMediaStream` * @self: a `GtkMediaStream`
* *
* Resets a given media stream implementation. * Resets a given media stream implementation.
@ -1080,9 +1082,11 @@ gtk_media_stream_prepared (GtkMediaStream *self,
* [method@Gtk.MediaStream.prepared] can then be called again. * [method@Gtk.MediaStream.prepared] can then be called again.
* *
* This function will also reset any error state the stream was in. * This function will also reset any error state the stream was in.
*
* Since: 4.4
*/ */
void void
gtk_media_stream_unprepared (GtkMediaStream *self) gtk_media_stream_unset_prepared (GtkMediaStream *self)
{ {
GtkMediaStreamPrivate *priv = gtk_media_stream_get_instance_private (self); GtkMediaStreamPrivate *priv = gtk_media_stream_get_instance_private (self);
@ -1135,6 +1139,42 @@ gtk_media_stream_unprepared (GtkMediaStream *self)
g_object_thaw_notify (G_OBJECT (self)); g_object_thaw_notify (G_OBJECT (self));
} }
/**
* gtk_media_stream_prepared:
* @self: a `GtkMediaStream`
* @has_audio: %TRUE if the stream should advertise audio support
* @has_video: %TRUE if the stream should advertise video support
* @seekable: %TRUE if the stream should advertise seekability
* @duration: The duration of the stream or 0 if unknown
*
* Same as gtk_media_stream_set_prepared().
*
* Deprecated: 4.4: Use [method@Gtk.MediaStream.set_prepared] instead.
*/
void
gtk_media_stream_prepared (GtkMediaStream *self,
gboolean has_audio,
gboolean has_video,
gboolean seekable,
gint64 duration)
{
gtk_media_stream_set_prepared (self, has_audio, has_video, seekable, duration);
}
/**
* gtk_media_stream_unprepared:
* @self: a `GtkMediaStream`
*
* Same as gtk_media_stream_unset_prepared().
*
* Deprecated: 4.4: Use [method@Gtk.MediaStream.unset_prepared] instead.
*/
void
gtk_media_stream_unprepared (GtkMediaStream *self)
{
gtk_media_stream_unset_prepared (self);
}
/** /**
* gtk_media_stream_gerror: * gtk_media_stream_gerror:
* @self: a `GtkMediaStream` * @self: a `GtkMediaStream`

View File

@ -116,15 +116,24 @@ void gtk_media_stream_unrealize (GtkMediaStream
GdkSurface *surface); GdkSurface *surface);
/* for implementations only */ /* for implementations only */
GDK_AVAILABLE_IN_ALL GDK_DEPRECATED_IN_4_4_FOR(gtk_media_stream_set_prepared)
void gtk_media_stream_prepared (GtkMediaStream *self, void gtk_media_stream_prepared (GtkMediaStream *self,
gboolean has_audio, gboolean has_audio,
gboolean has_video, gboolean has_video,
gboolean seekable, gboolean seekable,
gint64 duration); gint64 duration);
GDK_AVAILABLE_IN_ALL GDK_DEPRECATED_IN_4_4_FOR(gtk_media_stream_unset_prepared)
void gtk_media_stream_unprepared (GtkMediaStream *self); void gtk_media_stream_unprepared (GtkMediaStream *self);
GDK_AVAILABLE_IN_4_4
void gtk_media_stream_set_prepared (GtkMediaStream *self,
gboolean has_audio,
gboolean has_video,
gboolean seekable,
gint64 duration);
GDK_AVAILABLE_IN_4_4
void gtk_media_stream_unset_prepared (GtkMediaStream *self);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gtk_media_stream_update (GtkMediaStream *self, void gtk_media_stream_update (GtkMediaStream *self,
gint64 timestamp); gint64 timestamp);

View File

@ -553,13 +553,13 @@ gtk_ff_media_file_open (GtkMediaFile *file)
return; return;
} }
gtk_media_stream_prepared (GTK_MEDIA_STREAM (video), gtk_media_stream_set_prepared (GTK_MEDIA_STREAM (video),
FALSE, FALSE,
video->codec_ctx != NULL, video->codec_ctx != NULL,
TRUE, TRUE,
video->format_ctx->duration != AV_NOPTS_VALUE video->format_ctx->duration != AV_NOPTS_VALUE
? av_rescale (video->format_ctx->duration, G_USEC_PER_SEC, AV_TIME_BASE) ? av_rescale (video->format_ctx->duration, G_USEC_PER_SEC, AV_TIME_BASE)
: 0); : 0);
gdk_paintable_invalidate_size (GDK_PAINTABLE (video)); gdk_paintable_invalidate_size (GDK_PAINTABLE (video));

View File

@ -137,11 +137,11 @@ gtk_gst_media_file_ensure_prepared (GtkGstMediaFile *self)
media_info = gst_player_get_media_info (self->player); media_info = gst_player_get_media_info (self->player);
if (media_info) if (media_info)
{ {
gtk_media_stream_prepared (GTK_MEDIA_STREAM (self), gtk_media_stream_set_prepared (GTK_MEDIA_STREAM (self),
gst_player_media_info_get_audio_streams (media_info) != NULL, gst_player_media_info_get_audio_streams (media_info) != NULL,
gst_player_media_info_get_video_streams (media_info) != NULL, gst_player_media_info_get_video_streams (media_info) != NULL,
gst_player_media_info_is_seekable (media_info), gst_player_media_info_is_seekable (media_info),
FROM_GST_TIME (gst_player_media_info_get_duration (media_info))); FROM_GST_TIME (gst_player_media_info_get_duration (media_info)));
g_object_unref (media_info); g_object_unref (media_info);
} }
@ -152,11 +152,11 @@ gtk_gst_media_file_ensure_prepared (GtkGstMediaFile *self)
* *
* Only for seeking we can't do a thing, because with 0 duration we can't seek anywhere. * Only for seeking we can't do a thing, because with 0 duration we can't seek anywhere.
*/ */
gtk_media_stream_prepared (GTK_MEDIA_STREAM (self), gtk_media_stream_set_prepared (GTK_MEDIA_STREAM (self),
TRUE, TRUE,
TRUE, TRUE,
FALSE, FALSE,
0); 0);
} }
} }