~libv4l/libv4l/dev

« back to all changes in this revision

Viewing changes to utils/cec-follower/cec-follower.cpp

  • Committer: Hans Verkuil
  • Author(s): Deborah Brouwer
  • Date: 2021-07-13 07:02:23 UTC
  • Revision ID: git-v1:7e07a868f273af25a85c8cf7aec730853971d93c
cec: expand Timer Programming tests

Check that Timer Status and Time Cleared Status replies have a valid
operand. Send timers with out-of-range dates and check follower's
response. Send an out-of-range recording sequence and check that the timer
is not set. Send a duplicate timer and check that the timer is not set.
Set overlapping timers and check that the timer overlap warning is set.
In the follower, keep track of timers that have been received and warn
if there may be insufficient space for a programmed recording.

Signed-off-by: Deborah Brouwer <deborahbrouwer3563@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
bool show_state;
48
48
bool show_warnings = true;
49
49
unsigned warnings;
 
50
std::set<struct Timer> programmed_timers;
50
51
 
51
52
static struct option long_options[] = {
52
53
        { "device", required_argument, nullptr, OptSetDevice },
296
297
        return retval == -1 ? e : (retval ? -1 : 0);
297
298
}
298
299
 
 
300
void print_timers(struct node *node)
 
301
{
 
302
        if (show_info) {
 
303
                printf("Timers Set:\n");
 
304
                for (auto &t : programmed_timers) {
 
305
                        std::string start = ctime(&t.start_time);
 
306
                        time_t end_time = t.start_time + t.duration;
 
307
                        std::string end = ctime(&end_time);
 
308
                        /* Remove the seconds because timer is precise only to the minute. */
 
309
                        start.erase(16, 3);
 
310
                        end.erase(16, 3);
 
311
                        /* Remove the new line characters. */
 
312
                        start.erase(start.end() - 1);
 
313
                        end.erase(end.end() - 1);
 
314
                        /* Remove the start year if it is the same as the end year. */
 
315
                        if ((start.compare(start.size() - 4, 5, end, end.size() - 4, 5) == 0))
 
316
                                start.erase(start.size() - 5, 5);
 
317
                        printf("\t%s - %s, ", start.c_str(), end.c_str());
 
318
                        /* Find and print the source. */
 
319
                        std::string source;
 
320
                        switch (t.src.type) {
 
321
                        case CEC_OP_RECORD_SRC_OWN:
 
322
                                source = "own";
 
323
                                break;
 
324
                        case CEC_OP_RECORD_SRC_DIGITAL:
 
325
                                source = "digital";
 
326
                                break;
 
327
                        case CEC_OP_RECORD_SRC_ANALOG:
 
328
                                source = "analog";
 
329
                                break;
 
330
                        case CEC_OP_RECORD_SRC_EXT_PLUG:
 
331
                                source = "ext plug";
 
332
                                break;
 
333
                        case CEC_OP_RECORD_SRC_EXT_PHYS_ADDR:
 
334
                                source = "ext phy addr";
 
335
                                break;
 
336
                        default:
 
337
                                break;
 
338
                        }
 
339
                        printf("source: %s, ", source.c_str());
 
340
                        if (t.recording_seq)
 
341
                                printf("rec-seq: 0x%x, ", t.recording_seq);
 
342
                        printf("needs: %ld %s\n", t.duration, "MB."); /* 1MB per second. */
 
343
                }
 
344
                printf("Total media space available for recording: ");
 
345
                if (node->state.media_space_available >= 0)
 
346
                        printf("%d MB.\n\n", node->state.media_space_available);
 
347
                else
 
348
                        printf("0 MB.\n\n");
 
349
        }
 
350
}
 
351
 
299
352
void state_init(struct node &node)
300
353
{
301
354
        if (options[OptStandby])
319
372
        node.state.deck_skip_start = 0;
320
373
        node.state.one_touch_record_on = false;
321
374
        node.state.record_received_standby = false;
 
375
        node.state.media_space_available = 36000; /* In MB; space for 10 hours @ 1MB/sec */
322
376
        tuner_dev_info_init(&node.state);
323
377
        node.state.last_aud_rate_rx_ts = 0;
324
378
}