void AddNewStreamer(MediaStreamer newStreamer) { mediaStreamers.Add(newStreamer.ID, newStreamer); // Power options SetPowerOptions(); }
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); } }