Game Development Community

How to play a video stream on a Gui Control Window?

by Ryan Santos · in Torque 3D Professional · 10/25/2010 (3:46 am) · 6 replies

Anyone got any ideas how I can play a streaming video in a 2D window that pops up on top of the 3D display? I already have an existing implementation in VMR9 that paints a video if given a win32 HWND. How can I port this over to run from within torque?

#1
10/25/2010 (4:39 am)
T3D already has a video media stream player for OGG type videos. Theora I believe is the name. Why not just use that?
#2
10/25/2010 (4:40 am)
Just push a gui ontop of the current one that has a theora control and play the movie in the theora control. When your done stop the movie and unload it then pop the gui that you placed ontop of the one behind it. That sounds like the effect you are asking for.
#3
10/25/2010 (5:17 am)
Does it support video streaming from a url? I want to display a video from an axis security camera (www.axis.com/). This functionality is already supported in VMR9 as long as the axis dlls are installed or the correct codec is installed.

What you described is exactly the same effect that I want but I need to it to be able to play from a video stream as well.
#4
10/25/2010 (5:20 am)
A sample url is axrtpm://<ipaddress>/mpeg4/media.amp where <ipaddress> is the IP address of the security camera from within the network.
#5
10/25/2010 (8:23 am)
The demo in this thread www.torquepowered.com/community/forums/viewthread/109739 gave me an idea. Maybe I can display a webpage instead and the webpage had an embedded live video?
#6
11/30/2010 (8:48 am)
Just an update, I used torque to pop a child window then hid that window. Then I used ISampleGrabber from qedit.h to grab frames from VMR which I then manipulated before having it rendered

long nBufferSize = 0;
		long *pBuffer = mpVmr->GetBuffer( nBufferSize );
		if( pBuffer != 0 &&
			mpVmr->GetVideoInfo() != 0 )
		{
			U32 width = mpVmr->GetVideoInfo()->bmiHeader.biWidth;
			U32 height = mpVmr->GetVideoInfo()->bmiHeader.biHeight;

			GBitmap bitmap(width, height, false, GFXFormatR8G8B8);

			U32 srcIndex = 0, dstIndex = 0;
			U8 bytesPerPixel = bitmap.getBytesPerPixel();
			U8 *srcData = (U8*)pBuffer;
			U8 *tempData = new U8[(width + (width * height)) * bytesPerPixel];
			for (U32 x = 0; x < width; x++)
			{
				for (U32 y = 0; y < height; y++)
				{
					srcIndex = (x + (y * width)) * bytesPerPixel;
					/// Color correction
					Swap<U8>(srcData[srcIndex], srcData[srcIndex+bytesPerPixel-1]);
					/// Location correction
					dstIndex = (x + ((height - y) * width)) * bytesPerPixel;
					tempData[dstIndex]				= srcData[srcIndex];
					tempData[dstIndex+1]			= srcData[srcIndex+1];
					tempData[dstIndex+2]			= srcData[srcIndex+2];
				}
			}

			U8 *dst = bitmap.getWritableBits();
			/// Do memcpy only once
			dMemcpy(dst, tempData, width * height * bitmap.getBytesPerPixel());

			MutexHandle handle;
			handle.lock( mpTextureLock );
			mTexHandle.set(static_cast<GBitmap*>(&bitmap),
						static_cast<GFXTextureProfile*>(&GFXDefaultGUIProfile),
						false, 
						avar(""));

			srcData = 0;
			mpVmr->DeleteBuffer( pBuffer );
			delete [] tempData;
		}