aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia/llmediaimplgstreamer.cpp
diff options
context:
space:
mode:
authorMcCabe Maxsted2009-02-18 04:07:28 -0700
committerMcCabe Maxsted2009-02-18 04:07:28 -0700
commitd3415294494f0f640f41560e035add0befb25259 (patch)
tree722f3ad2631eb35a7296efa39ba4b3d969fcf42c /linden/indra/llmedia/llmediaimplgstreamer.cpp
parentFixed some bad comment formatting (diff)
downloadmeta-impy-d3415294494f0f640f41560e035add0befb25259.zip
meta-impy-d3415294494f0f640f41560e035add0befb25259.tar.gz
meta-impy-d3415294494f0f640f41560e035add0befb25259.tar.bz2
meta-impy-d3415294494f0f640f41560e035add0befb25259.tar.xz
Added error checking to play/stop/pause to prevent bad looping
Diffstat (limited to 'linden/indra/llmedia/llmediaimplgstreamer.cpp')
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp64
1 files changed, 39 insertions, 25 deletions
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp
index bae8ad9..d821bcd 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp
@@ -36,6 +36,7 @@
36 36
37extern "C" { 37extern "C" {
38#include <gst/gst.h> 38#include <gst/gst.h>
39#include <gst/gstelement.h>
39} 40}
40 41
41#include "llmediamanager.h" 42#include "llmediamanager.h"
@@ -93,22 +94,6 @@ LLMediaImplGStreamer () :
93 // todo: cleanup pump 94 // todo: cleanup pump
94 return; // error 95 return; // error
95 } 96 }
96
97 if (NULL == getenv("LL_GSTREAMER_EXTERNAL"))
98 {
99 // instantiate and connect a custom video sink
100 LL_DEBUGS("MediaManager") << "extrenal video sink..." << LL_ENDL;
101 mVideoSink =
102 GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo"));
103 if (!mVideoSink)
104 {
105 LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL;
106 // todo: cleanup.
107 return; // error
108 }
109
110 g_object_set(mPlaybin, "video-sink", mVideoSink, NULL);
111 }
112} 97}
113 98
114// virtual 99// virtual
@@ -394,7 +379,6 @@ bool LLMediaImplGStreamer::navigateTo (const std::string urlIn)
394 379
395 // set URI 380 // set URI
396 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL); 381 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL);
397 //g_object_set (G_OBJECT (mPlaybin), "uri", "file:///tmp/movie", NULL);
398 382
399 // get playbin's bus - perhaps this can/should be done in ctor 383 // get playbin's bus - perhaps this can/should be done in ctor
400 GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin)); 384 GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
@@ -567,10 +551,19 @@ bool LLMediaImplGStreamer::updateMedia()
567// 551//
568bool LLMediaImplGStreamer::stop() 552bool LLMediaImplGStreamer::stop()
569{ 553{
570 LL_DEBUGS("MediaImpl") << "stopping media..." << LL_ENDL; 554 LL_DEBUGS("MediaImpl") << "attempting to stop..." << LL_ENDL;
571 // todo: error-check this? 555
572 llgst_element_set_state(mPlaybin, GST_STATE_READY); 556 if (!mPlaybin) return true;
557
558 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin));
559 llgst_object_unref(pipeline);
560
561 llgst_element_set_state(pipeline, GST_STATE_READY);
573 mState = GST_STATE_READY; 562 mState = GST_STATE_READY;
563
564 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
565 LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL;
566
574 return true; 567 return true;
575} 568}
576 569
@@ -578,10 +571,25 @@ bool LLMediaImplGStreamer::stop()
578// 571//
579bool LLMediaImplGStreamer::play() 572bool LLMediaImplGStreamer::play()
580{ 573{
581 LL_DEBUGS("MediaImpl") << "playing media..." << LL_ENDL; 574 LL_DEBUGS("MediaImpl") << "attempting to play..." << LL_ENDL;
582 // todo: error-check this? 575
583 llgst_element_set_state(mPlaybin, GST_STATE_PLAYING); 576 if (!mPlaybin) return true;
577
578 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin));
579 llgst_object_unref(pipeline);
580
581 llgst_element_set_state(pipeline, GST_STATE_PLAYING);
584 mState = GST_STATE_PLAYING; 582 mState = GST_STATE_PLAYING;
583 /*llgst_element_set_state(mPlaybin, GST_STATE_PLAYING);
584 mState = GST_STATE_PLAYING;*/
585
586 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
587 LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL;
588
589 // Check to make sure playing was successful. If not, stop.
590 if (state_change == GST_STATE_CHANGE_FAILURE)
591 stop();
592
585 return true; 593 return true;
586} 594}
587 595
@@ -589,10 +597,16 @@ bool LLMediaImplGStreamer::play()
589// 597//
590bool LLMediaImplGStreamer::pause() 598bool LLMediaImplGStreamer::pause()
591{ 599{
592 LL_DEBUGS("MediaImpl") <<"pausing media..." << LL_ENDL; 600 LL_DEBUGS("MediaImpl") << "attempting to pause..." << LL_ENDL;
593 // todo: error-check this? 601
602 if (!mPlaybin) return true;
603
594 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED); 604 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED);
595 mState = GST_STATE_PAUSED; 605 mState = GST_STATE_PAUSED;
606
607 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
608 LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL;
609
596 return true; 610 return true;
597}; 611};
598 612