Esempio n. 1
0
        /**
         * Set source.
         * @param type : source type.
         * @param name : source name.
         */
        public DVRBResult SetSource(ESourceType type, string name)
        {
            try
            {
                string       scheme = string.Empty;
                IWMEncSource source = null;
                switch (type)
                {
                case ESourceType.DeviceAudio:
                    scheme = "Device";
                    if (this.audioSource == null)
                    {
                        this.audioSource = (IWMEncAudioSource)this.sourceGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
                    }

                    source = this.audioSource;
                    break;

                case ESourceType.DeviceVideo:
                    scheme = "Device";
                    if (this.videoSource == null)
                    {
                        this.videoSource = (IWMEncVideoSource)this.sourceGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                    }

                    source = this.videoSource;
                    break;

                case ESourceType.DesktopVideo:
                    scheme = "ScreenCap";
                    if (this.videoSource == null)
                    {
                        this.videoSource = (IWMEncVideoSource)this.sourceGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                    }

                    source = this.videoSource;
                    break;
                }

                log.Debug("Setting " + scheme + " -->" + name);
                source.SetInput(name, scheme, string.Empty);
            }
            catch (Exception e)
            {
                return(new DVRBResult(DVRBResult.ERROR, e.Message));
            }

            return(new DVRBResult());
        }
Esempio n. 2
0
        /**
         * Constructor.
         */
        public Encoder()
        {
            this.enableRecording = false;
            this.chopNumber      = 0;
            this.chopLength      = -1;

            this.choppingTimer                = new System.Timers.Timer();
            this.choppingTimer.Elapsed       += this.OnRecordTimeElapsed;
            this.archiveState                 = WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_STOPPED;
            this.stateChangeWaitHandle        = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset, string.Empty);
            this.archiveStateChangeWaitHandle = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset, string.Empty);

            // Audio and video sources
            this.audioSource = null;
            this.videoSource = null;

            // Windows Media Encoder
            this.wmEncoder        = new WMEncoderClass();
            this.sourceGroup      = (IWMEncSourceGroup2)this.wmEncoder.SourceGroupCollection.Add("SG_1");
            this.wmEncoderProfile = new WMEncProfile2();

            // For now, we only listen these events
            this.wmEncoder.OnStateChange        += this.OnStateChange;
            this.wmEncoder.OnError              += this.OnError;
            this.wmEncoder.OnArchiveStateChange += this.OnArchiveStateChange;

            // Set recording props.
            this.wmEncoder.EnableAutoArchive = false;
            this.wmEncoder.AutoIndex         = false;

            // Set default profile values
            this.wmEncoderProfile.ValidateMode = true;
            this.wmEncoderProfile.ProfileName  = "Windows Media Encoder Profile";
            this.wmEncoderProfile.ContentType  = 17;                                        // Audio + Video
            this.wmEncoderAudience             = this.wmEncoderProfile.AddAudience(100000); // Initial bitrate = 100 kbps, will change automatically
            // when user sets video and audio params.
        }
Esempio n. 3
0
        /**
         * Set source.
         * @param type : source type.
         * @param name : source name.
         */
        public DVRBResult SetSource(ESourceType type, string name)
        {
            try
            {
                string scheme = string.Empty;
                IWMEncSource source = null;
                switch (type)
                {
                    case ESourceType.DeviceAudio:
                        scheme = "Device";
                        if (this.audioSource == null)
                        {
                            this.audioSource = (IWMEncAudioSource)this.sourceGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
                        }

                        source = this.audioSource;
                        break;
                    case ESourceType.DeviceVideo:
                        scheme = "Device";
                        if (this.videoSource == null)
                        {
                            this.videoSource = (IWMEncVideoSource)this.sourceGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                        }

                        source = this.videoSource;
                        break;
                    case ESourceType.DesktopVideo:
                        scheme = "ScreenCap";
                        if (this.videoSource == null)
                        {
                            this.videoSource = (IWMEncVideoSource)this.sourceGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                        }

                        source = this.videoSource;
                        break;
                }

                log.Debug("Setting " + scheme + " -->" + name);
                source.SetInput(name, scheme, string.Empty);
            }
            catch (Exception e)
            {
                return new DVRBResult(DVRBResult.ERROR, e.Message);
            }

            return new DVRBResult();
        }
Esempio n. 4
0
        /**
         * Constructor.
         */
        public Encoder()
        {
            this.enableRecording = false;
            this.chopNumber = 0;
            this.chopLength = -1;

            this.choppingTimer = new System.Timers.Timer();
            this.choppingTimer.Elapsed += this.OnRecordTimeElapsed;
            this.archiveState = WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_STOPPED;
            this.stateChangeWaitHandle = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset, string.Empty);
            this.archiveStateChangeWaitHandle = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset, string.Empty);

            // Audio and video sources
            this.audioSource = null;
            this.videoSource = null;

            // Windows Media Encoder
            this.wmEncoder = new WMEncoderClass();
            this.sourceGroup = (IWMEncSourceGroup2)this.wmEncoder.SourceGroupCollection.Add("SG_1");
            this.wmEncoderProfile = new WMEncProfile2();

            // For now, we only listen these events
            this.wmEncoder.OnStateChange += this.OnStateChange;
            this.wmEncoder.OnError += this.OnError;
            this.wmEncoder.OnArchiveStateChange += this.OnArchiveStateChange;

            // Set recording props.
            this.wmEncoder.EnableAutoArchive = false;
            this.wmEncoder.AutoIndex = false;

            // Set default profile values
            this.wmEncoderProfile.ValidateMode = true;
            this.wmEncoderProfile.ProfileName = "Windows Media Encoder Profile";
            this.wmEncoderProfile.ContentType = 17; // Audio + Video
            this.wmEncoderAudience = this.wmEncoderProfile.AddAudience(100000); // Initial bitrate = 100 kbps, will change automatically
            // when user sets video and audio params.
        }