xine-lib: xine-lib-1.2.12/src/demuxers/demux_flv.c File Reference

xine-lib 1.2.12

Data Structures | Macros | Enumerations | Functions
demux_flv.c File Reference
`#include <stdio.h>`
`#include <fcntl.h>`
`#include <unistd.h>`
`#include <string.h>`
`#include <stdlib.h>`
`#include <time.h>`
`#include "group_video.h"`
`#include <xine/xine_internal.h>`
`#include <xine/xineutils.h>`
`#include <xine/compat.h>`
`#include <xine/demux.h>`
`#include "bswap.h"`

## Data Structures
struct | flv_index_entry_t
struct | demux_flv_t

## Macros
#define | LOG_MODULE "demux_flv"
#define | LOG_VERBOSE
#define | TEMPBUFSIZE 4096
#define | gettimestamp(p, o) (((((((uint32_t)p[o+3]<<8)|p[o])<<8)|p[o+1])<<8)|p[o+2])
#define | FLV_FLAG_HAS_VIDEO 0x01
#define | FLV_FLAG_HAS_AUDIO 0x04
#define | FLV_TAG_TYPE_AUDIO 0x08
#define | FLV_TAG_TYPE_VIDEO 0x09
#define | FLV_TAG_TYPE_NOTIFY 0x12
#define | IS_PCM(id) ((((1<<AF_PCM_BE)|(1<<AF_ADPCM)|(1<<AF_PCM_LE)|(1<<AF_ALAW)|(1<<AF_MULAW))>>(id))&1)
#define | abs(x) ( ((x)<0) ? -(x) : (x) )
#define | WRAP_THRESHOLD 220000
#define | PTS_AUDIO 0
#define | PTS_VIDEO 1
#define | BE_F64(buf)
#define | MAX_AMF_LEVELS 10
#define | SPC (space + 2 * (MAX_AMF_LEVELS - level))
#define | NEEDBYTES(n) if ((unsigned long int)(end - p) < n) return 0
#define | GETBYTES(n)

## Enumerations
enum | af_t { AF_PCM_BE , AF_ADPCM , AF_MP3 , AF_PCM_LE , AF_NELLY16 , AF_NELLY8 , AF_NELLY , AF_ALAW , AF_MULAW , AF_reserved9 , AF_AAC , AF_SPEEX , AF_reserved12 , AF_reserved13 , AF_MP38 , AF_DS }
enum | vf_t { VF_reserved0 , VF_JPEG , VF_FLV1 , VF_SCREEN , VF_VP6 , VF_VP6A , VF_SCREEN2 , VF_H264 , VF_H263 , VF_MP4 , VF_reserved10 , VF_reserved11 , VF_HEVC }
enum | amf_type_t { AMF0_NUMBER = 0x00 , AMF0_BOOLEAN = 0x01 , AMF0_STRING = 0x02 , AMF0_OBJECT = 0x03 , AMF0_MOVIECLIP = 0x04 , AMF0_NULL_VALUE = 0x05 , AMF0_UNDEFINED = 0x06 , AMF0_REFERENCE = 0x07 , AMF0_ECMA_ARRAY = 0x08 , AMF0_OBJECT_END = 0x09 , AMF0_STRICT_ARRAY = 0x0a , AMF0_DATE = 0x0b , AMF0_LONG_STRING = 0x0c , AMF0_UNSUPPORTED = 0x0d , AMF0_RECORD_SET = 0x0e , AMF0_XML_OBJECT = 0x0f , AMF0_TYPED_OBJECT = 0x10 , AMF0_AMF3 = 0x11 }
enum | _k_t { _K_NONE = 0 , _K_duration , _K_width , _K_height , _K_videoframerate , _K_videodatarate , _K_videocodecid , _K_audiosamplerate , _K_audiosamplesize , _K_stereo , _K_audiodatarate , _K_audiocodecid , _K_filesize , _K_audiodelay , _K_onMetaData , _K_times , _K_filepositions , _K_LAST , _K_NONE = 0 , _K_content_length , _K_content_type , _K_content_encoding , _K_content_range , _K_transfer_encoding , _K_accept_ranges , _K_location , _K_server , _K_www_authenticate , _K_icy_name , _K_icy_genre , _K_icy_notice2 , _K_icy_metaint , _K_LAST }

## Functions
static void | check_newpts (demux_flv_t *this, int64_t pts, int video)
static _k_t | key_num (const char *key, uint32_t klen)
static int | parse_amf (demux_flv_t *this, unsigned char *buf, int size)
static int | read_flv_packet (demux_flv_t *this, int preview)
static void | seek_flv_file (demux_flv_t *this, off_t seek_pos, int seek_pts)
static int | demux_flv_send_chunk (demux_plugin_t *this_gen)
static void | demux_flv_send_headers (demux_plugin_t *this_gen)
static int | demux_flv_seek (demux_plugin_t *this_gen, off_t start_pos, int start_time, int playing)
static void | demux_flv_dispose (demux_plugin_t *this_gen)
static int | demux_flv_get_status (demux_plugin_t *this_gen)
static int | demux_flv_get_stream_length (demux_plugin_t *this_gen)
static uint32_t | demux_flv_get_capabilities (demux_plugin_t *this_gen)
static int | demux_flv_get_optional_data (demux_plugin_t *this_gen, void *data, int data_type)
static demux_plugin_t * | open_plugin (demux_class_t *class_gen, xine_stream_t *stream, input_plugin_t *input)
void * | demux_flv_init_class (xine_t *xine, const void *data)

## Macro Definition Documentation

## ◆ abs

#define abs | ( |  | x | ) | ( ((x)<0) ? -(x) : (x) )

## ◆ BE_F64

#define BE_F64 | ( |  | buf | ) |

Value:
({\
union { uint64_t q; double d; } _tmp;\
_tmp.q = _X_BE_64(buf);\
_tmp.d;\
})\
_X_BE_64
#define _X_BE_64(x)
Definition: bswap.h:49

## ◆ FLV_FLAG_HAS_AUDIO

#define FLV_FLAG_HAS_AUDIO 0x04

## ◆ FLV_FLAG_HAS_VIDEO

#define FLV_FLAG_HAS_VIDEO 0x01

## ◆ FLV_TAG_TYPE_AUDIO

#define FLV_TAG_TYPE_AUDIO 0x08

## ◆ FLV_TAG_TYPE_NOTIFY

#define FLV_TAG_TYPE_NOTIFY 0x12

## ◆ FLV_TAG_TYPE_VIDEO

#define FLV_TAG_TYPE_VIDEO 0x09

## ◆ GETBYTES

#define GETBYTES | ( |  | n | ) |

Value:
if (remaining_bytes < n) \
continue; \
if (this->input->read (this->input, (char *)buffer + 16, n) != n) \
goto fail; \
remaining_bytes -= n;
input
static int input(void)
Definition: goomsl_lex.c:1495

## ◆ gettimestamp

#define gettimestamp | ( |  | p,
|  |  | o
| ) |  | (((((((uint32_t)p[o+3]<<8)|p[o])<<8)|p[o+1])<<8)|p[o+2])

## ◆ IS_PCM

#define IS_PCM | ( |  | id | ) | ((((1<<AF_PCM_BE)|(1<<AF_ADPCM)|(1<<AF_PCM_LE)|(1<<AF_ALAW)|(1<<AF_MULAW))>>(id))&1)

## ◆ LOG_MODULE

#define LOG_MODULE "demux_flv"

## ◆ LOG_VERBOSE

#define LOG_VERBOSE

## ◆ MAX_AMF_LEVELS

#define MAX_AMF_LEVELS 10

## ◆ NEEDBYTES

#define NEEDBYTES | ( |  | n | ) | if ((unsigned long int)(end - p) < n) return 0

## ◆ PTS_AUDIO

#define PTS_AUDIO 0

## ◆ PTS_VIDEO

#define PTS_VIDEO 1

## ◆ SPC

#define SPC (space + 2 * (MAX_AMF_LEVELS - level))

## ◆ TEMPBUFSIZE

#define TEMPBUFSIZE 4096

## ◆ WRAP_THRESHOLD

#define WRAP_THRESHOLD 220000

## Enumeration Type Documentation

## ◆ _k_t

enum _k_t

Enumerator
_K_NONE |
_K_duration |
_K_width |
_K_height |
_K_videoframerate |
_K_videodatarate |
_K_videocodecid |
_K_audiosamplerate |
_K_audiosamplesize |
_K_stereo |
_K_audiodatarate |
_K_audiocodecid |
_K_filesize |
_K_audiodelay |
_K_onMetaData |
_K_times |
_K_filepositions |
_K_LAST |
_K_NONE |
_K_content_length |
_K_content_type |
_K_content_encoding |
_K_content_range |
_K_transfer_encoding |
_K_accept_ranges |
_K_location |
_K_server |
_K_www_authenticate |
_K_icy_name |
_K_icy_genre |
_K_icy_notice2 |
_K_icy_metaint |
_K_LAST |

## ◆ af_t

enum af_t

Enumerator
AF_PCM_BE |
AF_ADPCM |
AF_MP3 |
AF_PCM_LE |
AF_NELLY16 |
AF_NELLY8 |
AF_NELLY |
AF_ALAW |
AF_MULAW |
AF_reserved9 |
AF_AAC |
AF_SPEEX |
AF_reserved12 |
AF_reserved13 |
AF_MP38 |
AF_DS |

## ◆ amf_type_t

enum amf_type_t

Enumerator
AMF0_NUMBER |
AMF0_BOOLEAN |
AMF0_STRING |
AMF0_OBJECT |
AMF0_MOVIECLIP |
AMF0_NULL_VALUE |
AMF0_UNDEFINED |
AMF0_REFERENCE |
AMF0_ECMA_ARRAY |
AMF0_OBJECT_END |
AMF0_STRICT_ARRAY |
AMF0_DATE |
AMF0_LONG_STRING |
AMF0_UNSUPPORTED |
AMF0_RECORD_SET |
AMF0_XML_OBJECT |
AMF0_TYPED_OBJECT |
AMF0_AMF3 |

## ◆ vf_t

enum vf_t

Enumerator
VF_reserved0 |
VF_JPEG |
VF_FLV1 |
VF_SCREEN |
VF_VP6 |
VF_VP6A |
VF_SCREEN2 |
VF_H264 |
VF_H263 |
VF_MP4 |
VF_reserved10 |
VF_reserved11 |
VF_HEVC |

## Function Documentation

## ◆ check_newpts()

static void check_newpts | ( | demux_flv_t * | this,
|  | int64_t | pts,
|  | int | video
| ) |  |
| static

References _x_demux_control_newpts(), abs, BUF_FLAG_SEEK, lprintf, and WRAP_THRESHOLD.

Referenced by read_flv_packet().

## ◆ demux_flv_dispose()

static void demux_flv_dispose | ( | demux_plugin_t * | this_gen | ) |
| static

Referenced by open_plugin().

## ◆ demux_flv_get_capabilities()

static uint32_t demux_flv_get_capabilities | ( | demux_plugin_t * | this_gen | ) |
| static

References DEMUX_CAP_AUDIOLANG, and DEMUX_CAP_VIDEO_TIME.

Referenced by open_plugin().

## ◆ demux_flv_get_optional_data()

static int demux_flv_get_optional_data | ( | demux_plugin_t * | this_gen,
|  | void * | data,
|  | int | data_type
| ) |  |
| static

References DEMUX_OPTIONAL_DATA_AUDIOLANG, DEMUX_OPTIONAL_DATA_VIDEO_TIME, DEMUX_OPTIONAL_SUCCESS, DEMUX_OPTIONAL_UNSUPPORTED, and NULL.

Referenced by open_plugin().

## ◆ demux_flv_get_status()

static int demux_flv_get_status | ( | demux_plugin_t * | this_gen | ) |
| static

Referenced by open_plugin().

## ◆ demux_flv_get_stream_length()

static int demux_flv_get_stream_length | ( | demux_plugin_t * | this_gen | ) |
| static

Referenced by open_plugin().

## ◆ demux_flv_init_class()

void * demux_flv_init_class | ( | xine_t * | xine,
|  | const void * | data
| ) |  |

References N_, NULL, open_plugin(), and demux_class_s::open_plugin.

## ◆ demux_flv_seek()

static int demux_flv_seek | ( | demux_plugin_t * | this_gen,
|  | off_t | start_pos,
|  | int | start_time,
|  | int | playing
| ) |  |
| static

References _x_demux_control_newpts(), _x_demux_flush_engine(), DEMUX_OK, input(), INPUT_IS_SEEKABLE, and seek_flv_file().

Referenced by open_plugin().

## ◆ demux_flv_send_chunk()

static int demux_flv_send_chunk | ( | demux_plugin_t * | this_gen | ) |
| static

References read_flv_packet().

Referenced by open_plugin().

## ◆ demux_flv_send_headers()

static void demux_flv_send_headers | ( | demux_plugin_t * | this_gen | ) |
| static

References _x_demux_control_start(), _x_stream_info_set(), DEMUX_OK, FLV_FLAG_HAS_AUDIO, FLV_FLAG_HAS_VIDEO, lprintf, read_flv_packet(), XINE_STREAM_INFO_HAS_AUDIO, and XINE_STREAM_INFO_HAS_VIDEO.

Referenced by open_plugin().

## ◆ key_num()

static _k_t key_num | ( | const char * | key,
|  | uint32_t | klen
| ) |  |
| static

References _K_audiocodecid, _K_audiodatarate, _K_audiodelay, _K_audiosamplerate, _K_audiosamplesize, _K_duration, _K_filepositions, _K_filesize, _K_height, _K_NONE, _K_onMetaData, _K_stereo, _K_times, _K_videocodecid, _K_videodatarate, _K_videoframerate, _K_width, and key.

Referenced by parse_amf().

## ◆ open_plugin()

static demux_plugin_t * open_plugin | ( | demux_class_t * | class_gen,
|  | xine_stream_t * | stream,
|  | input_plugin_t * | input
| ) |  |
| static

References _, _X_BE_32, _x_demux_read_header(), xine_stream_s::content_detection_method, DEMUX_FINISHED, demux_flv_dispose(), demux_flv_get_capabilities(), demux_flv_get_optional_data(), demux_flv_get_status(), demux_flv_get_stream_length(), demux_flv_seek(), demux_flv_send_chunk(), demux_flv_send_headers(), FLV_FLAG_HAS_AUDIO, FLV_FLAG_HAS_VIDEO, input(), lprintf, METHOD_BY_CONTENT, METHOD_BY_MRL, METHOD_EXPLICIT, NULL, TEMPBUFSIZE, xine_stream_s::xine, XINE_VERBOSITY_LOG, and xprintf.

Referenced by demux_flv_init_class().

## ◆ parse_amf()

static int parse_amf | ( | demux_flv_t * | this,
|  | unsigned char * | buf,
|  | int | size
| ) |  |
| static

References _K_audiocodecid, _K_audiodatarate, _K_audiodelay, _K_audiosamplerate, _K_audiosamplesize, _K_duration, _K_filepositions, _K_filesize, _K_height, _K_NONE, _K_stereo, _K_times, _K_videocodecid, _K_videodatarate, _K_videoframerate, _K_width, _X_BE_16, _X_BE_32, _x_stream_info_set(), AF_AAC, AMF0_BOOLEAN, AMF0_DATE, AMF0_ECMA_ARRAY, AMF0_LONG_STRING, AMF0_NULL_VALUE, AMF0_NUMBER, AMF0_OBJECT, AMF0_OBJECT_END, AMF0_REFERENCE, AMF0_STRICT_ARRAY, AMF0_STRING, AMF0_UNDEFINED, AMF0_XML_OBJECT, BE_F64, height, key_num(), MAX_AMF_LEVELS, name, NEEDBYTES, NULL, SPC, type, VF_H264, width, XINE_STREAM_INFO_AUDIO_BITRATE, XINE_STREAM_INFO_AUDIO_BITS, XINE_STREAM_INFO_AUDIO_CHANNELS, XINE_STREAM_INFO_AUDIO_SAMPLERATE, XINE_STREAM_INFO_FRAME_DURATION, XINE_STREAM_INFO_VIDEO_BITRATE, XINE_STREAM_INFO_VIDEO_HEIGHT, XINE_STREAM_INFO_VIDEO_WIDTH, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by read_flv_packet().

## ◆ read_flv_packet()

static int read_flv_packet | ( | demux_flv_t * | this,
|  | int | preview
| ) |  |
| static

References _X_BE_32, _x_keyframes_add(), AF_AAC, AF_ADPCM, AF_ALAW, AF_MP3, AF_MP38, AF_MULAW, AF_NELLY, AF_NELLY16, AF_NELLY8, AF_PCM_BE, AF_PCM_LE, AF_SPEEX, xine_bmiheader::biHeight, xine_bmiheader::biSize, xine_bmiheader::biWidth, BUF_AUDIO_AAC, BUF_AUDIO_ALAW, BUF_AUDIO_FLVADPCM, BUF_AUDIO_LPCM_BE, BUF_AUDIO_LPCM_LE, BUF_AUDIO_MPEG, BUF_AUDIO_MULAW, BUF_AUDIO_SPEEX, BUF_AUDIO_UNKNOWN, BUF_FLAG_FRAME_END, BUF_FLAG_FRAME_START, BUF_FLAG_FRAMERATE, BUF_FLAG_HEADER, BUF_FLAG_KEYFRAME, BUF_FLAG_SPECIAL, BUF_FLAG_STDHEADER, BUF_SPECIAL_DECODER_CONFIG, buf_type, BUF_VIDEO_FLV1, BUF_VIDEO_H263, BUF_VIDEO_H264, BUF_VIDEO_HEVC, BUF_VIDEO_JPEG, BUF_VIDEO_MPEG4, BUF_VIDEO_UNKNOWN, BUF_VIDEO_VP6F, fifo_buffer_s::buffer_pool_alloc, fifo_buffer_s::buffer_pool_size_alloc, check_newpts(), buf_element_s::content, buf_element_s::decoder_flags, buf_element_s::decoder_info, buf_element_s::decoder_info_ptr, DEMUX_FINISHED, DEMUX_OK, buf_element_s::extra_info, FLV_TAG_TYPE_AUDIO, FLV_TAG_TYPE_NOTIFY, FLV_TAG_TYPE_VIDEO, buf_element_s::free_buffer, GETBYTES, gettimestamp, height, input(), extra_info_s::input_normpos, extra_info_s::input_time, IS_PCM, lprintf, buf_element_s::max_size, buf_element_s::mem, xine_keyframes_entry_t::msecs, xine_keyframes_entry_t::normpos, NULL, parse_amf(), buf_element_s::pts, fifo_buffer_s::put, buf_element_s::size, buf_element_s::type, VF_FLV1, VF_H263, VF_H264, VF_HEVC, VF_JPEG, VF_MP4, VF_VP6, VF_VP6A, width, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by demux_flv_send_chunk(), and demux_flv_send_headers().

## ◆ seek_flv_file()

static void seek_flv_file | ( | demux_flv_t * | this,
|  | off_t | seek_pos,
|  | int | seek_pts
| ) |  |
| static

References _, _X_BE_32, abs, FLV_TAG_TYPE_AUDIO, FLV_TAG_TYPE_VIDEO, gettimestamp, input(), now(), flv_index_entry_t::offset, flv_index_entry_t::pts, TEMPBUFSIZE, XINE_VERBOSITY_DEBUG, XINE_VERBOSITY_LOG, and xprintf.

Referenced by demux_flv_seek().