public void MpegSectionsNegativeTest() { Exception ex = null; try { List<JpegSection> sections = new JpegStream(-1, "DoesntExist").MpegSections(); } catch(Exception exc) { ex = exc; } Assert.IsNotNull(ex); ex = null; try { List<JpegSection> sections = new JpegStream(-99, "FileTest").MpegSections(); } catch (Exception exc) { ex = exc; } Assert.IsNotNull(ex); }
public void MpegPickFrames() { List<JpegSection> sections = new JpegStream(0, "201623194433607",222,1015).MpegSections(); Assert.IsNotNull(sections); Assert.IsTrue(sections.Count == 2); Assert.IsNotNull(sections[0].imageFiles); Assert.IsTrue(sections[0].imageFiles.Count + sections[1].imageFiles.Count == 794); }
public void MpegSectionsTest() { List<JpegSection> sections = new JpegStream(-1, "FileTest").MpegSections(); Assert.IsNotNull(sections); Assert.IsTrue(sections.Count == 3); Assert.IsNotNull(sections[0].imageFiles); Assert.IsTrue(sections[0].imageFiles.Count + sections[1].imageFiles.Count + sections[2].imageFiles.Count == 12); }
public HttpResponseMessage Get(int cameraId, string sessionKey) { try { JpegStream jpegStream = new JpegStream(cameraId, sessionKey); Func<Stream, HttpContent, TransportContext, Task> func = jpegStream.WriteToStream; HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new PushStreamContent(func); response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/jpeg"); response.Content.Headers.Remove("Content-Type"); response.Content.Headers.TryAddWithoutValidation("Content-Type", "multipart/x-mixed-replace;boundary=" + jpegStream.boundary); return response; } catch { return new HttpResponseMessage(HttpStatusCode.InternalServerError); } }