123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- using System.Diagnostics;
- using Vinno.vCloud.FIS.CrossPlatform.Common.LiveVideo;
- namespace Vinno.vCloud.Common.FIS.LiveVideos
- {
- /// <summary>
- /// Configuration for pushing live video.
- /// </summary>
- public abstract class PushConfiguration
- {
- /// <summary>
- /// Push url
- /// </summary>
- public string PushUrl { get; set; }
- /// <summary>
- /// Gets the mode of this configuration.
- /// </summary>
- public PushMode Mode { get; }
- /// <summary>
- /// Get mic hardware path
- /// </summary>
- public string MicHardwarePath { get; set; }
- public ResolutionMode Resolution { get; set; }
- public string PushAppLogPath { get; }
- /// <summary>
- /// Enable preivew image
- /// </summary>
- public bool EnablePreviewImage { get; }
- /// <summary>
- /// Show Preview Image
- /// </summary>
- public bool ShowPreviewImage { get; set; }
- /// <summary>
- /// Should push data
- /// </summary>
- public bool ShouldPushData { get; set; }
- public string CameraHardwarePath { get; set; }
- protected PushConfiguration(PushMode mode, bool enablePreviewImage, bool showPreviewImage)
- {
- Mode = mode;
- EnablePreviewImage = enablePreviewImage;
- ShowPreviewImage = showPreviewImage;
- }
- protected PushConfiguration(PushMode mode, string micHardwarePath, bool enablePreviewImage, bool showPreviewImage)
- {
- Mode = mode;
- MicHardwarePath = micHardwarePath;
- EnablePreviewImage = enablePreviewImage;
- ShowPreviewImage = showPreviewImage;
- }
- protected PushConfiguration(PushMode mode, string micHardwarePath, ResolutionMode rMode, bool enablePreviewImage, bool showPreviewImage)
- {
- Mode = mode;
- MicHardwarePath = micHardwarePath;
- Resolution = rMode;
- EnablePreviewImage = enablePreviewImage;
- ShowPreviewImage = showPreviewImage;
- }
- protected PushConfiguration(PushMode mode, string micHardwarePath, ResolutionMode rMode, string pushAppLogPath = "", bool enablePreviewImage = false, bool showPreviewImage = false)
- {
- Mode = mode;
- MicHardwarePath = micHardwarePath;
- Resolution = rMode;
- EnablePreviewImage = enablePreviewImage;
- ShowPreviewImage = showPreviewImage;
- PushAppLogPath = pushAppLogPath;
- }
- protected string GetModeString()
- {
- return Mode == PushMode.Screen ? "Screen" : "Camera";
- }
- /// <summary>
- /// Convert configuration to a command line arguments.
- /// </summary>
- /// <returns>The command line arguments</returns>
- public abstract string ToArguments();
- }
- /// <inheritdoc />
- /// <summary>
- /// Configuration for pushing live video from desktop.
- /// </summary>
- public class ScreenPushConfiguration : PushConfiguration
- {
- public ScreenPushConfiguration(ResolutionMode rMode, string cameraHardwarePath, string micHardwarePath = "", string pushLogPath = "", bool enablePreviewImage = false, bool showPreviewImage = false)
- : base(PushMode.Screen, micHardwarePath, rMode, pushLogPath, enablePreviewImage, showPreviewImage)
- {
- CameraHardwarePath = cameraHardwarePath;
- }
- /// <inheritdoc />
- /// <summary>
- /// Convert configuration to a command line arguments.
- /// </summary>
- /// <returns>The command line arguments</returns>
- public override string ToArguments()
- {
- return $"\"{PushUrl}\" /p:plp=\"{PushAppLogPath}\" /p:m={GetModeString()} /p:vdp=\"{CameraHardwarePath}\" /p:adp=\"{MicHardwarePath}\" /p:irm=\"{Resolution}\" /p:pid={Process.GetCurrentProcess().Id} /p:epi={EnablePreviewImage} /p:spi={ShowPreviewImage} /p:spd={ShouldPushData}";
- }
- }
- /// <inheritdoc />
- /// <summary>
- /// Configuration for pushing live video from camera.
- /// </summary>
- public class CameraPushConfiguration : PushConfiguration
- {
- /// <summary>
- /// Gets the hardware source of the camera.
- /// </summary>
- public string CameraHardwarePath { get; set; }
- public CameraPushConfiguration(string cameraHardwarePath, ResolutionMode rMode, string micHardwarePath = "", string pushLogPath = "", bool enablePreviewImage = false, bool showPreviewImage = false)
- : base(PushMode.Camera, micHardwarePath, rMode, pushLogPath, enablePreviewImage, showPreviewImage)
- {
- CameraHardwarePath = cameraHardwarePath;
- }
- /// <inheritdoc />
- /// <summary>
- /// Convert configuration to a command line arguments.
- /// </summary>
- /// <returns>The command line arguments</returns>
- public override string ToArguments()
- {
- return $"\"{PushUrl}\" /p:plp=\"{PushAppLogPath}\" /p:m={GetModeString()} /p:vdp=\"{CameraHardwarePath}\" /p:irm=\"{Resolution}\" /p:adp=\"{MicHardwarePath}\" /p:pid={Process.GetCurrentProcess().Id} /p:epi={EnablePreviewImage} /p:spi={ShowPreviewImage} /p:spd={ShouldPushData}";
- }
- }
- public class HardwareResolution
- {
- /// <summary>
- /// Get average frame rate.
- /// </summary>
- public int AverageFrameRate { get; }
- /// <summary>
- /// Get frame height.
- /// </summary>
- public int FrameHeight { get; }
- /// <summary>
- /// Get frame width.
- /// </summary>
- public int FrameWidth { get; }
- public HardwareResolution(int averageFrameRate, int frameHeight, int frameWidth)
- {
- AverageFrameRate = averageFrameRate;
- FrameHeight = frameHeight;
- FrameWidth = frameWidth;
- }
- public override string ToString()
- {
- return $"{AverageFrameRate};{FrameHeight};{FrameWidth}";
- }
- }
- }
|