/// <summary> /// Generates the streaming URI for live or pre-recorded streams. /// </summary> /// <param name="id">The identifier (monitorId if source=live or eventId if source=event).</param> /// <param name="source">The streaming source (live or event).</param> /// <param name="mode">The streaming mode (video or snapshot).</param> /// <param name="options">The streaming options.</param> /// <returns>The URI to the specified stream</returns> public string GenerateStreamingURI(int id, StreamingOptions.Source source = StreamingOptions.Source.Live, StreamingOptions.Mode mode = StreamingOptions.Mode.MJPEG, StreamingOptions options = null) { var @params = new Dictionary <string, object>(); // Set the mode (Snapshot or Video) switch (mode) { case StreamingOptions.Mode.JPEG: // Snapshot = single @params["mode"] = "single"; break; case StreamingOptions.Mode.MJPEG: // Video = jpeg @params["mode"] = "jpeg"; break; } // Set the source (live or event) switch (source) { case StreamingOptions.Source.Live: @params["monitor"] = id; break; case StreamingOptions.Source.Event: @params["source"] = "event"; @params["replay"] = "none"; @params["event"] = id; break; } // Set the streaming options if (options?.Scale > 0) { @params["scale"] = options.Scale; } if (options?.Width > 0) { @params["width"] = options.Width + "px"; } if (options?.Height > 0) { @params["height"] = options.Height + "px"; } if (options?.Buffer > 0) { @params["buffer"] = options.Buffer; } if (options?.MaxFPS > 0) { @params["maxfps"] = options.MaxFPS; } if (!string.IsNullOrEmpty(options?.ConnKey)) { @params["connkey"] = options.ConnKey; } if (options?.IncludeAuthentificationToken ?? true) { @params["auth"] = this.AuthentificationToken; } return(((options?.IncludeRootURI ?? false) ? this.RootUri.TrimEnd('/') : "") + "/cgi-bin/nph-zms?" + string.Join("&", @params.Select(v => $"{v.Key}={v.Value}").ToArray())); }
public string GenerateStreamingURI(int id, StreamingOptions.Source source = StreamingOptions.Source.Live, StreamingOptions.Mode mode = StreamingOptions.Mode.MJPEG, StreamingOptions options = null) { return(this.zoneMinder.GenerateStreamingURI(id, source, mode, options)); }