[xiph-commits] r7984 - in trunk/oggdsf/src: lib/codecs/cmml/libCMMLTagsDotNET tools/DNPlay

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Tue Oct 12 03:15:37 PDT 2004


Author: illiminable
Date: 2004-10-12 03:15:37 -0700 (Tue, 12 Oct 2004)
New Revision: 7984

Modified:
   trunk/oggdsf/src/lib/codecs/cmml/libCMMLTagsDotNET/HeadTag.cpp
   trunk/oggdsf/src/tools/DNPlay/frmDNPlay.cs
   trunk/oggdsf/src/tools/DNPlay/frmDNPlay.resx
Log:
* Fixed a bug in the .NET CMML tag wrappers whereby if the inner native class is NULL, the wrapper creates a non-null object wrapper around a NULL object, so the .NET class is not NULL, yet any attempt to call methods will try to dereference the internal NULL pointer.
* DNPlay can now properly follow annodex links. Calculates base URI's from the Base tag's href field, if this is not present the base URI is that of the current file.

Modified: trunk/oggdsf/src/lib/codecs/cmml/libCMMLTagsDotNET/HeadTag.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/cmml/libCMMLTagsDotNET/HeadTag.cpp	2004-10-12 04:49:56 UTC (rev 7983)
+++ trunk/oggdsf/src/lib/codecs/cmml/libCMMLTagsDotNET/HeadTag.cpp	2004-10-12 10:15:37 UTC (rev 7984)
@@ -62,7 +62,11 @@
 		return new TitleTag(getMe()->title()->clone());
 	}
 	BaseTag* HeadTag::base() {
-		return new BaseTag(getMe()->base()->clone());
+		if (getMe()->base() != NULL) {
+			return new BaseTag(getMe()->base()->clone());
+		} else {
+			return NULL;
+		}
 	}
 	MetaTagList* HeadTag::metaList() {
 		return new MetaTagList(getMe()->metaList()->clone());

Modified: trunk/oggdsf/src/tools/DNPlay/frmDNPlay.cs
===================================================================
--- trunk/oggdsf/src/tools/DNPlay/frmDNPlay.cs	2004-10-12 04:49:56 UTC (rev 7983)
+++ trunk/oggdsf/src/tools/DNPlay/frmDNPlay.cs	2004-10-12 10:15:37 UTC (rev 7984)
@@ -45,7 +45,11 @@
 		private System.Windows.Forms.Button cmdFollowLink;
 		private System.Windows.Forms.Label lblAnchorLink;
 		private System.Windows.Forms.Label lblTitle;
+		private System.Windows.Forms.Label label1;
 		protected HeadTag mHeadTag;
+		private Int64 evCount;
+		private Uri mBaseURI; 
+		private String mFileName;
 
 		enum eEventCodes 
 		{
@@ -103,6 +107,8 @@
 		}
 		public bool eventNotification(Int32 inEventCode, Int32 inParam1, Int32 inParam2) 
 		{
+			evCount++;
+			label1.Text = evCount.ToString();
 			if (inEventCode == (long)eEventCodes.EC_COMPLETE) 
 			{
 				tmrUpdateDuration.Enabled = false;
@@ -121,8 +127,39 @@
 		}
 		public bool headCallback(HeadTag inHeadTag) 
 		{
+			MessageBox.Show("Head callback");
 			mHeadTag = inHeadTag;
+			if (mHeadTag != null) 
+			{
+				MessageBox.Show("Head tag not null");
+			}
+			else 
+			{
+				MessageBox.Show("Head tag is null");
+			}
 			lblTitle.Text = mHeadTag.title().text();
+			MessageBox.Show(mHeadTag.title().text());
+			Uri locBaseURI = null;
+			try 
+			{
+				if (mHeadTag. at base() != null) 
+				{
+					MessageBox.Show("Href = "+mHeadTag. at base().href());
+					locBaseURI = new Uri(mHeadTag. at base().href());
+				}
+			} 
+			catch(System.UriFormatException) 
+			{
+				locBaseURI = null;	
+					
+			}
+
+			if (locBaseURI != null) 
+			{
+				mBaseURI = locBaseURI;
+			}
+		
+			MessageBox.Show("Bug not here !!");
 			return true;
 		}
 		//
@@ -142,6 +179,8 @@
 			cmdStop.Enabled = false;
 			cmdPlay.Enabled = false;
 			cmdPause.Enabled = false;
+
+			evCount = 0;
 		}
 
 		/// <summary>
@@ -189,6 +228,7 @@
 			this.cmdFollowLink = new System.Windows.Forms.Button();
 			this.lblAnchorLink = new System.Windows.Forms.Label();
 			this.lblTitle = new System.Windows.Forms.Label();
+			this.label1 = new System.Windows.Forms.Label();
 			this.SuspendLayout();
 			// 
 			// mainMenu1
@@ -354,10 +394,19 @@
 			this.lblTitle.Size = new System.Drawing.Size(400, 16);
 			this.lblTitle.TabIndex = 13;
 			// 
+			// label1
+			// 
+			this.label1.Location = new System.Drawing.Point(8, 264);
+			this.label1.Name = "label1";
+			this.label1.Size = new System.Drawing.Size(112, 32);
+			this.label1.TabIndex = 14;
+			this.label1.Text = "label1";
+			// 
 			// frmDNPlay
 			// 
 			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
 			this.ClientSize = new System.Drawing.Size(416, 295);
+			this.Controls.Add(this.label1);
 			this.Controls.Add(this.lblTitle);
 			this.Controls.Add(this.lblAnchorLink);
 			this.Controls.Add(this.cmdFollowLink);
@@ -420,11 +469,19 @@
 		private void LoadFile(String inFileName) 
 		{
 			tmrUpdateDuration.Enabled = false;
-			lblFileLocation.Text = inFileName;
+
 			bool locRes = mPlayer.loadFile(inFileName);
 
 			if (locRes) 
 			{
+				mFileName = inFileName;
+				lblFileLocation.Text = inFileName;
+
+				
+				//Set the base URI from the current file.
+				setBaseURIFromFullPath(inFileName);
+					
+				
 				//Error check
 				mFileDuration = mPlayer.fileDuration();
 				setDurationText(mFileDuration);
@@ -440,7 +497,7 @@
 			} 
 			else 
 			{
-				MessageBox.Show("Failed!");
+				MessageBox.Show("File type is unrecognised, or media file does not exist", "Media Open Failed.", MessageBoxButtons.OK, MessageBoxIcon.Stop);
 			
 			}
 		}
@@ -544,13 +601,116 @@
 			}
 		}
 
+		private bool setBaseURIFromFullPath(String inFullPath) 
+		{
+			MessageBox.Show(inFullPath);
+			Uri locURI = null;
+			Uri locBaseURI = null;
+			try 
+			{
+				//Turn the full path into a URI
+				locURI = new Uri(inFullPath);
+			}
+			catch (System.UriFormatException) 
+			{
+				//This is not a URI !
+				locURI = null;
+			}
+
+			if (locURI != null) 
+			{
+				MessageBox.Show(locURI.ToString());
+				MessageBox.Show(locURI.GetLeftPart(UriPartial.Authority));
+				String locPartial = locURI.GetLeftPart(UriPartial.Authority);
+
+				if (locPartial.Equals("")) 
+				{
+
+					//Must be a file with a : 'd path in it
+					locPartial = locURI.GetLeftPart(UriPartial.Path);
+
+					//Find out where the lat slash is
+					int locDelimPos = locPartial.LastIndexOf("/");
+					if (locDelimPos != -1) 
+					{
+						//Strip off the filename part at the end
+						locPartial = locPartial.Substring(0, locDelimPos + 1);
+						MessageBox.Show("Parital : " + locPartial);
+					} 
+					else 
+					{
+						locPartial = "";
+					}
+				}
+				//Get the URI base which excludes the filename part.
+				
+				if (!locPartial.Equals("")) 
+				{
+					locBaseURI = new Uri(locPartial);
+					MessageBox.Show(locBaseURI.ToString());
+				}
+				
+			} 
+
+			mBaseURI = locBaseURI;
+
+			return (locBaseURI != null);
+
+
+		}
 		private void cmdFollowLink_Click(object sender, System.EventArgs e)
 		{
+			
+			if (mBaseURI != null) 
+			{
+				//Try to do relative to the base URI
+				Uri locURI = null;
+				try 
+				{
+					MessageBox.Show("Base is "+mBaseURI.ToString());
+					//try and make a URI using the base and the href from the clip (relative)
+					locURI = new Uri(mBaseURI, mCurrentClip.anchor().href());	
+					MessageBox.Show("New URI is "+locURI.ToString());
+				} 
+				catch(System.UriFormatException) 
+				{
+					try 
+					{
+						//If that failed, try to make one with just the clip tag (absolute)
+						locURI = new Uri(mCurrentClip.anchor().href());
+					}
+					catch (System.UriFormatException) 
+					{
+						locURI = null;
+						
 
-			String locFilename = "G:\\downloads\\firefox\\manufacturing_surveys.anx"; //mCurrentClip.anchor().href();
-			LoadFile(locFilename);
-			StartPlayback();
+					}
+				}
+
+				if (locURI == null) 
+				{
+					MessageBox.Show("The link is an invalid URI", "Invalid URI", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+				} 
+				else
+				{
+					MessageBox.Show("Opening "+locURI.ToString());
+					if (locURI.IsFile) 
+					{
+						//If it's a file change it to a local path.
+						LoadFile(locURI.LocalPath);
+						StartPlayback();
+
+					} 
+					else 
+					{
+						//Otherwise just load the URI
+						LoadFile(locURI.ToString());
+						StartPlayback();
+					}
+				}
+			} 
 			
+			
 //			tmrUpdateDuration.Enabled = false;
 //			lblFileLocation.Text = locFilename;
 //			bool locRes = mPlayer.loadFile("G:\\downloads\\firefox\\manufacturing_surveys.anx");
@@ -576,8 +736,9 @@
 			if (locOpenDialog.wasOK) 
 			{
 				LoadFile(locOpenDialog.URLToOpen);
-				StartPlayback();
 				
+				
+				
 			}
 		}
 

Modified: trunk/oggdsf/src/tools/DNPlay/frmDNPlay.resx
===================================================================
--- trunk/oggdsf/src/tools/DNPlay/frmDNPlay.resx	2004-10-12 04:49:56 UTC (rev 7983)
+++ trunk/oggdsf/src/tools/DNPlay/frmDNPlay.resx	2004-10-12 10:15:37 UTC (rev 7984)
@@ -247,15 +247,15 @@
   <data name="lblClipDesc.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>Private</value>
   </data>
-  <data name="cmdFollowLink.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>Private</value>
-  </data>
   <data name="cmdFollowLink.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>False</value>
   </data>
   <data name="cmdFollowLink.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>Private</value>
   </data>
+  <data name="cmdFollowLink.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>Private</value>
+  </data>
   <data name="lblAnchorLink.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>False</value>
   </data>
@@ -274,6 +274,15 @@
   <data name="lblTitle.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>Private</value>
   </data>
+  <data name="label1.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
+  </data>
+  <data name="label1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>Private</value>
+  </data>
+  <data name="label1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>Private</value>
+  </data>
   <data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>False</value>
   </data>
@@ -286,6 +295,9 @@
   <data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>False</value>
   </data>
+  <data name="$this.Name">
+    <value>frmDNPlay</value>
+  </data>
   <data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>8, 8</value>
   </data>
@@ -298,9 +310,6 @@
   <data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </data>
-  <data name="$this.Name">
-    <value>frmDNPlay</value>
-  </data>
   <data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>Private</value>
   </data>



More information about the commits mailing list