Ejemplo n.º 1
0
///////////////////////////////////////////////////////////
// virtual
bool
LLMediaImplGStreamer::
navigateTo ( const std::string urlIn )
{
	DEBUGMSG("Setting media URI: %s", urlIn.c_str());

	if (NULL == mPump
#ifdef LL_GST_SOUNDSINK
	    || NULL == mAudioSink
#endif
	    || NULL == mPlaybin)
	{
		return false;
	}

	setStatus( LLMediaBase::STATUS_NAVIGATING );

	// set URI
	g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL);
	//g_object_set (G_OBJECT (mPlaybin), "uri", "file:///tmp/movie", NULL);

	// get playbin's bus - perhaps this can/should be done in ctor
	GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
	if (!bus)
	{
		return false;
	}
	llgst_bus_add_watch (bus, bus_callback, this);
	llgst_object_unref (bus);

	// navigateTo implicitly plays, too.
	play();

	return true;
}
bool
MediaPluginGStreamer010::load()
{
	if (!mDoneInit)
		return false; // error

	setStatus(STATUS_LOADING);

	DEBUGMSG("setting up media...");

	mIsLooping = false;
	mVolume = 0.1234567; // minor hack to force an initial volume update

	// Create a pumpable main-loop for this media
	mPump = g_main_loop_new (NULL, FALSE);
	if (!mPump)
	{
		setStatus(STATUS_ERROR);
		return false; // error
	}

	// instantiate a playbin element to do the hard work
	mPlaybin = llgst_element_factory_make ("playbin", "play");
	if (!mPlaybin)
	{
		setStatus(STATUS_ERROR);
		return false; // error
	}

	// get playbin's bus
	GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
	if (!bus)
	{
		setStatus(STATUS_ERROR);
		return false; // error
	}
	mBusWatchID = llgst_bus_add_watch (bus,
					   llmediaimplgstreamer_bus_callback,
					   this);
	llgst_object_unref (bus);

	if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) {
		// instantiate a custom video sink
		mVideoSink =
			GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo"));
		if (!mVideoSink)
		{
			WARNMSG("Could not instantiate private-slvideo element.");
			// todo: cleanup.
			setStatus(STATUS_ERROR);
			return false; // error
		}

		// connect the pieces
		g_object_set(mPlaybin, "video-sink", mVideoSink, NULL);
	}

	return true;
}
Ejemplo n.º 3
0
BOOL
LLMediaImplGStreamer::
load ( const LLString& urlIn )
{
	llinfos << "Setting media URI: " << urlIn << llendl;

 	if (!mPlaybin)
 	{
		return FALSE;
	}

	// set URI
	g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL);
	//g_object_set (G_OBJECT (mPlaybin), "uri", "file:///tmp/movie", NULL);

	// get playbin's bus - perhaps this can/should be done at init()
	GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
	if (!bus)
	{
		return FALSE;
	}
	llgst_bus_add_watch (bus, my_bus_callback, this);
	llgst_object_unref (bus);

	if (true) // dummy values
	{
		const int fixedsize = 2;
		mMediaRowbytes = mMediaDepthBytes * fixedsize;
		mMediaWidth = fixedsize;
		mMediaHeight = fixedsize;
		mTextureWidth = fixedsize;
		mTextureHeight = fixedsize;
	}

	BOOL rtn = LLMediaMovieBase::load(urlIn);
	llinfos << "load returns " << int(rtn) << llendl;
	return rtn;
}
bool
MediaPluginGStreamer010::load()
{
	if (!mDoneInit)
		return false; // error

	setStatus(STATUS_LOADING);

	DEBUGMSG("setting up media...");

	mIsLooping = false;
	mVolume = 0.1234567; // minor hack to force an initial volume update

	// Create a pumpable main-loop for this media
	mPump = g_main_loop_new (NULL, FALSE);
	if (!mPump)
	{
		setStatus(STATUS_ERROR);
		return false; // error
	}

	// instantiate a playbin element to do the hard work
	mPlaybin = llgst_element_factory_make ("playbin", "play");
	if (!mPlaybin)
	{
		setStatus(STATUS_ERROR);
		return false; // error
	}

	// get playbin's bus
	GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
	if (!bus)
	{
		setStatus(STATUS_ERROR);
		return false; // error
	}
	mBusWatchID = llgst_bus_add_watch (bus,
					   llmediaimplgstreamer_bus_callback,
					   this);
	llgst_object_unref (bus);

#if 0 // not quite stable/correct yet
	// get a visualizer element (bonus feature!)
	char* vis_name = getenv("LL_GST_VIS_NAME");
	if (!vis_name ||
	    (vis_name && std::string(vis_name)!="none"))
	{
		if (vis_name)
		{
			mVisualizer = llgst_element_factory_make (vis_name, "vis");
		}
		if (!mVisualizer)
		{
			mVisualizer = llgst_element_factory_make ("libvisual_jess", "vis");
			if (!mVisualizer)
			{
				mVisualizer = llgst_element_factory_make ("goom", "vis");
				if (!mVisualizer)
				{
					mVisualizer = llgst_element_factory_make ("libvisual_lv_scope", "vis");
					if (!mVisualizer)
					{
						// That's okay, we don't NEED this.
					}
				}
			}
		}
	}
#endif

	if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) {
		// instantiate a custom video sink
		mVideoSink =
			GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo"));
		if (!mVideoSink)
		{
			WARNMSG("Could not instantiate private-slvideo element.");
			// todo: cleanup.
			setStatus(STATUS_ERROR);
			return false; // error
		}

		// connect the pieces
		g_object_set(mPlaybin, "video-sink", mVideoSink, NULL);
	}

	if (mVisualizer)
	{
		g_object_set(mPlaybin, "vis-plugin", mVisualizer, NULL);
	}

	return true;
}