Ejemplo n.º 1
0
 public AudioFormatInfo(
     SampleFormat sampleFormat,
     int sampleRate,
     ChannelLayout channelLayout)
     : this(sampleFormat, sampleRate, ChannelLayoutHelper.GetChannelCount(channelLayout), channelLayout)
 {
 }
Ejemplo n.º 2
0
        public AudioFormatInfo(
            SampleFormat sampleFormat,
            int sampleRate,
            int channelCount,
            ChannelLayout channelLayout = default)
        {
            if (sampleFormat == SampleFormat.Unknown)
            {
                throw new ArgumentException("Must not be Unknown", nameof(sampleFormat));
            }

            if (sampleRate <= 0 || sampleRate > Constants.MaxSampleRate)
            {
                throw ExceptionHelper.OutOfRange(nameof(sampleRate), 1, Constants.MaxSampleRate, sampleRate);
            }

            if (channelCount <= 0 || channelCount > Constants.MaxChannelCount)
            {
                throw ExceptionHelper.OutOfRange(nameof(sampleRate), 1, Constants.MaxChannelCount, sampleRate);
            }

            SampleFormat  = sampleFormat;
            SampleRate    = sampleRate;
            ChannelCount  = channelCount;
            ChannelLayout = channelLayout;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// <see cref="swr_alloc_set_opts(SwrContext*, long, AVSampleFormat, int, long, AVSampleFormat, int, int, void*)"/>
 /// </summary>
 public void Reset(
     ChannelLayout outputChannelLayout, SampleFormat outputSampleFormat, int outputSampleRate,
     ChannelLayout inputChannelLayout, SampleFormat inputSampleFormat, int inputSampleRate)
 {
     _nativePointer = NativeUtils.NotNull((IntPtr)swr_alloc_set_opts(this,
                                                                     (long)outputChannelLayout, (AVSampleFormat)outputSampleFormat, outputSampleRate,
                                                                     (long)inputChannelLayout, (AVSampleFormat)inputSampleFormat, inputSampleRate,
                                                                     log_offset: 0, log_ctx: null));
 }
Ejemplo n.º 4
0
        public override int GetHashCode()
        {
            var hashCode = 1182625657;

            hashCode = hashCode * -1521134295 + Codec.GetHashCode();
            hashCode = hashCode * -1521134295 + ChannelLayout.GetHashCode();
            hashCode = hashCode * -1521134295 + SampleRate.GetHashCode();
            hashCode = hashCode * -1521134295 + BitsPerChannel.GetHashCode();
            hashCode = hashCode * -1521134295 + BitRate.GetHashCode();
            return(hashCode);
        }
Ejemplo n.º 5
0
 // Set Layout
 public void SetLayout(ChannelLayout cLayout)
 {
     try
     {
         vsLayout = cLayout;
         GenerateLayout();
     }
     catch (Exception err)
     {
         logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
     }
 }
Ejemplo n.º 6
0
        internal static int get_right_channel(ChannelLayout layout, int stream_id, int prev)
        {
            int i;

            i = (prev < 0) ? 0 : prev + 1;
            for (; i < layout.nb_channels; i++)
            {
                if (layout.mapping[i] == stream_id * 2 + 1)
                {
                    return(i);
                }
            }
            return(-1);
        }
Ejemplo n.º 7
0
        internal static int get_mono_channel(ChannelLayout layout, int stream_id, int prev)
        {
            int i;

            i = (prev < 0) ? 0 : prev + 1;
            for (; i < layout.nb_channels; i++)
            {
                if (layout.mapping[i] == stream_id + layout.nb_coupled_streams)
                {
                    return(i);
                }
            }
            return(-1);
        }
Ejemplo n.º 8
0
        public static Frame CreateWritableAudio(SampleFormat sampleFormat, ChannelLayout channelLayout, int sampleRate, int sampleCount)
        {
            var frame = new Frame
            {
                Format        = (int)sampleFormat,
                ChannelLayout = channelLayout,
                SampleRate    = sampleRate,
                NbSamples     = sampleCount,
            };

            frame.EnsureBuffer();
            frame.MakeWritable();
            return(frame);
        }
Ejemplo n.º 9
0
        internal static int validate_layout(ChannelLayout layout)
        {
            int i, max_channel;

            max_channel = layout.nb_streams + layout.nb_coupled_streams;
            if (max_channel > 255)
            {
                return(0);
            }
            for (i = 0; i < layout.nb_channels; i++)
            {
                if (layout.mapping[i] >= max_channel && layout.mapping[i] != 255)
                {
                    return(0);
                }
            }
            return(1);
        }
Ejemplo n.º 10
0
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("item", Properties.Resources.CasparPlayoutSchemaURL);
            writer.WriteAttributeString("clipname", Clipname);
            writer.WriteAttributeString("videoLayer", VideoLayer.ToString());
            writer.WriteAttributeString("seek", Seek.ToString());
            writer.WriteAttributeString("length", Length.ToString());
            writer.WriteAttributeString("loop", Loop.ToString());
            writer.WriteAttributeString("channel_layout", ChannelLayout.ToString());
            writer.WriteStartElement("transition");
            writer.WriteAttributeString("type", Transition.Type.ToString());
            writer.WriteAttributeString("duration", Transition.Duration.ToString());
            writer.WriteAttributeString("easing", Transition.Easing.ToString());
            writer.WriteAttributeString("pause", Transition.Pause.ToString());
            writer.WriteEndElement();

            writer.WriteEndElement();
        }
Ejemplo n.º 11
0
        public static bool TryParse(string text, out ChannelLayout layout)
        {
            switch (text)
            {
            case "mono": layout = ChannelLayout.Mono;            return(true);

            case "stereo": layout = ChannelLayout.Stereo;          return(true);

            case "downmix": layout = ChannelLayout.StereoDownmix;   return(true);

            case "quad": layout = ChannelLayout.Quad;            return(true);

            case "2.1": layout = ChannelLayout._2_1;            return(true);

            case "2.2": layout = ChannelLayout._2_2;            return(true);

            case "3.0": layout = ChannelLayout._3_0;            return(true);

            case "3.1": layout = ChannelLayout._3_1;            return(true);

            case "4.1": layout = ChannelLayout._4_1;            return(true);

            case "4.0": layout = ChannelLayout._4_0;            return(true);

            case "5.0": layout = ChannelLayout._5_0;            return(true);

            case "5.1": layout = ChannelLayout._5_1;            return(true);

            case "6.0": layout = ChannelLayout._6_0;            return(true);

            case "6.1": layout = ChannelLayout._6_1;            return(true);

            case "7.0": layout = ChannelLayout._7_0;            return(true);

            case "7.1": layout = ChannelLayout._7_1;            return(true);

            case "octagonal": layout = ChannelLayout.Octagonal;       return(true);
            }

            layout = default;

            return(false);
        }
Ejemplo n.º 12
0
 public static int GetChannelCount(this ChannelLayout layout)
 {
     return(CountSetBits((ulong)layout));
 }
Ejemplo n.º 13
0
 // Set Layout
 public void SetLayout(ChannelLayout cLayout)
 {
     try
     {
         vsLayout = cLayout;
         GenerateLayout();
     }
     catch (Exception err)
     {
         logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
     }
 }
Ejemplo n.º 14
0
 /// <summary>
 /// <see cref="av_opt_set_channel_layout(void*, string, long, int)"/>
 /// </summary>
 public void Set(string name, ChannelLayout value, OptionSearchFlags searchFlags = OptionSearchFlags.None) =>
 av_opt_set_channel_layout(_obj, name, (long)value, (int)searchFlags).ThrowIfError();
Ejemplo n.º 15
0
 /// <summary>
 /// Set audio layout for the channel
 /// </summary>
 /// <param name="layout"></param>
 /// <returns></returns>
 public virtual bool SetChannelLayout(ChannelLayout layout)
 {
     return(_amcpTcpParser.SendCommand($"SET {ID} CHANNEL_LAYOUT {layout.ToAmcpValue()}"));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Init with default values
 /// </summary>
 /// <param name="channelLayout">channel layout</param>
 /// <param name="sampleRate">sample rate</param>
 /// <param name="framesPerBuffer">frames per buffer</param>
 public AudioParameters(ChannelLayout channelLayout, int sampleRate, int framesPerBuffer)
 {
     ChannelLayout   = channelLayout;
     SampleRate      = sampleRate;
     FramesPerBuffer = framesPerBuffer;
 }
Ejemplo n.º 17
0
 public void OnAudioStreamStarted(IWebBrowser chromiumWebBrowser, IBrowser browser, int audioStreamId, int channels, ChannelLayout channelLayout, int sampleRate, int framesPerBuffer)
 {
     Console.WriteLine("OnAudioStreamStarted");
 }
Ejemplo n.º 18
0
 public Mp3EncodingParameters(BitRate bitRate, ChannelLayout channelLayout = ChannelLayout.Stereo)
 {
     this.BitRate       = bitRate;
     this.ChannelLayout = channelLayout;
 }
Ejemplo n.º 19
0
 public static long GetAvChannelLayout(ChannelLayout channelLayout)
 {
     return(channelLayout == ChannelLayout.Mono
         ? ffmpeg.AV_CH_LAYOUT_MONO
         : ffmpeg.AV_CH_LAYOUT_STEREO);
 }
Ejemplo n.º 20
0
 void IAudioHandler.OnAudioStreamStarted(IWebBrowser chromiumWebBrowser, IBrowser browser, int audioStreamId, int channels, ChannelLayout channelLayout, int sampleRate, int framesPerBuffer)
 {
     this.channelLayout = channelLayout;
     this.channelCount  = channels;
     this.sampleRate    = sampleRate;
 }
Ejemplo n.º 21
0
 public void EqualToFFmpeg(ChannelLayout channel, long value)
 {
     Assert.Equal(value, (long)channel);
 }
Ejemplo n.º 22
0
 protected override void OnAudioStreamStarted(IWebBrowser chromiumWebBrowser, IBrowser browser, AudioParameters parameters, int channels)
 {
     this.channelLayout = parameters.ChannelLayout;
     this.sampleRate    = parameters.SampleRate;
     this.channelCount  = channels;
 }
Ejemplo n.º 23
0
 public void EqualToMediaFoundation(ChannelLayout channel, long value)
 {
     Assert.Equal(value, (long)channel);
 }