Beispiel #1
0
        /// <summary>
        /// Wraps the WMCreateEditor function
        /// </summary>
        /// <returns>The meta editor object</returns>
        public static IWMMetadataEditor CreateEditor()
        {
            IWMMetadataEditor res = null;

            Marshal.ThrowExceptionForHR(WMCreateEditor(out res));
            return(res);
        }
 public void Dispose()
 {
     if (m_pEditor != null)
     {
         Marshal.ReleaseComObject(m_pEditor);
         m_pEditor = null;
     }
     GC.SuppressFinalize(this);
 }
        //------------------------------------------------------------------------------
        // Name: EditorOpenFile()
        // Desc: Creates a metadata editor and opens the file.
        //------------------------------------------------------------------------------
        bool EditorOpenFile(string pwszInFile, out IWMMetadataEditor ppEditor)
        {
            ppEditor = null;

            try
            {
                WMFSDKFunctions.WMCreateEditor(out ppEditor);

                ppEditor.Open(pwszInFile);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }

            return(true);
        }
        /// <summary>Initialize the editor.</summary>
        /// <param name="filepath">The path to the file whose metadata needs to be edited.</param>
        public AsfMetadataEditor(string filepath)
            : base()
        {
            if (filepath == null) throw new ArgumentNullException("filepath");
            _path = filepath;

            try
            {
                _editor = WMCreateEditor();
                _editor.Open(filepath);
                _headerInfo = (IWMHeaderInfo3)_editor;
            }
            catch
            {
                Dispose(true);
                throw;
            }
        }
Beispiel #5
0
			bool EditorOpenFile (string pwszInFile, out IWMMetadataEditor ppEditor)
				{
				ppEditor = null;

				try
					{
					WMFSDKFunctions.WMCreateEditor (out ppEditor);

					ppEditor.Open (pwszInFile);
					}
				catch (System.Runtime.InteropServices.COMException e)
					{
					m_Resultat = new String [] { e.ToString() };
					return (false);
					}

				return (true);
				}
Beispiel #6
0
        //------------------------------------------------------------------------------
        // Name: CWMVCopy::CopyScriptInList()
        // Desc: Copies scripts in m_ScriptList to the header of the writer.
        //------------------------------------------------------------------------------
        protected void CopyScriptInList(string pwszOutputFile)
        {
            IWMMetadataEditor pEditor           = null;
            IWMHeaderInfo     pWriterHeaderInfo = null;

            //
            // Scripts can be added by the metadata editor.
            // Create an editor
            //
            WMUtils.WMCreateEditor(out pEditor);

            try
            {
                //
                // Open the output using the editor
                //
                pEditor.Open(pwszOutputFile);

                pWriterHeaderInfo = pEditor as IWMHeaderInfo;

                foreach (CScript pScript in m_ScriptList)
                {
                    //
                    // Add the script to the writer
                    //
                    pWriterHeaderInfo.AddScript(pScript.m_pwszType,
                                                pScript.m_pwszParameter,
                                                pScript.m_cnsTime);
                }

                //
                // Close and release the editor
                //
                pEditor.Flush();

                pEditor.Close();
            }
            finally
            {
                Marshal.ReleaseComObject(pEditor);
            }
        }
        /// <summary>Initialize the editor.</summary>
        /// <param name="filepath">The path to the file whose metadata needs to be edited.</param>
        public AsfMetadataEditor(string filepath) : base()
        {
            if (filepath == null)
            {
                throw new ArgumentNullException("filepath");
            }
            _path = filepath;

            try
            {
                _editor = WMCreateEditor();
                _editor.Open(filepath);
                _headerInfo = (IWMHeaderInfo3)_editor;
            }
            catch
            {
                Dispose(true);
                throw;
            }
        }
 /// <summary>Releases all of the resources for the editor.</summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_editor != null)
         {
             try { _editor.Flush(); }
             catch (COMException) {}
             while (Marshal.ReleaseComObject(_editor) > 0)
             {
                 ;
             }
             _editor = null;
         }
         if (_headerInfo != null)
         {
             while (Marshal.ReleaseComObject(_headerInfo) > 0)
             {
                 ;
             }
             _headerInfo = null;
         }
     }
 }
Beispiel #9
0
 internal static extern uint WMCreateEditor([MarshalAs(UnmanagedType.Interface)] out IWMMetadataEditor ppMetadataEditor);
Beispiel #10
0
 public static extern int WMCreateEditor(
     out IWMMetadataEditor ppMetadataEditor
     );
        //------------------------------------------------------------------------------
        // Name: EditorOpenFile()
        // Desc: Creates a metadata editor and opens the file.
        //------------------------------------------------------------------------------
        bool EditorOpenFile( string pwszInFile, out IWMMetadataEditor ppEditor )
        {
            ppEditor = null;

            try
            {
                WMFSDKFunctions.WMCreateEditor( out ppEditor );

                ppEditor.Open( pwszInFile ) ;
            }
            catch( System.Runtime.InteropServices.COMException e )
            {
                Console.WriteLine( e.Message );
                return( false );
            }

            return( true );
        }
Beispiel #12
0
        //------------------------------------------------------------------------------
        // Name: CWMVCopy::CopyMarker()
        // Desc: Copies the markers from the source file to the destination file.
        //------------------------------------------------------------------------------
        protected void CopyMarker(string pwszOutputFile)
        {
            short             cMarker           = 0;
            IWMMetadataEditor pEditor           = null;
            IWMHeaderInfo     pWriterHeaderInfo = null;
            StringBuilder     pwszMarkerName    = null;

            m_pReaderHeaderInfo.GetMarkerCount(out cMarker);

            //
            // Markers can be copied only by the metadata editor.
            // Create an editor
            //
            WMUtils.WMCreateEditor(out pEditor);

            try
            {
                //
                // Open the output using the editor
                //
                pEditor.Open(pwszOutputFile);

                pWriterHeaderInfo = pEditor as IWMHeaderInfo;

                for (short i = 0; i < cMarker; i++)
                {
                    short cchMarkerNameLen = 0;
                    long  cnsMarkerTime    = 0;

                    //
                    // Get the memory size for this marker
                    //
                    m_pReaderHeaderInfo.GetMarker(i,
                                                  null,
                                                  ref cchMarkerNameLen,
                                                  out cnsMarkerTime);

                    pwszMarkerName = new StringBuilder(cchMarkerNameLen);

                    m_pReaderHeaderInfo.GetMarker(i,
                                                  pwszMarkerName,
                                                  ref cchMarkerNameLen,
                                                  out cnsMarkerTime);
                    //
                    // Add marker to the writer
                    //
                    pWriterHeaderInfo.AddMarker(pwszMarkerName.ToString(),
                                                cnsMarkerTime);
                }

                //
                // Close and release the editor
                //
                pEditor.Flush();

                pEditor.Close();
            }
            finally
            {
                Marshal.ReleaseComObject(pEditor);
            }
        }
 /// <summary>
 /// Close this editor, committing any changes to disk.
 /// </summary>
 /// <remarks>The editor cannot be further used after this is called.</remarks>
 public void Close()
 {
     if (this.editor != null) {
         this.editor.Flush();
         this.editor.Close(); // is this redundant?
         this.editor = null;
     }
 }
		public void Dispose()
		{
			if (m_pEditor != null)
			{
				Marshal.ReleaseComObject(m_pEditor);
				m_pEditor = null;
			}
			GC.SuppressFinalize(this);
		}
 /// <summary>Releases all of the resources for the editor.</summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_editor != null)
         {
             try { _editor.Flush(); }
             catch(COMException){}
             while(Marshal.ReleaseComObject(_editor) > 0);
             _editor = null;
         }
         if (_headerInfo != null)
         {
             while(Marshal.ReleaseComObject(_headerInfo) > 0);
             _headerInfo = null;
         }
     }
 }
Beispiel #16
0
 private static extern int WMCreateEditor([Out, MarshalAs(UnmanagedType.Interface)] out IWMMetadataEditor ppEditor);
Beispiel #17
0
        /// <summary>
        /// Creates a metadata editor and opens the file.
        /// </summary>
        /// <param name="pwszInFile">
        /// The PWSZ in file. 
        /// </param>
        /// <param name="ppEditor">
        /// The pp editor. 
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool EditorOpenFile(string pwszInFile, out IWMMetadataEditor ppEditor)
        {
            ppEditor = null;

            try
            {
                WMFSDKFunctions.WMCreateEditor(out ppEditor);

                ppEditor.Open(pwszInFile);
            }
            catch (COMException e)
            {
                this.AddLogEntry(e.Message, LogType.Fail);
                return false;
            }

            return true;
        }