Beispiel #1
0
        /**
         * Method to manage state changes events.
         */
        private void OnArchiveStateChange(WMENC_ARCHIVE_TYPE type, WMENC_ARCHIVE_STATE state)
        {
            switch (state)
            {
            case WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_RUNNING:
                log.Debug("OnStateChange --> WMENC_ARCHIVE_RUNNING");
                break;

            case WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_PAUSED:
                log.Debug("OnStateChange --> WMENC_ARCHIVE_PAUSED");
                break;

            case WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_STOPPED:
                log.Debug("OnStateChange --> WMENC_ARCHIVE_STOPPED");
                break;
            }

            this.archiveState = state;
            this.archiveStateChangeWaitHandle.Set();
        }
Beispiel #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.
        }
Beispiel #3
0
        /**
         * Method to manage state changes events.
         */
        private void OnArchiveStateChange(WMENC_ARCHIVE_TYPE type, WMENC_ARCHIVE_STATE state)
        {
            switch (state)
            {
                case WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_RUNNING:
                    log.Debug("OnStateChange --> WMENC_ARCHIVE_RUNNING");
                    break;

                case WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_PAUSED:
                    log.Debug("OnStateChange --> WMENC_ARCHIVE_PAUSED");
                    break;

                case WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_STOPPED:
                    log.Debug("OnStateChange --> WMENC_ARCHIVE_STOPPED");
                    break;
            }

            this.archiveState = state;
            this.archiveStateChangeWaitHandle.Set();
        }
Beispiel #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.
        }
Beispiel #5
0
 void enc_OnArchiveStateChange(WMENC_ARCHIVE_TYPE enumArchive, WMENC_ARCHIVE_STATE enumState)
 {
     Console.WriteLine("archive state change : {0}, {1}", enumArchive, enumState);
 }
 void enc_OnArchiveStateChange(WMENC_ARCHIVE_TYPE enumArchive, WMENC_ARCHIVE_STATE enumState)
 {
     Console.WriteLine("archive state change : {0}, {1}", enumArchive, enumState);
 }