With commands, you can schedule behavior of an MWriter object. For example, you can schedule start and stop times for encoding.
To set a command, you should use the SchedulerCommandAdd method. The method has the following parameters:
- _pTime - schedule time to execute the command
- _bsCommand - the command itself
- _bsParam - additional parameters of command
- _pSourceOrTargetObject - a source or a target object (what object should be used to execute the command?)
- _ppTask - output scheduled item
For example, here is an example of scheduling an MWriter object to start and stop encoding at specified times:
M_DATETIME startDate = new M_DATETIME(); startDate.nDay = 25; startDate.nMonth = 12; startDate.nYear = 2017; startDate.nHour = 14; startDate.nMinute = 23; startDate.nSecond = 52; MItem command; (myWriter as IMScheduler).SchedulerCommandAdd(ref date, "start", "", myLiveSource, out command); // For example, let's stop after 1 hour M_DATETIME stopDate = new M_DATETIME(); stopDate.nDay = 25; stopDate.nMonth = 12; stopDate.nYear = 2017; stopDate.nHour = 15; stopDate.nMinute = 23; stopDate.nSecond = 52; MItem command; (myWriter as IMScheduler).SchedulerCommandAdd(ref date, "stop", "", myLiveSource, out command);
The code above uses myLiveSource object to be used in
myWriter.ObjectStart(myLiveSource);
method at the specified startDate. And at stopDate the following method is called internally:
myWriter.ObjectClose();