コード例 #1
0
        /**
         * Start streaming.
         */
        public DVRBResult Start()
        {
            DVRBResult result = new DVRBResult();

            if ((this.mode & Modes.Live) != 0)
            {
                if (this.livePublishingPoint != null)
                {
                    this.livePublishingPoint.Start();
                    this.liveState = State.Running;
                }
                else
                {
                    log.Error("Start:: Live is Active but not configured.");
                    result = new DVRBResult(DVRBResult.ERROR, "Start:: Live is Active but not configured.");
                }
            }

            if ((this.mode & Modes.OnDemand) != 0)
            {
                if (this.onDemandPublishingPoint != null)
                {
                    this.onDemandPublishingPoint.AllowClientsToConnect = true;
                    this.onDemandPublishingPoint.EnableClientWildcardDirectoryAccess = true;
                    this.onDemandState = State.Running;
                }
                else
                {
                    log.Error("Start:: OnDemand is Active but not configured.");
                    result = new DVRBResult(DVRBResult.ERROR, "Start:: OnDemand is Active but not configured.");
                }
            }

            return(result);
        }
コード例 #2
0
ファイル: Encoder.cs プロジェクト: huangjie18/isabel
        /**
         * Method to stop recording process.
         */
        private DVRBResult StopRecording()
        {
            DVRBResult result = new DVRBResult();

            if (this.archiveState != WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_STOPPED)
            {
                this.archiveStateChangeWaitHandle.Reset();
                result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
                for (int i = 0; i < MaxRetries && !result.Succeeded; i++)
                {
                    log.Debug("[" + i + "] StopRecording stopping record...");
                    this.wmEncoder.Archive(WMENC_ARCHIVE_TYPE.WMENC_ARCHIVE_LOCAL, WMENC_ARCHIVE_OPERATION.WMENC_ARCHIVE_STOP);
                    if (this.archiveStateChangeWaitHandle.WaitOne(archiveWaitTimeout, true) == false)
                    {
                        log.Error("[" + i + "] StopRecording timeout");
                        result = new DVRBResult(DVRBResult.ERROR_TIMEOUT, DVRBResult.ERROR_TIMEOUT_DESC);
                    }
                    else if (this.archiveState != WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_STOPPED)
                    {
                        log.Error("[" + i + "] Archive state != WMENC_ARCHIVE_STOPPED");
                        result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
                    }
                    else
                    {
                        result = new DVRBResult();
                    }
                }
            }

            return(result);
        }
コード例 #3
0
ファイル: Encoder.cs プロジェクト: huangjie18/isabel
        /**
         * Stops the encoding session.
         * @return Method result.
         */
        public DVRBResult Stop()
        {
            DVRBResult result = new DVRBResult();

            log.Debug("Stop encoding");
            try
            {
                if (this.wmEncoder.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPED)
                {
                    this.wmEncoder.Stop();
                    if (this.stateChangeWaitHandle.WaitOne(startStopWaitTimeout, true) == false)
                    {
                        log.Error("Stop timeout");
                        result = new DVRBResult(DVRBResult.ERROR_TIMEOUT, DVRBResult.ERROR_TIMEOUT_DESC);
                    }
                    else if (this.wmEncoder.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPED)
                    {
                        log.Error("Stop state != WMENC_ENCODER_STOPPED");
                        result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
                    }
                }
                else
                {
                    log.Debug("Encoding already stopped.");
                }
            }
            catch (Exception e)
            {
                log.ErrorException("Stop encoding exception:" + e.Message, e);
            }

            return(result);
        }
コード例 #4
0
ファイル: Encoder.cs プロジェクト: huangjie18/isabel
        /**
         * Start encoding session. Make sure you have propperly configured the session before calling this method:
         *  - Configure input with 'SetSource(...)'.
         *  - Configure video and audio encoding params with 'SetVideoParams(...)' and 'SetAudioParams(...)'.
         *  - Configure output port with 'SetOutputPort(...)'
         * @return Method result.
         */
        public DVRBResult Start()
        {
            DVRBResult result = new DVRBResult();

            log.Debug("Start encoding on port " + this.wmEncoder.Broadcast.get_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP));
            try
            {
                if (this.wmEncoder.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_RUNNING)
                {
                    this.sourceGroup.set_Profile(this.wmEncoderProfile);
                    this.wmEncoder.PrepareToEncode(true);
                    this.wmEncoder.Start();
                    if (this.stateChangeWaitHandle.WaitOne(startStopWaitTimeout, true) == false)
                    {
                        log.Error("Start timeout");
                        result = new DVRBResult(DVRBResult.ERROR_TIMEOUT, DVRBResult.ERROR_TIMEOUT_DESC);
                    }
                    else if (this.wmEncoder.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_RUNNING)
                    {
                        log.Error("Start state != WMENC_ENCODER_RUNNING");
                        result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
                    }
                }
                else
                {
                    log.Debug("Encoding already running.");
                }
            }
            catch (Exception e)
            {
                log.ErrorException("Start encoding exception:" + e.Message, e);
            }

            return(result);
        }
コード例 #5
0
ファイル: Encoder.cs プロジェクト: huangjie18/isabel
        /**
         * Enable/disable recording.
         */
        public DVRBResult EnableRecording(bool enable)
        {
            DVRBResult result = new DVRBResult();

            this.enableRecording = enable;                                          // Save state
            if (this.enableRecording)                                               // If enabled
            {
                if (this.archiveState != WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_RUNNING) // if not running
                {
                    this.Start();                                                   // Start running

                    string fileName = this.recordingPath + this.fileNamePrefix;
                    if (this.chopLength > 0) // if chopping
                    {
                        fileName += "_" + this.chopNumber;
                    }

                    result = this.StartRecording(fileName + ".wmv"); // Start recording
                }

                if (this.chopLength > 0) // Start chopper timer
                {
                    this.choppingTimer.Interval = this.chopLength * 1000;
                    this.choppingTimer.Start();
                }
            }
            else
            {
                this.choppingTimer.Stop();     // Stop chopper timer
                result = this.StopRecording(); // Stop recording
            }

            return(result);
        }
コード例 #6
0
ファイル: Encoder.cs プロジェクト: huangjie18/isabel
        /**
         * Method to start recording process.
         * @param fileName : Full fileName name (path + fileName).
         */
        private DVRBResult StartRecording(string fileName)
        {
            DVRBResult result = new DVRBResult();

            if (fileName.Length > 0)
            {
                if (this.wmEncoder.RunState == WMENC_ENCODER_STATE.WMENC_ENCODER_RUNNING)
                {
                    if (this.archiveState != WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_STOPPED)
                    {
                        this.StopRecording();
                    }

                    result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
                    for (int i = 0; i < MaxRetries && !result.Succeeded; i++)
                    {
                        try
                        {
                            log.Debug("[" + i + "] Setting recording fileName = " + fileName);
                            ((IWMEncFile2)this.wmEncoder.File).LocalFileName = fileName;
                        }
                        catch (Exception e)
                        {
                            log.ErrorException("Exception setting fileName params: " + e.Message, e);
                        }

                        this.archiveStateChangeWaitHandle.Reset();
                        log.Debug("[" + i + "] StartRecording starting record...");
                        this.wmEncoder.Archive(WMENC_ARCHIVE_TYPE.WMENC_ARCHIVE_LOCAL, WMENC_ARCHIVE_OPERATION.WMENC_ARCHIVE_START);
                        if (this.archiveStateChangeWaitHandle.WaitOne(archiveWaitTimeout, true) == false)
                        {
                            log.Error("[" + i + "] StartRecording timeout");
                            result = new DVRBResult(DVRBResult.ERROR_TIMEOUT, DVRBResult.ERROR_TIMEOUT_DESC);
                        }
                        else if (this.archiveState != WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_RUNNING)
                        {
                            log.Error("[" + i + "] Archive state != WMENC_ARCHIVE_RUNNING");
                            result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
                        }
                        else
                        {
                            result = new DVRBResult();
                        }
                    }
                }
                else
                {
                    result = new DVRBResult(DVRBResult.ERROR, "Encoder is not running");
                }
            }
            else
            {
                result = new DVRBResult(DVRBResult.ERROR, "Recording is not configured");
            }

            return(result);
        }
コード例 #7
0
        /**
         * Saves NSC announce to specified directory.
         * @param path : Full path + fileName name where the announce fileName is going to be saved (fileName should end with *.nsc extension).
         */
        public DVRBResult PublishNSCAnnounce(string path)
        {
            DVRBResult result = new DVRBResult();

            if (this.livePublishingPoint != null)
            {
                try
                {
                    this.livePublishingPoint.Announce();
                    this.livePublishingPoint.AnnounceToNSCFile(path, true);
                }
                catch (System.Exception e)
                {
                    log.ErrorException("Error creating announce in " + path + " : " + e.Message, e);
                    result = new DVRBResult(DVRBResult.ERROR_EXCEPTION, e.Message);
                }
            }
            else
            {
                result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
            }

            return(result);
        }
コード例 #8
0
ファイル: Encoder.cs プロジェクト: ejgarcia/isabel
        /**
         * Method to stop recording process.
         */
        private DVRBResult StopRecording()
        {
            DVRBResult result = new DVRBResult();
            if (this.archiveState != WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_STOPPED)
            {
                this.archiveStateChangeWaitHandle.Reset();
                result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
                for (int i = 0; i < MaxRetries && !result.Succeeded; i++)
                {
                    log.Debug("[" + i + "] StopRecording stopping record...");
                    this.wmEncoder.Archive(WMENC_ARCHIVE_TYPE.WMENC_ARCHIVE_LOCAL, WMENC_ARCHIVE_OPERATION.WMENC_ARCHIVE_STOP);
                    if (this.archiveStateChangeWaitHandle.WaitOne(archiveWaitTimeout, true) == false)
                    {
                        log.Error("[" + i + "] StopRecording timeout");
                        result = new DVRBResult(DVRBResult.ERROR_TIMEOUT, DVRBResult.ERROR_TIMEOUT_DESC);
                    }
                    else if (this.archiveState != WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_STOPPED)
                    {
                        log.Error("[" + i + "] Archive state != WMENC_ARCHIVE_STOPPED");
                        result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
                    }
                    else
                    {
                        result = new DVRBResult();
                    }
                }
            }

            return result;
        }
コード例 #9
0
ファイル: Encoder.cs プロジェクト: ejgarcia/isabel
        /**
         * Method to start recording process.
         * @param fileName : Full fileName name (path + fileName).
         */
        private DVRBResult StartRecording(string fileName)
        {
            DVRBResult result = new DVRBResult();

            if (fileName.Length > 0)
            {
                if (this.wmEncoder.RunState == WMENC_ENCODER_STATE.WMENC_ENCODER_RUNNING)
                {
                    if (this.archiveState != WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_STOPPED)
                    {
                        this.StopRecording();
                    }

                    result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
                    for (int i = 0; i < MaxRetries && !result.Succeeded; i++)
                    {
                        try
                        {
                            log.Debug("[" + i + "] Setting recording fileName = " + fileName);
                            ((IWMEncFile2)this.wmEncoder.File).LocalFileName = fileName;
                        }
                        catch (Exception e)
                        {
                            log.ErrorException("Exception setting fileName params: " + e.Message, e);
                        }

                        this.archiveStateChangeWaitHandle.Reset();
                        log.Debug("[" + i + "] StartRecording starting record...");
                        this.wmEncoder.Archive(WMENC_ARCHIVE_TYPE.WMENC_ARCHIVE_LOCAL, WMENC_ARCHIVE_OPERATION.WMENC_ARCHIVE_START);
                        if (this.archiveStateChangeWaitHandle.WaitOne(archiveWaitTimeout, true) == false)
                        {
                            log.Error("[" + i + "] StartRecording timeout");
                            result = new DVRBResult(DVRBResult.ERROR_TIMEOUT, DVRBResult.ERROR_TIMEOUT_DESC);
                        }
                        else if (this.archiveState != WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_RUNNING)
                        {
                            log.Error("[" + i + "] Archive state != WMENC_ARCHIVE_RUNNING");
                            result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
                        }
                        else
                        {
                            result = new DVRBResult();
                        }
                    }
                }
                else
                {
                    result = new DVRBResult(DVRBResult.ERROR, "Encoder is not running");
                }
            }
            else
            {
                result = new DVRBResult(DVRBResult.ERROR, "Recording is not configured");
            }

            return result;
        }
コード例 #10
0
ファイル: Encoder.cs プロジェクト: ejgarcia/isabel
        /**
         * Stops the encoding session.
         * @return Method result.
         */
        public DVRBResult Stop()
        {
            DVRBResult result = new DVRBResult();
            log.Debug("Stop encoding");
            try
            {
                if (this.wmEncoder.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPED)
                {
                    this.wmEncoder.Stop();
                    if (this.stateChangeWaitHandle.WaitOne(startStopWaitTimeout, true) == false)
                    {
                        log.Error("Stop timeout");
                        result = new DVRBResult(DVRBResult.ERROR_TIMEOUT, DVRBResult.ERROR_TIMEOUT_DESC);
                    }
                    else if (this.wmEncoder.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPED)
                    {
                        log.Error("Stop state != WMENC_ENCODER_STOPPED");
                        result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
                    }
                }
                else
                {
                    log.Debug("Encoding already stopped.");
                }
            }
            catch (Exception e)
            {
                log.ErrorException("Stop encoding exception:" + e.Message, e);
            }

            return result;
        }
コード例 #11
0
ファイル: Encoder.cs プロジェクト: ejgarcia/isabel
        /**
         * Start encoding session. Make sure you have propperly configured the session before calling this method:
         *  - Configure input with 'SetSource(...)'.
         *  - Configure video and audio encoding params with 'SetVideoParams(...)' and 'SetAudioParams(...)'.
         *  - Configure output port with 'SetOutputPort(...)'
         * @return Method result.
         */
        public DVRBResult Start()
        {
            DVRBResult result = new DVRBResult();
            log.Debug("Start encoding on port " + this.wmEncoder.Broadcast.get_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP));
            try
            {
                if (this.wmEncoder.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_RUNNING)
                {
                    this.sourceGroup.set_Profile(this.wmEncoderProfile);
                    this.wmEncoder.PrepareToEncode(true);
                    this.wmEncoder.Start();
                    if (this.stateChangeWaitHandle.WaitOne(startStopWaitTimeout, true) == false)
                    {
                        log.Error("Start timeout");
                        result = new DVRBResult(DVRBResult.ERROR_TIMEOUT, DVRBResult.ERROR_TIMEOUT_DESC);
                    }
                    else if (this.wmEncoder.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_RUNNING)
                    {
                        log.Error("Start state != WMENC_ENCODER_RUNNING");
                        result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
                    }
                }
                else
                {
                    log.Debug("Encoding already running.");
                }
            }
            catch (Exception e)
            {
                log.ErrorException("Start encoding exception:" + e.Message, e);
            }

            return result;
        }
コード例 #12
0
ファイル: Encoder.cs プロジェクト: ejgarcia/isabel
        /**
         * Enable/disable recording.
         */
        public DVRBResult EnableRecording(bool enable)
        {
            DVRBResult result = new DVRBResult();

            this.enableRecording = enable; // Save state
            if (this.enableRecording) // If enabled
            {
                if (this.archiveState != WMENC_ARCHIVE_STATE.WMENC_ARCHIVE_RUNNING) // if not running
                {
                    this.Start(); // Start running

                    string fileName = this.recordingPath + this.fileNamePrefix;
                    if (this.chopLength > 0) // if chopping
                    {
                        fileName += "_" + this.chopNumber;
                    }

                    result = this.StartRecording(fileName + ".wmv"); // Start recording
                }

                if (this.chopLength > 0) // Start chopper timer
                {
                    this.choppingTimer.Interval = this.chopLength * 1000;
                    this.choppingTimer.Start();
                }
            }
            else
            {
                this.choppingTimer.Stop(); // Stop chopper timer
                result = this.StopRecording(); // Stop recording
            }

            return result;
        }
コード例 #13
0
ファイル: Streaming.cs プロジェクト: ejgarcia/isabel
        /**
         * Start streaming.
         */
        public DVRBResult Start()
        {
            DVRBResult result = new DVRBResult();
            if ((this.mode & Modes.Live) != 0)
            {
                if (this.livePublishingPoint != null)
                {
                    this.livePublishingPoint.Start();
                    this.liveState = State.Running;
                }
                else
                {
                    log.Error("Start:: Live is Active but not configured.");
                    result = new DVRBResult(DVRBResult.ERROR, "Start:: Live is Active but not configured.");
                }
            }

            if ((this.mode & Modes.OnDemand) != 0)
            {
                if (this.onDemandPublishingPoint != null)
                {
                    this.onDemandPublishingPoint.AllowClientsToConnect = true;
                    this.onDemandPublishingPoint.EnableClientWildcardDirectoryAccess = true;
                    this.onDemandState = State.Running;
                }
                else
                {
                    log.Error("Start:: OnDemand is Active but not configured.");
                    result = new DVRBResult(DVRBResult.ERROR, "Start:: OnDemand is Active but not configured.");
                }
            }

            return result;
        }
コード例 #14
0
ファイル: Streaming.cs プロジェクト: ejgarcia/isabel
        /**
         * Saves NSC announce to specified directory.
         * @param path : Full path + fileName name where the announce fileName is going to be saved (fileName should end with *.nsc extension).
         */
        public DVRBResult PublishNSCAnnounce(string path)
        {
            DVRBResult result = new DVRBResult();
            if (this.livePublishingPoint != null)
            {
                try
                {
                    this.livePublishingPoint.Announce();
                    this.livePublishingPoint.AnnounceToNSCFile(path, true);
                }
                catch (System.Exception e)
                {
                    log.ErrorException("Error creating announce in " + path + " : " + e.Message, e);
                    result = new DVRBResult(DVRBResult.ERROR_EXCEPTION, e.Message);
                }
            }
            else
            {
                result = new DVRBResult(DVRBResult.ERROR, DVRBResult.ERROR_DESC);
            }

            return result;
        }