From 3e8d57944439a50f12c3e3eef10a416ced22aa7f Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Wed, 4 Apr 2012 05:05:50 +0000 Subject: Fixed #1478: AVI player virtual device. Initial spec: - Currently only Works with raw video and audio AVI files - Added --play-avi and --auto-play-avi options in pjsua - No A/V synchronization yet git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4016 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/include/pjmedia-videodev/avi_dev.h | 139 ++++++++++++++++++++++++ pjmedia/include/pjmedia-videodev/config.h | 11 ++ pjmedia/include/pjmedia-videodev/videodev.h | 19 +++- pjmedia/include/pjmedia-videodev/videodev_imp.h | 28 +++++ pjmedia/include/pjmedia_videodev.h | 1 + 5 files changed, 194 insertions(+), 4 deletions(-) create mode 100644 pjmedia/include/pjmedia-videodev/avi_dev.h (limited to 'pjmedia/include') diff --git a/pjmedia/include/pjmedia-videodev/avi_dev.h b/pjmedia/include/pjmedia-videodev/avi_dev.h new file mode 100644 index 00000000..71f1bc6e --- /dev/null +++ b/pjmedia/include/pjmedia-videodev/avi_dev.h @@ -0,0 +1,139 @@ +/* $Id$ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef PJMEDIA_VIDEODEV_AVI_DEV_H__ +#define PJMEDIA_VIDEODEV_AVI_DEV_H__ + +/** + * @file avi_dev.h + * @brief AVI player virtual device + */ +#include +#include + +PJ_BEGIN_DECL + +/** + * @defgroup avi_dev AVI Player Virtual Device + * @ingroup video_device_api + * @brief AVI player virtual device + * @{ + * This describes a virtual capture device which takes its input from an AVI + * file. + */ + +/** + * Settings for the AVI player virtual device. This param corresponds to + * PJMEDIA_VID_DEV_CAP_AVI_PLAY capability of the video device/stream. + */ +typedef struct pjmedia_avi_dev_param +{ + /** + * Specifies the full path of the AVI file to be played. + */ + pj_str_t path; + + /** + * If this setting is specified when setting the device, this specifies + * the title to be assigned as the device name. If this setting not + * specified, the filename part of the path will be used. + */ + pj_str_t title; + + /** + * The underlying AVI streams created by the device. If the value is NULL, + * that means the device has not been configured yet. Application can use + * this field to retrieve the audio stream of the AVI. This setting is + * "get"-only and will be ignored in "set capability" operation. + */ + pjmedia_avi_streams *avi_streams; + +} pjmedia_avi_dev_param; + + +/** + * Reset pjmedia_avi_dev_param with the default settings. This mostly will + * reset all values to NULL or zero. + * + * @param p The parameter to be initialized. + */ +PJ_DECL(void) pjmedia_avi_dev_param_default(pjmedia_avi_dev_param *p); + + +/** + * Create a AVI device factory, and register it to the video device + * subsystem. At least one factory needs to be created before an AVI + * device can be allocated and used, and normally only one factory is + * needed per application. + * + * @param pf Pool factory to be used. + * @param max_dev Number of devices to be reserved. + * @param p_ret Pointer to return the factory instance, to be + * used when allocating a virtual device. + * + * @return PJ_SUCCESS on success or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjmedia_avi_dev_create_factory( + pj_pool_factory *pf, + unsigned max_dev, + pjmedia_vid_dev_factory **p_ret); + +/** + * Allocate one device ID to be used to play the specified AVI file in + * the parameter. + * + * @param param The parameter, with at least the AVI file path + * set. + * @param p_id Optional pointer to receive device ID to play + * the file. + * + * @return PJ_SUCCESS or the appropriate error code. + * + */ +PJ_DECL(pj_status_t) pjmedia_avi_dev_alloc(pjmedia_vid_dev_factory *f, + pjmedia_avi_dev_param *param, + pjmedia_vid_dev_index *p_id); + +/** + * Retrieve the parameters set for the virtual device. + * + * @param id Device ID. + * @param prm Structure to receive the settings. + * + * @return PJ_SUCCESS or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjmedia_avi_dev_get_param(pjmedia_vid_dev_index id, + pjmedia_avi_dev_param *param); + +/** + * Free the resources associated with the virtual device. + * + * @param id The device ID. + * + * @return PJ_SUCCESS or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjmedia_avi_dev_free(pjmedia_vid_dev_index id); + +/** + * @} + */ + +PJ_END_DECL + + +#endif /* PJMEDIA_VIDEODEV_AVI_DEV_H__ */ diff --git a/pjmedia/include/pjmedia-videodev/config.h b/pjmedia/include/pjmedia-videodev/config.h index 0a0eb54e..5d261fb3 100644 --- a/pjmedia/include/pjmedia-videodev/config.h +++ b/pjmedia/include/pjmedia-videodev/config.h @@ -122,6 +122,17 @@ PJ_BEGIN_DECL # define PJMEDIA_VIDEO_DEV_HAS_V4L2 0 #endif + +/** + * Enable support for AVI player virtual capture device. + * + * Default: 1 + */ +#ifndef PJMEDIA_VIDEO_DEV_HAS_AVI +# define PJMEDIA_VIDEO_DEV_HAS_AVI 1 +#endif + + /** * @} */ diff --git a/pjmedia/include/pjmedia-videodev/videodev.h b/pjmedia/include/pjmedia-videodev/videodev.h index fa6c2697..235d2a3e 100644 --- a/pjmedia/include/pjmedia-videodev/videodev.h +++ b/pjmedia/include/pjmedia-videodev/videodev.h @@ -559,16 +559,23 @@ PJ_DECL(pj_status_t) pjmedia_vid_dev_subsys_shutdown(void); /** * Register a supported video device factory to the video device subsystem. + * Application can either register a function to create the factory, or + * an instance of an already created factory. + * * This function can only be called after calling * #pjmedia_vid_dev_subsys_init(). * - * @param vdf The video device factory. + * @param vdf The factory creation function. Either vdf or factory + * argument must be specified. + * @param factory Factory instance. Either vdf or factory + * argument must be specified. * * @return PJ_SUCCESS on successful operation or the appropriate * error code. */ PJ_DECL(pj_status_t) -pjmedia_vid_register_factory(pjmedia_vid_dev_factory_create_func_ptr vdf); +pjmedia_vid_register_factory(pjmedia_vid_dev_factory_create_func_ptr vdf, + pjmedia_vid_dev_factory *factory); /** @@ -577,13 +584,17 @@ pjmedia_vid_register_factory(pjmedia_vid_dev_factory_create_func_ptr vdf); * Devices from this factory will be unlisted. If a device from this factory * is currently in use, then the behavior is undefined. * - * @param vdf The video device factory. + * @param vdf The video device factory. Either vdf or factory argument + * must be specified. + * @param factory The factory instance. Either vdf or factory argument + * must be specified. * * @return PJ_SUCCESS on successful operation or the appropriate * error code. */ PJ_DECL(pj_status_t) -pjmedia_vid_unregister_factory(pjmedia_vid_dev_factory_create_func_ptr vdf); +pjmedia_vid_unregister_factory(pjmedia_vid_dev_factory_create_func_ptr vdf, + pjmedia_vid_dev_factory *factory); /** diff --git a/pjmedia/include/pjmedia-videodev/videodev_imp.h b/pjmedia/include/pjmedia-videodev/videodev_imp.h index 0a1d9830..e0ef5205 100644 --- a/pjmedia/include/pjmedia-videodev/videodev_imp.h +++ b/pjmedia/include/pjmedia-videodev/videodev_imp.h @@ -191,7 +191,35 @@ struct pjmedia_vid_dev_stream }; +/** + * Internal API: return the factory instance and device index that's local + * to the factory for a given device ID. + * + * @param id Device id. + * @param p_f Out: factory instance + * @param p_local_index Out: device index within the factory + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) +pjmedia_vid_dev_get_local_index(pjmedia_vid_dev_index id, + pjmedia_vid_dev_factory **p_f, + unsigned *p_local_index); +/** + * Internal API: return the global device index given a factory instance and + * a local device index. + * + * @param f Factory. + * @param local_idx Local index. + * @param pid Returned global index. + * + * @return PJ_SUCCESS on success. + */ +PJ_DEF(pj_status_t) +pjmedia_vid_dev_get_global_index(const pjmedia_vid_dev_factory *f, + unsigned local_idx, + pjmedia_vid_dev_index *pid); /** * @} diff --git a/pjmedia/include/pjmedia_videodev.h b/pjmedia/include/pjmedia_videodev.h index b11817fa..fe7c8800 100644 --- a/pjmedia/include/pjmedia_videodev.h +++ b/pjmedia/include/pjmedia_videodev.h @@ -26,5 +26,6 @@ #include #include +#include #endif /* __PJMEDIA_VIDEODEV_H__ */ -- cgit v1.2.3