Exemplo n.º 1
0
        /// <summary>
        /// Pushes elementary stream to decode audio or video.
        /// </summary>
        /// <remarks>
        /// This source must be set as a source to a WebRTC and the WebRTC must be in the
        /// <see cref="WebRTCState.Negotiating"/> or <see cref="WebRTCState.Playing"/> state
        /// </remarks>
        /// <param name="packet">The <see cref="MediaPacket"/> to decode.</param>
        /// <exception cref="InvalidOperationException">
        ///     This source is not set as a source to a WebRTC.<br/>
        ///     -or-<br/>
        ///     The WebRTC is not in the valid state.
        /// </exception>
        /// <exception cref="ArgumentNullException"><paramref name="packet"/> is null.</exception>
        /// <exception cref="ObjectDisposedException"><paramref name="packet"/> has been disposed.</exception>
        /// <exception cref="ArgumentException">
        ///     <paramref name="packet"/> is neither video nor audio type.<br/>
        ///     -or-<br/>
        ///     The format of packet is not matched with the specified format in the constructor.
        /// </exception>
        /// <seealso cref="WebRTC.AddSource"/>
        /// <seealso cref="WebRTC.AddSources"/>
        /// <seealso cref="MediaPacket"/>
        /// <since_tizen> 9 </since_tizen>
        public void Push(MediaPacket packet)
        {
            if (WebRtc == null)
            {
                Log.Error(WebRTCLog.Tag, "The source is not set as a source to a WebRTC yet.");
                throw new InvalidOperationException("The source is not set as a source to a WebRTC yet.");
            }

            if (packet == null)
            {
                Log.Error(WebRTCLog.Tag, "packet is null");
                throw new ArgumentNullException(nameof(packet));
            }

            if (packet.IsDisposed)
            {
                Log.Error(WebRTCLog.Tag, "packet is disposed");
                throw new ObjectDisposedException(nameof(packet));
            }

            if (packet.Format.Type == MediaFormatType.Text || packet.Format.Type == MediaFormatType.Container)
            {
                Log.Error(WebRTCLog.Tag, "The format of the packet is invalid : " + packet.Format.Type);
                throw new ArgumentException($"The format of the packet is invalid : {packet.Format.Type}.");
            }

            if (!packet.Format.Equals(_audioMediaFormat) && !packet.Format.Equals(_videoMediaFormat))
            {
                Log.Error(WebRTCLog.Tag, "The format of the packet is invalid : Unmatched format.");
                throw new ArgumentException("The format of the packet is invalid : Unmatched format.");
            }

            if (packet.Format.Type == MediaFormatType.Video && _videoMediaFormat == null)
            {
                Log.Error(WebRTCLog.Tag, "Video is not configured with the current source.");
                throw new ArgumentException("Video is not configured with the current source.");
            }

            if (packet.Format.Type == MediaFormatType.Audio && _audioMediaFormat == null)
            {
                Log.Error(WebRTCLog.Tag, "Audio is not configured with the current source.");
                throw new ArgumentException("Audio is not configured with the current source.");
            }

            WebRtc.ValidateWebRTCState(WebRTCState.Negotiating, WebRTCState.Playing);

            NativeWebRTC.PushMediaPacket(WebRtc.Handle, SourceId.Value, packet.GetHandle()).
            ThrowIfFailed("Failed to push the packet to the WebRTC");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Applies the audio stream policy to <see cref="MediaMicrophoneSource"/>.
        /// </summary>
        /// <param name="policy">The <see cref="AudioStreamPolicy"/> to apply.</param>
        /// <remarks>
        /// The WebRTC must be in the <see cref="WebRTCState.Idle"/> state.<br/>
        /// <br/>
        /// <see cref="WebRTC"/> does not support all <see cref="AudioStreamType"/>.<br/>
        /// Supported types are <see cref="AudioStreamType.Media"/>, <see cref="AudioStreamType.VoiceRecognition"/>,
        /// <see cref="AudioStreamType.Voip"/>, <see cref="AudioStreamType.MediaExternalOnly"/>.
        /// </remarks>
        /// <exception cref="ObjectDisposedException">
        ///     The WebRTC has already been disposed.<br/>
        ///     -or-<br/>
        ///     <paramref name="policy"/> has already been disposed.
        /// </exception>
        /// <exception cref="InvalidOperationException">The WebRTC is not in the valid state.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="policy"/> is null.</exception>
        /// <exception cref="NotSupportedException">
        ///     <see cref="AudioStreamType"/> of <paramref name="policy"/> is not supported on the current platform.
        /// </exception>
        /// <seealso cref="AudioStreamPolicy"/>
        /// <since_tizen> 9 </since_tizen>
        public void ApplyAudioStreamPolicy(AudioStreamPolicy policy)
        {
            if (policy == null)
            {
                throw new ArgumentNullException(nameof(policy), "policy is null");
            }

            WebRtc.ValidateWebRTCState(WebRTCState.Idle);

            var ret = NativeWebRTC.SetAudioStreamPolicyToMicrophoneSource(WebRtc.Handle, SourceId.Value, policy.Handle);

            if (ret == WebRTCErrorCode.InvalidArgument)
            {
                throw new NotSupportedException("The specified policy is not supported on the current system.");
            }

            ret.ThrowIfFailed("Failed to set the audio stream policy to the WebRTC");
        }
Exemplo n.º 3
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (BaseProfile == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "BaseProfile");
     }
     if (Canvas == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Canvas");
     }
     if (Webgl == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Webgl");
     }
     if (Timezone == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Timezone");
     }
     if (Geolocation == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Geolocation");
     }
     if (Proxy == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Proxy");
     }
     if (WebRtc == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "WebRtc");
     }
     if (Fonts == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Fonts");
     }
     if (Plugins == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Plugins");
     }
     if (Screen == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Screen");
     }
     if (StartPage == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "StartPage");
     }
     if (Extensions == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Extensions");
     }
     if (Notes == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Notes");
     }
     if (Launcher == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Launcher");
     }
     if (Status == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Status");
     }
     if (BaseProfile != null)
     {
         BaseProfile.Validate();
     }
     if (Webgl != null)
     {
         Webgl.Validate();
     }
     if (Timezone != null)
     {
         Timezone.Validate();
     }
     if (Geolocation != null)
     {
         Geolocation.Validate();
     }
     if (Proxy != null)
     {
         Proxy.Validate();
     }
     if (WebRtc != null)
     {
         WebRtc.Validate();
     }
     if (Fonts != null)
     {
         Fonts.Validate();
     }
     if (Plugins != null)
     {
         Plugins.Validate();
     }
     if (Screen != null)
     {
         Screen.Validate();
     }
     if (Status != null)
     {
         Status.Validate();
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (Canvas == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Canvas");
     }
     if (Webgl == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Webgl");
     }
     if (Timezone == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Timezone");
     }
     if (Geolocation == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Geolocation");
     }
     if (Proxy == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Proxy");
     }
     if (WebRtc == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "WebRtc");
     }
     if (Fonts == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Fonts");
     }
     if (Plugins == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Plugins");
     }
     if (Screen == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Screen");
     }
     if (StartPage == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "StartPage");
     }
     if (Webgl != null)
     {
         Webgl.Validate();
     }
     if (Timezone != null)
     {
         Timezone.Validate();
     }
     if (Geolocation != null)
     {
         Geolocation.Validate();
     }
     if (Proxy != null)
     {
         Proxy.Validate();
     }
     if (WebRtc != null)
     {
         WebRtc.Validate();
     }
     if (Fonts != null)
     {
         Fonts.Validate();
     }
     if (Plugins != null)
     {
         Plugins.Validate();
     }
     if (Screen != null)
     {
         Screen.Validate();
     }
 }