📄 codec_plugin.h
字号:
/* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is MPEG4IP. * * The Initial Developer of the Original Code is Cisco Systems Inc. * Portions created by Cisco Systems Inc. are * Copyright (C) Cisco Systems Inc. 2002-2005. All Rights Reserved. * * Contributor(s): * Bill May wmay@cisco.com *//* * codec_plugin.h - audio/video plugin definitions for player */#ifndef __CODEC_PLUGIN_H__#define __CODEC_PLUGIN_H__ 1#include <mpeg4ip_config_set.h>#include <sdp.h>/* * When you change the plugin version, you should add a "HAVE_PLUGIN_VERSION" * for easier makes */#define PLUGIN_VERSION "1.1"#define HAVE_PLUGIN_VERSION_0_8 1#define HAVE_PLUGIN_VERSION_0_9 1#define HAVE_PLUGIN_VERSION_0_A 1#define HAVE_PLUGIN_VERSION_0_B 1#define HAVE_PLUGIN_VERSION_1_0 1// version 1.1 for sdp redos#define HAVE_PLUGIN_VERSION_1_1 1/* * frame_timestamp_t structure is the method that the bytestreams will * pass timestamps to the codecs. * msec_timestamp is the timestamp in milliseconds * audio_freq_timestamp is the timestamp in the specified audio_freq * audio_freq is the timescale used for audio_freq_timestamp * timestamp_is_pts is used to indicate if a timestamp is a presentation or * decode timestamp. The plugin must translate a presentation timestamp * (from say a B frame) to the actual timestamp. Most file bytestreams * use a decode timestamp. */typedef struct frame_timestamp_t { uint64_t msec_timestamp; uint32_t audio_freq_timestamp; uint32_t audio_freq; bool timestamp_is_pts;} frame_timestamp_t;/*************************************************************************** * Audio callbacks from plugin to renderer ***************************************************************************//* * audio_configure_f - audio configuration - called when initializing * audio output. * Inputs: * ifptr - handle passed when created * freq - frequency in samples per second * chans - number of channels * format - audio format definitions from lib/SDL/include/SDL_audio.h * max_samples - number of samples required after processing each frame * Use a 0 for unknown or variable size. * variable size must use audio_load_buffer interface * Outputs: * nothing */typedef void (*audio_configure_f)(void *ifptr, int freq, int chans, audio_format_t format, uint32_t max_samples);/* * audio_get_buffer_f - get an audio ring buffer to fill * called before decoding a frame * Inputs: ifptr - pointer to handle * freq_ts - timestamp in samples (at the audio frequency) that * corresponds with ts. This lets us easily check if the samples * are consecutive without converting to msec and back again. * ts - timestamp of audio packet * Outputs: unsigned char pointer to buffer to write to. */typedef uint8_t *(*audio_get_buffer_f)(void *ifptr, uint32_t freq_ts, uint64_t ts);/* * audio_filled_buffer_f - routine to call after decoding * audio frame into a buffer gotten above. * Inputs: * ifptr - pointer to handle */typedef void (*audio_filled_buffer_f)(void *ifptr);/* * audio_load_buffer_f - load local audio buffer with a variable number of * bytes * Inputs: * ifptr - pointer to handle * from - pointer to from buffer * bytes - number of bytes (not samples) in buffer * freq_ts - timestamp in samples (at the audio frequency) that * corresponds with ts. This lets us easily check if the samples * are consecutive without converting to msec and back again. * ts - timestamp of start of buffer */typedef void (*audio_load_buffer_f)(void *ifptr, const uint8_t *from, uint32_t bytes, uint32_t freq_ts, uint64_t ts);/* * audio_vft_t - virtual function table for audio events */typedef struct audio_vft_t { lib_message_func_t log_msg; audio_configure_f audio_configure; audio_get_buffer_f audio_get_buffer; audio_filled_buffer_f audio_filled_buffer; audio_load_buffer_f audio_load_buffer; CConfigSet *pConfig;} audio_vft_t;/***************************************************************************** * Video callbacks from plugin to renderer *****************************************************************************/#define VIDEO_FORMAT_YUV 1/* * video_configure_f - configure video sizes * Inputs: ifptr - pointer to handle passed * w - width in pixels * h - height in pixels * format - right now, only VIDEO_FORMAT_YUV * aspect_ratio - 0.0 for default, set for value (value will * adjust so display_w = h * aspect_ratio; * Outputs: none */typedef void (*video_configure_f)(void *ifptr, int w, int h, int format, double aspect_ratio);/* * video_get_buffer_f - request y, u and v buffers before decoding * Inputs: ifptr - handle * Outputs: y - pointer to y buffer * u - pointer to u buffer * v - pointer to v buffer * return value: 0 - no buffer * 1 - valid buffer * Note: will wait for return until buffer ready */typedef int (*video_get_buffer_f)(void *ifptr, uint8_t **y, uint8_t **u, uint8_t **v);/* * video_filled_buffer_f - indicates we've filled buffer gotten above * Inputs - ifptr - handle * display_time - rendering time in msec. */typedef void (*video_filled_buffer_f)(void *ifptr, uint64_t display_time);/* * video_have_frame_f - instead of using video_get_buffer and * video_filled_buffer, can use this instead if buffer is stored locally * Inputs: ifptr - handle * y - pointer to y data * u - pointer to u data * v - pointer to v data * m_pixelw_y - width of each row in y above (might not be width) * m_pixelw_uv - width of each row in u and v * display_time - render time in msec */typedef void (*video_have_frame_f)(void *ifptr, const uint8_t *y, const uint8_t *u, const uint8_t *v, int m_pixelw_y, int m_pixelw_uv, uint64_t display_time);/* * video_vft_t - video virtual function table */typedef struct video_vft_t { lib_message_func_t log_msg; video_configure_f video_configure; video_get_buffer_f video_get_buffer; video_filled_buffer_f video_filled_buffer; video_have_frame_f video_have_frame; CConfigSet *pConfig;} video_vft_t;/************************************************************************* * Text callbacks *************************************************************************/typedef void (*text_configure_f)(void *ifptr, uint32_t display_type, void *display_configuration);typedef void (*text_have_frame_f)(void *ifptr, uint64_t display_time, uint32_t display_type, void *display_structure);typedef struct text_vft_t { lib_message_func_t log_msg; text_configure_f text_configure; text_have_frame_f text_have_frame; CConfigSet *pConfig;} text_vft_t;/************************************************************************** * Routines plugin must provide **************************************************************************/typedef struct video_info_t { int height; int width;} video_info_t;typedef struct audio_info_t { int freq; int chans; int bitspersample;} audio_info_t;/* * The codec data returned must start with this structure */typedef struct codec_data_t { void *ifptr; union { video_vft_t *video_vft; audio_vft_t *audio_vft; text_vft_t *text_vft; } v;} codec_data_t;/* * These are the values passed for the stream types */#define STREAM_TYPE_RTP "RTP"#define STREAM_TYPE_MPEG2_TRANSPORT_STREAM "MPEG2 TRANSPORT"#define STREAM_TYPE_AVI_FILE "AVI FILE"#define STREAM_TYPE_MPEG_FILE "MPEG FILE"#define STREAM_TYPE_MP4_FILE "MP4 FILE"#define STREAM_TYPE_QT_FILE "QT FILE"/* * ac_create_f - audio codec plugin creation routine * Inputs: * stream_type - stream type of file * compressor - pointer to codec. * type - video type. valid for .mp4 files * profile - video profile level - valid for .mp4 files * sdp_media - pointer to session description information for stream * audio - pointer to audio information * user_data - pointer to user data * userdata_size - size of user data * if_vft - pointer to audio vft to use * ifptr - handle to use for audio callbacks * Returns - must return a handle that contains codec_data_t. */typedef codec_data_t *(*ac_create_f)(const char *stream_type, const char *compressor, int type, int profile, format_list_t *sdp_media, audio_info_t *audio, const uint8_t *user_data, uint32_t userdata_size, audio_vft_t *if_vft, void *ifptr);/* * tc_create_f - text codec plugin creation routine * Inputs: * stream_type - stream type of file * compressor - pointer to codec. * sdp_media - pointer to session description information for stream * user_data - pointer to user data * userdata_size - size of user data * if_vft - pointer to video vft to use * ifptr - handle to use for video callbacks * Returns - must return a handle that contains codec_data_t. */typedef codec_data_t *(*tc_create_f)(const char *stream_type, const char *compressor, format_list_t *sdp_media, const uint8_t *user_data, uint32_t userdata_size, text_vft_t *if_vft, void *ifptr);/* * vc_create_f - video codec plugin creation routine * Inputs: * stream_type - stream type of file * compressor - pointer to codec. * type - video type. valid for .mp4 files * profile - video profile level - valid for .mp4 files * sdp_media - pointer to session description information for stream * video - pointer to video information * user_data - pointer to user data * userdata_size - size of user data * if_vft - pointer to video vft to use * ifptr - handle to use for video callbacks
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -