示例#1
0
        /// <summary>
        /// Initializes a new instance of the MediaStreamSource class with the specified <see cref="VideoMediaFormat"/>.
        /// </summary>
        /// <remarks>H.264 is supported.</remarks>
        /// <param name="videoMediaFormat">The <see cref="VideoMediaFormat"/> for this source.</param>
        /// <exception cref="ArgumentNullException"><paramref name="videoMediaFormat"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="videoMediaFormat"/> is not supported.</exception>
        /// <seealso cref="SupportedVideoTypes"/>
        /// <since_tizen> 3 </since_tizen>
        public MediaStreamSource(VideoMediaFormat videoMediaFormat)
        {
            if (videoMediaFormat == null)
            {
                throw new ArgumentNullException(nameof(videoMediaFormat));
            }

            _videoMediaFormat = videoMediaFormat;

            VideoConfiguration = CreateVideoConfiguration(videoMediaFormat);
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the MediaStreamSource class with the specified <see cref="AudioMediaFormat"/>.
        /// </summary>
        /// <param name="audioMediaFormat">The <see cref="AudioMediaFormat"/> for this source.</param>
        /// <remarks>AAC is supported.</remarks>
        /// <exception cref="ArgumentNullException"><paramref name="audioMediaFormat"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="audioMediaFormat"/> is not supported.</exception>
        /// <seealso cref="SupportedAudioTypes"/>
        /// <since_tizen> 3 </since_tizen>
        public MediaStreamSource(AudioMediaFormat audioMediaFormat)
        {
            if (audioMediaFormat == null)
            {
                throw new ArgumentNullException(nameof(audioMediaFormat));
            }

            _audioMediaFormat = audioMediaFormat;

            AudioConfiguration = CreateAudioConfiguration(audioMediaFormat);
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the MediaPacket class with the specified media format.
        /// </summary>
        /// <param name="format">The media format containing properties for the packet.</param>
        /// <exception cref="ArgumentNullException"><paramref name="format"/> is null.</exception>
        /// <exception cref="ArgumentException">
        ///     The <see cref="MediaFormatType"/> of the specified format is <see cref="MediaFormatType.Container"/>.
        /// </exception>
        /// <exception cref="InvalidOperationException">Operation failed.</exception>
        internal MediaPacket(MediaFormat format)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            Initialize(format);

            _format = format;
            _buffer = new Lazy <IMediaBuffer>(GetBuffer);
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the MediaStreamSource class
        /// with the specified <see cref="AudioMediaFormat"/> and <see cref="VideoMediaFormat"/>.
        /// </summary>
        /// <param name="audioMediaFormat">The <see cref="AudioMediaFormat"/> for this source.</param>
        /// <param name="videoMediaFormat">The <see cref="VideoMediaFormat"/> for this source.</param>
        /// <remarks>AAC and H.264 are supported.</remarks>
        /// <exception cref="ArgumentNullException">Both <paramref name="audioMediaFormat"/> and <paramref name="videoMediaFormat"/> are null.</exception>
        /// <exception cref="ArgumentException">
        ///     <paramref name="audioMediaFormat"/> is not supported.<br/>
        ///     -or-<br/>
        ///     <paramref name="videoMediaFormat"/> is not supported.
        /// </exception>
        /// <seealso cref="SupportedAudioTypes"/>
        /// <seealso cref="SupportedVideoTypes"/>
        /// <since_tizen> 3 </since_tizen>
        public MediaStreamSource(AudioMediaFormat audioMediaFormat, VideoMediaFormat videoMediaFormat)
        {
            if (audioMediaFormat == null && videoMediaFormat == null)
            {
                throw new ArgumentNullException(nameof(audioMediaFormat) + " and " + nameof(videoMediaFormat));
            }

            _audioMediaFormat = audioMediaFormat;
            _videoMediaFormat = videoMediaFormat;

            AudioConfiguration = CreateAudioConfiguration(audioMediaFormat);
            VideoConfiguration = CreateVideoConfiguration(videoMediaFormat);
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the MediaPacket class with the specified media format.
        /// </summary>
        /// <param name="format">The media format containing properties for the packet.</param>
        /// <exception cref="ArgumentNullException"><paramref name="format"/> is null.</exception>
        /// <exception cref="ArgumentException">
        ///     The <see cref="MediaFormatType"/> of the specified format is <see cref="MediaFormatType.Container"/>.
        /// </exception>
        /// <exception cref="InvalidOperationException">Operation failed.</exception>
        internal MediaPacket(MediaFormat format)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            if (format.Type == MediaFormatType.Container)
            {
                throw new ArgumentException("Container format can't be used to create a new packet.");
            }

            Initialize(format);
            _format = format;
            _buffer = new Lazy <IMediaBuffer>(GetBuffer);
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the MediaPacket class from a native handle.
        /// </summary>
        /// <param name="handle">The native handle to be used.</param>
        internal MediaPacket(IntPtr handle)
        {
            _handle = handle;

            int ret = Native.GetFormat(handle, out IntPtr formatHandle);

            MultimediaDebug.AssertNoError(ret);

            try
            {
                if (formatHandle != IntPtr.Zero)
                {
                    _format = MediaFormat.FromHandle(formatHandle);
                }
            }
            finally
            {
                NativeFormat.Unref(formatHandle);
            }
        }
示例#7
0
        private void SetMediaStreamInfo(StreamType streamType, MediaFormat mediaFormat)
        {
            if (mediaFormat == null)
            {
                Log.Error(PlayerLog.Tag, "invalid media format");
                return;
            }

            IntPtr ptr = IntPtr.Zero;

            try
            {
                ptr = mediaFormat.AsNativeHandle();
                NativePlayer.SetMediaStreamInfo(_player.Handle, (int)streamType, ptr).
                ThrowIfFailed("Failed to set the media stream info");
            }
            finally
            {
                MediaFormat.ReleaseNativeHandle(ptr);
            }
        }
示例#8
0
        /// <summary>
        /// Creates and initializes a native handle for the current object.
        /// </summary>
        /// <param name="format">The format to be set to the media format.</param>
        /// <exception cref="InvalidOperationException">Operation failed.</exception>
        private void Initialize(MediaFormat format)
        {
            if (format.Type == MediaFormatType.Container)
            {
                throw new ArgumentException("Container format can't be used to create a new packet.",
                                            nameof(format));
            }

            IntPtr formatHandle = IntPtr.Zero;

            try
            {
                formatHandle = format.AsNativeHandle();

                int ret = Native.Create(formatHandle, IntPtr.Zero, IntPtr.Zero, out _handle);
                MultimediaDebug.AssertNoError(ret);

                Debug.Assert(_handle != IntPtr.Zero, "Created handle must not be null");

                Alloc();
            }
            catch (Exception)
            {
                if (_handle != IntPtr.Zero)
                {
                    Native.Destroy(_handle);
                    _handle = IntPtr.Zero;
                }

                throw;
            }
            finally
            {
                if (formatHandle != IntPtr.Zero)
                {
                    NativeFormat.Unref(formatHandle);
                }
            }
        }
示例#9
0
        /// <summary>
        /// Creates and initializes a native handle for the current object.
        /// </summary>
        /// <param name="format">The format to be set to the media format.</param>
        /// <exception cref="InvalidOperationException">Operation failed.</exception>
        private void Initialize(MediaFormat format)
        {
            if (format.Type == MediaFormatType.Container)
            {
                throw new ArgumentException("Creating a packet for container is not supported.");
            }

            IntPtr formatHandle = IntPtr.Zero;

            try
            {
                formatHandle = format.AsNativeHandle();

                int ret = Interop.MediaPacket.Create(formatHandle, IntPtr.Zero, IntPtr.Zero, out _handle);
                MultimediaDebug.AssertNoError(ret);

                Debug.Assert(_handle != IntPtr.Zero, "Created handle must not be null");

                Alloc();
            }
            catch (Exception)
            {
                if (_handle != IntPtr.Zero)
                {
                    Interop.MediaPacket.Destroy(_handle);
                    _handle = IntPtr.Zero;
                }

                throw;
            }
            finally
            {
                if (formatHandle != IntPtr.Zero)
                {
                    Interop.MediaFormat.Unref(formatHandle);
                }
            }
        }
示例#10
0
 internal SimpleMediaPacket(MediaFormat format) : base(format)
 {
 }
示例#11
0
 /// <summary>
 /// Creates an object of the MediaPacket with the specified <see cref="MediaFormat"/>.
 /// </summary>
 /// <param name="format">The media format for the new packet.</param>
 /// <returns>A new MediaPacket object.</returns>
 /// <since_tizen> 3 </since_tizen>
 public static MediaPacket Create(MediaFormat format)
 {
     return(new SimpleMediaPacket(format));
 }