Exemple #1
0
LLMediaImplExample2::LLMediaImplExample2() :
	mMediaPixels( 0 )
{
	setRequestedMediaSize( 500, 500 );
	setMediaDepth( 3 );

	mXpos = ( getMediaWidth() / 2 ) + rand() % ( getMediaWidth() / 16 ) - ( getMediaWidth() / 32 );
	mYpos = ( getMediaHeight() / 2 ) + rand() % ( getMediaHeight() / 16 ) - ( getMediaHeight() / 32 );

	srand( (unsigned int)(time( NULL )) );
}
Exemple #2
0
// Assumes we are in a block "ParcelData"
void LLParcel::packMessage(LLSD& msg)
{
	msg["local_id"] = getLocalID();
	msg["parcel_flags"] = ll_sd_from_U32(getParcelFlags());
	msg["sale_price"] = getSalePrice();
	msg["name"] = getName();
	msg["description"] = getDesc();
	msg["music_url"] = getMusicURL();
	msg["media_url"] = getMediaURL();
	msg["media_desc"] = getMediaDesc();
	msg["media_type"] = getMediaType();
	msg["media_width"] = getMediaWidth();
	msg["media_height"] = getMediaHeight();
	msg["auto_scale"] = getMediaAutoScale();
	msg["media_loop"] = getMediaLoop();
	msg["obscure_media"] = getObscureMedia();
	msg["obscure_music"] = getObscureMusic();
	msg["media_id"] = getMediaID();
	msg["group_id"] = getGroupID();
	msg["pass_price"] = mPassPrice;
	msg["pass_hours"] = mPassHours;
	msg["category"] = (U8)mCategory;
	msg["auth_buyer_id"] = mAuthBuyerID;
	msg["snapshot_id"] = mSnapshotID;
	msg["snapshot_id"] = mSnapshotID;
	msg["user_location"] = ll_sd_from_vector3(mUserLocation);
	msg["user_look_at"] = ll_sd_from_vector3(mUserLookAt);
	msg["landing_type"] = (U8)mLandingType;

}
Exemple #3
0
////////////////////////////////////////////////////////////////////////////////
// virtual
bool LLMediaImplExample2::updateMedia()
{
	if ( mMediaPixels && getStatus() == LLMediaBase::STATUS_STARTED )
	{
		static int x_inc = rand() % 5 + 2;
		static int y_inc = rand() % 5 + 2;
		int block_size = 32;

		for( int y = 0; y < block_size; ++y )
		{
			for( int x = 0; x < block_size; ++x )
			{
				int rowspan = getMediaWidth() * getMediaDepth();
				mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 0 ] = 0;
				mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 1 ] = 0;
				mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 2 ] = 0;
			};
		};

		if ( mXpos + x_inc < 0 || mXpos + x_inc >= getMediaWidth() - block_size )
			x_inc =- x_inc;

		if ( mYpos + y_inc < 0 || mYpos + y_inc >= getMediaHeight() - block_size )
			y_inc =- y_inc;

		mXpos += x_inc;
		mYpos += y_inc;

		unsigned char col_r = rand() % 0xff;
		unsigned char col_g = rand() % 0xff;
		unsigned char col_b = rand() % 0xff;

		for( int y = 0; y < block_size; ++y )
		{
			for( int x = 0; x < block_size; ++x )
			{
				int rowspan = getMediaWidth() * getMediaDepth();
				mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 0 ] = col_r;
				mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 1 ] = col_g;
				mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 2 ] = col_b;
			};
		};

		// emit an event to say that something in the media stream changed
		LLMediaEvent event( this );
		mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
	};

	// update the command (e.g. transport controls) state
	updateCommand();

	return false;
}
// Assumes we are in a block "ParcelData"
void LLParcel::packMessage(LLSD& msg)
{
	// used in the viewer, the sim uses it's own packer
	msg["local_id"] = getLocalID();
	msg["parcel_flags"] = ll_sd_from_U32(getParcelFlags());
	msg["sale_price"] = getSalePrice();
	msg["name"] = getName();
	msg["description"] = getDesc();
	msg["music_url"] = getMusicURL();
	msg["media_url"] = getMediaURL();
	msg["media_desc"] = getMediaDesc();
	msg["media_type"] = getMediaType();
	msg["media_width"] = getMediaWidth();
	msg["media_height"] = getMediaHeight();
	msg["auto_scale"] = getMediaAutoScale();
	msg["media_loop"] = getMediaLoop();
	msg["media_current_url"] = getMediaCurrentURL();
	msg["obscure_media"] = false; // OBSOLETE - no longer used
	msg["obscure_music"] = false; // OBSOLETE - no longer used
	msg["media_id"] = getMediaID();
	msg["media_allow_navigate"] = getMediaAllowNavigate();
	msg["media_prevent_camera_zoom"] = getMediaPreventCameraZoom();
	msg["media_url_timeout"] = getMediaURLTimeout();
	msg["media_url_filter_enable"] = getMediaURLFilterEnable();
	msg["media_url_filter_list"] = getMediaURLFilterList();
	msg["group_id"] = getGroupID();
	msg["pass_price"] = mPassPrice;
	msg["pass_hours"] = mPassHours;
	msg["category"] = (U8)mCategory;
	msg["auth_buyer_id"] = mAuthBuyerID;
	msg["snapshot_id"] = mSnapshotID;
	msg["user_location"] = ll_sd_from_vector3(mUserLocation);
	msg["user_look_at"] = ll_sd_from_vector3(mUserLookAt);
	msg["landing_type"] = (U8)mLandingType;
	msg["see_avs"] = (LLSD::Boolean) getSeeAVs();
	msg["group_av_sounds"] = (LLSD::Boolean) getAllowGroupAVSounds();
	msg["any_av_sounds"] = (LLSD::Boolean) getAllowAnyAVSounds();
}
///////////////////////////////////////////////////////////////////////////////
// virtual
bool LLMediaImplGStreamer::updateMedia()
{
	//LL_DEBUGS("MediaImpl") << "updating media..." << LL_ENDL;
	
	// sanity check
	if (mPump == NULL || mPlaybin == NULL)
	{
#ifdef LL_GST_REPORT_STATE_CHANGES
		LL_DEBUGS("MediaImpl") << "dead media..." << LL_ENDL;
#endif
		mState = GST_STATE_NULL;
		setStatus(LLMediaBase::STATUS_DEAD);
		return false;
	}

	if (mState == GST_STATE_VOID_PENDING || mState == GST_STATE_NULL)
		return false;

	// process next outstanding command
	switch (nextCommand())
	{
	case LLMediaBase::COMMAND_START:
		LL_DEBUGS("MediaImpl") << "COMMAND_START" << LL_ENDL;
		if (getStatus() == LLMediaBase::STATUS_PAUSED ||
		    getStatus() == LLMediaBase::STATUS_NAVIGATING ||
		    getStatus() == LLMediaBase::STATUS_STOPPED)
		{
			play();
			setStatus(LLMediaBase::STATUS_STARTED);
			clearCommand();
		}
		break;
	case LLMediaBase::COMMAND_STOP:
		LL_DEBUGS("MediaImpl") << "COMMAND_STOP" << LL_ENDL;
		stop();
		setStatus(LLMediaBase::STATUS_STOPPED);
		clearCommand();
		break;
	case LLMediaBase::COMMAND_PAUSE:
		LL_DEBUGS("MediaImpl") << "COMMAND_PAUSE" << LL_ENDL;
		if (getStatus() == LLMediaBase::STATUS_STARTED)
		{
			pause();
			setStatus(LLMediaBase::STATUS_PAUSED);
			clearCommand();
		}
		break;
	default:
		LL_INFOS("MediaImpl") << "Unknown command" << LL_ENDL;
		clearCommand();
		break;
	case LLMediaBase::COMMAND_NONE:
		break;
	}

	// deal with results
	if (g_main_context_pending(g_main_loop_get_context(mPump)))
	{
	       g_main_context_iteration(g_main_loop_get_context(mPump), FALSE);
	}

	if (mVideoSink)
	{
	        GST_OBJECT_LOCK(mVideoSink);
		if (mVideoSink->retained_frame_ready)
		{
#ifdef LL_GST_REPORT_STATE_CHANGES
			LL_DEBUGS("MediaImpl") <<"NEW FRAME " << LL_ENDL;
#endif
			if (mVideoSink->retained_frame_width != getMediaWidth() ||
			    mVideoSink->retained_frame_height != getMediaHeight())
				// *TODO: also check for change in format
			{
				// just resize containe
				int neww = mVideoSink->retained_frame_width;
				int newh = mVideoSink->retained_frame_height;
				int newd = SLVPixelFormatBytes[mVideoSink->retained_frame_format];
				if (SLV_PF_RGBX == mVideoSink->retained_frame_format)
				{
					mTextureFormatPrimary = LL_MEDIA_RGBA;
					mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
				}
				else
				{
					mTextureFormatPrimary = LL_MEDIA_BGRA;
					mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
				}
				mMediaRowbytes = neww * newd;
				LL_DEBUGS("MediaImpl")
				    << "video container resized to " <<
				    neww <<"x"<< newh << LL_ENDL;
				
				delete[] mediaData;
				mediaData = new unsigned char[mMediaRowbytes *
							      newh];
				
				GST_OBJECT_UNLOCK(mVideoSink);

				setMediaDepth(newd);
				setMediaSize(neww, newh);
				return true;
			}

			// we're gonna totally consume this frame - reset 'ready' flag
			mVideoSink->retained_frame_ready = FALSE;
			memcpy(mediaData, mVideoSink->retained_frame_data,
			       mMediaRowbytes * getMediaHeight());
			
			GST_OBJECT_UNLOCK(mVideoSink);
			LLMediaEvent event( this );
			mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
			return true;
		}
		else
		{
			// nothing to do yet.
			GST_OBJECT_UNLOCK(mVideoSink);
			return true;
		}
	}

	return true;
}
Exemple #6
0
///////////////////////////////////////////////////////////////////////////////
// virtual
bool
LLMediaImplGStreamer::
updateMedia ()
{
	DEBUGMSG("updating media...");
	
	// sanity check
	if (NULL == mPump
#ifdef LL_GST_SOUNDSINK
	    || NULL == mAudioSink
#endif
	    || NULL == mPlaybin)
	{
		DEBUGMSG("dead media...");
		return false;
	}

	// process next outstanding command
	switch (nextCommand())
	{
	case LLMediaBase::COMMAND_START:
		DEBUGMSG("COMMAND_START");
		if (getStatus() == LLMediaBase::STATUS_PAUSED ||
		    getStatus() == LLMediaBase::STATUS_NAVIGATING ||
		    getStatus() == LLMediaBase::STATUS_STOPPED)
		{
			DEBUGMSG("doing COMMAND_START");
			play();
			setStatus(LLMediaBase::STATUS_STARTED);
			clearCommand();
		}
		break;
	case LLMediaBase::COMMAND_STOP:
		DEBUGMSG("COMMAND_STOP");
		DEBUGMSG("doing COMMAND_STOP");
		stop();
		setStatus(LLMediaBase::STATUS_STOPPED);
		clearCommand();
		break;
	case LLMediaBase::COMMAND_PAUSE:
		DEBUGMSG("COMMAND_PAUSE");
		if (getStatus() == LLMediaBase::STATUS_STARTED)
		{
			DEBUGMSG("doing COMMAND_PAUSE");
			pause();
			setStatus(LLMediaBase::STATUS_PAUSED);
			clearCommand();
		}
		break;
	default:
		DEBUGMSG("COMMAND_?");
		clearCommand();
		break;
	case LLMediaBase::COMMAND_NONE:
		break;
	}

	// deal with results
	if (g_main_context_pending(g_main_loop_get_context(mPump)))
	{
	       g_main_context_iteration(g_main_loop_get_context(mPump), FALSE);
	}

	if (mVideoSink)
	{
	        GST_OBJECT_LOCK(mVideoSink);
		if (mVideoSink->retained_frame_ready)
		{
			DEBUGMSG("NEW FRAME ");
			if (mVideoSink->retained_frame_width != getMediaWidth() ||
			    mVideoSink->retained_frame_height != getMediaHeight())
				// *TODO: also check for change in format
			{
				// just resize containe
				int neww = mVideoSink->retained_frame_width;
				int newh = mVideoSink->retained_frame_height;
				int newd = SLVPixelFormatBytes[mVideoSink->retained_frame_format];
				if (SLV_PF_RGBX == mVideoSink->retained_frame_format)
				{
					mTextureFormatPrimary = LL_MEDIA_RGBA;
					mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
				}
				else
				{
					mTextureFormatPrimary = LL_MEDIA_BGRA;
					mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
				}
				mMediaRowbytes = neww * newd;
				DEBUGMSG("video container resized to %dx%d",
					 neww, newh);
				
				delete[] mediaData;
				mediaData = new unsigned char[mMediaRowbytes *
							      newh];
				
				GST_OBJECT_UNLOCK(mVideoSink);

				setMediaDepth(newd);
				setMediaSize(neww, newh);
				return true;
			}

			// we're gonna totally consume this frame - reset 'ready' flag
			mVideoSink->retained_frame_ready = FALSE;
			memcpy(mediaData, mVideoSink->retained_frame_data,
			       mMediaRowbytes * getMediaHeight());
			
			GST_OBJECT_UNLOCK(mVideoSink);
			LLMediaEvent event( this );
			mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
			return true;
		}
		else
		{
			// nothing to do yet.
			GST_OBJECT_UNLOCK(mVideoSink);
			return true;
		}
	}

	return true;
}
////////////////////////////////////////////////////////////////////////////////
// virtual
bool LLMediaImplExample1::updateMedia()
{
    if ( mMediaPixels && getStatus() == LLMediaBase::STATUS_STARTED )
    {
        // first time - make sure it's a few seconds back so first update happens immediately
        static time_t t = time( 0 ) - 4;

        // selected time period elapsed (1 second)
        if ( time( 0 ) - t > 1 )
        {
            // display checkerboard
            const int num_squares = rand() % 20 + 4;
            int sqr1_r = rand() % 0x80;
            int sqr1_g = rand() % 0x80;
            int sqr1_b = rand() % 0x80;
            int sqr2_r = rand() % 0x80;
            int sqr2_g = rand() % 0x80;
            int sqr2_b = rand() % 0x80;

            for ( int y1 = 0; y1 < num_squares; ++y1 )
            {
                for ( int x1 = 0; x1 < num_squares; ++x1 )
                {
                    int px_start = getMediaWidth() * x1 / num_squares;
                    int px_end = ( getMediaWidth() * ( x1 + 1 ) ) / num_squares;
                    int py_start = getMediaHeight() * y1 / num_squares;
                    int py_end = ( getMediaHeight() * ( y1 + 1 ) ) / num_squares;

                    for( int y2 = py_start; y2 < py_end; ++y2 )
                    {
                        for( int x2 = px_start; x2 < px_end; ++x2 )
                        {
                            int rowspan = getMediaWidth() * getMediaDepth();

                            if ( ( y1 % 2 ) ^ ( x1 % 2 ) )
                            {
                                mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 0 ] = sqr1_r;
                                mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 1 ] = sqr1_g;
                                mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 2 ] = sqr1_b;
                            }
                            else
                            {
                                mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 0 ] = sqr2_r;
                                mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 1 ] = sqr2_g;
                                mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 2 ] = sqr2_b;
                            };
                        };
                    };
                };
            };

            // emit an event to say that something in the media stream changed
            LLMediaEvent event( this );
            mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );

            // reset time
            t = time( 0 );

            return true;
        };
    };

    // update the command (e.g. transport controls) state
    updateCommand();

    return false;
}
////////////////////////////////////////////////////////////////////////////////
// virtual (derives from LLMediaBase)
int LLMediaImplCommon::getMediaDataHeight() const
{
	return getMediaHeight();
}