c# - How to restream live jpeg image from event handler to WebAPI PushStreamContent? -
summary
we using milestonesys c# sdk live jpeg camera. have jpeglivesource class can instantiate. class has event handler livecontentevent(object sender, eventargs e) fired every new live frame camera. e parameter, image content (byte[]) can convert memorystream => bitmap.
we setup .net web api 2 , end point when user go to: http://localhost:9000/camera/id/live
, should see stream of jpeg in browser.
the problem
we don't know how restream new image continuously livecontentevent pushstreamcontent.
we tried pushstreamcontent code many different websites, of them streaming static video file or collections of images in folder.
the code
[httpget] [route("{cameraid}/live")] public httpresponsemessage livestream(string cameraid) { var camera = getcamera(cameraid); httpresponsemessage response = new httpresponsemessage(); if (camera == null) return ok("camera not found.").request.createresponse(); var livesource = new jpeglivesource(camera); livesource.livemodestart = true; livesource.setkeepaspectratio(true, true); livesource.width = 400; livesource.height = 400; livesource.init(); livesource.livecontentevent += livesource_livecontentevent; // pushstreamcontent code should here right? response.content = new pushstreamcontent((stream, httpcontent, context) => { onstreamavailable(stream, httpcontent, context); }, "video/x-motion-jpeg"); return response; } private void livesource_livecontentevent(object sender, eventargs e) { // or put pushstreamcontent code here? } private void onstreamavailable(stream stream, httpcontent content,transportcontext context) { // should put code instantiate jpeglivesource class here? }
the question
can this? how restream new image continuously livecontentevent pushstreamcontent?
Comments
Post a Comment