xine-lib: xine-lib-1.2.13/src/input/input_pvr.c File Reference

xine-lib 1.2.13-20230125hg15249

Data Structures | Macros | Typedefs | Functions | Variables
input_pvr.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <unistd.h>`
`#include <fcntl.h>`
`#include <string.h>`
`#include <errno.h>`
`#include <time.h>`
`#include <pthread.h>`
`#include <sys/ioctl.h>`
`#include <linux/videodev2.h>`
`#include <xine/xine_internal.h>`
`#include <xine/xineutils.h>`
`#include <xine/compat.h>`
`#include <xine/input_plugin.h>`

## Data Structures
struct | ivtv_ioctl_codec
struct | pvr_input_plugin_t
struct | saved_show_t
struct | pvrscr_s

## Macros
#define | XINE_ENABLE_EXPERIMENTAL_FEATURES
#define | LOG_MODULE "input_pvr"
#define | LOG_VERBOSE
#define | PVR_DEVICE "/dev/video0"
#define | PVR_BLOCK_SIZE 2048 /* pvr works with dvd-like data */
#define | BLOCKS_PER_PAGE 102400 /* 200MB per page. each session can have several pages */
#define | MAX_PAGES 10000 /* maximum number of pages to keep track */
#define | NUM_PREVIEW_BUFFERS 250 /* used in mpeg_block demuxer */
#define | IVTV_IOC_G_CODEC 0xFFEE7703
#define | IVTV_IOC_S_CODEC 0xFFEE7704
#define | IVTV_STREAM_PS 0
#define | IVTV_STREAM_TS 1
#define | IVTV_STREAM_MPEG1 2
#define | IVTV_STREAM_PES_AV 3
#define | IVTV_STREAM_PES_V 5
#define | IVTV_STREAM_PES_A 7
#define | IVTV_STREAM_DVD 10
#define | PVR_FILENAME "%s%08d_%08d.vob"
#define | SAVE_BASE_FILENAME "ch%03d %02d-%02d-%04d %02d:%02d:%02d"
#define | SAVE_FILENAME "%s%s_%04d.vob"

## Typedefs
typedef struct pvrscr_s | pvrscr_t

## Functions
static int | pvrscr_get_priority (scr_plugin_t *scr)
static void | pvrscr_set_pivot (pvrscr_t *this)
static int | pvrscr_set_speed (scr_plugin_t *scr, int speed)
static void | pvrscr_speed_tunning (pvrscr_t *this, double factor)
static void | pvrscr_adjust (scr_plugin_t *scr, int64_t vpts)
static void | pvrscr_start (scr_plugin_t *scr, int64_t start_vpts)
static int64_t | pvrscr_get_current (scr_plugin_t *scr)
static void | pvrscr_exit (scr_plugin_t *scr)
static pvrscr_t * | pvrscr_init (void)
static uint32_t | block_to_page (pvr_input_plugin_t *this, uint32_t block)
static uint32_t | pvr_plugin_get_capabilities (input_plugin_t *this_gen)
static off_t | pvr_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len)
static void | pvr_adjust_realtime_speed (pvr_input_plugin_t *this, fifo_buffer_t *fifo, int speed)
static char * | make_temp_name (pvr_input_plugin_t *this, int page)
static char * | make_base_save_name (int channel, time_t tm)
static char * | make_save_name (pvr_input_plugin_t *this, char *base, int page)
static void | pvr_report_realtime (pvr_input_plugin_t *this, int mode)
static int | pvr_break_rec_page (pvr_input_plugin_t *this)
static int | pvr_rec_file (pvr_input_plugin_t *this)
static int | pvr_play_file (pvr_input_plugin_t *this, fifo_buffer_t *fifo, uint8_t *buffer, int speed)
static int | pvr_mpeg_resync (int fd)
static void * | pvr_loop (void *this_gen)
static void | pvr_finish_recording (pvr_input_plugin_t *this)
static void | pvr_event_handler (pvr_input_plugin_t *this)
static buf_element_t * | pvr_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t todo)
static off_t | pvr_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin)
static off_t | pvr_plugin_get_current_pos (input_plugin_t *this_gen)
static off_t | pvr_plugin_get_length (input_plugin_t *this_gen)
static uint32_t | pvr_plugin_get_blocksize (input_plugin_t *this_gen)
static const char * | pvr_plugin_get_mrl (input_plugin_t *this_gen)
static int | pvr_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type)
static void | pvr_plugin_dispose (input_plugin_t *this_gen)
static int | pvr_plugin_open (input_plugin_t *this_gen)
static input_plugin_t * | pvr_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *data)
static void * | init_plugin (xine_t *xine, const void *data)

## Variables
const plugin_info_t xine_plugin_info[] | EXPORTED

## Macro Definition Documentation

## ◆ BLOCKS_PER_PAGE

#define BLOCKS_PER_PAGE 102400 /* 200MB per page. each session can have several pages */

Referenced by pvr_play_file(), and pvr_rec_file().

## ◆ IVTV_IOC_G_CODEC

#define IVTV_IOC_G_CODEC 0xFFEE7703

Referenced by pvr_event_handler(), and pvr_plugin_open().

## ◆ IVTV_IOC_S_CODEC

#define IVTV_IOC_S_CODEC 0xFFEE7704

Referenced by pvr_event_handler(), and pvr_plugin_open().

## ◆ IVTV_STREAM_DVD

#define IVTV_STREAM_DVD 10

Referenced by pvr_event_handler(), and pvr_plugin_open().

## ◆ IVTV_STREAM_MPEG1

#define IVTV_STREAM_MPEG1 2

## ◆ IVTV_STREAM_PES_A

#define IVTV_STREAM_PES_A 7

## ◆ IVTV_STREAM_PES_AV

#define IVTV_STREAM_PES_AV 3

## ◆ IVTV_STREAM_PES_V

#define IVTV_STREAM_PES_V 5

## ◆ IVTV_STREAM_PS

#define IVTV_STREAM_PS 0

## ◆ IVTV_STREAM_TS

#define IVTV_STREAM_TS 1

## ◆ LOG_MODULE

#define LOG_MODULE "input_pvr"

## ◆ LOG_VERBOSE

#define LOG_VERBOSE

## ◆ MAX_PAGES

#define MAX_PAGES 10000 /* maximum number of pages to keep track */

## ◆ NUM_PREVIEW_BUFFERS

#define NUM_PREVIEW_BUFFERS 250 /* used in mpeg_block demuxer */

Referenced by pvr_plugin_open().

## ◆ PVR_BLOCK_SIZE

#define PVR_BLOCK_SIZE 2048 /* pvr works with dvd-like data */

Referenced by pvr_loop(), pvr_play_file(), pvr_plugin_get_blocksize(), pvr_plugin_get_current_pos(), pvr_plugin_get_length(), pvr_plugin_read_block(), pvr_plugin_seek(), and pvr_rec_file().

## ◆ PVR_DEVICE

#define PVR_DEVICE "/dev/video0"

Referenced by init_plugin(), and pvr_class_get_instance().

## ◆ PVR_FILENAME

#define PVR_FILENAME "%s%08d_%08d.vob"

Referenced by make_temp_name().

## ◆ SAVE_BASE_FILENAME

#define SAVE_BASE_FILENAME "ch%03d %02d-%02d-%04d %02d:%02d:%02d"

Referenced by make_base_save_name().

## ◆ SAVE_FILENAME

#define SAVE_FILENAME "%s%s_%04d.vob"

Referenced by make_save_name().

## ◆ XINE_ENABLE_EXPERIMENTAL_FEATURES

#define XINE_ENABLE_EXPERIMENTAL_FEATURES

## Typedef Documentation

## ◆ pvrscr_t

typedef struct pvrscr_s pvrscr_t

## Function Documentation

## ◆ block_to_page()

static uint32_t block_to_page | ( | pvr_input_plugin_t * | this,
|  | uint32_t | block )
| static

Referenced by pvr_play_file(), and pvr_plugin_seek().

## ◆ init_plugin()

static void * init_plugin | ( | xine_t * | xine,
|  | const void * | data )
| static

References _, xine_s::config, input_plugin_s::dispose, input_class_s::get_instance, N_, NULL, pvr_class_get_instance(), PVR_DEVICE, config_values_s::register_filename, and XINE_CONFIG_STRING_IS_DEVICE_NAME.

## ◆ make_base_save_name()

static char * make_base_save_name | ( | int | channel,
|  | time_t | tm )
| static

References _x_asprintf(), and SAVE_BASE_FILENAME.

Referenced by pvr_finish_recording().

## ◆ make_save_name()

static char * make_save_name | ( | pvr_input_plugin_t * | this,
|  | char * | base,
|  | int | page )
| static

References _x_asprintf(), and SAVE_FILENAME.

Referenced by pvr_event_handler(), and pvr_finish_recording().

## ◆ make_temp_name()

static char * make_temp_name | ( | pvr_input_plugin_t * | this,
|  | int | page )
| static

References _x_asprintf(), and PVR_FILENAME.

Referenced by pvr_break_rec_page(), pvr_finish_recording(), and pvr_play_file().

## ◆ pvr_adjust_realtime_speed()

static void pvr_adjust_realtime_speed | ( | pvr_input_plugin_t * | this,
|  | fifo_buffer_t * | fifo,
|  | int | speed )
| static

References _x_set_speed(), fifo_buffer_s::num_free, pvrscr_speed_tunning(), fifo_buffer_s::size, XINE_SPEED_NORMAL, and XINE_SPEED_PAUSE.

Referenced by pvr_plugin_read_block().

## ◆ pvr_break_rec_page()

static int pvr_break_rec_page | ( | pvr_input_plugin_t * | this | ) |
| static

References _, lprintf, make_temp_name(), xine_create_cloexec(), XINE_VERBOSITY_LOG, and xprintf.

Referenced by pvr_event_handler(), and pvr_rec_file().

## ◆ pvr_class_get_instance()

static input_plugin_t * pvr_class_get_instance | ( | input_class_t * | cls_gen,
|  | xine_stream_t * | stream,
|  | const char * | data )
| static

References lprintf, NULL, PVR_DEVICE, pvr_plugin_dispose(), pvr_plugin_get_blocksize(), pvr_plugin_get_capabilities(), pvr_plugin_get_current_pos(), pvr_plugin_get_length(), pvr_plugin_get_mrl(), pvr_plugin_get_optional_data(), pvr_plugin_open(), pvr_plugin_read(), pvr_plugin_read_block(), pvr_plugin_seek(), xine_cfg_entry_s::str_value, xine_stream_s::xine, xine_config_lookup_entry(), and xine_list_new().

Referenced by init_plugin().

## ◆ pvr_event_handler()

static void pvr_event_handler | ( | pvr_input_plugin_t * | this | ) |
| static

References _, _x_demux_flush_engine(), _x_get_speed(), _x_set_speed(), saved_show_t::base_name, ivtv_ioctl_codec::bitrate, xine_set_mpeg_data_t::bitrate_mean, ivtv_ioctl_codec::bitrate_peak, xine_set_mpeg_data_t::bitrate_peak, xine_set_v4l2_data_t::channel, xine_set_v4l2_data_t::frequency, saved_show_t::id, input(), xine_set_v4l2_data_t::input, IVTV_IOC_G_CODEC, IVTV_IOC_S_CODEC, IVTV_STREAM_DVD, lprintf, make_save_name(), NULL, saved_show_t::pages, pvr_break_rec_page(), pvr_finish_recording(), pvrscr_speed_tunning(), xine_set_v4l2_data_t::session_id, ivtv_ioctl_codec::stream_type, xine_event_t::type, xine_event_free(), xine_event_get(), XINE_EVENT_PVR_PAUSE, XINE_EVENT_PVR_SAVE, XINE_EVENT_SET_MPEG_DATA, XINE_EVENT_SET_V4L2, xine_list_front(), xine_list_get_value(), xine_list_next(), xine_list_remove(), xine_open_cloexec(), XINE_SPEED_NORMAL, XINE_SPEED_PAUSE, XINE_VERBOSITY_DEBUG, XINE_VERBOSITY_LOG, and xprintf.

Referenced by pvr_plugin_read_block().

## ◆ pvr_finish_recording()

static void pvr_finish_recording | ( | pvr_input_plugin_t * | this | ) |
| static

References saved_show_t::base_name, saved_show_t::id, lprintf, make_base_save_name(), make_save_name(), make_temp_name(), NULL, saved_show_t::pages, xine_event_t::tv, XINE_EVENT_PVR_REPORT_NAME, xine_event_send(), xine_list_push_back(), XINE_VERBOSITY_LOG, and xprintf.

Referenced by pvr_event_handler(), and pvr_plugin_dispose().

## ◆ pvr_loop()

static void * pvr_loop | ( | void * | this_gen | ) |
| static

References _, NULL, PVR_BLOCK_SIZE, pvr_mpeg_resync(), pvr_rec_file(), XINE_VERBOSITY_DEBUG, XINE_VERBOSITY_LOG, and xprintf.

Referenced by pvr_plugin_open().

## ◆ pvr_mpeg_resync()

static int pvr_mpeg_resync | ( | int | fd | ) |
| static

Referenced by pvr_loop().

## ◆ pvr_play_file()

static int pvr_play_file | ( | pvr_input_plugin_t * | this,
|  | fifo_buffer_t * | fifo,
|  | uint8_t * | buffer,
|  | int | speed )
| static

References _, _x_set_speed(), block_to_page(), BLOCKS_PER_PAGE, lprintf, make_temp_name(), fifo_buffer_s::num_free, PVR_BLOCK_SIZE, pvr_report_realtime(), fifo_buffer_s::size, xine_open_cloexec(), XINE_SPEED_NORMAL, XINE_SPEED_PAUSE, XINE_VERBOSITY_DEBUG, XINE_VERBOSITY_LOG, and xprintf.

Referenced by pvr_plugin_read_block().

## ◆ pvr_plugin_dispose()

static void pvr_plugin_dispose | ( | input_plugin_t * | this_gen | ) |
| static

References _x_freep(), saved_show_t::base_name, lprintf, pvr_finish_recording(), xine_event_dispose_queue(), xine_list_delete(), xine_list_front(), xine_list_get_value(), and xine_list_next().

Referenced by pvr_class_get_instance().

## ◆ pvr_plugin_get_blocksize()

static uint32_t pvr_plugin_get_blocksize | ( | input_plugin_t * | this_gen | ) |
| static

References PVR_BLOCK_SIZE.

Referenced by pvr_class_get_instance().

## ◆ pvr_plugin_get_capabilities()

static uint32_t pvr_plugin_get_capabilities | ( | input_plugin_t * | this_gen | ) |
| static

References INPUT_CAP_BLOCK, and INPUT_CAP_SEEKABLE.

Referenced by pvr_class_get_instance().

## ◆ pvr_plugin_get_current_pos()

static off_t pvr_plugin_get_current_pos | ( | input_plugin_t * | this_gen | ) |
| static

References PVR_BLOCK_SIZE.

Referenced by pvr_class_get_instance().

## ◆ pvr_plugin_get_length()

static off_t pvr_plugin_get_length | ( | input_plugin_t * | this_gen | ) |
| static

References PVR_BLOCK_SIZE.

Referenced by pvr_class_get_instance().

## ◆ pvr_plugin_get_mrl()

static const char * pvr_plugin_get_mrl | ( | input_plugin_t * | this_gen | ) |
| static

Referenced by pvr_class_get_instance().

## ◆ pvr_plugin_get_optional_data()

static int pvr_plugin_get_optional_data | ( | input_plugin_t * | this_gen,
|  | void * | data,
|  | int | data_type )
| static

References INPUT_OPTIONAL_UNSUPPORTED.

Referenced by pvr_class_get_instance().

## ◆ pvr_plugin_open()

static int pvr_plugin_open | ( | input_plugin_t * | this_gen | ) |
| static

References _, _x_assert, ivtv_ioctl_codec::bitrate, ivtv_ioctl_codec::bitrate_mode, ivtv_ioctl_codec::bitrate_peak, input(), IVTV_IOC_G_CODEC, IVTV_IOC_S_CODEC, IVTV_STREAM_DVD, NULL, NUM_PREVIEW_BUFFERS, pvr_loop(), pvrscr_init(), ivtv_ioctl_codec::stream_type, xine_event_new_queue(), xine_open_cloexec(), XINE_VERBOSITY_LOG, XINE_VERBOSITY_NONE, and xprintf.

Referenced by pvr_class_get_instance().

## ◆ pvr_plugin_read()

static off_t pvr_plugin_read | ( | input_plugin_t * | this_gen,
|  | void * | buf_gen,
|  | off_t | len )
| static

Referenced by pvr_class_get_instance().

## ◆ pvr_plugin_read_block()

static buf_element_t * pvr_plugin_read_block | ( | input_plugin_t * | this_gen,
|  | fifo_buffer_t * | fifo,
|  | off_t | todo )
| static

References _x_get_speed(), _x_stream_info_get(), BUF_CONTROL_NOP, BUF_DEMUX_BLOCK, fifo_buffer_s::buffer_pool_alloc, buf_element_s::content, buf_element_s::free_buffer, buf_element_s::max_size, buf_element_s::mem, NULL, pvr_adjust_realtime_speed(), PVR_BLOCK_SIZE, pvr_event_handler(), pvr_play_file(), pvrscr_speed_tunning(), buf_element_s::size, buf_element_s::type, xine_fast_memcpy, XINE_SPEED_PAUSE, XINE_STREAM_INFO_IGNORE_VIDEO, xine_usec_sleep(), XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by pvr_class_get_instance().

## ◆ pvr_plugin_seek()

static off_t pvr_plugin_seek | ( | input_plugin_t * | this_gen,
|  | off_t | offset,
|  | int | origin )
| static

References block_to_page(), PVR_BLOCK_SIZE, and pvr_report_realtime().

Referenced by pvr_class_get_instance().

## ◆ pvr_rec_file()

static int pvr_rec_file | ( | pvr_input_plugin_t * | this | ) |
| static

References BLOCKS_PER_PAGE, PVR_BLOCK_SIZE, pvr_break_rec_page(), XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by pvr_loop().

## ◆ pvr_report_realtime()

static void pvr_report_realtime | ( | pvr_input_plugin_t * | this,
|  | int | mode )
| static

References mode(), NULL, xine_event_t::tv, xine_event_t::type, XINE_EVENT_PVR_REALTIME, and xine_event_send().

Referenced by pvr_play_file(), and pvr_plugin_seek().

## ◆ pvrscr_adjust()

static void pvrscr_adjust | ( | scr_plugin_t * | scr,
|  | int64_t | vpts )
| static

References NULL, and xine_monotonic_clock().

Referenced by pvrscr_init().

## ◆ pvrscr_exit()

static void pvrscr_exit | ( | scr_plugin_t * | scr | ) |
| static

Referenced by pvrscr_init().

## ◆ pvrscr_get_current()

static int64_t pvrscr_get_current | ( | scr_plugin_t * | scr | ) |
| static

References NULL, and xine_monotonic_clock().

Referenced by pvrscr_init().

## ◆ pvrscr_get_priority()

static int pvrscr_get_priority | ( | scr_plugin_t * | scr | ) |
| static

Referenced by pvrscr_init().

## ◆ pvrscr_init()

static pvrscr_t * pvrscr_init | ( | void |  | ) |
| static

References NULL, pvrscr_adjust(), pvrscr_exit(), pvrscr_get_current(), pvrscr_get_priority(), pvrscr_set_speed(), pvrscr_speed_tunning(), pvrscr_start(), and XINE_SPEED_PAUSE.

Referenced by pvr_plugin_open().

## ◆ pvrscr_set_pivot()

static void pvrscr_set_pivot | ( | pvrscr_t * | this | ) |
| static

References NULL, and xine_monotonic_clock().

Referenced by pvrscr_set_speed(), and pvrscr_speed_tunning().

## ◆ pvrscr_set_speed()

static int pvrscr_set_speed | ( | scr_plugin_t * | scr,
|  | int | speed )
| static

References pvrscr_set_pivot(), and XINE_FINE_SPEED_NORMAL.

Referenced by pvrscr_init(), and pvrscr_start().

## ◆ pvrscr_speed_tunning()

static void pvrscr_speed_tunning | ( | pvrscr_t * | this,
|  | double | factor )
| static

References pvrscr_set_pivot(), and XINE_FINE_SPEED_NORMAL.

Referenced by pvr_adjust_realtime_speed(), pvr_event_handler(), pvr_plugin_read_block(), and pvrscr_init().

## ◆ pvrscr_start()

static void pvrscr_start | ( | scr_plugin_t * | scr,
|  | int64_t | start_vpts )
| static

References NULL, pvrscr_set_speed(), XINE_FINE_SPEED_NORMAL, and xine_monotonic_clock().

Referenced by pvrscr_init().

## Variable Documentation

## ◆ EXPORTED

const plugin_info_t xine_plugin_info [] EXPORTED

Initial value:
= {
{ PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "pvr", XINE_VERSION_CODE, NULL, init_plugin },
{ PLUGIN_NONE, 0, NULL, 0, NULL, NULL }
}
init_plugin
static void * init_plugin(xine_t *xine, const void *data)
Definition input_pvr.c:1572
XINE_VERSION_CODE
#define XINE_VERSION_CODE
Definition xine_internal.h:57
NULL
NULL
Definition xine_plugin.c:78
PLUGIN_NONE
#define PLUGIN_NONE
Definition xine_plugin.h:29
PLUGIN_MUST_PRELOAD
#define PLUGIN_MUST_PRELOAD
Definition xine_plugin.h:46
PLUGIN_INPUT
#define PLUGIN_INPUT
Definition xine_plugin.h:30