Example #1
0
        public static void AddVideoEncodingParametersUsingiOSQuality(ref MediaStreamingRequest rq)
        {
            CreateOrUpdateVideoEncodingParametersFromiOSQuality(ref rq);

            // Override aspect ratio -> insert into custom parameters 
            rq.CustomParameters.AspectRatio = rq.AspectRatio;
        }
Example #2
0
        private static void CreateOrUpdateVideoEncodingParametersFromiOSQuality(ref MediaStreamingRequest rq)
        {
            rq.UseCustomParameters = true;
            int iOSQualityIndex = rq.Quality;

            // Work on the existing Customparameters object, if there is one, else create a new one
            if (rq.CustomParameters == null)
                rq.CustomParameters = new VideoEncodingParameters();
            VideoEncodingParameters vParams = rq.CustomParameters;

            switch (iOSQualityIndex)
            {
                    
#if ACCESSIBILITY_AUDIO
                    /*  ACCESSIBILITY VERSION :
                case 0:
                    vParams.VideoBitRate = "96k";
                    vParams.BitRateDeviation = "64k";
                    vParams.FrameWidth = 192;
                    vParams.FrameHeight = 128;
                    vParams.X264SubQ = 2;
                    vParams.AudioBitRate = "96k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 8;
                    break;
Example #3
0
        /// <summary>
        /// Note that everything should be passed into the constructor that depends upon encoding, since settings public
        /// fields afterwards would result in them not being passed to lower objects that are set up in the constructor.
        /// If the constructor grows really bloated, suggest a separate constructor and Configure() method.
        /// </summary>
        /// <param name="_ID"></param>
        /// <param name="request"></param>
        /// <param name="pathToTools"></param>
        /// <param name="timeToKeepAlive"></param>
        /// <param name="debugAdvanced"></param>
        public MediaStreamer(int _ID, MediaStreamingRequest request, string pathToTools, int timeToKeepAlive, bool debugAdvanced)
        {
            // Store variables
            ID = _ID;
            Request = request;
            SettingsDefaultDebugAdvanced = debugAdvanced;

            // Set up life timer
            lifeTimer = new System.Timers.Timer(1000);
            lifeTimer.AutoReset = true;
            lifeTimer.Elapsed += new ElapsedEventHandler(lifeTimer_Elapsed);
            lifeTimer.Start();

            // Creation date
            CreationDate = DateTime.Now;

            // Status
            AdditionalStatusInfo = "";

            // Create broker - and hook it to runner events
            broker = new SegmentStoreBroker(this.ID.ToString(), request, pathToTools);
            broker.SettingsDefaultDebugAdvanced = this.SettingsDefaultDebugAdvanced;
            broker.DebugMessage += new EventHandler<GenericEventArgs<string>>(broker_DebugMessage);
            broker.DebugMessage2 += new EventHandler<GenericEventArgs<string>>(broker_DebugMessage2);
            broker.DebugMessage3 += new EventHandler<GenericEventArgs<string>>(broker_DebugMessage3);
            broker.DebugMessage4 += new EventHandler<GenericEventArgs<string>>(broker_DebugMessage4);
        }
Example #4
0
        /// <summary>
        /// Note that everything should be passed into the constructor that depends upon encoding, since settings public
        /// fields afterwards would result in them not being passed to lower objects that are set up in the constructor.
        /// If the constructor grows really bloated, suggest a separate constructor and Configure() method.
        /// </summary>
        /// <param name="_ID"></param>
        /// <param name="request"></param>
        /// <param name="pathToTools"></param>
        /// <param name="timeToKeepAlive"></param>
        /// <param name="debugAdvanced"></param>
        public MediaStreamer(int _ID, MediaStreamingRequest request, string pathToTools, int timeToKeepAlive, bool debugAdvanced)
        {
            // Store variables
            ID      = _ID;
            Request = request;
            SettingsDefaultDebugAdvanced = debugAdvanced;

            // Set up life timer
            lifeTimer           = new System.Timers.Timer(1000);
            lifeTimer.AutoReset = true;
            lifeTimer.Elapsed  += new ElapsedEventHandler(lifeTimer_Elapsed);
            lifeTimer.Start();

            // Creation date
            CreationDate = DateTime.Now;

            // Status
            AdditionalStatusInfo = "";

            // Create broker - and hook it to runner events
            broker = new SegmentStoreBroker(this.ID.ToString(), request, pathToTools);
            broker.SettingsDefaultDebugAdvanced = this.SettingsDefaultDebugAdvanced;
            broker.DebugMessage  += new EventHandler <GenericEventArgs <string> >(broker_DebugMessage);
            broker.DebugMessage2 += new EventHandler <GenericEventArgs <string> >(broker_DebugMessage2);
            broker.DebugMessage3 += new EventHandler <GenericEventArgs <string> >(broker_DebugMessage3);
            broker.DebugMessage4 += new EventHandler <GenericEventArgs <string> >(broker_DebugMessage4);
        }
Example #5
0
        public static MediaStreamingRequest RequestWithDesktopProfileLevel(int desktopProfileLevel)
        {
            MediaStreamingRequest newRequest = new MediaStreamingRequest();
            
            newRequest.UseCustomParameters = true;
            newRequest.CustomParameters = videoEncodingParametersFromDesktopLevel(desktopProfileLevel); 

            return newRequest;
        }
 public FFHLSRunner(string pathToTools, SegmentStore store, MediaStreamingRequest mrq)
     : this(pathToTools, store)
 {
     request = mrq;
     EncodingParameters = mrq.CustomParameters;
     if (request.LiveTV)
     {
         EncodingParameters.SegmentDuration = request.ActualSegmentDuration;//LiveTV
     }
     else
     {
         EncodingParameters.SegmentDuration = 4;
     }
 }
        private static void CreateOrUpdateVideoEncodingParametersFromiOSQuality(ref MediaStreamingRequest rq)
        {
            rq.UseCustomParameters = true;
            int iOSQualityIndex = rq.Quality;

            // Work on the existing Customparameters object, if there is one, else create a new one
            if (rq.CustomParameters == null)
                rq.CustomParameters = new VideoEncodingParameters();
            VideoEncodingParameters vParams = rq.CustomParameters;

            switch (iOSQualityIndex)
            {
                    
#if ACCESSIBILITY_AUDIO
                    /*  ACCESSIBILITY VERSION :
                case 0:
                    vParams.VideoBitRate = "96k";
                    vParams.BitRateDeviation = "64k";
                    vParams.FrameWidth = 192;
                    vParams.FrameHeight = 128;
                    vParams.X264SubQ = 2;
                    vParams.AudioBitRate = "96k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 8;
                    break;

                case 1:
                    vParams.VideoBitRate = "96k";
                    vParams.BitRateDeviation = "64k";
                    vParams.FrameWidth = 192;
                    vParams.FrameHeight = 128;
                    vParams.X264SubQ = 2;
                    vParams.AudioBitRate = "96k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 8;
                    break;

                case 2:
                    vParams.VideoBitRate = "96k";
                    vParams.BitRateDeviation = "64k";
                    vParams.FrameWidth = 192;
                    vParams.FrameHeight = 128;
                    vParams.X264SubQ = 2;
                    vParams.AudioBitRate = "128k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 8;
                    break;

                case 3:
                    vParams.VideoBitRate = "164k";
                    vParams.BitRateDeviation = "64k";
                    vParams.FrameWidth = 192;
                    vParams.FrameHeight = 128;
                    vParams.X264SubQ = 2;
                    vParams.AudioBitRate = "148k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 8;
                    break;

                case 4:
                    vParams.VideoBitRate = "256k";
                    vParams.BitRateDeviation = "64k";
                    vParams.FrameWidth = 192;
                    vParams.FrameHeight = 128;
                    vParams.X264SubQ = 2;
                    vParams.AudioBitRate = "256k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 8;
                    break;

                case 5:  // ipad lo
                    vParams.VideoBitRate = "256k";
                    vParams.BitRateDeviation = "64k";
                    vParams.FrameWidth = 192;
                    vParams.FrameHeight = 128;
                    vParams.X264SubQ = 2;
                    vParams.AudioBitRate = "256k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 8;
                    break;


                case 6:  // ipad hi
                    vParams.VideoBitRate = "1400k";
                    vParams.BitRateDeviation = "120k";
                    vParams.FrameWidth = 1024;
                    vParams.FrameHeight = 768;
                    vParams.X264SubQ = 6;
                    vParams.AudioBitRate = "64k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 16;
                    break;
#else
                case 0:
                    vParams.VideoBitRate = "48k";
                    vParams.BitRateDeviation = "24k";
                    vParams.FrameWidth = 192;
                    vParams.FrameHeight = 128;
                    vParams.X264SubQ = 2;
                    vParams.AudioBitRate = "48k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 8;
                    break;

                case 1:
                    vParams.VideoBitRate = "56k";
                    vParams.BitRateDeviation = "32k";
                    vParams.FrameWidth = 192;
                    vParams.FrameHeight = 128;
                    vParams.X264SubQ = 2;
                    vParams.AudioBitRate = "48k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 8;
                    break;

                case 2:
                    vParams.VideoBitRate = "96k";
                    vParams.BitRateDeviation = "64k";
                    vParams.FrameWidth = 240;
                    vParams.FrameHeight = 160;
                    vParams.X264SubQ = 4;
                    vParams.AudioBitRate = "64k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 12;
                    break;

                case 3:
                    vParams.VideoBitRate = "192k";
                    vParams.BitRateDeviation = "120k";
                    vParams.FrameWidth = 240;
                    vParams.FrameHeight = 160;
                    vParams.X264SubQ = 5;
                    vParams.AudioBitRate = "64k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 16;
                    break;

                case 4:
                    vParams.VideoBitRate = "320k";
                    vParams.BitRateDeviation = "120k";
                    vParams.FrameWidth = 480;
                    vParams.FrameHeight = 320;
                    vParams.X264SubQ = 6;
                    vParams.AudioBitRate = "64k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 16;
                    break;

                case 5:  // ipad lo
                    vParams.VideoBitRate = "860k";
                    vParams.BitRateDeviation = "120k";
                    vParams.FrameWidth = 614;
                    vParams.FrameHeight = 460;
                    vParams.X264SubQ = 6;
                    vParams.AudioBitRate = "64k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 16;
                    break;


                case 6:  // ipad hi
                    vParams.VideoBitRate = "1400k";
                    vParams.BitRateDeviation = "120k";
                    vParams.FrameWidth = 1024;
                    vParams.FrameHeight = 768;
                    vParams.X264SubQ = 6;
                    vParams.AudioBitRate = "64k";
                    vParams.AudioSampleRate = "48000";
                    vParams.MotionSearchRange = 16;
                    break;

#endif
              
            }
Example #8
0
        public MediaStreamingResult StartStreamer(MediaStreamingRequest request, string HostName)
        {
            int newStreamerID = newUniqueID();

            // Universal workaround: can be removed once new iOS app introduced that sets the Client Device to 'iphone3g'
            // (desirable to remove it since this will also affect silverlive streaming)
            if (string.IsNullOrEmpty(request.ClientID))
            {
                request.ClientID = "ios";
                request.ClientDevice = "iphone3g";
            }

            try
            {

                // Legacy clients (e.g. iOS client) don't have any custom parameters - set them now based on 'Quality'
                if (!request.UseCustomParameters) // if there are no custom parameters
                {
                    // Create/update video encoding parameters (also transfers Aspect Ratio into child 'encoding parameters' object)
                    MediaStreamingRequest.AddVideoEncodingParametersUsingiOSQuality(ref request);
                }

                /* ************************************************************
                // Override any video encoding parameters from server settings
                 ************************************************************ */
                // 1. Audio Volume
                if (Settings.Default.StreamingVolumePercent != 100)
                    request.CustomParameters.AudioVolumePercent = Convert.ToInt32(Settings.Default.StreamingVolumePercent);

                // 2. Custom FFMPEG template
                if ( (Settings.Default.UseCustomFFMpegTemplate) &  (!string.IsNullOrWhiteSpace(Settings.Default.CustomFFMpegTemplate))  )
                        request.CustomParameters.CustomFFMpegTemplate = Settings.Default.CustomFFMpegTemplate.Trim();

                // 3. iPhone 3G requires profile constraints
                if (request.ClientDevice.ToLowerInvariant() == "iphone3g")
                {
                    request.CustomParameters.X264Level = 30;
                    request.CustomParameters.X264Profile = "baseline";
                }

                // 4. Deinterlace obvious WMC video
                if (
                    (request.InputFile.ToUpper().EndsWith("WTV")) ||
                    (request.InputFile.ToUpper().EndsWith("DVR-MS"))
                    )
                {
                    request.CustomParameters.DeInterlace = true;
                }

                // Create the streamer
                MediaStreamer mediaStreamer = new MediaStreamer(newStreamerID, request, Functions.ToolkitFolder, Settings.Default.MediaStreamerSecondsToKeepAlive, Settings.Default.DebugAdvancedStreaming);
                mediaStreamer.DebugMessage += new EventHandler<FatAttitude.GenericEventArgs<string>>(mediaStreamer_DebugMessage);

                mediaStreamer.AutoDied += new EventHandler(mediaStreamer_AutoDied);
                AddNewStreamer(mediaStreamer);

                Functions.WriteLineToLogFile("MediaStreamer: mediaStreamer object created.");

                // Try streaming
                MediaStreamingResult result = mediaStreamer.Configure();  // this does actually begin transcoding
                result.LiveStreamingIndexPath = "/httplivestream/" + newStreamerID.ToString() + "/index.m3u8";

                // Add streamer ID to result
                result.StreamerID = newStreamerID;

                // Return
                return result;
            }
            catch (Exception e)
            {
                Functions.WriteLineToLogFile("Exception setting up mediaStreaming object:");
                Functions.WriteExceptionToLogFile(e);
                return new MediaStreamingResult(MediaStreamingResultCodes.NamedError, e.Message);
            }
        }
Example #9
0
 public FFHLSRunner(string pathToTools, SegmentStore store, MediaStreamingRequest mrq)
     : this(pathToTools, store)
 {
     request = mrq;
     EncodingParameters = mrq.CustomParameters;
     if (request.LiveTV)
     {
         MaxIncomingDataSize = 20000000; // 20Mb per segment maximum size
     }
     if (request.LiveTV || request.NewLiveTV)
     {
         EncodingParameters.SegmentDuration = request.ActualSegmentDuration;//LiveTV
     }
     else
     {
         EncodingParameters.SegmentDuration = 4;
     }
 }