예제 #1
0
        private UPnPError OnGetRecordingFileOrStream(DvAction action, IList <object> inParams, out IList <object> outParams, CallContext context)
        {
            outParams = new List <object>();
            IProgramInfoAsync     programInfo     = ServiceRegistration.Get <ITvProvider>() as IProgramInfoAsync;
            IScheduleControlAsync scheduleControl = ServiceRegistration.Get <ITvProvider>() as IScheduleControlAsync;

            if (programInfo == null || scheduleControl == null)
            {
                return(new UPnPError(500, "IProgramInfo or IScheduleControl service not available"));
            }

            int      programId = (int)inParams[0];
            IProgram program;
            bool     result       = false;
            string   fileOrStream = null;

            if (programInfo.GetProgram(programId, out program))
            {
                var scheduleResult = scheduleControl.GetRecordingFileOrStreamAsync(program).Result;
                if (scheduleResult.Success)
                {
                    result       = true;
                    fileOrStream = scheduleResult.Result;
                }
            }

            outParams = new List <object> {
                result, fileOrStream
            };
            return(null);
        }
예제 #2
0
        private UPnPError OnCreateSchedule(DvAction action, IList <object> inParams, out IList <object> outParams, CallContext context)
        {
            outParams = new List <object>();
            IProgramInfoAsync     programInfo     = ServiceRegistration.Get <ITvProvider>() as IProgramInfoAsync;
            IScheduleControlAsync scheduleControl = ServiceRegistration.Get <ITvProvider>() as IScheduleControlAsync;

            if (programInfo == null || scheduleControl == null)
            {
                return(new UPnPError(500, "IProgramInfo or IScheduleControl service not available"));
            }

            int programId = (int)inParams[0];
            ScheduleRecordingType recordingType = (ScheduleRecordingType)inParams[1];
            IProgram  program;
            ISchedule schedule = null;
            bool      result   = false;

            if (programInfo.GetProgram(programId, out program))
            {
                var scheduleResult = scheduleControl.CreateScheduleAsync(program, recordingType).Result;
                result   = scheduleResult.Success;
                schedule = scheduleResult.Result;
            }

            outParams = new List <object> {
                result, schedule
            };
            return(null);
        }
예제 #3
0
        private UPnPError OnRemoveScheduleForProgram(DvAction action, IList <object> inParams, out IList <object> outParams, CallContext context)
        {
            outParams = new List <object>();
            IProgramInfoAsync     programInfo     = ServiceRegistration.Get <ITvProvider>() as IProgramInfoAsync;
            IScheduleControlAsync scheduleControl = ServiceRegistration.Get <ITvProvider>() as IScheduleControlAsync;

            if (programInfo == null || scheduleControl == null)
            {
                return(new UPnPError(500, "IProgramInfo or IScheduleControl service not available"));
            }

            int programId = (int)inParams[0];
            ScheduleRecordingType recordingType = (ScheduleRecordingType)inParams[1];
            IProgram program;
            var      result = programInfo.GetProgram(programId, out program) && scheduleControl.RemoveScheduleForProgramAsync(program, recordingType).Result;

            outParams = new List <object> {
                result
            };
            return(null);
        }