aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia/llmediaimplgstreamer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmedia/llmediaimplgstreamer.cpp')
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp
index 271bb5e..7ae6b02 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp
@@ -39,6 +39,7 @@
39 #pragma warning(disable : 4244) 39 #pragma warning(disable : 4244)
40#endif 40#endif
41 41
42#include "linden_common.h"
42#include "llmediaimplgstreamer.h" 43#include "llmediaimplgstreamer.h"
43 44
44extern "C" { 45extern "C" {
@@ -56,9 +57,8 @@ extern "C" {
56#include "llmediaimplregister.h" 57#include "llmediaimplregister.h"
57 58
58#include "llmediaimplgstreamervidplug.h" 59#include "llmediaimplgstreamervidplug.h"
60#include "llgstplaythread.h"
59 61
60#include "llerror.h"
61#include "linden_common.h"
62 62
63// register this impl with media manager factory 63// register this impl with media manager factory
64static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() ); 64static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() );
@@ -85,7 +85,8 @@ LLMediaImplGStreamer () :
85 mPump ( NULL ), 85 mPump ( NULL ),
86 mPlaybin ( NULL ), 86 mPlaybin ( NULL ),
87 mVideoSink ( NULL ), 87 mVideoSink ( NULL ),
88 mState( GST_STATE_NULL ) 88 mState( GST_STATE_NULL ),
89 mPlayThread ( NULL )
89{ 90{
90 startup( NULL ); // Startup gstreamer if it hasn't been already. 91 startup( NULL ); // Startup gstreamer if it hasn't been already.
91 92
@@ -737,6 +738,30 @@ bool LLMediaImplGStreamer::play()
737 if (!mPlaybin || mState == GST_STATE_NULL) 738 if (!mPlaybin || mState == GST_STATE_NULL)
738 return true; 739 return true;
739 740
741 // Clean up the existing thread, if any.
742 if( mPlayThread != NULL && mPlayThread->isStopped())
743 {
744 delete mPlayThread;
745 mPlayThread = NULL;
746 }
747
748 if( mPlayThread == NULL )
749 {
750 // Make a new thread to start playing. This keeps the viewer
751 // responsive while the stream is resolved and buffered.
752 mPlayThread = new LLGstPlayThread( (LLMediaImplCommon *)this, "GstPlayThread", NULL);
753 mPlayThread->start();
754 }
755
756 return true;
757}
758
759
760void LLMediaImplGStreamer::startPlay()
761{
762 GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin));
763 gst_object_unref(pipeline);
764
740 GstStateChangeReturn state_change; 765 GstStateChangeReturn state_change;
741 766
742 state_change = gst_element_set_state(mPlaybin, GST_STATE_PLAYING); 767 state_change = gst_element_set_state(mPlaybin, GST_STATE_PLAYING);
@@ -753,11 +778,6 @@ bool LLMediaImplGStreamer::play()
753 // We also force a stop in case the operations don't sync 778 // We also force a stop in case the operations don't sync
754 setStatus(LLMediaBase::STATUS_UNKNOWN); 779 setStatus(LLMediaBase::STATUS_UNKNOWN);
755 stop(); 780 stop();
756 return false;
757 }
758 else
759 {
760 return true;
761 } 781 }
762} 782}
763 783