2 * This file is a part of MAFW
4 * Copyright (C) 2007, 2008, 2009 Nokia Corporation, all rights reserved.
6 * Contact: Visa Smolander <visa.smolander@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; version 2.1 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #ifndef MAFW_GST_RENDERER_WORKER_H
25 #define MAFW_GST_RENDERER_WORKER_H
27 #include <X11/Xdefs.h>
28 #include <glib-object.h>
30 #include "mafw-gst-renderer-worker-volume.h"
32 #define MAFW_GST_RENDERER_MAX_TMP_FILES 5
34 typedef struct _MafwGstRendererWorker MafwGstRendererWorker;
36 typedef void (*MafwGstRendererWorkerNotifySeekCb)(MafwGstRendererWorker *worker, gpointer owner);
37 typedef void (*MafwGstRendererWorkerNotifyPauseCb)(MafwGstRendererWorker *worker, gpointer owner);
38 typedef void (*MafwGstRendererWorkerNotifyPlayCb)(MafwGstRendererWorker *worker, gpointer owner);
39 typedef void (*MafwGstRendererWorkerNotifyBufferStatusCb)(MafwGstRendererWorker *worker, gpointer owner, gdouble percent);
40 typedef void (*MafwGstRendererWorkerNotifyEOSCb)(MafwGstRendererWorker *worker, gpointer owner);
41 typedef void (*MafwGstRendererWorkerNotifyErrorCb)(MafwGstRendererWorker *worker,
46 WORKER_MODE_SINGLE_PLAY,
48 WORKER_MODE_REDUNDANT,
52 SEEKABILITY_UNKNOWN = -1,
53 SEEKABILITY_NO_SEEKABLE,
58 * media: Information about currently selected media.
59 * location: Current media location
60 * length_nanos: Length of the media, in nanoseconds
61 * has_visual_content: the clip contains some visual content (video)
62 * video_width: If media contains video, this tells the video width
63 * video_height: If media contains video, this tells the video height
64 * seekable: Tells whether the media can be seeked
65 * par_n: Video pixel aspect ratio numerator
66 * par_d: Video pixel aspect ratio denominator
67 * owner: Owner of the worker; usually a MafwGstRenderer (FIXME USUALLY?)
68 * pipeline: Playback pipeline
70 * state: Current playback pipeline state
71 * is_stream: Is currently playing media a stream
72 * muted: Is the audio muted
73 * eos: Has playback reached EOS already
74 * is_error: Has there been an error situation
75 * buffering: Indicates the buffering state
76 * prerolling: Indicates the prerolling state (NULL -> PAUSED)
77 * report_statechanges: Report state change bus messages
78 * current_volume: Current audio volume [0.0 .. 1.0], see playbin:volume
79 * async_bus_id: ID handle for GstBus
80 * buffer_probe_id: ID of the video renderer buffer probe
81 * seek_position: Indicates the pos where to seek, in seconds
82 * vsink: Video sink element of the pipeline
83 * asink: Audio sink element of the pipeline
84 * xid: XID for video playback
85 * current_frame_on_pause: whether to emit current frame when pausing
87 struct _MafwGstRendererWorker {
91 gboolean has_visual_content;
95 SeekabilityType seekable;
103 gboolean notify_play_pending;
106 GstElement *pipeline;
108 /* GStreamer state we are considering right now */
110 MafwGstRendererWorkerVolume *wvolume;
113 /* we are handing eos or we did */
115 /* if we are handling (or handled) and error */
117 /* pipeline is buffering */
119 /* pipeline is prerolling */
121 /* stream is live and doesn't need prerolling */
123 /* if we have to stay in paused though a do_play was
124 * requested. Usually used when pausing in transitioning */
125 gboolean stay_paused;
126 /* this variable should be FALSE while we are hiding state
127 * changed to the UI. This is that GStreamer can perform
128 * state_changes without us requiring it, for example, then
129 * seeking, buffering and so on and we have to hide those
131 gboolean report_statechanges;
135 guint duration_seek_timeout;
136 /* After some time PAUSED, we set the pipeline to READY in order to
137 * save resources. This field states if we are in this special
139 * It is set to TRUE when the state change to READY is requested
140 * and stays like that until we reach again PLAYING state (not PAUSED).
141 * The reason for this is that when resuming streams, we have to
142 * move from READY to PAUSED, then seek to the position where the
143 * stream had been paused, then wait for buffering to finish, and then
144 * play (and notify the state change to PLAYING), and we have to
145 * differentiate this case from the one in which we have entered PAUSED
146 * silently (when we ran out of buffer while playing, because in that
147 * case, when we are done buffering we want to resume playback silently
157 GHashTable *current_metadata;
159 #ifdef HAVE_GDKPIXBUF
160 gboolean current_frame_on_pause;
161 gchar *tmp_files_pool[MAFW_GST_RENDERER_MAX_TMP_FILES];
162 guint8 tmp_files_pool_index;
165 /* Handlers for notifications */
166 MafwGstRendererWorkerNotifySeekCb notify_seek_handler;
167 MafwGstRendererWorkerNotifyPauseCb notify_pause_handler;
168 MafwGstRendererWorkerNotifyPlayCb notify_play_handler;
169 MafwGstRendererWorkerNotifyBufferStatusCb notify_buffer_status_handler;
170 MafwGstRendererWorkerNotifyEOSCb notify_eos_handler;
171 MafwGstRendererWorkerNotifyErrorCb notify_error_handler;
176 MafwGstRendererWorker *mafw_gst_renderer_worker_new(gpointer owner);
177 void mafw_gst_renderer_worker_exit(MafwGstRendererWorker *worker);
179 void mafw_gst_renderer_worker_set_volume(MafwGstRendererWorker *worker,
181 guint mafw_gst_renderer_worker_get_volume(MafwGstRendererWorker *worker);
182 void mafw_gst_renderer_worker_set_mute(MafwGstRendererWorker *worker,
184 gboolean mafw_gst_renderer_worker_get_mute(MafwGstRendererWorker *worker);
185 #ifdef HAVE_GDKPIXBUF
186 void mafw_gst_renderer_worker_set_current_frame_on_pause(MafwGstRendererWorker *worker,
187 gboolean current_frame_on_pause);
188 gboolean mafw_gst_renderer_worker_get_current_frame_on_pause(MafwGstRendererWorker *worker);
190 void mafw_gst_renderer_worker_set_position(MafwGstRendererWorker *worker,
191 GstSeekType seek_type,
194 gint mafw_gst_renderer_worker_get_position(MafwGstRendererWorker *worker);
195 void mafw_gst_renderer_worker_set_xid(MafwGstRendererWorker *worker, XID xid);
196 XID mafw_gst_renderer_worker_get_xid(MafwGstRendererWorker *worker);
197 gboolean mafw_gst_renderer_worker_get_autopaint(MafwGstRendererWorker *worker);
198 void mafw_gst_renderer_worker_set_autopaint(MafwGstRendererWorker *worker, gboolean autopaint);
199 gint mafw_gst_renderer_worker_get_colorkey(MafwGstRendererWorker *worker);
200 gboolean mafw_gst_renderer_worker_get_seekable(MafwGstRendererWorker *worker);
201 GHashTable *mafw_gst_renderer_worker_get_current_metadata(MafwGstRendererWorker *worker);
202 void mafw_gst_renderer_worker_play(MafwGstRendererWorker *worker, const gchar *uri);
203 void mafw_gst_renderer_worker_play_alternatives(MafwGstRendererWorker *worker, gchar **uris);
204 void mafw_gst_renderer_worker_stop(MafwGstRendererWorker *worker);
205 void mafw_gst_renderer_worker_pause(MafwGstRendererWorker *worker);
206 void mafw_gst_renderer_worker_resume(MafwGstRendererWorker *worker);
210 /* vi: set noexpandtab ts=8 sw=8 cino=t0,(0: */