public override Task <StopReply> Stop(StopRequest request, ServerCallContext context) { // return base.Stop(request, context); var stopReply = new StopReply() { Status = new MediaContract.Status() { Code = 200, Msg = "Stop Successful!" } }; return(Task.FromResult(stopReply)); }
//public override Task<VideoDownloadReply> VideoDownload(VideoDownloadRequest request, ServerCallContext context) //{ // try // { // _eventSource?.VideoDownloadRequestEvent(request, context); // var reqeustProcessResult = _sipServiceDirector.VideoDownloadReq(Convert.ToDateTime(request.BeginTime), Convert.ToDateTime(request.EndTime), request.Gbid, new int[] { request.Port }, request.Ipaddr); // reqeustProcessResult?.Wait(System.TimeSpan.FromSeconds(1)); // //get the response . // var resReply = new VideoDownloadReply() // { // Ipaddr = reqeustProcessResult.Result.Item1, // Port = reqeustProcessResult.Result.Item2, // Hdr = GetHeaderBySipHeader(reqeustProcessResult.Result.Item3), // Status = new MediaContract.Status() // { // Code = 200, // Msg = "Request Successful!" // } // }; // //add Video Session Alive // Dictionary<string, DateTime> _Dictionary = new Dictionary<string, DateTime>(); // _Dictionary.Add(request.Gbid + ',' + resReply.Hdr.Sessionid, DateTime.Now); // _sipServiceDirector.VideoSessionAlive.Add(_Dictionary); // return Task.FromResult(resReply); // } // catch (Exception ex) // { // logger.Error("Exception GRPC VideoDownloadReply: " + ex.Message); // var resReply = new VideoDownloadReply() // { // Status = new MediaContract.Status() // { // Msg = ex.Message // } // }; // return Task.FromResult(resReply); // } //} public override Task <StopReply> Stop(StopRequest request, ServerCallContext context) { bool tf = false; string msg = ""; try { switch (request.BusinessType) { case BusinessType.BtLiveplay: tf = _sipServiceDirector.Stop(string.IsNullOrEmpty(request.Gbid) ? "42010000001180000184" : request.Gbid, request.Hdr.Sessionid); break; case BusinessType.BtPlayback: tf = _sipServiceDirector.BackVideoStopPlayingControlReq(string.IsNullOrEmpty(request.Gbid) ? "42010000001180000184" : request.Gbid, request.Hdr.Sessionid); break; default: tf = _sipServiceDirector.Stop(string.IsNullOrEmpty(request.Gbid) ? "42010000001180000184" : request.Gbid, request.Hdr.Sessionid); break; } msg = tf ? "Stop Successful!" : "Stop Failed!"; var reply = new StopReply() { Status = new Status() { Code = 200, Msg = msg } }; return(Task.FromResult(reply)); } catch (Exception ex) { logger.Error("Exception GRPC StopVideo: " + ex.Message); var reply = new StopReply() { Status = new Status() { Code = 400, Msg = ex.Message } }; return(Task.FromResult(reply)); } }