xine-lib 1.2.13-20230125hg15249
Data Structures | Macros | Typedefs | Functions | Variables
input_v4l.c File Reference
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/videodev.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <errno.h>
#include <xine/xine_internal.h>
#include <xine/xineutils.h>
#include <xine/input_plugin.h>

Data Structures

struct  resolution_t
 
struct  v4l_input_plugin_t
 
struct  pvrscr_s
 

Macros

#define _LINUX_TIME_H
 
#define ALSA_PCM_NEW_HW_PARAMS_API
 
#define ALSA_PCM_NEW_SW_PARAMS_API
 
#define XINE_ENABLE_EXPERIMENTAL_FEATURES
 
#define LOG_VERBOSE
 
#define NUM_FRAMES   15
 
#define MAX_RES   640
 
#define NUM_RESOLUTIONS   (sizeof(resolutions)/sizeof(resolutions[0]))
 
#define RADIO_DEV   "/dev/radio0"
 
#define VIDEO_DEV   "/dev/video0"
 
#define SCR_PAUSED   -2
 
#define SCR_FW   -3
 
#define SCR_SKIP   -4
 

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_fine_speed (scr_plugin_t *scr, int speed)
 
static void pvrscr_speed_tuning (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_tpvrscr_init (void)
 
static void report_progress (xine_stream_t *stream, int p)
 
static int search_by_tuner (v4l_input_plugin_t *this, char *input_source)
 
static int search_by_channel (v4l_input_plugin_t *this, char *input_source)
 
static void v4l_event_handler (v4l_input_plugin_t *this)
 
static buf_element_talloc_aud_frame (v4l_input_plugin_t *this)
 
static void store_aud_frame (buf_element_t *frame)
 
static buf_element_talloc_vid_frame (v4l_input_plugin_t *this)
 
static void store_vid_frame (buf_element_t *frame)
 
static int extract_mrl (v4l_input_plugin_t *this, const char *mrl)
 
static int set_frequency (v4l_input_plugin_t *this, unsigned long frequency)
 
static int set_input_source (v4l_input_plugin_t *this, char *input_source)
 
static void allocate_frames (v4l_input_plugin_t *this, unsigned dovideo)
 
static void unmute_audio (v4l_input_plugin_t *this)
 
static int open_radio_capture_device (v4l_input_plugin_t *this)
 
static int open_video_capture_device (v4l_input_plugin_t *this)
 
static int open_audio_capture_device (v4l_input_plugin_t *this)
 
static int v4l_adjust_realtime_speed (v4l_input_plugin_t *this, fifo_buffer_t *fifo, int speed)
 
static off_t v4l_plugin_read (input_plugin_t *this_gen, void *buf, off_t len)
 
static int64_t get_time (void)
 
static buf_element_tv4l_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t todo)
 
static off_t v4l_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin)
 
static off_t v4l_plugin_get_length (input_plugin_t *this_gen)
 
static uint32_t v4l_plugin_get_capabilities (input_plugin_t *this_gen)
 
static uint32_t v4l_plugin_get_blocksize (input_plugin_t *this_gen)
 
static off_t v4l_plugin_get_current_pos (input_plugin_t *this_gen)
 
static void v4l_plugin_dispose (input_plugin_t *this_gen)
 
static const char * v4l_plugin_get_mrl (input_plugin_t *this_gen)
 
static int v4l_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type)
 
static int v4l_plugin_radio_open (input_plugin_t *this_gen)
 
static int v4l_plugin_video_open (input_plugin_t *this_gen)
 
static input_plugin_tv4l_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *data)
 
static input_plugin_tv4l_class_get_video_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *data)
 
static input_plugin_tv4l_class_get_radio_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *data)
 
static void * init_video_class (xine_t *xine, const void *data)
 
static void * init_radio_class (xine_t *xine, const void *data)
 

Variables

static const resolution_t resolutions []
 
static const char *const tv_standard_names [] = { "AUTO", "PAL", "NTSC", "SECAM", "OLD", NULL }
 
static const int tv_standard_values [] = { VIDEO_MODE_AUTO, VIDEO_MODE_PAL, VIDEO_MODE_NTSC, VIDEO_MODE_SECAM, -1 }
 
const plugin_info_t xine_plugin_info[] EXPORTED
 

Macro Definition Documentation

◆ _LINUX_TIME_H

#define _LINUX_TIME_H

◆ ALSA_PCM_NEW_HW_PARAMS_API

#define ALSA_PCM_NEW_HW_PARAMS_API

◆ ALSA_PCM_NEW_SW_PARAMS_API

#define ALSA_PCM_NEW_SW_PARAMS_API

◆ LOG_VERBOSE

#define LOG_VERBOSE

◆ MAX_RES

#define MAX_RES   640

◆ NUM_FRAMES

#define NUM_FRAMES   15

◆ NUM_RESOLUTIONS

#define NUM_RESOLUTIONS   (sizeof(resolutions)/sizeof(resolutions[0]))

◆ RADIO_DEV

#define RADIO_DEV   "/dev/radio0"

Referenced by init_radio_class().

◆ SCR_FW

#define SCR_FW   -3

Referenced by report_progress().

◆ SCR_PAUSED

#define SCR_PAUSED   -2

◆ SCR_SKIP

#define SCR_SKIP   -4

◆ VIDEO_DEV

#define VIDEO_DEV   "/dev/video0"

Referenced by init_video_class().

◆ XINE_ENABLE_EXPERIMENTAL_FEATURES

#define XINE_ENABLE_EXPERIMENTAL_FEATURES

Typedef Documentation

◆ pvrscr_t

typedef struct pvrscr_s pvrscr_t

Function Documentation

◆ alloc_aud_frame()

static buf_element_t * alloc_aud_frame ( v4l_input_plugin_t * this)
inlinestatic

Allocate an audio frame.

References lprintf, and buf_element_s::next.

Referenced by v4l_plugin_read_block().

◆ alloc_vid_frame()

static buf_element_t * alloc_vid_frame ( v4l_input_plugin_t * this)
inlinestatic

Allocate a video frame.

References lprintf, and buf_element_s::next.

Referenced by v4l_plugin_read_block().

◆ allocate_frames()

static void allocate_frames ( v4l_input_plugin_t * this,
unsigned dovideo )
static

◆ extract_mrl()

static int extract_mrl ( v4l_input_plugin_t * this,
const char * mrl )
static

References lprintf, and NULL.

Referenced by v4l_class_get_instance().

◆ get_time()

static int64_t get_time ( void )
inlinestatic

Get time. Gets a pts time value.

References NULL, and xine_monotonic_clock().

Referenced by v4l_plugin_read_block().

◆ init_radio_class()

static void * init_radio_class ( xine_t * xine,
const void * data )
static

◆ init_video_class()

static void * init_video_class ( xine_t * xine,
const void * data )
static

◆ open_audio_capture_device()

static int open_audio_capture_device ( v4l_input_plugin_t * this)
static

Open audio capture device.

This function opens an alsa capture device. This will be used to capture audio data from.

References lprintf, mode(), NULL, XINE_VERBOSITY_LOG, and xprintf.

Referenced by v4l_plugin_radio_open(), and v4l_plugin_video_open().

◆ open_radio_capture_device()

static int open_radio_capture_device ( v4l_input_plugin_t * this)
static

◆ open_video_capture_device()

static int open_video_capture_device ( v4l_input_plugin_t * this)
static

◆ 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

◆ pvrscr_set_fine_speed()

static int pvrscr_set_fine_speed ( scr_plugin_t * scr,
int speed )
static

◆ pvrscr_set_pivot()

static void pvrscr_set_pivot ( pvrscr_t * this)
static

◆ pvrscr_speed_tuning()

static void pvrscr_speed_tuning ( pvrscr_t * this,
double factor )
static

◆ pvrscr_start()

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

◆ report_progress()

static void report_progress ( xine_stream_t * stream,
int p )
static

◆ search_by_channel()

static int search_by_channel ( v4l_input_plugin_t * this,
char * input_source )
static

◆ search_by_tuner()

static int search_by_tuner ( v4l_input_plugin_t * this,
char * input_source )
static

References lprintf, and NULL.

Referenced by set_input_source().

◆ set_frequency()

static int set_frequency ( v4l_input_plugin_t * this,
unsigned long frequency )
static

◆ set_input_source()

static int set_input_source ( v4l_input_plugin_t * this,
char * input_source )
static

◆ store_aud_frame()

static void store_aud_frame ( buf_element_t * frame)
static

Stores an audio frame.

References lprintf, buf_element_s::next, and buf_element_s::source.

Referenced by allocate_frames().

◆ store_vid_frame()

static void store_vid_frame ( buf_element_t * frame)
static

Stores a video frame.

References lprintf, buf_element_s::next, and buf_element_s::source.

Referenced by allocate_frames().

◆ unmute_audio()

static void unmute_audio ( v4l_input_plugin_t * this)
static

◆ v4l_adjust_realtime_speed()

static int v4l_adjust_realtime_speed ( v4l_input_plugin_t * this,
fifo_buffer_t * fifo,
int speed )
static

Adjust realtime speed

If xine is playing at normal speed, tries to adjust xines playing speed to avoid buffer overrun and buffer underrun

References _x_set_speed(), CLOCK_SCR_ADJUSTABLE, NULL, NUM_FRAMES, pvrscr_speed_tuning(), report_progress(), SCR_PAUSED, SCR_SKIP, fifo_buffer_s::size, XINE_SPEED_NORMAL, XINE_SPEED_PAUSE, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by v4l_plugin_read_block().

◆ v4l_class_get_instance()

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

◆ v4l_class_get_radio_instance()

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

◆ v4l_class_get_video_instance()

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

◆ v4l_event_handler()

static void v4l_event_handler ( v4l_input_plugin_t * this)
static

Event handler.

Processes events from a frontend. This way frequencies can be changed without closing the v4l plugin.

References _x_demux_flush_engine(), xine_set_v4l2_data_t::channel, xine_set_v4l2_data_t::frequency, xine_set_v4l2_data_t::input, input(), lprintf, set_frequency(), xine_event_t::type, xine_event_free(), xine_event_get(), and XINE_EVENT_SET_V4L2.

Referenced by v4l_plugin_read_block().

◆ v4l_plugin_dispose()

static void v4l_plugin_dispose ( input_plugin_t * this_gen)
static

Dispose plugin.

Closes the plugin, restore the V4L device in the initial state (volume) and frees the allocated memory

References _x_freep(), lprintf, NULL, xine_event_dispose_queue(), XINE_PARAM_VO_ZOOM_X, XINE_PARAM_VO_ZOOM_Y, xine_set_param(), XINE_VERBOSITY_LOG, and xprintf.

Referenced by v4l_class_get_instance(), v4l_class_get_radio_instance(), and v4l_class_get_video_instance().

◆ v4l_plugin_get_blocksize()

static uint32_t v4l_plugin_get_blocksize ( input_plugin_t * this_gen)
static

Plugin get block size. Unsupported by the plugin.

Referenced by v4l_class_get_instance().

◆ v4l_plugin_get_capabilities()

static uint32_t v4l_plugin_get_capabilities ( input_plugin_t * this_gen)
static

Plugin get capabilitiets. This plugin does not support any special capabilities.

Referenced by v4l_class_get_instance().

◆ v4l_plugin_get_current_pos()

static off_t v4l_plugin_get_current_pos ( input_plugin_t * this_gen)
static

Plugin get current pos. Unsupported by the plugin.

Referenced by v4l_class_get_instance().

◆ v4l_plugin_get_length()

static off_t v4l_plugin_get_length ( input_plugin_t * this_gen)
static

Plugin get length. This is a live stream, and as such does not have an known end.

Referenced by v4l_class_get_instance().

◆ v4l_plugin_get_mrl()

static const char * v4l_plugin_get_mrl ( input_plugin_t * this_gen)
static

Get MRL.

Get the current MRL used by the plugin.

Referenced by v4l_class_get_instance().

◆ v4l_plugin_get_optional_data()

static int v4l_plugin_get_optional_data ( input_plugin_t * this_gen,
void * data,
int data_type )
static

◆ v4l_plugin_radio_open()

static int v4l_plugin_radio_open ( input_plugin_t * this_gen)
static

◆ v4l_plugin_read()

static off_t v4l_plugin_read ( input_plugin_t * this_gen,
void * buf,
off_t len )
static

Plugin read. This function is not supported by the plugin.

References lprintf.

Referenced by v4l_class_get_instance().

◆ v4l_plugin_read_block()

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

◆ v4l_plugin_seek()

static off_t v4l_plugin_seek ( input_plugin_t * this_gen,
off_t offset,
int origin )
static

Plugin seek. Not supported by the plugin.

References lprintf.

Referenced by v4l_class_get_instance().

◆ v4l_plugin_video_open()

static int v4l_plugin_video_open ( input_plugin_t * this_gen)
static

Variable Documentation

◆ EXPORTED

const plugin_info_t xine_plugin_info [] EXPORTED
Initial value:
= {
{ PLUGIN_NONE, 0, NULL, 0, NULL, NULL }
}
static void * init_video_class(xine_t *xine, const void *data)
Definition input_v4l.c:1911
static void * init_radio_class(xine_t *xine, const void *data)
Definition input_v4l.c:1947
#define XINE_VERSION_CODE
Definition xine_internal.h:57
NULL
Definition xine_plugin.c:78
#define PLUGIN_NONE
Definition xine_plugin.h:29
#define PLUGIN_MUST_PRELOAD
Definition xine_plugin.h:46
#define PLUGIN_INPUT
Definition xine_plugin.h:30

◆ resolutions

const resolution_t resolutions[]
static
Initial value:
= {
{ 768, 576 },
{ 640, 480 },
{ 384, 288 },
{ 320, 240 },
{ 160, 120 }
}

Referenced by open_video_capture_device().

◆ tv_standard_names

const char* const tv_standard_names[] = { "AUTO", "PAL", "NTSC", "SECAM", "OLD", NULL }
static

◆ tv_standard_values

const int tv_standard_values[] = { VIDEO_MODE_AUTO, VIDEO_MODE_PAL, VIDEO_MODE_NTSC, VIDEO_MODE_SECAM, -1 }
static

Referenced by search_by_channel().