// private Leadtools.Multimedia.RTSPServer _ltRtspServer; public void Start() { try { // _ltRtspServer = new Leadtools.Multimedia.RTSPServer(); // _ltRtspServer.SetSecurity(-1, null); AppLogger.Message("RTSPServer security set to None"); for (int i = 0; i < ContentFolders.Count; i++) { // _ltRtspServer.SetSourceFolder(i, ContentFolders[0]); // _ltRtspServer.SetSecurity(i, null); AppLogger.Message(String.Format("RTSPServer added Content folder {0}", ContentFolders[i])); } int idx = ContentFolders.Count; // _ltRtspServer.SetSourceFolder(idx, Graphs.BaseDVRSinkGraph.Settings.RootFolder); LiveLatencySeconds = 0; // _ltRtspServer.SetLiveLatency(idx, LiveLatencySeconds); // _ltRtspServer.SetSecurity(idx, null); AppLogger.Message(String.Format("RTSPServer added DVR root folder {0}", Graphs.BaseDVRSinkGraph.Settings.RootFolder)); // _ltRtspServer.TargetAddress = TargetAddress; // _ltRtspServer.StartServer(Port); AppLogger.Message("RTSPServer started"); } catch (Exception e) { FutureConcepts.Tools.AppLogger.Dump(e); } }
private void SetPinVideoImageSize(string pinName) { int hr; IPin pin = DsFindPin.ByDirection(_videoEncoder, PinDirection.Output, 0); if (pin != null) { AppLogger.Message("VideoCaptureDevice: found output pin"); } // get video stream interfaces AppLogger.Message("VideoCaptureDevice:get Video stream control interface (IAMStreamConfig)"); IAMStreamConfig streamConfig = (IAMStreamConfig)pin; AMMediaType media; hr = streamConfig.GetFormat(out media); DsError.ThrowExceptionForHR(hr); VideoInfoHeader v = new VideoInfoHeader(); v.BmiHeader = new BitmapInfoHeader(); v.BmiHeader.Width = 320; v.BmiHeader.Height = 240; media.formatPtr = Marshal.AllocCoTaskMem(1024); Marshal.StructureToPtr(v, media.formatPtr, true); hr = streamConfig.SetFormat(media); DsError.ThrowExceptionForHR(hr); DsUtils.FreeAMMediaType(media); }
protected override void OnStart(string[] args) { try { AppLogger.ShowAssembly = false; AppLogger.ShowClass = false; AppLogger.ShowDate = false; AppLogger.ShowMethod = false; AppLogger.Message(DateTime.Now.ToString() + " " + Assembly.GetAssembly(typeof(MediaServer)).ToString()); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); if (ServiceMode) { //this.RequestAdditionalTime(60000); } SetupNativeEnvironment(); // QueryOriginServers.StartBackgroundThread(); IndigoServices.Host.StartServices(); GraphManager.ShutdownInProgress = false; GraphManager.StartPushGraphs(); // _rtspServer = RTSP.RTSPServer.LoadFromFile(); // if (_rtspServer != null) // { // _rtspServer.Start(); // } NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged); NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged); AppLogger.Message("MediaServer is READY"); } catch (Exception exc) { AppLogger.Dump(exc); } }
/// <summary> /// Loads StreamSources from a specified file. /// </summary> /// <param name="fileName">The filename to load. If you are trying to load multiple distinct files, set bypassCache to true.</param> /// Set to true to always read from the disk and return a distinct copy /// Set to false to use the cached copy if available. /// </param> /// <returns>the RTSPServer from the indicated file</returns> public static RTSPServer LoadFromFile(string fileName) { RTSPServer result = null; FileStream file = null; try { XmlSerializer xmlSerializer = new XmlSerializer(typeof(RTSPServer)); file = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); result = (RTSPServer)xmlSerializer.Deserialize(file); } catch (Exception e) { AppLogger.Message(String.Format("RTSPServer was not loaded -- the configuration file {0} could not be loaded", PersistFileName)); AppLogger.Dump(e); } finally { if (file != null) { file.Close(); file.Dispose(); } } return(result); }
public void Dispose() { AppLogger.Message("MicrowaveControlService2.Dispose"); if (scanner != null) { scanner.ScanCompleted -= new EventHandler <ScanCompleteEvent>(scanner_ScanCompleted); scanner.CancelScan(); scanner = null; } if (microwaveReceiver != null) { microwaveReceiver.StopPollingLinkQuality(); microwaveReceiver.Dispose(); microwaveReceiver = null; } if (resourceAcquired) { try { ResourceManager.Release(clientRequest.SourceName, typeof(MicrowaveControlService), clientRequest.UserName); } catch (Exception ex) { AppLogger.Dump(ex); } } if (frequencyPresets != null) { PersistPresets(); } }
public object GetStructure(Guid guidPropSet, int propId, System.Type structureType) { Guid propertyGuid = guidPropSet; IKsPropertySet propertySet = _captureFilter as IKsPropertySet; KSPropertySupport IsTypeSupported = 0; int uiSize; if (propertySet == null) { AppLogger.Message("GetStructure() properySet=null"); return(null); } int hr = propertySet.QuerySupported(propertyGuid, propId, out IsTypeSupported); if (hr != 0 || (IsTypeSupported & KSPropertySupport.Get) == 0) { AppLogger.Message("GetString() GetStructure is not supported"); return(null); } object objReturned = null; IntPtr pDataReturned = Marshal.AllocCoTaskMem(1000); hr = propertySet.Get(propertyGuid, propId, IntPtr.Zero, 0, pDataReturned, 1000, out uiSize); if (hr == 0) { objReturned = Marshal.PtrToStructure(pDataReturned, structureType); } else { AppLogger.Message(String.Format("GetStructure() failed 0x{0:X}", hr)); } Marshal.FreeCoTaskMem(pDataReturned); return(objReturned); }
/// <summary> /// If the plugin is an IPresetProvider /// </summary> /// <returns></returns> public UserPresetItem SavePreset() { lock (_userLock) { AppLogger.Message("CameraControlService.SavePreset"); try { UserPresetItem item = null; if (_plugin is IPresetProvider) { item = ((IPresetProvider)_plugin).SavePreset(); } else { item = new CameraPositionPreset(CurrentPanAngle, CurrentTiltAngle, CurrentZoomPosition); PresetItems.Add(item); } return(item); } catch (IndexOutOfRangeException ex) { AppLogger.Dump(ex); this.StatusMessage = ex.Message; return(null); } catch (Exception exc) { AppLogger.Dump(exc); return(null); } } }
protected void SetMPEG2Parameters() { #if COMMENT int hr; MPEG2AudioConfig config = SourceConfig.MPEG2Audio; if (Profile == null) { AppLogger.Message("SetMPEG2Parameters called, but Profile is not set"); return; } IntPtr nativeVariant = Marshal.AllocCoTaskMem(64); ICodecAPI codecAPI_MP3 = GetCodecAPI_MP3(); Marshal.GetNativeVariantForObject(config.DSP, nativeVariant); hr = codecAPI_MP3.SetValue(CodecAPIParam.DSP, nativeVariant); DsError.ThrowExceptionForHR(hr); Marshal.GetNativeVariantForObject(config.Mic, nativeVariant); hr = codecAPI_MP3.SetValue(CodecAPIParam.Mic, nativeVariant); DsError.ThrowExceptionForHR(hr); Marshal.GetNativeVariantForObject(config.BitRateKbps, nativeVariant); hr = codecAPI_MP3.SetValue(CodecAPIParam.AudioBitRate, nativeVariant); DsError.ThrowExceptionForHR(hr); hr = Marshal.ReleaseComObject(codecAPI_MP3); DsError.ThrowExceptionForHR(hr); Marshal.FreeCoTaskMem(nativeVariant); #endif }
protected virtual void SetStructure(Guid guidPropSet, int propId, System.Type structureType, object structValue) { Guid propertyGuid = guidPropSet; IKsPropertySet propertySet = _captureFilter as IKsPropertySet; KSPropertySupport IsTypeSupported = 0; if (propertySet == null) { AppLogger.Message("SetStructure() properySet=null"); return; } int hr = propertySet.QuerySupported(propertyGuid, propId, out IsTypeSupported); if (hr != 0 || (IsTypeSupported & KSPropertySupport.Set) == 0) { AppLogger.Message("GetString() GetStructure is not supported"); return; } int iSize = Marshal.SizeOf(structureType); IntPtr pDataReturned = Marshal.AllocCoTaskMem(iSize); Marshal.StructureToPtr(structValue, pDataReturned, true); hr = propertySet.Set(propertyGuid, propId, pDataReturned, (int)iSize, pDataReturned, (int)iSize); if (hr != 0) { AppLogger.Message(String.Format("SetStructure() failed 0x{0:X}", hr)); } Marshal.FreeCoTaskMem(pDataReturned); }
public void Initialize() { Plugin.Initialize(); PanTiltZoomPositionInquire(); Callback.SavedPositionsChanged(PresetItems); AppLogger.Message("CameraControlService.Initialize sent saved positions"); }
public CaptureSourceDVR(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest) : base(sourceConfig, openGraphRequest) { AppLogger.Message("In CaptureSourceDVR constructor - CurrentProfile is " + CurrentProfile.Name); _captureFilter = AddFilterByName(FilterCategory.VideoInputDevice, sourceConfig.Description); _videoEncoder = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD H264 Encoder (4.0)"); // _transcoder = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD H264 Transcoder"); InitializeSink(); ConnectFilters(_captureFilter, "Capture", _videoEncoder, "XForm In"); // ConnectFilters(_videoEncoder, "XForm Out", _transcoder, "Input"); // ConnectFilterToMux(_transcoder, "Output", "Input 01"); ConnectFilterToMux(_videoEncoder, "XForm Out", "Input 01"); ConnectMuxToSink(); _videoEncoderControl = (ILMH264Encoder)_videoEncoder; _videoEncoderControl.EnableRateControl = true; _videoEncoderControl.BitRate = CurrentProfile.Video.ConstantBitRate * 1024; _videoEncoderControl.OutputFormat = eH264OUTPUTFORMAT.H264FORMAT_IPOD; // seems to work the best }
public void StopRecording() { AppLogger.Message("StreamingAndRecording.StopRecording"); int hr = _dvrWriter.StopRecording(); DsError.ThrowExceptionForHR(hr); }
private void _eventTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { try { _eventTimer.Enabled = false; IMediaEventEx mediaEvent = _graphBuilder as IMediaEventEx; if (mediaEvent == null) { AppLogger.Message("couldn't get IMediaEventEx from graph builder!"); return; } EventCode eventCode; IntPtr lparam1, lparam2; while (mediaEvent.GetEvent(out eventCode, out lparam1, out lparam2, 10) == 0) { AppLogger.Message("ASFNetSink -- Got Media Event: " + eventCode.ToString() + " 0x" + lparam1.ToString("X") + " 0x" + lparam2.ToString("X")); OnDirectShowEvent(eventCode, lparam1, lparam2); mediaEvent.FreeEventParams(eventCode, lparam1, lparam2); } _eventTimer.Enabled = true; } catch (Exception ex) { AppLogger.Message("ASFNetSink -- Can't get Media Event due to an error"); AppLogger.Dump(ex); } }
public void SetupCaptureFormat(IBaseFilter filter) { AppLogger.Message("VideoCaptureDevice:get Video stream control interface (IAMStreamConfig)"); object o; int hr = _captureGraphBuilder.FindInterface(PinCategory.Preview, null, (IBaseFilter)filter, typeof(IAMStreamConfig).GUID, out o); if (hr == 0) { _interfaceStreamConfigVideoCapture = o as IAMStreamConfig; if (_interfaceStreamConfigVideoCapture != null) { AppLogger.Message(String.Format("FrameRate before set {0}", FrameRate)); FrameRate = 15d; //FrameSize = new Size(720, 576); // Size size = FrameSize; // if (size.Width != 720 || size.Height != 576) // { // FrameSize = new Size(640, 480); // FrameSize = new Size(352, 240); // } } } else { AppLogger.Message("Failed to find Preview interface on filter"); } AppLogger.Message(String.Format("FrameRate after set {0}", FrameRate)); return; }
public bool UpdatePreset(UserPresetItem newItem) { try { AppLogger.Message(String.Format("CameraControlService.UpdatePreset {0} = {1}", newItem.ID, newItem)); lock (_userLock) { if (_plugin is IPresetProvider) { return(((IPresetProvider)_plugin).UpdatePreset(newItem)); } else { UserPresetItem oldItem = PresetItems[newItem.ID]; if (oldItem != null) { PresetItems.Remove(oldItem); } else { AppLogger.Message(" Warning! No item with ID " + newItem.ID + " pre-existed!"); } PresetItems.Add(newItem); return(true); } } } catch (Exception exc) { AppLogger.Dump(exc); return(false); } }
protected void SetDSP_and_Camera(StreamSourceInfo sourceConfig) { int hr; IntPtr nativeVariant = Marshal.AllocCoTaskMem(64); ICodecAPI codecAPI_H264 = GetCodecAPI(); if (sourceConfig.DeviceAddress == null) { throw new SourceConfigException("DeviceAddress may not be null!"); } AppLogger.Message(String.Format("MangoDVR SetDSP_and_Camera Channel={0} Input={1}", sourceConfig.DeviceAddress.Channel, sourceConfig.DeviceAddress.Input)); Marshal.GetNativeVariantForObject(sourceConfig.DeviceAddress.Channel, nativeVariant); hr = codecAPI_H264.SetValue(CodecAPIParam.DSP, nativeVariant); DsError.ThrowExceptionForHR(hr); Marshal.GetNativeVariantForObject(sourceConfig.DeviceAddress.Input, nativeVariant); hr = codecAPI_H264.SetValue(CodecAPIParam.Cam, nativeVariant); DsError.ThrowExceptionForHR(hr); hr = Marshal.ReleaseComObject(codecAPI_H264); DsError.ThrowExceptionForHR(hr); Marshal.FreeCoTaskMem(nativeVariant); }
public bool DeletePreset(Guid id) { try { AppLogger.Message("CameraControlService.DeletePreset " + id); lock (_userLock) { if (_plugin is IPresetProvider) { return(((IPresetProvider)_plugin).DeletePreset(id)); } else { UserPresetItem item = PresetItems[id]; return(PresetItems.Remove(item)); } } } catch (Exception exc) { AppLogger.Dump(exc); return(false); } }
/// <summary> /// Configures the SmartCapture device to output the given image size. /// </summary> /// <param name="size">Supports CIF and 4CIF</param> private void SetImageSize(VideoImageSize size) { if (_deviceContext == IntPtr.Zero) { throw new ArgumentNullException("DeviceContext"); } int width; int height; switch (size) { case VideoImageSize.CIF: width = 352; height = 240; AppLogger.Message("ImageSize CIF"); break; case VideoImageSize.FourCIF: width = 704; height = 480; AppLogger.Message("ImageSize FourCIF"); break; default: throw new ArgumentException(size.ToString(), "ImageSize"); } if (NativeMethods.SCSetVideoFrameSize(_deviceContext, width, height) != 1) { throw new Exception("SCSetVideoFrameSize failed"); } Thread.Sleep(300); }
private void SendClientsUpdate() { if ((State == ServerGraphState.Running) && (this.DispatchClientsUpdate)) { TextWriter textWriter = new StringWriter(); XmlWriter xmlWriter = new XmlTextWriter(textWriter); xmlWriter.WriteStartDocument(true); xmlWriter.WriteStartElement("Clients"); foreach (string userName in ClientList) { xmlWriter.WriteStartElement("add"); xmlWriter.WriteAttributeString("UserName", userName); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); xmlWriter.Flush(); try { WriteLTNetMessage(textWriter.ToString()); } catch (Exception exc) { AppLogger.Message("StreamingGraph.SendClientsUpdate exception: " + exc.Message); } xmlWriter.Close(); textWriter.Close(); textWriter.Dispose(); } }
/// <summary> /// Cancels the current channels can operation /// </summary> public void CancelChannelScan() { AppLogger.Message("StreamingTVGraph.CancelChannelScan"); if (channelScanWorker != null) { channelScanWorker.CancelAsync(); } }
public override void Dispose(bool disposing) { AppLogger.Message("WinTV.Dispose"); if (disposing) { if (_tuner != null) { Marshal.ReleaseComObject(_tuner); _tuner = null; } if (_tvaudio != null) { Marshal.ReleaseComObject(_tvaudio); _tvaudio = null; } if (_crossbar2 != null) { Marshal.ReleaseComObject(_crossbar2); _crossbar2 = null; } if (_videoEncoder != null) { Marshal.ReleaseComObject(_videoEncoder); _videoEncoder = null; } if (_audioEncoder != null) { Marshal.ReleaseComObject(_audioEncoder); _audioEncoder = null; } if (_mpeg2Demux != null) { Marshal.ReleaseComObject(_mpeg2Demux); _mpeg2Demux = null; } if (_captureFilter != null) { Marshal.ReleaseComObject(_captureFilter); _captureFilter = null; } if (_hcwColorConverter != null) { Marshal.ReleaseComObject(_hcwColorConverter); _hcwColorConverter = null; } if (_amTvTuner != null) { Marshal.ReleaseComObject(_amTvTuner); _amTvTuner = null; } if (_amCrossbar != null) { Marshal.ReleaseComObject(_amCrossbar); _amCrossbar = null; } } base.Dispose(disposing); }
public void ForceUpdate() { AppLogger.Message("MicrowaveControlService.ForceUpdate"); AppLogger.Message("MicrowaveReceiver.Connected = " + microwaveReceiver.Connected); //tell client what's up FireFrequencyChanged((int)microwaveReceiver.GetTuning().FrequencyMHz); FireSignalStrengthChanged((int)microwaveReceiver.GetLinkQuality().ReceivedCarrierLevel); FirePresetsChanged(); }
public void Stop() { // if (_ltRtspServer != null) { // _ltRtspServer.StopServer(_port); // _ltRtspServer = null; AppLogger.Message("RTSPServer stopped"); } }
public ServerInfo GetServerInfoSpecific(int serverParams, int sourceParams) { AppLogger.Message("ServerConfigService.GetServerInfoSpecific"); ServerInfo output = new ServerInfo(); if ((serverParams & RequestedServerInfoParams.RevisionNumber) == RequestedServerInfoParams.RevisionNumber) { output.RevisionNumber = ServerConfigService.RevisionNumber; } if (serverParams == RequestedServerInfoParams.RevisionNumber) //quick optimization to avoid wasting time on "pings" { return(output); } if ((serverParams & RequestedServerInfoParams.ServerName) == RequestedServerInfoParams.ServerName) { output.ServerName = Dns.GetHostName(); } if ((serverParams & RequestedServerInfoParams.ServerAddress) == RequestedServerInfoParams.ServerAddress) { output.ServerAddress = OperationContext.Current.IncomingMessageHeaders.To.Host; } if ((serverParams & RequestedServerInfoParams.VersionInfo) == RequestedServerInfoParams.VersionInfo) { output.VersionInfo = Assembly.GetAssembly(typeof(MediaServer)).ToString(); } if ((serverParams & RequestedServerInfoParams.StreamSources) == RequestedServerInfoParams.StreamSources) { StreamSources temp; CopyStreamSourceInfo(StreamSources.LoadFromFile(), sourceParams, out temp); output.StreamSources = temp; } if ((serverParams & RequestedServerInfoParams.ProfileGroups) == RequestedServerInfoParams.ProfileGroups) { output.ProfileGroups = ProfileGroups.LoadFromFile(); } // if ((serverParams & RequestedServerInfoParams.OriginServers) == RequestedServerInfoParams.OriginServers) // { // output.OriginServers = new List<ServerInfo>(); // if (QueryOriginServers.OriginServers != null) // { // foreach (ServerInfo cur in QueryOriginServers.OriginServers) // { // ServerInfo copy; // CopyServerInfo(cur, serverParams, sourceParams, out copy); // output.OriginServers.Add(copy); // } // } // } return(output); }
protected void OpenSink() { AppLogger.Message("ASFNetSink -- OpenSink"); //extract the port number from the SinkURL Uri uri = new Uri(this.ClientURL); int portNum = uri.Port; // Done configuring the network sink, open it _netSink.Open(ref portNum); }
/// <summary> /// Does a sweep of the frequencies (inclusive) in a given range /// </summary> /// <param name="start">start frequency in Hz</param> /// <param name="end">end frequency in Hz</param> /// <param name="threshold">percentage of minimum signal strength</param> public void StartSweep(MicrowaveTuning settings, UInt64 start, UInt64 end, int threshold) { AppLogger.Message("MCS2.StartSweep"); scanStart = start; scanEnd = end; scanner.PeakScanAsync(settings, start, end, threshold); scanInProgress = true; }
public static void AbortAllGraphs() { List <BaseGraph> graphs = new List <BaseGraph>(_graphMap.Values); AppLogger.Message("GraphManager AbortAllGraphs"); foreach (BaseGraph graph in graphs) { graph.Abort(); } AppLogger.Message("GraphManager AbortAllGraphs done"); }
public void ChannelDown() { try { TVGraph.ChannelDown(); } catch (Exception exception) { AppLogger.Message(String.Format("ChannelDown failed because {0}", exception.Message)); } }
/// <summary> /// Sets the audio bit rate. /// </summary> /// <param name="Kbps">The KBPS.</param> public void SetAudioBitRate(int Kbps) { AppLogger.Message(String.Format("WinTV: SetAudioBitrate {0}", Kbps)); AudioBitRate bitrate = new AudioBitRate(); bitrate.size = (uint)Marshal.SizeOf(typeof(AudioBitRate)); //Allow explicit setting of this in the future bitrate.bitrate = AudioBitRateEnum.Khz192; SetStructure(HauppaugeGuid, (int)PropertyId.AudioBitRate, typeof(AudioBitRate), (object)bitrate); GetAudioBitRate(out Kbps); }
public void ForceUpdate() { AppLogger.Message("MicrowaveControlService.ForceUpdate"); AppLogger.Message("MicrowaveReceiver.Connected = " + microwaveReceiver.Connected); //tell client what's up FireCapabilitiesChanged(microwaveReceiver.GetCapabilities()); FireTuningChanged(microwaveReceiver.GetTuning()); FireLinkQualityChanged(microwaveReceiver.GetLinkQuality()); FirePresetsChanged(); }