コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the VideoMediaFormat class with the specified mime type,
        /// size, frame rate, and bit rate.
        /// </summary>
        /// <param name="mimeType">The mime type of the format.</param>
        /// <param name="size">The size of the format.</param>
        /// <param name="frameRate">The frame rate of the format.</param>
        /// <param name="bitRate">The bit rate of the format.</param>
        /// <param name="maxBps">The max bps of the format.</param>
        /// <exception cref="ArgumentException"><paramref name="mimeType"/> is invalid (i.e. undefined value).</exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     The width or the height of <paramref name="size"/> is less than zero.<br/>
        ///     -or-<br/>
        ///     <paramref name="frameRate"/> is less than zero.<br/>
        ///     -or-<br/>
        ///     <paramref name="bitRate"/> is less than zero.
        ///     -or-<br/>
        ///     <paramref name="maxBps"/> is less than zero.
        /// </exception>
        /// <since_tizen> 6 </since_tizen>
        public VideoMediaFormat(MediaFormatVideoMimeType mimeType, Size size, int frameRate, int bitRate, int maxBps)
            : base(MediaFormatType.Video)
        {
            ValidationUtil.ValidateEnum(typeof(MediaFormatVideoMimeType), mimeType, nameof(mimeType));

            if (size.Width < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(size), size.Width, "Size.Width value can't be less than zero.");
            }
            if (size.Height < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(size), size.Height, "Size.Height value can't be less than zero.");
            }
            if (frameRate < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(frameRate), frameRate, "Frame rate can't be less than zero.");
            }
            if (bitRate < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(bitRate), bitRate, "Bit rate value can't be less than zero.");
            }
            if (maxBps < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maxBps), maxBps, "Max bps value can't be less than zero.");
            }

            MimeType  = mimeType;
            Size      = size;
            FrameRate = frameRate;
            BitRate   = bitRate;
            MaxBps    = maxBps;
        }
コード例 #2
0
        private static void LoadSupportedCodec()
        {
            var videoCodecList = new List <MediaFormatVideoMimeType>();
            var audioCodecList = new List <MediaFormatAudioMimeType>();

            Interop.MediaCodec.SupportedCodecCallback cb = (codecType, _) =>
            {
                if ((codecType & CodecKindMask) == CodecKindVideo)
                {
                    MediaFormatVideoMimeType mimeType = 0;
                    if (TryGetMimeTypeFromCodecType(codecType, ref mimeType))
                    {
                        videoCodecList.Add(mimeType);
                    }
                }
                else
                {
                    MediaFormatAudioMimeType mimeType = 0;
                    if (TryGetMimeTypeFromCodecType(codecType, ref mimeType))
                    {
                        audioCodecList.Add(mimeType);
                    }
                }

                return(true);
            };

            int ret = Interop.MediaCodec.ForeachSupportedCodec(cb, IntPtr.Zero);

            MultimediaDebug.AssertNoError(ret);

            _supportedVideoCodecs = videoCodecList.AsReadOnly();
            _supportedAudioCodecs = audioCodecList.AsReadOnly();
        }
コード例 #3
0
ファイル: MediaCodec.cs プロジェクト: younghajung/TizenFX
        private static void LoadSupportedCodec()
        {
            var videoCodecList = new List <MediaFormatVideoMimeType>();
            var audioCodecList = new List <MediaFormatAudioMimeType>();

            Native.SupportedCodecCallback cb = (codecType, _) =>
            {
                if ((codecType & CodecKindMask) == CodecKindVideo)
                {
                    MediaFormatVideoMimeType mimeType = 0;
                    if (TryGetMimeTypeFromCodecType(codecType, ref mimeType))
                    {
                        videoCodecList.Add(mimeType);
                    }
                }
                else
                {
                    MediaFormatAudioMimeType mimeType = 0;
                    if (TryGetMimeTypeFromCodecType(codecType, ref mimeType))
                    {
                        audioCodecList.Add(mimeType);
                    }
                }

                return(true);
            };

            Native.ForeachSupportedCodec(cb, IntPtr.Zero).ThrowIfFailed("Failed to get supported codec.");

            _supportedVideoCodecs = videoCodecList.AsReadOnly();
            _supportedAudioCodecs = audioCodecList.AsReadOnly();
        }
コード例 #4
0
ファイル: VideoMediaFormat.cs プロジェクト: prjung/TizenFX
        /// <summary>
        /// Initializes a new instance of the VideoMediaFormat class with the specified mime type,
        /// size, frame rate, and bit rate.
        /// </summary>
        /// <param name="mimeType">The mime type of the format.</param>
        /// <param name="size">The size of the format.</param>
        /// <param name="frameRate">The frame rate of the format.</param>
        /// <param name="bitRate">The bit rate of the format.</param>
        /// <exception cref="ArgumentException"><paramref name="mimeType"/> is invalid (i.e. undefined value).</exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     The width or the height of <paramref name="size"/> is less than zero.<br/>
        ///     -or-<br/>
        ///     <paramref name="frameRate"/> is less than zero.<br/>
        ///     -or-<br/>
        ///     <paramref name="bitRate"/> is less than zero.
        /// </exception>
        /// <since_tizen> 3 </since_tizen>
        public VideoMediaFormat(MediaFormatVideoMimeType mimeType, Size size,
                                int frameRate, int bitRate)
            : base(MediaFormatType.Video)
        {
            if (!Enum.IsDefined(typeof(MediaFormatVideoMimeType), mimeType))
            {
                throw new ArgumentException($"Invalid mime type value : { (int)mimeType }");
            }
            if (size.Width < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(size), size.Width, "Size.Width value can't be less than zero.");
            }
            if (size.Height < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(size), size.Height, "Size.Height value can't be less than zero.");
            }
            if (frameRate < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(frameRate), frameRate, "Frame rate can't be less than zero.");
            }
            if (bitRate < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(bitRate), bitRate, "Bit rate value can't be less than zero.");
            }

            MimeType  = mimeType;
            Size      = size;
            FrameRate = frameRate;
            BitRate   = bitRate;
        }
コード例 #5
0
        /// <summary>
        /// Retrieves supported codec types for the specified params.
        /// </summary>
        /// <param name="encoder">The value indicating encoder or decoder.</param>
        /// <param name="type">The mime type to query.</param>
        /// <returns>The values indicating which codec types are supported on the current device.</returns>
        /// <exception cref="ArgumentException"><paramref name="type"/> is invalid.</exception>
        /// <since_tizen> 3 </since_tizen>
        public MediaCodecTypes GetCodecType(bool encoder, MediaFormatVideoMimeType type)
        {
            ValidateNotDisposed();

            if (CheckMimeType(typeof(MediaFormatVideoMimeType), (int)type) == false)
            {
                return(0);
            }

            return(GetCodecType((int)type, encoder));
        }
コード例 #6
0
ファイル: VideoMediaFormat.cs プロジェクト: prjung/TizenFX
        /// <summary>
        /// Retrieves video properties of the media format from a native handle.
        /// </summary>
        /// <param name="handle">A native handle that the properties are retrieved from.</param>
        /// <param name="width">An out parameter for the width.</param>
        /// <param name="height">An out parameter for the height.</param>
        /// <param name="bitRate">An out parameter for the bit rate.</param>
        /// <param name="mimeType">An out parameter for the mime type.</param>
        private static void GetInfo(IntPtr handle, out int width, out int height, out int bitRate,
                                    out MediaFormatVideoMimeType mimeType)
        {
            Debug.Assert(handle != IntPtr.Zero, "The handle is invalid!");

            int mimeTypeValue = 0;
            int maxBps        = 0;

            int ret = Interop.MediaFormat.GetVideoInfo(handle,
                                                       out mimeTypeValue, out width, out height, out bitRate, out maxBps);

            MultimediaDebug.AssertNoError(ret);

            mimeType = (MediaFormatVideoMimeType)mimeTypeValue;

            Debug.Assert(Enum.IsDefined(typeof(MediaFormatVideoMimeType), mimeType),
                         "Invalid video mime type!");
        }
コード例 #7
0
ファイル: Interop.MediaTool.cs プロジェクト: yunmiha/TizenFX
 internal static extern int SetVideoMimeType(IntPtr handle, MediaFormatVideoMimeType value);
コード例 #8
0
ファイル: Interop.MediaTool.cs プロジェクト: yunmiha/TizenFX
 internal static extern int GetVideoInfo(IntPtr handle, out MediaFormatVideoMimeType mimeType,
                                         out int width, out int height, out int averageBps, out int maxBps);
コード例 #9
0
ファイル: StreamRecorder.cs プロジェクト: yunmiha/TizenFX
 private static bool AreVideoTypesMatched(StreamRecorderVideoFormat videoFormat, MediaFormatVideoMimeType mimeType)
 {
     return((videoFormat == StreamRecorderVideoFormat.Nv12 && mimeType == MediaFormatVideoMimeType.NV12) ||
            (videoFormat == StreamRecorderVideoFormat.Nv21 && mimeType == MediaFormatVideoMimeType.NV21) ||
            (videoFormat == StreamRecorderVideoFormat.I420 && mimeType == MediaFormatVideoMimeType.I420));
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the VideoMediaFormat class with the specified mime type,
 /// width, height, and frame rate.
 /// </summary>
 /// <param name="mimeType">The mime type of the format.</param>
 /// <param name="size">The video size of the format.</param>
 /// <param name="frameRate">The frame rate of the format.</param>
 /// <exception cref="ArgumentException"><paramref name="mimeType"/> is invalid (i.e. undefined value).</exception>
 /// <exception cref="ArgumentOutOfRangeException">
 ///     The width or the height of <paramref name="size"/> is less than zero.<br/>
 ///     -or-<br/>
 ///     <paramref name="frameRate"/> is less than zero.
 /// </exception>
 /// <since_tizen> 3 </since_tizen>
 public VideoMediaFormat(MediaFormatVideoMimeType mimeType, Size size,
                         int frameRate)
     : this(mimeType, size, frameRate, DefaultBitRate)
 {
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the VideoMediaFormat class with the specified mime type,
 /// width, height, and frame rate.
 /// </summary>
 /// <param name="mimeType">The mime type of the format.</param>
 /// <param name="width">The width value of the format.</param>
 /// <param name="height">The height value of the format</param>
 /// <param name="frameRate">The frame rate of the format.</param>
 /// <exception cref="ArgumentException"><paramref name="mimeType"/> is invalid (i.e. undefined value).</exception>
 /// <exception cref="ArgumentOutOfRangeException">
 ///     <paramref name="width"/>, <paramref name="height"/>, or <paramref name="frameRate"/> is less than zero.
 /// </exception>
 /// <since_tizen> 3 </since_tizen>
 public VideoMediaFormat(MediaFormatVideoMimeType mimeType, int width, int height, int frameRate)
     : this(mimeType, width, height, frameRate, DefaultBitRate)
 {
 }
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of the VideoMediaFormat class with the specified mime type and size.
 /// </summary>
 /// <param name="mimeType">The mime type of the format.</param>
 /// <param name="size">The size of the format.</param>
 /// <exception cref="ArgumentException"><paramref name="mimeType"/> is invalid (i.e. undefined value).</exception>
 /// <exception cref="ArgumentOutOfRangeException">The width or the height of <paramref name="size"/> is less than zero.</exception>
 /// <since_tizen> 3 </since_tizen>
 public VideoMediaFormat(MediaFormatVideoMimeType mimeType, Size size)
     : this(mimeType, size, DefaultFrameRate)
 {
 }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the VideoMediaFormat class with the specified mime type, width, and height.
 /// </summary>
 /// <param name="mimeType">The mime type of the format.</param>
 /// <param name="width">The width value of the format.</param>
 /// <param name="height">The height value of the format</param>
 /// <exception cref="ArgumentException"><paramref name="mimeType"/> is invalid (i.e. undefined value).</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="width"/> or <paramref name="height"/> is less than zero.</exception>
 /// <since_tizen> 3 </since_tizen>
 public VideoMediaFormat(MediaFormatVideoMimeType mimeType, int width, int height)
     : this(mimeType, width, height, DefaultFrameRate)
 {
 }
コード例 #14
0
 /// <summary>
 /// Initializes a new instance of the VideoMediaFormat class with the specified mime type,
 /// width, height, frame rate, and bit rate.
 /// </summary>
 /// <param name="mimeType">The mime type of the format.</param>
 /// <param name="width">The width value of the format.</param>
 /// <param name="height">The height value of the format</param>
 /// <param name="frameRate">The frame rate of the format.</param>
 /// <param name="bitRate">The bit rate of the format.</param>
 /// <exception cref="ArgumentException"><paramref name="mimeType"/> is invalid (i.e. undefined value).</exception>
 /// <exception cref="ArgumentOutOfRangeException">
 ///     <paramref name="width"/>, <paramref name="height"/>, <paramref name="frameRate"/>, or <paramref name="bitRate"/> is less than zero.
 /// </exception>
 /// <since_tizen> 3 </since_tizen>
 public VideoMediaFormat(MediaFormatVideoMimeType mimeType, int width, int height,
                         int frameRate, int bitRate)
     : this(mimeType, new Size(width, height), frameRate, bitRate)
 {
 }
コード例 #15
0
 internal static int ToNative(MediaFormatVideoMimeType type)
 {
     return((int)type & CodecTypeMask);
 }