void ReleaseDesignerOutlets() { if (HandUpImage != null) { HandUpImage.Dispose(); HandUpImage = null; } if (MuteVideoView != null) { MuteVideoView.Dispose(); MuteVideoView = null; } if (MuteAudioView != null) { MuteAudioView.Dispose(); MuteAudioView = null; } if (VideoContainer != null) { VideoContainer.Dispose(); VideoContainer = null; } if (View != null) { View.Dispose(); View = null; } }
public void ShowVideo(Media.MediaUri uri, Media.VideoEncoderConfiguration encoder, Media.AudioEncoderConfiguration audio) { try { _videoWindow = new VideoContainer(); DeviceEnvironment environment = ContextController.GetDeviceEnvironment(); int messageTimeout = environment.Timeouts.Message; Media.TransportProtocol protocol = GetTransportProtocol(); VideoUtils.AdjustVideo( _videoWindow, environment.Credentials.UserName, environment.Credentials.Password, messageTimeout, protocol, Media.StreamType.RTPUnicast, uri, encoder); _videoWindow.KEEPALIVE = true; _videoWindow.DebugPage = true; _videoWindow.OpenWindow(audio != null); Invoke(new Action(() => { btnGetStreams.Text = "Stop Video"; })); } catch { _videoWindow.DebugPage = false; _videoWindow = null; throw; } }
public void ShowVideo(Onvif.MediaUri uri, Onvif.VideoEncoderConfiguration encoder) { try { _videoWindow = new VideoContainer(); DeviceEnvironment environment = ContextController.GetDeviceEnvironment(); int messageTimeout = environment.Timeouts.Message; VideoUtils.AdjustVideo( _videoWindow, environment.Credentials.UserName, environment.Credentials.Password, messageTimeout, Onvif.TransportProtocol.UDP, Onvif.StreamType.RTPUnicast, uri, encoder); _videoWindow.KEEPALIVE = true; _videoWindow.OpenWindow(false); Invoke(new Action(() => { btnVideo.Text = "Stop Video"; })); } catch { _videoWindow = null; throw; } }
public static string GetVideoContainer(VideoContainer container) { switch (container) { case VideoContainer.Unknown: return(null); case VideoContainer.Avi: return("avi"); case VideoContainer.Matroska: return("matroska"); case VideoContainer.Asf: return("asf"); case VideoContainer.Mp4: return("mp4"); case VideoContainer.Mpeg2Ps: return("mpeg"); case VideoContainer.Mpeg2Ts: return("mpegts"); case VideoContainer.Mpeg1: return("mpegvideo"); case VideoContainer.Flv: return("flv"); case VideoContainer.Wtv: return("wtv"); case VideoContainer.Ogg: return("ogg"); case VideoContainer.Gp3: return("3gp"); case VideoContainer.M2Ts: return("mpegts"); case VideoContainer.Hls: return("segment"); case VideoContainer.Rtp: return("rtp"); case VideoContainer.Rtsp: return("rtsp"); case VideoContainer.RealMedia: return("rm"); } return(null); }
/// <summary> /// Gets video form. /// </summary> /// <returns></returns> public IVideoForm GetVideoForm() { if (_videoWindow == null) { VideoContainer wnd = new VideoContainer(); _videoWindow = wnd; } return(_videoWindow); }
/// <summary> /// Gets video form. /// </summary> /// <returns></returns> public Tests.Definitions.Interfaces.IVideoForm GetVideoForm() { if (_videoWindow == null) { VideoContainer wnd = new VideoContainer(); VideoContainer.SilentMode = true; _videoWindow = wnd; } return(_videoWindow); }
public static void VW(object param) { VideoStreamForm vsf = (VideoStreamForm)param; try { lock (vsf.eventConsumer) { vsf.streamUri = vsf.getStreamUri(vsf.streamSetup, vsf.profile.token); } } catch (Exception ex) { vsf.exception = ex; } if (vsf.exception == null) { IVideoForm videoForm = new VideoContainer(); videoForm.NICIndex = vsf.NICIndex; VideoUtils.AdjustVideo( videoForm, vsf.username, vsf.password, vsf.messageTimeout, vsf.streamSetup.Transport.Protocol, vsf.streamSetup.Stream, vsf.streamUri, vsf.profile.VideoEncoderConfiguration); bool VideoIsOpened = false; try { VideoIsOpened = true; videoForm.EventSink = vsf; videoForm.OpenWindow(false); ((AutoResetEvent)vsf.eventOpened).Set(); vsf.signalCloseWindow.WaitOne(); videoForm.CloseWindow(); VideoIsOpened = false; } catch (Exception ex) { vsf.exception = ex; } finally { if (VideoIsOpened) { videoForm.CloseWindow(); } videoForm = null; } } ((ManualResetEvent)vsf.eventWorkEnded).Set(); ((AutoResetEvent)vsf.signalCloseWindow).Set(); }
public static bool IsSubtitleSupportedByContainer(SubtitleCodec codec, VideoContainer sourceContainer, VideoContainer targetContainer) { if (targetContainer != VideoContainer.Unknown && sourceContainer == targetContainer) { return(true); } if (targetContainer == VideoContainer.Matroska && (codec == SubtitleCodec.VobSub || codec == SubtitleCodec.Ass || codec == SubtitleCodec.MicroDvd || codec == SubtitleCodec.Smi || codec == SubtitleCodec.Srt || codec == SubtitleCodec.Ssa || codec == SubtitleCodec.SubView)) { return(true); } if (targetContainer == VideoContainer.Mpeg2Ps && codec == SubtitleCodec.VobSub) { return(true); } if (targetContainer == VideoContainer.Mpeg2Ts && (codec == SubtitleCodec.DvbSub || codec == SubtitleCodec.DvbTxt)) { return(true); } if (targetContainer == VideoContainer.Avi && codec == SubtitleCodec.Srt) { return(true); } if (targetContainer == VideoContainer.Asf && codec == SubtitleCodec.Srt) { return(true); } if (targetContainer == VideoContainer.Hls && codec == SubtitleCodec.MovTxt) { return(true); } if (targetContainer == VideoContainer.M2Ts && codec == SubtitleCodec.VobSub) { return(true); } if (targetContainer == VideoContainer.Mp4 && codec == SubtitleCodec.MovTxt) { return(true); } if (targetContainer == VideoContainer.Hls && codec == SubtitleCodec.WebVtt) { return(true); } if (targetContainer == VideoContainer.Mpeg1 && codec == SubtitleCodec.VobSub) { return(true); } return(false); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if ((e != null) && (e.Parameter != null)) { VideoContainer.SetMediaPlayer(_context.Player); if (e.Parameter is Video) { _context.Video = e.Parameter as Video; VideoContainer.TransportControls.IsSkipBackwardButtonVisible = true; VideoContainer.TransportControls.IsSkipBackwardEnabled = true; VideoContainer.TransportControls.IsSkipForwardButtonVisible = true; VideoContainer.TransportControls.IsSkipForwardEnabled = true; VideoContainer.TransportControls.IsSeekBarVisible = true; VideoContainer.TransportControls.IsSeekEnabled = true; } else if (e.Parameter is LiveStream) { _context.LiveStream = e.Parameter as LiveStream; VideoContainer.TransportControls.IsSkipBackwardButtonVisible = false; VideoContainer.TransportControls.IsSkipBackwardEnabled = false; VideoContainer.TransportControls.IsSkipForwardButtonVisible = false; VideoContainer.TransportControls.IsSkipForwardEnabled = false; VideoContainer.TransportControls.IsSeekBarVisible = false; VideoContainer.TransportControls.IsSeekEnabled = false; } if (Utilities.SystemInformationManager.IsTenFootExperience) { VideoContainer.TransportControls.IsFullWindowEnabled = false; VideoContainer.TransportControls.IsZoomButtonVisible = false; VideoContainer.TransportControls.IsFullWindowButtonVisible = false; VideoContainer.TransportControls.IsVolumeButtonVisible = false; } _context.Initialize(); Window.Current.CoreWindow.KeyUp += CoreWindow_KeyUp; if (!Utilities.SystemInformationManager.IsTenFootExperience) { VideoContainer.DoubleTapped += MediaPlayer_DoubleTapped; ActivateDisplay(); } } }
public static string GetVideoExtension(VideoContainer container) { switch (container) { case VideoContainer.Asf: return("wmv"); case VideoContainer.Avi: return("avi"); case VideoContainer.Flv: return("flv"); case VideoContainer.Gp3: return("3gp"); case VideoContainer.Matroska: return("mkv"); case VideoContainer.Mp4: return("mp4v"); case VideoContainer.M2Ts: return("m2ts"); case VideoContainer.Mpeg2Ps: return("mpg"); case VideoContainer.Mpeg2Ts: return("ts"); case VideoContainer.Mpeg1: return("mpeg"); case VideoContainer.MJpeg: return("mjpeg"); case VideoContainer.Ogg: return("ogg"); case VideoContainer.RealMedia: return("rm"); case VideoContainer.Wtv: return("wtv"); } return("mptv"); }
private void btnGetStreams_Click(object sender, EventArgs e) { try { if (_videoWindow == null) { OnPlayVideo(); } else { _videoWindow.CloseWindow(); _videoWindow = null; btnGetStreams.Text = "Play Video"; } } catch (Exception ex) { ShowError(ex); } }
public static List <string> ResolveVideoProfile(VideoContainer container, VideoCodec videoCodec, AudioCodec audioCodec, EncodingProfile h264Profile, float?h264Level, float?fps, int?width, int?height, long?videoBitrate, long?audioBitrate, Timestamp timestampType) { List <string> valuesProfiles = new List <string>(); if (container == VideoContainer.Asf) { if ((videoCodec == VideoCodec.Wmv && audioCodec == AudioCodec.Unknown) || (videoCodec == VideoCodec.Wmv && audioCodec == AudioCodec.Mp3) || (audioCodec == AudioCodec.Wma || audioCodec == AudioCodec.WmaPro)) { if (width <= 176 && height <= 144) { if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Wma) { if (audioBitrate != 0 && audioBitrate < 193) { valuesProfiles.Add("WMVSPLL_BASE"); //Fallback valuesProfiles.Add("WMVMED_BASE"); } else { valuesProfiles.Add("WMVMED_FULL"); } } else if (audioCodec == AudioCodec.Mp3) { valuesProfiles.Add("WMVSPLL_MP3"); } else { valuesProfiles.Add("WMVMED_PRO"); } } else if (width <= 352 && height <= 288) { if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Wma) { if (audioBitrate > 0 && audioBitrate < 193) { valuesProfiles.Add("WMVSPML_BASE"); //Fallback valuesProfiles.Add("WMVMED_BASE"); } else { valuesProfiles.Add("WMVMED_FULL"); } } else if (audioCodec == AudioCodec.Mp3) { valuesProfiles.Add("WMVSPML_MP3"); } else { valuesProfiles.Add("WMVMED_PRO"); } } else if (width <= 720 && height <= 576) { if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Wma) { if (audioBitrate > 0 && audioBitrate < 193) { valuesProfiles.Add("WMVMED_BASE"); } else { valuesProfiles.Add("WMVMED_FULL"); } } else { valuesProfiles.Add("WMVMED_PRO"); } } else if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Wma) { if (audioBitrate > 0 && audioBitrate < 193) { valuesProfiles.Add("WMVHIGH_BASE"); } else { valuesProfiles.Add("WMVHIGH_FULL"); } } else { valuesProfiles.Add("WMVHIGH_PRO"); } } else if (videoCodec == VideoCodec.Vc1) { if (width <= 720 && height <= 576) { valuesProfiles.Add("VC1_ASF_AP_L1_WMA"); } else if (width <= 1280 && height <= 720) { valuesProfiles.Add("VC1_ASF_AP_L2_WMA"); } else if (width <= 1920 && height <= 1080) { valuesProfiles.Add("VC1_ASF_AP_L3_WMA"); } } else if (videoCodec == VideoCodec.Mpeg1 || videoCodec == VideoCodec.Mpeg2) { valuesProfiles.Add("DVR_MS"); } else { throw new Exception("ASF video file does not match any supported DLNA profile"); } } else if (container == VideoContainer.Avi) { valuesProfiles.Add("AVI"); } else if (container == VideoContainer.Matroska) { valuesProfiles.Add("MATROSKA"); } else if (container == VideoContainer.Mp4) { bool isHD = false; if (Convert.ToInt32(width) > 720 || Convert.ToInt32(height) > 576) { isHD = true; } long bitrate = 0; if (videoBitrate > 0 && audioBitrate > 0) { bitrate = videoBitrate.Value + audioBitrate.Value; } if (videoCodec == VideoCodec.H264) { if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Ac3 || audioCodec == AudioCodec.EAc3) { if (h264Profile == EncodingProfile.Baseline) { if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000) { valuesProfiles.Add("AVC_MP4_BL_CIF30_AC3"); } } if (isHD) { valuesProfiles.Add("AVC_MP4_MP_HD_AC3"); } //Main profile and fallback valuesProfiles.Add("AVC_MP4_MP_SD_AC3"); } else if (audioCodec == AudioCodec.Mp3) { if (isHD) { valuesProfiles.Add("AVC_MP4_MP_HD_MPEG1_L3"); } valuesProfiles.Add("AVC_MP4_MP_SD_MPEG1_L3"); } else if (audioCodec == AudioCodec.Lpcm) { valuesProfiles.Add("AVC_MP4_LPCM"); } if (isHD == false) { if (audioCodec == AudioCodec.Aac) { if (h264Profile == EncodingProfile.Baseline) { if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000) { if (bitrate > 0 && bitrate <= 520) { valuesProfiles.Add("AVC_MP4_BL_CIF30_AAC_520"); } else if (bitrate > 0 && bitrate <= 940) { valuesProfiles.Add("AVC_MP4_BL_CIF30_AAC_940"); } //Fallback valuesProfiles.Add("AVC_MP4_BL_CIF30_AAC_MULT5"); } else { if (h264Level == 3.0 && bitrate > 0 && bitrate <= 5000) { valuesProfiles.Add("AVC_MP4_BL_L3L_SD_AAC"); } else if (h264Level <= 3.1 && bitrate > 0 && bitrate <= 15000) { valuesProfiles.Add("AVC_MP4_BL_L31_HD_AAC"); } } } //Main profile and fallback valuesProfiles.Add("AVC_MP4_MP_SD_AAC_MULT5"); } else if (audioCodec == AudioCodec.Dts) { valuesProfiles.Add("AVC_MP4_MP_SD_DTS"); } else if (audioCodec == AudioCodec.DtsHd) { valuesProfiles.Add("AVC_MP4_MP_SD_DTSHD"); } } else if (Convert.ToInt32(width) <= 1280 && Convert.ToInt32(height) <= 720) { if (audioCodec == AudioCodec.Aac) { if (h264Profile == EncodingProfile.Baseline) { if (h264Level <= 3.1 && bitrate > 0 && bitrate <= 15000) { valuesProfiles.Add("AVC_MP4_BL_L31_HD_AAC"); } else if (h264Level <= 3.2 && bitrate > 0 && bitrate <= 21000) { valuesProfiles.Add("AVC_MP4_BL_L32_HD_AAC"); } } //Main profile and fallback valuesProfiles.Add("AVC_MP4_MP_HD_720p_AAC"); } else if (audioCodec == AudioCodec.Dts) { valuesProfiles.Add("AVC_MP4_HP_HD_DTS"); } else if (audioCodec == AudioCodec.DtsHd) { valuesProfiles.Add("AVC_MP4_HP_HD_DTSHD"); } } else if (Convert.ToInt32(width) <= 1920 && Convert.ToInt32(height) <= 1080) { if (audioCodec == AudioCodec.Aac) { if (h264Profile == EncodingProfile.High || h264Profile == EncodingProfile.High10 || h264Profile == EncodingProfile.High422 || h264Profile == EncodingProfile.High444) { valuesProfiles.Add("AVC_MP4_HP_HD_AAC"); } //Main profile and fallback valuesProfiles.Add("AVC_MP4_MP_HD_1080i_AAC"); } else if (audioCodec == AudioCodec.Dts) { valuesProfiles.Add("AVC_MP4_HP_HD_DTS"); } else if (audioCodec == AudioCodec.DtsHd) { valuesProfiles.Add("AVC_MP4_HP_HD_DTSHD"); } } } else if (videoCodec == VideoCodec.H265) { valuesProfiles.Add("HEVC_MP4"); } else if (videoCodec == VideoCodec.MsMpeg4 || videoCodec == VideoCodec.Mpeg4) { if (Convert.ToInt32(width) <= 720 && Convert.ToInt32(height) <= 576) { if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Aac) { valuesProfiles.Add("MPEG4_P2_MP4_ASP_AAC"); } else if (audioCodec == AudioCodec.Ac3 || audioCodec == AudioCodec.Mp3) { valuesProfiles.Add("MPEG4_P2_MP4_NDSD"); } } else if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Aac) { valuesProfiles.Add("MPEG4_P2_MP4_SP_L6_AAC"); } } else if (videoCodec == VideoCodec.H263 && audioCodec == AudioCodec.Aac) { valuesProfiles.Add("MPEG4_H263_MP4_P0_L10_AAC"); } else { throw new Exception("MP4 video file does not match any supported DLNA profile"); } } else if (container == VideoContainer.Mpeg2Ps) { valuesProfiles.Add("MPEG_PS_PAL"); valuesProfiles.Add("MPEG_PS_NTSC"); } else if (container == VideoContainer.Mpeg1) { valuesProfiles.Add("MPEG1"); } else if (container == VideoContainer.Mpeg2Ts || container == VideoContainer.M2Ts) { bool isHD = false; if (Convert.ToInt32(width) > 720 || Convert.ToInt32(height) > 576) { isHD = true; } if (videoCodec == VideoCodec.Mpeg2) { if (isHD) { if (timestampType == Timestamp.None) { valuesProfiles.Add("MPEG_TS_HD_EU_ISO"); valuesProfiles.Add("MPEG_TS_HD_NA_ISO"); valuesProfiles.Add("MPEG_TS_HD_KO_ISO"); } else if (timestampType == Timestamp.Valid) { valuesProfiles.Add("MPEG_TS_HD_EU_T"); valuesProfiles.Add("MPEG_TS_HD_NA_T"); valuesProfiles.Add("MPEG_TS_HD_KO_T"); if (audioCodec == AudioCodec.Aac) { valuesProfiles.Add("MPEG_TS_JP_T"); } } else { valuesProfiles.Add("MPEG_TS_HD_EU"); valuesProfiles.Add("MPEG_TS_HD_NA"); valuesProfiles.Add("MPEG_TS_HD_KO"); } } else { if (timestampType == Timestamp.None) { valuesProfiles.Add("MPEG_TS_SD_EU_ISO"); valuesProfiles.Add("MPEG_TS_SD_NA_ISO"); valuesProfiles.Add("MPEG_TS_SD_KO_ISO"); } else if (timestampType == Timestamp.Valid) { valuesProfiles.Add("MPEG_TS_SD_EU_T"); valuesProfiles.Add("MPEG_TS_SD_NA_T"); valuesProfiles.Add("MPEG_TS_SD_KO_T"); if (audioCodec == AudioCodec.Aac) { valuesProfiles.Add("MPEG_TS_JP_T"); } } else { valuesProfiles.Add("MPEG_TS_SD_EU"); valuesProfiles.Add("MPEG_TS_SD_NA"); valuesProfiles.Add("MPEG_TS_SD_KO"); } } } else if (videoCodec == VideoCodec.H264) { if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Ac3 || audioCodec == AudioCodec.EAc3) { if (timestampType == Timestamp.None) { if (h264Profile == EncodingProfile.Baseline) { if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 384) { valuesProfiles.Add("AVC_TS_BL_CIF15_AC3_ISO"); } else if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000) { valuesProfiles.Add("AVC_TS_BL_CIF30_AC3_ISO"); } } else if (h264Profile == EncodingProfile.High || h264Profile == EncodingProfile.High10 || h264Profile == EncodingProfile.High422 || h264Profile == EncodingProfile.High444) { if (isHD) { valuesProfiles.Add("AVC_TS_HP_HD_AC3_ISO"); } else { valuesProfiles.Add("AVC_TS_HP_SD_AC3_ISO"); } } //Main profile and fallbacks if (isHD) { valuesProfiles.Add("AVC_TS_MP_HD_AC3_ISO"); } else { valuesProfiles.Add("AVC_TS_MP_SD_AC3_ISO"); } } else if (timestampType == Timestamp.Valid) { if (h264Profile == EncodingProfile.Baseline) { if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 384) { valuesProfiles.Add("AVC_TS_BL_CIF15_AC3_T"); } else if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000) { valuesProfiles.Add("AVC_TS_BL_CIF30_AC3_T"); } } else if (h264Profile == EncodingProfile.High || h264Profile == EncodingProfile.High10 || h264Profile == EncodingProfile.High422 || h264Profile == EncodingProfile.High444) { if (isHD) { valuesProfiles.Add("AVC_TS_HP_HD_AC3_T"); } else { valuesProfiles.Add("AVC_TS_HP_SD_AC3_T"); } } //Main profile and fallbacks if (isHD) { valuesProfiles.Add("AVC_TS_MP_HD_AC3_T"); } else { valuesProfiles.Add("AVC_TS_MP_SD_AC3_T"); } } else { if (h264Profile == EncodingProfile.Baseline) { if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 384) { valuesProfiles.Add("AVC_TS_BL_CIF15_AC3"); } else if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000) { valuesProfiles.Add("AVC_TS_BL_CIF30_AC3"); } } else if (h264Profile == EncodingProfile.High || h264Profile == EncodingProfile.High10 || h264Profile == EncodingProfile.High422 || h264Profile == EncodingProfile.High444) { if (isHD) { valuesProfiles.Add("AVC_TS_HP_HD_AC3"); } else { valuesProfiles.Add("AVC_TS_HP_SD_AC3"); } } //Main profile and fallbacks if (isHD) { valuesProfiles.Add("AVC_TS_MP_HD_AC3"); } else { valuesProfiles.Add("AVC_TS_MP_SD_AC3"); } } } else if (audioCodec == AudioCodec.Lpcm) { if (fps >= 59) { valuesProfiles.Add("AVC_TS_HD_60_LPCM_T"); } //Fallback valuesProfiles.Add("AVC_TS_HD_50_LPCM_T"); } else if (audioCodec == AudioCodec.Dts) { if (timestampType == Timestamp.None) { valuesProfiles.Add("AVC_TS_HD_DTS_ISO"); } else { valuesProfiles.Add("AVC_TS_HD_DTS_T"); } } else if (audioCodec == AudioCodec.DtsHd) { if (timestampType == Timestamp.None) { valuesProfiles.Add("AVC_TS_DTSHD_MA_ISO"); } else { valuesProfiles.Add("AVC_TS_DTSHD_MA_T"); } } else if (audioCodec == AudioCodec.Mp2) { if (timestampType == Timestamp.None) { if (isHD) { valuesProfiles.Add("AVC_TS_HP_HD_MPEG1_L2_ISO"); } else { valuesProfiles.Add("AVC_TS_HP_SD_MPEG1_L2_ISO"); } } else { if (isHD) { valuesProfiles.Add("AVC_TS_HP_HD_MPEG1_L2_T"); } else { valuesProfiles.Add("AVC_TS_HP_SD_MPEG1_L2_T"); } } } else if (audioCodec == AudioCodec.Aac) { if (timestampType == Timestamp.None) { if (h264Profile == EncodingProfile.Baseline) { if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 384) { valuesProfiles.Add("AVC_TS_BL_CIF15_AAC_MULT5_ISO"); } else if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000) { valuesProfiles.Add("AVC_TS_BL_CIF30_AAC_MULT5_ISO"); } } //Main profile and fallbacks if (isHD) { valuesProfiles.Add("AVC_TS_MP_HD_AAC_MULT5_ISO"); } else { valuesProfiles.Add("AVC_TS_MP_SD_AAC_MULT5_ISO"); } } else if (timestampType == Timestamp.Valid) { if (h264Profile == EncodingProfile.Baseline) { if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 384) { valuesProfiles.Add("AVC_TS_BL_CIF15_AAC_MULT5_T"); } else if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000) { valuesProfiles.Add("AVC_TS_BL_CIF30_AAC_MULT5_T"); } } //Main profile and fallbacks if (isHD) { valuesProfiles.Add("AVC_TS_MP_HD_AAC_MULT5_T"); } else { valuesProfiles.Add("AVC_TS_MP_SD_AAC_MULT5_T"); } } else { if (h264Profile == EncodingProfile.Baseline) { if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 384) { valuesProfiles.Add("AVC_TS_BL_CIF15_AAC_MULT5"); } else if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000) { valuesProfiles.Add("AVC_TS_BL_CIF30_AAC_MULT5"); } } //Main profile and fallbacks if (isHD) { valuesProfiles.Add("AVC_TS_MP_HD_AAC_MULT5"); } else { valuesProfiles.Add("AVC_TS_MP_SD_AAC_MULT5"); } } } else if (audioCodec == AudioCodec.Mp3) { if (timestampType == Timestamp.None) { if (h264Profile == EncodingProfile.Baseline) { if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000) { valuesProfiles.Add("AVC_TS_BL_CIF30_MPEG1_L3_ISO"); } } //Main profile and fallbacks if (isHD) { valuesProfiles.Add("AVC_TS_MP_HD_MPEG1_L3_ISO"); } else { valuesProfiles.Add("AVC_TS_MP_SD_MPEG1_L3_ISO"); } } else if (timestampType == Timestamp.Valid) { if (h264Profile == EncodingProfile.Baseline) { if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000) { valuesProfiles.Add("AVC_TS_BL_CIF30_MPEG1_L3_T"); } } //Main profile and fallbacks if (isHD) { valuesProfiles.Add("AVC_TS_MP_HD_MPEG1_L3_T"); } else { valuesProfiles.Add("AVC_TS_MP_SD_MPEG1_L3_T"); } } else { if (h264Profile == EncodingProfile.Baseline) { if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000) { valuesProfiles.Add("AVC_TS_BL_CIF30_MPEG1_L3"); } } //Main profile and fallbacks if (isHD) { valuesProfiles.Add("AVC_TS_MP_HD_MPEG1_L3"); } else { valuesProfiles.Add("AVC_TS_MP_SD_MPEG1_L3"); } } } } else if (videoCodec == VideoCodec.Vc1) { if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Ac3) { if (isHD) { valuesProfiles.Add("VC1_TS_AP_L2_AC3_ISO"); } else { valuesProfiles.Add("VC1_TS_AP_L1_AC3_ISO"); } } else if (audioCodec == AudioCodec.Dts) { if (timestampType == Timestamp.None) { valuesProfiles.Add("VC1_TS_HD_DTS_ISO"); } else { valuesProfiles.Add("VC1_TS_HD_DTS_T"); } } else if (audioCodec == AudioCodec.DtsHd) { if (timestampType == Timestamp.None) { valuesProfiles.Add("VC1_TS_HD_DTSHD_MA_ISO"); } else { valuesProfiles.Add("VC1_TS_HD_DTSHD_MA_T"); } } else { if (isHD) { valuesProfiles.Add("VC1_TS_AP_L2_AC3_ISO"); } else { valuesProfiles.Add("VC1_TS_AP_L1_AC3_ISO"); } } } else if (videoCodec == VideoCodec.H265) { valuesProfiles.Add("HEVC_TS"); } else if (videoCodec == VideoCodec.MsMpeg4 || videoCodec == VideoCodec.Mpeg4) { if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Ac3 || audioCodec == AudioCodec.EAc3) { if (timestampType == Timestamp.None) { valuesProfiles.Add("MPEG4_P2_TS_ASP_AC3_ISO"); } else if (timestampType == Timestamp.Valid) { valuesProfiles.Add("MPEG4_P2_TS_ASP_AC3_T"); } else { valuesProfiles.Add("MPEG4_P2_TS_ASP_AC3"); } } else if (audioCodec == AudioCodec.Aac) { if (timestampType == Timestamp.None) { valuesProfiles.Add("MPEG4_P2_TS_ASP_AAC_ISO"); } else if (timestampType == Timestamp.Valid) { valuesProfiles.Add("MPEG4_P2_TS_ASP_AAC_T"); } else { valuesProfiles.Add("MPEG4_P2_TS_ASP_AAC"); } } else if (audioCodec == AudioCodec.Mp3) { if (timestampType == Timestamp.None) { valuesProfiles.Add("MPEG4_P2_TS_ASP_MPEG1_L3_ISO"); } else if (timestampType == Timestamp.Valid) { valuesProfiles.Add("MPEG4_P2_TS_ASP_MPEG1_L3_T"); } else { valuesProfiles.Add("MPEG4_P2_TS_ASP_MPEG1_L3"); } } else if (audioCodec == AudioCodec.Mp2) { if (timestampType == Timestamp.None) { valuesProfiles.Add("MPEG4_P2_TS_ASP_MPEG2_L2_ISO"); } else if (timestampType == Timestamp.Valid) { valuesProfiles.Add("MPEG4_P2_TS_ASP_MPEG2_L2_T"); } else { valuesProfiles.Add("MPEG4_P2_TS_ASP_MPEG2_L2"); } } } else { throw new Exception("MPEG2TS video file does not match any supported DLNA profile"); } } else if (container == VideoContainer.Flv) { valuesProfiles.Add("FLV"); } else if (container == VideoContainer.Wtv) { valuesProfiles.Add("WTV"); } else if (container == VideoContainer.Gp3) { if (videoCodec == VideoCodec.H264) { if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Aac) { valuesProfiles.Add("AVC_3GPP_BL_QCIF15_AAC"); } } else if (videoCodec == VideoCodec.MsMpeg4 || videoCodec == VideoCodec.Mpeg4) { if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Aac) { valuesProfiles.Add("MPEG4_P2_3GPP_SP_L0B_AAC"); } else if (audioCodec == AudioCodec.Amr) { valuesProfiles.Add("MPEG4_P2_3GPP_SP_L0B_AMR"); } } else if (videoCodec == VideoCodec.H263 && audioCodec == AudioCodec.Amr) { valuesProfiles.Add("MPEG4_H263_3GPP_P0_L10_AMR"); } else { throw new Exception("3GP video file does not match any supported DLNA profile"); } } else if (container == VideoContainer.RealMedia) { valuesProfiles.Add("REAL_VIDEO"); } else if (container == VideoContainer.Ogg) { valuesProfiles.Add("OGV"); } else if (container == VideoContainer.Hls) { if (videoCodec == VideoCodec.H264 && (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Aac)) { valuesProfiles.Add("HLS"); } } //else if (container == VideoContainer.Rtsp) //{ // valuesProfiles.Add("RTSP"); //} //else if (container == VideoContainer.Rtp) //{ // valuesProfiles.Add("RTP"); //} else { throw new Exception("Video does not match any supported DLNA profile"); } return(valuesProfiles); }
public static bool IsMPEGTSContainer(VideoContainer container) { return(container == VideoContainer.Mpeg2Ts || container == VideoContainer.Wtv || container == VideoContainer.Hls || container == VideoContainer.M2Ts); }
public static List <string> ResolveVideoProfile(VideoContainer container, VideoCodec videoCodec, AudioCodec audioCodec, EncodingProfile h264Profile, float h264Level, float fps, int width, int height, long videoBitrate, long audioBitrate, Timestamp timestampType) { List <string> valuesProfiles = new List <string>(); if (container == VideoContainer.Asf) { if ((videoCodec == VideoCodec.Wmv && audioCodec == AudioCodec.Unknown) || (videoCodec == VideoCodec.Wmv && audioCodec == AudioCodec.Mp3) || (audioCodec == AudioCodec.Wma || audioCodec == AudioCodec.WmaPro)) { if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Wma) { valuesProfiles.Add("WMV"); } } else if (videoCodec == VideoCodec.Vc1) { valuesProfiles.Add("VC1_ASF"); } else if (videoCodec == VideoCodec.Mpeg1 || videoCodec == VideoCodec.Mpeg2) { valuesProfiles.Add("DVR_MS"); } else { throw new Exception("ASF video file does not match any supported web profile"); } } else if (container == VideoContainer.Avi) { valuesProfiles.Add("AVI"); } else if (container == VideoContainer.Matroska) { valuesProfiles.Add("MATROSKA"); } else if (container == VideoContainer.Mp4) { if (videoCodec == VideoCodec.H264) { valuesProfiles.Add("AVC_MP4"); } else if (videoCodec == VideoCodec.MsMpeg4 || videoCodec == VideoCodec.Mpeg4) { valuesProfiles.Add("MPEG4_P2_MP4"); } else if (videoCodec == VideoCodec.H263 && audioCodec == AudioCodec.Aac) { valuesProfiles.Add("MPEG4_H263_MP4"); } else { throw new Exception("MP4 video file does not match any supported web profile"); } } else if (container == VideoContainer.Mpeg2Ps) { valuesProfiles.Add("MPEG_PS"); } else if (container == VideoContainer.Mpeg1) { valuesProfiles.Add("MPEG1"); } else if (container == VideoContainer.Mpeg2Ts || container == VideoContainer.M2Ts) { if (videoCodec == VideoCodec.Mpeg2) { valuesProfiles.Add("MPEG_TS"); } else if (videoCodec == VideoCodec.H264) { valuesProfiles.Add("AVC_TS"); } else if (videoCodec == VideoCodec.Vc1) { valuesProfiles.Add("VC1_TS"); } else if (videoCodec == VideoCodec.MsMpeg4 || videoCodec == VideoCodec.Mpeg4) { valuesProfiles.Add("MPEG4_P2_TS"); } else { throw new Exception("MPEG2TS video file does not match any supported web profile"); } } else if (container == VideoContainer.Flv) { valuesProfiles.Add("FLV"); } else if (container == VideoContainer.Wtv) { valuesProfiles.Add("WTV"); } else if (container == VideoContainer.Gp3) { if (videoCodec == VideoCodec.H264) { valuesProfiles.Add("AVC_3GPP"); } else if (videoCodec == VideoCodec.MsMpeg4 || videoCodec == VideoCodec.Mpeg4) { valuesProfiles.Add("MPEG4_P2_3GPP"); } else if (videoCodec == VideoCodec.H263) { valuesProfiles.Add("MPEG4_H263_3GPP"); } else { throw new Exception("3GP video file does not match any supported web profile"); } } else if (container == VideoContainer.RealMedia) { valuesProfiles.Add("REAL_VIDEO"); } else if (container == VideoContainer.Ogg) { valuesProfiles.Add("OGV"); } else if (container == VideoContainer.Hls) { if (videoCodec == VideoCodec.H264 && (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Aac || audioCodec == AudioCodec.Mp3)) { valuesProfiles.Add("HLS"); } else { throw new Exception("HLS video file does not match any supported web profile"); } } else { throw new Exception("Video does not match any supported web profile"); } return(valuesProfiles); }