[xiph-commits] r8800 - trunk/oggdsf/src/lib/player/libDSPlayDotNET

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Fri Jan 28 06:11:48 PST 2005


Author: illiminable
Date: 2005-01-28 06:11:34 -0800 (Fri, 28 Jan 2005)
New Revision: 8800

Modified:
   trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.cpp
   trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.h
Log:
* Update dsplay to do frame advancing.

Modified: trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.cpp
===================================================================
--- trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.cpp	2005-01-28 07:43:34 UTC (rev 8799)
+++ trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.cpp	2005-01-28 14:11:34 UTC (rev 8800)
@@ -61,14 +61,20 @@
 	,	mCMMLAppControl(NULL)
 	,	mWindowHandle(NULL)
 	,	mVideoWindow(NULL)
+	,	mVideoRenderFilter(NULL)
 	,	mVMR7Window(NULL)
 	,	mVMR9Window(NULL)
+	,	mVideoFrameStep(NULL)
 	,	mLeft(0)
 	,	mTop(0)
 	,	mWidth(0)
 	,	mHeight(0)
 	,	mFileSize(0)
 	,	mVideoRenderType(VR_NONE)
+
+	,	mAvgTimePerFrame(0)
+	,	mVideoWidth(0)
+	,	mVideoHeight(0)
 	
 
 
@@ -85,20 +91,27 @@
 	,	mMediaControl(NULL)
 	,	mMediaSeeking(NULL)
 	,	mMediaEvent(NULL)
+	,	mBasicAudio(NULL)
 	,	mEventHandle(INVALID_HANDLE_VALUE)
 	//,	mDNCMMLCallbacks(NULL)
 	,	mDNMediaEvent(NULL)
 	,	mCMMLAppControl(NULL)
 	,	mWindowHandle(inWindowHandle)
 	,	mVideoWindow(NULL)
+	,	mVideoRenderFilter(NULL)
 	,	mVMR7Window(NULL)
 	,	mVMR9Window(NULL)
+	,	mVideoFrameStep(NULL)
 	,	mLeft(inLeft)
 	,	mTop(inTop)
 	,	mWidth(inWidth)
 	,	mHeight(inHeight)
 	,	mFileSize(0)
 	,	mVideoRenderType(VR_NONE)
+
+	,	mAvgTimePerFrame(0)
+	,	mVideoWidth(0)
+	,	mVideoHeight(0)
 {
 	CoInitialize(NULL);
 	mCMMLProxy = new CMMLCallbackProxy;			//Need to delete this !
@@ -248,8 +261,15 @@
 		mCMMLAppControl = NULL;
 	}
 
+	if(mVideoRenderFilter != NULL) {
+		numRef =
+            mVideoRenderFilter->Release();
 
+		*debugLog<<"Video Render Filter count = "<<numRef<<endl;
+		mVideoRenderFilter = NULL;
+	}
 
+
 	if (mVideoWindow != NULL) {
 		numRef =
             mVideoWindow->Release();
@@ -258,6 +278,14 @@
 		mVideoWindow = NULL;
 	}
 
+	if (mVideoFrameStep != NULL) {
+		numRef =
+            mVideoFrameStep->Release();
+
+		*debugLog<<"Video Frame Step count = "<<numRef<<endl;
+		mVideoFrameStep = NULL;
+	}
+
 	if (mVMR9Window != NULL) {
 		numRef =
             mVMR9Window->Release();
@@ -290,6 +318,65 @@
 	//TODO::: Release everything !
 }
 
+void DSPlay::GetVideoInformation() {
+	//Check there's even a video renderer.
+	if (mVideoRenderFilter != NULL) {
+		//Get an enumerator for the pins
+		IEnumPins* locEnumPins = NULL;
+		HRESULT locHR = mVideoRenderFilter->EnumPins(&locEnumPins);
+		if (locHR == S_OK) {
+			//Get the first pin
+			IPin* locPin = NULL;
+			ULONG locHowMany = 0;
+			locHR = locEnumPins->Next(1, &locPin, &locHowMany);
+			if (locHR == S_OK) {
+				//Get the media type for the connection
+				AM_MEDIA_TYPE locMediaType;
+				locHR = locPin->ConnectionMediaType(&locMediaType);
+				if (locHR == S_OK) {
+					//Make sure it's video
+					if (locMediaType.formattype == FORMAT_VideoInfo) {
+						VIDEOINFOHEADER* locVideoInfo = (VIDEOINFOHEADER*)locMediaType.pbFormat;
+
+						//Get the info we need
+						mAvgTimePerFrame = locVideoInfo->AvgTimePerFrame;
+						mVideoWidth = locVideoInfo->bmiHeader.biWidth;
+						mVideoHeight = locVideoInfo->bmiHeader.biHeight;
+
+					}
+
+					//Free the format block
+					if ((locMediaType.cbFormat != 0) && (locMediaType.pbFormat != NULL)) {
+						CoTaskMemFree(locMediaType.pbFormat);
+					}
+
+					locPin->Release();
+					locEnumPins->Release();
+					return;
+
+				} else {
+					//Failed to get media type or not conencted
+					locPin->Release();
+					locEnumPins->Release();
+					
+				}
+			} else {
+				//Failed to get pin
+				locEnumPins->Release();
+			}
+		} else {
+			//Failed to get enumerator
+		}
+	} else {
+		//There is no video renderer
+	}
+
+	mAvgTimePerFrame = 0;
+	mVideoWidth = 0;
+	mVideoHeight = 0;
+
+}
+
 bool DSPlay::loadFile(String* inFileName) {
 
 	//Debugging only
@@ -385,9 +472,10 @@
 
 		}
 		
-		numRef =
-			locVMR9->Release();
-		*debugLog<<"VMR9 ref count = "<<numRef<<endl;
+		//numRef =
+		//	locVMR9->Release();
+		//*debugLog<<"VMR9 ref count = "<<numRef<<endl;
+		mVideoRenderFilter = locVMR9;
 	}
 
 	if (mVideoRenderType == VR_NONE) {
@@ -419,9 +507,11 @@
 
 			}
 			
-			numRef =
-				locVMR7->Release();
-			*debugLog<<"VMR7 ref count = "<<numRef<<endl;
+			//numRef =
+			//	locVMR7->Release();
+			//*debugLog<<"VMR7 ref count = "<<numRef<<endl;
+
+			mVideoRenderFilter = locVMR7;
 		}
 	}
 
@@ -495,6 +585,9 @@
 		return false;
 	}
 
+	//CHANGES::: Use this to get information about the video, once it's been rendered.
+	GetVideoInformation();
+
 	*debugLog<<"Render must have been ok"<<endl;
 	if (isFileAnnodex(inFileName)) {
 		*debugLog<<"Is annodex"<<endl;
@@ -557,8 +650,17 @@
 		mBasicAudio = NULL;
 	}
 
+	//Get the IVideFrameStep if ity exists
+	IVideoFrameStep* locVideoStep = NULL;
+	locHR = mGraphBuilder->QueryInterface(IID_IVideoFrameStep, (void**)&locVideoStep);
+	if (locHR == S_OK) {
+		mVideoFrameStep = locVideoStep;
+	} else {
+		mVideoFrameStep = NULL;
+	}
 
 
+
 //	if (FAILED(hr))
 
 	return true;
@@ -681,6 +783,26 @@
 	
 }
 
+bool DSPlay::canStepFrame() {
+	if (mVideoFrameStep != NULL) {
+		HRESULT locHR = mVideoFrameStep->CanStep(0, NULL);
+		if (locHR == S_OK) {
+			return true;
+		}
+	}
+	return false;
+}
+
+bool DSPlay::stepFrame() {
+	if (mVideoFrameStep != NULL) {
+		HRESULT locHR = mVideoFrameStep->Step(1, NULL);
+		if (locHR == S_OK) {
+			return true;
+		}
+	}
+	return false;
+}
+
 Int64 DSPlay::seekStart() {
 	return seek(0);
 }
@@ -730,5 +852,33 @@
 }
 
 
+		/// Gets the average time per frame in ds units. Returns 0 if unknown or no video.
+Int64 DSPlay::averageTimePerFrame() {
+	return mAvgTimePerFrame;
+}
+
+		/// Gets the average frame rate in fps*100 (ie 29.97 fps = 2997)
+Int64 DSPlay::averageFrameRate() {
+
+	if (mAvgTimePerFrame != 0) {
+		Int64 locFrameRate = (10000000 * 100);
+		locFrameRate /= mAvgTimePerFrame;
+		return locFrameRate;
+	} else {
+		return 0;
+	}
+}
+
+		/// Gets the width of the video data. Not necessarily the same as the display size.
+Int32 DSPlay::videoWidth() {
+	return mVideoWidth;
+}
+
+		/// Gets the height of the video data. Not necessarily the same as the display size.
+Int32 DSPlay::videoHeight() {
+	return mVideoHeight;
+}
+
+
 } //end namespace libDSPlayDotNET
 } //end namespace illiminable

Modified: trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.h
===================================================================
--- trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.h	2005-01-28 07:43:34 UTC (rev 8799)
+++ trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.h	2005-01-28 14:11:34 UTC (rev 8800)
@@ -105,6 +105,24 @@
 		///Sets the current balance (-10,000 to 10,000)
 		bool setBalance(long inBalance);
 
+		/// Gets the average time per frame in ds units. Returns 0 if unknown or no video.
+		Int64 averageTimePerFrame();
+
+		/// Gets the average frame rate in fps*100 (ie 29.97 fps = 2997)
+		Int64 averageFrameRate();
+
+		/// Gets the width of the video data. Not necessarily the same as the display size.
+		Int32 videoWidth();
+
+		/// Gets the height of the video data. Not necessarily the same as the display size.
+		Int32 videoHeight();
+
+		/// Steps forward a single video frame. Check canStepFrame() to see if this is possible
+		bool stepFrame();
+
+		/// Checks if the graph can step forward frame by frame.
+		bool canStepFrame();
+
 		/// Seek to the specified time in 100 nanoseconds units. ie 10 000 000 per second.
 		Int64 seek(Int64 inTime);
 
@@ -143,6 +161,9 @@
 		void releaseInterfaces();
 
 	protected:
+
+		/// Internal method to get video information from the video renderer.
+		void GetVideoInformation();
 		//static wstring toWStr(std::string inString);
 		IGraphBuilder* mGraphBuilder;
 		IMediaControl* mMediaControl;
@@ -151,6 +172,8 @@
 		IBasicAudio* mBasicAudio;
 		ICMMLAppControl* mCMMLAppControl;
 		IVideoWindow* mVideoWindow;
+		IBaseFilter* mVideoRenderFilter;
+		IVideoFrameStep* mVideoFrameStep;
 
 		IVMRWindowlessControl* mVMR7Window;
 		IVMRWindowlessControl9* mVMR9Window;
@@ -181,7 +204,12 @@
 		eVideoRenderer mVideoRenderType;
 
 		fstream* debugLog;
+
+		__int64 mAvgTimePerFrame;
+		int mVideoWidth;
+		int mVideoHeight;
 		
+		
 
 	};
 }



More information about the commits mailing list