/** @internal @This parses and outputs a m3u file. * * @param upipe description structure of the pipe * @return an error code */ static void upipe_m3u_reader_process(struct upipe *upipe) { struct upipe_m3u_reader *upipe_m3u_reader = upipe_m3u_reader_from_upipe(upipe); if (unlikely(upipe_m3u_reader->current_flow_def == NULL)) { upipe_m3u_reader->current_flow_def = uref_dup(upipe_m3u_reader->flow_def); if (unlikely(upipe_m3u_reader->current_flow_def == NULL)) { upipe_throw_fatal(upipe, UBASE_ERR_ALLOC); return; } } /* parse m3u */ int ret = UBASE_ERR_NONE; struct uref *uref = upipe_m3u_reader->next_uref; for (size_t offset = 0; uref && ubase_check(ret) && ubase_check(uref_block_scan(uref, &offset, '\n')); offset = 0, uref = upipe_m3u_reader->next_uref) { struct uref *line = upipe_m3u_reader_extract_uref_stream(upipe, offset + 1); ret = upipe_m3u_reader_process_line( upipe, upipe_m3u_reader->current_flow_def, line); uref_free(line); } if (!ubase_check(ret)) upipe_err(upipe, "invalid m3u"); }
/** @internal @This scans for a sync word. * * @param upipe description structure of the pipe * @param dropped_p filled with the number of octets to drop before the sync * @return true if a sync word was found */ static bool upipe_a52f_scan(struct upipe *upipe, size_t *dropped_p) { struct upipe_a52f *upipe_a52f = upipe_a52f_from_upipe(upipe); while (ubase_check(uref_block_scan(upipe_a52f->next_uref, dropped_p, 0xb))) { uint8_t word; if (!ubase_check(uref_block_extract(upipe_a52f->next_uref, *dropped_p + 1, 1, &word))) return false; if (word == 0x77) return true; (*dropped_p)++; } return false; }
/** @internal @This scans for a sync word. * * @param upipe description structure of the pipe * @param dropped_p filled with the number of octets to drop before the sync * @return true if a sync word was found */ static bool upipe_s337d_scan(struct upipe *upipe, size_t *dropped_p) { struct upipe_s337d *upipe_s337d = upipe_s337d_from_upipe(upipe); while (ubase_check(uref_block_scan(upipe_s337d->next_uref, dropped_p, S337_PREAMBLE_A1))) { uint8_t preamble[3]; if (!ubase_check(uref_block_extract(upipe_s337d->next_uref, *dropped_p + 1, 3, preamble))) return false; if (preamble[0] == S337_PREAMBLE_A2 && preamble[1] == S337_PREAMBLE_B1 && preamble[2] == S337_PREAMBLE_B2) return true; (*dropped_p)++; } return false; }