コード例 #1
0
ファイル: MetadataExtractor.cs プロジェクト: yunmiha/TizenFX
        /// <summary>
        /// Gets the frame of a video media.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="timeStamp">The timestamp in milliseconds.</param>
        /// <param name="accurate">true to get an accurate frame for the given timestamp,
        ///     otherwise false to get the nearest i-frame of the video rapidly.</param>
        /// <returns>The raw frame data in RGB888 if a frame at specified time exists, otherwise null.</returns>
        /// <exception cref="InvalidOperationException">An internal error occurs.</exception>
        /// <exception cref="ObjectDisposedException">The <see cref="MetadataExtractor"/> has been already disposed of.</exception>
        public byte[] GetFrameAt(uint timeStamp, bool accurate)
        {
            IntPtr data = IntPtr.Zero;

            try
            {
                int size = 0;

                var ret = Interop.MetadataExtractor.GetFrameAtTime(Handle, timeStamp, accurate, out data, out size);
                MetadataExtractorRetValidator.ThrowIfError(ret, "Failed to get value");

                if (size == 0)
                {
                    return(null);
                }

                var buf = new byte[size];
                Marshal.Copy(data, buf, 0, size);

                return(buf);
            }
            finally
            {
                Interop.Libc.Free(data);
            }
        }
コード例 #2
0
ファイル: MetadataExtractor.cs プロジェクト: yunmiha/TizenFX
        /// <summary>
        /// Gets the artwork image in the source.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns>The <see cref="Artwork"/> if it exists, otherwise null.</returns>
        /// <exception cref="InvalidOperationException">An internal process error occurs.</exception>
        /// <exception cref="ObjectDisposedException">The <see cref="MetadataExtractor"/> has been already disposed of.</exception>
        public Artwork GetArtwork()
        {
            IntPtr data     = IntPtr.Zero;
            IntPtr mimeType = IntPtr.Zero;

            try
            {
                int size = 0;

                var ret = Interop.MetadataExtractor.GetArtwork(Handle, out data, out size, out mimeType);
                MetadataExtractorRetValidator.ThrowIfError(ret, "Failed to get value");

                if (size > 0)
                {
                    var buf = new byte[size];
                    Marshal.Copy(data, buf, 0, size);

                    return(new Artwork(buf, Marshal.PtrToStringAnsi(mimeType)));
                }

                return(null);
            }
            finally
            {
                Interop.Libc.Free(data);
                Interop.Libc.Free(mimeType);
            }
        }
コード例 #3
0
        internal static string GetMetadata(this MetadataExtractor extractor, MetadataExtractorAttr attr)
        {
            Debug.Assert(extractor != null);

            IntPtr valuePtr = IntPtr.Zero;

            try
            {
                var ret = Native.GetMetadata(extractor.Handle, attr, out valuePtr);
                MetadataExtractorRetValidator.ThrowIfError(ret, "Failed to get value for " + attr);
                return(Marshal.PtrToStringAnsi(valuePtr));
            }
            finally
            {
                Libc.Free(valuePtr);
            }
        }
コード例 #4
0
ファイル: MetadataExtractor.cs プロジェクト: yunmiha/TizenFX
        private void Create(Func <MetadataExtractorError> initFunc)
        {
            MetadataExtractorRetValidator.ThrowIfError(
                Interop.MetadataExtractor.Create(out _handle), "Failed to create metadata");

            try
            {
                MetadataExtractorRetValidator.ThrowIfError(initFunc(), "Failed to init");

                _metadata = new Lazy <Metadata>(() => new Metadata(this));
            }
            catch
            {
                Release();
                throw;
            }
        }
コード例 #5
0
ファイル: MetadataExtractor.cs プロジェクト: yunmiha/TizenFX
        /// <summary>
        /// Gets the sync lyrics of the source.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="index">The index of lyrics to retrieve.</param>
        /// <returns>The <see cref="SyncLyrics"/> object if <paramref name="index"/> is valid, otherwise null.</returns>
        /// <exception cref="InvalidOperationException">An internal process error occurs.</exception>
        /// <exception cref="ObjectDisposedException">The <see cref="MetadataExtractor"/> has been already disposed of.</exception>
        public SyncLyrics GetSyncLyrics(int index)
        {
            IntPtr lyrics = IntPtr.Zero;

            try
            {
                uint timestamp = 0;

                var ret = Interop.MetadataExtractor.GetSynclyrics(Handle, index, out timestamp, out lyrics);
                MetadataExtractorRetValidator.ThrowIfError(ret, "Failed to get sync lyrics");

                if (lyrics == IntPtr.Zero)
                {
                    return(null);
                }

                return(new SyncLyrics(Marshal.PtrToStringAnsi(lyrics), timestamp));
            }
            finally
            {
                Interop.Libc.Free(lyrics);
            }
        }