Rework to include gnome preferences. Correct signal methods
[wxWidgets.git] / src / unix / mediactrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: unix/mediactrl.cpp
3 // Purpose: Built-in Media Backends for Unix
4 // Author: Ryan Norton <wxprojects@comcast.net>
5 // Modified by:
6 // Created: 02/04/05
7 // RCS-ID: $Id$
8 // Copyright: (c) 2004-2005 Ryan Norton
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 //===========================================================================
13 // DECLARATIONS
14 //===========================================================================
15
16 //---------------------------------------------------------------------------
17 // Pre-compiled header stuff
18 //---------------------------------------------------------------------------
19
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "mediactrl.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 //---------------------------------------------------------------------------
32 // Includes
33 //---------------------------------------------------------------------------
34 #include "wx/mediactrl.h"
35
36 //---------------------------------------------------------------------------
37 // Compilation guard
38 //---------------------------------------------------------------------------
39 #if wxUSE_MEDIACTRL
40
41 //===========================================================================
42 // BACKEND DECLARATIONS
43 //===========================================================================
44
45 //---------------------------------------------------------------------------
46 //
47 // wxGStreamerMediaBackend
48 //
49 //TODO:
50 //TODO: This is really not the best way to play-stop -
51 //TODO: it should just have one playbin and stick with it the whole
52 //TODO: instance of wxGStreamerMediaBackend - but stopping appears
53 //TODO: to invalidate the playbin object...
54 //TODO:
55 //
56 //---------------------------------------------------------------------------
57 #if wxUSE_GSTREAMER
58
59 //---------------------------------------------------------------------------
60 // GStreamer Includes
61 //---------------------------------------------------------------------------
62 #include <gst/gst.h>
63 #include <gst/xoverlay/xoverlay.h>
64
65 #include <string.h> //strstr
66
67 #include "wx/log.h"
68
69 #ifdef __WXGTK__
70 //for <gdk/gdkx.h>/related for GDK_WINDOW_XWINDOW
71 # include "wx/gtk/win_gtk.h"
72 # include <gtk/gtksignal.h>
73 # if wxUSE_DYNLIB_CLASS
74 # include "wx/dynlib.h"
75 # endif
76 //# include <gst/gconf/gconf.h> //gstreamer gnome interface - needs deps
77 #endif
78
79
80 class WXDLLIMPEXP_MEDIA wxGStreamerMediaBackend : public wxMediaBackend
81 {
82 public:
83
84 wxGStreamerMediaBackend();
85 ~wxGStreamerMediaBackend();
86
87 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
88 wxWindowID id,
89 const wxPoint& pos,
90 const wxSize& size,
91 long style,
92 const wxValidator& validator,
93 const wxString& name);
94
95 virtual bool Play();
96 virtual bool Pause();
97 virtual bool Stop();
98
99 virtual bool Load(const wxString& fileName);
100 virtual bool Load(const wxURI& location);
101
102 virtual wxMediaState GetState();
103
104 virtual bool SetPosition(wxLongLong where);
105 virtual wxLongLong GetPosition();
106 virtual wxLongLong GetDuration();
107
108 virtual void Move(int x, int y, int w, int h);
109 wxSize GetVideoSize() const;
110
111 virtual double GetPlaybackRate();
112 virtual bool SetPlaybackRate(double dRate);
113
114 void Cleanup();
115
116 static void OnFinish(GstElement *play, gpointer data);
117 static void OnError (GstElement *play, GstElement *src,
118 GError *err, gchar *debug,
119 gpointer data);
120 static void OnVideoCapsReady(GstPad* pad, GParamSpec* pspec, gpointer data);
121
122 static bool TransCapsToVideoSize(wxGStreamerMediaBackend* be, GstPad* caps);
123 void PostRecalcSize();
124
125 #ifdef __WXGTK__
126 static gint OnGTKRealize(GtkWidget* theWidget, wxGStreamerMediaBackend* be);
127 #endif
128
129 GstElement* m_player; //GStreamer media element
130
131 wxSize m_videoSize;
132 wxControl* m_ctrl;
133
134 wxLongLong m_nPausedPos;
135
136 DECLARE_DYNAMIC_CLASS(wxGStreamerMediaBackend);
137 };
138
139
140 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
141 //
142 // wxGStreamerMediaBackend
143 //
144 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
145
146 IMPLEMENT_DYNAMIC_CLASS(wxGStreamerMediaBackend, wxMediaBackend);
147
148 //---------------------------------------------------------------------------
149 // wxGStreamerMediaBackend Constructor
150 //
151 // Sets m_player to NULL signifying we havn't loaded anything yet
152 //---------------------------------------------------------------------------
153 wxGStreamerMediaBackend::wxGStreamerMediaBackend() : m_player(NULL), m_videoSize(0,0)
154 {
155 }
156
157 //---------------------------------------------------------------------------
158 // wxGStreamerMediaBackend Destructor
159 //
160 // Stops/cleans up memory
161 //---------------------------------------------------------------------------
162 wxGStreamerMediaBackend::~wxGStreamerMediaBackend()
163 {
164 Cleanup();
165 }
166
167 //---------------------------------------------------------------------------
168 // wxGStreamerMediaBackend::OnGTKRealize
169 //
170 // If the window wasn't realized when Load was called, this is the
171 // callback for when it is.
172 //
173 // 1) Installs GTK idle handler if it doesn't exist
174 // 2) Yeilds to avoid an X11 bug (?)
175 // 3) Tells GStreamer to play the video in our control
176 //---------------------------------------------------------------------------
177 #ifdef __WXGTK__
178
179 #ifdef __WXDEBUG__
180
181 #if wxUSE_THREADS
182 # define DEBUG_MAIN_THREAD if (wxThread::IsMain() && g_mainThreadLocked) printf("gui reentrance");
183 #else
184 # define DEBUG_MAIN_THREAD
185 #endif
186 #else
187 #define DEBUG_MAIN_THREAD
188 #endif // Debug
189
190 extern void wxapp_install_idle_handler();
191 extern bool g_isIdle;
192 extern bool g_mainThreadLocked;
193
194 gint wxGStreamerMediaBackend::OnGTKRealize(GtkWidget* theWidget,
195 wxGStreamerMediaBackend* be)
196 {
197 DEBUG_MAIN_THREAD
198
199 if (g_isIdle)
200 wxapp_install_idle_handler();
201
202 wxYield(); //FIXME: X Server gets an error if I don't do this or a messagebox beforehand?!?!??
203
204 GdkWindow *window = GTK_PIZZA(theWidget)->bin_window;
205 wxASSERT(window);
206
207 GstElement* videosink;
208 g_object_get (G_OBJECT (be->m_player), "video-sink", &videosink, NULL);
209
210 GstElement* overlay = gst_bin_get_by_interface (GST_BIN (videosink),
211 GST_TYPE_X_OVERLAY);
212 gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(overlay),
213 GDK_WINDOW_XWINDOW( window )
214 );
215
216 return 0;
217 }
218
219
220 #endif
221
222 //---------------------------------------------------------------------------
223 // wxGStreamerMediaBackend::Cleanup
224 //
225 // Frees the gstreamer interfaces if there were any created
226 //---------------------------------------------------------------------------
227 void wxGStreamerMediaBackend::Cleanup()
228 {
229 if(m_player && GST_IS_OBJECT(m_player))
230 {
231 gst_element_set_state (m_player, GST_STATE_NULL);
232 gst_object_unref (GST_OBJECT (m_player));
233 }
234 }
235
236 //---------------------------------------------------------------------------
237 // wxGStreamerMediaBackend::CreateControl
238 //
239 // Initializes GStreamer and creates the wx side of our media control
240 //---------------------------------------------------------------------------
241 bool wxGStreamerMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
242 wxWindowID id,
243 const wxPoint& pos,
244 const wxSize& size,
245 long style,
246 const wxValidator& validator,
247 const wxString& name)
248 {
249 //init gstreamer
250 gst_init(NULL, NULL);
251
252 m_ctrl = ctrl;
253
254 return m_ctrl->wxControl::Create(parent, id, pos, size,
255 style, //remove borders???
256 validator, name);
257 }
258
259 //---------------------------------------------------------------------------
260 // wxGStreamerMediaBackend::TransCapsToVideoSize
261 //
262 // Gets the size of our video (in wxSize) from a GstPad
263 //---------------------------------------------------------------------------
264 bool wxGStreamerMediaBackend::TransCapsToVideoSize(wxGStreamerMediaBackend* be, GstPad* pad)
265 {
266 const GstCaps* caps = GST_PAD_CAPS (pad);
267 if(caps)
268 {
269
270 const GstStructure *s;
271 s = gst_caps_get_structure (caps, 0);
272 wxASSERT(s);
273
274 gst_structure_get_int (s, "width", &be->m_videoSize.x);
275 gst_structure_get_int (s, "height", &be->m_videoSize.y);
276
277 const GValue *par;
278 par = gst_structure_get_value (s, "pixel-aspect-ratio");
279
280 if (par)
281 {
282 int num = gst_value_get_fraction_numerator (par),
283 den = gst_value_get_fraction_denominator (par);
284
285 //TODO: maybe better fraction normalization...
286 if (num > den)
287 be->m_videoSize.x = (int) ((float) num * be->m_videoSize.x / den);
288 else
289 be->m_videoSize.y = (int) ((float) den * be->m_videoSize.y / num);
290 }
291
292 be->PostRecalcSize();
293 return true;
294 }//end if caps
295
296 return false;
297 }
298
299 //---------------------------------------------------------------------------
300 // wxGStreamerMediaBackend::PostRecalcSize
301 //
302 // Forces parent to recalc its layout if it has sizers to update
303 // to the new video size
304 //---------------------------------------------------------------------------
305 void wxGStreamerMediaBackend::PostRecalcSize()
306 {
307 m_ctrl->InvalidateBestSize();
308 m_ctrl->GetParent()->Layout();
309 m_ctrl->GetParent()->Refresh();
310 m_ctrl->GetParent()->Update();
311 }
312
313 //---------------------------------------------------------------------------
314 // wxGStreamerMediaBackend::OnFinish
315 //
316 // Called by gstreamer when the media is done playing
317 //
318 // 1) Send a wxEVT_MEDIA_STOP to the control
319 // 2) If veteod, break out
320 // 3) really stop the media
321 // 4) Send a wxEVT_MEDIA_FINISHED to the control
322 //---------------------------------------------------------------------------
323 void wxGStreamerMediaBackend::OnFinish(GstElement *play, gpointer data)
324 {
325 wxGStreamerMediaBackend* m_parent = (wxGStreamerMediaBackend*) data;
326
327 wxMediaEvent theEvent(wxEVT_MEDIA_STOP,
328 m_parent->m_ctrl->GetId());
329 m_parent->m_ctrl->ProcessEvent(theEvent);
330
331 if(theEvent.IsAllowed())
332 {
333 bool bOk = m_parent->Stop();
334 wxASSERT(bOk);
335
336 //send the event to our child
337 wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
338 m_parent->m_ctrl->GetId());
339 m_parent->m_ctrl->ProcessEvent(theEvent);
340 }
341 }
342
343 //---------------------------------------------------------------------------
344 // wxGStreamerMediaBackend::OnError
345 //
346 // Called by gstreamer when an error is encountered playing the media
347 //
348 // TODO: Make this better - maybe some more intelligent wxLog stuff
349 //---------------------------------------------------------------------------
350 void wxGStreamerMediaBackend::OnError(GstElement *play,
351 GstElement *src,
352 GError *err,
353 gchar *debug,
354 gpointer data)
355 {
356 wxLogSysError(
357 wxString::Format(
358 wxT("Error in wxMediaCtrl!\nError Message:%s\nDebug:%s\n"),
359 (const wxChar*)wxConvUTF8.cMB2WX(err->message),
360 (const wxChar*)wxConvUTF8.cMB2WX(debug)
361 )
362 );
363 }
364
365
366 //---------------------------------------------------------------------------
367 // wxGStreamerMediaBackend::Load (File version)
368 //
369 // Just calls the URI version
370 //---------------------------------------------------------------------------
371 bool wxGStreamerMediaBackend::Load(const wxString& fileName)
372 {
373 return Load(
374 wxURI(
375 wxString( wxT("file://") ) + fileName
376 )
377 );
378 }
379
380 //---------------------------------------------------------------------------
381 // wxGStreamerMediaBackend::OnVideoCapsReady
382 //
383 // Called by gstreamer when the video caps for the media is ready
384 //---------------------------------------------------------------------------
385 void wxGStreamerMediaBackend::OnVideoCapsReady(GstPad* pad, GParamSpec* pspec, gpointer data)
386 {
387 wxGStreamerMediaBackend::TransCapsToVideoSize((wxGStreamerMediaBackend*) data, pad);
388 }
389
390 //---------------------------------------------------------------------------
391 // wxGStreamerMediaBackend::Load (URI version)
392 //
393 // 1) Stops/Cleanups the previous instance if there is any
394 // 2) Creates the gstreamer playbin
395 // 3) If there is no playbin bail out
396 // 4) Set up the error and end-of-stream callbacks for our player
397 // 5) Make our video sink and make sure it supports the x overlay interface
398 // 6) Make sure the passed URI is valid and tell playbin to load it
399 // 7) Use the xoverlay extension to tell gstreamer to play in our window
400 // 8) Get the video size - pause required to set the stream in action
401 //---------------------------------------------------------------------------
402 bool wxGStreamerMediaBackend::Load(const wxURI& location)
403 {
404 //1
405 Cleanup();
406
407 //2
408 m_player = gst_element_factory_make ("playbin", "play");
409
410 //3
411 if (!m_player)
412 return false;
413
414 //4
415 g_signal_connect (m_player, "eos", G_CALLBACK (OnFinish), this);
416 g_signal_connect (m_player, "error", G_CALLBACK (OnError), this);
417
418 //5
419 GstElement* overlay = NULL;
420 GstElement* videosink;
421
422 #if defined(__WXGTK__) && wxUSE_DYNLIB_CLASS
423
424 //use gnome-specific gstreamer extensions
425 //if synthisis (?) file not found, it
426 //spits out a warning and uses ximagesink
427 wxDynamicLibrary gstgconf;
428 if(gstgconf.Load(gstgconf.CanonicalizeName(wxT("gstgconf-0.8"))))
429 {
430 typedef GstElement* (*LPgst_gconf_get_default_video_sink) (void);
431 LPgst_gconf_get_default_video_sink pGst_gconf_get_default_video_sink =
432 (LPgst_gconf_get_default_video_sink)
433 gstgconf.GetSymbol(wxT("gst_gconf_get_default_video_sink"));
434
435 if (pGst_gconf_get_default_video_sink)
436 {
437 videosink = (*pGst_gconf_get_default_video_sink) ();
438 wxASSERT( GST_IS_BIN(videosink) );
439 overlay = gst_bin_get_by_interface (GST_BIN (videosink),
440 GST_TYPE_X_OVERLAY);
441 }
442
443 gstgconf.Detach();
444 }
445
446 if ( ! GST_IS_X_OVERLAY(overlay) )
447 {
448 #endif
449 videosink = gst_element_factory_make ("xvimagesink", "videosink");
450 if ( !GST_IS_OBJECT(videosink) )
451 videosink = gst_element_factory_make ("ximagesink", "videosink");
452
453 overlay = videosink;
454
455 wxASSERT( GST_IS_X_OVERLAY(overlay) );
456 if ( ! GST_IS_X_OVERLAY(overlay) )
457 return false;
458 #if defined(__WXGTK__) && wxUSE_DYNLIB_CLASS
459 }
460 #endif
461
462 g_object_set (G_OBJECT (m_player),
463 "video-sink", videosink,
464 // "audio-sink", m_audiosink,
465 NULL);
466
467 //6
468 wxString locstring = location.BuildUnescapedURI();
469 wxASSERT(gst_uri_protocol_is_valid("file"));
470 wxASSERT(gst_uri_is_valid(locstring.mb_str()));
471
472 g_object_set (G_OBJECT (m_player), "uri", (const char*)locstring.mb_str(), NULL);
473
474 //7
475 #ifdef __WXGTK__
476 if(!GTK_WIDGET_REALIZED(m_ctrl->m_wxwindow))
477 {
478 //Not realized yet - set to connect at realization time
479 gtk_signal_connect( GTK_OBJECT(m_ctrl->m_wxwindow),
480 "realize",
481 GTK_SIGNAL_FUNC(wxGStreamerMediaBackend::OnGTKRealize),
482 (gpointer) this );
483 }
484 else
485 {
486 wxYield(); //see realize callback...
487 GdkWindow *window = GTK_PIZZA(m_ctrl->m_wxwindow)->bin_window;
488 wxASSERT(window);
489 #endif
490
491
492 gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(overlay),
493 #ifdef __WXGTK__
494 GDK_WINDOW_XWINDOW( window )
495 #else
496 ctrl->GetHandle()
497 #endif
498 );
499
500 #ifdef __WXGTK__
501 } //end else block
502 #endif
503
504 //8
505
506 wxASSERT(gst_element_set_state (m_player,
507 GST_STATE_PAUSED) == GST_STATE_SUCCESS);
508
509 const GList *list = NULL;
510 g_object_get (G_OBJECT (m_player), "stream-info", &list, NULL);
511
512 for ( ; list != NULL; list = list->next)
513 {
514 GObject *info = (GObject *) list->data;
515 gint type;
516 GParamSpec *pspec;
517 GEnumValue *val;
518 GstPad *pad = NULL;
519
520 g_object_get (info, "type", &type, NULL);
521 pspec = g_object_class_find_property (
522 G_OBJECT_GET_CLASS (info), "type");
523 val = g_enum_get_value (G_PARAM_SPEC_ENUM (pspec)->enum_class, type);
524
525 if (strstr (val->value_name, "VIDEO"))
526 {
527 //Newer gstreamer 0.8+ is SUPPOSED to have "object"...
528 //but a lot of old plugins still use "pad" :)
529 pspec = g_object_class_find_property (
530 G_OBJECT_GET_CLASS (info), "object");
531
532 if (!pspec)
533 g_object_get (info, "pad", &pad, NULL);
534 else
535 g_object_get (info, "object", &pad, NULL);
536
537 pad = (GstPad *) GST_PAD_REALIZE (pad);
538 wxASSERT(pad);
539
540 if(!wxGStreamerMediaBackend::TransCapsToVideoSize(this, pad));
541 {
542 //wait for those caps to get ready
543 g_signal_connect(
544 pad,
545 "notify::caps",
546 G_CALLBACK(wxGStreamerMediaBackend::OnVideoCapsReady),
547 this);
548 }
549 }//end if video
550 else
551 {
552 m_videoSize = wxSize(0,0);
553 PostRecalcSize();
554 }
555 }//end searching through info list
556
557 m_nPausedPos = 0;
558 return true;
559 }
560
561 //---------------------------------------------------------------------------
562 // wxGStreamerMediaBackend::Play
563 //
564 // Sets the stream to a playing state
565 //---------------------------------------------------------------------------
566 bool wxGStreamerMediaBackend::Play()
567 {
568 if (gst_element_set_state (m_player, GST_STATE_PLAYING)
569 != GST_STATE_SUCCESS)
570 return false;
571 return true;
572 }
573
574 //---------------------------------------------------------------------------
575 // wxGStreamerMediaBackend::Pause
576 //
577 // Marks where we paused and pauses the stream
578 //---------------------------------------------------------------------------
579 bool wxGStreamerMediaBackend::Pause()
580 {
581 m_nPausedPos = GetPosition();
582 if (gst_element_set_state (m_player, GST_STATE_PAUSED)
583 != GST_STATE_SUCCESS)
584 return false;
585 return true;
586 }
587
588 //---------------------------------------------------------------------------
589 // wxGStreamerMediaBackend::Stop
590 //
591 // Pauses the stream and sets the position to 0
592 //---------------------------------------------------------------------------
593 bool wxGStreamerMediaBackend::Stop()
594 {
595 if (gst_element_set_state (m_player,
596 GST_STATE_PAUSED) != GST_STATE_SUCCESS)
597 return false;
598 return wxGStreamerMediaBackend::SetPosition(0);
599 }
600
601 //---------------------------------------------------------------------------
602 // wxGStreamerMediaBackend::GetState
603 //
604 // Gets the state of the stream
605 //---------------------------------------------------------------------------
606 wxMediaState wxGStreamerMediaBackend::GetState()
607 {
608 switch(GST_STATE(m_player))
609 {
610 case GST_STATE_PLAYING:
611 return wxMEDIASTATE_PLAYING;
612 case GST_STATE_PAUSED:
613 if (m_nPausedPos == 0)
614 return wxMEDIASTATE_STOPPED;
615 else
616 return wxMEDIASTATE_PAUSED;
617 default://case GST_STATE_READY:
618 return wxMEDIASTATE_STOPPED;
619 }
620 }
621
622 //---------------------------------------------------------------------------
623 // wxGStreamerMediaBackend::GetPosition
624 //
625 // If paused, returns our marked position - otherwise it queries the
626 // GStreamer playbin for the position and returns that
627 //
628 //TODO:
629 //TODO: In lue of the last big TODO, when you pause and seek gstreamer
630 //TODO: doesn't update the position sometimes, so we need to keep track of whether
631 //TODO: we have paused or not and keep track of the time after the pause
632 //TODO: and whenever the user seeks while paused
633 //TODO:
634 //---------------------------------------------------------------------------
635 wxLongLong wxGStreamerMediaBackend::GetPosition()
636 {
637 if(GetState() != wxMEDIASTATE_PLAYING)
638 return m_nPausedPos;
639 else
640 {
641 gint64 pos;
642 GstFormat fmtTime = GST_FORMAT_TIME;
643
644 if (!gst_element_query (m_player, GST_QUERY_POSITION, &fmtTime, &pos))
645 return 0;
646 return pos / GST_MSECOND ;
647 }
648 }
649
650 //---------------------------------------------------------------------------
651 // wxGStreamerMediaBackend::SetPosition
652 //
653 // Sets the position of the stream
654 // Note that GST_MSECOND is 1000000 (GStreamer uses nanoseconds - so
655 // there is 1000000 nanoseconds in a millisecond)
656 //
657 // If paused marks where we seeked to
658 //---------------------------------------------------------------------------
659 bool wxGStreamerMediaBackend::SetPosition(wxLongLong where)
660 {
661 if( gst_element_seek (m_player, (GstSeekType) (GST_SEEK_METHOD_SET |
662 GST_FORMAT_TIME | GST_SEEK_FLAG_FLUSH),
663 where.GetValue() * GST_MSECOND ) )
664 {
665 if (GetState() != wxMEDIASTATE_PLAYING)
666 m_nPausedPos = where;
667
668 return true;
669 }
670
671 return false;
672 }
673
674 //---------------------------------------------------------------------------
675 // wxGStreamerMediaBackend::GetDuration
676 //
677 // Obtains the total time of our stream
678 //---------------------------------------------------------------------------
679 wxLongLong wxGStreamerMediaBackend::GetDuration()
680 {
681 gint64 length;
682 GstFormat fmtTime = GST_FORMAT_TIME;
683
684 if(!gst_element_query(m_player, GST_QUERY_TOTAL, &fmtTime, &length))
685 return 0;
686 return length / GST_MSECOND ;
687 }
688
689 //---------------------------------------------------------------------------
690 // wxGStreamerMediaBackend::Move
691 //
692 // Called when the window is moved - GStreamer takes care of this
693 // for us so nothing is needed
694 //---------------------------------------------------------------------------
695 void wxGStreamerMediaBackend::Move(int x, int y, int w, int h)
696 {
697 }
698
699 //---------------------------------------------------------------------------
700 // wxGStreamerMediaBackend::GetVideoSize
701 //
702 // Returns our cached video size from Load/OnVideoCapsReady
703 //---------------------------------------------------------------------------
704 wxSize wxGStreamerMediaBackend::GetVideoSize() const
705 {
706 return m_videoSize;
707 }
708
709 //---------------------------------------------------------------------------
710 // wxGStreamerMediaBackend::GetPlaybackRate
711 // wxGStreamerMediaBackend::SetPlaybackRate
712 //
713 // Obtains/Sets the playback rate of the stream
714 //
715 //TODO: PlaybackRate not currently supported via playbin directly -
716 //TODO: Ronald S. Bultje noted on gstreamer-devel:
717 //TODO:
718 //TODO: Like "play at twice normal speed"? Or "play at 25 fps and 44,1 kHz"? As
719 //TODO: for the first, yes, we have elements for that, btu they"re not part of
720 //TODO: playbin. You can create a bin (with a ghost pad) containing the actual
721 //TODO: video/audiosink and the speed-changing element for this, and set that
722 //TODO: element as video-sink or audio-sink property in playbin. The
723 //TODO: audio-element is called "speed", the video-element is called "videodrop"
724 //TODO: (although that appears to be deprecated in favour of "videorate", which
725 //TODO: again cannot do this, so this may not work at all in the end). For
726 //TODO: forcing frame/samplerates, see audioscale and videorate. Audioscale is
727 //TODO: part of playbin.
728 //---------------------------------------------------------------------------
729 double wxGStreamerMediaBackend::GetPlaybackRate()
730 {
731 //not currently supported via playbin
732 return 1.0;
733 }
734
735 bool wxGStreamerMediaBackend::SetPlaybackRate(double dRate)
736 {
737 //not currently supported via playbin
738 return false;
739 }
740
741 #endif //wxUSE_GSTREAMER
742
743 //in source file that contains stuff you don't directly use
744 #include <wx/html/forcelnk.h>
745 FORCE_LINK_ME(basewxmediabackends);
746
747 #endif //wxUSE_MEDIACTRL
748
749
750
751
752