diff options
Diffstat (limited to 'Protocols/SIP/lib/pjsip/pjmedia')
67 files changed, 18070 insertions, 0 deletions
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/audiodev.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/audiodev.h new file mode 100644 index 0000000..96f62fe --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/audiodev.h @@ -0,0 +1,667 @@ +/* $Id: audiodev.h 2506 2009-03-12 18:11:37Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_AUDIODEV_AUDIODEV_H__
+#define __PJMEDIA_AUDIODEV_AUDIODEV_H__
+
+/**
+ * @file audiodev.h
+ * @brief Audio device API.
+ */
+#include <pjmedia-audiodev/config.h>
+#include <pjmedia-audiodev/errno.h>
+#include <pjmedia/types.h>
+#include <pj/pool.h>
+
+
+PJ_BEGIN_DECL
+
+/**
+ * @defgroup s2_audio_device_reference Audio Device API Reference
+ * @ingroup audio_device_api
+ * @brief API Reference
+ * @{
+ */
+
+/**
+ * Type for device index.
+ */
+typedef pj_int32_t pjmedia_aud_dev_index;
+
+/**
+ * Device index constants.
+ */
+enum
+{
+ /**
+ * Constant to denote default capture device
+ */
+ PJMEDIA_AUD_DEFAULT_CAPTURE_DEV = -1,
+
+ /**
+ * Constant to denote default playback device
+ */
+ PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV = -2,
+
+ /**
+ * Constant to denote invalid device index.
+ */
+ PJMEDIA_AUD_INVALID_DEV = -3
+};
+
+
+/**
+ * This enumeration identifies various audio device capabilities. These audio
+ * capabilities indicates what features are supported by the underlying
+ * audio device implementation.
+ *
+ * Applications get these capabilities in the #pjmedia_aud_dev_info structure.
+ *
+ * Application can also set the specific features/capabilities when opening
+ * the audio stream by setting the \a flags member of #pjmedia_aud_param
+ * structure.
+ *
+ * Once audio stream is running, application can also retrieve or set some
+ * specific audio capability, by using #pjmedia_aud_stream_get_cap() and
+ * #pjmedia_aud_stream_set_cap() and specifying the desired capability. The
+ * value of the capability is specified as pointer, and application needs to
+ * supply the pointer with the correct value, according to the documentation
+ * of each of the capability.
+ */
+typedef enum pjmedia_aud_dev_cap
+{
+ /**
+ * Support for audio formats other than PCM. The value of this capability
+ * is represented by #pjmedia_format structure.
+ */
+ PJMEDIA_AUD_DEV_CAP_EXT_FORMAT = 1,
+
+ /**
+ * Support for audio input latency control or query. The value of this
+ * capability is an unsigned integer containing milliseconds value of
+ * the latency.
+ */
+ PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY = 2,
+
+ /**
+ * Support for audio output latency control or query. The value of this
+ * capability is an unsigned integer containing milliseconds value of
+ * the latency.
+ */
+ PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY = 4,
+
+ /**
+ * Support for setting/retrieving the audio input device volume level.
+ * The value of this capability is an unsigned integer representing
+ * the input audio volume setting in percent.
+ */
+ PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING = 8,
+
+ /**
+ * Support for setting/retrieving the audio output device volume level.
+ * The value of this capability is an unsigned integer representing
+ * the output audio volume setting in percent.
+ */
+ PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING = 16,
+
+ /**
+ * Support for monitoring the current audio input signal volume.
+ * The value of this capability is an unsigned integer representing
+ * the audio volume in percent.
+ */
+ PJMEDIA_AUD_DEV_CAP_INPUT_SIGNAL_METER = 32,
+
+ /**
+ * Support for monitoring the current audio output signal volume.
+ * The value of this capability is an unsigned integer representing
+ * the audio volume in percent.
+ */
+ PJMEDIA_AUD_DEV_CAP_OUTPUT_SIGNAL_METER = 64,
+
+ /**
+ * Support for audio input routing. The value of this capability is an
+ * integer containing #pjmedia_aud_dev_route enumeration.
+ */
+ PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE = 128,
+
+ /**
+ * Support for audio output routing (e.g. loudspeaker vs earpiece). The
+ * value of this capability is an integer containing #pjmedia_aud_dev_route
+ * enumeration.
+ */
+ PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE = 256,
+
+ /**
+ * The audio device has echo cancellation feature. The value of this
+ * capability is a pj_bool_t containing boolean PJ_TRUE or PJ_FALSE.
+ */
+ PJMEDIA_AUD_DEV_CAP_EC = 512,
+
+ /**
+ * The audio device supports setting echo cancellation fail length. The
+ * value of this capability is an unsigned integer representing the
+ * echo tail in milliseconds.
+ */
+ PJMEDIA_AUD_DEV_CAP_EC_TAIL = 1024,
+
+ /**
+ * The audio device has voice activity detection feature. The value
+ * of this capability is a pj_bool_t containing boolean PJ_TRUE or
+ * PJ_FALSE.
+ */
+ PJMEDIA_AUD_DEV_CAP_VAD = 2048,
+
+ /**
+ * The audio device has comfort noise generation feature. The value
+ * of this capability is a pj_bool_t containing boolean PJ_TRUE or
+ * PJ_FALSE.
+ */
+ PJMEDIA_AUD_DEV_CAP_CNG = 4096,
+
+ /**
+ * The audio device has packet loss concealment feature. The value
+ * of this capability is a pj_bool_t containing boolean PJ_TRUE or
+ * PJ_FALSE.
+ */
+ PJMEDIA_AUD_DEV_CAP_PLC = 8192,
+
+ /**
+ * End of capability
+ */
+ PJMEDIA_AUD_DEV_CAP_MAX = 16384
+
+} pjmedia_aud_dev_cap;
+
+
+/**
+ * This enumeration describes audio routing setting.
+ */
+typedef enum pjmedia_aud_dev_route
+{
+ /** Default route. */
+ PJMEDIA_AUD_DEV_ROUTE_DEFAULT = 0,
+
+ /** Route to loudspeaker */
+ PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER = 1,
+
+ /** Route to earpiece */
+ PJMEDIA_AUD_DEV_ROUTE_EARPIECE = 2
+
+} pjmedia_aud_dev_route;
+
+
+/**
+ * Device information structure returned by #pjmedia_aud_dev_get_info().
+ */
+typedef struct pjmedia_aud_dev_info
+{
+ /**
+ * The device name
+ */
+ char name[64];
+
+ /**
+ * Maximum number of input channels supported by this device. If the
+ * value is zero, the device does not support input operation (i.e.
+ * it is a playback only device).
+ */
+ unsigned input_count;
+
+ /**
+ * Maximum number of output channels supported by this device. If the
+ * value is zero, the device does not support output operation (i.e.
+ * it is an input only device).
+ */
+ unsigned output_count;
+
+ /**
+ * Default sampling rate.
+ */
+ unsigned default_samples_per_sec;
+
+ /**
+ * The underlying driver name
+ */
+ char driver[32];
+
+ /**
+ * Device capabilities, as bitmask combination of #pjmedia_aud_dev_cap.
+ */
+ unsigned caps;
+
+ /**
+ * Supported audio device routes, as bitmask combination of
+ * #pjmedia_aud_dev_route. The value may be zero if the device
+ * does not support audio routing.
+ */
+ unsigned routes;
+
+ /**
+ * Number of audio formats supported by this device. The value may be
+ * zero if the device does not support non-PCM format.
+ */
+ unsigned ext_fmt_cnt;
+
+ /**
+ * Array of supported extended audio formats
+ */
+ pjmedia_format ext_fmt[8];
+
+
+} pjmedia_aud_dev_info;
+
+
+/**
+ * This callback is called by player stream when it needs additional data
+ * to be played by the device. Application must fill in the whole of output
+ * buffer with audio samples.
+ *
+ * The frame argument contains the following values:
+ * - timestamp Playback timestamp, in samples.
+ * - buf Buffer to be filled out by application.
+ * - size The size requested in bytes, which will be equal to
+ * the size of one whole packet.
+ *
+ * @param user_data User data associated with the stream.
+ * @param frame Audio frame, which buffer is to be filled in by
+ * the application.
+ *
+ * @return Returning non-PJ_SUCCESS will cause the audio stream
+ * to stop
+ */
+typedef pj_status_t (*pjmedia_aud_play_cb)(void *user_data,
+ pjmedia_frame *frame);
+
+/**
+ * This callback is called by recorder stream when it has captured the whole
+ * packet worth of audio samples.
+ *
+ * @param user_data User data associated with the stream.
+ * @param frame Captured frame.
+ *
+ * @return Returning non-PJ_SUCCESS will cause the audio stream
+ * to stop
+ */
+typedef pj_status_t (*pjmedia_aud_rec_cb)(void *user_data,
+ pjmedia_frame *frame);
+
+/**
+ * This structure specifies the parameters to open the audio stream.
+ */
+typedef struct pjmedia_aud_param
+{
+ /**
+ * The audio direction. This setting is mandatory.
+ */
+ pjmedia_dir dir;
+
+ /**
+ * The audio recorder device ID. This setting is mandatory if the audio
+ * direction includes input/capture direction.
+ */
+ pjmedia_aud_dev_index rec_id;
+
+ /**
+ * The audio playback device ID. This setting is mandatory if the audio
+ * direction includes output/playback direction.
+ */
+ pjmedia_aud_dev_index play_id;
+
+ /**
+ * Clock rate/sampling rate. This setting is mandatory.
+ */
+ unsigned clock_rate;
+
+ /**
+ * Number of channels. This setting is mandatory.
+ */
+ unsigned channel_count;
+
+ /**
+ * Number of samples per frame. This setting is mandatory.
+ */
+ unsigned samples_per_frame;
+
+ /**
+ * Number of bits per sample. This setting is mandatory.
+ */
+ unsigned bits_per_sample;
+
+ /**
+ * This flags specifies which of the optional settings are valid in this
+ * structure. The flags is bitmask combination of pjmedia_aud_dev_cap.
+ */
+ unsigned flags;
+
+ /**
+ * Set the audio format. This setting is optional, and will only be used
+ * if PJMEDIA_AUD_DEV_CAP_EXT_FORMAT is set in the flags.
+ */
+ pjmedia_format ext_fmt;
+
+ /**
+ * Input latency, in milliseconds. This setting is optional, and will
+ * only be used if PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY is set in the flags.
+ */
+ unsigned input_latency_ms;
+
+ /**
+ * Input latency, in milliseconds. This setting is optional, and will
+ * only be used if PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY is set in the flags.
+ */
+ unsigned output_latency_ms;
+
+ /**
+ * Input volume setting, in percent. This setting is optional, and will
+ * only be used if PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING is set in
+ * the flags.
+ */
+ unsigned input_vol;
+
+ /**
+ * Output volume setting, in percent. This setting is optional, and will
+ * only be used if PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING is set in
+ * the flags.
+ */
+ unsigned output_vol;
+
+ /**
+ * Set the audio input route. This setting is optional, and will only be
+ * used if PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE is set in the flags.
+ */
+ pjmedia_aud_dev_route input_route;
+
+ /**
+ * Set the audio output route. This setting is optional, and will only be
+ * used if PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE is set in the flags.
+ */
+ pjmedia_aud_dev_route output_route;
+
+ /**
+ * Enable/disable echo canceller, if the device supports it. This setting
+ * is optional, and will only be used if PJMEDIA_AUD_DEV_CAP_EC is set in
+ * the flags.
+ */
+ pj_bool_t ec_enabled;
+
+ /**
+ * Set echo canceller tail length in milliseconds, if the device supports
+ * it. This setting is optional, and will only be used if
+ * PJMEDIA_AUD_DEV_CAP_EC_TAIL is set in the flags.
+ */
+ unsigned ec_tail_ms;
+
+ /**
+ * Enable/disable PLC. This setting is optional, and will only be used
+ * if PJMEDIA_AUD_DEV_CAP_PLC is set in the flags.
+ */
+ pj_bool_t plc_enabled;
+
+ /**
+ * Enable/disable CNG. This setting is optional, and will only be used
+ * if PJMEDIA_AUD_DEV_CAP_CNG is set in the flags.
+ */
+ pj_bool_t cng_enabled;
+
+} pjmedia_aud_param;
+
+
+/** Forward declaration for pjmedia_aud_stream */
+typedef struct pjmedia_aud_stream pjmedia_aud_stream;
+
+/** Forward declaration for audio device factory */
+typedef struct pjmedia_aud_dev_factory pjmedia_aud_dev_factory;
+
+/**
+ * Get string info for the specified capability.
+ *
+ * @param cap The capability ID.
+ * @param p_desc Optional pointer which will be filled with longer
+ * description about the capability.
+ *
+ * @return Capability name.
+ */
+PJ_DECL(const char*) pjmedia_aud_dev_cap_name(pjmedia_aud_dev_cap cap,
+ const char **p_desc);
+
+
+/**
+ * Set a capability field value in #pjmedia_aud_param structure. This will
+ * also set the flags field for the specified capability in the structure.
+ *
+ * @param param The structure.
+ * @param cap The audio capability which value is to be set.
+ * @param value Pointer to value. Please see the type of value to
+ * be supplied in the pjmedia_aud_dev_cap documentation.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_param_set_cap(pjmedia_aud_param *param,
+ pjmedia_aud_dev_cap cap,
+ const void *pval);
+
+
+/**
+ * Get a capability field value from #pjmedia_aud_param structure. This
+ * function will return PJMEDIA_EAUD_INVCAP error if the flag for that
+ * capability is not set in the flags field in the structure.
+ *
+ * @param param The structure.
+ * @param cap The audio capability which value is to be retrieved.
+ * @param value Pointer to value. Please see the type of value to
+ * be supplied in the pjmedia_aud_dev_cap documentation.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_param_get_cap(const pjmedia_aud_param *param,
+ pjmedia_aud_dev_cap cap,
+ void *pval);
+
+/**
+ * Initialize the audio subsystem. This will register all supported audio
+ * device factories to the audio subsystem. This function may be called
+ * more than once, but each call to this function must have the
+ * corresponding #pjmedia_aud_subsys_shutdown() call.
+ *
+ * @param pf The pool factory.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_subsys_init(pj_pool_factory *pf);
+
+
+/**
+ * Get the pool factory registered to the audio subsystem.
+ *
+ * @return The pool factory.
+ */
+PJ_DECL(pj_pool_factory*) pjmedia_aud_subsys_get_pool_factory(void);
+
+
+/**
+ * Shutdown the audio subsystem. This will destroy all audio device factories
+ * registered in the audio subsystem. Note that currently opened audio streams
+ * may or may not be closed, depending on the implementation of the audio
+ * device factories.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_subsys_shutdown(void);
+
+
+/**
+ * Get the number of sound devices installed in the system.
+ *
+ * @return The number of sound devices installed in the system.
+ */
+PJ_DECL(unsigned) pjmedia_aud_dev_count(void);
+
+
+/**
+ * Get device information.
+ *
+ * @param id The audio device ID.
+ * @param info The device information which will be filled in by this
+ * function once it returns successfully.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_dev_get_info(pjmedia_aud_dev_index id,
+ pjmedia_aud_dev_info *info);
+
+
+/**
+ * Lookup device index based on the driver and device name.
+ *
+ * @param drv_name The driver name.
+ * @param dev_name The device name.
+ * @param id Pointer to store the returned device ID.
+ *
+ * @return PJ_SUCCESS if the device can be found.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_dev_lookup(const char *drv_name,
+ const char *dev_name,
+ pjmedia_aud_dev_index *id);
+
+
+/**
+ * Initialize the audio device parameters with default values for the
+ * specified device.
+ *
+ * @param id The audio device ID.
+ * @param param The audio device parameters which will be initialized
+ * by this function once it returns successfully.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_dev_default_param(pjmedia_aud_dev_index id,
+ pjmedia_aud_param *param);
+
+
+/**
+ * Open audio stream object using the specified parameters.
+ *
+ * @param param Sound device parameters to be used for the stream.
+ * @param rec_cb Callback to be called on every input frame captured.
+ * @param play_cb Callback to be called everytime the sound device needs
+ * audio frames to be played back.
+ * @param user_data Arbitrary user data, which will be given back in the
+ * callbacks.
+ * @param p_strm Pointer to receive the audio stream.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_stream_create(const pjmedia_aud_param *param,
+ pjmedia_aud_rec_cb rec_cb,
+ pjmedia_aud_play_cb play_cb,
+ void *user_data,
+ pjmedia_aud_stream **p_strm);
+
+/**
+ * Get the running parameters for the specified audio stream.
+ *
+ * @param strm The audio stream.
+ * @param param Audio stream parameters to be filled in by this
+ * function once it returns successfully.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_stream_get_param(pjmedia_aud_stream *strm,
+ pjmedia_aud_param *param);
+
+/**
+ * Get the value of a specific capability of the audio stream.
+ *
+ * @param strm The audio stream.
+ * @param cap The audio capability which value is to be retrieved.
+ * @param value Pointer to value to be filled in by this function
+ * once it returns successfully. Please see the type
+ * of value to be supplied in the pjmedia_aud_dev_cap
+ * documentation.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_stream_get_cap(pjmedia_aud_stream *strm,
+ pjmedia_aud_dev_cap cap,
+ void *value);
+
+/**
+ * Set the value of a specific capability of the audio stream.
+ *
+ * @param strm The audio stream.
+ * @param cap The audio capability which value is to be set.
+ * @param value Pointer to value. Please see the type of value to
+ * be supplied in the pjmedia_aud_dev_cap documentation.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_stream_set_cap(pjmedia_aud_stream *strm,
+ pjmedia_aud_dev_cap cap,
+ const void *value);
+
+/**
+ * Start the stream.
+ *
+ * @param strm The audio stream.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_stream_start(pjmedia_aud_stream *strm);
+
+/**
+ * Stop the stream.
+ *
+ * @param strm The audio stream.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_stream_stop(pjmedia_aud_stream *strm);
+
+/**
+ * Destroy the stream.
+ *
+ * @param strm The audio stream.
+ *
+ * @return PJ_SUCCESS on successful operation or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_stream_destroy(pjmedia_aud_stream *strm);
+
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_AUDIODEV_AUDIODEV_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/audiodev_imp.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/audiodev_imp.h new file mode 100644 index 0000000..c7d6933 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/audiodev_imp.h @@ -0,0 +1,181 @@ +/* $Id: audiodev_imp.h 2506 2009-03-12 18:11:37Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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 __AUDIODEV_IMP_H__
+#define __AUDIODEV_IMP_H__
+
+#include <pjmedia-audiodev/audiodev.h>
+
+/**
+ * @defgroup s8_audio_device_implementors_api Audio Device Implementors API
+ * @ingroup audio_device_api
+ * @brief API for audio device implementors
+ * @{
+ */
+
+/**
+ * Sound device factory operations.
+ */
+typedef struct pjmedia_aud_dev_factory_op
+{
+ /**
+ * Initialize the audio device factory.
+ *
+ * @param f The audio device factory.
+ */
+ pj_status_t (*init)(pjmedia_aud_dev_factory *f);
+
+ /**
+ * Close this audio device factory and release all resources back to the
+ * operating system.
+ *
+ * @param f The audio device factory.
+ */
+ pj_status_t (*destroy)(pjmedia_aud_dev_factory *f);
+
+ /**
+ * Get the number of audio devices installed in the system.
+ *
+ * @param f The audio device factory.
+ */
+ unsigned (*get_dev_count)(pjmedia_aud_dev_factory *f);
+
+ /**
+ * Get the audio device information and capabilities.
+ *
+ * @param f The audio device factory.
+ * @param index Device index.
+ * @param info The audio device information structure which will be
+ * initialized by this function once it returns
+ * successfully.
+ */
+ pj_status_t (*get_dev_info)(pjmedia_aud_dev_factory *f,
+ unsigned index,
+ pjmedia_aud_dev_info *info);
+
+ /**
+ * Initialize the specified audio device parameter with the default
+ * values for the specified device.
+ *
+ * @param f The audio device factory.
+ * @param index Device index.
+ * @param param The audio device parameter.
+ */
+ pj_status_t (*default_param)(pjmedia_aud_dev_factory *f,
+ unsigned index,
+ pjmedia_aud_param *param);
+
+ /**
+ * Open the audio device and create audio stream. See
+ * #pjmedia_aud_stream_create()
+ */
+ pj_status_t (*create_stream)(pjmedia_aud_dev_factory *f,
+ const pjmedia_aud_param *param,
+ pjmedia_aud_rec_cb rec_cb,
+ pjmedia_aud_play_cb play_cb,
+ void *user_data,
+ pjmedia_aud_stream **p_aud_strm);
+
+} pjmedia_aud_dev_factory_op;
+
+
+/**
+ * This structure describes an audio device factory.
+ */
+struct pjmedia_aud_dev_factory
+{
+ /** Internal data to be initialized by audio subsystem. */
+ struct {
+ /** Driver index */
+ unsigned drv_idx;
+ } sys;
+
+ /** Operations */
+ pjmedia_aud_dev_factory_op *op;
+};
+
+
+/**
+ * Sound stream operations.
+ */
+typedef struct pjmedia_aud_stream_op
+{
+ /**
+ * See #pjmedia_aud_stream_get_param()
+ */
+ pj_status_t (*get_param)(pjmedia_aud_stream *strm,
+ pjmedia_aud_param *param);
+
+ /**
+ * See #pjmedia_aud_stream_get_cap()
+ */
+ pj_status_t (*get_cap)(pjmedia_aud_stream *strm,
+ pjmedia_aud_dev_cap cap,
+ void *value);
+
+ /**
+ * See #pjmedia_aud_stream_set_cap()
+ */
+ pj_status_t (*set_cap)(pjmedia_aud_stream *strm,
+ pjmedia_aud_dev_cap cap,
+ const void *value);
+
+ /**
+ * See #pjmedia_aud_stream_start()
+ */
+ pj_status_t (*start)(pjmedia_aud_stream *strm);
+
+ /**
+ * See #pjmedia_aud_stream_stop().
+ */
+ pj_status_t (*stop)(pjmedia_aud_stream *strm);
+
+ /**
+ * See #pjmedia_aud_stream_destroy().
+ */
+ pj_status_t (*destroy)(pjmedia_aud_stream *strm);
+
+} pjmedia_aud_stream_op;
+
+
+/**
+ * This structure describes the audio device stream.
+ */
+struct pjmedia_aud_stream
+{
+ /** Internal data to be initialized by audio subsystem */
+ struct {
+ /** Driver index */
+ unsigned drv_idx;
+ } sys;
+
+ /** Operations */
+ pjmedia_aud_stream_op *op;
+};
+
+
+
+
+/**
+ * @}
+ */
+
+
+
+#endif /* __AUDIODEV_IMP_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/audiotest.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/audiotest.h new file mode 100644 index 0000000..eb8c749 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/audiotest.h @@ -0,0 +1,116 @@ +/* $Id: audiotest.h 2506 2009-03-12 18:11:37Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_AUDIODEV_AUDIOTEST_H__
+#define __PJMEDIA_AUDIODEV_AUDIOTEST_H__
+
+/**
+ * @file audiotest.h
+ * @brief Audio test utility.
+ */
+#include <pjmedia-audiodev/audiodev.h>
+
+
+PJ_BEGIN_DECL
+
+/**
+ * @defgroup s30_audio_test_utility Audio tests utility.
+ * @ingroup audio_device_api
+ * @brief Audio test utility.
+ * @{
+ */
+
+/**
+ * Statistic for each direction.
+ */
+typedef struct pjmedia_aud_test_stat
+{
+ /**
+ * Number of frames processed during the test.
+ */
+ unsigned frame_cnt;
+
+ /**
+ * Minimum inter-frame arrival time, in milliseconds
+ */
+ unsigned min_interval;
+
+ /**
+ * Maximum inter-frame arrival time, in milliseconds
+ */
+ unsigned max_interval;
+
+ /**
+ * Average inter-frame arrival time, in milliseconds
+ */
+ unsigned avg_interval;
+
+ /**
+ * Standard deviation of inter-frame arrival time, in milliseconds
+ */
+ unsigned dev_interval;
+
+ /**
+ * Maximum number of frame burst
+ */
+ unsigned max_burst;
+
+} pjmedia_aud_test_stat;
+
+
+/**
+ * Test results.
+ */
+typedef struct pjmedia_aud_test_results
+{
+ /**
+ * Recording statistic.
+ */
+ pjmedia_aud_test_stat rec;
+
+ /**
+ * Playback statistic.
+ */
+ pjmedia_aud_test_stat play;
+
+ /**
+ * Clock drifts per second, in samples. Positive number indicates rec
+ * device is running faster than playback device.
+ */
+ pj_int32_t rec_drift_per_sec;
+
+} pjmedia_aud_test_results;
+
+
+/**
+ * Perform audio device testing.
+ */
+PJ_DECL(pj_status_t) pjmedia_aud_test(const pjmedia_aud_param *param,
+ pjmedia_aud_test_results *result);
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_AUDIODEV_AUDIOTEST_H__ */
+
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/config.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/config.h new file mode 100644 index 0000000..271b94c --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/config.h @@ -0,0 +1,394 @@ +/* $Id: config.h 2977 2009-10-29 09:39:17Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_AUDIODEV_CONFIG_H__
+#define __PJMEDIA_AUDIODEV_CONFIG_H__
+
+/**
+ * @file audiodev.h
+ * @brief Audio device API.
+ */
+#include <pjmedia/types.h>
+#include <pj/pool.h>
+
+
+PJ_BEGIN_DECL
+
+/**
+ * @defgroup audio_device_api Audio Device API
+ * @brief PJMEDIA audio device abstraction API.
+ */
+
+/**
+ * @defgroup s1_audio_device_config Compile time configurations
+ * @ingroup audio_device_api
+ * @brief Compile time configurations
+ * @{
+ */
+
+/**
+ * This setting controls whether PortAudio support should be included.
+ *
+ * By default it is enabled except on Windows platforms (including
+ * Windows Mobile) and Symbian.
+ */
+#ifndef PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO
+# if (defined(PJ_WIN32) && PJ_WIN32!=0) || \
+ (defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0)
+# define PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO 0
+# else
+# define PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO 1
+# endif
+#endif
+
+
+/**
+ * This setting controls whether WMME support should be included.
+ */
+#ifndef PJMEDIA_AUDIO_DEV_HAS_WMME
+# define PJMEDIA_AUDIO_DEV_HAS_WMME 1
+#endif
+
+
+/**
+ * This setting controls whether Symbian APS support should be included.
+ */
+#ifndef PJMEDIA_AUDIO_DEV_HAS_SYMB_APS
+# define PJMEDIA_AUDIO_DEV_HAS_SYMB_APS 0
+#endif
+
+
+/**
+ * This setting controls whether Symbian VAS support should be included.
+ */
+#ifndef PJMEDIA_AUDIO_DEV_HAS_SYMB_VAS
+# define PJMEDIA_AUDIO_DEV_HAS_SYMB_VAS 0
+#endif
+
+/**
+ * This setting controls Symbian VAS version to be used. Currently, valid
+ * values are only 1 (for VAS 1.0) and 2 (for VAS 2.0).
+ *
+ * Default: 1 (VAS version 1.0)
+ */
+#ifndef PJMEDIA_AUDIO_DEV_SYMB_VAS_VERSION
+# define PJMEDIA_AUDIO_DEV_SYMB_VAS_VERSION 1
+#endif
+
+
+/**
+ * This setting controls whether Symbian audio (using built-in multimedia
+ * framework) support should be included.
+ */
+#ifndef PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA
+# define PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA PJ_SYMBIAN
+#endif
+
+
+/**
+ * This setting controls whether the Audio Device API should support
+ * device implementation that is based on the old sound device API
+ * (sound.h).
+ *
+ * Enable this API if:
+ * - you have implemented your own sound device using the old sound
+ * device API (sound.h), and
+ * - you wish to be able to use your sound device implementation
+ * using the new Audio Device API.
+ *
+ * Please see http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more
+ * info.
+ */
+#ifndef PJMEDIA_AUDIO_DEV_HAS_LEGACY_DEVICE
+# define PJMEDIA_AUDIO_DEV_HAS_LEGACY_DEVICE 0
+#endif
+
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_AUDIODEV_CONFIG_H__ */
+
+/*
+ --------------------- DOCUMENTATION FOLLOWS ---------------------------
+ */
+
+/**
+ * @addtogroup audio_device_api Audio Device API
+ * @{
+
+PJMEDIA Audio Device API is a cross-platform audio API appropriate for use with
+VoIP applications and many other types of audio streaming applications.
+
+The API abstracts many different audio API's on various platforms, such as:
+ - PortAudio back-end for Win32, Windows Mobile, Linux, Unix, dan MacOS X.
+ - native WMME audio for Win32 and Windows Mobile devices
+ - native Symbian audio streaming/multimedia framework (MMF) implementation
+ - native Nokia Audio Proxy Server (APS) implementation
+ - null-audio implementation
+ - and more to be implemented in the future
+
+The Audio Device API/library is an evolution from PJMEDIA @ref PJMED_SND and
+contains many enhancements:
+
+ - Forward compatibility:
+\n
+ The new API has been designed to be extensible, it will support new API's as
+ well as new features that may be introduced in the future without breaking
+ compatibility with applications that use this API as well as compatibility
+ with existing device implementations.
+
+ - Device capabilities:
+\n
+ At the heart of the API is device capabilities management, where all possible
+ audio capabilities of audio devices should be able to be handled in a generic
+ manner. With this framework, new capabilities that may be discovered in the
+ future can be handled in manner without breaking existing applications.
+
+ - Built-in features:
+\n
+ The device capabilities framework enables applications to use and control
+ audio features built-in in the device, such as:
+ - echo cancellation,
+ - built-in codecs,
+ - audio routing (e.g. to earpiece or loudspeaker),
+ - volume control,
+ - etc.
+
+ - Codec support:
+\n
+ Some audio devices such as Nokia/Symbian Audio Proxy Server (APS) and Nokia
+ VoIP Audio Services (VAS) support built-in hardware audio codecs (e.g. G.729,
+ iLBC, and AMR), and application can use the sound device in encoded mode to
+ make use of these hardware codecs.
+
+ - Multiple backends:
+\n
+ The new API supports multiple audio backends (called factories or drivers in
+ the code) to be active simultaneously, and audio backends may be added or
+ removed during run-time.
+
+
+@section using Overview on using the API
+
+@subsection getting_started Getting started
+
+ -# <b>Configure the application's project settings</b>.\n
+ Add the following
+ include:
+ \code
+ #include <pjmedia_audiodev.h>\endcode\n
+ And add <b>pjmedia-audiodev</b> library to your application link
+ specifications.\n
+ -# <b>Compile time settings</b>.\n
+ Use the compile time settings to enable or
+ disable specific audio drivers. For more information, please see
+ \ref s1_audio_device_config.
+ -# <b>API initialization and cleaning up</b>.\n
+ Before anything else, application must initialize the API by calling:
+ \code
+ pjmedia_aud_subsys_init(pf);\endcode\n
+ And add this in the application cleanup sequence
+ \code
+ pjmedia_aud_subsys_shutdown();\endcode
+
+@subsection devices Working with devices
+
+ -# The following code prints the list of audio devices detected
+ in the system.
+ \code
+ int dev_count;
+ pjmedia_aud_dev_index dev_idx;
+ pj_status_t status;
+
+ dev_count = pjmedia_aud_dev_count();
+ printf("Got %d audio devices\n", dev_count);
+
+ for (dev_idx=0; dev_idx<dev_count; ++i) {
+ pjmedia_aud_dev_info info;
+
+ status = pjmedia_aud_dev_get_info(dev_idx, &info);
+ printf("%d. %s (in=%d, out=%d)\n",
+ dev_idx, info.name,
+ info.input_count, info.output_count);
+ }
+ \endcode\n
+ -# Info: The #PJMEDIA_AUD_DEFAULT_CAPTURE_DEV and #PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV
+ constants are used to denote default capture and playback devices
+ respectively.
+ -# Info: You may save the device and driver's name in your application
+ setting, for example to specify the prefered devices to be
+ used by your application. You can then retrieve the device index
+ for the device by calling:
+ \code
+ const char *drv_name = "WMME";
+ const char *dev_name = "Wave mapper";
+ pjmedia_aud_dev_index dev_idx;
+
+ status = pjmedia_aud_dev_lookup(drv_name, dev_name, &dev_idx);
+ if (status==PJ_SUCCESS)
+ printf("Device index is %d\n", dev_idx);
+ \endcode
+
+@subsection caps Device capabilities
+
+Capabilities are encoded as #pjmedia_aud_dev_cap enumeration. Please see
+#pjmedia_aud_dev_cap enumeration for more information.
+
+ -# The following snippet prints the capabilities supported by the device:
+ \code
+ pjmedia_aud_dev_info info;
+ pj_status_t status;
+
+ status = pjmedia_aud_dev_get_info(PJMEDIA_AUD_DEFAULT_CAPTURE_DEV, &info);
+ if (status == PJ_SUCCESS) {
+ unsigned i;
+ // Enumerate capability bits
+ printf("Device capabilities: ");
+ for (i=0; i<32; ++i) {
+ if (info.caps & (1 << i))
+ printf("%s ", pjmedia_aud_dev_cap_name(1 << i, NULL));
+ }
+ }
+ \endcode\n
+ -# Info: You can set the device settings when opening audio stream by setting
+ the flags and the appropriate setting in #pjmedia_aud_param when calling
+ #pjmedia_aud_stream_create()\n
+ -# Info: Once the audio stream is running, you can retrieve or change the stream
+ setting by specifying the capability in #pjmedia_aud_stream_get_cap()
+ and #pjmedia_aud_stream_set_cap() respectively.
+
+
+@subsection creating_stream Creating audio streams
+
+The audio stream enables audio streaming to capture device, playback device,
+or both.
+
+ -# It is recommended to initialize the #pjmedia_aud_param with its default
+ values before using it:
+ \code
+ pjmedia_aud_param param;
+ pjmedia_aud_dev_index dev_idx;
+ pj_status_t status;
+
+ dev_idx = PJMEDIA_AUD_DEFAULT_CAPTURE_DEV;
+ status = pjmedia_aud_dev_default_param(dev_idx, ¶m);
+ \endcode\n
+ -# Configure the mandatory parameters:
+ \code
+ param.dir = PJMEDIA_DIR_CAPTURE_PLAYBACK;
+ param.rec_id = PJMEDIA_AUD_DEFAULT_CAPTURE_DEV;
+ param.play_id = PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV;
+ param.clock_rate = 8000;
+ param.channel_count = 1;
+ param.samples_per_frame = 160;
+ param.bits_per_sample = 16;
+ \endcode\n
+ -# If you want the audio stream to use the device's built-in codec, specify
+ the codec in the #pjmedia_aud_param. You must make sure that the codec
+ is supported by the device, by looking at its supported format list in
+ the #pjmedia_aud_dev_info.\n
+ The snippet below sets the audio stream to use G.711 ULAW encoding:
+ \code
+ unsigned i;
+
+ // Make sure Ulaw is supported
+ if ((info.caps & PJMEDIA_AUD_DEV_CAP_EXT_FORMAT) == 0)
+ error("Device does not support extended formats");
+ for (i = 0; i < info.ext_fmt_cnt; ++i) {
+ if (info.ext_fmt[i].id == PJMEDIA_FORMAT_ULAW)
+ break;
+ }
+ if (i == info.ext_fmt_cnt)
+ error("Device does not support Ulaw format");
+
+ // Set Ulaw format
+ param.flags |= PJMEDIA_AUD_DEV_CAP_EXT_FORMAT;
+ param.ext_fmt.id = PJMEDIA_FORMAT_ULAW;
+ param.ext_fmt.bitrate = 64000;
+ param.ext_fmt.vad = PJ_FALSE;
+ \endcode\n
+ -# Note that if non-PCM format is configured on the audio stream, the
+ capture and/or playback functions (#pjmedia_aud_rec_cb and
+ #pjmedia_aud_play_cb respectively) will report the audio frame as
+ #pjmedia_frame_ext structure instead of the #pjmedia_frame.
+ -# Optionally configure other device's capabilities. The following snippet
+ shows how to enable echo cancellation on the device (note that this
+ snippet may not be necessary since the setting may have been enabled
+ when calling #pjmedia_aud_dev_default_param() above):
+ \code
+ if (info.caps & PJMEDIA_AUD_DEV_CAP_EC) {
+ param.flags |= PJMEDIA_AUD_DEV_CAP_EC;
+ param.ec_enabled = PJ_TRUE;
+ }
+ \endcode
+ -# Open the audio stream, specifying the capture and/or playback callback
+ functions:
+ \code
+ pjmedia_aud_stream *stream;
+
+ status = pjmedia_aud_stream_create(¶m, &rec_cb, &play_cb,
+ user_data, &stream);
+ \endcode
+
+@subsection working_with_stream Working with audio streams
+
+ -# To start the audio stream:
+ \code
+ status = pjmedia_aud_stream_start(stream);
+ \endcode\n
+ To stop the stream:
+ \code
+ status = pjmedia_aud_stream_stop(stream);
+ \endcode\n
+ And to destroy the stream:
+ \code
+ status = pjmedia_aud_stream_destroy(stream);
+ \endcode\n
+ -# Info: The following shows how to retrieve the capability value of the
+ stream (in this case, the current output volume setting).
+ \code
+ // Volume setting is an unsigned integer showing the level in percent.
+ unsigned vol;
+ status = pjmedia_aud_stream_get_cap(stream,
+ PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING,
+ &vol);
+ \endcode
+ -# Info: And following shows how to modify the capability value of the
+ stream (in this case, the current output volume setting).
+ \code
+ // Volume setting is an unsigned integer showing the level in percent.
+ unsigned vol = 50;
+ status = pjmedia_aud_stream_set_cap(stream,
+ PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING,
+ &vol);
+ \endcode
+
+
+*/
+
+
+/**
+ * @}
+ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/errno.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/errno.h new file mode 100644 index 0000000..ada9f87 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-audiodev/errno.h @@ -0,0 +1,198 @@ +/* $Id: errno.h 2506 2009-03-12 18:11:37Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 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_AUDIODEV_AUDIODEV_ERRNO_H__
+#define __PJMEDIA_AUDIODEV_AUDIODEV_ERRNO_H__
+
+/**
+ * @file errno.h Error Codes
+ * @brief Audiodev specific error codes.
+ */
+
+#include <pjmedia-audiodev/config.h>
+#include <pj/errno.h>
+
+/**
+ * @defgroup error_codes Error Codes
+ * @ingroup audio_device_api
+ * @brief Audio devive library specific error codes.
+ * @{
+ */
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Start of error code relative to PJ_ERRNO_START_USER.
+ * This value is 420000.
+ */
+#define PJMEDIA_AUDIODEV_ERRNO_START \
+ (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*5)
+#define PJMEDIA_AUDIODEV_ERRNO_END \
+ (PJMEDIA_AUDIODEV_ERRNO_START + PJ_ERRNO_SPACE_SIZE - 1)
+
+
+/**
+ * Mapping from PortAudio error codes to pjmedia error space.
+ */
+#define PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_START \
+ (PJMEDIA_AUDIODEV_ERRNO_END-10000)
+#define PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_END \
+ (PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_START + 10000 -1)
+/**
+ * Convert PortAudio error code to PJLIB error code.
+ * PortAudio error code range: 0 >= err >= -10000
+ */
+#define PJMEDIA_AUDIODEV_ERRNO_FROM_PORTAUDIO(err) \
+ ((int)PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_START-err)
+
+/**
+ * Mapping from Windows multimedia WaveIn error codes.
+ */
+#define PJMEDIA_AUDIODEV_WMME_IN_ERROR_START \
+ (PJMEDIA_AUDIODEV_ERRNO_START + 30000)
+#define PJMEDIA_AUDIODEV_WMME_IN_ERROR_END \
+ (PJMEDIA_AUDIODEV_WMME_IN_ERROR_START + 1000 - 1)
+/**
+ * Convert WaveIn operation error codes to PJLIB error space.
+ */
+#define PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_IN(err) \
+ ((int)PJMEDIA_AUDIODEV_WMME_IN_ERROR_START+err)
+
+
+/**
+ * Mapping from Windows multimedia WaveOut error codes.
+ */
+#define PJMEDIA_AUDIODEV_WMME_OUT_ERROR_START \
+ (PJMEDIA_AUDIODEV_WMME_IN_ERROR_END + 1000)
+#define PJMEDIA_AUDIODEV_WMME_OUT_ERROR_END \
+ (PJMEDIA_AUDIODEV_WMME_OUT_ERROR_START + 1000)
+/**
+ * Convert WaveOut operation error codes to PJLIB error space.
+ */
+#define PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_OUT(err) \
+ ((int)PJMEDIA_AUDIODEV_WMME_OUT_ERROR_START+err)
+
+
+/************************************************************
+ * Audio Device API error codes
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * General/unknown error.
+ */
+#define PJMEDIA_EAUD_ERR (PJMEDIA_AUDIODEV_ERRNO_START+1) /* 420001 */
+
+/**
+ * @hideinitializer
+ * Unknown error from audio driver
+ */
+#define PJMEDIA_EAUD_SYSERR (PJMEDIA_AUDIODEV_ERRNO_START+2) /* 420002 */
+
+/**
+ * @hideinitializer
+ * Audio subsystem not initialized
+ */
+#define PJMEDIA_EAUD_INIT (PJMEDIA_AUDIODEV_ERRNO_START+3) /* 420003 */
+
+/**
+ * @hideinitializer
+ * Invalid audio device
+ */
+#define PJMEDIA_EAUD_INVDEV (PJMEDIA_AUDIODEV_ERRNO_START+4) /* 420004 */
+
+/**
+ * @hideinitializer
+ * Found no devices
+ */
+#define PJMEDIA_EAUD_NODEV (PJMEDIA_AUDIODEV_ERRNO_START+5) /* 420005 */
+
+/**
+ * @hideinitializer
+ * Unable to find default device
+ */
+#define PJMEDIA_EAUD_NODEFDEV (PJMEDIA_AUDIODEV_ERRNO_START+6) /* 420006 */
+
+/**
+ * @hideinitializer
+ * Device not ready
+ */
+#define PJMEDIA_EAUD_NOTREADY (PJMEDIA_AUDIODEV_ERRNO_START+7) /* 420007 */
+
+/**
+ * @hideinitializer
+ * The audio capability is invalid or not supported
+ */
+#define PJMEDIA_EAUD_INVCAP (PJMEDIA_AUDIODEV_ERRNO_START+8) /* 420008 */
+
+/**
+ * @hideinitializer
+ * The operation is invalid or not supported
+ */
+#define PJMEDIA_EAUD_INVOP (PJMEDIA_AUDIODEV_ERRNO_START+9) /* 420009 */
+
+/**
+ * @hideinitializer
+ * Bad or invalid audio device format
+ */
+#define PJMEDIA_EAUD_BADFORMAT (PJMEDIA_AUDIODEV_ERRNO_START+10) /* 4200010 */
+
+/**
+ * @hideinitializer
+ * Invalid audio device sample format
+ */
+#define PJMEDIA_EAUD_SAMPFORMAT (PJMEDIA_AUDIODEV_ERRNO_START+11) /* 4200011 */
+
+/**
+ * @hideinitializer
+ * Bad latency setting
+ */
+#define PJMEDIA_EAUD_BADLATENCY (PJMEDIA_AUDIODEV_ERRNO_START+12) /* 4200012 */
+
+
+
+
+
+/**
+ * Get error message for the specified error code. Note that this
+ * function is only able to decode PJMEDIA Audiodev specific error code.
+ * Application should use pj_strerror(), which should be able to
+ * decode all error codes belonging to all subsystems (e.g. pjlib,
+ * pjmedia, pjsip, etc).
+ *
+ * @param status The error code.
+ * @param buffer The buffer where to put the error message.
+ * @param bufsize Size of the buffer.
+ *
+ * @return The error message as NULL terminated string,
+ * wrapped with pj_str_t.
+ */
+PJ_DECL(pj_str_t) pjmedia_audiodev_strerror(pj_status_t status, char *buffer,
+ pj_size_t bufsize);
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_AUDIODEV_AUDIODEV_ERRNO_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec.h new file mode 100644 index 0000000..9bc852b --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec.h @@ -0,0 +1,39 @@ +/* $Id: pjmedia-codec.h 2563 2009-04-01 12:05:34Z nanang $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODEC_PJMEDIA_CODEC_H__
+#define __PJMEDIA_CODEC_PJMEDIA_CODEC_H__
+
+/**
+ * @file pjmedia-codec.h
+ * @brief Include all codecs API in PJMEDIA-CODEC
+ */
+
+#include <pjmedia-codec/l16.h>
+#include <pjmedia-codec/gsm.h>
+#include <pjmedia-codec/speex.h>
+#include <pjmedia-codec/ilbc.h>
+#include <pjmedia-codec/g722.h>
+#include <pjmedia-codec/g7221.h>
+#include <pjmedia-codec/ipp_codecs.h>
+#include <pjmedia-codec/passthrough.h>
+
+
+#endif /* __PJMEDIA_CODEC_PJMEDIA_CODEC_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/amr_helper.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/amr_helper.h new file mode 100644 index 0000000..bbb5aea --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/amr_helper.h @@ -0,0 +1,1222 @@ +/* $Id: amr_helper.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODECS_AMR_HELPER_H__
+#define __PJMEDIA_CODECS_AMR_HELPER_H__
+
+/**
+ * @file pjmedia-codec/amr_helper.h
+ * @brief Common tables and helper functions for AMR codec (NB & WB).
+ */
+
+
+#ifdef _MSC_VER
+# pragma warning(disable:4214) // bit field types other than int
+#endif
+
+/**
+ * @defgroup PJMED_AMR_CODEC_HELPER AMR Codec Helper
+ * @ingroup PJMEDIA_CODEC_CODECS
+ * @brief AMR common tables and helper functions.
+ * @{
+ *
+ * This sections describes common AMR constants tables (e.g: bits sensitivity
+ * order map, frame lengths, bitrates) and helper functions (e.g: pack AMR
+ * payload in octet-aligned mode or bandwidth-efficient mode, payload parser,
+ * reorder AMR bitstream).
+ */
+
+PJ_BEGIN_DECL
+
+
+/* AMR bits sensitivity order maps */
+
+const pj_int16_t pjmedia_codec_amrnb_ordermap122[244] =
+{
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 23, 15, 16, 17, 18,
+ 19, 20, 21, 22, 24, 25, 26, 27, 28, 38,
+ 141, 39, 142, 40, 143, 41, 144, 42, 145, 43,
+ 146, 44, 147, 45, 148, 46, 149, 47, 97, 150,
+ 200, 48, 98, 151, 201, 49, 99, 152, 202, 86,
+ 136, 189, 239, 87, 137, 190, 240, 88, 138, 191,
+ 241, 91, 194, 92, 195, 93, 196, 94, 197, 95,
+ 198, 29, 30, 31, 32, 33, 34, 35, 50, 100,
+ 153, 203, 89, 139, 192, 242, 51, 101, 154, 204,
+ 55, 105, 158, 208, 90, 140, 193, 243, 59, 109,
+ 162, 212, 63, 113, 166, 216, 67, 117, 170, 220,
+ 36, 37, 54, 53, 52, 58, 57, 56, 62, 61,
+ 60, 66, 65, 64, 70, 69, 68, 104, 103, 102,
+ 108, 107, 106, 112, 111, 110, 116, 115, 114, 120,
+ 119, 118, 157, 156, 155, 161, 160, 159, 165, 164,
+ 163, 169, 168, 167, 173, 172, 171, 207, 206, 205,
+ 211, 210, 209, 215, 214, 213, 219, 218, 217, 223,
+ 222, 221, 73, 72, 71, 76, 75, 74, 79, 78,
+ 77, 82, 81, 80, 85, 84, 83, 123, 122, 121,
+ 126, 125, 124, 129, 128, 127, 132, 131, 130, 135,
+ 134, 133, 176, 175, 174, 179, 178, 177, 182, 181,
+ 180, 185, 184, 183, 188, 187, 186, 226, 225, 224,
+ 229, 228, 227, 232, 231, 230, 235, 234, 233, 238,
+ 237, 236, 96, 199
+};
+
+const pj_int16_t pjmedia_codec_amrnb_ordermap102[204] =
+{
+ 7, 6, 5, 4, 3, 2, 1, 0, 16, 15,
+ 14, 13, 12, 11, 10, 9, 8, 26, 27, 28,
+ 29, 30, 31, 115, 116, 117, 118, 119, 120, 72,
+ 73, 161, 162, 65, 68, 69, 108, 111, 112, 154,
+ 157, 158, 197, 200, 201, 32, 33, 121, 122, 74,
+ 75, 163, 164, 66, 109, 155, 198, 19, 23, 21,
+ 22, 18, 17, 20, 24, 25, 37, 36, 35, 34,
+ 80, 79, 78, 77, 126, 125, 124, 123, 169, 168,
+ 167, 166, 70, 67, 71, 113, 110, 114, 159, 156,
+ 160, 202, 199, 203, 76, 165, 81, 82, 92, 91,
+ 93, 83, 95, 85, 84, 94, 101, 102, 96, 104,
+ 86, 103, 87, 97, 127, 128, 138, 137, 139, 129,
+ 141, 131, 130, 140, 147, 148, 142, 150, 132, 149,
+ 133, 143, 170, 171, 181, 180, 182, 172, 184, 174,
+ 173, 183, 190, 191, 185, 193, 175, 192, 176, 186,
+ 38, 39, 49, 48, 50, 40, 52, 42, 41, 51,
+ 58, 59, 53, 61, 43, 60, 44, 54, 194, 179,
+ 189, 196, 177, 195, 178, 187, 188, 151, 136, 146,
+ 153, 134, 152, 135, 144, 145, 105, 90, 100, 107,
+ 88, 106, 89, 98, 99, 62, 47, 57, 64, 45,
+ 63, 46, 55, 56
+};
+
+const pj_int16_t pjmedia_codec_amrnb_ordermap795[159] =
+{
+ 8, 7, 6, 5, 4, 3, 2, 14, 16, 9,
+ 10, 12, 13, 15, 11, 17, 20, 22, 24, 23,
+ 19, 18, 21, 56, 88, 122, 154, 57, 89, 123,
+ 155, 58, 90, 124, 156, 52, 84, 118, 150, 53,
+ 85, 119, 151, 27, 93, 28, 94, 29, 95, 30,
+ 96, 31, 97, 61, 127, 62, 128, 63, 129, 59,
+ 91, 125, 157, 32, 98, 64, 130, 1, 0, 25,
+ 26, 33, 99, 34, 100, 65, 131, 66, 132, 54,
+ 86, 120, 152, 60, 92, 126, 158, 55, 87, 121,
+ 153, 117, 116, 115, 46, 78, 112, 144, 43, 75,
+ 109, 141, 40, 72, 106, 138, 36, 68, 102, 134,
+ 114, 149, 148, 147, 146, 83, 82, 81, 80, 51,
+ 50, 49, 48, 47, 45, 44, 42, 39, 35, 79,
+ 77, 76, 74, 71, 67, 113, 111, 110, 108, 105,
+ 101, 145, 143, 142, 140, 137, 133, 41, 73, 107,
+ 139, 37, 69, 103, 135, 38, 70, 104, 136
+};
+
+const pj_int16_t pjmedia_codec_amrnb_ordermap74[148] =
+{
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 26, 87, 27,
+ 88, 28, 89, 29, 90, 30, 91, 51, 80, 112,
+ 141, 52, 81, 113, 142, 54, 83, 115, 144, 55,
+ 84, 116, 145, 58, 119, 59, 120, 21, 22, 23,
+ 17, 18, 19, 31, 60, 92, 121, 56, 85, 117,
+ 146, 20, 24, 25, 50, 79, 111, 140, 57, 86,
+ 118, 147, 49, 78, 110, 139, 48, 77, 53, 82,
+ 114, 143, 109, 138, 47, 76, 108, 137, 32, 33,
+ 61, 62, 93, 94, 122, 123, 41, 42, 43, 44,
+ 45, 46, 70, 71, 72, 73, 74, 75, 102, 103,
+ 104, 105, 106, 107, 131, 132, 133, 134, 135, 136,
+ 34, 63, 95, 124, 35, 64, 96, 125, 36, 65,
+ 97, 126, 37, 66, 98, 127, 38, 67, 99, 128,
+ 39, 68, 100, 129, 40, 69, 101, 130
+};
+
+const pj_int16_t pjmedia_codec_amrnb_ordermap67[134] =
+{
+ 0, 1, 4, 3, 5, 6, 13, 7, 2, 8,
+ 9, 11, 15, 12, 14, 10, 28, 82, 29, 83,
+ 27, 81, 26, 80, 30, 84, 16, 55, 109, 56,
+ 110, 31, 85, 57, 111, 48, 73, 102, 127, 32,
+ 86, 51, 76, 105, 130, 52, 77, 106, 131, 58,
+ 112, 33, 87, 19, 23, 53, 78, 107, 132, 21,
+ 22, 18, 17, 20, 24, 25, 50, 75, 104, 129,
+ 47, 72, 101, 126, 54, 79, 108, 133, 46, 71,
+ 100, 125, 128, 103, 74, 49, 45, 70, 99, 124,
+ 42, 67, 96, 121, 39, 64, 93, 118, 38, 63,
+ 92, 117, 35, 60, 89, 114, 34, 59, 88, 113,
+ 44, 69, 98, 123, 43, 68, 97, 122, 41, 66,
+ 95, 120, 40, 65, 94, 119, 37, 62, 91, 116,
+ 36, 61, 90, 115
+};
+
+const pj_int16_t pjmedia_codec_amrnb_ordermap59[118] =
+{
+ 0, 1, 4, 5, 3, 6, 7, 2, 13, 15,
+ 8, 9, 11, 12, 14, 10, 16, 28, 74, 29,
+ 75, 27, 73, 26, 72, 30, 76, 51, 97, 50,
+ 71, 96, 117, 31, 77, 52, 98, 49, 70, 95,
+ 116, 53, 99, 32, 78, 33, 79, 48, 69, 94,
+ 115, 47, 68, 93, 114, 46, 67, 92, 113, 19,
+ 21, 23, 22, 18, 17, 20, 24, 111, 43, 89,
+ 110, 64, 65, 44, 90, 25, 45, 66, 91, 112,
+ 54, 100, 40, 61, 86, 107, 39, 60, 85, 106,
+ 36, 57, 82, 103, 35, 56, 81, 102, 34, 55,
+ 80, 101, 42, 63, 88, 109, 41, 62, 87, 108,
+ 38, 59, 84, 105, 37, 58, 83, 104
+};
+
+const pj_int16_t pjmedia_codec_amrnb_ordermap515[103] =
+{
+ 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
+ 13, 12, 11, 10, 9, 8, 23, 24, 25, 26,
+ 27, 46, 65, 84, 45, 44, 43, 64, 63, 62,
+ 83, 82, 81, 102, 101, 100, 42, 61, 80, 99,
+ 28, 47, 66, 85, 18, 41, 60, 79, 98, 29,
+ 48, 67, 17, 20, 22, 40, 59, 78, 97, 21,
+ 30, 49, 68, 86, 19, 16, 87, 39, 38, 58,
+ 57, 77, 35, 54, 73, 92, 76, 96, 95, 36,
+ 55, 74, 93, 32, 51, 33, 52, 70, 71, 89,
+ 90, 31, 50, 69, 88, 37, 56, 75, 94, 34,
+ 53, 72, 91
+};
+
+const pj_int16_t pjmedia_codec_amrnb_ordermap475[95] =
+{
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 23, 24, 25, 26,
+ 27, 28, 48, 49, 61, 62, 82, 83, 47, 46,
+ 45, 44, 81, 80, 79, 78, 17, 18, 20, 22,
+ 77, 76, 75, 74, 29, 30, 43, 42, 41, 40,
+ 38, 39, 16, 19, 21, 50, 51, 59, 60, 63,
+ 64, 72, 73, 84, 85, 93, 94, 32, 33, 35,
+ 36, 53, 54, 56, 57, 66, 67, 69, 70, 87,
+ 88, 90, 91, 34, 55, 68, 89, 37, 58, 71,
+ 92, 31, 52, 65, 86
+};
+
+
+const pj_int16_t pjmedia_codec_amrwb_ordermap_660[] =
+{
+ 0, 5, 6, 7, 61, 84, 107, 130, 62, 85,
+ 8, 4, 37, 38, 39, 40, 58, 81, 104, 127,
+ 60, 83, 106, 129, 108, 131, 128, 41, 42, 80,
+ 126, 1, 3, 57, 103, 82, 105, 59, 2, 63,
+ 109, 110, 86, 19, 22, 23, 64, 87, 18, 20,
+ 21, 17, 13, 88, 43, 89, 65, 111, 14, 24,
+ 25, 26, 27, 28, 15, 16, 44, 90, 66, 112,
+ 9, 11, 10, 12, 67, 113, 29, 30, 31, 32,
+ 34, 33, 35, 36, 45, 51, 68, 74, 91, 97,
+ 114, 120, 46, 69, 92, 115, 52, 75, 98, 121,
+ 47, 70, 93, 116, 53, 76, 99, 122, 48, 71,
+ 94, 117, 54, 77, 100, 123, 49, 72, 95, 118,
+ 55, 78, 101, 124, 50, 73, 96, 119, 56, 79,
+ 102, 125
+};
+
+const pj_int16_t pjmedia_codec_amrwb_ordermap_885[] =
+{
+ 0, 4, 6, 7, 5, 3, 47, 48, 49, 112,
+ 113, 114, 75, 106, 140, 171, 80, 111, 145, 176,
+ 77, 108, 142, 173, 78, 109, 143, 174, 79, 110,
+ 144, 175, 76, 107, 141, 172, 50, 115, 51, 2,
+ 1, 81, 116, 146, 19, 21, 12, 17, 18, 20,
+ 16, 25, 13, 10, 14, 24, 23, 22, 26, 8,
+ 15, 52, 117, 31, 82, 147, 9, 33, 11, 83,
+ 148, 53, 118, 28, 27, 84, 149, 34, 35, 29,
+ 46, 32, 30, 54, 119, 37, 36, 39, 38, 40,
+ 85, 150, 41, 42, 43, 44, 45, 55, 60, 65,
+ 70, 86, 91, 96, 101, 120, 125, 130, 135, 151,
+ 156, 161, 166, 56, 87, 121, 152, 61, 92, 126,
+ 157, 66, 97, 131, 162, 71, 102, 136, 167, 57,
+ 88, 122, 153, 62, 93, 127, 158, 67, 98, 132,
+ 163, 72, 103, 137, 168, 58, 89, 123, 154, 63,
+ 94, 128, 159, 68, 99, 133, 164, 73, 104, 138,
+ 169, 59, 90, 124, 155, 64, 95, 129, 160, 69,
+ 100, 134, 165, 74, 105, 139, 170
+};
+
+const pj_int16_t pjmedia_codec_amrwb_ordermap_1265[] =
+{
+ 0, 4, 6, 93, 143, 196, 246, 7, 5, 3,
+ 47, 48, 49, 50, 51, 150, 151, 152, 153, 154,
+ 94, 144, 197, 247, 99, 149, 202, 252, 96, 146,
+ 199, 249, 97, 147, 200, 250, 100, 203, 98, 148,
+ 201, 251, 95, 145, 198, 248, 52, 2, 1, 101,
+ 204, 155, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 156, 31, 102, 205, 9, 33, 11, 103, 206, 54,
+ 157, 28, 27, 104, 207, 34, 35, 29, 46, 32,
+ 30, 55, 158, 37, 36, 39, 38, 40, 105, 208,
+ 41, 42, 43, 44, 45, 56, 106, 159, 209, 57,
+ 66, 75, 84, 107, 116, 125, 134, 160, 169, 178,
+ 187, 210, 219, 228, 237, 58, 108, 161, 211, 62,
+ 112, 165, 215, 67, 117, 170, 220, 71, 121, 174,
+ 224, 76, 126, 179, 229, 80, 130, 183, 233, 85,
+ 135, 188, 238, 89, 139, 192, 242, 59, 109, 162,
+ 212, 63, 113, 166, 216, 68, 118, 171, 221, 72,
+ 122, 175, 225, 77, 127, 180, 230, 81, 131, 184,
+ 234, 86, 136, 189, 239, 90, 140, 193, 243, 60,
+ 110, 163, 213, 64, 114, 167, 217, 69, 119, 172,
+ 222, 73, 123, 176, 226, 78, 128, 181, 231, 82,
+ 132, 185, 235, 87, 137, 190, 240, 91, 141, 194,
+ 244, 61, 111, 164, 214, 65, 115, 168, 218, 70,
+ 120, 173, 223, 74, 124, 177, 227, 79, 129, 182,
+ 232, 83, 133, 186, 236, 88, 138, 191, 241, 92,
+ 142, 195, 245
+};
+
+const pj_int16_t pjmedia_codec_amrwb_ordermap_1425[] =
+{
+ 0, 4, 6, 101, 159, 220, 278, 7, 5, 3,
+ 47, 48, 49, 50, 51, 166, 167, 168, 169, 170,
+ 102, 160, 221, 279, 107, 165, 226, 284, 104, 162,
+ 223, 281, 105, 163, 224, 282, 108, 227, 106, 164,
+ 225, 283, 103, 161, 222, 280, 52, 2, 1, 109,
+ 228, 171, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 172, 31, 110, 229, 9, 33, 11, 111, 230, 54,
+ 173, 28, 27, 112, 231, 34, 35, 29, 46, 32,
+ 30, 55, 174, 37, 36, 39, 38, 40, 113, 232,
+ 41, 42, 43, 44, 45, 56, 114, 175, 233, 62,
+ 120, 181, 239, 75, 133, 194, 252, 57, 115, 176,
+ 234, 63, 121, 182, 240, 70, 128, 189, 247, 76,
+ 134, 195, 253, 83, 141, 202, 260, 92, 150, 211,
+ 269, 84, 142, 203, 261, 93, 151, 212, 270, 85,
+ 143, 204, 262, 94, 152, 213, 271, 86, 144, 205,
+ 263, 95, 153, 214, 272, 64, 122, 183, 241, 77,
+ 135, 196, 254, 65, 123, 184, 242, 78, 136, 197,
+ 255, 87, 145, 206, 264, 96, 154, 215, 273, 58,
+ 116, 177, 235, 66, 124, 185, 243, 71, 129, 190,
+ 248, 79, 137, 198, 256, 88, 146, 207, 265, 97,
+ 155, 216, 274, 59, 117, 178, 236, 67, 125, 186,
+ 244, 72, 130, 191, 249, 80, 138, 199, 257, 89,
+ 147, 208, 266, 98, 156, 217, 275, 60, 118, 179,
+ 237, 68, 126, 187, 245, 73, 131, 192, 250, 81,
+ 139, 200, 258, 90, 148, 209, 267, 99, 157, 218,
+ 276, 61, 119, 180, 238, 69, 127, 188, 246, 74,
+ 132, 193, 251, 82, 140, 201, 259, 91, 149, 210,
+ 268, 100, 158, 219, 277
+};
+
+const pj_int16_t pjmedia_codec_amrwb_ordermap_1585[] =
+{
+ 0, 4, 6, 109, 175, 244, 310, 7, 5, 3,
+ 47, 48, 49, 50, 51, 182, 183, 184, 185, 186,
+ 110, 176, 245, 311, 115, 181, 250, 316, 112, 178,
+ 247, 313, 113, 179, 248, 314, 116, 251, 114, 180,
+ 249, 315, 111, 177, 246, 312, 52, 2, 1, 117,
+ 252, 187, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 188, 31, 118, 253, 9, 33, 11, 119, 254, 54,
+ 189, 28, 27, 120, 255, 34, 35, 29, 46, 32,
+ 30, 55, 190, 37, 36, 39, 38, 40, 121, 256,
+ 41, 42, 43, 44, 45, 56, 122, 191, 257, 63,
+ 129, 198, 264, 76, 142, 211, 277, 89, 155, 224,
+ 290, 102, 168, 237, 303, 57, 123, 192, 258, 70,
+ 136, 205, 271, 83, 149, 218, 284, 96, 162, 231,
+ 297, 62, 128, 197, 263, 75, 141, 210, 276, 88,
+ 154, 223, 289, 101, 167, 236, 302, 58, 124, 193,
+ 259, 71, 137, 206, 272, 84, 150, 219, 285, 97,
+ 163, 232, 298, 59, 125, 194, 260, 64, 130, 199,
+ 265, 67, 133, 202, 268, 72, 138, 207, 273, 77,
+ 143, 212, 278, 80, 146, 215, 281, 85, 151, 220,
+ 286, 90, 156, 225, 291, 93, 159, 228, 294, 98,
+ 164, 233, 299, 103, 169, 238, 304, 106, 172, 241,
+ 307, 60, 126, 195, 261, 65, 131, 200, 266, 68,
+ 134, 203, 269, 73, 139, 208, 274, 78, 144, 213,
+ 279, 81, 147, 216, 282, 86, 152, 221, 287, 91,
+ 157, 226, 292, 94, 160, 229, 295, 99, 165, 234,
+ 300, 104, 170, 239, 305, 107, 173, 242, 308, 61,
+ 127, 196, 262, 66, 132, 201, 267, 69, 135, 204,
+ 270, 74, 140, 209, 275, 79, 145, 214, 280, 82,
+ 148, 217, 283, 87, 153, 222, 288, 92, 158, 227,
+ 293, 95, 161, 230, 296, 100, 166, 235, 301, 105,
+ 171, 240, 306, 108, 174, 243, 309
+};
+
+const pj_int16_t pjmedia_codec_amrwb_ordermap_1825[] =
+{
+ 0, 4, 6, 121, 199, 280, 358, 7, 5, 3,
+ 47, 48, 49, 50, 51, 206, 207, 208, 209, 210,
+ 122, 200, 281, 359, 127, 205, 286, 364, 124, 202,
+ 283, 361, 125, 203, 284, 362, 128, 287, 126, 204,
+ 285, 363, 123, 201, 282, 360, 52, 2, 1, 129,
+ 288, 211, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 212, 31, 130, 289, 9, 33, 11, 131, 290, 54,
+ 213, 28, 27, 132, 291, 34, 35, 29, 46, 32,
+ 30, 55, 214, 37, 36, 39, 38, 40, 133, 292,
+ 41, 42, 43, 44, 45, 56, 134, 215, 293, 198,
+ 299, 136, 120, 138, 60, 279, 58, 62, 357, 139,
+ 140, 295, 156, 57, 219, 297, 63, 217, 137, 170,
+ 300, 222, 64, 106, 61, 78, 294, 92, 142, 141,
+ 135, 221, 296, 301, 343, 59, 298, 184, 329, 315,
+ 220, 216, 265, 251, 218, 237, 352, 223, 157, 86,
+ 171, 87, 164, 351, 111, 302, 65, 178, 115, 323,
+ 72, 192, 101, 179, 93, 73, 193, 151, 337, 309,
+ 143, 274, 69, 324, 165, 150, 97, 338, 110, 310,
+ 330, 273, 68, 107, 175, 245, 114, 79, 113, 189,
+ 246, 259, 174, 71, 185, 96, 344, 100, 322, 83,
+ 334, 316, 333, 252, 161, 348, 147, 82, 269, 232,
+ 260, 308, 353, 347, 163, 231, 306, 320, 188, 270,
+ 146, 177, 266, 350, 256, 85, 149, 116, 191, 160,
+ 238, 258, 336, 305, 255, 88, 224, 99, 339, 230,
+ 228, 227, 272, 242, 241, 319, 233, 311, 102, 74,
+ 180, 275, 66, 194, 152, 325, 172, 247, 244, 261,
+ 117, 158, 166, 354, 75, 144, 108, 312, 94, 186,
+ 303, 80, 234, 89, 195, 112, 340, 181, 345, 317,
+ 326, 276, 239, 167, 118, 313, 70, 355, 327, 253,
+ 190, 176, 271, 104, 98, 153, 103, 90, 76, 267,
+ 277, 248, 225, 262, 182, 84, 154, 235, 335, 168,
+ 331, 196, 341, 249, 162, 307, 148, 349, 263, 321,
+ 257, 243, 229, 356, 159, 119, 67, 187, 173, 145,
+ 240, 77, 304, 332, 314, 342, 109, 254, 81, 278,
+ 105, 91, 346, 318, 183, 250, 197, 328, 95, 155,
+ 169, 268, 226, 236, 264
+};
+
+const pj_int16_t pjmedia_codec_amrwb_ordermap_1985[] =
+{
+ 0, 4, 6, 129, 215, 304, 390, 7, 5, 3,
+ 47, 48, 49, 50, 51, 222, 223, 224, 225, 226,
+ 130, 216, 305, 391, 135, 221, 310, 396, 132, 218,
+ 307, 393, 133, 219, 308, 394, 136, 311, 134, 220,
+ 309, 395, 131, 217, 306, 392, 52, 2, 1, 137,
+ 312, 227, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 228, 31, 138, 313, 9, 33, 11, 139, 314, 54,
+ 229, 28, 27, 140, 315, 34, 35, 29, 46, 32,
+ 30, 55, 230, 37, 36, 39, 38, 40, 141, 316,
+ 41, 42, 43, 44, 45, 56, 142, 231, 317, 63,
+ 73, 92, 340, 82, 324, 149, 353, 159, 334, 165,
+ 338, 178, 163, 254, 77, 168, 257, 153, 343, 57,
+ 248, 238, 79, 252, 166, 67, 80, 201, 101, 267,
+ 143, 164, 341, 255, 339, 187, 376, 318, 78, 328,
+ 362, 115, 232, 242, 253, 290, 276, 62, 58, 158,
+ 68, 93, 179, 319, 148, 169, 154, 72, 385, 329,
+ 333, 344, 102, 83, 144, 233, 323, 124, 243, 192,
+ 354, 237, 64, 247, 202, 209, 150, 116, 335, 268,
+ 239, 299, 188, 196, 298, 94, 195, 258, 123, 363,
+ 384, 109, 325, 371, 170, 370, 84, 110, 295, 180,
+ 74, 210, 191, 106, 291, 205, 367, 381, 377, 206,
+ 355, 122, 119, 120, 383, 160, 105, 108, 277, 380,
+ 294, 284, 285, 345, 208, 269, 249, 366, 386, 300,
+ 297, 259, 125, 369, 197, 97, 194, 286, 211, 281,
+ 280, 183, 372, 87, 155, 283, 59, 348, 327, 184,
+ 76, 111, 330, 203, 349, 69, 98, 152, 145, 189,
+ 66, 320, 337, 173, 358, 251, 198, 174, 263, 262,
+ 126, 241, 193, 88, 388, 117, 95, 387, 112, 359,
+ 287, 244, 103, 272, 301, 171, 162, 234, 273, 127,
+ 373, 181, 292, 85, 378, 302, 121, 107, 364, 346,
+ 356, 212, 278, 213, 65, 382, 288, 207, 113, 175,
+ 99, 296, 374, 368, 199, 260, 185, 336, 331, 161,
+ 270, 264, 250, 240, 75, 350, 151, 60, 89, 321,
+ 156, 274, 360, 326, 70, 282, 167, 146, 352, 81,
+ 91, 389, 266, 245, 177, 235, 190, 256, 204, 342,
+ 128, 118, 303, 104, 379, 182, 114, 375, 200, 96,
+ 293, 172, 214, 365, 279, 86, 289, 351, 347, 357,
+ 261, 186, 176, 271, 90, 100, 147, 322, 275, 361,
+ 71, 332, 61, 265, 157, 246, 236
+};
+
+const pj_int16_t pjmedia_codec_amrwb_ordermap_2305[] =
+{
+ 0, 4, 6, 145, 247, 352, 454, 7, 5, 3,
+ 47, 48, 49, 50, 51, 254, 255, 256, 257, 258,
+ 146, 248, 353, 455, 151, 253, 358, 460, 148, 250,
+ 355, 457, 149, 251, 356, 458, 152, 359, 150, 252,
+ 357, 459, 147, 249, 354, 456, 52, 2, 1, 153,
+ 360, 259, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 260, 31, 154, 361, 9, 33, 11, 155, 362, 54,
+ 261, 28, 27, 156, 363, 34, 35, 29, 46, 32,
+ 30, 55, 262, 37, 36, 39, 38, 40, 157, 364,
+ 41, 42, 43, 44, 45, 56, 158, 263, 365, 181,
+ 192, 170, 79, 57, 399, 90, 159, 297, 377, 366,
+ 275, 68, 183, 388, 286, 194, 299, 92, 70, 182,
+ 401, 172, 59, 91, 58, 400, 368, 161, 81, 160,
+ 264, 171, 80, 389, 390, 378, 379, 193, 298, 69,
+ 266, 265, 367, 277, 288, 276, 287, 184, 60, 195,
+ 82, 93, 71, 369, 402, 173, 162, 444, 300, 391,
+ 98, 76, 278, 61, 267, 374, 135, 411, 167, 102,
+ 380, 200, 87, 178, 65, 94, 204, 124, 72, 342,
+ 189, 305, 381, 396, 433, 301, 226, 407, 289, 237,
+ 113, 215, 185, 128, 309, 403, 116, 320, 196, 331,
+ 370, 422, 174, 64, 392, 83, 425, 219, 134, 188,
+ 432, 112, 427, 139, 279, 163, 436, 208, 447, 218,
+ 236, 229, 97, 294, 385, 230, 166, 268, 177, 443,
+ 225, 426, 101, 272, 138, 127, 290, 117, 347, 199,
+ 414, 95, 140, 240, 410, 395, 209, 129, 283, 346,
+ 105, 241, 437, 86, 308, 448, 203, 345, 186, 107,
+ 220, 415, 334, 319, 106, 313, 118, 123, 73, 207,
+ 421, 214, 384, 373, 438, 62, 371, 341, 75, 449,
+ 168, 323, 164, 242, 416, 324, 304, 197, 335, 404,
+ 271, 63, 191, 325, 96, 169, 231, 280, 312, 187,
+ 406, 84, 201, 100, 67, 382, 175, 336, 202, 330,
+ 269, 393, 376, 383, 293, 307, 409, 179, 285, 314,
+ 302, 372, 398, 190, 180, 89, 99, 103, 232, 78,
+ 88, 77, 136, 387, 165, 198, 394, 125, 176, 428,
+ 74, 375, 238, 227, 66, 273, 282, 141, 306, 412,
+ 114, 85, 130, 348, 119, 291, 296, 386, 233, 397,
+ 303, 405, 284, 445, 423, 221, 210, 205, 450, 108,
+ 274, 434, 216, 343, 337, 142, 243, 321, 408, 451,
+ 310, 292, 120, 109, 281, 439, 270, 429, 332, 295,
+ 418, 211, 315, 222, 326, 131, 430, 244, 327, 349,
+ 417, 316, 143, 338, 440, 234, 110, 212, 452, 245,
+ 121, 419, 350, 223, 132, 441, 328, 413, 317, 339,
+ 126, 104, 137, 446, 344, 239, 435, 115, 333, 206,
+ 322, 217, 228, 424, 453, 311, 351, 111, 442, 224,
+ 213, 122, 431, 340, 235, 246, 133, 144, 420, 329,
+ 318
+};
+
+const pj_int16_t pjmedia_codec_amrwb_ordermap_2385[] =
+{
+ 0, 4, 6, 145, 251, 360, 466, 7, 5, 3,
+ 47, 48, 49, 50, 51, 262, 263, 264, 265, 266,
+ 146, 252, 361, 467, 151, 257, 366, 472, 148, 254,
+ 363, 469, 149, 255, 364, 470, 156, 371, 150, 256,
+ 365, 471, 147, 253, 362, 468, 52, 2, 1, 157,
+ 372, 267, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 268, 31, 152, 153, 154, 155, 258, 259, 260, 261,
+ 367, 368, 369, 370, 473, 474, 475, 476, 158, 373,
+ 9, 33, 11, 159, 374, 54, 269, 28, 27, 160,
+ 375, 34, 35, 29, 46, 32, 30, 55, 270, 37,
+ 36, 39, 38, 40, 161, 376, 41, 42, 43, 44,
+ 45, 56, 162, 271, 377, 185, 196, 174, 79, 57,
+ 411, 90, 163, 305, 389, 378, 283, 68, 187, 400,
+ 294, 198, 307, 92, 70, 186, 413, 176, 59, 91,
+ 58, 412, 380, 165, 81, 164, 272, 175, 80, 401,
+ 402, 390, 391, 197, 306, 69, 274, 273, 379, 285,
+ 296, 284, 295, 188, 60, 199, 82, 93, 71, 381,
+ 414, 177, 166, 456, 308, 403, 98, 76, 286, 61,
+ 275, 386, 135, 423, 171, 102, 392, 204, 87, 182,
+ 65, 94, 208, 124, 72, 350, 193, 313, 393, 408,
+ 445, 309, 230, 419, 297, 241, 113, 219, 189, 128,
+ 317, 415, 116, 328, 200, 339, 382, 434, 178, 64,
+ 404, 83, 437, 223, 134, 192, 444, 112, 439, 139,
+ 287, 167, 448, 212, 459, 222, 240, 233, 97, 302,
+ 397, 234, 170, 276, 181, 455, 229, 438, 101, 280,
+ 138, 127, 298, 117, 355, 203, 426, 95, 140, 244,
+ 422, 407, 213, 129, 291, 354, 105, 245, 449, 86,
+ 316, 460, 207, 353, 190, 107, 224, 427, 342, 327,
+ 106, 321, 118, 123, 73, 211, 433, 218, 396, 385,
+ 450, 62, 383, 349, 75, 461, 172, 331, 168, 246,
+ 428, 332, 312, 201, 343, 416, 279, 63, 195, 333,
+ 96, 173, 235, 288, 320, 191, 418, 84, 205, 100,
+ 67, 394, 179, 344, 206, 338, 277, 405, 388, 395,
+ 301, 315, 421, 183, 293, 322, 310, 384, 410, 194,
+ 184, 89, 99, 103, 236, 78, 88, 77, 136, 399,
+ 169, 202, 406, 125, 180, 440, 74, 387, 242, 231,
+ 66, 281, 290, 141, 314, 424, 114, 85, 130, 356,
+ 119, 299, 304, 398, 237, 409, 311, 417, 292, 457,
+ 435, 225, 214, 209, 462, 108, 282, 446, 220, 351,
+ 345, 142, 247, 329, 420, 463, 318, 300, 120, 109,
+ 289, 451, 278, 441, 340, 303, 430, 215, 323, 226,
+ 334, 131, 442, 248, 335, 357, 429, 324, 143, 346,
+ 452, 238, 110, 216, 464, 249, 121, 431, 358, 227,
+ 132, 453, 336, 425, 325, 347, 126, 104, 137, 458,
+ 352, 243, 447, 115, 341, 210, 330, 221, 232, 436,
+ 465, 319, 359, 111, 454, 228, 217, 122, 443, 348,
+ 239, 250, 133, 144, 432, 337, 326
+};
+
+/**
+ * AMR-NB bitstream sensitivity order maps.
+ */
+const pj_int16_t* const pjmedia_codec_amrnb_ordermaps[8] =
+{
+ pjmedia_codec_amrnb_ordermap475,
+ pjmedia_codec_amrnb_ordermap515,
+ pjmedia_codec_amrnb_ordermap59,
+ pjmedia_codec_amrnb_ordermap67,
+ pjmedia_codec_amrnb_ordermap74,
+ pjmedia_codec_amrnb_ordermap795,
+ pjmedia_codec_amrnb_ordermap102,
+ pjmedia_codec_amrnb_ordermap122
+};
+
+/**
+ * AMR-WB bitstream sensitivity order maps.
+ */
+const pj_int16_t* const pjmedia_codec_amrwb_ordermaps[9] =
+{
+ pjmedia_codec_amrwb_ordermap_660,
+ pjmedia_codec_amrwb_ordermap_885,
+ pjmedia_codec_amrwb_ordermap_1265,
+ pjmedia_codec_amrwb_ordermap_1425,
+ pjmedia_codec_amrwb_ordermap_1585,
+ pjmedia_codec_amrwb_ordermap_1825,
+ pjmedia_codec_amrwb_ordermap_1985,
+ pjmedia_codec_amrwb_ordermap_2305,
+ pjmedia_codec_amrwb_ordermap_2385
+};
+
+/**
+ * Constant of AMR-NB frame lengths in bytes.
+ */
+const pj_uint8_t pjmedia_codec_amrnb_framelen[16] =
+ {12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 5};
+/**
+ * Constant of AMR-NB frame lengths in bits.
+ */
+const pj_uint16_t pjmedia_codec_amrnb_framelenbits[9] =
+ {95, 103, 118, 134, 148, 159, 204, 244, 39};
+/**
+ * Constant of AMR-NB bitrates.
+ */
+const pj_uint16_t pjmedia_codec_amrnb_bitrates[8] =
+ {4750, 5150, 5900, 6700, 7400, 7950, 10200, 12200};
+
+/**
+ * Constant of AMR-WB frame lengths in bytes.
+ */
+const pj_uint8_t pjmedia_codec_amrwb_framelen[16] =
+ {17, 23, 32, 37, 40, 46, 50, 58, 60, 5, 0, 0, 0, 0, 0, 5};
+/**
+ * Constant of AMR-WB frame lengths in bits.
+ */
+const pj_uint16_t pjmedia_codec_amrwb_framelenbits[10] =
+ {132, 177, 253, 285, 317, 365, 397, 461, 477, 40};
+/**
+ * Constant of AMR-WB bitrates.
+ */
+const pj_uint16_t pjmedia_codec_amrwb_bitrates[9] =
+ {6600, 8850, 12650, 14250, 15850, 18250, 19850, 23050, 23850};
+
+
+/**
+ * This structure describes AMR frame info, to be fitted into @pjmedia_frame
+ * bit info.
+ */
+#pragma pack(1)
+typedef struct pjmedia_codec_amr_bit_info {
+ pj_uint8_t frame_type; /**< AMR frame type. */
+ pj_int8_t mode; /**< AMR mode. */
+ pj_uint8_t start_bit; /**< Frame start bit. */
+ pj_uint8_t good_quality:1; /**< Flag if frame is good/degraded. */
+} pjmedia_codec_amr_bit_info;
+#pragma pack()
+
+
+/**
+ * This structure describes AMR settings.
+ */
+typedef struct pjmedia_codec_amr_pack_setting {
+ pj_uint8_t amr_nb:1; /**< Set 1 for AMR-NB, 0 for AMR-WB. */
+ pj_uint8_t reorder:1; /**< Reorder bitstream into descending
+ sensitivity order or vice versa. */
+ pj_uint8_t octet_aligned:1; /**< TRUE if payload is in octet-aligned mode,
+ FALSE if payload is in bandwidth
+ efficient mode. */
+ pj_uint8_t cmr:4; /**< Change Mode Request for remote
+ encoder. */
+} pjmedia_codec_amr_pack_setting;
+
+
+/**
+ * Get AMR mode based on bitrate.
+ *
+ * @param bitrate AMR bitrate.
+ *
+ * @return AMR mode.
+ */
+PJ_INLINE(pj_int8_t) pjmedia_codec_amr_get_mode(unsigned bitrate)
+{
+ pj_int8_t mode = -1;
+
+ if(bitrate==4750){
+ mode = 0;
+ } else if(bitrate==5150){
+ mode = 1;
+ } else if(bitrate==5900){
+ mode = 2;
+ } else if(bitrate==6700){
+ mode = 3;
+ } else if(bitrate==7400){
+ mode = 4;
+ } else if(bitrate==7950){
+ mode = 5;
+ } else if(bitrate==10200){
+ mode = 6;
+ } else if(bitrate==12200){
+ mode = 7;
+
+ /* AMRWB */
+ } else if(bitrate==6600){
+ mode = 0;
+ } else if(bitrate==8850){
+ mode = 1;
+ } else if(bitrate==12650){
+ mode = 2;
+ } else if(bitrate==14250){
+ mode = 3;
+ } else if(bitrate==15850){
+ mode = 4;
+ } else if(bitrate==18250){
+ mode = 5;
+ } else if(bitrate==19850){
+ mode = 6;
+ } else if(bitrate==23050){
+ mode = 7;
+ } else if(bitrate==23850){
+ mode = 8;
+ }
+ return mode;
+}
+
+/**
+ * Get AMR mode based on frame length.
+ *
+ * @param amrnb Set to PJ_TRUE for AMR-NB domain or PJ_FALSE for AMR-WB.
+ * @param frame_len The frame length.
+ *
+ * @return AMR mode.
+ */
+
+PJ_INLINE(pj_int8_t) pjmedia_codec_amr_get_mode2(pj_bool_t amrnb,
+ unsigned frame_len)
+{
+ int i;
+
+ if (amrnb) {
+ for (i = 0; i < 9; ++i)
+ if (frame_len == pjmedia_codec_amrnb_framelen[i])
+ return (pj_int8_t)i;
+ } else {
+ for (i = 0; i < 10; ++i) {
+ if (frame_len == pjmedia_codec_amrwb_framelen[i])
+ return (pj_int8_t)i;
+ }
+ }
+
+ pj_assert(!"Invalid AMR frame length");
+ return -1;
+}
+
+/**
+ * Prepare a frame before pass it to decoder. This function will do:
+ * - reorder AMR bitstream from descending sensitivity order into
+ * encoder bits order. This can be enabled/disabled via param
+ * 'setting' by setting/resetting field 'reorder'.
+ * - align left the start bit (make the start_bit to be 0).
+ *
+ * @param amr_nb Set PJ_TRUE for AMR-NB and PJ_FALSE for AMR-WB.
+ * @param in Input frame.
+ * @param setting Settings, see @pjmedia_codec_amr_pack_setting.
+ * @param out Output frame.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_codec_amr_predecode(
+ const pjmedia_frame *in,
+ const pjmedia_codec_amr_pack_setting *setting,
+ pjmedia_frame *out)
+{
+ pj_int8_t amr_bits[477 + 7] = {0};
+ pj_int8_t *p_amr_bits = &amr_bits[0];
+
+ pj_uint8_t *r = (pj_uint8_t*) in->buf; /* read cursor */
+ pj_uint8_t *w = (pj_uint8_t*) out->buf; /* write cursor */
+
+ /* env vars for AMR or AMRWB */
+ pj_uint8_t SID_FT;
+ const pj_uint8_t *framelen_tbl;
+ const pj_uint16_t *framelenbit_tbl;
+ const pj_uint16_t *bitrate_tbl;
+ const pj_int16_t* const *order_maps;
+
+ pjmedia_codec_amr_bit_info *in_info =
+ (pjmedia_codec_amr_bit_info*) &in->bit_info;
+ pjmedia_codec_amr_bit_info *out_info =
+ (pjmedia_codec_amr_bit_info*) &out->bit_info;
+
+ unsigned i;
+
+ *out_info = *in_info;
+
+ if (setting->amr_nb) {
+ SID_FT = 8;
+ framelen_tbl = pjmedia_codec_amrnb_framelen;
+ framelenbit_tbl = pjmedia_codec_amrnb_framelenbits;
+ bitrate_tbl = pjmedia_codec_amrnb_bitrates;
+ order_maps = pjmedia_codec_amrnb_ordermaps;
+ } else {
+ SID_FT = 9;
+ framelen_tbl = pjmedia_codec_amrwb_framelen;
+ framelenbit_tbl = pjmedia_codec_amrwb_framelenbits;
+ bitrate_tbl = pjmedia_codec_amrwb_bitrates;
+ order_maps = pjmedia_codec_amrwb_ordermaps;
+ }
+
+ /* unpack AMR bitstream if there is any data */
+ if (in_info->frame_type <= SID_FT) {
+ i = 0;
+ if (in_info->start_bit) {
+ for (; i < (unsigned)(8-in_info->start_bit); ++i)
+ *p_amr_bits++ = (pj_uint8_t)
+ ((*r >> (7-in_info->start_bit-i)) & 1);
+ ++r;
+ }
+ for(; i < framelenbit_tbl[in_info->frame_type]; i += 8, ++r) {
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 7) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 6) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 5) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 4) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 3) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 2) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 1) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r ) & 1);
+ }
+ }
+
+ if (in_info->frame_type < SID_FT) {
+
+ /* Speech */
+ out_info->mode = in_info->frame_type;
+ out->size = framelen_tbl[out_info->mode];
+
+ pj_bzero(out->buf, out->size);
+
+ if (setting->reorder) {
+ const pj_int16_t *order_map;
+
+ order_map = order_maps[out_info->mode];
+ for(i = 0; i < framelenbit_tbl[out_info->mode]; ++i) {
+ if (amr_bits[i]) {
+ pj_uint16_t bitpos;
+ bitpos = order_map[i];
+ w[bitpos>>3] |= 1 << (7 - (bitpos % 8));
+ }
+ }
+ } else {
+ for(i = 0; i < framelenbit_tbl[out_info->mode]; ++i) {
+ if (amr_bits[i])
+ w[i >> 3] |= 1 << (7 - (i % 8));
+ }
+ }
+
+ } else if (in_info->frame_type == SID_FT) {
+
+ /* SID */
+ pj_uint8_t w_bitptr = 0;
+ pj_uint8_t FT_;
+
+ if (setting->amr_nb)
+ FT_ = (pj_uint8_t)((amr_bits[36] << 2) | (amr_bits[37] << 1) |
+ amr_bits[38]);
+ else
+ FT_ = (pj_uint8_t)((amr_bits[36] << 3) | (amr_bits[37] << 2) |
+ (amr_bits[38] << 1) | amr_bits[39]);
+
+ out_info->mode = FT_;
+ out->size = 5;
+
+ pj_bzero(out->buf, out->size);
+ for(i = 0; i < framelenbit_tbl[SID_FT]; ++i) {
+ if (amr_bits[i])
+ *w |= (1 << (7-w_bitptr));
+
+ if (++w_bitptr == 8) {
+ ++w;
+ w_bitptr = 0;
+ }
+ }
+
+ } else {
+
+ /* NO DATA */
+ out->size = 0;
+ out_info->mode = -1;
+ }
+
+ out_info->start_bit = 0;
+
+ return PJ_SUCCESS;
+}
+
+
+/**
+ * Pack encoded AMR frame(s) into an RTP payload.
+ *
+ * @param frames AMR frames to be packed.
+ * @param nframes Number of frames to be packed.
+ * @param setting Settings, see @pjmedia_codec_amr_pack_setting.
+ * @param pkt Payload.
+ * @param pkt_size Payload size, as input this specifies payload maximum size,
+ * as output this specifies payload packed size.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_INLINE (pj_status_t) pjmedia_codec_amr_pack(
+ const pjmedia_frame frames[],
+ unsigned nframes,
+ const pjmedia_codec_amr_pack_setting *setting,
+ void *pkt,
+ pj_size_t *pkt_size)
+{
+ /* Write cursor */
+ pj_uint8_t *w = (pj_uint8_t*)pkt;
+ pj_uint8_t w_bitptr = 0;
+
+ /* Read cursor */
+ pj_uint8_t *r;
+
+ /* env vars for AMR or AMRWB */
+ pj_uint8_t SID_FT;
+ const pj_uint8_t *framelen_tbl;
+ const pj_uint16_t *framelenbit_tbl;
+ const pj_uint16_t *bitrate_tbl;
+ const pj_int16_t* const *order_maps;
+
+ /* frame info */
+ pjmedia_codec_amr_bit_info *info;
+
+ unsigned i, max_pkt_size;
+
+ max_pkt_size = *pkt_size;
+
+ if (setting->amr_nb) {
+ SID_FT = 8;
+ framelen_tbl = pjmedia_codec_amrnb_framelen;
+ framelenbit_tbl = pjmedia_codec_amrnb_framelenbits;
+ bitrate_tbl = pjmedia_codec_amrnb_bitrates;
+ order_maps = pjmedia_codec_amrnb_ordermaps;
+ } else {
+ SID_FT = 9;
+ framelen_tbl = pjmedia_codec_amrwb_framelen;
+ framelenbit_tbl = pjmedia_codec_amrwb_framelenbits;
+ bitrate_tbl = pjmedia_codec_amrwb_bitrates;
+ order_maps = pjmedia_codec_amrwb_ordermaps;
+ }
+
+ /* Code Mode Request, 4 bits */
+ *w = (pj_uint8_t)(setting->cmr << 4);
+ w_bitptr = 4;
+ if (setting->octet_aligned) {
+ ++w;
+ w_bitptr = 0;
+ }
+
+ /* Table Of Contents, 6 bits each */
+ for (i = 0; i < nframes; ++i) {
+ pj_uint8_t TOC, FT, Q;
+ pj_bool_t F;
+
+ info = (pjmedia_codec_amr_bit_info*)&frames[i].bit_info;
+
+ F = (i != nframes-1);
+ FT = info->frame_type;
+ Q = (pj_uint8_t)(info->good_quality == 1);
+ pj_assert(FT <= SID_FT || FT == 14 || FT == 15);
+
+ /* Check buffer availability */
+ *pkt_size = w - (pj_uint8_t*)pkt + 1;
+ PJ_ASSERT_RETURN(*pkt_size <= max_pkt_size, PJ_ETOOSMALL);
+
+ TOC = (pj_uint8_t)((F<<5) | (FT<<1) | Q);
+ if (w_bitptr == 0) {
+ *w = (pj_uint8_t)(TOC<<2);
+ w_bitptr = 6;
+ } else if (w_bitptr == 2) {
+ *w++ |= TOC;
+ w_bitptr = 0;
+ } else if (w_bitptr == 4) {
+ *w++ |= TOC>>2;
+ *w = (pj_uint8_t)(TOC<<6);
+ w_bitptr = 2;
+ } else if (w_bitptr == 6) {
+ *w++ |= TOC>>4;
+ *w = (pj_uint8_t)(TOC<<4);
+ w_bitptr = 4;
+ }
+ if (setting->octet_aligned) {
+ ++w;
+ w_bitptr = 0;
+ }
+ }
+
+ /* Encoded data */
+ for (i = 0; i < nframes; ++i) {
+ pj_int8_t amr_bits[477 + 7] = {0};
+ pj_int8_t *p_amr_bits = &amr_bits[0];
+ unsigned j;
+
+ info = (pjmedia_codec_amr_bit_info*)&frames[i].bit_info;
+
+ /* Check buffer availability */
+ *pkt_size = w - (pj_uint8_t*)pkt;
+ if (info->frame_type <= SID_FT)
+ *pkt_size += framelen_tbl[info->frame_type] + 1;
+ PJ_ASSERT_RETURN(*pkt_size <= max_pkt_size, PJ_ETOOSMALL);
+
+ /* Skip if there is no data */
+ if (info->frame_type > SID_FT)
+ continue;
+
+ /* Unpack bits */
+ r = (pj_uint8_t*) frames[i].buf;
+ j = 0;
+ if (info->start_bit) {
+ for (; j < (unsigned)(8-info->start_bit); ++j)
+ *p_amr_bits++ = (pj_uint8_t)
+ ((*r >> (7-info->start_bit-j)) & 1);
+ ++r;
+ }
+ for(; j < framelenbit_tbl[info->frame_type]; j+=8, ++r) {
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 7) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 6) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 5) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 4) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 3) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 2) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r >> 1) & 1);
+ *p_amr_bits++ = (pj_uint8_t)((*r ) & 1);
+ }
+
+ if (info->frame_type < SID_FT) {
+
+ /* Speech */
+ if (w_bitptr == 0) *w = 0;
+
+ if (setting->reorder) {
+ const pj_int16_t *order_map;
+
+ /* Put bits in the packet, sensitivity descending ordered */
+ order_map = order_maps[info->frame_type];
+ for(j = 0; j < framelenbit_tbl[info->frame_type]; ++j) {
+ if (amr_bits[order_map[j]])
+ *w |= (1 << (7-w_bitptr));
+
+ if (++w_bitptr == 8) {
+ w_bitptr = 0;
+ ++w;
+ *w = 0;
+ }
+ }
+ } else {
+ for(j = 0; j < framelenbit_tbl[info->frame_type]; ++j) {
+ if (amr_bits[j])
+ *w |= (1 << (7-w_bitptr));
+
+ if (++w_bitptr == 8) {
+ w_bitptr = 0;
+ ++w;
+ *w = 0;
+ }
+ }
+ }
+
+ } else if (info->frame_type == SID_FT) {
+
+ /* SID */
+ pj_uint8_t STI = 0;
+
+ amr_bits[35] = (pj_uint8_t)(STI & 1);
+
+ if (setting->amr_nb) {
+ amr_bits[36] = (pj_uint8_t)((info->mode >> 2) & 1);
+ amr_bits[37] = (pj_uint8_t)((info->mode >> 1) & 1);
+ amr_bits[38] = (pj_uint8_t)((info->mode) & 1);
+ } else {
+ amr_bits[36] = (pj_uint8_t)((info->mode >> 3) & 1);
+ amr_bits[37] = (pj_uint8_t)((info->mode >> 2) & 1);
+ amr_bits[38] = (pj_uint8_t)((info->mode >> 1) & 1);
+ amr_bits[39] = (pj_uint8_t)((info->mode) & 1);
+ }
+
+ if (w_bitptr == 0) *w = 0;
+ for(j = 0; j < framelenbit_tbl[info->frame_type]; ++j) {
+ if (amr_bits[j])
+ *w |= (1 << (7-w_bitptr));
+
+ if (++w_bitptr == 8) {
+ w_bitptr = 0;
+ ++w;
+ *w = 0;
+ }
+ }
+ }
+
+ if (setting->octet_aligned) {
+ ++w;
+ w_bitptr = 0;
+ }
+ }
+
+ *pkt_size = w - (pj_uint8_t*)pkt;
+ if (w_bitptr)
+ *pkt_size += 1;
+
+ return PJ_SUCCESS;
+}
+
+
+/**
+ * Parse AMR payload into frames.
+ *
+ * @param pkt Payload.
+ * @param pkt_size Payload size.
+ * @param ts Base timestamp.
+ * @param setting Settings, see @pjmedia_codec_amr_pack_setting.
+ * @param frames Frames parsed.
+ * @param nframes Number of frames parsed.
+ * @param cmr Change Mode Request message for local encoder.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_codec_amr_parse(
+ void *pkt,
+ pj_size_t pkt_size,
+ const pj_timestamp *ts,
+ const pjmedia_codec_amr_pack_setting* setting,
+ pjmedia_frame frames[],
+ unsigned *nframes,
+ pj_uint8_t *cmr)
+{
+ unsigned cnt = 0;
+ pj_timestamp ts_ = *ts;
+
+ /* Read cursor */
+ pj_uint8_t r_bitptr = 0;
+ pj_uint8_t *r = (pj_uint8_t*)pkt;
+
+ /* env vars for AMR or AMRWB */
+ pj_uint8_t SID_FT;
+ const pj_uint8_t *framelen_tbl;
+ const pj_uint16_t *framelenbit_tbl;
+ const pj_int16_t* const *order_maps;
+
+ /* frame info */
+ pjmedia_codec_amr_bit_info *info;
+
+ if (setting->amr_nb) {
+ SID_FT = 8;
+ framelen_tbl = pjmedia_codec_amrnb_framelen;
+ framelenbit_tbl = pjmedia_codec_amrnb_framelenbits;
+ order_maps = pjmedia_codec_amrnb_ordermaps;
+ } else {
+ SID_FT = 9;
+ framelen_tbl = pjmedia_codec_amrwb_framelen;
+ framelenbit_tbl = pjmedia_codec_amrwb_framelenbits;
+ order_maps = pjmedia_codec_amrwb_ordermaps;
+ }
+
+ PJ_UNUSED_ARG(pkt_size);
+
+ /* Code Mode Request, 4 bits */
+ *cmr = (pj_uint8_t)((*r >> 4) & 0x0F);
+ r_bitptr = 4;
+ if (setting->octet_aligned) {
+ ++r;
+ r_bitptr = 0;
+ }
+
+ /* Table Of Contents, 6 bits each */
+ for (;;) {
+ pj_uint8_t TOC = 0;
+ pj_uint8_t F, FT, Q;
+
+ if (r_bitptr == 0) {
+ TOC = (pj_uint8_t)(*r >> 2);
+ r_bitptr = 6;
+ } else if (r_bitptr == 2) {
+ TOC = (pj_uint8_t)(*r++ & 0x3F);
+ r_bitptr = 0;
+ } else if (r_bitptr == 4) {
+ TOC = (pj_uint8_t)((*r++ & 0x0f) << 2);
+ TOC |= *r >> 6;
+ r_bitptr = 2;
+ } else if (r_bitptr == 6) {
+ TOC = (pj_uint8_t)((*r++ & 0x03) << 4);
+ TOC |= *r >> 4;
+ r_bitptr = 4;
+ }
+
+ F = (pj_uint8_t)(TOC >> 5);
+ FT = (pj_uint8_t)((TOC >> 1) & 0x0F);
+ Q = (pj_uint8_t)(TOC & 1);
+
+ if (FT > SID_FT && FT < 14) {
+ pj_assert(!"Invalid AMR frametype, stream may be corrupted!");
+ break;
+ }
+
+ if (setting->octet_aligned) {
+ ++r;
+ r_bitptr = 0;
+ }
+
+ /* Set frame attributes */
+ info = (pjmedia_codec_amr_bit_info*) &frames[cnt].bit_info;
+ info->frame_type = FT;
+ info->mode = (pj_int8_t)((FT < SID_FT)? FT : -1);
+ info->good_quality = (pj_uint8_t)(Q == 1);
+ info->start_bit = 0;
+ frames[cnt].timestamp = ts_;
+ frames[cnt].type = PJMEDIA_FRAME_TYPE_AUDIO;
+
+ /* AMR frame length is 20ms */
+ ts_.u64 += setting->amr_nb? 160 : 320;
+
+ if (++cnt == *nframes || !F)
+ break;
+ }
+ *nframes = cnt;
+
+ cnt = 0;
+
+ /* Speech frames */
+ while (cnt < *nframes) {
+ pj_uint8_t FT;
+
+ info = (pjmedia_codec_amr_bit_info*) &frames[cnt].bit_info;
+ FT = info->frame_type;
+
+ frames[cnt].buf = r;
+ info->start_bit = r_bitptr;
+
+ if (setting->octet_aligned) {
+ r += framelen_tbl[FT];
+ frames[cnt].size = framelen_tbl[FT];
+ } else {
+ if (FT == 14 || FT == 15) {
+ /* NO DATA */
+ frames[cnt].size = 0;
+ } else {
+ unsigned adv_bit;
+
+ adv_bit = framelenbit_tbl[FT] + r_bitptr;
+ r += adv_bit >> 3;
+ r_bitptr = (pj_uint8_t)(adv_bit % 8);
+
+ frames[cnt].size = adv_bit >> 3;
+ if (r_bitptr)
+ ++frames[cnt].size;
+ }
+ }
+ ++cnt;
+ }
+
+ return PJ_SUCCESS;
+}
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_CODECS_AMR_HELPER_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/config.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/config.h new file mode 100644 index 0000000..5a22a7d --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/config.h @@ -0,0 +1,316 @@ +/* $Id: config.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODEC_CONFIG_H__
+#define __PJMEDIA_CODEC_CONFIG_H__
+
+/**
+ * @file config.h
+ * @brief PJMEDIA-CODEC compile time settings
+ */
+
+/**
+ * @defgroup pjmedia_codec_config PJMEDIA-CODEC Compile Time Settings
+ * @ingroup PJMEDIA_CODEC
+ * @brief Various compile time settings such as to enable/disable codecs
+ * @{
+ */
+
+#include <pjmedia/types.h>
+
+
+/*
+ * Include config_auto.h if autoconf is used (PJ_AUTOCONF is set)
+ */
+#if defined(PJ_AUTOCONF)
+# include <pjmedia-codec/config_auto.h>
+#endif
+
+/**
+ * Unless specified otherwise, L16 codec is included by default.
+ */
+#ifndef PJMEDIA_HAS_L16_CODEC
+# define PJMEDIA_HAS_L16_CODEC 1
+#endif
+
+
+/**
+ * Unless specified otherwise, GSM codec is included by default.
+ */
+#ifndef PJMEDIA_HAS_GSM_CODEC
+# define PJMEDIA_HAS_GSM_CODEC 1
+#endif
+
+
+/**
+ * Unless specified otherwise, Speex codec is included by default.
+ */
+#ifndef PJMEDIA_HAS_SPEEX_CODEC
+# define PJMEDIA_HAS_SPEEX_CODEC 1
+#endif
+
+/**
+ * Speex codec default complexity setting.
+ */
+#ifndef PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY
+# define PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY 2
+#endif
+
+/**
+ * Speex codec default quality setting. Please note that pjsua-lib may override
+ * this setting via its codec quality setting (i.e PJSUA_DEFAULT_CODEC_QUALITY).
+ */
+#ifndef PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY
+# define PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY 8
+#endif
+
+
+/**
+ * Unless specified otherwise, iLBC codec is included by default.
+ */
+#ifndef PJMEDIA_HAS_ILBC_CODEC
+# define PJMEDIA_HAS_ILBC_CODEC 1
+#endif
+
+
+/**
+ * Unless specified otherwise, G.722 codec is included by default.
+ */
+#ifndef PJMEDIA_HAS_G722_CODEC
+# define PJMEDIA_HAS_G722_CODEC 1
+#endif
+
+
+/**
+ * Enable the features provided by Intel IPP libraries, for example
+ * codecs such as G.729, G.723.1, G.726, G.728, G.722.1, and AMR.
+ *
+ * By default this is disabled. Please follow the instructions in
+ * http://trac.pjsip.org/repos/wiki/Intel_IPP_Codecs on how to setup
+ * Intel IPP with PJMEDIA.
+ */
+#ifndef PJMEDIA_HAS_INTEL_IPP
+# define PJMEDIA_HAS_INTEL_IPP 0
+#endif
+
+
+/**
+ * Visual Studio only: when this option is set, the Intel IPP libraries
+ * will be automatically linked to application using pragma(comment)
+ * constructs. This is convenient, however it will only link with
+ * the stub libraries and the Intel IPP DLL's will be required when
+ * distributing the application.
+ *
+ * If application wants to link with the different types of the Intel IPP
+ * libraries (for example, the static libraries), it must set this option
+ * to zero and specify the Intel IPP libraries in the application's input
+ * library specification manually.
+ *
+ * Default 1.
+ */
+#ifndef PJMEDIA_AUTO_LINK_IPP_LIBS
+# define PJMEDIA_AUTO_LINK_IPP_LIBS 1
+#endif
+
+
+/**
+ * Enable Intel IPP AMR codec. This also needs to be enabled when AMR WB
+ * codec is enabled. This option is only used when PJMEDIA_HAS_INTEL_IPP
+ * is enabled.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_AMR
+# define PJMEDIA_HAS_INTEL_IPP_CODEC_AMR 1
+#endif
+
+
+/**
+ * Enable Intel IPP AMR wideband codec. The PJMEDIA_HAS_INTEL_IPP_CODEC_AMR
+ * option must also be enabled to use this codec. This option is only used
+ * when PJMEDIA_HAS_INTEL_IPP is enabled.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_AMRWB
+# define PJMEDIA_HAS_INTEL_IPP_CODEC_AMRWB 1
+#endif
+
+
+/**
+ * Enable Intel IPP G.729 codec. This option is only used when
+ * PJMEDIA_HAS_INTEL_IPP is enabled.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_G729
+# define PJMEDIA_HAS_INTEL_IPP_CODEC_G729 1
+#endif
+
+
+/**
+ * Enable Intel IPP G.723.1 codec. This option is only used when
+ * PJMEDIA_HAS_INTEL_IPP is enabled.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_G723_1
+# define PJMEDIA_HAS_INTEL_IPP_CODEC_G723_1 1
+#endif
+
+
+/**
+ * Enable Intel IPP G.726 codec. This option is only used when
+ * PJMEDIA_HAS_INTEL_IPP is enabled.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_G726
+# define PJMEDIA_HAS_INTEL_IPP_CODEC_G726 1
+#endif
+
+
+/**
+ * Enable Intel IPP G.728 codec. This option is only used when
+ * PJMEDIA_HAS_INTEL_IPP is enabled.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_G728
+# define PJMEDIA_HAS_INTEL_IPP_CODEC_G728 1
+#endif
+
+
+/**
+ * Enable Intel IPP G.722.1 codec. This option is only used when
+ * PJMEDIA_HAS_INTEL_IPP is enabled.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1
+# define PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 1
+#endif
+
+/**
+ * Enable Passthrough codecs.
+ *
+ * Default: 0
+ */
+#ifndef PJMEDIA_HAS_PASSTHROUGH_CODECS
+# define PJMEDIA_HAS_PASSTHROUGH_CODECS 0
+#endif
+
+/**
+ * Enable AMR passthrough codec.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR
+# define PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR 1
+#endif
+
+/**
+ * Enable G.729 passthrough codec.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_HAS_PASSTHROUGH_CODEC_G729
+# define PJMEDIA_HAS_PASSTHROUGH_CODEC_G729 1
+#endif
+
+/**
+ * Enable iLBC passthrough codec.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC
+# define PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC 1
+#endif
+
+/**
+ * Enable PCMU passthrough codec.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU
+# define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU 1
+#endif
+
+/**
+ * Enable PCMA passthrough codec.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA
+# define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA 1
+#endif
+
+/* If passthrough and PCMU/PCMA are enabled, disable the software
+ * G.711 codec
+ */
+#if PJMEDIA_HAS_PASSTHROUGH_CODECS && \
+ (PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU || PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA)
+# undef PJMEDIA_HAS_G711_CODEC
+# define PJMEDIA_HAS_G711_CODEC 0
+#endif
+
+
+/**
+ * G.722.1 codec is disabled by default.
+ */
+#ifndef PJMEDIA_HAS_G7221_CODEC
+# define PJMEDIA_HAS_G7221_CODEC 0
+#endif
+
+/**
+ * Default G.722.1 codec encoder and decoder level adjustment.
+ * If the value is non-zero, then PCM input samples to the encoder will
+ * be shifted right by this value, and similarly PCM output samples from
+ * the decoder will be shifted left by this value.
+ *
+ * This can be changed at run-time after initialization by calling
+ * #pjmedia_codec_g7221_set_pcm_shift().
+ */
+#ifndef PJMEDIA_G7221_DEFAULT_PCM_SHIFT
+# define PJMEDIA_G7221_DEFAULT_PCM_SHIFT 1
+#endif
+
+
+/**
+ * Enabling both G.722.1 codec implementations, internal PJMEDIA and IPP,
+ * may cause problem in SDP, i.e: payload types duplications. So, let's
+ * just trap such case here at compile time.
+ *
+ * Application can control which implementation to be used by manipulating
+ * PJMEDIA_HAS_G7221_CODEC and PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 in
+ * config_site.h.
+ */
+#if (PJMEDIA_HAS_G7221_CODEC != 0) && (PJMEDIA_HAS_INTEL_IPP != 0) && \
+ (PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 != 0)
+# error Only one G.722.1 implementation can be enabled at the same time. \
+ Please use PJMEDIA_HAS_G7221_CODEC and \
+ PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 in your config_site.h \
+ to control which implementation to be used.
+#endif
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_CODEC_CONFIG_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/config_auto.h.in b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/config_auto.h.in new file mode 100644 index 0000000..db6cb80 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/config_auto.h.in @@ -0,0 +1,71 @@ +/* $Id: config_auto.h.in 2601 2009-04-15 14:45:41Z nanang $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODEC_CONFIG_AUTO_H_
+#define __PJMEDIA_CODEC_CONFIG_AUTO_H_
+
+/**
+ * @file config_auto.h
+ * @brief PJMEDIA-CODEC configuration as set by autoconf script
+ */
+
+/*
+ * Note:
+ * The configuration in config_site.h overrides any other settings,
+ * including the setting as detected by autoconf.
+ */
+
+/* L16 codec */
+#ifndef PJMEDIA_HAS_L16_CODEC
+#undef PJMEDIA_HAS_L16_CODEC
+#endif
+
+
+/* GSM codec */
+#ifndef PJMEDIA_HAS_GSM_CODEC
+#undef PJMEDIA_HAS_GSM_CODEC
+#endif
+
+
+/* Speex codec */
+#ifndef PJMEDIA_HAS_SPEEX_CODEC
+#undef PJMEDIA_HAS_SPEEX_CODEC
+#endif
+
+
+/* iLBC codec */
+#ifndef PJMEDIA_HAS_ILBC_CODEC
+#undef PJMEDIA_HAS_ILBC_CODEC
+#endif
+
+
+/* G722 codec */
+#ifndef PJMEDIA_HAS_G722_CODEC
+#undef PJMEDIA_HAS_G722_CODEC
+#endif
+
+/* G7221 codec */
+#ifndef PJMEDIA_HAS_G7221_CODEC
+#undef PJMEDIA_HAS_G7221_CODEC
+#endif
+
+
+#endif /* __PJMEDIA_CODEC_CONFIG_AUTO_H_ */
+
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/g722.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/g722.h new file mode 100644 index 0000000..42f0311 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/g722.h @@ -0,0 +1,74 @@ +/* $Id: g722.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODEC_G722_H__
+#define __PJMEDIA_CODEC_G722_H__
+
+/**
+ * @file pjmedia-codec/g722.h
+ * @brief G.722 codec.
+ */
+
+#include <pjmedia-codec/types.h>
+
+/**
+ * @defgroup PJMED_G722 G.722 Codec
+ * @ingroup PJMEDIA_CODEC_CODECS
+ * @brief Implementation of G.722 Codec
+ * @{
+ *
+ * This section describes functions to register and register G.722 codec
+ * factory to the codec manager. After the codec factory has been registered,
+ * application can use @ref PJMEDIA_CODEC API to manipulate the codec.
+ *
+ * The G.722 codec implementation is provided as part of pjmedia-codec
+ * library, and does not depend on external G.722 codec implementation.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Initialize and register G.722 codec factory to pjmedia endpoint.
+ *
+ * @param endpt The pjmedia endpoint.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_g722_init(pjmedia_endpt *endpt);
+
+
+/**
+ * Unregister G.722 codec factory from pjmedia endpoint and cleanup
+ * resources allocated by the factory.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_g722_deinit(void);
+
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_CODEC_G722_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/g7221.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/g7221.h new file mode 100644 index 0000000..0384563 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/g7221.h @@ -0,0 +1,128 @@ +/* $Id: g7221.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODECS_G7221_H__
+#define __PJMEDIA_CODECS_G7221_H__
+
+/**
+ * @file pjmedia-codec/g7221.h
+ * @brief G722.1 codec.
+ */
+
+#include <pjmedia-codec/types.h>
+
+/**
+ * @defgroup PJMED_G7221_CODEC G722.1 Codec
+ * @ingroup PJMEDIA_CODEC_CODECS
+ * @brief Implementation of G722.1 codec
+ * @{
+ *
+ * <b>G722.1 licensed from Polycom®</b>
+ * <b>G722.1 Annex C licensed from Polycom®</b>
+ *
+ * This section describes functions to register and register G722.1 codec
+ * factory to the codec manager. After the codec factory has been registered,
+ * application can use @ref PJMEDIA_CODEC API to manipulate the codec.
+ *
+ * PJMEDIA G722.1 codec implementation is based on ITU-T Recommendation
+ * G.722.1 (05/2005) C fixed point implementation including its Annex C.
+ *
+ * G722.1 is a low complexity codec that supports for 7kHz and 14kHz bandwidth
+ * audio signals working at bitrates ranging from 16kbps to 48kbps. It may be
+ * used with speech or music inputs.
+ *
+ * The codec implementation supports for standard and non-standard bitrates.
+ * By default, the standard bitrates are enabled upon initialization, i.e.:
+ * - 24kbps and 32kbps for audio bandwidth 7 kHz (16kHz sampling rate),
+ * - 24kbps, 32kbps, and 48kbps for audio bandwidth 14 kHz (32kHz sampling
+ * rate).
+ * The usage of non-standard bitrates must follow this requirements:
+ * - for sampling rate 16kHz: 16000 to 32000 bps, it must be a multiple of 400
+ * - for sampling rate 32kHz: 24000 to 48000 bps, it must be a multiple of 400
+ * Note that currently it is only up to two non-standard modes can be enabled
+ * at one time.
+ */
+
+PJ_BEGIN_DECL
+
+/**
+ * Initialize and register G722.1 codec factory to pjmedia endpoint.
+ *
+ * @param endpt The pjmedia endpoint.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_g7221_init( pjmedia_endpt *endpt );
+
+
+/**
+ * Enable and disable G722.1 mode. By default, the standard modes are
+ * enabled upon initialization, i.e.:
+ * - sampling rate 16kHz, bitrate 24kbps and 32kbps.
+ * - sampling rate 32kHz, bitrate 24kbps, 32kbps, and 48kbps.
+ * This function can also be used for enabling non-standard modes.
+ * Note that currently it is only up to two non-standard modes can be
+ * enabled at one time.
+ *
+ * @param sample_rate PCM sampling rate, in Hz, valid values are only
+ * 16000 and 32000.
+ * @param bitrate G722.1 bitrate, in bps, the valid values are
+ * standard and non-standard bitrates as described
+ * above.
+ * @param enabled PJ_TRUE for enabling specified mode.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_g7221_set_mode(unsigned sample_rate,
+ unsigned bitrate,
+ pj_bool_t enabled);
+
+/**
+ * Set the G.722.1 codec encoder and decoder level adjustment.
+ * If the value is non-zero, then PCM input samples to the encoder will
+ * be shifted right by this value, and similarly PCM output samples from
+ * the decoder will be shifted left by this value.
+ *
+ * Default value is PJMEDIA_G7221_DEFAULT_PCM_SHIFT.
+ *
+ * @param val The value
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_g7221_set_pcm_shift(int val);
+
+
+
+/**
+ * Unregister G722.1 codecs factory from pjmedia endpoint.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_g7221_deinit(void);
+
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_CODECS_G7221_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/gsm.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/gsm.h new file mode 100644 index 0000000..7555fd5 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/gsm.h @@ -0,0 +1,72 @@ +/* $Id: gsm.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODEC_GSM_H__
+#define __PJMEDIA_CODEC_GSM_H__
+
+/**
+ * @file pjmedia-codec/gsm.h
+ * @brief GSM 06.10 codec.
+ */
+
+#include <pjmedia-codec/types.h>
+
+/**
+ * @defgroup PJMED_GSM GSM 06.10 Codec
+ * @ingroup PJMEDIA_CODEC_CODECS
+ * @brief Implementation of GSM FR based on GSM 06.10 library
+ * @{
+ *
+ * This section describes functions to register and register GSM codec
+ * factory to the codec manager. After the codec factory has been registered,
+ * application can use @ref PJMEDIA_CODEC API to manipulate the codec.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Initialize and register GSM codec factory to pjmedia endpoint.
+ *
+ * @param endpt The pjmedia endpoint.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_gsm_init( pjmedia_endpt *endpt );
+
+
+
+/**
+ * Unregister GSM codec factory from pjmedia endpoint and deinitialize
+ * the GSM codec library.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_gsm_deinit(void);
+
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_CODEC_GSM_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/ilbc.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/ilbc.h new file mode 100644 index 0000000..b9ad150 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/ilbc.h @@ -0,0 +1,76 @@ +/* $Id: ilbc.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODEC_ILBC_H__
+#define __PJMEDIA_CODEC_ILBC_H__
+
+/**
+ * @file pjmedia-codec/ilbc.h
+ * @brief iLBC codec.
+ */
+
+#include <pjmedia-codec/types.h>
+
+/**
+ * @defgroup PJMED_ILBC iLBC Codec
+ * @ingroup PJMEDIA_CODEC_CODECS
+ * @brief Implementation of iLBC Codec
+ * @{
+ *
+ * This section describes functions to register and register iLBC codec
+ * factory to the codec manager. After the codec factory has been registered,
+ * application can use @ref PJMEDIA_CODEC API to manipulate the codec.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Initialize and register iLBC codec factory to pjmedia endpoint.
+ *
+ * @param endpt The pjmedia endpoint.
+ * @param mode Default decoder mode to be used. Valid values are
+ * 20 and 30 ms. Note that encoder mode follows the
+ * setting advertised in the remote's SDP.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_ilbc_init( pjmedia_endpt *endpt,
+ int mode );
+
+
+
+/**
+ * Unregister iLBC codec factory from pjmedia endpoint and deinitialize
+ * the iLBC codec library.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_ilbc_deinit(void);
+
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_CODEC_ILBC_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/ipp_codecs.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/ipp_codecs.h new file mode 100644 index 0000000..1936c88 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/ipp_codecs.h @@ -0,0 +1,73 @@ +/* $Id: ipp_codecs.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODECS_IPP_H__
+#define __PJMEDIA_CODECS_IPP_H__
+
+/**
+ * @file pjmedia-codec/ipp_codecs.h
+ * @brief IPP codecs wrapper.
+ */
+
+#include <pjmedia-codec/types.h>
+
+/**
+ * @defgroup PJMED_IPP_CODEC IPP Codecs
+ * @ingroup PJMEDIA_CODEC_CODECS
+ * @brief Implementation of IPP codecs
+ * @{
+ *
+ * This section describes functions to register and register IPP codec
+ * factory to the codec manager. After the codec factory has been registered,
+ * application can use @ref PJMEDIA_CODEC API to manipulate the codec.
+ * This codec factory contains various codecs, e.g: G.729, G.723.1, G.726,
+ * G.728, G.722.1, AMR.
+ */
+
+PJ_BEGIN_DECL
+
+/**
+ * Initialize and register IPP codecs factory to pjmedia endpoint.
+ *
+ * @param endpt The pjmedia endpoint.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_ipp_init( pjmedia_endpt *endpt );
+
+
+
+/**
+ * Unregister IPP codecs factory from pjmedia endpoint and deinitialize
+ * the IPP codecs library.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_ipp_deinit(void);
+
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_CODECS_IPP_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/l16.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/l16.h new file mode 100644 index 0000000..ce49270 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/l16.h @@ -0,0 +1,69 @@ +/* $Id: l16.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODEC_L16_H__
+#define __PJMEDIA_CODEC_L16_H__
+
+#include <pjmedia-codec/types.h>
+
+
+/**
+ * @defgroup PJMED_L16 L16 Codec Family
+ * @ingroup PJMEDIA_CODEC_CODECS
+ * @brief PCM/16bit/linear codecs
+ * @{
+ *
+ * This section describes functions to register and register L16 codec
+ * factory to the codec manager. After the codec factory has been registered,
+ * application can use @ref PJMEDIA_CODEC API to manipulate the codec.
+ *
+ * Note that the L16 codec factory registers several (about fourteen!)
+ * L16 codec types to codec manager (different combinations of clock
+ * rate and number of channels).
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Initialize and register L16 codec factory to pjmedia endpoint.
+ *
+ * @param endpt The pjmedia endpoint.
+ * @param options Must be zero for now.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_l16_init( pjmedia_endpt *endpt,
+ unsigned options);
+
+
+
+/**
+ * Unregister L16 codec factory from pjmedia endpoint.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_l16_deinit(void);
+
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_CODEC_L16_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/passthrough.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/passthrough.h new file mode 100644 index 0000000..ea8c046 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/passthrough.h @@ -0,0 +1,106 @@ +/* $Id: passthrough.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODECS_PASSTHROUGH_H__
+#define __PJMEDIA_CODECS_PASSTHROUGH_H__
+
+/**
+ * @file pjmedia-codec/passthrough.h
+ * @brief Passthrough codecs.
+ */
+
+#include <pjmedia-codec/types.h>
+
+/**
+ * @defgroup PJMED_PASSTHROUGH_CODEC Passthrough Codecs
+ * @ingroup PJMEDIA_CODEC_CODECS
+ * @brief Implementation of passthrough codecs
+ * @{
+ *
+ * This section describes functions to register and register passthrough
+ * codecs factory to the codec manager. After the codec factory has been
+ * registered, application can use @ref PJMEDIA_CODEC API to manipulate
+ * the codec. This codec factory contains various codecs, e.g: G.729, iLBC,
+ * AMR, and G.711.
+ *
+ * Passthrough codecs are codecs wrapper that does not perform encoding
+ * or decoding, it just pack and parse encoded audio data from/into RTP
+ * payload. This will accomodate pjmedia ports which work with encoded
+ * audio data, e.g: encoded audio files, sound device with capability
+ * of playing/recording encoded audio data.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Codec passthrough configuration settings.
+ */
+typedef struct pjmedia_codec_passthrough_setting
+{
+ unsigned fmt_cnt; /**< Number of encoding formats
+ to be enabled. */
+ pjmedia_format *fmts; /**< Encoding formats to be
+ enabled. */
+ unsigned ilbc_mode; /**< iLBC default mode. */
+} pjmedia_codec_passthrough_setting;
+
+
+/**
+ * Initialize and register passthrough codecs factory to pjmedia endpoint,
+ * all supported encoding formats will be enabled.
+ *
+ * @param endpt The pjmedia endpoint.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_passthrough_init( pjmedia_endpt *endpt );
+
+
+/**
+ * Initialize and register passthrough codecs factory to pjmedia endpoint
+ * with only specified encoding formats enabled.
+ *
+ * @param endpt The pjmedia endpoint.
+ * @param setting The settings, see @pjmedia_codec_passthrough_setting.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_passthrough_init2(
+ pjmedia_endpt *endpt,
+ const pjmedia_codec_passthrough_setting *setting);
+
+
+/**
+ * Unregister passthrough codecs factory from pjmedia endpoint.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_passthrough_deinit(void);
+
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_CODECS_PASSTHROUGH_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/speex.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/speex.h new file mode 100644 index 0000000..a08b8c1 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/speex.h @@ -0,0 +1,121 @@ +/* $Id: speex.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODEC_SPEEX_H__
+#define __PJMEDIA_CODEC_SPEEX_H__
+
+/**
+ * @file speex.h
+ * @brief Speex codec header.
+ */
+
+#include <pjmedia-codec/types.h>
+
+/**
+ * @defgroup PJMED_SPEEX Speex Codec Family
+ * @ingroup PJMEDIA_CODEC_CODECS
+ * @brief Implementation of Speex codecs (narrow/wide/ultrawide-band).
+ * @{
+ *
+ * This section describes functions to register and register speex codec
+ * factory to the codec manager. After the codec factory has been registered,
+ * application can use @ref PJMEDIA_CODEC API to manipulate the codec.
+ *
+ * By default, the speex codec factory registers three Speex codecs:
+ * "speex/8000" narrowband codec, "speex/16000" wideband codec, and
+ * "speex/32000" ultra-wideband codec. This behavior can be changed by
+ * specifying #pjmedia_speex_options flags during initialization.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Bitmask options to be passed during Speex codec factory initialization.
+ */
+enum pjmedia_speex_options
+{
+ PJMEDIA_SPEEX_NO_NB = 1, /**< Disable narrowband mode. */
+ PJMEDIA_SPEEX_NO_WB = 2, /**< Disable wideband mode. */
+ PJMEDIA_SPEEX_NO_UWB = 4, /**< Disable ultra-wideband mode. */
+};
+
+
+/**
+ * Initialize and register Speex codec factory to pjmedia endpoint.
+ *
+ * @param endpt The pjmedia endpoint.
+ * @param options Bitmask of pjmedia_speex_options (default=0).
+ * @param quality Specify encoding quality, or use -1 for default
+ * (@see PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY).
+ * @param complexity Specify encoding complexity , or use -1 for default
+ * (@see PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY).
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_speex_init( pjmedia_endpt *endpt,
+ unsigned options,
+ int quality,
+ int complexity );
+
+
+/**
+ * Initialize Speex codec factory using default settings and register to
+ * pjmedia endpoint.
+ *
+ * @param endpt The pjmedia endpoint.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_speex_init_default(pjmedia_endpt *endpt);
+
+
+/**
+ * Change the settings of Speex codec.
+ *
+ * @param clock_rate Clock rate of Speex mode to be set.
+ * @param quality Specify encoding quality, or use -1 for default
+ * (@see PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY).
+ * @param complexity Specify encoding complexity , or use -1 for default
+ * (@see PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY).
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_speex_set_param(unsigned clock_rate,
+ int quality,
+ int complexity);
+
+
+/**
+ * Unregister Speex codec factory from pjmedia endpoint and deinitialize
+ * the Speex codec library.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_speex_deinit(void);
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_CODEC_SPEEX_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/types.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/types.h new file mode 100644 index 0000000..04079ac --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia-codec/types.h @@ -0,0 +1,93 @@ +/* $Id: types.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODEC_TYPES_H__
+#define __PJMEDIA_CODEC_TYPES_H__
+
+/**
+ * @file types.h
+ * @brief PJMEDIA-CODEC types and constants
+ */
+
+#include <pjmedia-codec/config.h>
+
+/**
+ * @defgroup pjmedia_codec_types PJMEDIA-CODEC Types and Constants
+ * @ingroup PJMEDIA_CODEC
+ * @brief Constants used by PJMEDIA-CODEC
+ * @{
+ */
+
+
+
+/**
+ * These are the dynamic payload types that are used by codecs in
+ * this library. Also see the header file <pjmedia/codec.h> for list
+ * of static payload types.
+ */
+enum
+{
+ /* PJMEDIA_RTP_PT_TELEPHONE_EVENTS is declared in
+ * <pjmedia/config.h>
+ */
+#if PJMEDIA_RTP_PT_TELEPHONE_EVENTS
+ PJMEDIA_RTP_PT_START = PJMEDIA_RTP_PT_TELEPHONE_EVENTS,
+#else
+ PJMEDIA_RTP_PT_START = 102,
+#endif
+
+ PJMEDIA_RTP_PT_SPEEX_NB, /**< Speex narrowband/8KHz */
+ PJMEDIA_RTP_PT_SPEEX_WB, /**< Speex wideband/16KHz */
+ PJMEDIA_RTP_PT_SPEEX_UWB, /**< Speex 32KHz */
+ PJMEDIA_RTP_PT_L16_8KHZ_MONO, /**< L16 @ 8KHz, mono */
+ PJMEDIA_RTP_PT_L16_8KHZ_STEREO, /**< L16 @ 8KHz, stereo */
+ //PJMEDIA_RTP_PT_L16_11KHZ_MONO, /**< L16 @ 11KHz, mono */
+ //PJMEDIA_RTP_PT_L16_11KHZ_STEREO, /**< L16 @ 11KHz, stereo */
+ PJMEDIA_RTP_PT_L16_16KHZ_MONO, /**< L16 @ 16KHz, mono */
+ PJMEDIA_RTP_PT_L16_16KHZ_STEREO, /**< L16 @ 16KHz, stereo */
+ //PJMEDIA_RTP_PT_L16_22KHZ_MONO, /**< L16 @ 22KHz, mono */
+ //PJMEDIA_RTP_PT_L16_22KHZ_STEREO, /**< L16 @ 22KHz, stereo */
+ PJMEDIA_RTP_PT_L16_32KHZ_MONO, /**< L16 @ 32KHz, mono */
+ PJMEDIA_RTP_PT_L16_32KHZ_STEREO, /**< L16 @ 32KHz, stereo */
+ PJMEDIA_RTP_PT_L16_48KHZ_MONO, /**< L16 @ 48KHz, mono */
+ PJMEDIA_RTP_PT_L16_48KHZ_STEREO, /**< L16 @ 48KHz, stereo */
+ PJMEDIA_RTP_PT_ILBC, /**< iLBC (13.3/15.2Kbps) */
+ PJMEDIA_RTP_PT_AMR, /**< AMR (4.75 - 12.2Kbps) */
+ PJMEDIA_RTP_PT_AMRWB, /**< AMRWB (6.6 - 23.85Kbps)*/
+ PJMEDIA_RTP_PT_AMRWBE, /**< AMRWBE */
+ PJMEDIA_RTP_PT_G726_16, /**< G726 @ 16Kbps */
+ PJMEDIA_RTP_PT_G726_24, /**< G726 @ 24Kbps */
+ /* PJMEDIA_RTP_PT_G726_32,*/ /**< G726 @ 32Kbps, static? */
+ PJMEDIA_RTP_PT_G726_40, /**< G726 @ 40Kbps */
+ PJMEDIA_RTP_PT_G722_1_16, /**< G722.1 (16Kbps) */
+ PJMEDIA_RTP_PT_G722_1_24, /**< G722.1 (24Kbps) */
+ PJMEDIA_RTP_PT_G722_1_32, /**< G722.1 (32Kbps) */
+ PJMEDIA_RTP_PT_G7221C_24, /**< G722.1 Annex C (24Kbps)*/
+ PJMEDIA_RTP_PT_G7221C_32, /**< G722.1 Annex C (32Kbps)*/
+ PJMEDIA_RTP_PT_G7221C_48, /**< G722.1 Annex C (48Kbps)*/
+ PJMEDIA_RTP_PT_G7221_RSV1, /**< G722.1 reserve */
+ PJMEDIA_RTP_PT_G7221_RSV2, /**< G722.1 reserve */
+};
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_CODEC_TYPES_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia.h new file mode 100644 index 0000000..09f2a46 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia.h @@ -0,0 +1,73 @@ +/* $Id: pjmedia.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_H__
+#define __PJMEDIA_H__
+
+/**
+ * @file pjmedia.h
+ * @brief PJMEDIA main header file.
+ */
+
+#include <pjmedia/types.h>
+#include <pjmedia/alaw_ulaw.h>
+#include <pjmedia/bidirectional.h>
+#include <pjmedia/circbuf.h>
+#include <pjmedia/clock.h>
+#include <pjmedia/codec.h>
+#include <pjmedia/conference.h>
+#include <pjmedia/delaybuf.h>
+#include <pjmedia/echo.h>
+#include <pjmedia/echo_port.h>
+#include <pjmedia/errno.h>
+#include <pjmedia/endpoint.h>
+#include <pjmedia/g711.h>
+#include <pjmedia/jbuf.h>
+#include <pjmedia/master_port.h>
+#include <pjmedia/mem_port.h>
+#include <pjmedia/null_port.h>
+#include <pjmedia/plc.h>
+#include <pjmedia/port.h>
+#include <pjmedia/resample.h>
+#include <pjmedia/rtcp.h>
+#include <pjmedia/rtcp_xr.h>
+#include <pjmedia/rtp.h>
+#include <pjmedia/sdp.h>
+#include <pjmedia/sdp_neg.h>
+#include <pjmedia/session.h>
+#include <pjmedia/silencedet.h>
+#include <pjmedia/sound.h>
+#include <pjmedia/sound_port.h>
+#include <pjmedia/splitcomb.h>
+#include <pjmedia/stereo.h>
+#include <pjmedia/stream.h>
+#include <pjmedia/tonegen.h>
+#include <pjmedia/transport.h>
+#include <pjmedia/transport_adapter_sample.h>
+#include <pjmedia/transport_ice.h>
+#include <pjmedia/transport_loop.h>
+#include <pjmedia/transport_srtp.h>
+#include <pjmedia/transport_udp.h>
+#include <pjmedia/wav_playlist.h>
+#include <pjmedia/wav_port.h>
+#include <pjmedia/wave.h>
+#include <pjmedia/wsola.h>
+
+#endif /* __PJMEDIA_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/alaw_ulaw.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/alaw_ulaw.h new file mode 100644 index 0000000..015722e --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/alaw_ulaw.h @@ -0,0 +1,213 @@ +/* $Id: alaw_ulaw.h 2506 2009-03-12 18:11:37Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_ALAW_ULAW_H__
+#define __PJMEDIA_ALAW_ULAW_H__
+
+#include <pjmedia/types.h>
+
+PJ_BEGIN_DECL
+
+#if defined(PJMEDIA_HAS_ALAW_ULAW_TABLE) && PJMEDIA_HAS_ALAW_ULAW_TABLE!=0
+
+extern const pj_uint8_t pjmedia_linear2ulaw_tab[16384];
+extern const pj_uint8_t pjmedia_linear2alaw_tab[16384];
+extern const pj_int16_t pjmedia_ulaw2linear_tab[256];
+extern const pj_int16_t pjmedia_alaw2linear_tab[256];
+
+
+/**
+ * Convert 16-bit linear PCM value to 8-bit A-Law.
+ *
+ * @param pcm_val 16-bit linear PCM value.
+ * @return 8-bit A-Law value.
+ */
+#define pjmedia_linear2alaw(pcm_val) \
+ pjmedia_linear2alaw_tab[(((pj_int16_t)pcm_val) >> 2) & 0x3fff]
+
+/**
+ * Convert 8-bit A-Law value to 16-bit linear PCM value.
+ *
+ * @param chara_val 8-bit A-Law value.
+ * @return 16-bit linear PCM value.
+ */
+#define pjmedia_alaw2linear(chara_val) \
+ pjmedia_alaw2linear_tab[chara_val]
+
+/**
+ * Convert 16-bit linear PCM value to 8-bit U-Law.
+ *
+ * @param pcm_val 16-bit linear PCM value.
+ * @return U-bit A-Law value.
+ */
+#define pjmedia_linear2ulaw(pcm_val) \
+ pjmedia_linear2ulaw_tab[(((pj_int16_t)pcm_val) >> 2) & 0x3fff]
+
+/**
+ * Convert 8-bit U-Law value to 16-bit linear PCM value.
+ *
+ * @param u_val 8-bit U-Law value.
+ * @return 16-bit linear PCM value.
+ */
+#define pjmedia_ulaw2linear(u_val) \
+ pjmedia_ulaw2linear_tab[u_val]
+
+/**
+ * Convert 8-bit A-Law value to 8-bit U-Law value.
+ *
+ * @param aval 8-bit A-Law value.
+ * @return 8-bit U-Law value.
+ */
+#define pjmedia_alaw2ulaw(aval) \
+ pjmedia_linear2ulaw(pjmedia_alaw2linear(aval))
+
+/**
+ * Convert 8-bit U-Law value to 8-bit A-Law value.
+ *
+ * @param uval 8-bit U-Law value.
+ * @return 8-bit A-Law value.
+ */
+#define pjmedia_ulaw2alaw(uval) \
+ pjmedia_linear2alaw(pjmedia_ulaw2linear(uval))
+
+
+#else
+
+/**
+ * Convert 16-bit linear PCM value to 8-bit A-Law.
+ *
+ * @param pcm_val 16-bit linear PCM value.
+ * @return 8-bit A-Law value.
+ */
+PJ_DECL(pj_uint8_t) pjmedia_linear2alaw(int pcm_val);
+
+/**
+ * Convert 8-bit A-Law value to 16-bit linear PCM value.
+ *
+ * @param chara_val 8-bit A-Law value.
+ * @return 16-bit linear PCM value.
+ */
+PJ_DECL(int) pjmedia_alaw2linear(unsigned chara_val);
+
+/**
+ * Convert 16-bit linear PCM value to 8-bit U-Law.
+ *
+ * @param pcm_val 16-bit linear PCM value.
+ * @return U-bit A-Law value.
+ */
+PJ_DECL(unsigned char) pjmedia_linear2ulaw(int pcm_val);
+
+/**
+ * Convert 8-bit U-Law value to 16-bit linear PCM value.
+ *
+ * @param u_val 8-bit U-Law value.
+ * @return 16-bit linear PCM value.
+ */
+PJ_DECL(int) pjmedia_ulaw2linear(unsigned char u_val);
+
+/**
+ * Convert 8-bit A-Law value to 8-bit U-Law value.
+ *
+ * @param aval 8-bit A-Law value.
+ * @return 8-bit U-Law value.
+ */
+PJ_DECL(unsigned char) pjmedia_alaw2ulaw(unsigned char aval);
+
+/**
+ * Convert 8-bit U-Law value to 8-bit A-Law value.
+ *
+ * @param uval 8-bit U-Law value.
+ * @return 8-bit A-Law value.
+ */
+PJ_DECL(unsigned char) pjmedia_ulaw2alaw(unsigned char uval);
+
+#endif
+
+/**
+ * Encode 16-bit linear PCM data to 8-bit U-Law data.
+ *
+ * @param dst Destination buffer for 8-bit U-Law data.
+ * @param src Source, 16-bit linear PCM data.
+ * @param count Number of samples.
+ */
+PJ_INLINE(void) pjmedia_ulaw_encode(pj_uint8_t *dst, const pj_int16_t *src,
+ pj_size_t count)
+{
+ const pj_int16_t *end = src + count;
+
+ while (src < end) {
+ *dst++ = pjmedia_linear2ulaw(*src++);
+ }
+}
+
+/**
+ * Encode 16-bit linear PCM data to 8-bit A-Law data.
+ *
+ * @param dst Destination buffer for 8-bit A-Law data.
+ * @param src Source, 16-bit linear PCM data.
+ * @param count Number of samples.
+ */
+PJ_INLINE(void) pjmedia_alaw_encode(pj_uint8_t *dst, const pj_int16_t *src,
+ pj_size_t count)
+{
+ const pj_int16_t *end = src + count;
+
+ while (src < end) {
+ *dst++ = pjmedia_linear2alaw(*src++);
+ }
+}
+
+/**
+ * Decode 8-bit U-Law data to 16-bit linear PCM data.
+ *
+ * @param dst Destination buffer for 16-bit PCM data.
+ * @param src Source, 8-bit U-Law data.
+ * @param len Encoded frame/source length in bytes.
+ */
+PJ_INLINE(void) pjmedia_ulaw_decode(pj_int16_t *dst, const pj_uint8_t *src,
+ pj_size_t len)
+{
+ const pj_uint8_t *end = src + len;
+
+ while (src < end) {
+ *dst++ = pjmedia_ulaw2linear(*src++);
+ }
+}
+
+/**
+ * Decode 8-bit A-Law data to 16-bit linear PCM data.
+ *
+ * @param dst Destination buffer for 16-bit PCM data.
+ * @param src Source, 8-bit A-Law data.
+ * @param len Encoded frame/source length in bytes.
+ */
+PJ_INLINE(void) pjmedia_alaw_decode(pj_int16_t *dst, const pj_uint8_t *src,
+ pj_size_t len)
+{
+ const pj_uint8_t *end = src + len;
+
+ while (src < end) {
+ *dst++ = pjmedia_alaw2linear(*src++);
+ }
+}
+
+PJ_END_DECL
+
+#endif /* __PJMEDIA_ALAW_ULAW_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/bidirectional.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/bidirectional.h new file mode 100644 index 0000000..a374540 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/bidirectional.h @@ -0,0 +1,67 @@ +/* $Id: bidirectional.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_BIDIRECTIONAL_H__
+#define __PJMEDIA_BIDIRECTIONAL_H__
+
+/**
+ * @file bidirectional.h
+ * @brief Bidirectional media port.
+ */
+#include <pjmedia/port.h>
+
+
+/**
+ * @defgroup PJMEDIA_BIDIRECTIONAL_PORT Bidirectional Port
+ * @ingroup PJMEDIA_PORT
+ * @brief A bidirectional port combines two unidirectional ports into one
+ * bidirectional port
+ * @{
+ */
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Create bidirectional port from two unidirectional ports
+ *
+ * @param pool Pool to allocate memory.
+ * @param get_port Port where get_frame() will be directed to.
+ * @param put_port Port where put_frame() will be directed to.
+ * @param p_port Pointer to receive the port instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_bidirectional_port_create(pj_pool_t *pool,
+ pjmedia_port *get_port,
+ pjmedia_port *put_port,
+ pjmedia_port **p_port );
+
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_BIDIRECTIONAL_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/circbuf.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/circbuf.h new file mode 100644 index 0000000..b036280 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/circbuf.h @@ -0,0 +1,435 @@ +/* $Id: circbuf.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CIRC_BUF_H__
+#define __PJMEDIA_CIRC_BUF_H__
+
+/**
+ * @file circbuf.h
+ * @brief Circular Buffer.
+ */
+
+#include <pj/assert.h>
+#include <pj/errno.h>
+#include <pj/pool.h>
+
+/**
+ * @defgroup PJMED_CIRCBUF Circular Buffer
+ * @ingroup PJMEDIA_FRAME_OP
+ * @brief Circular buffer manages read and write contiguous audio samples in a
+ * non-contiguous buffer as if the buffer were contiguous. This should give
+ * better performance than keeping contiguous samples in a contiguous buffer,
+ * since read/write operations will only update the pointers, instead of
+ * shifting audio samples.
+ *
+ * @{
+ *
+ * This section describes PJMEDIA's implementation of circular buffer.
+ */
+
+/* Algorithm checkings, for development purpose only */
+#if 0
+# define PJMEDIA_CIRC_BUF_CHECK(x) pj_assert(x)
+#else
+# define PJMEDIA_CIRC_BUF_CHECK(x)
+#endif
+
+PJ_BEGIN_DECL
+
+/**
+ * Circular buffer structure
+ */
+typedef struct pjmedia_circ_buf {
+ pj_int16_t *buf; /**< The buffer */
+ unsigned capacity; /**< Buffer capacity, in samples */
+
+ pj_int16_t *start; /**< Pointer to the first sample */
+ unsigned len; /**< Audio samples length,
+ in samples */
+} pjmedia_circ_buf;
+
+
+/**
+ * Create the circular buffer.
+ *
+ * @param pool Pool where the circular buffer will be allocated
+ * from.
+ * @param capacity Capacity of the buffer, in samples.
+ * @param p_cb Pointer to receive the circular buffer instance.
+ *
+ * @return PJ_SUCCESS if the circular buffer has been
+ * created successfully, otherwise the appropriate
+ * error will be returned.
+ */
+PJ_INLINE(pj_status_t) pjmedia_circ_buf_create(pj_pool_t *pool,
+ unsigned capacity,
+ pjmedia_circ_buf **p_cb)
+{
+ pjmedia_circ_buf *cbuf;
+
+ cbuf = PJ_POOL_ZALLOC_T(pool, pjmedia_circ_buf);
+ cbuf->buf = (pj_int16_t*) pj_pool_calloc(pool, capacity,
+ sizeof(pj_int16_t));
+ cbuf->capacity = capacity;
+ cbuf->start = cbuf->buf;
+ cbuf->len = 0;
+
+ *p_cb = cbuf;
+
+ return PJ_SUCCESS;
+}
+
+
+/**
+ * Reset the circular buffer.
+ *
+ * @param circbuf The circular buffer.
+ *
+ * @return PJ_SUCCESS when successful.
+ */
+PJ_INLINE(pj_status_t) pjmedia_circ_buf_reset(pjmedia_circ_buf *circbuf)
+{
+ circbuf->start = circbuf->buf;
+ circbuf->len = 0;
+
+ return PJ_SUCCESS;
+}
+
+
+/**
+ * Get the circular buffer length, it is number of samples buffered in the
+ * circular buffer.
+ *
+ * @param circbuf The circular buffer.
+ *
+ * @return The buffer length.
+ */
+PJ_INLINE(unsigned) pjmedia_circ_buf_get_len(pjmedia_circ_buf *circbuf)
+{
+ return circbuf->len;
+}
+
+
+/**
+ * Set circular buffer length. This is useful when audio buffer is manually
+ * manipulated by the user, e.g: shrinked, expanded.
+ *
+ * @param circbuf The circular buffer.
+ * @param len The new buffer length.
+ */
+PJ_INLINE(void) pjmedia_circ_buf_set_len(pjmedia_circ_buf *circbuf,
+ unsigned len)
+{
+ PJMEDIA_CIRC_BUF_CHECK(len <= circbuf->capacity);
+ circbuf->len = len;
+}
+
+
+/**
+ * Advance the read pointer of circular buffer. This function will discard
+ * the skipped samples while advancing the read pointer, thus reducing
+ * the buffer length.
+ *
+ * @param circbuf The circular buffer.
+ * @param count Distance from current read pointer, can only be
+ * possitive number, in samples.
+ *
+ * @return PJ_SUCCESS when successful, otherwise
+ * the appropriate error will be returned.
+ */
+PJ_INLINE(pj_status_t) pjmedia_circ_buf_adv_read_ptr(pjmedia_circ_buf *circbuf,
+ unsigned count)
+{
+ if (count >= circbuf->len)
+ return pjmedia_circ_buf_reset(circbuf);
+
+ PJMEDIA_CIRC_BUF_CHECK(count <= circbuf->len);
+
+ circbuf->start += count;
+ if (circbuf->start >= circbuf->buf + circbuf->capacity)
+ circbuf->start -= circbuf->capacity;
+ circbuf->len -= count;
+
+ return PJ_SUCCESS;
+}
+
+
+/**
+ * Advance the write pointer of circular buffer. Since write pointer is always
+ * pointing to a sample after the end of sample, so this function also means
+ * increasing the buffer length.
+ *
+ * @param circbuf The circular buffer.
+ * @param count Distance from current write pointer, can only be
+ * possitive number, in samples.
+ *
+ * @return PJ_SUCCESS when successful, otherwise
+ * the appropriate error will be returned.
+ */
+PJ_INLINE(pj_status_t) pjmedia_circ_buf_adv_write_ptr(pjmedia_circ_buf *circbuf,
+ unsigned count)
+{
+ if (count + circbuf->len > circbuf->capacity)
+ return PJ_ETOOBIG;
+
+ circbuf->len += count;
+
+ return PJ_SUCCESS;
+}
+
+
+/**
+ * Get the real buffer addresses containing the audio samples.
+ *
+ * @param circbuf The circular buffer.
+ * @param reg1 Pointer to store the first buffer address.
+ * @param reg1_len Pointer to store the length of the first buffer,
+ * in samples.
+ * @param reg2 Pointer to store the second buffer address.
+ * @param reg2_len Pointer to store the length of the second buffer,
+ * in samples.
+ */
+PJ_INLINE(void) pjmedia_circ_buf_get_read_regions(pjmedia_circ_buf *circbuf,
+ pj_int16_t **reg1,
+ unsigned *reg1_len,
+ pj_int16_t **reg2,
+ unsigned *reg2_len)
+{
+ *reg1 = circbuf->start;
+ *reg1_len = circbuf->len;
+ if (*reg1 + *reg1_len > circbuf->buf + circbuf->capacity) {
+ *reg1_len = circbuf->buf + circbuf->capacity - circbuf->start;
+ *reg2 = circbuf->buf;
+ *reg2_len = circbuf->len - *reg1_len;
+ } else {
+ *reg2 = NULL;
+ *reg2_len = 0;
+ }
+
+ PJMEDIA_CIRC_BUF_CHECK(*reg1_len != 0 || (*reg1_len == 0 &&
+ circbuf->len == 0));
+ PJMEDIA_CIRC_BUF_CHECK(*reg1_len + *reg2_len == circbuf->len);
+}
+
+
+/**
+ * Get the real buffer addresses that is empty or writeable.
+ *
+ * @param circbuf The circular buffer.
+ * @param reg1 Pointer to store the first buffer address.
+ * @param reg1_len Pointer to store the length of the first buffer,
+ * in samples.
+ * @param reg2 Pointer to store the second buffer address.
+ * @param reg2_len Pointer to store the length of the second buffer,
+ * in samples.
+ */
+PJ_INLINE(void) pjmedia_circ_buf_get_write_regions(pjmedia_circ_buf *circbuf,
+ pj_int16_t **reg1,
+ unsigned *reg1_len,
+ pj_int16_t **reg2,
+ unsigned *reg2_len)
+{
+ *reg1 = circbuf->start + circbuf->len;
+ if (*reg1 >= circbuf->buf + circbuf->capacity)
+ *reg1 -= circbuf->capacity;
+ *reg1_len = circbuf->capacity - circbuf->len;
+ if (*reg1 + *reg1_len > circbuf->buf + circbuf->capacity) {
+ *reg1_len = circbuf->buf + circbuf->capacity - *reg1;
+ *reg2 = circbuf->buf;
+ *reg2_len = circbuf->start - circbuf->buf;
+ } else {
+ *reg2 = NULL;
+ *reg2_len = 0;
+ }
+
+ PJMEDIA_CIRC_BUF_CHECK(*reg1_len != 0 || (*reg1_len == 0 &&
+ circbuf->len == 0));
+ PJMEDIA_CIRC_BUF_CHECK(*reg1_len + *reg2_len == circbuf->capacity -
+ circbuf->len);
+}
+
+
+/**
+ * Read audio samples from the circular buffer.
+ *
+ * @param circbuf The circular buffer.
+ * @param data Buffer to store the read audio samples.
+ * @param count Number of samples being read.
+ *
+ * @return PJ_SUCCESS when successful, otherwise
+ * the appropriate error will be returned.
+ */
+PJ_INLINE(pj_status_t) pjmedia_circ_buf_read(pjmedia_circ_buf *circbuf,
+ pj_int16_t *data,
+ unsigned count)
+{
+ pj_int16_t *reg1, *reg2;
+ unsigned reg1cnt, reg2cnt;
+
+ /* Data in the buffer is less than requested */
+ if (count > circbuf->len)
+ return PJ_ETOOBIG;
+
+ pjmedia_circ_buf_get_read_regions(circbuf, ®1, ®1cnt,
+ ®2, ®2cnt);
+ if (reg1cnt >= count) {
+ pjmedia_copy_samples(data, reg1, count);
+ } else {
+ pjmedia_copy_samples(data, reg1, reg1cnt);
+ pjmedia_copy_samples(data + reg1cnt, reg2, count - reg1cnt);
+ }
+
+ return pjmedia_circ_buf_adv_read_ptr(circbuf, count);
+}
+
+
+/**
+ * Write audio samples to the circular buffer.
+ *
+ * @param circbuf The circular buffer.
+ * @param data Audio samples to be written.
+ * @param count Number of samples being written.
+ *
+ * @return PJ_SUCCESS when successful, otherwise
+ * the appropriate error will be returned.
+ */
+PJ_INLINE(pj_status_t) pjmedia_circ_buf_write(pjmedia_circ_buf *circbuf,
+ pj_int16_t *data,
+ unsigned count)
+{
+ pj_int16_t *reg1, *reg2;
+ unsigned reg1cnt, reg2cnt;
+
+ /* Data to write is larger than buffer can store */
+ if (count > circbuf->capacity - circbuf->len)
+ return PJ_ETOOBIG;
+
+ pjmedia_circ_buf_get_write_regions(circbuf, ®1, ®1cnt,
+ ®2, ®2cnt);
+ if (reg1cnt >= count) {
+ pjmedia_copy_samples(reg1, data, count);
+ } else {
+ pjmedia_copy_samples(reg1, data, reg1cnt);
+ pjmedia_copy_samples(reg2, data + reg1cnt, count - reg1cnt);
+ }
+
+ return pjmedia_circ_buf_adv_write_ptr(circbuf, count);
+}
+
+
+/**
+ * Copy audio samples from the circular buffer without changing its state.
+ *
+ * @param circbuf The circular buffer.
+ * @param start_idx Starting sample index to be copied.
+ * @param data Buffer to store the read audio samples.
+ * @param count Number of samples being read.
+ *
+ * @return PJ_SUCCESS when successful, otherwise
+ * the appropriate error will be returned.
+ */
+PJ_INLINE(pj_status_t) pjmedia_circ_buf_copy(pjmedia_circ_buf *circbuf,
+ unsigned start_idx,
+ pj_int16_t *data,
+ unsigned count)
+{
+ pj_int16_t *reg1, *reg2;
+ unsigned reg1cnt, reg2cnt;
+
+ /* Data in the buffer is less than requested */
+ if (count + start_idx > circbuf->len)
+ return PJ_ETOOBIG;
+
+ pjmedia_circ_buf_get_read_regions(circbuf, ®1, ®1cnt,
+ ®2, ®2cnt);
+ if (reg1cnt > start_idx) {
+ unsigned tmp_len;
+ tmp_len = reg1cnt - start_idx;
+ if (tmp_len > count)
+ tmp_len = count;
+ pjmedia_copy_samples(data, reg1 + start_idx, tmp_len);
+ if (tmp_len < count)
+ pjmedia_copy_samples(data + tmp_len, reg2, count - tmp_len);
+ } else {
+ pjmedia_copy_samples(data, reg2 + start_idx - reg1cnt, count);
+ }
+
+ return PJ_SUCCESS;
+}
+
+
+/**
+ * Pack the buffer so the first sample will be in the beginning of the buffer.
+ * This will also make the buffer contiguous.
+ *
+ * @param circbuf The circular buffer.
+ *
+ * @return PJ_SUCCESS when successful, otherwise
+ * the appropriate error will be returned.
+ */
+PJ_INLINE(pj_status_t) pjmedia_circ_buf_pack_buffer(pjmedia_circ_buf *circbuf)
+{
+ pj_int16_t *reg1, *reg2;
+ unsigned reg1cnt, reg2cnt;
+ unsigned gap;
+
+ pjmedia_circ_buf_get_read_regions(circbuf, ®1, ®1cnt,
+ ®2, ®2cnt);
+
+ /* Check if not contigue */
+ if (reg2cnt != 0) {
+ /* Check if no space left to roll the buffer
+ * (or should this function provide temporary buffer?)
+ */
+ gap = circbuf->capacity - pjmedia_circ_buf_get_len(circbuf);
+ if (gap == 0)
+ return PJ_ETOOBIG;
+
+ /* Roll buffer left using the gap until reg2cnt == 0 */
+ do {
+ if (gap > reg2cnt)
+ gap = reg2cnt;
+ pjmedia_move_samples(reg1 - gap, reg1, reg1cnt);
+ pjmedia_copy_samples(reg1 + reg1cnt - gap, reg2, gap);
+ if (gap < reg2cnt)
+ pjmedia_move_samples(reg2, reg2 + gap, reg2cnt - gap);
+ reg1 -= gap;
+ reg1cnt += gap;
+ reg2cnt -= gap;
+ } while (reg2cnt > 0);
+ }
+
+ /* Finally, Shift samples to the left edge */
+ if (reg1 != circbuf->buf)
+ pjmedia_move_samples(circbuf->buf, reg1,
+ pjmedia_circ_buf_get_len(circbuf));
+ circbuf->start = circbuf->buf;
+
+ return PJ_SUCCESS;
+}
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+#endif
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/clock.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/clock.h new file mode 100644 index 0000000..0972d44 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/clock.h @@ -0,0 +1,208 @@ +/* $Id: clock.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CLOCK_H__
+#define __PJMEDIA_CLOCK_H__
+
+/**
+ * @file clock.h
+ * @brief Media clock.
+ */
+#include <pjmedia/types.h>
+
+
+/**
+ * @defgroup PJMEDIA_PORT_CLOCK Clock/Timing
+ * @ingroup PJMEDIA_PORT
+ * @brief Various types of classes that provide timing.
+ * @{
+
+ The media clock/timing extends the media port concept that is explained
+ in @ref PJMEDIA_PORT. When clock is present in the ports
+ interconnection, media will flow automatically (and with correct timing too!)
+ from one media port to another.
+
+ There are few objects in PJMEDIA that are able to provide clock/timing
+ to media ports interconnection:
+
+ - @ref PJMED_SND_PORT\n
+ The sound device makes a good candidate as the clock source, and
+ PJMEDIA @ref PJMED_SND is designed so that it is able to invoke
+ operations according to timing driven by the sound hardware clock
+ (this may sound complicated, but actually it just means that
+ the sound device abstraction provides callbacks to be called when
+ it has/wants media frames).\n
+ See @ref PJMED_SND_PORT for more details.
+
+ - @ref PJMEDIA_MASTER_PORT\n
+ The master port uses @ref PJMEDIA_CLOCK as the clock source. By using
+ @ref PJMEDIA_MASTER_PORT, it is possible to interconnect passive
+ media ports and let the frames flow automatically in timely manner.\n
+ Please see @ref PJMEDIA_MASTER_PORT for more details.
+
+ @}
+ */
+
+
+/**
+ * @addtogroup PJMEDIA_CLOCK Clock Generator
+ * @ingroup PJMEDIA_PORT_CLOCK
+ * @brief Interface for generating clock.
+ * @{
+ *
+ * The clock generator provides the application with media timing,
+ * and it is used by the @ref PJMEDIA_MASTER_PORT for its sound clock.
+ *
+ * The clock generator may be configured to run <b>asynchronously</b>
+ * (the default behavior) or <b>synchronously</b>. When it is run
+ * asynchronously, it will call the application's callback every time
+ * the clock <b>tick</b> expires. When it is run synchronously,
+ * application must continuously polls the clock generator to synchronize
+ * the timing.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Opaque declaration for media clock.
+ */
+typedef struct pjmedia_clock pjmedia_clock;
+
+
+/**
+ * Options when creating the clock.
+ */
+enum pjmedia_clock_options
+{
+ /**
+ * Prevents the clock from running asynchronously. In this case,
+ * application must poll the clock continuously by calling
+ * #pjmedia_clock_wait() in order to synchronize timing.
+ */
+ PJMEDIA_CLOCK_NO_ASYNC = 1,
+
+ /**
+ * Prevent the clock from setting it's thread to highest priority.
+ */
+ PJMEDIA_CLOCK_NO_HIGHEST_PRIO = 2
+};
+
+
+/**
+ * Type of media clock callback.
+ *
+ * @param ts Current timestamp, in samples.
+ * @param user_data Application data that is passed when
+ * the clock was created.
+ */
+typedef void pjmedia_clock_callback(const pj_timestamp *ts,
+ void *user_data);
+
+
+
+/**
+ * Create media clock.
+ *
+ * @param pool Pool to allocate memory.
+ * @param clock_rate Number of samples per second.
+ * @param channel_count Number of channel.
+ * @param samples_per_frame Number of samples per frame. This argument
+ * along with clock_rate and channel_count, specifies
+ * the interval of each clock run (or clock ticks).
+ * @param options Bitmask of pjmedia_clock_options.
+ * @param cb Callback to be called for each clock tick.
+ * @param user_data User data, which will be passed to the callback.
+ * @param p_clock Pointer to receive the clock instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t) pjmedia_clock_create( pj_pool_t *pool,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned options,
+ pjmedia_clock_callback *cb,
+ void *user_data,
+ pjmedia_clock **p_clock);
+
+/**
+ * Start the clock. For clock created with asynchronous flag set to TRUE,
+ * this may start a worker thread for the clock (depending on the
+ * backend clock implementation being used).
+ *
+ * @param clock The media clock.
+ *
+ * @return PJ_SUCCES on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_clock_start(pjmedia_clock *clock);
+
+
+/**
+ * Stop the clock.
+ *
+ * @param clock The media clock.
+ *
+ * @return PJ_SUCCES on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_clock_stop(pjmedia_clock *clock);
+
+
+
+/**
+ * Poll the media clock, and execute the callback when the clock tick has
+ * elapsed. This operation is only valid if the clock is created with async
+ * flag set to FALSE.
+ *
+ * @param clock The media clock.
+ * @param wait If non-zero, then the function will block until
+ * a clock tick elapsed and callback has been called.
+ * @param ts Optional argument to receive the current
+ * timestamp.
+ *
+ * @return Non-zero if clock tick has elapsed, or FALSE if
+ * the function returns before a clock tick has
+ * elapsed.
+ */
+PJ_DECL(pj_bool_t) pjmedia_clock_wait(pjmedia_clock *clock,
+ pj_bool_t wait,
+ pj_timestamp *ts);
+
+
+/**
+ * Destroy the clock.
+ *
+ * @param clock The media clock.
+ *
+ * @return PJ_SUCCES on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_clock_destroy(pjmedia_clock *clock);
+
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_CLOCK_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/codec.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/codec.h new file mode 100644 index 0000000..1bb8038 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/codec.h @@ -0,0 +1,879 @@ +/* $Id: codec.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CODEC_H__
+#define __PJMEDIA_CODEC_H__
+
+
+/**
+ * @file codec.h
+ * @brief Codec framework.
+ */
+
+#include <pjmedia/port.h>
+#include <pj/list.h>
+
+PJ_BEGIN_DECL
+
+
+/**
+ * @defgroup PJMEDIA_CODEC Codec Framework
+ * @brief Media codec framework and management
+ * @{
+ *
+ * @section codec_mgmt_sec Codec Management
+ * @subsection codec_fact_sec Codec Manager
+ *
+ * The codec manager is used to manage all codec capabilities in the endpoint.
+ * When used with media endpoint (pjmedia_endpt), application can retrieve
+ * the codec manager instance by calling #pjmedia_endpt_get_codec_mgr().
+ *
+ * @subsection reg_new_codec Registering New Codec
+ *
+ * New codec types can be registered to PJMEDIA (or to be precise, to the
+ * codec manager) during run-time.
+ * To do this, application needs to initialize an instance of
+ * codec factory (#pjmedia_codec_factory) and registers this codec factory
+ * by calling #pjmedia_codec_mgr_register_factory().
+ *
+ * For codecs implemented/supported by PJMEDIA, this process is normally
+ * concealed in an easy to use function such as #pjmedia_codec_g711_init().
+ *
+ * @subsection codec_factory Codec Factory
+ *
+ * A codec factory (#pjmedia_codec_factory) is registered to codec manager,
+ * and it is used to create and release codec instance.
+ *
+ * The most important member of the codec factory is the "virtual" function
+ * table #pjmedia_codec_factory_op, where it contains, among other thing,
+ * pointer to functions to allocate and deallocate codec instance.
+ *
+ * @subsection codec_inst Codec Instance
+ *
+ * Application allocates codec instance by calling #pjmedia_codec_mgr_alloc_codec().
+ * One codec instance (#pjmedia_codec) can be used for simultaneous encoding
+ * and decoding.
+ *
+ * The most important member of the codec instance is the "virtual" function
+ * table #pjmedia_codec_op, where it holds pointer to functions to
+ * encode/decode media frames.
+ *
+ * @subsection codec_ident Codec Identification
+ *
+ * A particular codec type in PJMEDIA can be uniquely identified by two
+ * keys: by #pjmedia_codec_info, or by #pjmedia_codec_id string. A fully
+ * qualified codec ID string consists of codec name, sampling rate, and
+ * number of channels. However, application may use only first parts of
+ * the tokens as long as it will make to codec ID unique. For example, "gsm"
+ * is a fully qualified codec name, since it will always have 8000 clock
+ * rate and 1 channel. Other examples of fully qualified codec ID strings
+ * are "pcma", "speex/8000", "speex/16000", and "L16/16000/1". A codec
+ * id "speex" (without clock rate) is not fully qualified, since it will
+ * match the narrowband, wideband, and ultrawideband Speex codec.
+ *
+ * The two keys can be converted to one another, with
+ * #pjmedia_codec_info_to_id() and #pjmedia_codec_mgr_find_codecs_by_id()
+ * functions.
+ *
+ * Codec ID string is not case sensitive.
+ *
+ *
+ * @section using_codec Using the Codec Framework
+ * @subsection init_alloc_codec Allocating Codec
+ *
+ * Application needs to allocate one codec instance for encoding and decoding
+ * media frames. One codec instance can be used to perform both encoding
+ * and decoding.
+ *
+ * Application allocates codec by calling #pjmedia_codec_mgr_alloc_codec().
+ * This function takes #pjmedia_codec_info argument, which is used to locate
+ * the particular codec factory to be used to allocate the codec.
+ *
+ * Application can build #pjmedia_codec_info structure manually for
+ * the specific codec, or alternatively it may get the #pjmedia_codec_info
+ * from the codec ID string, by using #pjmedia_codec_mgr_find_codecs_by_id()
+ * function.
+ *
+ * The following snippet shows an example to allocate a codec:
+ *
+ \code
+ pj_str_t codec_id;
+ pjmedia_codec_info *codec_info;
+ unsigned count = 1;
+ pjmedia_codec *codec;
+
+ codec_id = pj_str("pcma");
+
+ // Find codec info for the specified coded ID (i.e. "pcma").
+ status = pjmedia_codec_mgr_find_codecs_by_id( codec_mgr, &codec_id,
+ &count, &codec_info, NULL);
+
+ // Allocate the codec.
+ status = pjmedia_codec_mgr_alloc_codec( codec_mgr, codec_info, &codec );
+
+ \endcode
+ *
+ *
+ * @subsection opening_codec Initializing Codec
+ *
+ * Once codec is allocated, application needs to initialize the codec
+ * by calling <b><tt>open</tt></b> member of the codec. This function
+ * takes #pjmedia_codec_param as the argument, which contains the
+ * settings for the codec.
+ *
+ * Application shoud use #pjmedia_codec_mgr_get_default_param() function
+ * to initiaize #pjmedia_codec_param. The <tt>setting</tt> part of
+ * #pjmedia_codec_param then can be tuned to suit the application's
+ * requirements.
+ *
+ * The following snippet shows an example to initialize codec:
+ *
+ \code
+ pjmedia_codec_param param;
+
+ // Retrieve default codec param for the specified codec.
+ pjmedia_codec_mgr_get_default_param(codec_mgr, codec_info
+ ¶m);
+
+ // Application may change the "settings" part of codec param,
+ // for example, to disable VAD
+ param.setting.vad = 0;
+
+ // Open the codec using the specified settings.
+ codec->op->open( codec, ¶m );
+
+ \endcode
+ *
+ *
+ * @subsection enc_dec_codec Encoding and Decoding Media Frames
+ *
+ * Application encodes and decodes media frames by calling
+ * <tt>encode</tt> and <tt>decode</tt> member of the codec's "virtual"
+ * function table (#pjmedia_codec_op).
+ *
+ * @subsection plc_codec Concealing Lost Frames
+ *
+ * All codecs has Packet Lost Concealment (PLC) feature, and application
+ * can activate the PLC to conceal lost frames by calling <tt>recover</tt>
+ * member of the codec's "virtual" function table (#pjmedia_codec_op).
+ *
+ * If the codec's algorithm supports PLC, the <tt>recover</tt> function
+ * will use the codec's PLC. Otherwise for codecs that don't have
+ * intrinsic PLC, PJMEDIA will suply the PLC implementation from the
+ * @ref PJMED_PLC implementation.
+ *
+ * @subsection close_codec Closing and Releasing the Codec
+ *
+ * The codec must be closed by calling <tt>close</tt> member of the codec's
+ * operation. Then it must be released by calling
+ * #pjmedia_codec_mgr_dealloc_codec().
+ */
+
+
+/**
+ * Standard RTP static payload types, as defined by RFC 3551.
+ * The header file <pjmedia-codec/types.h> also declares dynamic payload
+ * type numbers that are used by PJMEDIA when advertising the capability
+ * for example in SDP message.
+ */
+enum pjmedia_rtp_pt
+{
+ PJMEDIA_RTP_PT_PCMU = 0, /**< audio PCMU */
+ PJMEDIA_RTP_PT_G726_32 = 2, /**< audio G726-32 */
+ PJMEDIA_RTP_PT_GSM = 3, /**< audio GSM */
+ PJMEDIA_RTP_PT_G723 = 4, /**< audio G723 */
+ PJMEDIA_RTP_PT_DVI4_8K = 5, /**< audio DVI4 8KHz */
+ PJMEDIA_RTP_PT_DVI4_16K = 6, /**< audio DVI4 16Khz */
+ PJMEDIA_RTP_PT_LPC = 7, /**< audio LPC */
+ PJMEDIA_RTP_PT_PCMA = 8, /**< audio PCMA */
+ PJMEDIA_RTP_PT_G722 = 9, /**< audio G722 */
+ PJMEDIA_RTP_PT_L16_2 = 10, /**< audio 16bit linear 44.1KHz stereo */
+ PJMEDIA_RTP_PT_L16_1 = 11, /**< audio 16bit linear 44.1KHz mono */
+ PJMEDIA_RTP_PT_QCELP = 12, /**< audio QCELP */
+ PJMEDIA_RTP_PT_CN = 13, /**< audio Comfort Noise */
+ PJMEDIA_RTP_PT_MPA = 14, /**< audio MPEG1/MPEG2 elemetr. streams */
+ PJMEDIA_RTP_PT_G728 = 15, /**< audio G728 */
+ PJMEDIA_RTP_PT_DVI4_11K = 16, /**< audio DVI4 11.025KHz mono */
+ PJMEDIA_RTP_PT_DVI4_22K = 17, /**< audio DVI4 22.050KHz mono */
+ PJMEDIA_RTP_PT_G729 = 18, /**< audio G729 */
+
+ PJMEDIA_RTP_PT_CELB = 25, /**< video/comb Cell-B by Sun (RFC2029) */
+ PJMEDIA_RTP_PT_JPEG = 26, /**< video JPEG */
+ PJMEDIA_RTP_PT_NV = 28, /**< video NV by nv program by Xerox */
+ PJMEDIA_RTP_PT_H261 = 31, /**< video H261 */
+ PJMEDIA_RTP_PT_MPV = 32, /**< video MPEG1 or MPEG2 elementary */
+ PJMEDIA_RTP_PT_MP2T = 33, /**< video MPEG2 transport */
+ PJMEDIA_RTP_PT_H263 = 34, /**< video H263 */
+
+ PJMEDIA_RTP_PT_DYNAMIC = 96 /**< start of dynamic RTP payload */
+
+};
+
+
+/**
+ * Identification used to search for codec factory that supports specific
+ * codec specification.
+ */
+typedef struct pjmedia_codec_info
+{
+ pjmedia_type type; /**< Media type. */
+ unsigned pt; /**< Payload type (can be dynamic). */
+ pj_str_t encoding_name; /**< Encoding name. */
+ unsigned clock_rate; /**< Sampling rate. */
+ unsigned channel_cnt; /**< Channel count. */
+} pjmedia_codec_info;
+
+#define PJMEDIA_CODEC_MAX_FMTP_CNT 8
+
+/**
+ * Structure of codec specific parameters which contains name=value pairs.
+ * The codec specific parameters are to be used with SDP according to
+ * the standards (e.g: RFC 3555).
+ */
+typedef struct pjmedia_codec_fmtp
+{
+ pj_uint8_t cnt;
+ struct param {
+ pj_str_t name;
+ pj_str_t val;
+ } param [PJMEDIA_CODEC_MAX_FMTP_CNT];
+} pjmedia_codec_fmtp;
+
+/**
+ * Detailed codec attributes used both to configure a codec and to query
+ * the capability of codec factories.
+ */
+typedef struct pjmedia_codec_param
+{
+ /**
+ * The "info" part of codec param describes the capability of the codec,
+ * and the value should NOT be changed by application.
+ */
+ struct {
+ unsigned clock_rate; /**< Sampling rate in Hz */
+ unsigned channel_cnt; /**< Channel count. */
+ pj_uint32_t avg_bps; /**< Average bandwidth in bits/sec */
+ pj_uint32_t max_bps; /**< Maximum bandwidth in bits/sec */
+ pj_uint16_t frm_ptime; /**< Decoder frame ptime in msec. */
+ pj_uint16_t enc_ptime; /**< Encoder ptime, or zero if it's
+ equal to decoder ptime. */
+ pj_uint8_t pcm_bits_per_sample; /**< Bits/sample in the PCM side */
+ pj_uint8_t pt; /**< Payload type. */
+ pjmedia_format_id fmt_id; /**< Source format, it's format of
+ encoder input and decoder
+ output. */
+ } info;
+
+ /**
+ * The "setting" part of codec param describes various settings to be
+ * applied to the codec. When the codec param is retrieved from the codec
+ * or codec factory, the values of these will be filled by the capability
+ * of the codec. Any features that are supported by the codec (e.g. vad
+ * or plc) will be turned on, so that application can query which
+ * capabilities are supported by the codec. Application may change the
+ * settings here before instantiating the codec/stream.
+ */
+ struct {
+ pj_uint8_t frm_per_pkt; /**< Number of frames per packet. */
+ unsigned vad:1; /**< Voice Activity Detector. */
+ unsigned cng:1; /**< Comfort Noise Generator. */
+ unsigned penh:1; /**< Perceptual Enhancement */
+ unsigned plc:1; /**< Packet loss concealment */
+ unsigned reserved:1; /**< Reserved, must be zero. */
+ pjmedia_codec_fmtp enc_fmtp;/**< Encoder's fmtp params. */
+ pjmedia_codec_fmtp dec_fmtp;/**< Decoder's fmtp params. */
+ } setting;
+} pjmedia_codec_param;
+
+
+
+/*
+ * Forward declaration for pjmedia_codec.
+ */
+typedef struct pjmedia_codec pjmedia_codec;
+
+
+/**
+ * This structure describes codec operations. Each codec MUST implement
+ * all of these functions.
+ */
+typedef struct pjmedia_codec_op
+{
+ /**
+ * Initialize codec using the specified attribute.
+ *
+ * @param codec The codec instance.
+ * @param pool Pool to use when the codec needs to allocate
+ * some memory.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+ pj_status_t (*init)(pjmedia_codec *codec,
+ pj_pool_t *pool );
+
+ /**
+ * Open the codec and initialize with the specified parameter.
+ * Upon successful initialization, the codec may modify the parameter
+ * and fills in the unspecified values (such as enc_ptime, when
+ * encoder ptime is different than decoder ptime).
+ *
+ * @param codec The codec instance.
+ * @param param Codec initialization parameter.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+ pj_status_t (*open)(pjmedia_codec *codec,
+ pjmedia_codec_param *param );
+
+ /**
+ * Close and shutdown codec, releasing all resources allocated by
+ * this codec, if any.
+ *
+ * @param codec The codec instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+ pj_status_t (*close)(pjmedia_codec *codec);
+
+ /**
+ * Modify the codec parameter after the codec is open.
+ * Note that not all codec parameters can be modified during run-time.
+ * When the parameter cannot be changed, this function will return
+ * non-PJ_SUCCESS, and the original parameters will not be changed.
+ *
+ * Application can expect changing trivial codec settings such as
+ * changing VAD setting to succeed.
+ *
+ * @param codec The codec instance.
+ * @param param The new codec parameter.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+ pj_status_t (*modify)(pjmedia_codec *codec,
+ const pjmedia_codec_param *param );
+
+ /**
+ * Instruct the codec to inspect the specified payload/packet and
+ * split the packet into individual base frames. Each output frames will
+ * have ptime that is equal to basic frame ptime (i.e. the value of
+ * info.frm_ptime in #pjmedia_codec_param).
+ *
+ * @param codec The codec instance
+ * @param pkt The input packet.
+ * @param pkt_size Size of the packet.
+ * @param timestamp The timestamp of the first sample in the packet.
+ * @param frame_cnt On input, specifies the maximum number of frames
+ * in the array. On output, the codec must fill
+ * with number of frames detected in the packet.
+ * @param frames On output, specifies the frames that have been
+ * detected in the packet.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+ pj_status_t (*parse)( pjmedia_codec *codec,
+ void *pkt,
+ pj_size_t pkt_size,
+ const pj_timestamp *timestamp,
+ unsigned *frame_cnt,
+ pjmedia_frame frames[]);
+
+ /**
+ * Instruct the codec to encode the specified input frame. The input
+ * PCM samples MUST have ptime that is multiplication of base frame
+ * ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param).
+ *
+ * @param codec The codec instance.
+ * @param input The input frame.
+ * @param out_size The length of buffer in the output frame.
+ * @param output The output frame.
+ *
+ * @return PJ_SUCCESS on success;
+ */
+ pj_status_t (*encode)(pjmedia_codec *codec,
+ const struct pjmedia_frame *input,
+ unsigned out_size,
+ struct pjmedia_frame *output);
+
+ /**
+ * Instruct the codec to decode the specified input frame. The input
+ * frame MUST have ptime that is exactly equal to base frame
+ * ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param).
+ * Application can achieve this by parsing the packet into base
+ * frames before decoding each frame.
+ *
+ * @param codec The codec instance.
+ * @param input The input frame.
+ * @param out_size The length of buffer in the output frame.
+ * @param output The output frame.
+ *
+ * @return PJ_SUCCESS on success;
+ */
+ pj_status_t (*decode)(pjmedia_codec *codec,
+ const struct pjmedia_frame *input,
+ unsigned out_size,
+ struct pjmedia_frame *output);
+
+ /**
+ * Instruct the codec to recover a missing frame.
+ *
+ * @param codec The codec instance.
+ * @param out_size The length of buffer in the output frame.
+ * @param output The output frame where generated signal
+ * will be placed.
+ *
+ * @return PJ_SUCCESS on success;
+ */
+ pj_status_t (*recover)(pjmedia_codec *codec,
+ unsigned out_size,
+ struct pjmedia_frame *output);
+} pjmedia_codec_op;
+
+
+
+/*
+ * Forward declaration for pjmedia_codec_factory.
+ */
+typedef struct pjmedia_codec_factory pjmedia_codec_factory;
+
+
+/**
+ * This structure describes a codec instance.
+ */
+struct pjmedia_codec
+{
+ /** Entries to put this codec instance in codec factory's list. */
+ PJ_DECL_LIST_MEMBER(struct pjmedia_codec);
+
+ /** Codec's private data. */
+ void *codec_data;
+
+ /** Codec factory where this codec was allocated. */
+ pjmedia_codec_factory *factory;
+
+ /** Operations to codec. */
+ pjmedia_codec_op *op;
+};
+
+
+
+/**
+ * This structure describes operations that must be supported by codec
+ * factories.
+ */
+typedef struct pjmedia_codec_factory_op
+{
+ /**
+ * Check whether the factory can create codec with the specified
+ * codec info.
+ *
+ * @param factory The codec factory.
+ * @param info The codec info.
+ *
+ * @return PJ_SUCCESS if this factory is able to create an
+ * instance of codec with the specified info.
+ */
+ pj_status_t (*test_alloc)(pjmedia_codec_factory *factory,
+ const pjmedia_codec_info *info );
+
+ /**
+ * Create default attributes for the specified codec ID. This function
+ * can be called by application to get the capability of the codec.
+ *
+ * @param factory The codec factory.
+ * @param info The codec info.
+ * @param attr The attribute to be initialized.
+ *
+ * @return PJ_SUCCESS if success.
+ */
+ pj_status_t (*default_attr)(pjmedia_codec_factory *factory,
+ const pjmedia_codec_info *info,
+ pjmedia_codec_param *attr );
+
+ /**
+ * Enumerate supported codecs that can be created using this factory.
+ *
+ * @param factory The codec factory.
+ * @param count On input, specifies the number of elements in
+ * the array. On output, the value will be set to
+ * the number of elements that have been initialized
+ * by this function.
+ * @param info The codec info array, which contents will be
+ * initialized upon return.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+ pj_status_t (*enum_info)(pjmedia_codec_factory *factory,
+ unsigned *count,
+ pjmedia_codec_info codecs[]);
+
+ /**
+ * Create one instance of the codec with the specified codec info.
+ *
+ * @param factory The codec factory.
+ * @param info The codec info.
+ * @param p_codec Pointer to receive the codec instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+ pj_status_t (*alloc_codec)(pjmedia_codec_factory *factory,
+ const pjmedia_codec_info *info,
+ pjmedia_codec **p_codec);
+
+ /**
+ * This function is called by codec manager to return a particular
+ * instance of codec back to the codec factory.
+ *
+ * @param factory The codec factory.
+ * @param codec The codec instance to be returned.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+ pj_status_t (*dealloc_codec)(pjmedia_codec_factory *factory,
+ pjmedia_codec *codec );
+
+} pjmedia_codec_factory_op;
+
+
+
+/**
+ * Codec factory describes a module that is able to create codec with specific
+ * capabilities. These capabilities can be queried by codec manager to create
+ * instances of codec.
+ */
+struct pjmedia_codec_factory
+{
+ /** Entries to put this structure in the codec manager list. */
+ PJ_DECL_LIST_MEMBER(struct pjmedia_codec_factory);
+
+ /** The factory's private data. */
+ void *factory_data;
+
+ /** Operations to the factory. */
+ pjmedia_codec_factory_op *op;
+
+};
+
+
+/**
+ * Declare maximum codecs
+ */
+#define PJMEDIA_CODEC_MGR_MAX_CODECS 32
+
+
+/**
+ * Specify these values to set the codec priority, by calling
+ * #pjmedia_codec_mgr_set_codec_priority().
+ */
+typedef enum pjmedia_codec_priority
+{
+ /**
+ * This priority makes the codec the highest in the order.
+ * The last codec specified with this priority will get the
+ * highest place in the order, and will change the priority
+ * of previously highest priority codec to NEXT_HIGHER.
+ */
+ PJMEDIA_CODEC_PRIO_HIGHEST = 255,
+
+ /**
+ * This priority will put the codec as the next codec after
+ * codecs with this same priority.
+ */
+ PJMEDIA_CODEC_PRIO_NEXT_HIGHER = 254,
+
+ /**
+ * This is the initial codec priority when it is registered to
+ * codec manager by codec factory.
+ */
+ PJMEDIA_CODEC_PRIO_NORMAL = 128,
+
+ /**
+ * This priority makes the codec the lowest in the order.
+ * The last codec specified with this priority will be put
+ * in the last place in the order.
+ */
+ PJMEDIA_CODEC_PRIO_LOWEST = 1,
+
+ /**
+ * This priority will prevent the codec from being listed in the
+ * SDP created by media endpoint, thus should prevent the codec
+ * from being used in the sessions. However, the codec will still
+ * be listed by #pjmedia_codec_mgr_enum_codecs() and other codec
+ * query functions.
+ */
+ PJMEDIA_CODEC_PRIO_DISABLED = 0
+
+} pjmedia_codec_priority;
+
+
+/**
+ * Codec identification (e.g. "pcmu/8000/1").
+ * See @ref codec_ident for more info.
+ */
+typedef char pjmedia_codec_id[32];
+
+
+/**
+ * Codec manager maintains array of these structs for each supported
+ * codec.
+ */
+struct pjmedia_codec_desc
+{
+ pjmedia_codec_info info; /**< Codec info. */
+ pjmedia_codec_id id; /**< Fully qualified name */
+ pjmedia_codec_priority prio; /**< Priority. */
+ pjmedia_codec_factory *factory; /**< The factory. */
+};
+
+
+/**
+ * The declaration for codec manager. Application doesn't normally need
+ * to see this declaration, but nevertheless this declaration is needed
+ * by media endpoint to instantiate the codec manager.
+ */
+typedef struct pjmedia_codec_mgr
+{
+ /** List of codec factories registered to codec manager. */
+ pjmedia_codec_factory factory_list;
+
+ /** Number of supported codesc. */
+ unsigned codec_cnt;
+
+ /** Array of codec descriptor. */
+ struct pjmedia_codec_desc codec_desc[PJMEDIA_CODEC_MGR_MAX_CODECS];
+
+} pjmedia_codec_mgr;
+
+
+
+/**
+ * Initialize codec manager. Normally this function is called by pjmedia
+ * endpoint's initialization code.
+ *
+ * @param mgr Codec manager instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_mgr_init(pjmedia_codec_mgr *mgr);
+
+
+/**
+ * Register codec factory to codec manager. This will also register
+ * all supported codecs in the factory to the codec manager.
+ *
+ * @param mgr The codec manager instance. Application can get the
+ * instance by calling #pjmedia_endpt_get_codec_mgr().
+ * @param factory The codec factory to be registered.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_codec_mgr_register_factory( pjmedia_codec_mgr *mgr,
+ pjmedia_codec_factory *factory);
+
+/**
+ * Unregister codec factory from the codec manager. This will also
+ * remove all the codecs registered by the codec factory from the
+ * codec manager's list of supported codecs.
+ *
+ * @param mgr The codec manager instance. Application can get the
+ * instance by calling #pjmedia_endpt_get_codec_mgr().
+ * @param factory The codec factory to be unregistered.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_codec_mgr_unregister_factory( pjmedia_codec_mgr *mgr,
+ pjmedia_codec_factory *factory);
+
+/**
+ * Enumerate all supported codecs that have been registered to the
+ * codec manager by codec factories.
+ *
+ * @param mgr The codec manager instance. Application can get the
+ * instance by calling #pjmedia_endpt_get_codec_mgr().
+ * @param count On input, specifies the number of elements in
+ * the array. On output, the value will be set to
+ * the number of elements that have been initialized
+ * by this function.
+ * @param info The codec info array, which contents will be
+ * initialized upon return.
+ * @param prio Optional pointer to receive array of codec priorities.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_mgr_enum_codecs( pjmedia_codec_mgr *mgr,
+ unsigned *count,
+ pjmedia_codec_info info[],
+ unsigned *prio);
+
+/**
+ * Get codec info for the specified static payload type. Note that
+ * this can only find codec with static payload types. This function can
+ * be used to find codec info for a payload type inside SDP which doesn't
+ * have the corresponding rtpmap attribute.
+ *
+ * @param mgr The codec manager instance. Application can get the
+ * instance by calling #pjmedia_endpt_get_codec_mgr().
+ * @param pt Static payload type/number.
+ * @param inf Pointer to receive codec info.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_codec_mgr_get_codec_info( pjmedia_codec_mgr *mgr,
+ unsigned pt,
+ const pjmedia_codec_info **inf);
+
+/**
+ * Convert codec info struct into a unique codec identifier.
+ * A codec identifier looks something like "L16/44100/2".
+ *
+ * @param info The codec info
+ * @param id Buffer to put the codec info string.
+ * @param max_len The length of the buffer.
+ *
+ * @return The null terminated codec info string, or NULL if
+ * the buffer is not long enough.
+ */
+PJ_DECL(char*) pjmedia_codec_info_to_id(const pjmedia_codec_info *info,
+ char *id, unsigned max_len );
+
+
+/**
+ * Find codecs by the unique codec identifier. This function will find
+ * all codecs that match the codec identifier prefix. For example, if
+ * "L16" is specified, then it will find "L16/8000/1", "L16/16000/1",
+ * and so on, up to the maximum count specified in the argument.
+ *
+ * @param mgr The codec manager instance. Application can get the
+ * instance by calling #pjmedia_endpt_get_codec_mgr().
+ * @param codec_id The full codec ID or codec ID prefix. If an empty
+ * string is given, it will match all codecs.
+ * @param count Maximum number of codecs to find. On return, it
+ * contains the actual number of codecs found.
+ * @param p_info Array of pointer to codec info to be filled. This
+ * argument may be NULL, which in this case, only
+ * codec count will be returned.
+ * @param prio Optional array of codec priorities.
+ *
+ * @return PJ_SUCCESS if at least one codec info is found.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_codec_mgr_find_codecs_by_id( pjmedia_codec_mgr *mgr,
+ const pj_str_t *codec_id,
+ unsigned *count,
+ const pjmedia_codec_info *p_info[],
+ unsigned prio[]);
+
+
+/**
+ * Set codec priority. The codec priority determines the order of
+ * the codec in the SDP created by the endpoint. If more than one codecs
+ * are found with the same codec_id prefix, then the function sets the
+ * priorities of all those codecs.
+ *
+ * @param mgr The codec manager instance. Application can get the
+ * instance by calling #pjmedia_endpt_get_codec_mgr().
+ * @param codec_id The full codec ID or codec ID prefix. If an empty
+ * string is given, it will match all codecs.
+ * @param prio Priority to be set. The priority can have any value
+ * between 1 to 255. When the priority is set to zero,
+ * the codec will be disabled.
+ *
+ * @return PJ_SUCCESS if at least one codec info is found.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_codec_mgr_set_codec_priority(pjmedia_codec_mgr *mgr,
+ const pj_str_t *codec_id,
+ pj_uint8_t prio);
+
+
+/**
+ * Get default codec param for the specified codec info.
+ *
+ * @param mgr The codec manager instance. Application can get the
+ * instance by calling #pjmedia_endpt_get_codec_mgr().
+ * @param info The codec info, which default parameter's is being
+ * queried.
+ * @param param On return, will be filled with the default codec
+ * parameter.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_codec_mgr_get_default_param( pjmedia_codec_mgr *mgr,
+ const pjmedia_codec_info *info,
+ pjmedia_codec_param *param );
+
+/**
+ * Request the codec manager to allocate one instance of codec with the
+ * specified codec info. The codec will enumerate all codec factories
+ * until it finds factory that is able to create the specified codec.
+ *
+ * @param mgr The codec manager instance. Application can get the
+ * instance by calling #pjmedia_endpt_get_codec_mgr().
+ * @param info The information about the codec to be created.
+ * @param p_codec Pointer to receive the codec instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_codec_mgr_alloc_codec( pjmedia_codec_mgr *mgr,
+ const pjmedia_codec_info *info,
+ pjmedia_codec **p_codec);
+
+/**
+ * Deallocate the specified codec instance. The codec manager will return
+ * the instance of the codec back to its factory.
+ *
+ * @param mgr The codec manager instance. Application can get the
+ * instance by calling #pjmedia_endpt_get_codec_mgr().
+ * @param codec The codec instance.
+ *
+ * @return PJ_SUCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_mgr_dealloc_codec(pjmedia_codec_mgr *mgr,
+ pjmedia_codec *codec);
+
+
+
+
+
+/**
+ * @}
+ */
+
+/**
+ * @defgroup PJMEDIA_CODEC_CODECS Supported codecs
+ * @ingroup PJMEDIA_CODEC
+ * @brief Documentation about individual codec supported by PJMEDIA
+ * @{
+ * Please see the APIs provided by the individual codecs below.
+ */
+/**
+ * @}
+ */
+
+
+
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_CODEC_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/conference.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/conference.h new file mode 100644 index 0000000..5b13590 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/conference.h @@ -0,0 +1,511 @@ +/* $Id: conference.h 2728 2009-06-01 13:56:09Z nanang $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CONF_H__
+#define __PJMEDIA_CONF_H__
+
+
+/**
+ * @file conference.h
+ * @brief Conference bridge.
+ */
+#include <pjmedia/port.h>
+
+/**
+ * @defgroup PJMEDIA_CONF Conference Bridge
+ * @ingroup PJMEDIA_PORT
+ * @brief Audio conference bridge implementation
+ * @{
+ *
+ * This describes the conference bridge implementation in PJMEDIA. The
+ * conference bridge provides powerful and very efficient mechanism to
+ * route the audio flow and mix the audio signal when required.
+ *
+ * Some more information about the media flow when conference bridge is
+ * used is described in http://www.pjsip.org/trac/wiki/media-flow .
+ */
+
+PJ_BEGIN_DECL
+
+/**
+ * The conference bridge signature in pjmedia_port_info.
+ */
+#define PJMEDIA_CONF_BRIDGE_SIGNATURE \
+ PJMEDIA_PORT_SIGNATURE('C', 'O', 'N', 'F')
+
+/**
+ * The audio switchboard signature in pjmedia_port_info.
+ */
+#define PJMEDIA_CONF_SWITCH_SIGNATURE \
+ PJMEDIA_PORT_SIGNATURE('A', 'S', 'W', 'I')
+
+
+/**
+ * Opaque type for conference bridge.
+ */
+typedef struct pjmedia_conf pjmedia_conf;
+
+/**
+ * Conference port info.
+ */
+typedef struct pjmedia_conf_port_info
+{
+ unsigned slot; /**< Slot number. */
+ pj_str_t name; /**< Port name. */
+ pjmedia_format format; /**< Format. */
+ pjmedia_port_op tx_setting; /**< Transmit settings. */
+ pjmedia_port_op rx_setting; /**< Receive settings. */
+ unsigned listener_cnt; /**< Number of listeners. */
+ unsigned *listener_slots; /**< Array of listeners. */
+ unsigned transmitter_cnt; /**< Number of transmitter. */
+ unsigned clock_rate; /**< Clock rate of the port. */
+ unsigned channel_count; /**< Number of channels. */
+ unsigned samples_per_frame; /**< Samples per frame */
+ unsigned bits_per_sample; /**< Bits per sample. */
+ int tx_adj_level; /**< Tx level adjustment. */
+ int rx_adj_level; /**< Rx level adjustment. */
+} pjmedia_conf_port_info;
+
+
+/**
+ * Conference port options. The values here can be combined in bitmask to
+ * be specified when the conference bridge is created.
+ */
+enum pjmedia_conf_option
+{
+ PJMEDIA_CONF_NO_MIC = 1, /**< Disable audio streams from the
+ microphone device. */
+ PJMEDIA_CONF_NO_DEVICE = 2, /**< Do not create sound device. */
+ PJMEDIA_CONF_SMALL_FILTER=4,/**< Use small filter table when resampling */
+ PJMEDIA_CONF_USE_LINEAR=8 /**< Use linear resampling instead of filter
+ based. */
+};
+
+
+/**
+ * Create conference bridge with the specified parameters. The sampling rate,
+ * samples per frame, and bits per sample will be used for the internal
+ * operation of the bridge (e.g. when mixing audio frames). However, ports
+ * with different configuration may be connected to the bridge. In this case,
+ * the bridge is able to perform sampling rate conversion, and buffering in
+ * case the samples per frame is different.
+ *
+ * For this version of PJMEDIA, only 16bits per sample is supported.
+ *
+ * For this version of PJMEDIA, the channel count of the ports MUST match
+ * the channel count of the bridge.
+ *
+ * Under normal operation (i.e. when PJMEDIA_CONF_NO_DEVICE option is NOT
+ * specified), the bridge internally create an instance of sound device
+ * and connect the sound device to port zero of the bridge.
+ *
+ * If PJMEDIA_CONF_NO_DEVICE options is specified, no sound device will
+ * be created in the conference bridge. Application MUST acquire the port
+ * interface of the bridge by calling #pjmedia_conf_get_master_port(), and
+ * connect this port interface to a sound device port by calling
+ * #pjmedia_snd_port_connect(), or to a master port (pjmedia_master_port)
+ * if application doesn't want to instantiate any sound devices.
+ *
+ * The sound device or master port are crucial for the bridge's operation,
+ * because it provides the bridge with necessary clock to process the audio
+ * frames periodically. Internally, the bridge runs when get_frame() to
+ * port zero is called.
+ *
+ * @param pool Pool to use to allocate the bridge and
+ * additional buffers for the sound device.
+ * @param max_slots Maximum number of slots/ports to be created in
+ * the bridge. Note that the bridge internally uses
+ * one port for the sound device, so the actual
+ * maximum number of ports will be less one than
+ * this value.
+ * @param sampling_rate Set the sampling rate of the bridge. This value
+ * is also used to set the sampling rate of the
+ * sound device.
+ * @param channel_count Number of channels in the PCM stream. Normally
+ * the value will be 1 for mono, but application may
+ * specify a value of 2 for stereo. Note that all
+ * ports that will be connected to the bridge MUST
+ * have the same number of channels as the bridge.
+ * @param samples_per_frame Set the number of samples per frame. This value
+ * is also used to set the sound device.
+ * @param bits_per_sample Set the number of bits per sample. This value
+ * is also used to set the sound device. Currently
+ * only 16bit per sample is supported.
+ * @param options Bitmask options to be set for the bridge. The
+ * options are constructed from #pjmedia_conf_option
+ * enumeration.
+ * @param p_conf Pointer to receive the conference bridge instance.
+ *
+ * @return PJ_SUCCESS if conference bridge can be created.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_create( pj_pool_t *pool,
+ unsigned max_slots,
+ unsigned sampling_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ unsigned options,
+ pjmedia_conf **p_conf );
+
+
+/**
+ * Destroy conference bridge.
+ *
+ * @param conf The conference bridge.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_destroy( pjmedia_conf *conf );
+
+
+/**
+ * Get the master port interface of the conference bridge. The master port
+ * corresponds to the port zero of the bridge. This is only usefull when
+ * application wants to manage the sound device by itself, instead of
+ * allowing the bridge to automatically create a sound device implicitly.
+ *
+ * This function will only return a port interface if PJMEDIA_CONF_NO_DEVICE
+ * option was specified when the bridge was created.
+ *
+ * Application can connect the port returned by this function to a
+ * sound device by calling #pjmedia_snd_port_connect().
+ *
+ * @param conf The conference bridge.
+ *
+ * @return The port interface of port zero of the bridge,
+ * only when PJMEDIA_CONF_NO_DEVICE options was
+ * specified when the bridge was created.
+ */
+PJ_DECL(pjmedia_port*) pjmedia_conf_get_master_port(pjmedia_conf *conf);
+
+
+/**
+ * Set master port name.
+ *
+ * @param conf The conference bridge.
+ * @param name Name to be assigned.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_set_port0_name(pjmedia_conf *conf,
+ const pj_str_t *name);
+
+
+/**
+ * Add media port to the conference bridge.
+ *
+ * By default, the new conference port will have both TX and RX enabled,
+ * but it is not connected to any other ports. Application SHOULD call
+ * #pjmedia_conf_connect_port() to enable audio transmission and receipt
+ * to/from this port.
+ *
+ * Once the media port is connected to other port(s) in the bridge,
+ * the bridge will continuosly call get_frame() and put_frame() to the
+ * port, allowing media to flow to/from the port.
+ *
+ * @param conf The conference bridge.
+ * @param pool Pool to allocate buffers for this port.
+ * @param strm_port Stream port interface.
+ * @param name Optional name for the port. If this value is NULL,
+ * the name will be taken from the name in the port
+ * info.
+ * @param p_slot Pointer to receive the slot index of the port in
+ * the conference bridge.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_add_port( pjmedia_conf *conf,
+ pj_pool_t *pool,
+ pjmedia_port *strm_port,
+ const pj_str_t *name,
+ unsigned *p_slot );
+
+
+/**
+ * <i><b>Warning:</b> This API has been deprecated since 1.3 and will be
+ * removed in the future release, use #PJMEDIA_SPLITCOMB instead.</i>
+ *
+ * Create and add a passive media port to the conference bridge. Unlike
+ * "normal" media port that is added with #pjmedia_conf_add_port(), media
+ * port created with this function will not have its get_frame() and
+ * put_frame() called by the bridge; instead, application MUST continuosly
+ * call these functions to the port, to allow media to flow from/to the
+ * port.
+ *
+ * Upon return of this function, application will be given two objects:
+ * the slot number of the port in the bridge, and pointer to the media
+ * port where application MUST start calling get_frame() and put_frame()
+ * to the port.
+ *
+ * @param conf The conference bridge.
+ * @param pool Pool to allocate buffers etc for this port.
+ * @param name Name to be assigned to the port.
+ * @param clock_rate Clock rate/sampling rate.
+ * @param channel_count Number of channels.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Number of bits per sample.
+ * @param options Options (should be zero at the moment).
+ * @param p_slot Pointer to receive the slot index of the port in
+ * the conference bridge.
+ * @param p_port Pointer to receive the port instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_add_passive_port( pjmedia_conf *conf,
+ pj_pool_t *pool,
+ const pj_str_t *name,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ unsigned options,
+ unsigned *p_slot,
+ pjmedia_port **p_port );
+
+
+/**
+ * Change TX and RX settings for the port.
+ *
+ * @param conf The conference bridge.
+ * @param slot Port number/slot in the conference bridge.
+ * @param tx Settings for the transmission TO this port.
+ * @param rx Settings for the receipt FROM this port.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_configure_port( pjmedia_conf *conf,
+ unsigned slot,
+ pjmedia_port_op tx,
+ pjmedia_port_op rx);
+
+
+/**
+ * Enable unidirectional audio from the specified source slot to the
+ * specified sink slot.
+ *
+ * @param conf The conference bridge.
+ * @param src_slot Source slot.
+ * @param sink_slot Sink slot.
+ * @param level This argument is reserved for future improvements
+ * where it is possible to adjust the level of signal
+ * transmitted in a specific connection. For now,
+ * this argument MUST be zero.
+ *
+ * @return PJ_SUCCES on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_connect_port( pjmedia_conf *conf,
+ unsigned src_slot,
+ unsigned sink_slot,
+ int level );
+
+
+/**
+ * Disconnect unidirectional audio from the specified source to the specified
+ * sink slot.
+ *
+ * @param conf The conference bridge.
+ * @param src_slot Source slot.
+ * @param sink_slot Sink slot.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_disconnect_port( pjmedia_conf *conf,
+ unsigned src_slot,
+ unsigned sink_slot );
+
+
+/**
+ * Get number of ports currently registered to the conference bridge.
+ *
+ * @param conf The conference bridge.
+ *
+ * @return Number of ports currently registered to the conference
+ * bridge.
+ */
+PJ_DECL(unsigned) pjmedia_conf_get_port_count(pjmedia_conf *conf);
+
+
+/**
+ * Get total number of ports connections currently set up in the bridge.
+ *
+ * @param conf The conference bridge.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(unsigned) pjmedia_conf_get_connect_count(pjmedia_conf *conf);
+
+
+/**
+ * Remove the specified port from the conference bridge.
+ *
+ * @param conf The conference bridge.
+ * @param slot The port index to be removed.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_remove_port( pjmedia_conf *conf,
+ unsigned slot );
+
+
+
+/**
+ * Enumerate occupied ports in the bridge.
+ *
+ * @param conf The conference bridge.
+ * @param ports Array of port numbers to be filled in.
+ * @param count On input, specifies the maximum number of ports
+ * in the array. On return, it will be filled with
+ * the actual number of ports.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_enum_ports( pjmedia_conf *conf,
+ unsigned ports[],
+ unsigned *count );
+
+
+/**
+ * Get port info.
+ *
+ * @param conf The conference bridge.
+ * @param slot Port index.
+ * @param info Pointer to receive the info.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_get_port_info( pjmedia_conf *conf,
+ unsigned slot,
+ pjmedia_conf_port_info *info);
+
+
+/**
+ * Get occupied ports info.
+ *
+ * @param conf The conference bridge.
+ * @param size On input, contains maximum number of infos
+ * to be retrieved. On output, contains the actual
+ * number of infos that have been copied.
+ * @param info Array of info.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_get_ports_info(pjmedia_conf *conf,
+ unsigned *size,
+ pjmedia_conf_port_info info[]
+ );
+
+
+/**
+ * Get last signal level transmitted to or received from the specified port.
+ * This will retrieve the "real-time" signal level of the audio as they are
+ * transmitted or received by the specified port. Application may call this
+ * function periodically to display the signal level to a VU meter.
+ *
+ * The signal level is an integer value in zero to 255, with zero indicates
+ * no signal, and 255 indicates the loudest signal level.
+ *
+ * @param conf The conference bridge.
+ * @param slot Slot number.
+ * @param tx_level Optional argument to receive the level of signal
+ * transmitted to the specified port (i.e. the direction
+ * is from the bridge to the port).
+ * @param rx_level Optional argument to receive the level of signal
+ * received from the port (i.e. the direction is from the
+ * port to the bridge).
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_get_signal_level(pjmedia_conf *conf,
+ unsigned slot,
+ unsigned *tx_level,
+ unsigned *rx_level);
+
+
+/**
+ * Adjust the level of signal received from the specified port.
+ * Application may adjust the level to make signal received from the port
+ * either louder or more quiet. The level adjustment is calculated with this
+ * formula: <b><tt>output = input * (adj_level+128) / 128</tt></b>. Using
+ * this, zero indicates no adjustment, the value -128 will mute the signal,
+ * and the value of +128 will make the signal 100% louder, +256 will make it
+ * 200% louder, etc.
+ *
+ * The level adjustment value will stay with the port until the port is
+ * removed from the bridge or new adjustment value is set. The current
+ * level adjustment value is reported in the media port info when
+ * the #pjmedia_conf_get_port_info() function is called.
+ *
+ * @param conf The conference bridge.
+ * @param slot Slot number of the port.
+ * @param adj_level Adjustment level, which must be greater than or equal
+ * to -128. A value of zero means there is no level
+ * adjustment to be made, the value -128 will mute the
+ * signal, and the value of +128 will make the signal
+ * 100% louder, +256 will make it 200% louder, etc.
+ * See the function description for the formula.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_adjust_rx_level( pjmedia_conf *conf,
+ unsigned slot,
+ int adj_level );
+
+
+/**
+ * Adjust the level of signal to be transmitted to the specified port.
+ * Application may adjust the level to make signal transmitted to the port
+ * either louder or more quiet. The level adjustment is calculated with this
+ * formula: <b><tt>output = input * (adj_level+128) / 128</tt></b>. Using
+ * this, zero indicates no adjustment, the value -128 will mute the signal,
+ * and the value of +128 will make the signal 100% louder, +256 will make it
+ * 200% louder, etc.
+ *
+ * The level adjustment value will stay with the port until the port is
+ * removed from the bridge or new adjustment value is set. The current
+ * level adjustment value is reported in the media port info when
+ * the #pjmedia_conf_get_port_info() function is called.
+ *
+ * @param conf The conference bridge.
+ * @param slot Slot number of the port.
+ * @param adj_level Adjustment level, which must be greater than or equal
+ * to -128. A value of zero means there is no level
+ * adjustment to be made, the value -128 will mute the
+ * signal, and the value of +128 will make the signal
+ * 100% louder, +256 will make it 200% louder, etc.
+ * See the function description for the formula.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_conf_adjust_tx_level( pjmedia_conf *conf,
+ unsigned slot,
+ int adj_level );
+
+
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_CONF_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/config.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/config.h new file mode 100644 index 0000000..abcfc30 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/config.h @@ -0,0 +1,833 @@ +/* $Id: config.h 2977 2009-10-29 09:39:17Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CONFIG_H__
+#define __PJMEDIA_CONFIG_H__
+
+/**
+ * @file pjmedia/config.h Compile time config
+ * @brief Contains some compile time constants.
+ */
+#include <pj/config.h>
+
+/**
+ * @defgroup PJMEDIA_BASE Base Types and Configurations
+ */
+
+/**
+ * @defgroup PJMEDIA_CONFIG Compile time configuration
+ * @ingroup PJMEDIA_BASE
+ * @brief Some compile time configuration settings.
+ * @{
+ */
+
+/*
+ * Include config_auto.h if autoconf is used (PJ_AUTOCONF is set)
+ */
+#if defined(PJ_AUTOCONF)
+# include <pjmedia/config_auto.h>
+#endif
+
+/**
+ * Specify whether we prefer to use audio switch board rather than
+ * conference bridge.
+ *
+ * Audio switch board is a kind of simplified version of conference
+ * bridge, but not really the subset of conference bridge. It has
+ * stricter rules on audio routing among the pjmedia ports and has
+ * no audio mixing capability. The power of it is it could work with
+ * encoded audio frames where conference brigde couldn't.
+ *
+ * Default: 0
+ */
+#ifndef PJMEDIA_CONF_USE_SWITCH_BOARD
+# define PJMEDIA_CONF_USE_SWITCH_BOARD 0
+#endif
+
+/*
+ * Types of sound stream backends.
+ */
+
+/**
+ * This macro has been deprecated in releasee 1.1. Please see
+ * http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more information.
+ */
+#if defined(PJMEDIA_SOUND_IMPLEMENTATION)
+# error PJMEDIA_SOUND_IMPLEMENTATION has been deprecated
+#endif
+
+/**
+ * This macro has been deprecated in releasee 1.1. Please see
+ * http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more information.
+ */
+#if defined(PJMEDIA_PREFER_DIRECT_SOUND)
+# error PJMEDIA_PREFER_DIRECT_SOUND has been deprecated
+#endif
+
+/**
+ * This macro controls whether the legacy sound device API is to be
+ * implemented, for applications that still use the old sound device
+ * API (sound.h). If this macro is set to non-zero, the sound_legacy.c
+ * will be included in the compilation. The sound_legacy.c is an
+ * implementation of old sound device (sound.h) using the new Audio
+ * Device API.
+ *
+ * Please see http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more
+ * info.
+ */
+#ifndef PJMEDIA_HAS_LEGACY_SOUND_API
+# define PJMEDIA_HAS_LEGACY_SOUND_API 1
+#endif
+
+/**
+ * Specify default sound device latency, in milisecond.
+ */
+#ifndef PJMEDIA_SND_DEFAULT_REC_LATENCY
+# define PJMEDIA_SND_DEFAULT_REC_LATENCY 100
+#endif
+
+/**
+ * Specify default sound device latency, in milisecond.
+ *
+ * Default is 160ms for Windows Mobile and 140ms for other platforms.
+ */
+#ifndef PJMEDIA_SND_DEFAULT_PLAY_LATENCY
+# if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0
+# define PJMEDIA_SND_DEFAULT_PLAY_LATENCY 160
+# else
+# define PJMEDIA_SND_DEFAULT_PLAY_LATENCY 140
+# endif
+#endif
+
+
+/*
+ * Types of WSOLA backend algorithm.
+ */
+
+/**
+ * This denotes implementation of WSOLA using null algorithm. Expansion
+ * will generate zero frames, and compression will just discard some
+ * samples from the input.
+ *
+ * This type of implementation may be used as it requires the least
+ * processing power.
+ */
+#define PJMEDIA_WSOLA_IMP_NULL 0
+
+/**
+ * This denotes implementation of WSOLA using fixed or floating point WSOLA
+ * algorithm. This implementation provides the best quality of the result,
+ * at the expense of one frame delay and intensive processing power
+ * requirement.
+ */
+#define PJMEDIA_WSOLA_IMP_WSOLA 1
+
+/**
+ * This denotes implementation of WSOLA algorithm with faster waveform
+ * similarity calculation. This implementation provides fair quality of
+ * the result with the main advantage of low processing power requirement.
+ */
+#define PJMEDIA_WSOLA_IMP_WSOLA_LITE 2
+
+/**
+ * Specify type of Waveform based Similarity Overlap and Add (WSOLA) backend
+ * implementation to be used. WSOLA is an algorithm to expand and/or compress
+ * audio frames without changing the pitch, and used by the delaybuf and as PLC
+ * backend algorithm.
+ *
+ * Default is PJMEDIA_WSOLA_IMP_WSOLA
+ */
+#ifndef PJMEDIA_WSOLA_IMP
+# define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_WSOLA
+#endif
+
+
+/**
+ * Specify the default maximum duration of synthetic audio that is generated
+ * by WSOLA. This value should be long enough to cover burst of packet losses.
+ * but not too long, because as the duration increases the quality would
+ * degrade considerably.
+ *
+ * Note that this limit is only applied when fading is enabled in the WSOLA
+ * session.
+ *
+ * Default: 80
+ */
+#ifndef PJMEDIA_WSOLA_MAX_EXPAND_MSEC
+# define PJMEDIA_WSOLA_MAX_EXPAND_MSEC 80
+#endif
+
+
+/**
+ * Specify WSOLA template length, in milliseconds. The longer the template,
+ * the smoother signal to be generated at the expense of more computation
+ * needed, since the algorithm will have to compare more samples to find
+ * the most similar pitch.
+ *
+ * Default: 5
+ */
+#ifndef PJMEDIA_WSOLA_TEMPLATE_LENGTH_MSEC
+# define PJMEDIA_WSOLA_TEMPLATE_LENGTH_MSEC 5
+#endif
+
+
+/**
+ * Specify WSOLA algorithm delay, in milliseconds. The algorithm delay is
+ * used to merge synthetic samples with real samples in the transition
+ * between real to synthetic and vice versa. The longer the delay, the
+ * smoother signal to be generated, at the expense of longer latency and
+ * a slighty more computation.
+ *
+ * Default: 5
+ */
+#ifndef PJMEDIA_WSOLA_DELAY_MSEC
+# define PJMEDIA_WSOLA_DELAY_MSEC 5
+#endif
+
+
+/**
+ * Set this to non-zero to disable fade-out/in effect in the PLC when it
+ * instructs WSOLA to generate synthetic frames. The use of fading may
+ * or may not improve the quality of audio, depending on the nature of
+ * packet loss and the type of audio input (e.g. speech vs music).
+ * Disabling fading also implicitly remove the maximum limit of synthetic
+ * audio samples generated by WSOLA (see PJMEDIA_WSOLA_MAX_EXPAND_MSEC).
+ *
+ * Default: 0
+ */
+#ifndef PJMEDIA_WSOLA_PLC_NO_FADING
+# define PJMEDIA_WSOLA_PLC_NO_FADING 0
+#endif
+
+
+/**
+ * Specify number of sound buffers. Larger number is better for sound
+ * stability and to accommodate sound devices that are unable to send frames
+ * in timely manner, however it would probably cause more audio delay (and
+ * definitely will take more memory). One individual buffer is normally 10ms
+ * or 20 ms long, depending on ptime settings (samples_per_frame value).
+ *
+ * The setting here currently is used by the conference bridge, the splitter
+ * combiner port, and dsound.c.
+ *
+ * Default: (PJMEDIA_SND_DEFAULT_PLAY_LATENCY+20)/20
+ */
+#ifndef PJMEDIA_SOUND_BUFFER_COUNT
+# define PJMEDIA_SOUND_BUFFER_COUNT ((PJMEDIA_SND_DEFAULT_PLAY_LATENCY+20)/20)
+#endif
+
+
+/**
+ * Specify which A-law/U-law conversion algorithm to use.
+ * By default the conversion algorithm uses A-law/U-law table which gives
+ * the best performance, at the expense of 33 KBytes of static data.
+ * If this option is disabled, a smaller but slower algorithm will be used.
+ */
+#ifndef PJMEDIA_HAS_ALAW_ULAW_TABLE
+# define PJMEDIA_HAS_ALAW_ULAW_TABLE 1
+#endif
+
+
+/**
+ * Unless specified otherwise, G711 codec is included by default.
+ */
+#ifndef PJMEDIA_HAS_G711_CODEC
+# define PJMEDIA_HAS_G711_CODEC 1
+#endif
+
+
+/*
+ * Warn about obsolete macros.
+ *
+ * PJMEDIA_HAS_SMALL_FILTER has been deprecated in 0.7.
+ */
+#if defined(PJMEDIA_HAS_SMALL_FILTER)
+# ifdef _MSC_VER
+# pragma message("Warning: PJMEDIA_HAS_SMALL_FILTER macro is deprecated"\
+ " and has no effect")
+# else
+# warning "PJMEDIA_HAS_SMALL_FILTER macro is deprecated and has no effect"
+# endif
+#endif
+
+
+/*
+ * Warn about obsolete macros.
+ *
+ * PJMEDIA_HAS_LARGE_FILTER has been deprecated in 0.7.
+ */
+#if defined(PJMEDIA_HAS_LARGE_FILTER)
+# ifdef _MSC_VER
+# pragma message("Warning: PJMEDIA_HAS_LARGE_FILTER macro is deprecated"\
+ " and has no effect")
+# else
+# warning "PJMEDIA_HAS_LARGE_FILTER macro is deprecated"
+# endif
+#endif
+
+
+/*
+ * These macros are obsolete in 0.7.1 so it will trigger compilation error.
+ * Please use PJMEDIA_RESAMPLE_IMP to select the resample implementation
+ * to use.
+ */
+#ifdef PJMEDIA_HAS_LIBRESAMPLE
+# error "PJMEDIA_HAS_LIBRESAMPLE macro is deprecated. Use '#define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_LIBRESAMPLE'"
+#endif
+
+#ifdef PJMEDIA_HAS_SPEEX_RESAMPLE
+# error "PJMEDIA_HAS_SPEEX_RESAMPLE macro is deprecated. Use '#define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_SPEEX'"
+#endif
+
+
+/*
+ * Sample rate conversion backends.
+ * Select one of these backends in PJMEDIA_RESAMPLE_IMP.
+ */
+#define PJMEDIA_RESAMPLE_NONE 1 /**< No resampling. */
+#define PJMEDIA_RESAMPLE_LIBRESAMPLE 2 /**< Sample rate conversion
+ using libresample. */
+#define PJMEDIA_RESAMPLE_SPEEX 3 /**< Sample rate conversion
+ using Speex. */
+#define PJMEDIA_RESAMPLE_LIBSAMPLERATE 4 /**< Sample rate conversion
+ using libsamplerate
+ (a.k.a Secret Rabbit Code)
+ */
+
+/**
+ * Select which resample implementation to use. Currently pjmedia supports:
+ * - #PJMEDIA_RESAMPLE_LIBRESAMPLE, to use libresample-1.7, this is the default
+ * implementation to be used.
+ * - #PJMEDIA_RESAMPLE_LIBSAMPLERATE, to use libsamplerate implementation
+ * (a.k.a. Secret Rabbit Code).
+ * - #PJMEDIA_RESAMPLE_SPEEX, to use experimental sample rate conversion in
+ * Speex library.
+ * - #PJMEDIA_RESAMPLE_NONE, to disable sample rate conversion. Any calls to
+ * resample function will return error.
+ *
+ * Default is PJMEDIA_RESAMPLE_LIBRESAMPLE
+ */
+#ifndef PJMEDIA_RESAMPLE_IMP
+# define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_LIBRESAMPLE
+#endif
+
+
+/**
+ * Specify whether libsamplerate, when used, should be linked statically
+ * into the application. This option is only useful for Visual Studio
+ * projects, and when this static linking is enabled
+ */
+
+
+/**
+ * Default file player/writer buffer size.
+ */
+#ifndef PJMEDIA_FILE_PORT_BUFSIZE
+# define PJMEDIA_FILE_PORT_BUFSIZE 4000
+#endif
+
+
+/**
+ * Maximum frame duration (in msec) to be supported.
+ * This (among other thing) will affect the size of buffers to be allocated
+ * for outgoing packets.
+ */
+#ifndef PJMEDIA_MAX_FRAME_DURATION_MS
+# define PJMEDIA_MAX_FRAME_DURATION_MS 200
+#endif
+
+
+/**
+ * Max packet size to support.
+ */
+#ifndef PJMEDIA_MAX_MTU
+# define PJMEDIA_MAX_MTU 1500
+#endif
+
+
+/**
+ * DTMF/telephone-event duration, in timestamp.
+ */
+#ifndef PJMEDIA_DTMF_DURATION
+# define PJMEDIA_DTMF_DURATION 1600 /* in timestamp */
+#endif
+
+
+/**
+ * Number of packets received from different source IP address from the
+ * remote address required to make the stream switch transmission
+ * to the source address.
+ */
+#ifndef PJMEDIA_RTP_NAT_PROBATION_CNT
+# define PJMEDIA_RTP_NAT_PROBATION_CNT 10
+#endif
+
+
+/**
+ * Specify whether RTCP should be advertised in SDP. This setting would
+ * affect whether RTCP candidate will be added in SDP when ICE is used.
+ * Application might want to disable RTCP advertisement in SDP to
+ * reduce the message size.
+ *
+ * Default: 1 (yes)
+ */
+#ifndef PJMEDIA_ADVERTISE_RTCP
+# define PJMEDIA_ADVERTISE_RTCP 1
+#endif
+
+
+/**
+ * Interval to send RTCP packets, in msec
+ */
+#ifndef PJMEDIA_RTCP_INTERVAL
+# define PJMEDIA_RTCP_INTERVAL 5000 /* msec*/
+#endif
+
+
+/**
+ * Tell RTCP to ignore the first N packets when calculating the
+ * jitter statistics. From experimentation, the first few packets
+ * (25 or so) have relatively big jitter, possibly because during
+ * this time, the program is also busy setting up the signaling,
+ * so they make the average jitter big.
+ *
+ * Default: 25.
+ */
+#ifndef PJMEDIA_RTCP_IGNORE_FIRST_PACKETS
+# define PJMEDIA_RTCP_IGNORE_FIRST_PACKETS 25
+#endif
+
+/**
+ * Specify whether RTCP XR support should be built into PJMEDIA. Disabling
+ * this feature will reduce footprint slightly. Note that even when this
+ * setting is enabled, RTCP XR processing will only be performed in stream
+ * if it is enabled on run-time on per stream basis. See
+ * PJMEDIA_STREAM_ENABLE_XR setting for more info.
+ *
+ * Default: 1 (yes).
+ */
+#ifndef PJMEDIA_HAS_RTCP_XR
+# define PJMEDIA_HAS_RTCP_XR 0
+#endif
+
+
+/**
+ * The RTCP XR feature is activated and used by stream if \a enable_rtcp_xr
+ * field of \a pjmedia_stream_info structure is non-zero. This setting
+ * controls the default value of this field.
+ *
+ * Default: 0 (disabled)
+ */
+#ifndef PJMEDIA_STREAM_ENABLE_XR
+# define PJMEDIA_STREAM_ENABLE_XR 0
+#endif
+
+/**
+ * Specify how long (in miliseconds) the stream should suspend the
+ * silence detector/voice activity detector (VAD) during the initial
+ * period of the session. This feature is useful to open bindings in
+ * all NAT routers between local and remote endpoint since most NATs
+ * do not allow incoming packet to get in before local endpoint sends
+ * outgoing packets.
+ *
+ * Specify zero to disable this feature.
+ *
+ * Default: 600 msec (which gives good probability that some RTP
+ * packets will reach the destination, but without
+ * filling up the jitter buffer on the remote end).
+ */
+#ifndef PJMEDIA_STREAM_VAD_SUSPEND_MSEC
+# define PJMEDIA_STREAM_VAD_SUSPEND_MSEC 600
+#endif
+
+
+/**
+ * Specify the maximum duration of silence period in the codec, in msec.
+ * This is useful for example to keep NAT binding open in the firewall
+ * and to prevent server from disconnecting the call because no
+ * RTP packet is received.
+ *
+ * This only applies to codecs that use PJMEDIA's VAD (pretty much
+ * everything including iLBC, except Speex, which has its own DTX
+ * mechanism).
+ *
+ * Use (-1) to disable this feature.
+ *
+ * Default: 5000 ms
+ *
+ */
+#ifndef PJMEDIA_CODEC_MAX_SILENCE_PERIOD
+# define PJMEDIA_CODEC_MAX_SILENCE_PERIOD 5000
+#endif
+
+
+/**
+ * Suggested or default threshold to be set for fixed silence detection
+ * or as starting threshold for adaptive silence detection. The threshold
+ * has the range from zero to 0xFFFF.
+ */
+#ifndef PJMEDIA_SILENCE_DET_THRESHOLD
+# define PJMEDIA_SILENCE_DET_THRESHOLD 4
+#endif
+
+
+/**
+ * Maximum silence threshold in the silence detector. The silence detector
+ * will not cut the audio transmission if the audio level is above this
+ * level.
+ *
+ * Use 0x10000 (or greater) to disable this feature.
+ *
+ * Default: 0x10000 (disabled)
+ */
+#ifndef PJMEDIA_SILENCE_DET_MAX_THRESHOLD
+# define PJMEDIA_SILENCE_DET_MAX_THRESHOLD 0x10000
+#endif
+
+
+/**
+ * Speex Accoustic Echo Cancellation (AEC).
+ * By default is enabled.
+ */
+#ifndef PJMEDIA_HAS_SPEEX_AEC
+# define PJMEDIA_HAS_SPEEX_AEC 1
+#endif
+
+
+/**
+ * This specifies the behavior of the SDP negotiator when responding to an
+ * offer, whether it should rather use the codec preference as set by
+ * remote, or should it rather use the codec preference as specified by
+ * local endpoint.
+ *
+ * For example, suppose incoming call has codec order "8 0 3", while
+ * local codec order is "3 0 8". If remote codec order is preferable,
+ * the selected codec will be 8, while if local codec order is preferable,
+ * the selected codec will be 3.
+ *
+ * If set to non-zero, the negotiator will use the codec order as specified
+ * by remote in the offer.
+ *
+ * Note that this behavior can be changed during run-time by calling
+ * pjmedia_sdp_neg_set_prefer_remote_codec_order().
+ *
+ * Default is 1 (to maintain backward compatibility)
+ */
+#ifndef PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER
+# define PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER 1
+#endif
+
+
+/**
+ * Support for sending and decoding RTCP port in SDP (RFC 3605).
+ * Default is equal to PJMEDIA_ADVERTISE_RTCP setting.
+ */
+#ifndef PJMEDIA_HAS_RTCP_IN_SDP
+# define PJMEDIA_HAS_RTCP_IN_SDP (PJMEDIA_ADVERTISE_RTCP)
+#endif
+
+
+/**
+ * This macro controls whether pjmedia should include SDP rtpmap
+ * attribute for static payload types. SDP rtpmap for static
+ * payload types are optional, although they are normally included
+ * for interoperability reason.
+ *
+ * Note that there is also a run-time variable to turn this setting
+ * on or off, defined in endpoint.c. To access this variable, use
+ * the following construct
+ *
+ \verbatim
+ extern pj_bool_t pjmedia_add_rtpmap_for_static_pt;
+
+ // Do not include rtpmap for static payload types (<96)
+ pjmedia_add_rtpmap_for_static_pt = PJ_FALSE;
+ \endverbatim
+ *
+ * Default: 1 (yes)
+ */
+#ifndef PJMEDIA_ADD_RTPMAP_FOR_STATIC_PT
+# define PJMEDIA_ADD_RTPMAP_FOR_STATIC_PT 1
+#endif
+
+
+/**
+ * This macro declares the payload type for telephone-event
+ * that is advertised by PJMEDIA for outgoing SDP. If this macro
+ * is set to zero, telephone events would not be advertised nor
+ * supported.
+ *
+ * If this value is changed to other number, please update the
+ * PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR too.
+ */
+#ifndef PJMEDIA_RTP_PT_TELEPHONE_EVENTS
+# define PJMEDIA_RTP_PT_TELEPHONE_EVENTS 101
+#endif
+
+
+/**
+ * Macro to get the string representation of the telephone-event
+ * payload type.
+ */
+#ifndef PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR
+# define PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR "101"
+#endif
+
+
+/**
+ * Maximum tones/digits that can be enqueued in the tone generator.
+ */
+#ifndef PJMEDIA_TONEGEN_MAX_DIGITS
+# define PJMEDIA_TONEGEN_MAX_DIGITS 32
+#endif
+
+
+/*
+ * Below specifies the various tone generator backend algorithm.
+ */
+
+/**
+ * The math's sine(), floating point. This has very good precision
+ * but it's the slowest and requires floating point support and
+ * linking with the math library.
+ */
+#define PJMEDIA_TONEGEN_SINE 1
+
+/**
+ * Floating point approximation of sine(). This has relatively good
+ * precision and much faster than plain sine(), but it requires floating-
+ * point support and linking with the math library.
+ */
+#define PJMEDIA_TONEGEN_FLOATING_POINT 2
+
+/**
+ * Fixed point using sine signal generated by Cordic algorithm. This
+ * algorithm can be tuned to provide balance between precision and
+ * performance by tuning the PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP
+ * setting, and may be suitable for platforms that lack floating-point
+ * support.
+ */
+#define PJMEDIA_TONEGEN_FIXED_POINT_CORDIC 3
+
+/**
+ * Fast fixed point using some approximation to generate sine waves.
+ * The tone generated by this algorithm is not very precise, however
+ * the algorithm is very fast.
+ */
+#define PJMEDIA_TONEGEN_FAST_FIXED_POINT 4
+
+
+/**
+ * Specify the tone generator algorithm to be used. Please see
+ * http://trac.pjsip.org/repos/wiki/Tone_Generator for the performance
+ * analysis results of the various tone generator algorithms.
+ *
+ * Default value:
+ * - PJMEDIA_TONEGEN_FLOATING_POINT when PJ_HAS_FLOATING_POINT is set
+ * - PJMEDIA_TONEGEN_FIXED_POINT_CORDIC when PJ_HAS_FLOATING_POINT is not set
+ */
+#ifndef PJMEDIA_TONEGEN_ALG
+# if defined(PJ_HAS_FLOATING_POINT) && PJ_HAS_FLOATING_POINT
+# define PJMEDIA_TONEGEN_ALG PJMEDIA_TONEGEN_FLOATING_POINT
+# else
+# define PJMEDIA_TONEGEN_ALG PJMEDIA_TONEGEN_FIXED_POINT_CORDIC
+# endif
+#endif
+
+
+/**
+ * Specify the number of calculation loops to generate the tone, when
+ * PJMEDIA_TONEGEN_FIXED_POINT_CORDIC algorithm is used. With more calculation
+ * loops, the tone signal gets more precise, but this will add more
+ * processing.
+ *
+ * Valid values are 1 to 28.
+ *
+ * Default value: 10
+ */
+#ifndef PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP
+# define PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP 10
+#endif
+
+
+/**
+ * Enable high quality of tone generation, the better quality will cost
+ * more CPU load. This is only applied to floating point enabled machines.
+ *
+ * By default it is enabled when PJ_HAS_FLOATING_POINT is set.
+ *
+ * This macro has been deprecated in version 1.0-rc3.
+ */
+#ifdef PJMEDIA_USE_HIGH_QUALITY_TONEGEN
+# error "The PJMEDIA_USE_HIGH_QUALITY_TONEGEN macro is obsolete"
+#endif
+
+
+/**
+ * Fade-in duration for the tone, in milliseconds. Set to zero to disable
+ * this feature.
+ *
+ * Default: 1 (msec)
+ */
+#ifndef PJMEDIA_TONEGEN_FADE_IN_TIME
+# define PJMEDIA_TONEGEN_FADE_IN_TIME 1
+#endif
+
+
+/**
+ * Fade-out duration for the tone, in milliseconds. Set to zero to disable
+ * this feature.
+ *
+ * Default: 2 (msec)
+ */
+#ifndef PJMEDIA_TONEGEN_FADE_OUT_TIME
+# define PJMEDIA_TONEGEN_FADE_OUT_TIME 2
+#endif
+
+
+/**
+ * The default tone generator amplitude (1-32767).
+ *
+ * Default value: 12288
+ */
+#ifndef PJMEDIA_TONEGEN_VOLUME
+# define PJMEDIA_TONEGEN_VOLUME 12288
+#endif
+
+
+/**
+ * Enable support for SRTP media transport. This will require linking
+ * with libsrtp from the third_party directory.
+ *
+ * By default it is enabled.
+ */
+#ifndef PJMEDIA_HAS_SRTP
+# define PJMEDIA_HAS_SRTP 1
+#endif
+
+
+/**
+ * Enable support to handle codecs with inconsistent clock rate
+ * between clock rate in SDP/RTP & the clock rate that is actually used.
+ * This happens for example with G.722 and MPEG audio codecs.
+ * See:
+ * - G.722 : RFC 3551 4.5.2
+ * - MPEG audio : RFC 3551 4.5.13 & RFC 3119
+ *
+ * Also when this feature is enabled, some handling will be performed
+ * to deal with clock rate incompatibilities of some phones.
+ *
+ * By default it is enabled.
+ */
+#ifndef PJMEDIA_HANDLE_G722_MPEG_BUG
+# define PJMEDIA_HANDLE_G722_MPEG_BUG 1
+#endif
+
+
+/**
+ * Transport info (pjmedia_transport_info) contains a socket info and list
+ * of transport specific info, since transports can be chained together
+ * (for example, SRTP transport uses UDP transport as the underlying
+ * transport). This constant specifies maximum number of transport specific
+ * infos that can be held in a transport info.
+ */
+#ifndef PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXCNT
+# define PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXCNT 4
+#endif
+
+
+/**
+ * Maximum size in bytes of storage buffer of a transport specific info.
+ */
+#ifndef PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE
+# define PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE (16*sizeof(long))
+#endif
+
+
+/**
+ * Value to be specified in PJMEDIA_STREAM_ENABLE_KA setting.
+ * This indicates that an empty RTP packet should be used as
+ * the keep-alive packet.
+ */
+#define PJMEDIA_STREAM_KA_EMPTY_RTP 1
+
+/**
+ * Value to be specified in PJMEDIA_STREAM_ENABLE_KA setting.
+ * This indicates that a user defined packet should be used
+ * as the keep-alive packet. The content of the user-defined
+ * packet is specified by PJMEDIA_STREAM_KA_USER_PKT. Default
+ * content is a CR-LF packet.
+ */
+#define PJMEDIA_STREAM_KA_USER 2
+
+/**
+ * The content of the user defined keep-alive packet. The format
+ * of the packet is initializer to pj_str_t structure. Note that
+ * the content may contain NULL character.
+ */
+#ifndef PJMEDIA_STREAM_KA_USER_PKT
+# define PJMEDIA_STREAM_KA_USER_PKT { "\r\n", 2 }
+#endif
+
+/**
+ * Specify another type of keep-alive and NAT hole punching
+ * mechanism (the other type is PJMEDIA_STREAM_VAD_SUSPEND_MSEC
+ * and PJMEDIA_CODEC_MAX_SILENCE_PERIOD) to be used by stream.
+ * When this feature is enabled, the stream will initially
+ * transmit one packet to punch a hole in NAT, and periodically
+ * transmit keep-alive packets.
+ *
+ * When this alternative keep-alive mechanism is used, application
+ * may disable the other keep-alive mechanisms, i.e: by setting
+ * PJMEDIA_STREAM_VAD_SUSPEND_MSEC to zero and
+ * PJMEDIA_CODEC_MAX_SILENCE_PERIOD to -1.
+ *
+ * The value of this macro specifies the type of packet used
+ * for the keep-alive mechanism. Valid values are
+ * PJMEDIA_STREAM_KA_EMPTY_RTP and PJMEDIA_STREAM_KA_USER.
+ *
+ * The duration of the keep-alive interval further can be set
+ * with PJMEDIA_STREAM_KA_INTERVAL setting.
+ *
+ * Default: 0 (disabled)
+ */
+#ifndef PJMEDIA_STREAM_ENABLE_KA
+# define PJMEDIA_STREAM_ENABLE_KA 0
+#endif
+
+
+/**
+ * Specify the keep-alive interval of PJMEDIA_STREAM_ENABLE_KA
+ * mechanism, in seconds.
+ *
+ * Default: 5 seconds
+ */
+#ifndef PJMEDIA_STREAM_KA_INTERVAL
+# define PJMEDIA_STREAM_KA_INTERVAL 5
+#endif
+
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_CONFIG_H__ */
+
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/config_auto.h.in b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/config_auto.h.in new file mode 100644 index 0000000..3ec8773 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/config_auto.h.in @@ -0,0 +1,43 @@ +/* $Id: config_auto.h.in 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_CONFIG_AUTO_H_
+#define __PJMEDIA_CONFIG_AUTO_H_
+
+/**
+ * @file config_auto.h
+ * @brief PJMEDIA configuration as set by autoconf script
+ */
+
+/*
+ * Note:
+ * The configuration in config_site.h overrides any other settings,
+ * including the setting as detected by autoconf.
+ */
+
+/* G711 codec */
+#ifndef PJMEDIA_HAS_G711_CODEC
+#undef PJMEDIA_HAS_G711_CODEC
+#endif
+
+
+#endif /* __PJMEDIA_CONFIG_AUTO_H_ */
+
+
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/delaybuf.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/delaybuf.h new file mode 100644 index 0000000..fc6a3e6 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/delaybuf.h @@ -0,0 +1,158 @@ +/* $Id: delaybuf.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_DELAYBUF_H__
+#define __PJMEDIA_DELAYBUF_H__
+
+
+/**
+ * @file delaybuf.h
+ * @brief Delay Buffer.
+ */
+
+#include <pjmedia/types.h>
+
+/**
+ * @defgroup PJMED_DELAYBUF Adaptive Delay Buffer
+ * @ingroup PJMEDIA_FRAME_OP
+ * @brief Adaptive delay buffer with high-quality time-scale
+ * modification
+ * @{
+ *
+ * This section describes PJMEDIA's implementation of delay buffer.
+ * Delay buffer works quite similarly like a fixed jitter buffer, that
+ * is it will delay the frame retrieval by some interval so that caller
+ * will get continuous frame from the buffer. This can be useful when
+ * the put() and get() operations are not evenly interleaved, for example
+ * when caller performs burst of put() operations and then followed by
+ * burst of get() operations. With using this delay buffer, the buffer
+ * will put the burst frames into a buffer so that get() operations
+ * will always get a frame from the buffer (assuming that the number of
+ * get() and put() are matched).
+ *
+ * The buffer is adaptive, that is it continuously learns the optimal delay
+ * to be applied to the audio flow at run-time. Once the optimal delay has
+ * been learned, the delay buffer will apply this delay to the audio flow,
+ * expanding or shrinking the audio samples as necessary when the actual
+ * audio samples in the buffer are too low or too high. It does this without
+ * distorting the audio quality of the audio, by using \a PJMED_WSOLA.
+ *
+ * The delay buffer is used in \ref PJMED_SND_PORT, \ref PJMEDIA_SPLITCOMB,
+ * and \ref PJMEDIA_CONF.
+ */
+
+PJ_BEGIN_DECL
+
+/** Opaque declaration for delay buffer. */
+typedef struct pjmedia_delay_buf pjmedia_delay_buf;
+
+/**
+ * Create the delay buffer. Once the delay buffer is created, it will
+ * enter learning state unless the delay argument is specified, which
+ * in this case it will directly enter the running state.
+ *
+ * @param pool Pool where the delay buffer will be allocated
+ * from.
+ * @param name Optional name for the buffer for log
+ * identification.
+ * @param clock_rate Number of samples processed per second.
+ * @param samples_per_frame Number of samples per frame.
+ * @param channel_count Number of channel per frame.
+ * @param max_delay Maximum number of delay to be accommodated,
+ * in ms, if this value is negative or less than
+ * one frame time, default maximum delay used is
+ * 400 ms.
+ * @param option Option flags, must be zero for now.
+ * @param p_b Pointer to receive the delay buffer instance.
+ *
+ * @return PJ_SUCCESS if the delay buffer has been
+ * created successfully, otherwise the appropriate
+ * error will be returned.
+ */
+PJ_DECL(pj_status_t) pjmedia_delay_buf_create(pj_pool_t *pool,
+ const char *name,
+ unsigned clock_rate,
+ unsigned samples_per_frame,
+ unsigned channel_count,
+ unsigned max_delay,
+ unsigned options,
+ pjmedia_delay_buf **p_b);
+
+/**
+ * Put one frame into the buffer.
+ *
+ * @param b The delay buffer.
+ * @param frame Frame to be put into the buffer. This frame
+ * must have samples_per_frame length.
+ *
+ * @return PJ_SUCCESS if frames can be put successfully.
+ * PJ_EPENDING if the buffer is still at learning
+ * state. PJ_ETOOMANY if the number of frames
+ * will exceed maximum delay level, which in this
+ * case the new frame will overwrite the oldest
+ * frame in the buffer.
+ */
+PJ_DECL(pj_status_t) pjmedia_delay_buf_put(pjmedia_delay_buf *b,
+ pj_int16_t frame[]);
+
+/**
+ * Get one frame from the buffer.
+ *
+ * @param b The delay buffer.
+ * @param frame Buffer to receive the frame from the delay
+ * buffer.
+ *
+ * @return PJ_SUCCESS if frame has been copied successfully.
+ * PJ_EPENDING if no frame is available, either
+ * because the buffer is still at learning state or
+ * no buffer is available during running state.
+ * On non-successful return, the frame will be
+ * filled with zeroes.
+ */
+PJ_DECL(pj_status_t) pjmedia_delay_buf_get(pjmedia_delay_buf *b,
+ pj_int16_t frame[]);
+
+/**
+ * Reset delay buffer. This will clear the buffer's content. But keep
+ * the learning result.
+ *
+ * @param b The delay buffer.
+ *
+ * @return PJ_SUCCESS on success or the appropriate error.
+ */
+PJ_DECL(pj_status_t) pjmedia_delay_buf_reset(pjmedia_delay_buf *b);
+
+/**
+ * Destroy delay buffer.
+ *
+ * @param b Delay buffer session.
+ *
+ * @return PJ_SUCCESS normally.
+ */
+PJ_DECL(pj_status_t) pjmedia_delay_buf_destroy(pjmedia_delay_buf *b);
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_DELAYBUF_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/doxygen.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/doxygen.h new file mode 100644 index 0000000..945b6c5 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/doxygen.h @@ -0,0 +1,174 @@ +/* $Id: doxygen.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_DOXYGEN_H__
+#define __PJMEDIA_DOXYGEN_H__
+
+/**
+ * @file doxygen.h
+ * @brief Doxygen's mainpage.
+ */
+
+
+/*////////////////////////////////////////////////////////////////////////// */
+/*
+ INTRODUCTION PAGE
+ */
+
+/**
+ * @mainpage PJMEDIA and PJMEDIA-CODEC
+ *
+ * \n
+ * @section intro_sec PJMEDIA
+ *
+ * PJMEDIA is a rather complete media stack, distributed under Open Source/GPL
+ * terms, and featuring small footprint and good extensibility and portability.
+ *
+ * Please click the <A HREF="modules.htm"><b>Table of Contents</b></A> link on top
+ * of this page to get the complete features currently present in PJMEDIA.
+ *
+ * Also please read the documentation about @ref PJMEDIA_PORT
+ * which is a major concept that is used for implementing many objects in
+ * the library.
+ *
+ * \n
+ * @section pjmedia_codec_sec PJMEDIA-CODEC
+ *
+ * PJMEDIA-CODEC is a static library containing various codec implementations,
+ * wrapped into PJMEDIA codec framework. The static library is designed as
+ * such so that only codecs that are explicitly initialized are linked with
+ * the application, therefore keeping the application size in control.
+ *
+ * Please see @ref pjmedia_codec_page on how to use the codec in
+ * PJMEDIA-CODEC.
+ *
+ * \n
+ * @section main_page_get_start_sec Getting Started
+ *
+ * For those who likes to just get start coding, the @ref getting_started_pjmedia
+ * may be a good place to start.
+ *
+ * The @ref page_pjmedia_samples page describes some examples that are available
+ * in the source tree.
+ *
+ *
+ * \n
+ * @section pjmedia_lic Copying and Acknowledgements
+ *
+ * PJMEDIA and PJMEDIA-CODEC contains various parts obtained from other
+ * places, and each of these would have their own licensing terms.
+ * Please see @ref lic_stuffs page for details.
+ *
+ */
+
+
+/**
+ @page page_pjmedia_samples PJMEDIA and PJMEDIA-CODEC Examples
+
+ @section pjmedia_samples_sec PJMEDIA and PJMEDIA-CODEC Examples
+
+ Please find below some PJMEDIA related examples that may help in giving
+ some more info:
+
+ - @ref page_pjmedia_samples_level_c\n
+ This is a good place to start learning about @ref PJMEDIA_PORT,
+ as it shows that @ref PJMEDIA_PORT are only "passive" objects
+ with <tt>get_frame()</tt> and <tt>put_frame()</tt> interface, and
+ someone has to call these to retrieve/store media frames.
+
+ - @ref page_pjmedia_samples_playfile_c\n
+ This example shows that when application connects a media port (in this
+ case a @ref PJMEDIA_FILE_PLAY) to @ref PJMED_SND_PORT, media will flow
+ automatically since the @ref PJMED_SND_PORT provides @ref PJMEDIA_PORT_CLOCK.
+
+ - @ref page_pjmedia_samples_recfile_c\n
+ Demonstrates how to capture audio from microphone to WAV file.
+
+ - @ref page_pjmedia_samples_playsine_c\n
+ Demonstrates how to create a custom @ref PJMEDIA_PORT (in this
+ case a sine wave generator) and integrate it to PJMEDIA.
+
+ - @ref page_pjmedia_samples_confsample_c\n
+ This demonstrates how to use the @ref PJMEDIA_CONF. The sample program can
+ open multiple WAV files, and instruct the conference bridge to mix the
+ signal before playing it to the sound device.
+
+ - @ref page_pjmedia_samples_confbench_c\n
+ I use this to benchmark/optimize the conference bridge algorithm, but
+ readers may find the source useful.
+
+ - @ref page_pjmedia_samples_resampleplay_c\n
+ Demonstrates how to use @ref PJMEDIA_RESAMPLE_PORT to change the
+ sampling rate of a media port (in this case, a @ref PJMEDIA_FILE_PLAY).
+
+ - @ref page_pjmedia_samples_sndtest_c\n
+ This program performs some tests to the sound device to get some
+ quality parameters (such as sound jitter and clock drifts).\n
+ Screenshots on WinXP: \image html sndtest.jpg "sndtest screenshot on WinXP"
+
+ - @ref page_pjmedia_samples_streamutil_c\n
+ This example mainly demonstrates how to stream media (in this case a
+ @ref PJMEDIA_FILE_PLAY) to remote peer using RTP.
+
+ - @ref page_pjmedia_samples_siprtp_c\n
+ This is a useful program (integrated with PJSIP) to actively measure
+ the network quality/impairment parameters by making one or more SIP
+ calls (or receiving one or more SIP calls) and display the network
+ impairment of each stream direction at the end of the call.
+ The program is able to measure network quality parameters such as
+ jitter, packet lost/reorder/duplicate, round trip time, etc.\n
+ Note that the remote peer MUST support RTCP so that network quality
+ of each direction can be calculated. Using siprtp for both endpoints
+ is recommended.\n
+ Screenshots on WinXP: \image html siprtp.jpg "siprtp screenshot on WinXP"
+
+ - @ref page_pjmedia_samples_tonegen_c\n
+ This is a simple program to generate a tone and write the samples to
+ a raw PCM file. The main purpose of this file is to analyze the
+ quality of the tones/sine wave generated by PJMEDIA tone/sine wave
+ generator.
+
+ - @ref page_pjmedia_samples_aectest_c\n
+ Play a file to speaker, run AEC, and record the microphone input
+ to see if echo is coming.
+ */
+
+/**
+ * \page page_pjmedia_samples_siprtp_c Samples: Using SIP and Custom RTP/RTCP to Monitor Quality
+ *
+ * This source is an example to demonstrate using SIP and RTP/RTCP framework
+ * to measure the network quality/impairment from the SIP call. This
+ * program can be used to make calls or to receive calls from other
+ * SIP endpoint (or other siprtp program), and to display the media
+ * quality statistics at the end of the call.
+ *
+ * Note that the remote peer must support RTCP.
+ *
+ * The layout of the program has been designed so that custom reporting
+ * can be generated instead of plain human readable text.
+ *
+ * The source code of the file is pjsip-apps/src/samples/siprtp.c
+ *
+ * Screenshots on WinXP: \image html siprtp.jpg
+ *
+ * \includelineno siprtp.c
+ */
+
+#endif /* __PJMEDIA_DOXYGEN_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/echo.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/echo.h new file mode 100644 index 0000000..d8a4ec1 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/echo.h @@ -0,0 +1,247 @@ +/* $Id: echo.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_ECHO_H__
+#define __PJMEDIA_ECHO_H__
+
+
+/**
+ * @file echo.h
+ * @brief Echo Cancellation API.
+ */
+#include <pjmedia/types.h>
+
+
+
+/**
+ * @defgroup PJMEDIA_Echo_Cancel Accoustic Echo Cancellation API
+ * @ingroup PJMEDIA_PORT
+ * @brief Echo Cancellation API.
+ * @{
+ *
+ * This section describes API to perform echo cancellation to audio signal.
+ * There may be multiple echo canceller implementation in PJMEDIA, ranging
+ * from simple echo suppressor to a full Accoustic Echo Canceller/AEC. By
+ * using this API, application should be able to use which EC backend to
+ * use base on the requirement and capability of the platform.
+ */
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Opaque type for PJMEDIA Echo Canceller state.
+ */
+typedef struct pjmedia_echo_state pjmedia_echo_state;
+
+
+/**
+ * Echo cancellation options.
+ */
+typedef enum pjmedia_echo_flag
+{
+ /**
+ * Use any available backend echo canceller algorithm. This is
+ * the default settings. This setting is mutually exclusive with
+ * PJMEDIA_ECHO_SIMPLE and PJMEDIA_ECHO_SPEEX.
+ */
+ PJMEDIA_ECHO_DEFAULT= 0,
+
+ /**
+ * Force to use Speex AEC as the backend echo canceller algorithm.
+ * This setting is mutually exclusive with PJMEDIA_ECHO_SIMPLE.
+ */
+ PJMEDIA_ECHO_SPEEX = 1,
+
+ /**
+ * If PJMEDIA_ECHO_SIMPLE flag is specified during echo canceller
+ * creation, then a simple echo suppressor will be used instead of
+ * an accoustic echo cancellation. This setting is mutually exclusive
+ * with PJMEDIA_ECHO_SPEEX.
+ */
+ PJMEDIA_ECHO_SIMPLE = 2,
+
+ /**
+ * For internal use.
+ */
+ PJMEDIA_ECHO_ALGO_MASK = 15,
+
+ /**
+ * If PJMEDIA_ECHO_NO_LOCK flag is specified, no mutex will be created
+ * for the echo canceller, but application will guarantee that echo
+ * canceller will not be called by different threads at the same time.
+ */
+ PJMEDIA_ECHO_NO_LOCK = 16
+
+} pjmedia_echo_flag;
+
+
+
+
+/**
+ * Create the echo canceller.
+ *
+ * @param pool Pool to allocate memory.
+ * @param clock_rate Media clock rate/sampling rate.
+ * @param samples_per_frame Number of samples per frame.
+ * @param tail_ms Tail length, miliseconds.
+ * @param latency_ms Total lacency introduced by playback and
+ * recording device. Set to zero if the latency
+ * is not known.
+ * @param options Options. If PJMEDIA_ECHO_SIMPLE is specified,
+ * then a simple echo suppressor implementation
+ * will be used instead of an accoustic echo
+ * cancellation.
+ * See #pjmedia_echo_flag for other options.
+ * @param p_echo Pointer to receive the Echo Canceller state.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate status.
+ */
+PJ_DECL(pj_status_t) pjmedia_echo_create(pj_pool_t *pool,
+ unsigned clock_rate,
+ unsigned samples_per_frame,
+ unsigned tail_ms,
+ unsigned latency_ms,
+ unsigned options,
+ pjmedia_echo_state **p_echo );
+
+/**
+ * Create multi-channel the echo canceller.
+ *
+ * @param pool Pool to allocate memory.
+ * @param clock_rate Media clock rate/sampling rate.
+ * @param channel_count Number of channels.
+ * @param samples_per_frame Number of samples per frame.
+ * @param tail_ms Tail length, miliseconds.
+ * @param latency_ms Total lacency introduced by playback and
+ * recording device. Set to zero if the latency
+ * is not known.
+ * @param options Options. If PJMEDIA_ECHO_SIMPLE is specified,
+ * then a simple echo suppressor implementation
+ * will be used instead of an accoustic echo
+ * cancellation.
+ * See #pjmedia_echo_flag for other options.
+ * @param p_echo Pointer to receive the Echo Canceller state.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate status.
+ */
+PJ_DECL(pj_status_t) pjmedia_echo_create2(pj_pool_t *pool,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned tail_ms,
+ unsigned latency_ms,
+ unsigned options,
+ pjmedia_echo_state **p_echo );
+
+/**
+ * Destroy the Echo Canceller.
+ *
+ * @param echo The Echo Canceller.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_echo_destroy(pjmedia_echo_state *echo );
+
+
+/**
+ * Reset the echo canceller.
+ *
+ * @param echo The Echo Canceller.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_echo_reset(pjmedia_echo_state *echo );
+
+
+/**
+ * Let the Echo Canceller know that a frame has been played to the speaker.
+ * The Echo Canceller will keep the frame in its internal buffer, to be used
+ * when cancelling the echo with #pjmedia_echo_capture().
+ *
+ * @param echo The Echo Canceller.
+ * @param play_frm Sample buffer containing frame to be played
+ * (or has been played) to the playback device.
+ * The frame must contain exactly samples_per_frame
+ * number of samples.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_echo_playback(pjmedia_echo_state *echo,
+ pj_int16_t *play_frm );
+
+
+/**
+ * Let the Echo Canceller know that a frame has been captured from the
+ * microphone. The Echo Canceller will cancel the echo from the captured
+ * signal, using the internal buffer (supplied by #pjmedia_echo_playback())
+ * as the FES (Far End Speech) reference.
+ *
+ * @param echo The Echo Canceller.
+ * @param rec_frm On input, it contains the input signal (captured
+ * from microphone) which echo is to be removed.
+ * Upon returning this function, this buffer contain
+ * the processed signal with the echo removed.
+ * The frame must contain exactly samples_per_frame
+ * number of samples.
+ * @param options Echo cancellation options, reserved for future use.
+ * Put zero for now.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_echo_capture(pjmedia_echo_state *echo,
+ pj_int16_t *rec_frm,
+ unsigned options );
+
+
+/**
+ * Perform echo cancellation.
+ *
+ * @param echo The Echo Canceller.
+ * @param rec_frm On input, it contains the input signal (captured
+ * from microphone) which echo is to be removed.
+ * Upon returning this function, this buffer contain
+ * the processed signal with the echo removed.
+ * @param play_frm Sample buffer containing frame to be played
+ * (or has been played) to the playback device.
+ * The frame must contain exactly samples_per_frame
+ * number of samples.
+ * @param options Echo cancellation options, reserved for future use.
+ * Put zero for now.
+ * @param reserved Reserved for future use, put NULL for now.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_echo_cancel( pjmedia_echo_state *echo,
+ pj_int16_t *rec_frm,
+ const pj_int16_t *play_frm,
+ unsigned options,
+ void *reserved );
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_ECHO_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/echo_port.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/echo_port.h new file mode 100644 index 0000000..e0e1737 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/echo_port.h @@ -0,0 +1,74 @@ +/* $Id: echo_port.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_AEC_PORT_H__
+#define __PJMEDIA_AEC_PORT_H__
+
+/**
+ * @file echo_port.h
+ * @brief AEC (Accoustic Echo Cancellation) media port.
+ */
+#include <pjmedia/port.h>
+
+
+
+/**
+ * @defgroup PJMEDIA_ECHO_PORT Echo Cancellation Port
+ * @ingroup PJMEDIA_PORT
+ * @brief Echo Cancellation
+ * @{
+ *
+ * Wrapper to \ref PJMEDIA_Echo_Cancel into media port interface.
+ */
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Create echo canceller port.
+ *
+ * @param pool Pool to allocate memory.
+ * @param dn_port Downstream port.
+ * @param tail_ms Tail length in miliseconds.
+ * @param latency_ms Total lacency introduced by playback and
+ * recording device. Set to zero if the latency
+ * is not known.
+ * @param options Options, as in #pjmedia_echo_create().
+ * @param p_port Pointer to receive the port instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_echo_port_create(pj_pool_t *pool,
+ pjmedia_port *dn_port,
+ unsigned tail_ms,
+ unsigned latency_ms,
+ unsigned options,
+ pjmedia_port **p_port );
+
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_AEC_PORT_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/endpoint.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/endpoint.h new file mode 100644 index 0000000..f52275e --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/endpoint.h @@ -0,0 +1,177 @@ +/* $Id: endpoint.h 2506 2009-03-12 18:11:37Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_MEDIAMGR_H__
+#define __PJMEDIA_MEDIAMGR_H__
+
+
+/**
+ * @file endpoint.h
+ * @brief Media endpoint.
+ */
+/**
+ * @defgroup PJMED_ENDPT The Endpoint
+ * @{
+ *
+ * The media endpoint acts as placeholder for endpoint capabilities. Each
+ * media endpoint will have a codec manager to manage list of codecs installed
+ * in the endpoint and a sound device factory.
+ *
+ * A reference to media endpoint instance is required when application wants
+ * to create a media session (#pjmedia_session_create()).
+ */
+
+#include <pjmedia/codec.h>
+#include <pjmedia/sdp.h>
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Create an instance of media endpoint.
+ *
+ * @param pf Pool factory, which will be used by the media endpoint
+ * throughout its lifetime.
+ * @param ioqueue Optional ioqueue instance to be registered to the
+ * endpoint. The ioqueue instance is used to poll all RTP
+ * and RTCP sockets. If this argument is NULL, the
+ * endpoint will create an internal ioqueue instance.
+ * @param worker_cnt Specify the number of worker threads to be created
+ * to poll the ioqueue.
+ * @param p_endpt Pointer to receive the endpoint instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_endpt_create( pj_pool_factory *pf,
+ pj_ioqueue_t *ioqueue,
+ unsigned worker_cnt,
+ pjmedia_endpt **p_endpt);
+
+/**
+ * Destroy media endpoint instance.
+ *
+ * @param endpt Media endpoint instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_endpt_destroy(pjmedia_endpt *endpt);
+
+
+
+/**
+ * Get the ioqueue instance of the media endpoint.
+ *
+ * @param endpt The media endpoint instance.
+ *
+ * @return The ioqueue instance of the media endpoint.
+ */
+PJ_DECL(pj_ioqueue_t*) pjmedia_endpt_get_ioqueue(pjmedia_endpt *endpt);
+
+
+/**
+ * Get the number of worker threads on the media endpoint
+ *
+ * @param endpt The media endpoint instance.
+ * @return The number of worker threads on the media endpoint
+ */
+PJ_DECL(unsigned) pjmedia_endpt_get_thread_count(pjmedia_endpt *endpt);
+
+/**
+ * Get a reference to one of the worker threads of the media endpoint
+ *
+ * @param endpt The media endpoint instance.
+ * @param index The index of the thread: 0<= index < thread_cnt
+ *
+ * @return pj_thread_t or NULL
+ */
+PJ_DECL(pj_thread_t*) pjmedia_endpt_get_thread(pjmedia_endpt *endpt,
+ unsigned index);
+
+
+/**
+ * Request the media endpoint to create pool.
+ *
+ * @param endpt The media endpoint instance.
+ * @param name Name to be assigned to the pool.
+ * @param initial Initial pool size, in bytes.
+ * @param increment Increment size, in bytes.
+ *
+ * @return Memory pool.
+ */
+PJ_DECL(pj_pool_t*) pjmedia_endpt_create_pool( pjmedia_endpt *endpt,
+ const char *name,
+ pj_size_t initial,
+ pj_size_t increment);
+
+/**
+ * Get the codec manager instance of the media endpoint.
+ *
+ * @param endpt The media endpoint instance.
+ *
+ * @return The instance of codec manager belonging to
+ * this media endpoint.
+ */
+PJ_DECL(pjmedia_codec_mgr*) pjmedia_endpt_get_codec_mgr(pjmedia_endpt *endpt);
+
+
+/**
+ * Create a SDP session description that describes the endpoint
+ * capability.
+ *
+ * @param endpt The media endpoint.
+ * @param pool Pool to use to create the SDP descriptor.
+ * @param stream_cnt Number of elements in the sock_info array. This
+ * also denotes the maximum number of streams (i.e.
+ * the "m=" lines) that will be created in the SDP.
+ * @param sock_info Array of socket transport information. One
+ * transport is needed for each media stream, and
+ * each transport consists of an RTP and RTCP socket
+ * pair.
+ * @param p_sdp Pointer to receive SDP session descriptor.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_endpt_create_sdp( pjmedia_endpt *endpt,
+ pj_pool_t *pool,
+ unsigned stream_cnt,
+ const pjmedia_sock_info sock_info[],
+ pjmedia_sdp_session **p_sdp );
+
+
+/**
+ * Dump media endpoint capabilities.
+ *
+ * @param endpt The media endpoint.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_endpt_dump(pjmedia_endpt *endpt);
+
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+
+
+#endif /* __PJMEDIA_MEDIAMGR_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/errno.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/errno.h new file mode 100644 index 0000000..9dcecbf --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/errno.h @@ -0,0 +1,631 @@ +/* $Id: errno.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_ERRNO_H__
+#define __PJMEDIA_ERRNO_H__
+
+/**
+ * @file errno.h Error Codes
+ * @brief PJMEDIA specific error codes.
+ */
+
+#include <pjmedia/types.h>
+#include <pj/errno.h>
+
+/**
+ * @defgroup PJMEDIA_ERRNO Error Codes
+ * @ingroup PJMEDIA_BASE
+ * @brief PJMEDIA specific error codes.
+ * @{
+ */
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Start of error code relative to PJ_ERRNO_START_USER.
+ */
+#define PJMEDIA_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
+#define PJMEDIA_ERRNO_END (PJMEDIA_ERRNO_START + PJ_ERRNO_SPACE_SIZE - 1)
+
+
+/**
+ * Mapping from PortAudio error codes to pjmedia error space.
+ */
+#define PJMEDIA_PORTAUDIO_ERRNO_START (PJMEDIA_ERRNO_END-10000)
+#define PJMEDIA_PORTAUDIO_ERRNO_END (PJMEDIA_PORTAUDIO_ERRNO_START + 10000 -1)
+/**
+ * Convert PortAudio error code to PJMEDIA error code.
+ * PortAudio error code range: 0 >= err >= -10000
+ */
+#define PJMEDIA_ERRNO_FROM_PORTAUDIO(err) ((int)PJMEDIA_PORTAUDIO_ERRNO_START-err)
+
+
+#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
+
+ /**
+ * Mapping from LibSRTP error codes to pjmedia error space.
+ */
+#define PJMEDIA_LIBSRTP_ERRNO_START (PJMEDIA_ERRNO_END-10200)
+#define PJMEDIA_LIBSRTP_ERRNO_END (PJMEDIA_LIBSRTP_ERRNO_START + 200 - 1)
+/**
+ * Convert LibSRTP error code to PJMEDIA error code.
+ * LibSRTP error code range: 0 <= err < 200
+ */
+#define PJMEDIA_ERRNO_FROM_LIBSRTP(err) (PJMEDIA_LIBSRTP_ERRNO_START+err)
+
+#endif
+
+/************************************************************
+ * GENERIC/GENERAL PJMEDIA ERRORS
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * General/unknown PJMEDIA error.
+ */
+#define PJMEDIA_ERROR (PJMEDIA_ERRNO_START+1) /* 220001 */
+
+
+/************************************************************
+ * SDP ERRORS
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * Generic invalid SDP descriptor.
+ */
+#define PJMEDIA_SDP_EINSDP (PJMEDIA_ERRNO_START+20) /* 220020 */
+/**
+ * @hideinitializer
+ * Invalid SDP version.
+ */
+#define PJMEDIA_SDP_EINVER (PJMEDIA_ERRNO_START+21) /* 220021 */
+/**
+ * @hideinitializer
+ * Invalid SDP origin (o=) line.
+ */
+#define PJMEDIA_SDP_EINORIGIN (PJMEDIA_ERRNO_START+22) /* 220022 */
+/**
+ * @hideinitializer
+ * Invalid SDP time (t=) line.
+ */
+#define PJMEDIA_SDP_EINTIME (PJMEDIA_ERRNO_START+23) /* 220023 */
+/**
+ * @hideinitializer
+ * Empty SDP subject/name (s=) line.
+ */
+#define PJMEDIA_SDP_EINNAME (PJMEDIA_ERRNO_START+24) /* 220024 */
+/**
+ * @hideinitializer
+ * Invalid SDP connection info (c=) line.
+ */
+#define PJMEDIA_SDP_EINCONN (PJMEDIA_ERRNO_START+25) /* 220025 */
+/**
+ * @hideinitializer
+ * Missing SDP connection info line.
+ */
+#define PJMEDIA_SDP_EMISSINGCONN (PJMEDIA_ERRNO_START+26) /* 220026 */
+/**
+ * @hideinitializer
+ * Invalid attribute (a=) line.
+ */
+#define PJMEDIA_SDP_EINATTR (PJMEDIA_ERRNO_START+27) /* 220027 */
+/**
+ * @hideinitializer
+ * Invalid rtpmap attribute.
+ */
+#define PJMEDIA_SDP_EINRTPMAP (PJMEDIA_ERRNO_START+28) /* 220028 */
+/**
+ * @hideinitializer
+ * rtpmap attribute is too long.
+ */
+#define PJMEDIA_SDP_ERTPMAPTOOLONG (PJMEDIA_ERRNO_START+29) /* 220029 */
+/**
+ * @hideinitializer
+ * rtpmap is missing for dynamic payload type.
+ */
+#define PJMEDIA_SDP_EMISSINGRTPMAP (PJMEDIA_ERRNO_START+30) /* 220030 */
+/**
+ * @hideinitializer
+ * Invalid SDP media (m=) line.
+ */
+#define PJMEDIA_SDP_EINMEDIA (PJMEDIA_ERRNO_START+31) /* 220031 */
+/**
+ * @hideinitializer
+ * No payload format in the media stream.
+ */
+#define PJMEDIA_SDP_ENOFMT (PJMEDIA_ERRNO_START+32) /* 220032 */
+/**
+ * @hideinitializer
+ * Invalid payload type in media.
+ */
+#define PJMEDIA_SDP_EINPT (PJMEDIA_ERRNO_START+33) /* 220033 */
+/**
+ * @hideinitializer
+ * Invalid SDP "fmtp" attribute.
+ */
+#define PJMEDIA_SDP_EINFMTP (PJMEDIA_ERRNO_START+34) /* 220034 */
+/**
+ * @hideinitializer
+ * Invalid SDP "rtcp" attribute.
+ */
+#define PJMEDIA_SDP_EINRTCP (PJMEDIA_ERRNO_START+35) /* 220035 */
+/**
+ * @hideinitializer
+ * Invalid SDP media transport protocol.
+ */
+#define PJMEDIA_SDP_EINPROTO (PJMEDIA_ERRNO_START+36) /* 220036 */
+
+
+/************************************************************
+ * SDP NEGOTIATOR ERRORS
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * Invalid state to perform the specified operation.
+ */
+#define PJMEDIA_SDPNEG_EINSTATE (PJMEDIA_ERRNO_START+40) /* 220040 */
+/**
+ * @hideinitializer
+ * No initial local SDP.
+ */
+#define PJMEDIA_SDPNEG_ENOINITIAL (PJMEDIA_ERRNO_START+41) /* 220041 */
+/**
+ * @hideinitializer
+ * No currently active SDP.
+ */
+#define PJMEDIA_SDPNEG_ENOACTIVE (PJMEDIA_ERRNO_START+42) /* 220042 */
+/**
+ * @hideinitializer
+ * No current offer or answer.
+ */
+#define PJMEDIA_SDPNEG_ENONEG (PJMEDIA_ERRNO_START+43) /* 220043 */
+/**
+ * @hideinitializer
+ * Media count mismatch in offer and answer.
+ */
+#define PJMEDIA_SDPNEG_EMISMEDIA (PJMEDIA_ERRNO_START+44) /* 220044 */
+/**
+ * @hideinitializer
+ * Media type is different in the remote answer.
+ */
+#define PJMEDIA_SDPNEG_EINVANSMEDIA (PJMEDIA_ERRNO_START+45) /* 220045 */
+/**
+ * @hideinitializer
+ * Transport type is different in the remote answer.
+ */
+#define PJMEDIA_SDPNEG_EINVANSTP (PJMEDIA_ERRNO_START+46) /* 220046 */
+/**
+ * @hideinitializer
+ * No common media payload is provided in the answer.
+ */
+#define PJMEDIA_SDPNEG_EANSNOMEDIA (PJMEDIA_ERRNO_START+47) /* 220047 */
+/**
+ * @hideinitializer
+ * No media is active after negotiation.
+ */
+#define PJMEDIA_SDPNEG_ENOMEDIA (PJMEDIA_ERRNO_START+48) /* 220048 */
+/**
+ * @hideinitializer
+ * No suitable codec for remote offer.
+ */
+#define PJMEDIA_SDPNEG_NOANSCODEC (PJMEDIA_ERRNO_START+49) /* 220049 */
+/**
+ * @hideinitializer
+ * No suitable telephone-event for remote offer.
+ */
+#define PJMEDIA_SDPNEG_NOANSTELEVENT (PJMEDIA_ERRNO_START+50) /* 220050 */
+/**
+ * @hideinitializer
+ * No suitable answer for unknown remote offer.
+ */
+#define PJMEDIA_SDPNEG_NOANSUNKNOWN (PJMEDIA_ERRNO_START+51) /* 220051 */
+
+
+/************************************************************
+ * SDP COMPARISON STATUS
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * SDP media stream not equal.
+ */
+#define PJMEDIA_SDP_EMEDIANOTEQUAL (PJMEDIA_ERRNO_START+60) /* 220060 */
+/**
+ * @hideinitializer
+ * Port number in SDP media descriptor not equal.
+ */
+#define PJMEDIA_SDP_EPORTNOTEQUAL (PJMEDIA_ERRNO_START+61) /* 220061 */
+/**
+ * @hideinitializer
+ * Transport in SDP media descriptor not equal.
+ */
+#define PJMEDIA_SDP_ETPORTNOTEQUAL (PJMEDIA_ERRNO_START+62) /* 220062 */
+/**
+ * @hideinitializer
+ * Media format in SDP media descriptor not equal.
+ */
+#define PJMEDIA_SDP_EFORMATNOTEQUAL (PJMEDIA_ERRNO_START+63) /* 220063 */
+/**
+ * @hideinitializer
+ * SDP connection description not equal.
+ */
+#define PJMEDIA_SDP_ECONNNOTEQUAL (PJMEDIA_ERRNO_START+64) /* 220064 */
+/**
+ * @hideinitializer
+ * SDP attributes not equal.
+ */
+#define PJMEDIA_SDP_EATTRNOTEQUAL (PJMEDIA_ERRNO_START+65) /* 220065 */
+/**
+ * @hideinitializer
+ * SDP media direction not equal.
+ */
+#define PJMEDIA_SDP_EDIRNOTEQUAL (PJMEDIA_ERRNO_START+66) /* 220066 */
+/**
+ * @hideinitializer
+ * SDP fmtp attribute not equal.
+ */
+#define PJMEDIA_SDP_EFMTPNOTEQUAL (PJMEDIA_ERRNO_START+67) /* 220067 */
+/**
+ * @hideinitializer
+ * SDP ftpmap attribute not equal.
+ */
+#define PJMEDIA_SDP_ERTPMAPNOTEQUAL (PJMEDIA_ERRNO_START+68) /* 220068 */
+/**
+ * @hideinitializer
+ * SDP session descriptor not equal.
+ */
+#define PJMEDIA_SDP_ESESSNOTEQUAL (PJMEDIA_ERRNO_START+69) /* 220069 */
+/**
+ * @hideinitializer
+ * SDP origin not equal.
+ */
+#define PJMEDIA_SDP_EORIGINNOTEQUAL (PJMEDIA_ERRNO_START+70) /* 220070 */
+/**
+ * @hideinitializer
+ * SDP name/subject not equal.
+ */
+#define PJMEDIA_SDP_ENAMENOTEQUAL (PJMEDIA_ERRNO_START+71) /* 220071 */
+/**
+ * @hideinitializer
+ * SDP time not equal.
+ */
+#define PJMEDIA_SDP_ETIMENOTEQUAL (PJMEDIA_ERRNO_START+72) /* 220072 */
+
+
+/************************************************************
+ * CODEC
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * Unsupported codec.
+ */
+#define PJMEDIA_CODEC_EUNSUP (PJMEDIA_ERRNO_START+80) /* 220080 */
+/**
+ * @hideinitializer
+ * Codec internal creation error.
+ */
+#define PJMEDIA_CODEC_EFAILED (PJMEDIA_ERRNO_START+81) /* 220081 */
+/**
+ * @hideinitializer
+ * Codec frame is too short.
+ */
+#define PJMEDIA_CODEC_EFRMTOOSHORT (PJMEDIA_ERRNO_START+82) /* 220082 */
+/**
+ * @hideinitializer
+ * PCM buffer is too short.
+ */
+#define PJMEDIA_CODEC_EPCMTOOSHORT (PJMEDIA_ERRNO_START+83) /* 220083 */
+/**
+ * @hideinitializer
+ * Invalid codec frame length.
+ */
+#define PJMEDIA_CODEC_EFRMINLEN (PJMEDIA_ERRNO_START+84) /* 220084 */
+/**
+ * @hideinitializer
+ * Invalid PCM frame length.
+ */
+#define PJMEDIA_CODEC_EPCMFRMINLEN (PJMEDIA_ERRNO_START+85) /* 220085 */
+/**
+ * @hideinitializer
+ * Invalid mode.
+ */
+#define PJMEDIA_CODEC_EINMODE (PJMEDIA_ERRNO_START+86) /* 220086 */
+
+
+/************************************************************
+ * MEDIA
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * Invalid remote IP address (in SDP).
+ */
+#define PJMEDIA_EINVALIDIP (PJMEDIA_ERRNO_START+100) /* 220100 */
+/**
+ * @hideinitializer
+ * Asymetric codec is not supported.
+ */
+#define PJMEDIA_EASYMCODEC (PJMEDIA_ERRNO_START+101) /* 220101 */
+/**
+ * @hideinitializer
+ * Invalid payload type.
+ */
+#define PJMEDIA_EINVALIDPT (PJMEDIA_ERRNO_START+102) /* 220102 */
+/**
+ * @hideinitializer
+ * Missing rtpmap.
+ */
+#define PJMEDIA_EMISSINGRTPMAP (PJMEDIA_ERRNO_START+103) /* 220103 */
+/**
+ * @hideinitializer
+ * Invalid media type.
+ */
+#define PJMEDIA_EINVALIMEDIATYPE (PJMEDIA_ERRNO_START+104) /* 220104 */
+/**
+ * @hideinitializer
+ * Remote does not support DTMF.
+ */
+#define PJMEDIA_EREMOTENODTMF (PJMEDIA_ERRNO_START+105) /* 220105 */
+/**
+ * @hideinitializer
+ * Invalid DTMF digit.
+ */
+#define PJMEDIA_RTP_EINDTMF (PJMEDIA_ERRNO_START+106) /* 220106 */
+/**
+ * @hideinitializer
+ * Remote does not support RFC 2833
+ */
+#define PJMEDIA_RTP_EREMNORFC2833 (PJMEDIA_ERRNO_START+107) /* 220107 */
+
+
+
+/************************************************************
+ * RTP SESSION ERRORS
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * General invalid RTP packet error.
+ */
+#define PJMEDIA_RTP_EINPKT (PJMEDIA_ERRNO_START+120) /* 220120 */
+/**
+ * @hideinitializer
+ * Invalid RTP packet packing.
+ */
+#define PJMEDIA_RTP_EINPACK (PJMEDIA_ERRNO_START+121) /* 220121 */
+/**
+ * @hideinitializer
+ * Invalid RTP packet version.
+ */
+#define PJMEDIA_RTP_EINVER (PJMEDIA_ERRNO_START+122) /* 220122 */
+/**
+ * @hideinitializer
+ * RTP SSRC id mismatch.
+ */
+#define PJMEDIA_RTP_EINSSRC (PJMEDIA_ERRNO_START+123) /* 220123 */
+/**
+ * @hideinitializer
+ * RTP payload type mismatch.
+ */
+#define PJMEDIA_RTP_EINPT (PJMEDIA_ERRNO_START+124) /* 220124 */
+/**
+ * @hideinitializer
+ * Invalid RTP packet length.
+ */
+#define PJMEDIA_RTP_EINLEN (PJMEDIA_ERRNO_START+125) /* 220125 */
+/**
+ * @hideinitializer
+ * RTP session restarted.
+ */
+#define PJMEDIA_RTP_ESESSRESTART (PJMEDIA_ERRNO_START+130) /* 220130 */
+/**
+ * @hideinitializer
+ * RTP session in probation
+ */
+#define PJMEDIA_RTP_ESESSPROBATION (PJMEDIA_ERRNO_START+131) /* 220131 */
+/**
+ * @hideinitializer
+ * Bad RTP sequence number
+ */
+#define PJMEDIA_RTP_EBADSEQ (PJMEDIA_ERRNO_START+132) /* 220132 */
+/**
+ * @hideinitializer
+ * RTP media port destination is not configured
+ */
+#define PJMEDIA_RTP_EBADDEST (PJMEDIA_ERRNO_START+133) /* 220133 */
+/**
+ * @hideinitializer
+ * RTP is not configured.
+ */
+#define PJMEDIA_RTP_ENOCONFIG (PJMEDIA_ERRNO_START+134) /* 220134 */
+
+
+/************************************************************
+ * PORT ERRORS
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * Generic incompatible port error.
+ */
+#define PJMEDIA_ENOTCOMPATIBLE (PJMEDIA_ERRNO_START+160) /* 220160 */
+/**
+ * @hideinitializer
+ * Incompatible clock rate
+ */
+#define PJMEDIA_ENCCLOCKRATE (PJMEDIA_ERRNO_START+161) /* 220161 */
+/**
+ * @hideinitializer
+ * Incompatible samples per frame
+ */
+#define PJMEDIA_ENCSAMPLESPFRAME (PJMEDIA_ERRNO_START+162) /* 220162 */
+/**
+ * @hideinitializer
+ * Incompatible media type
+ */
+#define PJMEDIA_ENCTYPE (PJMEDIA_ERRNO_START+163) /* 220163 */
+/**
+ * @hideinitializer
+ * Incompatible bits per sample
+ */
+#define PJMEDIA_ENCBITS (PJMEDIA_ERRNO_START+164) /* 220164 */
+/**
+ * @hideinitializer
+ * Incompatible bytes per frame
+ */
+#define PJMEDIA_ENCBYTES (PJMEDIA_ERRNO_START+165) /* 220165 */
+/**
+ * @hideinitializer
+ * Incompatible number of channels
+ */
+#define PJMEDIA_ENCCHANNEL (PJMEDIA_ERRNO_START+166) /* 220166 */
+
+
+/************************************************************
+ * FILE ERRORS
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * Not a valid WAVE file.
+ */
+#define PJMEDIA_ENOTVALIDWAVE (PJMEDIA_ERRNO_START+180) /* 220180 */
+/**
+ * @hideinitializer
+ * Unsupported WAVE file.
+ */
+#define PJMEDIA_EWAVEUNSUPP (PJMEDIA_ERRNO_START+181) /* 220181 */
+/**
+ * @hideinitializer
+ * Wave file too short.
+ */
+#define PJMEDIA_EWAVETOOSHORT (PJMEDIA_ERRNO_START+182) /* 220182 */
+/**
+ * @hideinitializer
+ * Sound frame is too large for file buffer.
+ */
+#define PJMEDIA_EFRMFILETOOBIG (PJMEDIA_ERRNO_START+183) /* 220183 */
+
+
+/************************************************************
+ * SOUND DEVICE ERRORS
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * No suitable audio capture device.
+ */
+#define PJMEDIA_ENOSNDREC (PJMEDIA_ERRNO_START+200) /* 220200 */
+/**
+ * @hideinitializer
+ * No suitable audio playback device.
+ */
+#define PJMEDIA_ENOSNDPLAY (PJMEDIA_ERRNO_START+201) /* 220201 */
+/**
+ * @hideinitializer
+ * Invalid sound device ID.
+ */
+#define PJMEDIA_ESNDINDEVID (PJMEDIA_ERRNO_START+202) /* 220202 */
+/**
+ * @hideinitializer
+ * Invalid sample format for sound device.
+ */
+#define PJMEDIA_ESNDINSAMPLEFMT (PJMEDIA_ERRNO_START+203) /* 220203 */
+
+
+#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
+/************************************************************
+ * SRTP TRANSPORT ERRORS
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * SRTP crypto-suite name not match the offerer tag.
+ */
+#define PJMEDIA_SRTP_ECRYPTONOTMATCH (PJMEDIA_ERRNO_START+220) /* 220220 */
+/**
+ * @hideinitializer
+ * Invalid SRTP key length for specific crypto.
+ */
+#define PJMEDIA_SRTP_EINKEYLEN (PJMEDIA_ERRNO_START+221) /* 220221 */
+/**
+ * @hideinitializer
+ * Unsupported SRTP crypto-suite.
+ */
+#define PJMEDIA_SRTP_ENOTSUPCRYPTO (PJMEDIA_ERRNO_START+222) /* 220222 */
+/**
+ * @hideinitializer
+ * SRTP SDP contains ambigue answer.
+ */
+#define PJMEDIA_SRTP_ESDPAMBIGUEANS (PJMEDIA_ERRNO_START+223) /* 220223 */
+/**
+ * @hideinitializer
+ * Duplicated crypto tag.
+ */
+#define PJMEDIA_SRTP_ESDPDUPCRYPTOTAG (PJMEDIA_ERRNO_START+224) /* 220224 */
+/**
+ * @hideinitializer
+ * Invalid crypto attribute.
+ */
+#define PJMEDIA_SRTP_ESDPINCRYPTO (PJMEDIA_ERRNO_START+225) /* 220225 */
+/**
+ * @hideinitializer
+ * Invalid crypto tag.
+ */
+#define PJMEDIA_SRTP_ESDPINCRYPTOTAG (PJMEDIA_ERRNO_START+226) /* 220226 */
+/**
+ * @hideinitializer
+ * Invalid SDP media transport for SRTP.
+ */
+#define PJMEDIA_SRTP_ESDPINTRANSPORT (PJMEDIA_ERRNO_START+227) /* 220227 */
+/**
+ * @hideinitializer
+ * SRTP crypto attribute required in SDP.
+ */
+#define PJMEDIA_SRTP_ESDPREQCRYPTO (PJMEDIA_ERRNO_START+228) /* 220228 */
+/**
+ * @hideinitializer
+ * Secure transport required in SDP media descriptor.
+ */
+#define PJMEDIA_SRTP_ESDPREQSECTP (PJMEDIA_ERRNO_START+229) /* 220229 */
+
+#endif /* PJMEDIA_HAS_SRTP */
+
+
+/**
+ * Get error message for the specified error code. Note that this
+ * function is only able to decode PJMEDIA specific error code.
+ * Application should use pj_strerror(), which should be able to
+ * decode all error codes belonging to all subsystems (e.g. pjlib,
+ * pjmedia, pjsip, etc).
+ *
+ * @param status The error code.
+ * @param buffer The buffer where to put the error message.
+ * @param bufsize Size of the buffer.
+ *
+ * @return The error message as NULL terminated string,
+ * wrapped with pj_str_t.
+ */
+PJ_DECL(pj_str_t) pjmedia_strerror( pj_status_t status, char *buffer,
+ pj_size_t bufsize);
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_ERRNO_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/g711.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/g711.h new file mode 100644 index 0000000..8f79604 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/g711.h @@ -0,0 +1,70 @@ +/* $Id: g711.h 2875 2009-08-13 15:57:26Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_G711_H__
+#define __PJMEDIA_G711_H__
+
+/**
+ * @file g711.h
+ * @brief G711 Codec
+ */
+
+#include <pjmedia-codec/types.h>
+
+/**
+ * @defgroup PJMED_G711 G711 G.711 Codec
+ * @ingroup PJMEDIA_CODEC_CODECS
+ * @brief Standard G.711/PCMA and PCMU codec.
+ * @{
+ * This section describes functions to register and register G.711 codec
+ * factory to the codec manager. After the codec factory has been registered,
+ * application can use @ref PJMEDIA_CODEC API to manipulate the codec.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Initialize and register G711 codec factory to pjmedia endpoint.
+ * This will register PCMU and PCMA codec, in that order.
+ *
+ * @param endpt The pjmedia endpoint.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_g711_init(pjmedia_endpt *endpt);
+
+
+
+/**
+ * Unregister G711 codec factory from pjmedia endpoint.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_g711_deinit(void);
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_G711_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/jbuf.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/jbuf.h new file mode 100644 index 0000000..e80ea02 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/jbuf.h @@ -0,0 +1,314 @@ +/* $Id: jbuf.h 2844 2009-07-29 12:14:21Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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
+ */
+/*
+ * Based on implementation kindly contributed by Switchlab, Ltd.
+ */
+#ifndef __PJMEDIA_JBUF_H__
+#define __PJMEDIA_JBUF_H__
+
+
+/**
+ * @file jbuf.h
+ * @brief Adaptive jitter buffer implementation.
+ */
+#include <pjmedia/types.h>
+
+/**
+ * @defgroup PJMED_JBUF Adaptive jitter buffer
+ * @ingroup PJMEDIA_FRAME_OP
+ * @brief Adaptive de-jitter buffering implementation
+ * @{
+ *
+ * This section describes PJMEDIA's implementation of de-jitter buffer.
+ * The de-jitter buffer may be set to operate in adaptive mode or fixed
+ * delay mode.
+ */
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Types of frame returned by the jitter buffer.
+ */
+enum pjmedia_jb_frame_type
+{
+ PJMEDIA_JB_MISSING_FRAME = 0, /**< No frame because it's missing */
+ PJMEDIA_JB_NORMAL_FRAME = 1, /**< Normal frame is being returned */
+ PJMEDIA_JB_ZERO_PREFETCH_FRAME = 2, /**< Zero frame is being returned
+ because JB is bufferring. */
+ PJMEDIA_JB_ZERO_EMPTY_FRAME = 3 /**< Zero frame is being returned
+ because JB is empty. */
+};
+
+
+/**
+ * @see pjmedia_jb_frame_type.
+ */
+typedef enum pjmedia_jb_frame_type pjmedia_jb_frame_type;
+
+
+/**
+ * This structure describes jitter buffer state.
+ */
+struct pjmedia_jb_state
+{
+ /* Setting */
+ unsigned frame_size; /**< Individual frame size, in bytes. */
+ unsigned min_prefetch; /**< Minimum allowed prefetch, in frms. */
+ unsigned max_prefetch; /**< Maximum allowed prefetch, in frms. */
+
+ /* Status */
+ unsigned prefetch; /**< Current prefetch value, in frames */
+ unsigned size; /**< Current buffer size, in frames. */
+
+ /* Statistic */
+ unsigned avg_delay; /**< Average delay, in ms. */
+ unsigned min_delay; /**< Minimum delay, in ms. */
+ unsigned max_delay; /**< Maximum delay, in ms. */
+ unsigned dev_delay; /**< Standard deviation of delay, in ms.*/
+ unsigned avg_burst; /**< Average burst, in frames. */
+ unsigned lost; /**< Number of lost frames. */
+ unsigned discard; /**< Number of discarded frames. */
+ unsigned empty; /**< Number of empty on GET events. */
+};
+
+
+/**
+ * @see pjmedia_jb_state
+ */
+typedef struct pjmedia_jb_state pjmedia_jb_state;
+
+
+/**
+ * The constant PJMEDIA_JB_DEFAULT_INIT_DELAY specifies default jitter
+ * buffer prefetch count during jitter buffer creation.
+ */
+#define PJMEDIA_JB_DEFAULT_INIT_DELAY 15
+
+/**
+ * Opaque declaration for jitter buffer.
+ */
+typedef struct pjmedia_jbuf pjmedia_jbuf;
+
+
+/**
+ * Create an adaptive jitter buffer according to the specification. If
+ * application wants to have a fixed jitter buffer, it may call
+ * #pjmedia_jbuf_set_fixed() after the jitter buffer is created.
+ *
+ * This function may allocate large chunk of memory to keep the frames in
+ * the buffer.
+ *
+ * @param pool The pool to allocate memory.
+ * @param name Name to identify the jitter buffer for logging
+ * purpose.
+ * @param frame_size The size of each frame that will be kept in the
+ * jitter buffer, in bytes. This should correspond
+ * to the minimum frame size supported by the codec.
+ * For example, a 10ms frame (80 bytes) would be
+ * recommended for G.711 codec.
+ * @param max_count Maximum number of frames that can be kept in the
+ * jitter buffer. This effectively means the maximum
+ * delay that may be introduced by this jitter
+ * buffer.
+ * @param ptime Indication of frame duration, used to calculate
+ * the interval between jitter recalculation.
+ * @param p_jb Pointer to receive jitter buffer instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_jbuf_create(pj_pool_t *pool,
+ const pj_str_t *name,
+ unsigned frame_size,
+ unsigned ptime,
+ unsigned max_count,
+ pjmedia_jbuf **p_jb);
+
+/**
+ * Set the jitter buffer to fixed delay mode. The default behavior
+ * is to adapt the delay with actual packet delay.
+ *
+ * @param jb The jitter buffer
+ * @param prefetch The fixed delay value, in number of frames.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_jbuf_set_fixed( pjmedia_jbuf *jb,
+ unsigned prefetch);
+
+
+/**
+ * Set the jitter buffer to adaptive mode.
+ *
+ * @param jb The jitter buffer.
+ * @param prefetch The initial prefetch value to be applied to the
+ * jitter buffer. Setting this to other than 0 will
+ * activate prefetch buffering, a jitter buffer feature
+ * that each time it gets empty, it won't return a
+ * normal frame until its size reaches the number
+ * specified here.
+ * @param min_prefetch The minimum delay that must be applied to each
+ * incoming packets, in number of frames.
+ * @param max_prefetch The maximum allowable value for prefetch delay,
+ * in number of frames.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_jbuf_set_adaptive( pjmedia_jbuf *jb,
+ unsigned prefetch,
+ unsigned min_prefetch,
+ unsigned max_prefetch);
+
+
+/**
+ * Destroy jitter buffer instance.
+ *
+ * @param jb The jitter buffer.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_jbuf_destroy(pjmedia_jbuf *jb);
+
+
+/**
+ * Restart jitter. This function flushes all packets in the buffer and
+ * reset the internal sequence number.
+ *
+ * @param jb The jitter buffer.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_jbuf_reset(pjmedia_jbuf *jb);
+
+/**
+ * Put a frame to the jitter buffer. If the frame can be accepted (based
+ * on the sequence number), the jitter buffer will copy the frame and put
+ * it in the appropriate position in the buffer.
+ *
+ * Application MUST manage it's own synchronization when multiple threads
+ * are accessing the jitter buffer at the same time.
+ *
+ * @param jb The jitter buffer.
+ * @param frame Pointer to frame buffer to be stored in the jitter
+ * buffer.
+ * @param size The frame size.
+ * @param frame_seq The frame sequence number.
+ */
+PJ_DECL(void) pjmedia_jbuf_put_frame( pjmedia_jbuf *jb,
+ const void *frame,
+ pj_size_t size,
+ int frame_seq);
+
+/**
+ * Put a frame to the jitter buffer. If the frame can be accepted (based
+ * on the sequence number), the jitter buffer will copy the frame and put
+ * it in the appropriate position in the buffer.
+ *
+ * Application MUST manage it's own synchronization when multiple threads
+ * are accessing the jitter buffer at the same time.
+ *
+ * @param jb The jitter buffer.
+ * @param frame Pointer to frame buffer to be stored in the jitter
+ * buffer.
+ * @param size The frame size.
+ * @param bit_info Bit precise info of the frame, e.g: a frame may not
+ * exactly start and end at the octet boundary, so this
+ * field may be used for specifying start & end bit offset.
+ * @param frame_seq The frame sequence number.
+ * @param discarded Flag whether the frame is discarded by jitter buffer.
+ */
+PJ_DECL(void) pjmedia_jbuf_put_frame2( pjmedia_jbuf *jb,
+ const void *frame,
+ pj_size_t size,
+ pj_uint32_t bit_info,
+ int frame_seq,
+ pj_bool_t *discarded);
+
+/**
+ * Get a frame from the jitter buffer. The jitter buffer will return the
+ * oldest frame from it's buffer, when it is available.
+ *
+ * Application MUST manage it's own synchronization when multiple threads
+ * are accessing the jitter buffer at the same time.
+ *
+ * @param jb The jitter buffer.
+ * @param frame Buffer to receive the payload from the jitter buffer.
+ * Application MUST make sure that the buffer has
+ * appropriate size (i.e. not less than the frame size,
+ * as specified when the jitter buffer was created).
+ * The jitter buffer only copied a frame to this
+ * buffer when the frame type returned by this function
+ * is PJMEDIA_JB_NORMAL_FRAME.
+ * @param p_frm_type Pointer to receive frame type. If jitter buffer is
+ * currently empty or bufferring, the frame type will
+ * be set to PJMEDIA_JB_ZERO_FRAME, and no frame will
+ * be copied. If the jitter buffer detects that frame is
+ * missing with current sequence number, the frame type
+ * will be set to PJMEDIA_JB_MISSING_FRAME, and no
+ * frame will be copied. If there is a frame, the jitter
+ * buffer will copy the frame to the buffer, and frame
+ * type will be set to PJMEDIA_JB_NORMAL_FRAME.
+ */
+PJ_DECL(void) pjmedia_jbuf_get_frame( pjmedia_jbuf *jb,
+ void *frame,
+ char *p_frm_type);
+
+/**
+ * Get a frame from the jitter buffer. The jitter buffer will return the
+ * oldest frame from it's buffer, when it is available.
+ *
+ * @param jb The jitter buffer.
+ * @param frame Buffer to receive the payload from the jitter buffer.
+ * @see pjmedia_jbuf_get_frame().
+ * @param size Pointer to receive frame size.
+ * @param p_frm_type Pointer to receive frame type.
+ * @see pjmedia_jbuf_get_frame().
+ * @param bit_info Bit precise info of the frame, e.g: a frame may not
+ * exactly start and end at the octet boundary, so this
+ * field may be used for specifying start & end bit offset.
+ */
+PJ_DECL(void) pjmedia_jbuf_get_frame2(pjmedia_jbuf *jb,
+ void *frame,
+ pj_size_t *size,
+ char *p_frm_type,
+ pj_uint32_t *bit_info);
+
+
+/**
+ * Get jitter buffer current state/settings.
+ *
+ * @param jb The jitter buffer.
+ * @param state Buffer to receive jitter buffer state.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_jbuf_get_state( const pjmedia_jbuf *jb,
+ pjmedia_jb_state *state );
+
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_JBUF_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/master_port.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/master_port.h new file mode 100644 index 0000000..0e10547 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/master_port.h @@ -0,0 +1,179 @@ +/* $Id: master_port.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_MASTER_PORT_H__
+#define __PJMEDIA_MASTER_PORT_H__
+
+
+/**
+ * @file master_port.h
+ * @brief Master port.
+ */
+#include <pjmedia/port.h>
+
+/**
+ * @defgroup PJMEDIA_MASTER_PORT Master Port
+ * @ingroup PJMEDIA_PORT_CLOCK
+ * @brief Thread based media clock provider
+ * @{
+ *
+ * A master port has two media ports connected to it, and by convention
+ * thay are called downstream and upstream ports. The media stream flowing to
+ * the downstream port is called encoding or send direction, and media stream
+ * flowing to the upstream port is called decoding or receive direction
+ * (imagine the downstream as stream to remote endpoint, and upstream as
+ * local media port; media flowing to remote endpoint (downstream) will need
+ * to be encoded before it is transmitted to remote endpoint).
+ *
+ * A master port internally has an instance of @ref PJMEDIA_CLOCK, which
+ * provides the essensial timing for the master port. The @ref PJMEDIA_CLOCK
+ * runs asynchronously, and whenever a clock <b>tick</b> expires, a callback
+ * will be called, and the master port performs the following tasks:
+ * - it calls <b><tt>get_frame()</tt></b> from the downstream port,
+ * when give the frame to the upstream port by calling <b><tt>put_frame
+ * </tt></b> to the upstream port, and
+ * - performs the same task, but on the reverse direction (i.e. get the stream
+ * from upstream port and give it to the downstream port).
+ *
+ * Because master port enables media stream to flow automatically, it is
+ * said that the master port supplies @ref PJMEDIA_PORT_CLOCK to the
+ * media ports interconnection.
+ *
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Opaque declaration for master port.
+ */
+typedef struct pjmedia_master_port pjmedia_master_port;
+
+
+/**
+ * Create a master port.
+ *
+ * @param pool Pool to allocate master port from.
+ * @param u_port Upstream port.
+ * @param d_port Downstream port.
+ * @param options Options flags, from bitmask combinations from
+ * pjmedia_clock_options.
+ * @param p_m Pointer to receive the master port instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_master_port_create(pj_pool_t *pool,
+ pjmedia_port *u_port,
+ pjmedia_port *d_port,
+ unsigned options,
+ pjmedia_master_port **p_m);
+
+
+/**
+ * Start the media flow.
+ *
+ * @param m The master port.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_master_port_start(pjmedia_master_port *m);
+
+
+/**
+ * Stop the media flow.
+ *
+ * @param m The master port.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_master_port_stop(pjmedia_master_port *m);
+
+
+/**
+ * Change the upstream port. Note that application is responsible to destroy
+ * current upstream port (the one that is going to be replaced with the
+ * new port).
+ *
+ * @param m The master port.
+ * @param port Port to be used for upstream port.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_master_port_set_uport(pjmedia_master_port *m,
+ pjmedia_port *port);
+
+
+/**
+ * Get the upstream port.
+ *
+ * @param m The master port.
+ *
+ * @return The upstream port.
+ */
+PJ_DECL(pjmedia_port*) pjmedia_master_port_get_uport(pjmedia_master_port*m);
+
+
+/**
+ * Change the downstream port. Note that application is responsible to destroy
+ * current downstream port (the one that is going to be replaced with the
+ * new port).
+ *
+ * @param m The master port.
+ * @param port Port to be used for downstream port.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_master_port_set_dport(pjmedia_master_port *m,
+ pjmedia_port *port);
+
+
+/**
+ * Get the downstream port.
+ *
+ * @param m The master port.
+ *
+ * @return The downstream port.
+ */
+PJ_DECL(pjmedia_port*) pjmedia_master_port_get_dport(pjmedia_master_port*m);
+
+
+/**
+ * Destroy the master port, and optionally destroy the upstream and
+ * downstream ports.
+ *
+ * @param m The master port.
+ * @param destroy_ports If non-zero, the function will destroy both
+ * upstream and downstream ports too.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_master_port_destroy(pjmedia_master_port *m,
+ pj_bool_t destroy_ports);
+
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_MASTER_PORT_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/mem_port.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/mem_port.h new file mode 100644 index 0000000..5de8523 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/mem_port.h @@ -0,0 +1,195 @@ +/* $Id: mem_port.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_MEM_PORT_H__
+#define __PJMEDIA_MEM_PORT_H__
+
+/**
+ * @file mem_port.h
+ * @brief Memory based media playback/capture port
+ */
+#include <pjmedia/port.h>
+
+PJ_BEGIN_DECL
+
+
+/**
+ * @defgroup PJMEDIA_MEM_PLAYER Memory/Buffer-based Playback Port
+ * @ingroup PJMEDIA_PORT
+ * @brief Media playback from a fixed size memory buffer
+ * @{
+ *
+ * A memory/buffer based playback port is used to play media from a fixed
+ * size buffer. This is useful over @ref PJMEDIA_FILE_PLAY for
+ * situation where filesystems are not available in the target system.
+ */
+
+
+/**
+ * Memory player options.
+ */
+enum pjmedia_mem_player_option
+{
+ /**
+ * Tell the memory player to return NULL frame when the whole
+ * buffer has been played instead of rewinding the buffer back
+ * to start position.
+ */
+ PJMEDIA_MEM_NO_LOOP = 1
+};
+
+
+/**
+ * Create the buffer based playback to play the media from the specified
+ * buffer.
+ *
+ * @param pool Pool to allocate memory for the port structure.
+ * @param buffer The buffer to play the media from, which should
+ * be available throughout the life time of the port.
+ * The player plays the media directly from this
+ * buffer (i.e. no copying is done).
+ * @param size The size of the buffer, in bytes.
+ * @param clock_rate Sampling rate.
+ * @param channel_count Number of channels.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Number of bits per sample.
+ * @param options Option flags, see #pjmedia_mem_player_option
+ * @param p_port Pointer to receive the port instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_mem_player_create(pj_pool_t *pool,
+ const void *buffer,
+ pj_size_t size,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ unsigned options,
+ pjmedia_port **p_port );
+
+
+/**
+ * Register a callback to be called when the buffer reading has reached the
+ * end of buffer. If the player is set to play repeatedly, then the callback
+ * will be called multiple times. Note that only one callback can be
+ * registered for each player port.
+ *
+ * @param port The memory player port.
+ * @param user_data User data to be specified in the callback
+ * @param cb Callback to be called. If the callback returns non-
+ * PJ_SUCCESS, the playback will stop. Note that if
+ * application destroys the player port in the callback,
+ * it must return non-PJ_SUCCESS here.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_mem_player_set_eof_cb( pjmedia_port *port,
+ void *user_data,
+ pj_status_t (*cb)(pjmedia_port *port,
+ void *usr_data));
+
+
+/**
+ * @}
+ */
+
+/**
+ * @defgroup PJMEDIA_MEM_CAPTURE Memory/Buffer-based Capture Port
+ * @ingroup PJMEDIA_PORT
+ * @brief Media capture to fixed size memory buffer
+ * @{
+ *
+ * A memory based capture is used to save media streams to a fixed size
+ * buffer. This is useful over @ref PJMEDIA_FILE_REC for
+ * situation where filesystems are not available in the target system.
+ */
+
+/**
+ * Create media port to capture/record media into a fixed size buffer.
+ *
+ * @param pool Pool to allocate memory for the port structure.
+ * @param buffer The buffer to record the media to, which should
+ * be available throughout the life time of the port.
+ * @param size The maximum size of the buffer, in bytes.
+ * @param clock_rate Sampling rate.
+ * @param channel_count Number of channels.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Number of bits per sample.
+ * @param options Option flags.
+ * @param p_port Pointer to receive the port instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_mem_capture_create(pj_pool_t *pool,
+ void *buffer,
+ pj_size_t size,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ unsigned options,
+ pjmedia_port **p_port);
+
+
+/**
+ * Register a callback to be called when no space left in the buffer.
+ * Note that when a callback is registered, this callback will also be
+ * called when application destroys the port and the callback has not
+ * been called before.
+ *
+ * @param port The memory recorder port.
+ * @param user_data User data to be specified in the callback
+ * @param cb Callback to be called. If the callback returns non-
+ * PJ_SUCCESS, the recording will stop. In other cases
+ * recording will be restarted and the rest of the frame
+ * will be stored starting from the beginning of the
+ * buffer. Note that if application destroys the capture
+ * port in the callback, it must return non-PJ_SUCCESS
+ * here.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_mem_capture_set_eof_cb(pjmedia_port *port,
+ void *user_data,
+ pj_status_t (*cb)(pjmedia_port *port,
+ void *usr_data));
+
+/**
+ * Return the current size of the recorded data in the buffer.
+ *
+ * @param port The memory recorder port.
+ * @return The size of buffer data..
+ */
+PJ_DECL(pj_size_t)
+pjmedia_mem_capture_get_size(pjmedia_port *port);
+
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_MEM_PORT_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/null_port.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/null_port.h new file mode 100644 index 0000000..e4e7659 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/null_port.h @@ -0,0 +1,70 @@ +/* $Id: null_port.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_NULL_PORT_H__
+#define __PJMEDIA_NULL_PORT_H__
+
+/**
+ * @file null_port.h
+ * @brief Null media port.
+ */
+#include <pjmedia/port.h>
+
+
+
+/**
+ * @defgroup PJMEDIA_NULL_PORT Null Port
+ * @ingroup PJMEDIA_PORT
+ * @brief The simplest type of media port which does nothing.
+ * @{
+ */
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Create Null port.
+ *
+ * @param pool Pool to allocate memory.
+ * @param sampling_rate Sampling rate of the port.
+ * @param channel_count Number of channels.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Number of bits per sample.
+ * @param p_port Pointer to receive the port instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_null_port_create( pj_pool_t *pool,
+ unsigned sampling_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ pjmedia_port **p_port );
+
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_NULL_PORT_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/plc.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/plc.h new file mode 100644 index 0000000..5ab4a10 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/plc.h @@ -0,0 +1,115 @@ +/* $Id: plc.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_PLC_H__
+#define __PJMEDIA_PLC_H__
+
+
+/**
+ * @file plc.h
+ * @brief Packet Lost Concealment (PLC) API.
+ */
+#include <pjmedia/types.h>
+
+/**
+ * @defgroup PJMED_PLC Packet Lost Concealment (PLC)
+ * @ingroup PJMEDIA_FRAME_OP
+ * @brief Packet lost compensation algorithm
+ * @{
+ *
+ * This section describes PJMEDIA's implementation of Packet Lost
+ * Concealment algorithm. This algorithm is used to implement PLC for
+ * codecs that do not have built-in support for one (e.g. G.711 or GSM
+ * codecs).
+ *
+ * The PLC algorithm (either built-in or external) is embedded in
+ * PJMEDIA codec instance, and application can conceal lost frames
+ * by calling <b><tt>recover()</tt></b> member of the codec's member
+ * operation (#pjmedia_codec_op).
+ *
+ * See also @ref plc_codec for more info.
+ */
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Opaque declaration for PLC.
+ */
+typedef struct pjmedia_plc pjmedia_plc;
+
+
+
+/**
+ * Create PLC session. This function will select the PLC algorithm to
+ * use based on the arguments.
+ *
+ * @param pool Pool to allocate memory for the PLC.
+ * @param clock_rate Media sampling rate.
+ * @param samples_per_frame Number of samples per frame.
+ * @param options Must be zero for now.
+ * @param p_plc Pointer to receive the PLC instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_plc_create( pj_pool_t *pool,
+ unsigned clock_rate,
+ unsigned samples_per_frame,
+ unsigned options,
+ pjmedia_plc **p_plc);
+
+
+/**
+ * Save a good frame to PLC.
+ *
+ * @param plc The PLC session.
+ * @param frame The good frame to be stored to PLC. This frame
+ * must have the same length as the configured
+ * samples per frame.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_plc_save( pjmedia_plc *plc,
+ pj_int16_t *frame );
+
+
+/**
+ * Generate a replacement for lost frame.
+ *
+ * @param plc The PLC session.
+ * @param frame Buffer to receive the generated frame. This buffer
+ * must be able to store the frame.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_plc_generate( pjmedia_plc *plc,
+ pj_int16_t *frame );
+
+
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_PLC_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/port.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/port.h new file mode 100644 index 0000000..20f5b55 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/port.h @@ -0,0 +1,326 @@ +/* $Id: port.h 2506 2009-03-12 18:11:37Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_PORT_H__
+#define __PJMEDIA_PORT_H__
+
+/**
+ * @file port.h
+ * @brief Port interface declaration
+ */
+#include <pjmedia/types.h>
+#include <pj/assert.h>
+#include <pj/os.h>
+
+
+/**
+ @addtogroup PJMEDIA_PORT Media Ports Framework
+ @{
+
+ @section media_port_intro Media Port Concepts
+
+ @subsection The Media Port
+ A media port (represented with pjmedia_port "class") provides a generic
+ and extensible framework for implementing media terminations. A media
+ port interface basically has the following properties:
+ - media port information (pjmedia_port_info) to describe the
+ media port properties (sampling rate, number of channels, etc.),
+ - pointer to function to acquire frames from the port (<tt>get_frame()
+ </tt> interface), which will be called by #pjmedia_port_get_frame()
+ public API, and
+ - pointer to function to store frames to the port (<tt>put_frame()</tt>
+ interface) which will be called by #pjmedia_port_put_frame() public
+ API.
+
+ Media ports are passive "objects". Applications (or other PJMEDIA
+ components) must actively calls #pjmedia_port_get_frame() or
+ #pjmedia_port_put_frame() from/to the media port in order to retrieve/
+ store media frames.
+
+ Some media ports (such as @ref PJMEDIA_CONF and @ref PJMEDIA_RESAMPLE_PORT)
+ may be interconnected with each other, while some
+ others represent the ultimate source/sink termination for the media.
+
+
+ @subsection port_clock_ex1 Example: Manual Resampling
+
+ For example, suppose application wants to convert the sampling rate
+ of one WAV file to another. In this case, application would create and
+ arrange media ports connection as follows:
+
+ \image html sample-manual-resampling.jpg
+
+ Application would setup the media ports using the following pseudo-
+ code:
+
+ \code
+
+ pjmedia_port *player, *resample, *writer;
+ pj_status_t status;
+
+ // Create the file player port.
+ status = pjmedia_wav_player_port_create(pool,
+ "Input.WAV", // file name
+ 20, // ptime.
+ PJMEDIA_FILE_NO_LOOP, // flags
+ 0, // buffer size
+ NULL, // user data.
+ &player );
+ PJ_ASSERT_RETURN(status==PJ_SUCCESS, PJ_SUCCESS);
+
+ // Create the resample port with specifying the target sampling rate,
+ // and with the file port as the source. This will effectively
+ // connect the resample port with the player port.
+ status = pjmedia_resample_port_create( pool, player, 8000,
+ 0, &resample);
+ PJ_ASSERT_RETURN(status==PJ_SUCCESS, PJ_SUCCESS);
+
+ // Create the file writer, specifying the resample port's configuration
+ // as the WAV parameters.
+ status pjmedia_wav_writer_port_create(pool,
+ "Output.WAV", // file name.
+ resample->info.clock_rate,
+ resample->info.channel_count,
+ resample->info.samples_per_frame,
+ resample->info.bits_per_sample,
+ 0, // flags
+ 0, // buffer size
+ NULL, // user data.
+ &writer);
+
+ \endcode
+
+
+ After the ports have been set up, application can perform the conversion
+ process by running this loop:
+
+ \code
+
+ pj_int16_t samplebuf[MAX_FRAME];
+
+ while (1) {
+ pjmedia_frame frame;
+ pj_status_t status;
+
+ frame.buf = samplebuf;
+ frame.size = sizeof(samplebuf);
+
+ // Get the frame from resample port.
+ status = pjmedia_port_get_frame(resample, &frame);
+ if (status != PJ_SUCCESS || frame.type == PJMEDIA_FRAME_TYPE_NONE) {
+ // End-of-file, end the conversion.
+ break;
+ }
+
+ // Put the frame to write port.
+ status = pjmedia_port_put_frame(writer, &frame);
+ if (status != PJ_SUCCESS) {
+ // Error in writing the file.
+ break;
+ }
+ }
+
+ \endcode
+
+ For the sake of completeness, after the resampling process is done,
+ application would need to destroy the ports:
+
+ \code
+ // Note: by default, destroying resample port will destroy the
+ // the downstream port too.
+ pjmedia_port_destroy(resample);
+ pjmedia_port_destroy(writer);
+ \endcode
+
+
+ The above steps are okay for our simple purpose of changing file's sampling
+ rate. But for other purposes, the process of reading and writing frames
+ need to be done in timely manner (for example, sending RTP packets to
+ remote stream). And more over, as the application's scope goes bigger,
+ the same pattern of manually reading/writing frames comes up more and more often,
+ thus perhaps it would be better if PJMEDIA provides mechanism to
+ automate this process.
+
+ And indeed PJMEDIA does provide such mechanism, which is described in
+ @ref PJMEDIA_PORT_CLOCK section.
+
+
+ @subsection media_port_autom Automating Media Flow
+
+ PJMEDIA provides few mechanisms to make media flows automatically
+ among media ports. This concept is described in @ref PJMEDIA_PORT_CLOCK
+ section.
+*/
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Port operation setting.
+ */
+typedef enum pjmedia_port_op
+{
+ /**
+ * No change to the port TX or RX settings.
+ */
+ PJMEDIA_PORT_NO_CHANGE,
+
+ /**
+ * TX or RX is disabled from the port. It means get_frame() or
+ * put_frame() WILL NOT be called for this port.
+ */
+ PJMEDIA_PORT_DISABLE,
+
+ /**
+ * TX or RX is muted, which means that get_frame() or put_frame()
+ * will still be called, but the audio frame is discarded.
+ */
+ PJMEDIA_PORT_MUTE,
+
+ /**
+ * Enable TX and RX to/from this port.
+ */
+ PJMEDIA_PORT_ENABLE
+
+} pjmedia_port_op;
+
+
+/**
+ * Port info.
+ */
+typedef struct pjmedia_port_info
+{
+ pj_str_t name; /**< Port name. */
+ pj_uint32_t signature; /**< Port signature. */
+ pjmedia_type type; /**< Media type. */
+ pj_bool_t has_info; /**< Has info? */
+ pj_bool_t need_info; /**< Need info on connect? */
+ unsigned pt; /**< Payload type (can be dynamic). */
+ pjmedia_format format; /**< Format. */
+ pj_str_t encoding_name; /**< Encoding name. */
+ unsigned clock_rate; /**< Sampling rate. */
+ unsigned channel_count; /**< Number of channels. */
+ unsigned bits_per_sample; /**< Bits/sample */
+ unsigned samples_per_frame; /**< No of samples per frame. */
+ unsigned bytes_per_frame; /**< No of samples per frame. */
+} pjmedia_port_info;
+
+
+/**
+ * Port interface.
+ */
+typedef struct pjmedia_port
+{
+ pjmedia_port_info info; /**< Port information. */
+
+ /** Port data can be used by the port creator to attach arbitrary
+ * value to be associated with the port.
+ */
+ struct port_data {
+ void *pdata; /**< Pointer data. */
+ long ldata; /**< Long data. */
+ } port_data;
+
+ /**
+ * Sink interface.
+ * This should only be called by #pjmedia_port_put_frame().
+ */
+ pj_status_t (*put_frame)(struct pjmedia_port *this_port,
+ const pjmedia_frame *frame);
+
+ /**
+ * Source interface.
+ * This should only be called by #pjmedia_port_get_frame().
+ */
+ pj_status_t (*get_frame)(struct pjmedia_port *this_port,
+ pjmedia_frame *frame);
+
+ /**
+ * Called to destroy this port.
+ */
+ pj_status_t (*on_destroy)(struct pjmedia_port *this_port);
+
+} pjmedia_port;
+
+
+/**
+ * This is an auxiliary function to initialize port info for
+ * ports which deal with PCM audio.
+ *
+ * @param info The port info to be initialized.
+ * @param name Port name.
+ * @param signature Port signature.
+ * @param clock_rate Port's clock rate.
+ * @param channel_count Number of channels.
+ * @param bits_per_sample Bits per sample.
+ * @param samples_per_frame Number of samples per frame.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_port_info_init( pjmedia_port_info *info,
+ const pj_str_t *name,
+ unsigned signature,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned bits_per_sample,
+ unsigned samples_per_frame);
+
+
+/**
+ * Get a frame from the port (and subsequent downstream ports).
+ *
+ * @param port The media port.
+ * @param frame Frame to store samples.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_port_get_frame( pjmedia_port *port,
+ pjmedia_frame *frame );
+
+/**
+ * Put a frame to the port (and subsequent downstream ports).
+ *
+ * @param port The media port.
+ * @param frame Frame to the put to the port.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_port_put_frame( pjmedia_port *port,
+ const pjmedia_frame *frame );
+
+
+/**
+ * Destroy port (and subsequent downstream ports)
+ *
+ * @param port The media port.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_port_destroy( pjmedia_port *port );
+
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_PORT_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/resample.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/resample.h new file mode 100644 index 0000000..ada2e77 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/resample.h @@ -0,0 +1,200 @@ +/* $Id: resample.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_RESAMPLE_H__
+#define __PJMEDIA_RESAMPLE_H__
+
+
+
+/**
+ * @file resample.h
+ * @brief Sample rate converter.
+ */
+#include <pjmedia/types.h>
+#include <pjmedia/port.h>
+
+/**
+ * @defgroup PJMEDIA_RESAMPLE Resampling Algorithm
+ * @ingroup PJMEDIA_FRAME_OP
+ * @brief Sample rate conversion algorithm
+ * @{
+ *
+ * This section describes the base resampling functions. In addition to this,
+ * application can use the @ref PJMEDIA_RESAMPLE_PORT which provides
+ * media port abstraction for the base resampling algorithm.
+ */
+
+PJ_BEGIN_DECL
+
+/*
+ * This file declares two types of API:
+ *
+ * Application can use #pjmedia_resample_create() and #pjmedia_resample_run()
+ * to convert a frame from source rate to destination rate. The inpuit frame
+ * must have a constant length.
+ *
+ * Alternatively, application can create a resampling port with
+ * #pjmedia_resample_port_create() and connect the port to other ports to
+ * change the sampling rate of the samples.
+ */
+
+
+/**
+ * Opaque resample session.
+ */
+typedef struct pjmedia_resample pjmedia_resample;
+
+/**
+ * Create a frame based resample session.
+ *
+ * @param pool Pool to allocate the structure and buffers.
+ * @param high_quality If true, then high quality conversion will be
+ * used, at the expense of more CPU and memory,
+ * because temporary buffer needs to be created.
+ * @param large_filter If true, large filter size will be used.
+ * @param channel_count Number of channels.
+ * @param rate_in Clock rate of the input samples.
+ * @param rate_out Clock rate of the output samples.
+ * @param samples_per_frame Number of samples per frame in the input.
+ * @param p_resample Pointer to receive the resample session.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_resample_create(pj_pool_t *pool,
+ pj_bool_t high_quality,
+ pj_bool_t large_filter,
+ unsigned channel_count,
+ unsigned rate_in,
+ unsigned rate_out,
+ unsigned samples_per_frame,
+ pjmedia_resample **p_resample);
+
+
+/**
+ * Use the resample session to resample a frame. The frame must have the
+ * same size and settings as the resample session, or otherwise the
+ * behavior is undefined.
+ *
+ * @param resample The resample session.
+ * @param input Buffer containing the input samples.
+ * @param output Buffer to store the output samples.
+ */
+PJ_DECL(void) pjmedia_resample_run( pjmedia_resample *resample,
+ const pj_int16_t *input,
+ pj_int16_t *output );
+
+
+/**
+ * Get the input frame size of a resample session.
+ *
+ * @param resample The resample session.
+ *
+ * @return The frame size, in number of samples.
+ */
+PJ_DECL(unsigned) pjmedia_resample_get_input_size(pjmedia_resample *resample);
+
+
+/**
+ * Destroy the resample.
+ *
+ * @param resample The resample session.
+ */
+PJ_DECL(void) pjmedia_resample_destroy(pjmedia_resample *resample);
+
+/**
+ * @}
+ */
+
+/**
+ * @defgroup PJMEDIA_RESAMPLE_PORT Resample Port
+ * @ingroup PJMEDIA_PORT
+ * @brief Audio sample rate conversion
+ * @{
+ *
+ * This section describes media port abstraction for @ref PJMEDIA_RESAMPLE.
+ */
+
+
+/**
+ * Option flags that can be specified when creating resample port.
+ */
+enum pjmedia_resample_port_options
+{
+ /**
+ * Do not use high quality resampling algorithm, but use linear
+ * algorithm instead.
+ */
+ PJMEDIA_RESAMPLE_USE_LINEAR = 1,
+
+ /**
+ * Use small filter workspace when high quality resampling is
+ * used.
+ */
+ PJMEDIA_RESAMPLE_USE_SMALL_FILTER = 2,
+
+ /**
+ * Do not destroy downstream port when resample port is destroyed.
+ */
+ PJMEDIA_RESAMPLE_DONT_DESTROY_DN = 4
+};
+
+
+
+/**
+ * Create a resample port. This creates a bidirectional resample session,
+ * which will resample frames when the port's get_frame() and put_frame()
+ * is called.
+ *
+ * When the resample port's get_frame() is called, this port will get
+ * a frame from the downstream port and resample the frame to the target
+ * clock rate before returning it to the caller.
+ *
+ * When the resample port's put_frame() is called, this port will resample
+ * the frame to the downstream port's clock rate before giving the frame
+ * to the downstream port.
+ *
+ * @param pool Pool to allocate the structure and buffers.
+ * @param dn_port The downstream port, which clock rate is to
+ * be converted to the target clock rate.
+ * @param clock_rate Target clock rate.
+ * @param options Flags from #pjmedia_resample_port_options.
+ * When this flag is zero, the default behavior
+ * is to use high quality resampling with
+ * large filter, and to destroy downstream port
+ * when resample port is destroyed.
+ * @param p_port Pointer to receive the resample port instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_resample_port_create( pj_pool_t *pool,
+ pjmedia_port *dn_port,
+ unsigned clock_rate,
+ unsigned options,
+ pjmedia_port **p_port );
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_RESAMPLE_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/rtcp.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/rtcp.h new file mode 100644 index 0000000..6814d35 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/rtcp.h @@ -0,0 +1,408 @@ +/* $Id: rtcp.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_RTCP_H__
+#define __PJMEDIA_RTCP_H__
+
+/**
+ * @file rtcp.h
+ * @brief RTCP implementation.
+ */
+
+#include <pjmedia/types.h>
+#include <pjmedia/rtcp_xr.h>
+#include <pjmedia/rtp.h>
+
+PJ_BEGIN_DECL
+
+
+/**
+ * @defgroup PJMED_RTCP RTCP Session and Encapsulation (RFC 3550)
+ * @ingroup PJMEDIA_SESSION
+ * @brief RTCP format and session management
+ * @{
+ *
+ * PJMEDIA implements subsets of RTCP specification (RFC 3550) to monitor
+ * the quality of the real-time media (audio/video) transmission. In
+ * addition to the standard quality monitoring and reporting with RTCP
+ * SR and RR types, PJMEDIA's RTCP implementation is able to report
+ * extended statistics for incoming streams, such as packet duplications,
+ * reorder, discarded, and loss period (to distinguish between random
+ * and burst loss).
+ *
+ * The bidirectional media quality statistic is represented with
+ * #pjmedia_rtcp_stat structure.
+ *
+ * When application uses the stream interface (see @ref PJMED_STRM),
+ * application may retrieve the RTCP statistic by calling
+ * #pjmedia_stream_get_stat() function.
+ */
+
+#pragma pack(1)
+
+/**
+ * RTCP sender report.
+ */
+struct pjmedia_rtcp_sr
+{
+ pj_uint32_t ntp_sec; /**< NTP time, seconds part. */
+ pj_uint32_t ntp_frac; /**< NTP time, fractions part. */
+ pj_uint32_t rtp_ts; /**< RTP timestamp. */
+ pj_uint32_t sender_pcount; /**< Sender packet cound. */
+ pj_uint32_t sender_bcount; /**< Sender octet/bytes count. */
+};
+
+/**
+ * @see pjmedia_rtcp_sr
+ */
+typedef struct pjmedia_rtcp_sr pjmedia_rtcp_sr;
+
+/**
+ * RTCP receiver report.
+ */
+struct pjmedia_rtcp_rr
+{
+ pj_uint32_t ssrc; /**< SSRC identification. */
+#if defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN!=0
+ pj_uint32_t fract_lost:8; /**< Fraction lost. */
+ pj_uint32_t total_lost_2:8; /**< Total lost, bit 16-23. */
+ pj_uint32_t total_lost_1:8; /**< Total lost, bit 8-15. */
+ pj_uint32_t total_lost_0:8; /**< Total lost, bit 0-7. */
+#else
+ pj_uint32_t fract_lost:8; /**< Fraction lost. */
+ pj_uint32_t total_lost_2:8; /**< Total lost, bit 0-7. */
+ pj_uint32_t total_lost_1:8; /**< Total lost, bit 8-15. */
+ pj_uint32_t total_lost_0:8; /**< Total lost, bit 16-23. */
+#endif
+ pj_uint32_t last_seq; /**< Last sequence number. */
+ pj_uint32_t jitter; /**< Jitter. */
+ pj_uint32_t lsr; /**< Last SR. */
+ pj_uint32_t dlsr; /**< Delay since last SR. */
+};
+
+/**
+ * @see pjmedia_rtcp_rr
+ */
+typedef struct pjmedia_rtcp_rr pjmedia_rtcp_rr;
+
+
+/**
+ * RTCP common header.
+ */
+struct pjmedia_rtcp_common
+{
+#if defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN!=0
+ unsigned version:2; /**< packet type */
+ unsigned p:1; /**< padding flag */
+ unsigned count:5; /**< varies by payload type */
+ unsigned pt:8; /**< payload type */
+#else
+ unsigned count:5; /**< varies by payload type */
+ unsigned p:1; /**< padding flag */
+ unsigned version:2; /**< packet type */
+ unsigned pt:8; /**< payload type */
+#endif
+ unsigned length:16; /**< packet length */
+ pj_uint32_t ssrc; /**< SSRC identification */
+};
+
+/**
+ * @see pjmedia_rtcp_common
+ */
+typedef struct pjmedia_rtcp_common pjmedia_rtcp_common;
+
+/**
+ * This structure declares default RTCP packet (SR) that is sent by pjmedia.
+ * Incoming RTCP packet may have different format, and must be parsed
+ * manually by application.
+ */
+typedef struct pjmedia_rtcp_sr_pkt
+{
+ pjmedia_rtcp_common common; /**< Common header. */
+ pjmedia_rtcp_sr sr; /**< Sender report. */
+ pjmedia_rtcp_rr rr; /**< variable-length list */
+} pjmedia_rtcp_sr_pkt;
+
+/**
+ * This structure declares RTCP RR (Receiver Report) packet.
+ */
+typedef struct pjmedia_rtcp_rr_pkt
+{
+ pjmedia_rtcp_common common; /**< Common header. */
+ pjmedia_rtcp_rr rr; /**< variable-length list */
+} pjmedia_rtcp_rr_pkt;
+
+
+#pragma pack()
+
+
+/**
+ * NTP time representation.
+ */
+struct pjmedia_rtcp_ntp_rec
+{
+ pj_uint32_t hi; /**< High order 32-bit part. */
+ pj_uint32_t lo; /**< Lo order 32-bit part. */
+};
+
+/**
+ * @see pjmedia_rtcp_ntp_rec
+ */
+typedef struct pjmedia_rtcp_ntp_rec pjmedia_rtcp_ntp_rec;
+
+
+
+/**
+ * Unidirectional RTP stream statistics.
+ */
+struct pjmedia_rtcp_stream_stat
+{
+ pj_time_val update; /**< Time of last update. */
+ unsigned update_cnt; /**< Number of updates (to calculate avg) */
+ pj_uint32_t pkt; /**< Total number of packets */
+ pj_uint32_t bytes; /**< Total number of payload/bytes */
+ unsigned discard; /**< Total number of discarded packets. */
+ unsigned loss; /**< Total number of packets lost */
+ unsigned reorder; /**< Total number of out of order packets */
+ unsigned dup; /**< Total number of duplicates packets */
+
+ pj_math_stat loss_period;/**< Loss period statistics (in usec) */
+
+ struct {
+ unsigned burst:1; /**< Burst/sequential packet lost detected */
+ unsigned random:1; /**< Random packet lost detected. */
+ } loss_type; /**< Types of loss detected. */
+
+ pj_math_stat jitter; /**< Jitter statistics (in usec) */
+};
+
+
+/**
+ * @see pjmedia_rtcp_stream_stat
+ */
+typedef struct pjmedia_rtcp_stream_stat pjmedia_rtcp_stream_stat;
+
+
+
+/**
+ * Bidirectional RTP stream statistics.
+ */
+struct pjmedia_rtcp_stat
+{
+ pj_time_val start; /**< Time when session was created */
+
+ pjmedia_rtcp_stream_stat tx; /**< Encoder stream statistics. */
+ pjmedia_rtcp_stream_stat rx; /**< Decoder stream statistics. */
+
+ pj_math_stat rtt; /**< Round trip delay statistic(in usec)*/
+
+ pj_uint32_t rtp_tx_last_ts; /**< Last TX RTP timestamp. */
+ pj_uint16_t rtp_tx_last_seq;/**< Last TX RTP sequence. */
+};
+
+
+/**
+ * @see pjmedia_rtcp_stat
+ */
+typedef struct pjmedia_rtcp_stat pjmedia_rtcp_stat;
+
+
+/**
+ * RTCP session is used to monitor the RTP session of one endpoint. There
+ * should only be one RTCP session for a bidirectional RTP streams.
+ */
+struct pjmedia_rtcp_session
+{
+ char *name; /**< Name identification. */
+ pjmedia_rtcp_sr_pkt rtcp_sr_pkt;/**< Cached RTCP SR packet. */
+ pjmedia_rtcp_rr_pkt rtcp_rr_pkt;/**< Cached RTCP RR packet. */
+
+ pjmedia_rtp_seq_session seq_ctrl; /**< RTCP sequence number control. */
+ unsigned rtp_last_ts;/**< Last timestamp in RX RTP pkt. */
+
+ unsigned clock_rate; /**< Clock rate of the stream */
+ unsigned pkt_size; /**< Avg pkt size, in samples. */
+ pj_uint32_t received; /**< # pkt received */
+ pj_uint32_t exp_prior; /**< # pkt expected at last interval*/
+ pj_uint32_t rx_prior; /**< # pkt received at last interval*/
+ pj_int32_t transit; /**< Rel transit time for prev pkt */
+ pj_uint32_t jitter; /**< Scaled jitter */
+ pj_time_val tv_base; /**< Base time, in seconds. */
+ pj_timestamp ts_base; /**< Base system timestamp. */
+ pj_timestamp ts_freq; /**< System timestamp frequency. */
+
+ pj_uint32_t rx_lsr; /**< NTP ts in last SR received */
+ pj_timestamp rx_lsr_time;/**< Time when last SR is received */
+ pj_uint32_t peer_ssrc; /**< Peer SSRC */
+
+ pjmedia_rtcp_stat stat; /**< Bidirectional stream stat. */
+
+#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)
+ /**
+ * Specify whether RTCP XR processing is enabled on this session.
+ */
+ pj_bool_t xr_enabled;
+
+ /**
+ * RTCP XR session, only valid if RTCP XR processing is enabled
+ * on this session.
+ */
+ pjmedia_rtcp_xr_session xr_session;
+#endif
+};
+
+/**
+ * @see pjmedia_rtcp_session
+ */
+typedef struct pjmedia_rtcp_session pjmedia_rtcp_session;
+
+
+/**
+ * Initialize RTCP session.
+ *
+ * @param session The session
+ * @param name Optional name to identify the session (for
+ * logging purpose).
+ * @param clock_rate Codec clock rate in samples per second.
+ * @param samples_per_frame Average number of samples per frame.
+ * @param ssrc The SSRC used in to identify the session.
+ */
+PJ_DECL(void) pjmedia_rtcp_init( pjmedia_rtcp_session *session,
+ char *name,
+ unsigned clock_rate,
+ unsigned samples_per_frame,
+ pj_uint32_t ssrc );
+
+
+/**
+ * Utility function to retrieve current NTP timestamp.
+ *
+ * @param sess RTCP session.
+ * @param ntp NTP record.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_rtcp_get_ntp_time(const pjmedia_rtcp_session *sess,
+ pjmedia_rtcp_ntp_rec *ntp);
+
+
+/**
+ * Deinitialize RTCP session.
+ *
+ * @param session The session.
+ */
+PJ_DECL(void) pjmedia_rtcp_fini( pjmedia_rtcp_session *session);
+
+
+/**
+ * Call this function everytime an RTP packet is received to let the RTCP
+ * session do its internal calculations.
+ *
+ * @param session The session.
+ * @param seq The RTP packet sequence number, in host byte order.
+ * @param ts The RTP packet timestamp, in host byte order.
+ * @param payload Size of the payload.
+ */
+PJ_DECL(void) pjmedia_rtcp_rx_rtp( pjmedia_rtcp_session *session,
+ unsigned seq,
+ unsigned ts,
+ unsigned payload);
+
+
+/**
+ * Call this function everytime an RTP packet is received to let the RTCP
+ * session do its internal calculations.
+ *
+ * @param session The session.
+ * @param seq The RTP packet sequence number, in host byte order.
+ * @param ts The RTP packet timestamp, in host byte order.
+ * @param payload Size of the payload.
+ * @param discarded Flag to specify whether the packet is discarded.
+ */
+PJ_DECL(void) pjmedia_rtcp_rx_rtp2(pjmedia_rtcp_session *session,
+ unsigned seq,
+ unsigned ts,
+ unsigned payload,
+ pj_bool_t discarded);
+
+
+/**
+ * Call this function everytime an RTP packet is sent to let the RTCP session
+ * do its internal calculations.
+ *
+ * @param session The session.
+ * @param ptsize The payload size of the RTP packet (ie packet minus
+ * RTP header) in bytes.
+ */
+PJ_DECL(void) pjmedia_rtcp_tx_rtp( pjmedia_rtcp_session *session,
+ unsigned ptsize );
+
+
+/**
+ * Call this function when an RTCP packet is received from remote peer.
+ * This RTCP packet received from remote is used to calculate the end-to-
+ * end delay of the network.
+ *
+ * @param session RTCP session.
+ * @param rtcp_pkt The received RTCP packet.
+ * @param size Size of the incoming packet.
+ */
+PJ_DECL(void) pjmedia_rtcp_rx_rtcp( pjmedia_rtcp_session *session,
+ const void *rtcp_pkt,
+ pj_size_t size);
+
+
+/**
+ * Build a RTCP packet to be transmitted to remote RTP peer. This will
+ * create RTCP Sender Report (SR) or Receiver Report (RR) depending on
+ * whether the endpoint has been transmitting RTP since the last interval.
+ * Note that this function will reset the interval counters (such as
+ * the ones to calculate fraction lost) in the session.
+ *
+ * @param session The RTCP session.
+ * @param rtcp_pkt Upon return, it will contain pointer to the
+ * RTCP packet, which can be RTCP SR or RR.
+ * @param len Upon return, it will indicate the size of
+ * the RTCP packet.
+ */
+PJ_DECL(void) pjmedia_rtcp_build_rtcp( pjmedia_rtcp_session *session,
+ void **rtcp_pkt, int *len);
+
+
+/**
+ * Call this function if RTCP XR needs to be enabled/disabled in the
+ * RTCP session.
+ *
+ * @param session The RTCP session.
+ * @param enable Enable/disable RTCP XR.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_rtcp_enable_xr( pjmedia_rtcp_session *session,
+ pj_bool_t enable);
+
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_RTCP_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/rtcp_xr.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/rtcp_xr.h new file mode 100644 index 0000000..37ecc75 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/rtcp_xr.h @@ -0,0 +1,467 @@ +/* $Id: rtcp_xr.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_RTCP_XR_H__
+#define __PJMEDIA_RTCP_XR_H__
+
+/**
+ * @file rtcp_xr.h
+ * @brief RTCP XR implementation.
+ */
+
+#include <pjmedia/types.h>
+#include <pj/math.h>
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * @defgroup PJMED_RTCP_XR RTCP Extended Report (XR) - RFC 3611
+ * @ingroup PJMEDIA_SESSION
+ * @brief RTCP XR extension to RTCP session
+ * @{
+ *
+ * PJMEDIA implements subsets of RTCP XR specification (RFC 3611) to monitor
+ * the quality of the real-time media (audio/video) transmission.
+ */
+
+/**
+ * Enumeration of report types of RTCP XR. Useful for user to enable varying
+ * combinations of RTCP XR report blocks.
+ */
+typedef enum {
+ PJMEDIA_RTCP_XR_LOSS_RLE = (1 << 0),
+ PJMEDIA_RTCP_XR_DUP_RLE = (1 << 1),
+ PJMEDIA_RTCP_XR_RCPT_TIMES = (1 << 2),
+ PJMEDIA_RTCP_XR_RR_TIME = (1 << 3),
+ PJMEDIA_RTCP_XR_DLRR = (1 << 4),
+ PJMEDIA_RTCP_XR_STATS = (1 << 5),
+ PJMEDIA_RTCP_XR_VOIP_METRICS = (1 << 6)
+} pjmedia_rtcp_xr_type;
+
+/**
+ * Enumeration of info need to be updated manually to RTCP XR. Most info
+ * could be updated automatically each time RTP received.
+ */
+typedef enum {
+ PJMEDIA_RTCP_XR_INFO_SIGNAL_LVL = 1,
+ PJMEDIA_RTCP_XR_INFO_NOISE_LVL = 2,
+ PJMEDIA_RTCP_XR_INFO_RERL = 3,
+ PJMEDIA_RTCP_XR_INFO_R_FACTOR = 4,
+ PJMEDIA_RTCP_XR_INFO_MOS_LQ = 5,
+ PJMEDIA_RTCP_XR_INFO_MOS_CQ = 6,
+ PJMEDIA_RTCP_XR_INFO_CONF_PLC = 7,
+ PJMEDIA_RTCP_XR_INFO_CONF_JBA = 8,
+ PJMEDIA_RTCP_XR_INFO_CONF_JBR = 9,
+ PJMEDIA_RTCP_XR_INFO_JB_NOM = 10,
+ PJMEDIA_RTCP_XR_INFO_JB_MAX = 11,
+ PJMEDIA_RTCP_XR_INFO_JB_ABS_MAX = 12
+} pjmedia_rtcp_xr_info;
+
+/**
+ * Enumeration of PLC types definitions for RTCP XR report.
+ */
+typedef enum {
+ PJMEDIA_RTCP_XR_PLC_UNK = 0,
+ PJMEDIA_RTCP_XR_PLC_DIS = 1,
+ PJMEDIA_RTCP_XR_PLC_ENH = 2,
+ PJMEDIA_RTCP_XR_PLC_STD = 3
+} pjmedia_rtcp_xr_plc_type;
+
+/**
+ * Enumeration of jitter buffer types definitions for RTCP XR report.
+ */
+typedef enum {
+ PJMEDIA_RTCP_XR_JB_UNKNOWN = 0,
+ PJMEDIA_RTCP_XR_JB_FIXED = 2,
+ PJMEDIA_RTCP_XR_JB_ADAPTIVE = 3
+} pjmedia_rtcp_xr_jb_type;
+
+
+#pragma pack(1)
+
+/**
+ * This type declares RTCP XR Report Header.
+ */
+typedef struct pjmedia_rtcp_xr_rb_header
+{
+ pj_uint8_t bt; /**< Block type. */
+ pj_uint8_t specific; /**< Block specific data. */
+ pj_uint16_t length; /**< Block length. */
+} pjmedia_rtcp_xr_rb_header;
+
+/**
+ * This type declares RTCP XR Receiver Reference Time Report Block.
+ */
+typedef struct pjmedia_rtcp_xr_rb_rr_time
+{
+ pjmedia_rtcp_xr_rb_header header; /**< Block header. */
+ pj_uint32_t ntp_sec; /**< NTP time, seconds part. */
+ pj_uint32_t ntp_frac; /**< NTP time, fractions part. */
+} pjmedia_rtcp_xr_rb_rr_time;
+
+
+/**
+ * This type declares RTCP XR DLRR Report Sub-block
+ */
+typedef struct pjmedia_rtcp_xr_rb_dlrr_item
+{
+ pj_uint32_t ssrc; /**< receiver SSRC */
+ pj_uint32_t lrr; /**< last receiver report */
+ pj_uint32_t dlrr; /**< delay since last receiver
+ report */
+} pjmedia_rtcp_xr_rb_dlrr_item;
+
+/**
+ * This type declares RTCP XR DLRR Report Block
+ */
+typedef struct pjmedia_rtcp_xr_rb_dlrr
+{
+ pjmedia_rtcp_xr_rb_header header; /**< Block header. */
+ pjmedia_rtcp_xr_rb_dlrr_item item; /**< Block contents,
+ variable length list */
+} pjmedia_rtcp_xr_rb_dlrr;
+
+/**
+ * This type declares RTCP XR Statistics Summary Report Block
+ */
+typedef struct pjmedia_rtcp_xr_rb_stats
+{
+ pjmedia_rtcp_xr_rb_header header; /**< Block header. */
+ pj_uint32_t ssrc; /**< Receiver SSRC */
+ pj_uint16_t begin_seq; /**< Begin RTP sequence reported */
+ pj_uint16_t end_seq; /**< End RTP sequence reported */
+ pj_uint32_t lost; /**< Number of packet lost in this
+ interval */
+ pj_uint32_t dup; /**< Number of duplicated packet in
+ this interval */
+ pj_uint32_t jitter_min; /**< Minimum jitter in this interval */
+ pj_uint32_t jitter_max; /**< Maximum jitter in this interval */
+ pj_uint32_t jitter_mean; /**< Average jitter in this interval */
+ pj_uint32_t jitter_dev; /**< Jitter deviation in this
+ interval */
+ pj_uint32_t toh_min:8; /**< Minimum ToH in this interval */
+ pj_uint32_t toh_max:8; /**< Maximum ToH in this interval */
+ pj_uint32_t toh_mean:8; /**< Average ToH in this interval */
+ pj_uint32_t toh_dev:8; /**< ToH deviation in this interval */
+} pjmedia_rtcp_xr_rb_stats;
+
+/**
+ * This type declares RTCP XR VoIP Metrics Report Block
+ */
+typedef struct pjmedia_rtcp_xr_rb_voip_mtc
+{
+ pjmedia_rtcp_xr_rb_header header; /**< Block header. */
+ pj_uint32_t ssrc; /**< Receiver SSRC */
+ pj_uint8_t loss_rate; /**< Packet loss rate */
+ pj_uint8_t discard_rate; /**< Packet discarded rate */
+ pj_uint8_t burst_den; /**< Burst density */
+ pj_uint8_t gap_den; /**< Gap density */
+ pj_uint16_t burst_dur; /**< Burst duration */
+ pj_uint16_t gap_dur; /**< Gap duration */
+ pj_uint16_t rnd_trip_delay;/**< Round trip delay */
+ pj_uint16_t end_sys_delay; /**< End system delay */
+ pj_uint8_t signal_lvl; /**< Signal level */
+ pj_uint8_t noise_lvl; /**< Noise level */
+ pj_uint8_t rerl; /**< Residual Echo Return Loss */
+ pj_uint8_t gmin; /**< The gap threshold */
+ pj_uint8_t r_factor; /**< Voice quality metric carried
+ over this RTP session */
+ pj_uint8_t ext_r_factor; /**< Voice quality metric carried
+ outside of this RTP session*/
+ pj_uint8_t mos_lq; /**< Mean Opinion Score for
+ Listening Quality */
+ pj_uint8_t mos_cq; /**< Mean Opinion Score for
+ Conversation Quality */
+ pj_uint8_t rx_config; /**< Receiver configuration */
+ pj_uint8_t reserved2; /**< Not used */
+ pj_uint16_t jb_nom; /**< Current delay by jitter
+ buffer */
+ pj_uint16_t jb_max; /**< Maximum delay by jitter
+ buffer */
+ pj_uint16_t jb_abs_max; /**< Maximum possible delay by
+ jitter buffer */
+} pjmedia_rtcp_xr_rb_voip_mtc;
+
+/**
+ * This structure declares RTCP XR (Extended Report) packet.
+ */
+typedef struct pjmedia_rtcp_xr_pkt
+{
+ struct {
+#if defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN!=0
+ unsigned version:2; /**< packet type */
+ unsigned p:1; /**< padding flag */
+ unsigned count:5; /**< varies by payload type */
+ unsigned pt:8; /**< payload type */
+#else
+ unsigned count:5; /**< varies by payload type */
+ unsigned p:1; /**< padding flag */
+ unsigned version:2; /**< packet type */
+ unsigned pt:8; /**< payload type */
+#endif
+ unsigned length:16; /**< packet length */
+ pj_uint32_t ssrc; /**< SSRC identification */
+ } common;
+
+ pj_int8_t buf[PJMEDIA_MAX_MTU];/**< Content buffer */
+} pjmedia_rtcp_xr_pkt;
+
+#pragma pack()
+
+
+/**
+ * This structure describes RTCP XR statitic.
+ */
+typedef struct pjmedia_rtcp_xr_stream_stat
+{
+ struct {
+ pj_time_val update; /**< Time of last update. */
+
+ pj_uint32_t begin_seq; /**< Begin # seq of this interval. */
+ pj_uint32_t end_seq; /**< End # seq of this interval. */
+ unsigned count; /**< Number of packets. */
+
+ /**
+ * Flags represent whether the such report is valid/updated
+ */
+ unsigned l:1; /**< Lost flag */
+ unsigned d:1; /**< Duplicated flag */
+ unsigned j:1; /**< Jitter flag */
+ unsigned t:2; /**< TTL or Hop Limit,
+ 0=none, 1=TTL, 2=HL */
+
+ unsigned lost; /**< Number of packets lost */
+ unsigned dup; /**< Number of duplicated packets */
+ pj_math_stat jitter; /**< Jitter statistics (in usec) */
+ pj_math_stat toh; /**< TTL of hop limit statistics. */
+ } stat_sum;
+
+ struct {
+ pj_time_val update; /**< Time of last update. */
+
+ pj_uint8_t loss_rate; /**< Packet loss rate */
+ pj_uint8_t discard_rate; /**< Packet discarded rate */
+ pj_uint8_t burst_den; /**< Burst density */
+ pj_uint8_t gap_den; /**< Gap density */
+ pj_uint16_t burst_dur; /**< Burst duration */
+ pj_uint16_t gap_dur; /**< Gap duration */
+ pj_uint16_t rnd_trip_delay; /**< Round trip delay */
+ pj_uint16_t end_sys_delay; /**< End system delay */
+ pj_int8_t signal_lvl; /**< Signal level */
+ pj_int8_t noise_lvl; /**< Noise level */
+ pj_uint8_t rerl; /**< Residual Echo Return Loss */
+ pj_uint8_t gmin; /**< The gap threshold */
+ pj_uint8_t r_factor; /**< Voice quality metric carried
+ over this RTP session */
+ pj_uint8_t ext_r_factor; /**< Voice quality metric carried
+ outside of this RTP session*/
+ pj_uint8_t mos_lq; /**< Mean Opinion Score for
+ Listening Quality */
+ pj_uint8_t mos_cq; /**< Mean Opinion Score for
+ Conversation Quality */
+ pj_uint8_t rx_config; /**< Receiver configuration */
+ pj_uint16_t jb_nom; /**< Current delay by jitter
+ buffer */
+ pj_uint16_t jb_max; /**< Maximum delay by jitter
+ buffer */
+ pj_uint16_t jb_abs_max; /**< Maximum possible delay by
+ jitter buffer */
+ } voip_mtc;
+
+} pjmedia_rtcp_xr_stream_stat;
+
+typedef struct pjmedia_rtcp_xr_stat
+{
+ pjmedia_rtcp_xr_stream_stat rx; /**< Decoding direction statistics. */
+ pjmedia_rtcp_xr_stream_stat tx; /**< Encoding direction statistics. */
+ pj_math_stat rtt; /**< Round-trip delay stat (in usec)
+ the value is calculated from
+ receiver side. */
+} pjmedia_rtcp_xr_stat;
+
+/**
+ * Forward declaration of RTCP session
+ */
+struct pjmedia_rtcp_session;
+
+/**
+ * RTCP session is used to monitor the RTP session of one endpoint. There
+ * should only be one RTCP session for a bidirectional RTP streams.
+ */
+struct pjmedia_rtcp_xr_session
+{
+ char *name; /**< Name identification. */
+ pjmedia_rtcp_xr_pkt pkt; /**< Cached RTCP XR packet. */
+
+ pj_uint32_t rx_lrr; /**< NTP ts in last RR received. */
+ pj_timestamp rx_lrr_time;/**< Time when last RR is received. */
+ pj_uint32_t rx_last_rr; /**< # pkt received since last
+ sending RR time. */
+
+ pjmedia_rtcp_xr_stat stat; /**< RTCP XR statistics. */
+
+ /* The reference sequence number is an extended sequence number
+ * that serves as the basis for determining whether a new 16 bit
+ * sequence number comes earlier or later in the 32 bit sequence
+ * space.
+ */
+ pj_uint32_t src_ref_seq;
+ pj_bool_t uninitialized_src_ref_seq;
+
+ /* This structure contains variables needed for calculating
+ * burst metrics.
+ */
+ struct {
+ pj_uint32_t pkt;
+ pj_uint32_t lost;
+ pj_uint32_t loss_count;
+ pj_uint32_t discard_count;
+ pj_uint32_t c11;
+ pj_uint32_t c13;
+ pj_uint32_t c14;
+ pj_uint32_t c22;
+ pj_uint32_t c23;
+ pj_uint32_t c33;
+ } voip_mtc_stat;
+
+ unsigned ptime; /**< Packet time. */
+ unsigned frames_per_packet; /**< # frames per packet. */
+
+ struct pjmedia_rtcp_session *rtcp_session;
+ /**< Parent/RTCP session. */
+};
+
+typedef struct pjmedia_rtcp_xr_session pjmedia_rtcp_xr_session;
+
+/**
+ * Build an RTCP XR packet which contains one or more RTCP XR report blocks.
+ * There are seven report types as defined in RFC 3611.
+ *
+ * @param session The RTCP XR session.
+ * @param rpt_types Report types to be included in the packet, report types
+ * are defined in pjmedia_rtcp_xr_type, set this to zero
+ * will make this function build all reports appropriately.
+ * @param rtcp_pkt Upon return, it will contain pointer to the RTCP XR packet.
+ * @param len Upon return, it will indicate the size of the generated
+ * RTCP XR packet.
+ */
+PJ_DECL(void) pjmedia_rtcp_build_rtcp_xr( pjmedia_rtcp_xr_session *session,
+ unsigned rpt_types,
+ void **rtcp_pkt, int *len);
+
+/**
+ * Call this function to manually update some info needed by RTCP XR to
+ * generate report which could not be populated directly when receiving
+ * RTP.
+ *
+ * @param session The RTCP XR session.
+ * @param info Info type to be updated, @see pjmedia_rtcp_xr_info.
+ * @param val Value.
+ */
+PJ_DECL(pj_status_t) pjmedia_rtcp_xr_update_info(
+ pjmedia_rtcp_xr_session *session,
+ unsigned info,
+ pj_int32_t val);
+
+/*
+ * Private APIs:
+ */
+
+/**
+ * This function is called internally by RTCP session when RTCP XR is enabled
+ * to initialize the RTCP XR session.
+ *
+ * @param session RTCP XR session.
+ * @param r_session RTCP session.
+ * @param gmin Gmin value (defined in RFC 3611), set to 0 for default (16).
+ * @param ptime Packet time.
+ * @param frames_per_packet
+ Number of frames per packet.
+ */
+void pjmedia_rtcp_xr_init( pjmedia_rtcp_xr_session *session,
+ struct pjmedia_rtcp_session *r_session,
+ pj_uint8_t gmin,
+ unsigned frames_per_packet);
+
+/**
+ * This function is called internally by RTCP session to destroy
+ * the RTCP XR session.
+ *
+ * @param session RTCP XR session.
+ */
+void pjmedia_rtcp_xr_fini( pjmedia_rtcp_xr_session *session );
+
+/**
+ * This function is called internally by RTCP session when it receives
+ * incoming RTCP XR packets.
+ *
+ * @param session RTCP XR session.
+ * @param rtcp_pkt The received RTCP XR packet.
+ * @param size Size of the incoming packet.
+ */
+void pjmedia_rtcp_xr_rx_rtcp_xr( pjmedia_rtcp_xr_session *session,
+ const void *rtcp_xr_pkt,
+ pj_size_t size);
+
+/**
+ * This function is called internally by RTCP session whenever an RTP packet
+ * is received or lost to let the RTCP XR session update its statistics.
+ * Data passed to this function is a result of analyzation by RTCP and the
+ * jitter buffer. Whenever some info is available, the value should be zero
+ * or more (no negative info), otherwise if info is not available the info
+ * should be -1 so no update will be done for this info in the RTCP XR session.
+ *
+ * @param session RTCP XR session.
+ * @param seq Sequence number of RTP packet.
+ * @param lost Info if this packet is lost.
+ * @param dup Info if this packet is a duplication.
+ * @param discarded Info if this packet is discarded
+ * (not because of duplication).
+ * @param jitter Info jitter of this packet.
+ * @param toh Info Time To Live or Hops Limit of this packet.
+ * @param toh_ipv4 Set PJ_TRUE if packet is transported over IPv4.
+ */
+void pjmedia_rtcp_xr_rx_rtp( pjmedia_rtcp_xr_session *session,
+ unsigned seq,
+ int lost,
+ int dup,
+ int discarded,
+ int jitter,
+ int toh, pj_bool_t toh_ipv4);
+
+/**
+ * This function is called internally by RTCP session whenever an RTP
+ * packet is sent to let the RTCP XR session do its internal calculations.
+ *
+ * @param session RTCP XR session.
+ * @param ptsize Size of RTP payload being sent.
+ */
+void pjmedia_rtcp_xr_tx_rtp( pjmedia_rtcp_xr_session *session,
+ unsigned ptsize );
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_RTCP_XR_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/rtp.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/rtp.h new file mode 100644 index 0000000..86cda9c --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/rtp.h @@ -0,0 +1,394 @@ +/* $Id: rtp.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_RTP_H__
+#define __PJMEDIA_RTP_H__
+
+
+/**
+ * @file rtp.h
+ * @brief RTP packet and RTP session declarations.
+ */
+#include <pjmedia/types.h>
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * @defgroup PJMED_RTP RTP Session and Encapsulation (RFC 3550)
+ * @ingroup PJMEDIA_SESSION
+ * @brief RTP format and session management
+ * @{
+ *
+ * The RTP module is designed to be dependent only to PJLIB, it does not depend
+ * on any other parts of PJMEDIA library. The RTP module does not even depend
+ * on any transports (sockets), to promote even more use, such as in DSP
+ * development (where transport may be handled by different processor).
+ *
+ * An RTCP implementation is available, in separate module. Please see
+ * @ref PJMED_RTCP.
+ *
+ * The functions that are provided by this module:
+ * - creating RTP header for each outgoing packet.
+ * - decoding RTP packet into RTP header and payload.
+ * - provide simple RTP session management (sequence number, etc.)
+ *
+ * The RTP module does not use any dynamic memory at all.
+ *
+ * \section P1 How to Use the RTP Module
+ *
+ * First application must call #pjmedia_rtp_session_init() to initialize the RTP
+ * session.
+ *
+ * When application wants to send RTP packet, it needs to call
+ * #pjmedia_rtp_encode_rtp() to build the RTP header. Note that this WILL NOT build
+ * the complete RTP packet, but instead only the header. Application can
+ * then either concatenate the header with the payload, or send the two
+ * fragments (the header and the payload) using scatter-gather transport API
+ * (e.g. \a sendv()).
+ *
+ * When application receives an RTP packet, first it should call
+ * #pjmedia_rtp_decode_rtp to decode RTP header and payload, then it should call
+ * #pjmedia_rtp_session_update to check whether we can process the RTP payload,
+ * and to let the RTP session updates its internal status. The decode function
+ * is guaranteed to point the payload to the correct position regardless of
+ * any options present in the RTP packet.
+ *
+ */
+
+#ifdef _MSC_VER
+# pragma warning(disable:4214) // bit field types other than int
+#endif
+
+
+/**
+ * RTP packet header. Note that all RTP functions here will work with this
+ * header in network byte order.
+ */
+#pragma pack(1)
+struct pjmedia_rtp_hdr
+{
+#if defined(PJ_IS_BIG_ENDIAN) && (PJ_IS_BIG_ENDIAN!=0)
+ pj_uint16_t v:2; /**< packet type/version */
+ pj_uint16_t p:1; /**< padding flag */
+ pj_uint16_t x:1; /**< extension flag */
+ pj_uint16_t cc:4; /**< CSRC count */
+ pj_uint16_t m:1; /**< marker bit */
+ pj_uint16_t pt:7; /**< payload type */
+#else
+ pj_uint16_t cc:4; /**< CSRC count */
+ pj_uint16_t x:1; /**< header extension flag */
+ pj_uint16_t p:1; /**< padding flag */
+ pj_uint16_t v:2; /**< packet type/version */
+ pj_uint16_t pt:7; /**< payload type */
+ pj_uint16_t m:1; /**< marker bit */
+#endif
+ pj_uint16_t seq; /**< sequence number */
+ pj_uint32_t ts; /**< timestamp */
+ pj_uint32_t ssrc; /**< synchronization source */
+};
+#pragma pack()
+
+/**
+ * @see pjmedia_rtp_hdr
+ */
+typedef struct pjmedia_rtp_hdr pjmedia_rtp_hdr;
+
+
+/**
+ * RTP extendsion header.
+ */
+struct pjmedia_rtp_ext_hdr
+{
+ pj_uint16_t profile_data; /**< Profile data. */
+ pj_uint16_t length; /**< Length. */
+};
+
+/**
+ * @see pjmedia_rtp_ext_hdr
+ */
+typedef struct pjmedia_rtp_ext_hdr pjmedia_rtp_ext_hdr;
+
+
+#pragma pack(1)
+
+/**
+ * Declaration for DTMF telephony-events (RFC2833).
+ */
+struct pjmedia_rtp_dtmf_event
+{
+ pj_uint8_t event; /**< Event type ID. */
+ pj_uint8_t e_vol; /**< Event volume. */
+ pj_uint16_t duration; /**< Event duration. */
+};
+
+/**
+ * @see pjmedia_rtp_dtmf_event
+ */
+typedef struct pjmedia_rtp_dtmf_event pjmedia_rtp_dtmf_event;
+
+#pragma pack()
+
+
+/**
+ * A generic sequence number management, used by both RTP and RTCP.
+ */
+struct pjmedia_rtp_seq_session
+{
+ pj_uint16_t max_seq; /**< Highest sequence number heard */
+ pj_uint32_t cycles; /**< Shifted count of seq number cycles */
+ pj_uint32_t base_seq; /**< Base seq number */
+ pj_uint32_t bad_seq; /**< Last 'bad' seq number + 1 */
+ pj_uint32_t probation; /**< Sequ. packets till source is valid */
+};
+
+/**
+ * @see pjmedia_rtp_seq_session
+ */
+typedef struct pjmedia_rtp_seq_session pjmedia_rtp_seq_session;
+
+
+/**
+ * RTP session descriptor.
+ */
+struct pjmedia_rtp_session
+{
+ pjmedia_rtp_hdr out_hdr; /**< Saved hdr for outgoing pkts. */
+ pjmedia_rtp_seq_session seq_ctrl; /**< Sequence number management. */
+ pj_uint16_t out_pt; /**< Default outgoing payload type. */
+ pj_uint32_t out_extseq; /**< Outgoing extended seq #. */
+ pj_uint32_t peer_ssrc; /**< Peer SSRC. */
+ pj_uint32_t received; /**< Number of received packets. */
+};
+
+/**
+ * @see pjmedia_rtp_session
+ */
+typedef struct pjmedia_rtp_session pjmedia_rtp_session;
+
+
+/**
+ * This structure is used to receive additional information about the
+ * state of incoming RTP packet.
+ */
+struct pjmedia_rtp_status
+{
+ union {
+ struct flag {
+ int bad:1; /**< General flag to indicate that sequence is
+ bad, and application should not process
+ this packet. More information will be given
+ in other flags. */
+ int badpt:1; /**< Bad payload type. */
+ int badssrc:1; /**< Bad SSRC */
+ int dup:1; /**< Indicates duplicate packet */
+ int outorder:1; /**< Indicates out of order packet */
+ int probation:1;/**< Indicates that session is in probation
+ until more packets are received. */
+ int restart:1; /**< Indicates that sequence number has made
+ a large jump, and internal base sequence
+ number has been adjusted. */
+ } flag; /**< Status flags. */
+
+ pj_uint16_t value; /**< Status value, to conveniently address all
+ flags. */
+
+ } status; /**< Status information union. */
+
+ pj_uint16_t diff; /**< Sequence number difference from previous
+ packet. Normally the value should be 1.
+ Value greater than one may indicate packet
+ loss. If packet with lower sequence is
+ received, the value will be set to zero.
+ If base sequence has been restarted, the
+ value will be one. */
+};
+
+
+/**
+ * RTP session settings.
+ */
+typedef struct pjmedia_rtp_session_setting
+{
+ pj_uint8_t flags; /**< Bitmask flags to specify whether such
+ field is set. Bitmask contents are:
+ (bit #0 is LSB)
+ bit #0: default payload type
+ bit #1: sender SSRC
+ bit #2: sequence
+ bit #3: timestamp */
+ int default_pt; /**< Default payload type. */
+ pj_uint32_t sender_ssrc; /**< Sender SSRC. */
+ pj_uint16_t seq; /**< Sequence. */
+ pj_uint32_t ts; /**< Timestamp. */
+} pjmedia_rtp_session_setting;
+
+
+/**
+ * @see pjmedia_rtp_status
+ */
+typedef struct pjmedia_rtp_status pjmedia_rtp_status;
+
+
+/**
+ * This function will initialize the RTP session according to given parameters.
+ *
+ * @param ses The session.
+ * @param default_pt Default payload type.
+ * @param sender_ssrc SSRC used for outgoing packets, in host byte order.
+ *
+ * @return PJ_SUCCESS if successfull.
+ */
+PJ_DECL(pj_status_t) pjmedia_rtp_session_init( pjmedia_rtp_session *ses,
+ int default_pt,
+ pj_uint32_t sender_ssrc );
+
+/**
+ * This function will initialize the RTP session according to given parameters
+ * defined in RTP session settings.
+ *
+ * @param ses The session.
+ * @param settings RTP session settings.
+ *
+ * @return PJ_SUCCESS if successfull.
+ */
+PJ_DECL(pj_status_t) pjmedia_rtp_session_init2(
+ pjmedia_rtp_session *ses,
+ pjmedia_rtp_session_setting settings);
+
+
+/**
+ * Create the RTP header based on arguments and current state of the RTP
+ * session.
+ *
+ * @param ses The session.
+ * @param pt Payload type.
+ * @param m Marker flag.
+ * @param payload_len Payload length in bytes.
+ * @param ts_len Timestamp length.
+ * @param rtphdr Upon return will point to RTP packet header.
+ * @param hdrlen Upon return will indicate the size of RTP packet header
+ *
+ * @return PJ_SUCCESS if successfull.
+ */
+PJ_DECL(pj_status_t) pjmedia_rtp_encode_rtp( pjmedia_rtp_session *ses,
+ int pt, int m,
+ int payload_len, int ts_len,
+ const void **rtphdr,
+ int *hdrlen );
+
+/**
+ * This function decodes incoming packet into RTP header and payload.
+ * The decode function is guaranteed to point the payload to the correct
+ * position regardless of any options present in the RTP packet.
+ *
+ * Note that this function does not modify the returned RTP header to
+ * host byte order.
+ *
+ * @param ses The session.
+ * @param pkt The received RTP packet.
+ * @param pkt_len The length of the packet.
+ * @param hdr Upon return will point to the location of the RTP
+ * header inside the packet. Note that the RTP header
+ * will be given back as is, meaning that the fields
+ * will be in network byte order.
+ * @param payload Upon return will point to the location of the
+ * payload inside the packet.
+ * @param payloadlen Upon return will indicate the size of the payload.
+ *
+ * @return PJ_SUCCESS if successfull.
+ */
+PJ_DECL(pj_status_t) pjmedia_rtp_decode_rtp( pjmedia_rtp_session *ses,
+ const void *pkt, int pkt_len,
+ const pjmedia_rtp_hdr **hdr,
+ const void **payload,
+ unsigned *payloadlen);
+
+/**
+ * Call this function everytime an RTP packet is received to check whether
+ * the packet can be received and to let the RTP session performs its internal
+ * calculations.
+ *
+ * @param ses The session.
+ * @param hdr The RTP header of the incoming packet. The header must
+ * be given with fields in network byte order.
+ * @param seq_st Optional structure to receive the status of the RTP packet
+ * processing.
+ */
+PJ_DECL(void) pjmedia_rtp_session_update( pjmedia_rtp_session *ses,
+ const pjmedia_rtp_hdr *hdr,
+ pjmedia_rtp_status *seq_st);
+
+
+/**
+ * Call this function everytime an RTP packet is received to check whether
+ * the packet can be received and to let the RTP session performs its internal
+ * calculations.
+ *
+ * @param ses The session.
+ * @param hdr The RTP header of the incoming packet. The header must
+ * be given with fields in network byte order.
+ * @param seq_st Optional structure to receive the status of the RTP packet
+ * processing.
+ * @param check_pt Flag to indicate whether payload type needs to be validate.
+ *
+ * @see pjmedia_rtp_session_update()
+ */
+PJ_DECL(void) pjmedia_rtp_session_update2(pjmedia_rtp_session *ses,
+ const pjmedia_rtp_hdr *hdr,
+ pjmedia_rtp_status *seq_st,
+ pj_bool_t check_pt);
+
+
+/*
+ * INTERNAL:
+ */
+
+/**
+ * Internal function for creating sequence number control, shared by RTCP
+ * implementation.
+ *
+ * @param seq_ctrl The sequence control instance.
+ * @param seq Sequence number to initialize.
+ */
+void pjmedia_rtp_seq_init(pjmedia_rtp_seq_session *seq_ctrl,
+ pj_uint16_t seq);
+
+
+/**
+ * Internal function update sequence control, shared by RTCP implementation.
+ *
+ * @param seq_ctrl The sequence control instance.
+ * @param seq Sequence number to update.
+ * @param seq_status Optional structure to receive additional information
+ * about the packet.
+ */
+void pjmedia_rtp_seq_update( pjmedia_rtp_seq_session *seq_ctrl,
+ pj_uint16_t seq,
+ pjmedia_rtp_status *seq_status);
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_RTP_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/sdp.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/sdp.h new file mode 100644 index 0000000..e49fc36 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/sdp.h @@ -0,0 +1,674 @@ +/* $Id: sdp.h 2995 2009-11-09 05:18:12Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_SDP_H__
+#define __PJMEDIA_SDP_H__
+
+/**
+ * @file sdp.h
+ * @brief SDP header file.
+ */
+#include <pjmedia/types.h>
+
+
+/**
+ * @defgroup PJMEDIA_SDP SDP Parsing and Data Structure
+ * @ingroup PJMEDIA_SESSION
+ * @brief SDP data structure representation and parsing
+ * @{
+ *
+ * The basic SDP session descriptor and elements are described in header
+ * file <b><pjmedia/sdp.h></b>. This file contains declaration for
+ * SDP session descriptor and SDP media descriptor, along with their
+ * attributes. This file also declares functions to parse SDP message.
+ */
+
+
+PJ_BEGIN_DECL
+
+/**
+ * The PJMEDIA_MAX_SDP_FMT macro defines maximum format in a media line.
+ */
+#ifndef PJMEDIA_MAX_SDP_FMT
+# define PJMEDIA_MAX_SDP_FMT 32
+#endif
+
+/**
+ * The PJMEDIA_MAX_SDP_ATTR macro defines maximum SDP attributes in media and
+ * session descriptor.
+ */
+#ifndef PJMEDIA_MAX_SDP_ATTR
+# define PJMEDIA_MAX_SDP_ATTR (PJMEDIA_MAX_SDP_FMT*2 + 4)
+#endif
+
+/**
+ * The PJMEDIA_MAX_SDP_MEDIA macro defines maximum SDP media lines in a
+ * SDP session descriptor.
+ */
+#ifndef PJMEDIA_MAX_SDP_MEDIA
+# define PJMEDIA_MAX_SDP_MEDIA 16
+#endif
+
+
+/* **************************************************************************
+ * SDP ATTRIBUTES
+ ***************************************************************************
+ */
+
+/**
+ * Generic representation of attribute.
+ */
+struct pjmedia_sdp_attr
+{
+ pj_str_t name; /**< Attribute name. */
+ pj_str_t value; /**< Attribute value. */
+};
+
+/**
+ * @see pjmedia_sdp_attr
+ */
+typedef struct pjmedia_sdp_attr pjmedia_sdp_attr;
+
+
+/**
+ * Create SDP attribute.
+ *
+ * @param pool Pool to create the attribute.
+ * @param name Attribute name.
+ * @param value Optional attribute value.
+ *
+ * @return The new SDP attribute.
+ */
+PJ_DECL(pjmedia_sdp_attr*) pjmedia_sdp_attr_create(pj_pool_t *pool,
+ const char *name,
+ const pj_str_t *value);
+
+/**
+ * Clone attribute
+ *
+ * @param pool Pool to be used.
+ * @param attr The attribute to clone.
+ *
+ * @return New attribute as cloned from the attribute.
+ */
+PJ_DECL(pjmedia_sdp_attr*) pjmedia_sdp_attr_clone(pj_pool_t *pool,
+ const pjmedia_sdp_attr*attr);
+
+/**
+ * Find the first attribute with the specified type.
+ *
+ * @param count Number of attributes in the array.
+ * @param attr_array Array of attributes.
+ * @param name Attribute name to find.
+ * @param fmt Optional string to indicate which payload format
+ * to find for \a rtpmap and \a fmt attributes. For other
+ * types of attributes, the value should be NULL.
+ *
+ * @return The specified attribute, or NULL if it can't be found.
+ *
+ * @see pjmedia_sdp_attr_find2, pjmedia_sdp_media_find_attr,
+ * pjmedia_sdp_media_find_attr2
+ */
+PJ_DECL(pjmedia_sdp_attr*)
+pjmedia_sdp_attr_find(unsigned count,
+ pjmedia_sdp_attr *const attr_array[],
+ const pj_str_t *name, const pj_str_t *fmt);
+
+/**
+ * Find the first attribute with the specified type.
+ *
+ * @param count Number of attributes in the array.
+ * @param attr_array Array of attributes.
+ * @param name Attribute name to find.
+ * @param fmt Optional string to indicate which payload format
+ * to find for \a rtpmap and \a fmt attributes. For other
+ * types of attributes, the value should be NULL.
+ *
+ * @return The specified attribute, or NULL if it can't be found.
+ *
+ * @see pjmedia_sdp_attr_find, pjmedia_sdp_media_find_attr,
+ * pjmedia_sdp_media_find_attr2
+ */
+PJ_DECL(pjmedia_sdp_attr*)
+pjmedia_sdp_attr_find2(unsigned count,
+ pjmedia_sdp_attr *const attr_array[],
+ const char *name, const pj_str_t *fmt);
+
+/**
+ * Add a new attribute to array of attributes.
+ *
+ * @param count Number of attributes in the array.
+ * @param attr_array Array of attributes.
+ * @param attr The attribute to add.
+ *
+ * @return PJ_SUCCESS or the error code.
+ *
+ * @see pjmedia_sdp_media_add_attr
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_attr_add(unsigned *count,
+ pjmedia_sdp_attr *attr_array[],
+ pjmedia_sdp_attr *attr);
+
+/**
+ * Remove all attributes with the specified name in array of attributes.
+ *
+ * @param count Number of attributes in the array.
+ * @param attr_array Array of attributes.
+ * @param name Attribute name to find.
+ *
+ * @return Number of attributes removed.
+ *
+ * @see pjmedia_sdp_media_remove_all_attr
+ */
+PJ_DECL(unsigned) pjmedia_sdp_attr_remove_all(unsigned *count,
+ pjmedia_sdp_attr *attr_array[],
+ const char *name);
+
+
+/**
+ * Remove the specified attribute from the attribute array.
+ *
+ * @param count Number of attributes in the array.
+ * @param attr_array Array of attributes.
+ * @param attr The attribute instance to remove.
+ *
+ * @return PJ_SUCCESS when attribute has been removed, or
+ * PJ_ENOTFOUND when the attribute can not be found.
+ *
+ * @see pjmedia_sdp_media_remove_attr
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_attr_remove(unsigned *count,
+ pjmedia_sdp_attr *attr_array[],
+ pjmedia_sdp_attr *attr);
+
+
+/**
+ * This structure declares SDP \a rtpmap attribute.
+ */
+struct pjmedia_sdp_rtpmap
+{
+ pj_str_t pt; /**< Payload type. */
+ pj_str_t enc_name; /**< Encoding name. */
+ unsigned clock_rate; /**< Clock rate. */
+ pj_str_t param; /**< Parameter. */
+};
+
+/**
+ * @see pjmedia_sdp_rtpmap
+ */
+typedef struct pjmedia_sdp_rtpmap pjmedia_sdp_rtpmap;
+
+
+/**
+ * Convert generic attribute to SDP \a rtpmap. This function allocates
+ * a new attribute and call #pjmedia_sdp_attr_get_rtpmap().
+ *
+ * @param pool Pool used to create the rtpmap attribute.
+ * @param attr Generic attribute to be converted to rtpmap, which
+ * name must be "rtpmap".
+ * @param p_rtpmap Pointer to receive SDP rtpmap attribute.
+ *
+ * @return PJ_SUCCESS if the attribute can be successfully
+ * converted to \a rtpmap type.
+ *
+ * @see pjmedia_sdp_attr_get_rtpmap
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_attr_to_rtpmap(pj_pool_t *pool,
+ const pjmedia_sdp_attr *attr,
+ pjmedia_sdp_rtpmap **p_rtpmap);
+
+
+/**
+ * Get the rtpmap representation of the same SDP attribute.
+ *
+ * @param attr Generic attribute to be converted to rtpmap, which
+ * name must be "rtpmap".
+ * @param rtpmap SDP \a rtpmap attribute to be initialized.
+ *
+ * @return PJ_SUCCESS if the attribute can be successfully
+ * converted to \a rtpmap attribute.
+ *
+ * @see pjmedia_sdp_attr_to_rtpmap
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_attr_get_rtpmap(const pjmedia_sdp_attr *attr,
+ pjmedia_sdp_rtpmap *rtpmap);
+
+
+/**
+ * Convert \a rtpmap attribute to generic attribute.
+ *
+ * @param pool Pool to be used.
+ * @param rtpmap The \a rtpmap attribute.
+ * @param p_attr Pointer to receive the generic SDP attribute.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_rtpmap_to_attr( pj_pool_t *pool,
+ const pjmedia_sdp_rtpmap *rtpmap,
+ pjmedia_sdp_attr **p_attr);
+
+
+/**
+ * This structure describes SDP \a fmtp attribute.
+ */
+struct pjmedia_sdp_fmtp
+{
+ pj_str_t fmt; /**< Format type. */
+ pj_str_t fmt_param; /**< Format specific parameter. */
+};
+
+
+/**
+ * @see pjmedia_sdp_fmtp
+ */
+typedef struct pjmedia_sdp_fmtp pjmedia_sdp_fmtp;
+
+
+
+/**
+ * Get the fmtp representation of the same SDP attribute.
+ *
+ * @param attr Generic attribute to be converted to fmtp, which
+ * name must be "fmtp".
+ * @param fmtp SDP fmtp attribute to be initialized.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_attr_get_fmtp(const pjmedia_sdp_attr *attr,
+ pjmedia_sdp_fmtp *fmtp);
+
+
+/**
+ * This structure describes SDP \a rtcp attribute.
+ */
+typedef struct pjmedia_sdp_rtcp_attr
+{
+ unsigned port; /**< RTCP port number. */
+ pj_str_t net_type; /**< Optional network type. */
+ pj_str_t addr_type; /**< Optional address type. */
+ pj_str_t addr; /**< Optional address. */
+} pjmedia_sdp_rtcp_attr;
+
+
+/**
+ * Parse a generic SDP attribute to get SDP rtcp attribute values.
+ *
+ * @param attr Generic attribute to be converted to rtcp, which
+ * name must be "rtcp".
+ * @param rtcp SDP rtcp attribute to be initialized.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_attr_get_rtcp(const pjmedia_sdp_attr *attr,
+ pjmedia_sdp_rtcp_attr *rtcp);
+
+
+/**
+ * Create a=rtcp attribute.
+ *
+ * @param pool Pool to create the attribute.
+ * @param a Socket address.
+ *
+ * @return SDP RTCP attribute.
+ */
+PJ_DECL(pjmedia_sdp_attr*) pjmedia_sdp_attr_create_rtcp(pj_pool_t *pool,
+ const pj_sockaddr *a);
+
+
+/* **************************************************************************
+ * SDP CONNECTION INFO
+ ****************************************************************************
+ */
+
+/**
+ * This structure describes SDP connection info ("c=" line).
+ */
+struct pjmedia_sdp_conn
+{
+ pj_str_t net_type; /**< Network type ("IN"). */
+ pj_str_t addr_type; /**< Address type ("IP4", "IP6"). */
+ pj_str_t addr; /**< The address. */
+};
+
+
+/**
+ * @see pjmedia_sdp_conn
+ */
+typedef struct pjmedia_sdp_conn pjmedia_sdp_conn;
+
+
+/**
+ * Clone connection info.
+ *
+ * @param pool Pool to allocate memory for the new connection info.
+ * @param rhs The connection into to clone.
+ *
+ * @return The new connection info.
+ */
+PJ_DECL(pjmedia_sdp_conn*) pjmedia_sdp_conn_clone(pj_pool_t *pool,
+ const pjmedia_sdp_conn *rhs);
+
+
+
+/* **************************************************************************
+ * SDP MEDIA INFO/LINE
+ ****************************************************************************
+ */
+
+/**
+ * This structure describes SDP media descriptor. A SDP media descriptor
+ * starts with "m=" line and contains the media attributes and optional
+ * connection line.
+ */
+struct pjmedia_sdp_media
+{
+ /** Media descriptor line ("m=" line) */
+ struct
+ {
+ pj_str_t media; /**< Media type ("audio", "video") */
+ pj_uint16_t port; /**< Port number. */
+ unsigned port_count; /**< Port count, used only when >2 */
+ pj_str_t transport; /**< Transport ("RTP/AVP") */
+ unsigned fmt_count; /**< Number of formats. */
+ pj_str_t fmt[PJMEDIA_MAX_SDP_FMT]; /**< Media formats. */
+ } desc;
+
+ pjmedia_sdp_conn *conn; /**< Optional connection info. */
+ unsigned attr_count; /**< Number of attributes. */
+ pjmedia_sdp_attr*attr[PJMEDIA_MAX_SDP_ATTR]; /**< Attributes. */
+
+};
+
+
+/**
+ * @see pjmedia_sdp_media
+ */
+typedef struct pjmedia_sdp_media pjmedia_sdp_media;
+
+
+/**
+ * Clone SDP media description.
+ *
+ * @param pool Pool to allocate memory for the new media description.
+ * @param rhs The media descriptin to clone.
+ *
+ * @return New media description.
+ */
+PJ_DECL(pjmedia_sdp_media*)
+pjmedia_sdp_media_clone( pj_pool_t *pool,
+ const pjmedia_sdp_media *rhs);
+
+/**
+ * Find the first occurence of the specified attribute name in the media
+ * descriptor. Optionally the format may be specified.
+ *
+ * @param m The SDP media description.
+ * @param name Attribute name to find.
+ * @param fmt Optional payload type to match in the
+ * attribute list, when the attribute is \a rtpmap
+ * or \a fmtp. For other types of SDP attributes, this
+ * value should be NULL.
+ *
+ * @return The first instance of the specified attribute or NULL.
+ */
+PJ_DECL(pjmedia_sdp_attr*)
+pjmedia_sdp_media_find_attr(const pjmedia_sdp_media *m,
+ const pj_str_t *name, const pj_str_t *fmt);
+
+
+/**
+ * Find the first occurence of the specified attribute name in the SDP media
+ * descriptor. Optionally the format may be specified.
+ *
+ * @param m The SDP media description.
+ * @param name Attribute name to find.
+ * @param fmt Optional payload type to match in the
+ * attribute list, when the attribute is \a rtpmap
+ * or \a fmtp. For other types of SDP attributes, this
+ * value should be NULL.
+ *
+ * @return The first instance of the specified attribute or NULL.
+ */
+PJ_DECL(pjmedia_sdp_attr*)
+pjmedia_sdp_media_find_attr2(const pjmedia_sdp_media *m,
+ const char *name, const pj_str_t *fmt);
+
+/**
+ * Add new attribute to the media descriptor.
+ *
+ * @param m The SDP media description.
+ * @param attr Attribute to add.
+ *
+ * @return PJ_SUCCESS or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_media_add_attr(pjmedia_sdp_media *m,
+ pjmedia_sdp_attr *attr);
+
+/**
+ * Remove all attributes with the specified name from the SDP media
+ * descriptor.
+ *
+ * @param m The SDP media description.
+ * @param name Attribute name to remove.
+ *
+ * @return The number of attributes removed.
+ */
+PJ_DECL(unsigned)
+pjmedia_sdp_media_remove_all_attr(pjmedia_sdp_media *m,
+ const char *name);
+
+
+/**
+ * Remove the occurence of the specified attribute from the SDP media
+ * descriptor.
+ *
+ * @param m The SDP media descriptor.
+ * @param attr The attribute to find and remove.
+ *
+ * @return PJ_SUCCESS if the attribute can be found and has
+ * been removed from the array.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_media_remove_attr(pjmedia_sdp_media *m,
+ pjmedia_sdp_attr *attr);
+
+
+/**
+ * Compare two SDP media for equality.
+ *
+ * @param sd1 The first SDP media to compare.
+ * @param sd2 The second SDP media to compare.
+ * @param option Comparison option, which should be zero for now.
+ *
+ * @return PJ_SUCCESS when both SDP medias are equal, or the
+ * appropriate status code describing which part of
+ * the descriptors that are not equal.
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_media_cmp(const pjmedia_sdp_media *sd1,
+ const pjmedia_sdp_media *sd2,
+ unsigned option);
+
+
+/**
+ * Compare two media transports for compatibility.
+ *
+ * @param t1 The first media transport to compare.
+ * @param t2 The second media transport to compare.
+ *
+ * @return PJ_SUCCESS when both media transports are compatible,
+ * otherwise returns PJMEDIA_SDP_ETPORTNOTEQUAL.
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_transport_cmp(const pj_str_t *t1,
+ const pj_str_t *t2);
+
+
+/**
+ * Deactivate SDP media.
+ *
+ * @param m The SDP media to deactivate.
+ *
+ * @return PJ_SUCCESS when SDP media successfully deactivated,
+ * otherwise appropriate status code returned.
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_media_deactivate(pj_pool_t *pool,
+ pjmedia_sdp_media *m);
+
+
+/* **************************************************************************
+ * SDP SESSION DESCRIPTION
+ ****************************************************************************
+ */
+
+
+/**
+ * This structure describes SDP session description. A SDP session descriptor
+ * contains complete information about a session, and normally is exchanged
+ * with remote media peer using signaling protocol such as SIP.
+ */
+struct pjmedia_sdp_session
+{
+ /** Session origin (o= line) */
+ struct
+ {
+ pj_str_t user; /**< User */
+ pj_uint32_t id; /**< Session ID */
+ pj_uint32_t version; /**< Session version */
+ pj_str_t net_type; /**< Network type ("IN") */
+ pj_str_t addr_type; /**< Address type ("IP4", "IP6") */
+ pj_str_t addr; /**< The address. */
+ } origin;
+
+ pj_str_t name; /**< Subject line (s=) */
+ pjmedia_sdp_conn *conn; /**< Connection line (c=) */
+
+ /** Session time (t= line) */
+ struct
+ {
+ pj_uint32_t start; /**< Start time. */
+ pj_uint32_t stop; /**< Stop time. */
+ } time;
+
+ unsigned attr_count; /**< Number of attributes. */
+ pjmedia_sdp_attr *attr[PJMEDIA_MAX_SDP_ATTR]; /**< Attributes array. */
+
+ unsigned media_count; /**< Number of media. */
+ pjmedia_sdp_media *media[PJMEDIA_MAX_SDP_MEDIA]; /**< Media array. */
+
+};
+
+/**
+ * @see pjmedia_sdp_session
+ */
+typedef struct pjmedia_sdp_session pjmedia_sdp_session;
+
+
+
+/**
+ * Parse SDP message.
+ *
+ * @param pool The pool to allocate SDP session description.
+ * @param buf The message buffer.
+ * @param len The length of the message.
+ * @param p_sdp Pointer to receive the SDP session descriptor.
+ *
+ * @return PJ_SUCCESS if message was successfully parsed into
+ * SDP session descriptor.
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_parse( pj_pool_t *pool,
+ char *buf, pj_size_t len,
+ pjmedia_sdp_session **p_sdp );
+
+/**
+ * Print SDP description to a buffer.
+ *
+ * @param sdp The SDP session description.
+ * @param buf The buffer.
+ * @param size The buffer length.
+ *
+ * @return the length printed, or -1 if the buffer is too
+ * short.
+ */
+PJ_DECL(int) pjmedia_sdp_print( const pjmedia_sdp_session *sdp,
+ char *buf, pj_size_t size);
+
+
+/**
+ * Perform semantic validation for the specified SDP session descriptor.
+ * This function perform validation beyond just syntactic verification,
+ * such as to verify the value of network type and address type, check
+ * the connection line, and verify that \a rtpmap attribute is present
+ * when dynamic payload type is used.
+ *
+ * @param sdp The SDP session descriptor to validate.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_validate(const pjmedia_sdp_session *sdp);
+
+
+/**
+ * Clone SDP session descriptor.
+ *
+ * @param pool The pool used to clone the session.
+ * @param sdp The SDP session to clone.
+ *
+ * @return New SDP session.
+ */
+PJ_DECL(pjmedia_sdp_session*)
+pjmedia_sdp_session_clone( pj_pool_t *pool,
+ const pjmedia_sdp_session *sdp);
+
+
+/**
+ * Compare two SDP session for equality.
+ *
+ * @param sd1 The first SDP session to compare.
+ * @param sd2 The second SDP session to compare.
+ * @param option Must be zero for now.
+ *
+ * @return PJ_SUCCESS when both SDPs are equal, or otherwise
+ * the status code indicates which part of the session
+ * descriptors are not equal.
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_session_cmp(const pjmedia_sdp_session *sd1,
+ const pjmedia_sdp_session *sd2,
+ unsigned option);
+
+
+/**
+ * Add new attribute to the session descriptor.
+ *
+ * @param s The SDP session description.
+ * @param attr Attribute to add.
+ *
+ * @return PJ_SUCCESS or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_session_add_attr(pjmedia_sdp_session *m,
+ pjmedia_sdp_attr *attr);
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_SDP_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/sdp_neg.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/sdp_neg.h new file mode 100644 index 0000000..caa4906 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/sdp_neg.h @@ -0,0 +1,674 @@ +/* $Id: sdp_neg.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_SDP_NEG_H__
+#define __PJMEDIA_SDP_NEG_H__
+
+
+/**
+ * @file sdp_neg.h
+ * @brief SDP negotiator header file.
+ */
+/**
+ * @defgroup PJMEDIA_SDP_NEG SDP Negotiation State Machine (Offer/Answer Model, RFC 3264)
+ * @ingroup PJMEDIA_SESSION
+ * @brief SDP Negotiation State Machine (Offer/Answer Model, RFC 3264)
+ * @{
+ *
+ * The header file <b><pjmedia/sdp_neg.h></b> contains the declaration
+ * of SDP offer and answer negotiator. SDP offer and answer model is described
+ * in RFC 3264 <b>"An Offer/Answer Model with Session Description Protocol
+ * (SDP)"</b>.
+ *
+ * The SDP negotiator is represented with opaque type \a pjmedia_sdp_neg.
+ * This structure contains negotiation state and several SDP session
+ * descriptors currently being used in the negotiation.
+ *
+ *
+ * \section sdpneg_state_dia SDP Negotiator State Diagram
+ *
+ * The following diagram describes the state transition diagram of the
+ * SDP negotiator.
+ *
+ * <pre>
+ *
+ * modify_local_offer()
+ * create_w_local_offer() +-------------+ send_local_offer()
+ * ----------------------->| LOCAL_OFFER |<-----------------------
+ * | +-------------+______ |
+ * | | \______ cancel() |
+ * | set_remote_answer() | \______ |
+ * | V \ |
+ * +--+---+ +-----------+ negotiate() +-~----+
+ * | NULL | | WAIT_NEGO |-------------------->| DONE |
+ * +------+ +-----------+ +------+
+ * | A |
+ * | set_local_answer() | |
+ * | | |
+ * | +--------------+ set_remote_offer() |
+ * ----------------------->| REMOTE_OFFER |<----------------------
+ * create_w_remote_offer() +--------------+
+ *
+ * </pre>
+ *
+ *
+ *
+ * \section sdpneg_offer_answer SDP Offer/Answer Model with Negotiator
+ *
+ * \subsection sdpneg_create_offer Creating Initial Offer
+ *
+ * Application creates an offer by manualy building the SDP session descriptor
+ * (pjmedia_sdp_session), or request PJMEDIA endpoint (pjmedia_endpt) to
+ * create SDP session descriptor based on capabilities that present in the
+ * endpoint by calling #pjmedia_endpt_create_sdp().
+ *
+ * Application then creates SDP negotiator instance by calling
+ * #pjmedia_sdp_neg_create_w_local_offer(), passing the SDP offer in the
+ * function arguments. The SDP negotiator keeps a copy of current local offer,
+ * and update its state to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER.
+ *
+ * Application can then send the initial SDP offer that it creates to
+ * remote peer using signaling protocol such as SIP.
+ *
+ *
+ * \subsection sdpneg_subseq_offer Generating Subsequent Offer
+ *
+ * The negotiator can only create subsequent offer after it has finished
+ * the negotiation process of previous offer/answer session (i.e. the
+ * negotiator state is PJMEDIA_SDP_NEG_STATE_DONE).
+ *
+ * If any previous negotiation process was successfull (i.e. the return
+ * value of #pjmedia_sdp_neg_negotiate() was PJ_SUCCESS), the negotiator
+ * keeps both active local and active remote SDP.
+ *
+ * If application does not want send modified offer, it can just send
+ * the active local SDP as the offer. In this case, application calls
+ * #pjmedia_sdp_neg_send_local_offer() to get the active local SDP.
+ *
+ * If application wants to modify it's local offer, it MUST inform
+ * the negotiator about the modified SDP by calling
+ * #pjmedia_sdp_neg_modify_local_offer().
+ *
+ * In both cases, the negotiator will internally create a copy of the offer,
+ * and move it's state to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER, where it
+ * waits until application passes the remote answer.
+ *
+ *
+ * \subsection sdpneg_receive_offer Receiving Initial Offer
+ *
+ * Application receives an offer in the incoming request from remote to
+ * establish multimedia session, such as incoming INVITE message with SDP
+ * body.
+ *
+ * Initially, when the initial offer is received, application creates the
+ * SDP negotiator by calling #pjmedia_sdp_neg_create_w_remote_offer(),
+ * specifying the remote SDP offer in one of the argument.
+ *
+ * At this stage, application may or may not ready to create an answer.
+ * For example, a SIP B2BUA needs to make outgoing call and receive SDP
+ * from the outgoing call leg in order to create a SDP answer to the
+ * incoming call leg.
+ *
+ * If application is not ready to create an answer, it passes NULL as
+ * the local SDP when it calls #pjmedia_sdp_neg_create_w_remote_offer().
+ *
+ * The section @ref sdpneg_create_answer describes the case when
+ * application is ready to create a SDP answer.
+ *
+ *
+ * \subsection sdpneg_subseq_offer Receiving Subsequent Offer
+ *
+ * Application passes subsequent SDP offer received from remote by
+ * calling #pjmedia_sdp_neg_set_remote_offer().
+ *
+ * The negotiator can only receive subsequent offer after it has finished
+ * the negotiation process of previous offer/answer session (i.e. the
+ * negotiator state is PJMEDIA_SDP_NEG_STATE_DONE).
+ *
+ *
+ * \subsection sdpneg_recv_answer Receiving SDP Answer
+ *
+ * When application receives SDP answer from remote, it informs the
+ * negotiator by calling #pjmedia_sdp_neg_set_remote_answer(). The
+ * negotiator validates the answer (#pjmedia_sdp_validate()), and if
+ * succeeds, it moves it's state to PJMEDIA_SDP_NEG_STATE_WAIT_NEGO.
+ *
+ * Application then instruct the negotiator to negotiate the remote
+ * answer by calling #pjmedia_sdp_neg_negotiate(). The purpose of
+ * this negotiation is to verify remote answer, and update the initial
+ * offer according to the answer. For example, the initial offer may
+ * specify that a stream is \a sendrecv, while the answer specifies
+ * that remote stream is \a inactive. In this case, the negotiator
+ * will update the stream in the local active media as \a inactive
+ * too.
+ *
+ * If #pjmedia_sdp_neg_negotiate() returns PJ_SUCCESS, the negotiator will
+ * keep the updated local answer and remote answer internally. These two
+ * SDPs are called active local SDP and active remote SDP, as it describes
+ * currently active session.
+ *
+ * Application can retrieve the active local SDP by calling
+ * #pjmedia_sdp_neg_get_active_local(), and active remote SDP by calling
+ * #pjmedia_sdp_neg_get_active_remote().
+ *
+ * If #pjmedia_sdp_neg_negotiate() returns failure (i.e. not PJ_SUCCESS),
+ * it WILL NOT update its active local and active remote SDP.
+ *
+ * Regardless of the return status of the #pjmedia_sdp_neg_negotiate(),
+ * the negotiator state will move to PJMEDIA_SDP_NEG_STATE_DONE.
+ *
+ *
+ * \subsection sdpneg_cancel_offer Cancelling an Offer
+ *
+ * In other case, after an offer is generated (negotiator state is in
+ * PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER), the answer may not be received, and
+ * application wants the negotiator to reset itself to its previous state.
+ * Consider this example:
+ *
+ * - media has been established, and negotiator state is
+ * PJMEDIA_SDP_NEG_STATE_DONE.
+ * - application generates a new offer for re-INVITE, so in this case
+ * it would either call #pjmedia_sdp_neg_send_local_offer() or
+ * #pjmedia_sdp_neg_modify_local_offer()
+ * - the negotiator state moves to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER
+ * - the re-INVITE was rejected with an error
+ *
+ * Since an answer is not received, it is necessary to reset the negotiator
+ * state back to PJMEDIA_SDP_NEG_STATE_DONE so that the negotiator can
+ * create or receive new offer.
+ *
+ * This can be accomplished by calling #pjmedia_sdp_neg_cancel_offer(),
+ * to reset the negotiator state back to PJMEDIA_SDP_NEG_STATE_DONE. In
+ * this case, both active local and active remote will not be modified.
+ *
+ * \subsection sdpneg_create_answer Generating SDP Answer
+ *
+ * After remote offer has been set in the negotiator, application can
+ * request the SDP negotiator to generate appropriate answer based on local
+ * capability.
+ *
+ * To do this, first the application MUST have an SDP describing its local
+ * capabilities. This SDP can be built manually, or application can generate
+ * SDP to describe local media endpoint capability by calling
+ * #pjmedia_endpt_create_sdp(). When the application is a SIP B2BUA,
+ * application can treat the SDP received from the outgoing call leg as if
+ * it was it's local capability.
+ *
+ * The local SDP session descriptor DOES NOT have to match the SDP offer.
+ * For example, it can have more or less media lines than the offer, or
+ * their order may be different than the offer. The negotiator is capable
+ * to match and reorder local SDP according to remote offer, and create
+ * an answer that is suitable for the offer.
+ *
+ * After local SDP capability has been acquired, application can create
+ * a SDP answer.
+ *
+ * If application does not already have the negotiator instance, it creates
+ * one by calling #pjmedia_sdp_neg_create_w_remote_offer(), specifying
+ * both remote SDP offer and local SDP as the arguments. The SDP negotiator
+ * validates both remote and local SDP by calling #pjmedia_sdp_validate(),
+ * and if both SDPs are valid, the negotiator state will move to
+ * PJMEDIA_SDP_NEG_STATE_WAIT_NEGO where it is ready to negotiate the
+ * offer and answer.
+ *
+ * If application already has the negotiator instance, it sets the local
+ * SDP in the negotiator by calling #pjmedia_sdp_neg_set_local_answer().
+ * The SDP negotiator then validates local SDP (#pjmedia_sdp_validate() ),
+ * and if it is valid, the negotiator state will move to
+ * PJMEDIA_SDP_NEG_STATE_WAIT_NEGO where it is ready to negotiate the
+ * offer and answer.
+ *
+ * After the SDP negotiator state has moved to PJMEDIA_SDP_NEG_STATE_WAIT_NEGO,
+ * application calls #pjmedia_sdp_neg_negotiate() to instruct the SDP
+ * negotiator to negotiate both offer and answer. This function returns
+ * PJ_SUCCESS if an answer can be generated AND at least one media stream
+ * is active in the session.
+ *
+ * If #pjmedia_sdp_neg_negotiate() returns PJ_SUCCESS, the negotiator will
+ * keep the remote offer and local answer internally. These two SDPs are
+ * called active local SDP and active remote SDP, as it describes currently
+ * active session.
+ *
+ * Application can retrieve the active local SDP by calling
+ * #pjmedia_sdp_neg_get_active_local(), and send this SDP to remote as the
+ * SDP answer.
+ *
+ * If #pjmedia_sdp_neg_negotiate() returns failure (i.e. not PJ_SUCCESS),
+ * it WILL NOT update its active local and active remote SDP.
+ *
+ * Regardless of the return status of the #pjmedia_sdp_neg_negotiate(),
+ * the negotiator state will move to PJMEDIA_SDP_NEG_STATE_DONE.
+ *
+ *
+ */
+
+#include <pjmedia/sdp.h>
+
+PJ_BEGIN_DECL
+
+/**
+ * This enumeration describes SDP negotiation state.
+ */
+enum pjmedia_sdp_neg_state
+{
+ /**
+ * This is the state of SDP negoator before it is initialized.
+ */
+ PJMEDIA_SDP_NEG_STATE_NULL,
+
+ /**
+ * This state occurs when SDP negotiator has sent our offer to remote and
+ * it is waiting for answer.
+ */
+ PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER,
+
+ /**
+ * This state occurs when SDP negotiator has received offer from remote
+ * and currently waiting for local answer.
+ */
+ PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER,
+
+ /**
+ * This state occurs when an offer (either local or remote) has been
+ * provided with answer. The SDP negotiator is ready to negotiate both
+ * session descriptors. Application can call #pjmedia_sdp_neg_negotiate()
+ * immediately to begin negotiation process.
+ */
+ PJMEDIA_SDP_NEG_STATE_WAIT_NEGO,
+
+ /**
+ * This state occurs when SDP negotiation has completed, either
+ * successfully or not.
+ */
+ PJMEDIA_SDP_NEG_STATE_DONE
+};
+
+
+/**
+ * @see pjmedia_sdp_neg_state
+ */
+typedef enum pjmedia_sdp_neg_state pjmedia_sdp_neg_state;
+
+
+/**
+ * Opaque declaration of SDP negotiator.
+ */
+typedef struct pjmedia_sdp_neg pjmedia_sdp_neg;
+
+
+/**
+ * Get the state string description of the specified state.
+ *
+ * @param state Negotiator state.
+ *
+ * @return String description of the state.
+ */
+PJ_DECL(const char*) pjmedia_sdp_neg_state_str(pjmedia_sdp_neg_state state);
+
+
+/**
+ * Create the SDP negotiator with local offer. The SDP negotiator then
+ * will move to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER state, where it waits
+ * until it receives answer from remote. When SDP answer from remote is
+ * received, application must call #pjmedia_sdp_neg_set_remote_answer().
+ *
+ * After calling this function, application should send the local SDP offer
+ * to remote party using signaling protocol such as SIP and wait for SDP
+ * answer.
+ *
+ * @param pool Pool to allocate memory. The pool's lifetime needs
+ * to be valid for the duration of the negotiator.
+ * @param local The initial local capability.
+ * @param p_neg Pointer to receive the negotiator instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_neg_create_w_local_offer( pj_pool_t *pool,
+ const pjmedia_sdp_session *local,
+ pjmedia_sdp_neg **p_neg);
+
+/**
+ * Initialize the SDP negotiator with remote offer, and optionally
+ * specify the initial local capability, if known. Application normally
+ * calls this function when it receives initial offer from remote.
+ *
+ * If local media capability is specified, this capability will be set as
+ * initial local capability of the negotiator, and after this function is
+ * called, the SDP negotiator state will move to state
+ * PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, and the negotiation function can be
+ * called.
+ *
+ * If local SDP is not specified, the negotiator will not have initial local
+ * capability, and after this function is called the negotiator state will
+ * move to PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER state. Application MUST supply
+ * local answer later with #pjmedia_sdp_neg_set_local_answer(), before
+ * calling the negotiation function.
+ *
+ * @param pool Pool to allocate memory. The pool's lifetime needs
+ * to be valid for the duration of the negotiator.
+ * @param initial Optional initial local capability.
+ * @param remote The remote offer.
+ * @param p_neg Pointer to receive the negotiator instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_neg_create_w_remote_offer(pj_pool_t *pool,
+ const pjmedia_sdp_session *initial,
+ const pjmedia_sdp_session *remote,
+ pjmedia_sdp_neg **p_neg);
+
+/**
+ * This specifies the behavior of the SDP negotiator when responding to an
+ * offer, whether it should rather use the codec preference as set by
+ * remote, or should it rather use the codec preference as specified by
+ * local endpoint.
+ *
+ * For example, suppose incoming call has codec order "8 0 3", while
+ * local codec order is "3 0 8". If remote codec order is preferable,
+ * the selected codec will be 8, while if local codec order is preferable,
+ * the selected codec will be 3.
+ *
+ * By default, the value in PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER will
+ * be used.
+ *
+ * @param neg The SDP negotiator instance.
+ * @param prefer_remote If non-zero, the negotiator will use the codec
+ * order as specified in remote offer. If zero, it
+ * will prefer to use the local codec order.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_neg_set_prefer_remote_codec_order(pjmedia_sdp_neg *neg,
+ pj_bool_t prefer_remote);
+
+
+/**
+ * Get SDP negotiator state.
+ *
+ * @param neg The SDP negotiator instance.
+ *
+ * @return The negotiator state.
+ */
+PJ_DECL(pjmedia_sdp_neg_state)
+pjmedia_sdp_neg_get_state( pjmedia_sdp_neg *neg );
+
+/**
+ * Get the currently active local SDP. Application can only call this
+ * function after negotiation has been done, or otherwise there won't be
+ * active SDPs. Calling this function will not change the state of the
+ * negotiator.
+ *
+ * @param neg The SDP negotiator instance.
+ * @param local Pointer to receive the local active SDP.
+ *
+ * @return PJ_SUCCESS if local active SDP is present.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_neg_get_active_local( pjmedia_sdp_neg *neg,
+ const pjmedia_sdp_session **local);
+
+/**
+ * Get the currently active remote SDP. Application can only call this
+ * function after negotiation has been done, or otherwise there won't be
+ * active SDPs. Calling this function will not change the state of the
+ * negotiator.
+ *
+ * @param neg The SDP negotiator instance.
+ * @param remote Pointer to receive the remote active SDP.
+ *
+ * @return PJ_SUCCESS if remote active SDP is present.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_neg_get_active_remote( pjmedia_sdp_neg *neg,
+ const pjmedia_sdp_session **remote);
+
+
+/**
+ * Determine whether remote sent answer (as opposed to offer) on the
+ * last negotiation. This function can only be called in state
+ * PJMEDIA_SDP_NEG_STATE_DONE.
+ *
+ * @param neg The SDP negotiator instance.
+ *
+ * @return Non-zero if it was remote who sent answer,
+ * otherwise zero if it was local who supplied
+ * answer.
+ */
+PJ_DECL(pj_bool_t)
+pjmedia_sdp_neg_was_answer_remote(pjmedia_sdp_neg *neg);
+
+
+/**
+ * Get the current remote SDP offer or answer. Application can only
+ * call this function in state PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER or
+ * PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, or otherwise there won't be remote
+ * SDP offer/answer. Calling this function will not change the state
+ * of the negotiator.
+ *
+ * @param neg The SDP negotiator instance.
+ * @param remote Pointer to receive the current remote offer or
+ * answer.
+ *
+ * @return PJ_SUCCESS if the negotiator currently has
+ * remote offer or answer.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_neg_get_neg_remote( pjmedia_sdp_neg *neg,
+ const pjmedia_sdp_session **remote);
+
+
+/**
+ * Get the current local SDP offer or answer. Application can only
+ * call this function in state PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER or
+ * PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, or otherwise there won't be local
+ * SDP offer/answer. Calling this function will not change the state
+ * of the negotiator.
+ *
+ * @param neg The SDP negotiator instance.
+ * @param local Pointer to receive the current local offer or
+ * answer.
+ *
+ * @return PJ_SUCCESS if the negotiator currently has
+ * local offer or answer.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_neg_get_neg_local( pjmedia_sdp_neg *neg,
+ const pjmedia_sdp_session **local);
+
+/**
+ * Modify local session with a new SDP and treat this as a new offer.
+ * This function can only be called in state PJMEDIA_SDP_NEG_STATE_DONE.
+ * After calling this function, application can send the SDP as offer
+ * to remote party, using signaling protocol such as SIP.
+ * The negotiator state will move to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER,
+ * where it waits for SDP answer from remote.
+ *
+ * @param pool Pool to allocate memory. The pool's lifetime needs
+ * to be valid for the duration of the negotiator.
+ * @param neg The SDP negotiator instance.
+ * @param local The new local SDP.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_neg_modify_local_offer( pj_pool_t *pool,
+ pjmedia_sdp_neg *neg,
+ const pjmedia_sdp_session *local);
+
+/**
+ * This function can only be called in PJMEDIA_SDP_NEG_STATE_DONE state.
+ * Application calls this function to retrieve currently active
+ * local SDP, and then send the SDP to remote as an offer. The negotiator
+ * state will then move to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER, where it waits
+ * for SDP answer from remote.
+ *
+ * When SDP answer has been received from remote, application must call
+ * #pjmedia_sdp_neg_set_remote_answer().
+ *
+ * @param pool Pool to allocate memory. The pool's lifetime needs
+ * to be valid for the duration of the negotiator.
+ * @param neg The SDP negotiator instance.
+ * @param offer Pointer to receive active local SDP to be
+ * offered to remote.
+ *
+ * @return PJ_SUCCESS if local offer can be created.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_neg_send_local_offer( pj_pool_t *pool,
+ pjmedia_sdp_neg *neg,
+ const pjmedia_sdp_session **offer);
+
+/**
+ * This function can only be called in PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER
+ * state, i.e. after application calls #pjmedia_sdp_neg_send_local_offer()
+ * function. Application calls this function when it receives SDP answer
+ * from remote. After this function is called, the negotiator state will
+ * move to PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, and application can call the
+ * negotiation function #pjmedia_sdp_neg_negotiate().
+ *
+ * @param pool Pool to allocate memory. The pool's lifetime needs
+ * to be valid for the duration of the negotiator.
+ * @param neg The SDP negotiator instance.
+ * @param remote The remote answer.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_neg_set_remote_answer( pj_pool_t *pool,
+ pjmedia_sdp_neg *neg,
+ const pjmedia_sdp_session *remote);
+
+
+
+/**
+ * This function can only be called in PJMEDIA_SDP_NEG_STATE_DONE state.
+ * Application calls this function when it receives SDP offer from remote.
+ * After this function is called, the negotiator state will move to
+ * PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER, and application MUST call the
+ * #pjmedia_sdp_neg_set_local_answer() to set local answer before it can
+ * call the negotiation function.
+ *
+ * @param pool Pool to allocate memory. The pool's lifetime needs
+ * to be valid for the duration of the negotiator.
+ * @param neg The SDP negotiator instance.
+ * @param remote The remote offer.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_neg_set_remote_offer( pj_pool_t *pool,
+ pjmedia_sdp_neg *neg,
+ const pjmedia_sdp_session *remote);
+
+
+
+/**
+ * This function can only be called in PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER
+ * state, i.e. after application calls #pjmedia_sdp_neg_set_remote_offer()
+ * function. After this function is called, the negotiator state will
+ * move to PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, and application can call the
+ * negotiation function #pjmedia_sdp_neg_negotiate().
+ *
+ * @param pool Pool to allocate memory. The pool's lifetime needs
+ * to be valid for the duration of the negotiator.
+ * @param neg The SDP negotiator instance.
+ * @param local Optional local answer. If negotiator has initial
+ * local capability, application can specify NULL on
+ * this argument; in this case, the negotiator will
+ * create answer by by negotiating remote offer with
+ * initial local capability. If negotiator doesn't have
+ * initial local capability, application MUST specify
+ * local answer here.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_sdp_neg_set_local_answer( pj_pool_t *pool,
+ pjmedia_sdp_neg *neg,
+ const pjmedia_sdp_session *local);
+
+
+/**
+ * Call this function when the negotiator is in PJMEDIA_SDP_NEG_STATE_WAIT_NEGO
+ * state to see if it was local who is answering the offer (instead of
+ * remote).
+ *
+ * @param neg The negotiator.
+ *
+ * @return PJ_TRUE if it is local is answering an offer, PJ_FALSE
+ * if remote has answered local offer.
+ */
+PJ_DECL(pj_bool_t) pjmedia_sdp_neg_has_local_answer(pjmedia_sdp_neg *neg);
+
+
+/**
+ * Cancel previously sent offer, and move negotiator state back to
+ * previous stable state (PJMEDIA_SDP_NEG_STATE_DONE). The negotiator
+ * must be in PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER state.
+ *
+ * @param neg The negotiator.
+ *
+ * @return PJ_SUCCESS or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_neg_cancel_offer(pjmedia_sdp_neg *neg);
+
+
+/**
+ * Negotiate local and remote answer. Before calling this function, the
+ * SDP negotiator must be in PJMEDIA_SDP_NEG_STATE_WAIT_NEGO state.
+ * After calling this function, the negotiator state will move to
+ * PJMEDIA_SDP_NEG_STATE_DONE regardless whether the negotiation has
+ * been successfull or not.
+ *
+ * If the negotiation succeeds (i.e. the return value is PJ_SUCCESS),
+ * the active local and remote SDP will be replaced with the new SDP
+ * from the negotiation process.
+ *
+ * If the negotiation fails, the active local and remote SDP will not
+ * change.
+ *
+ * @param pool Pool to allocate memory. The pool's lifetime needs
+ * to be valid for the duration of the negotiator.
+ * @param neg The SDP negotiator instance.
+ * @param allow_asym Should be zero.
+ *
+ * @return PJ_SUCCESS when there is at least one media
+ * is actuve common in both offer and answer, or
+ * failure code when negotiation has failed.
+ */
+PJ_DECL(pj_status_t) pjmedia_sdp_neg_negotiate( pj_pool_t *pool,
+ pjmedia_sdp_neg *neg,
+ pj_bool_t allow_asym);
+
+
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_SDP_NEG_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/session.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/session.h new file mode 100644 index 0000000..fcbb955 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/session.h @@ -0,0 +1,404 @@ +/* $Id: session.h 2844 2009-07-29 12:14:21Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_SESSION_H__
+#define __PJMEDIA_SESSION_H__
+
+
+/**
+ * @file session.h
+ * @brief Media Session.
+ */
+
+#include <pjmedia/endpoint.h>
+#include <pjmedia/stream.h>
+#include <pjmedia/sdp.h>
+
+PJ_BEGIN_DECL
+
+/**
+ * @defgroup PJMEDIA_SESSION Media Sessions
+ * @brief Management of media sessions
+ * @{
+ *
+ * A media session represents multimedia communication between two
+ * parties. A media session represents the multimedia session that
+ * is described by SDP session descriptor. A media session consists
+ * of one or more media streams (pjmedia_stream), where each stream
+ * represents one media line (m= line) in SDP.
+ *
+ * This module provides functions to create and manage multimedia
+ * sessions.
+ *
+ * Application creates the media session by calling #pjmedia_session_create(),
+ * normally after it has completed negotiating both SDP offer and answer.
+ * The session creation function creates the media session (including
+ * media streams) based on the content of local and remote SDP.
+ */
+
+
+/**
+ * Session info, retrieved from a session by calling
+ * #pjmedia_session_get_info().
+ */
+struct pjmedia_session_info
+{
+ /** Number of streams. */
+ unsigned stream_cnt;
+
+ /** Individual stream info. */
+ pjmedia_stream_info stream_info[PJMEDIA_MAX_SDP_MEDIA];
+};
+
+
+/**
+ * Opaque declaration of media session.
+ */
+typedef struct pjmedia_session pjmedia_session;
+
+
+/**
+ * @see pjmedia_session_info.
+ */
+typedef struct pjmedia_session_info pjmedia_session_info;
+
+
+/**
+ * This function will initialize the session info based on information
+ * in both SDP session descriptors. The remaining information will be
+ * taken from default codec parameters. If socket info array is specified,
+ * the socket will be copied to the session info as well.
+ *
+ * @param pool Pool to allocate memory.
+ * @param endpt Pjmedia endpoint.
+ * @param max_streams Maximum number of stream infos to be created.
+ * @param si Session info structure to be initialized.
+ * @param local Local SDP session descriptor.
+ * @param remote Remote SDP session descriptor.
+ *
+ * @return PJ_SUCCESS if stream info is successfully initialized.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_session_info_from_sdp( pj_pool_t *pool,
+ pjmedia_endpt *endpt,
+ unsigned max_streams,
+ pjmedia_session_info *si,
+ const pjmedia_sdp_session *local,
+ const pjmedia_sdp_session *remote);
+
+
+/**
+ * This function will initialize the stream info based on information
+ * in both SDP session descriptors for the specified stream index.
+ * The remaining information will be taken from default codec parameters.
+ * If socket info array is specified, the socket will be copied to the
+ * session info as well.
+ *
+ * @param si Stream info structure to be initialized.
+ * @param pool Pool to allocate memory.
+ * @param endpt PJMEDIA endpoint instance.
+ * @param local Local SDP session descriptor.
+ * @param remote Remote SDP session descriptor.
+ * @param stream_idx Media stream index in the session descriptor.
+ *
+ * @return PJ_SUCCESS if stream info is successfully initialized.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_stream_info_from_sdp( pjmedia_stream_info *si,
+ pj_pool_t *pool,
+ pjmedia_endpt *endpt,
+ const pjmedia_sdp_session *local,
+ const pjmedia_sdp_session *remote,
+ unsigned stream_idx);
+
+/**
+ * Create media session based on the local and remote SDP. After the session
+ * has been created, application normally would want to get the media port
+ * interface of each streams, by calling #pjmedia_session_get_port(). The
+ * media port interface exports put_frame() and get_frame() function, used
+ * to transmit and receive media frames from the stream.
+ *
+ * Without application calling put_frame() and get_frame(), there will be
+ * no media frames transmitted or received by the session.
+ *
+ * @param endpt The PJMEDIA endpoint instance.
+ * @param si Session info containing stream count and array of
+ * stream info. The stream count indicates how many
+ * streams to be created in the session.
+ * @param transports Array of media stream transports, with
+ * sufficient number of elements (one for each stream).
+ * @param user_data Arbitrary user data to be kept in the session.
+ * @param p_session Pointer to receive the media session.
+ *
+ * @return PJ_SUCCESS if media session can be created
+ * successfully.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_session_create( pjmedia_endpt *endpt,
+ const pjmedia_session_info *si,
+ pjmedia_transport *transports[],
+ void *user_data,
+ pjmedia_session **p_session );
+
+
+/**
+ * Get media session info of the session.
+ *
+ * @param session The session which info is being queried.
+ * @param info Pointer to receive session info.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_get_info( pjmedia_session *session,
+ pjmedia_session_info *info );
+
+/**
+ * Get user data of the session.
+ *
+ * @param session The session being queried.
+ *
+ * @return User data of the session.
+ */
+PJ_DECL(void*) pjmedia_session_get_user_data( pjmedia_session *session);
+
+
+/**
+ * Activate all streams in media session for the specified direction.
+ * Application only needs to call this function if it previously paused
+ * the session.
+ *
+ * @param session The media session.
+ * @param dir The direction to activate.
+ *
+ * @return PJ_SUCCESS if success.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_resume(pjmedia_session *session,
+ pjmedia_dir dir);
+
+
+/**
+ * Suspend receipt and transmission of all streams in media session
+ * for the specified direction.
+ *
+ * @param session The media session.
+ * @param dir The media direction to suspend.
+ *
+ * @return PJ_SUCCESS if success.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_pause(pjmedia_session *session,
+ pjmedia_dir dir);
+
+/**
+ * Suspend receipt and transmission of individual stream in media session
+ * for the specified direction.
+ *
+ * @param session The media session.
+ * @param index The stream index.
+ * @param dir The media direction to pause.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_pause_stream( pjmedia_session *session,
+ unsigned index,
+ pjmedia_dir dir);
+
+/**
+ * Activate individual stream in media session for the specified direction.
+ *
+ * @param session The media session.
+ * @param index The stream index.
+ * @param dir The media direction to activate.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_resume_stream(pjmedia_session *session,
+ unsigned index,
+ pjmedia_dir dir);
+
+/**
+ * Enumerate media streams in the session.
+ *
+ * @param session The media session.
+ * @param count On input, specifies the number of elements in
+ * the array. On output, the number will be filled
+ * with number of streams in the session.
+ * @param strm_info Array of stream info.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_session_enum_streams( const pjmedia_session *session,
+ unsigned *count,
+ pjmedia_stream_info strm_info[]);
+
+
+/**
+ * Get the media port interface of the specified stream. The media port
+ * interface declares put_frame() and get_frame() function, which is the
+ * only way for application to transmit and receive media frames from the
+ * stream.
+ *
+ * @param session The media session.
+ * @param index Stream index.
+ * @param p_port Pointer to receive the media port interface for
+ * the specified stream.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_get_port( pjmedia_session *session,
+ unsigned index,
+ pjmedia_port **p_port);
+
+
+/**
+ * Get session statistics. The stream statistic shows various
+ * indicators such as packet count, packet lost, jitter, delay, etc.
+ * See also #pjmedia_session_get_stream_stat_jbuf()
+ *
+ * @param session The media session.
+ * @param index Stream index.
+ * @param stat Stream statistic.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_get_stream_stat(pjmedia_session *session,
+ unsigned index,
+ pjmedia_rtcp_stat *stat);
+
+
+#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)
+/**
+ * Get extended session statistics. The extended statistic shows reports
+ * from RTCP XR, such as per interval statistics summary (packet count,
+ * packet lost, jitter, etc), VoIP metrics (delay, quality, etc)
+ *
+ * @param session The media session.
+ * @param index Stream index.
+ * @param stat_xr Stream extended statistics.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_get_stream_stat_xr(
+ pjmedia_session *session,
+ unsigned index,
+ pjmedia_rtcp_xr_stat *stat_xr);
+#endif
+
+
+/**
+ * Get current jitter buffer state for the specified stream.
+ * See also #pjmedia_session_get_stream_stat()
+ *
+ * @param session The media session.
+ * @param index Stream index.
+ * @param state Jitter buffer state.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_get_stream_stat_jbuf(
+ pjmedia_session *session,
+ unsigned index,
+ pjmedia_jb_state *state);
+
+/**
+ * Dial DTMF digit to the stream, using RFC 2833 mechanism.
+ *
+ * @param session The media session.
+ * @param index The stream index.
+ * @param ascii_digits String of ASCII digits (i.e. 0-9*##A-B).
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_dial_dtmf( pjmedia_session *session,
+ unsigned index,
+ const pj_str_t *ascii_digits );
+
+
+/**
+ * Check if the specified stream has received DTMF digits.
+ *
+ * @param session The media session.
+ * @param index The stream index.
+ *
+ * @return Non-zero (PJ_TRUE) if the stream has DTMF digits.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_check_dtmf( pjmedia_session *session,
+ unsigned index);
+
+
+/**
+ * Retrieve DTMF digits from the specified stream.
+ *
+ * @param session The media session.
+ * @param index The stream index.
+ * @param ascii_digits Buffer to receive the digits. The length of this
+ * buffer is indicated in the "size" argument.
+ * @param size On input, contains the maximum digits to be copied
+ * to the buffer.
+ * On output, it contains the actual digits that has
+ * been copied to the buffer.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_get_dtmf( pjmedia_session *session,
+ unsigned index,
+ char *ascii_digits,
+ unsigned *size );
+
+/**
+ * Set callback to be called upon receiving DTMF digits. If callback is
+ * registered, the stream will not buffer incoming DTMF but rather call
+ * the callback as soon as DTMF digit is received completely.
+ *
+ * @param session The media session.
+ * @param index The stream index.
+ * @param cb Callback to be called upon receiving DTMF digits.
+ * The DTMF digits will be given to the callback as
+ * ASCII digits.
+ * @param user_data User data to be returned back when the callback
+ * is called.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_session_set_dtmf_callback(pjmedia_session *session,
+ unsigned index,
+ void (*cb)(pjmedia_stream*,
+ void *user_data,
+ int digit),
+ void *user_data);
+
+/**
+ * Destroy media session.
+ *
+ * @param session The media session.
+ *
+ * @return PJ_SUCCESS if success.
+ */
+PJ_DECL(pj_status_t) pjmedia_session_destroy(pjmedia_session *session);
+
+
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+#endif /* __PJMEDIA_SESSION_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/silencedet.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/silencedet.h new file mode 100644 index 0000000..7ffe0a7 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/silencedet.h @@ -0,0 +1,200 @@ +/* $Id: silencedet.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_SILENCE_DET_H__
+#define __PJMEDIA_SILENCE_DET_H__
+
+
+/**
+ * @file silencedet.h
+ * @brief Adaptive silence detector.
+ */
+#include <pjmedia/types.h>
+
+
+/**
+ * @defgroup PJMEDIA_SILENCEDET Adaptive Silence Detection
+ * @ingroup PJMEDIA_FRAME_OP
+ * @brief Adaptive Silence Detector
+ * @{
+ */
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Opaque declaration for silence detector.
+ */
+typedef struct pjmedia_silence_det pjmedia_silence_det;
+
+
+
+/**
+ * Create voice activity detector with default settings. The default settings
+ * are set to adaptive silence detection with the default threshold.
+ *
+ * @param pool Pool for allocating the structure.
+ * @param clock_rate Clock rate.
+ * @param samples_per_frame Number of samples per frame. The clock_rate and
+ * samples_per_frame is only used to calculate the
+ * frame time, from which some timing parameters
+ * are calculated from.
+ * @param p_sd Pointer to receive the silence detector instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_silence_det_create( pj_pool_t *pool,
+ unsigned clock_rate,
+ unsigned samples_per_frame,
+ pjmedia_silence_det **p_sd );
+
+
+/**
+ * Set silence detector name to identify the particular silence detector
+ * instance in the log.
+ *
+ * @param sd The silence detector.
+ * @param name Name.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_silence_det_set_name(pjmedia_silence_det *sd,
+ const char *name);
+
+
+/**
+ * Set the sd to operate in fixed threshold mode. With fixed threshold mode,
+ * the threshold will not be changed adaptively.
+ *
+ * @param sd The silence detector
+ * @param threshold The silence threshold, or -1 to use default
+ * threshold.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_silence_det_set_fixed( pjmedia_silence_det *sd,
+ int threshold );
+
+/**
+ * Set the sd to operate in adaptive mode. This is the default mode
+ * when the silence detector is created.
+ *
+ * @param sd The silence detector
+ * @param threshold Initial threshold to be set, or -1 to use default
+ * threshold.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_silence_det_set_adaptive(pjmedia_silence_det *sd,
+ int threshold);
+
+/**
+ * Set other silence detector parameters.
+ *
+ * @param sd The silence detector
+ * @param before_silence Minimum duration of silence (in msec) before
+ * silence is reported. If -1 is specified, then
+ * the default value will be used. The default is
+ * 400 msec.
+ * @param recalc_time1 The interval (in msec) to recalculate threshold
+ * in non-silence condition when adaptive silence
+ * detection is set. If -1 is specified, then the
+ * default value will be used. The default is 4000
+ * (msec).
+ * @param recalc_time2 The interval (in msec) to recalculate threshold
+ * in silence condition when adaptive silence detection
+ * is set. If -1 is specified, then the default value
+ * will be used. The default value is 2000 (msec).
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_silence_det_set_params( pjmedia_silence_det *sd,
+ int before_silence,
+ int recalc_time1,
+ int recalc_time2);
+
+
+/**
+ * Disable the silence detector.
+ *
+ * @param sd The silence detector
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_silence_det_disable( pjmedia_silence_det *sd );
+
+
+/**
+ * Perform voice activity detection on the given input samples. This
+ * function uses #pjmedia_calc_avg_signal() and #pjmedia_silence_det_apply()
+ * for its calculation.
+ *
+ * @param sd The silence detector instance.
+ * @param samples Pointer to 16-bit PCM input samples.
+ * @param count Number of samples in the input.
+ * @param p_level Optional pointer to receive average signal level
+ * of the input samples.
+ *
+ * @return Non zero if signal is silence.
+ */
+PJ_DECL(pj_bool_t) pjmedia_silence_det_detect( pjmedia_silence_det *sd,
+ const pj_int16_t samples[],
+ pj_size_t count,
+ pj_int32_t *p_level);
+
+
+/**
+ * Calculate average signal level for the given samples.
+ *
+ * @param samples Pointer to 16-bit PCM samples.
+ * @param count Number of samples in the input.
+ *
+ * @return The average signal level, which simply is total level
+ * divided by number of samples.
+ */
+PJ_DECL(pj_int32_t) pjmedia_calc_avg_signal( const pj_int16_t samples[],
+ pj_size_t count );
+
+
+
+/**
+ * Perform voice activity detection, given the specified average signal
+ * level.
+ *
+ * @param sd The silence detector instance.
+ * @param level Signal level.
+ *
+ * @return Non zero if signal is silence.
+ */
+PJ_DECL(pj_bool_t) pjmedia_silence_det_apply( pjmedia_silence_det *sd,
+ pj_uint32_t level);
+
+
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_SILENCE_DET_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/sound.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/sound.h new file mode 100644 index 0000000..7ef818c --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/sound.h @@ -0,0 +1,336 @@ +/* $Id: sound.h 2506 2009-03-12 18:11:37Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_SOUND_H__
+#define __PJMEDIA_SOUND_H__
+
+
+/**
+ * @file sound.h
+ * @brief Legacy sound device API
+ */
+#include <pjmedia-audiodev/audiodev.h>
+#include <pjmedia/types.h>
+
+
+PJ_BEGIN_DECL
+
+/**
+ * @defgroup PJMED_SND Portable Sound Hardware Abstraction
+ * @ingroup PJMED_SND_PORT
+ * @brief PJMEDIA abstraction for sound device hardware
+ * @{
+ *
+ * <strong>Warning: this sound device API has been deprecated
+ * and replaced by PJMEDIA Audio Device API. Please see
+ * http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more
+ * information.</strong>
+ *
+ * This section describes lower level abstraction for sound device
+ * hardware. Application normally uses the higher layer @ref
+ * PJMED_SND_PORT abstraction since it works seamlessly with
+ * @ref PJMEDIA_PORT.
+ *
+ * The sound hardware abstraction basically runs <b>asychronously</b>,
+ * and application must register callbacks to be called to receive/
+ * supply audio frames from/to the sound hardware.
+ *
+ * A full duplex sound stream (created with #pjmedia_snd_open())
+ * requires application to supply two callbacks:
+ * - <b><tt>rec_cb</tt></b> callback to be called when it has finished
+ * capturing one media frame, and
+ * - <b><tt>play_cb</tt></b> callback to be called when it needs media
+ * frame to be played to the sound playback hardware.
+ *
+ * Half duplex sound stream (created with #pjmedia_snd_open_rec() or
+ * #pjmedia_snd_open_player()) will only need one of the callback to
+ * be specified.
+ *
+ * After sound stream is created, application need to call
+ * #pjmedia_snd_stream_start() to start capturing/playing back media
+ * frames from/to the sound device.
+ */
+
+/** Opaque declaration for pjmedia_snd_stream. */
+typedef struct pjmedia_snd_stream pjmedia_snd_stream;
+
+/**
+ * Device information structure returned by #pjmedia_snd_get_dev_info.
+ */
+typedef struct pjmedia_snd_dev_info
+{
+ char name[64]; /**< Device name. */
+ unsigned input_count; /**< Max number of input channels. */
+ unsigned output_count; /**< Max number of output channels. */
+ unsigned default_samples_per_sec;/**< Default sampling rate. */
+} pjmedia_snd_dev_info;
+
+/**
+ * Stream information, can be retrieved from a live stream by calling
+ * #pjmedia_snd_stream_get_info().
+ */
+typedef struct pjmedia_snd_stream_info
+{
+ pjmedia_dir dir; /**< Stream direction. */
+ int play_id; /**< Playback dev id, or -1 for rec only*/
+ int rec_id; /**< Capture dev id, or -1 for play only*/
+ unsigned clock_rate; /**< Actual clock rate. */
+ unsigned channel_count; /**< Number of channels. */
+ unsigned samples_per_frame; /**< Samples per frame. */
+ unsigned bits_per_sample; /**< Bits per sample. */
+ unsigned rec_latency; /**< Record latency, in samples. */
+ unsigned play_latency; /**< Playback latency, in samples. */
+} pjmedia_snd_stream_info;
+
+/**
+ * This callback is called by player stream when it needs additional data
+ * to be played by the device. Application must fill in the whole of output
+ * buffer with sound samples.
+ *
+ * @param user_data User data associated with the stream.
+ * @param timestamp Timestamp, in samples.
+ * @param output Buffer to be filled out by application.
+ * @param size The size requested in bytes, which will be equal to
+ * the size of one whole packet.
+ *
+ * @return Non-zero to stop the stream.
+ */
+typedef pj_status_t (*pjmedia_snd_play_cb)(/* in */ void *user_data,
+ /* in */ pj_uint32_t timestamp,
+ /* out */ void *output,
+ /* out */ unsigned size);
+
+/**
+ * This callback is called by recorder stream when it has captured the whole
+ * packet worth of audio samples.
+ *
+ * @param user_data User data associated with the stream.
+ * @param timestamp Timestamp, in samples.
+ * @param output Buffer containing the captured audio samples.
+ * @param size The size of the data in the buffer, in bytes.
+ *
+ * @return Non-zero to stop the stream.
+ */
+typedef pj_status_t (*pjmedia_snd_rec_cb)(/* in */ void *user_data,
+ /* in */ pj_uint32_t timestamp,
+ /* in */ void *input,
+ /* in*/ unsigned size);
+
+/**
+ * Init the sound library.
+ *
+ * @param factory The sound factory.
+ *
+ * @return Zero on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_init(pj_pool_factory *factory);
+
+
+/**
+ * Get the number of devices detected by the library.
+ *
+ * @return Number of devices.
+ */
+PJ_DECL(int) pjmedia_snd_get_dev_count(void);
+
+
+/**
+ * Get device info.
+ *
+ * @param index The index of the device, which should be in the range
+ * from zero to #pjmedia_snd_get_dev_count - 1.
+ */
+PJ_DECL(const pjmedia_snd_dev_info*) pjmedia_snd_get_dev_info(unsigned index);
+
+
+/**
+ * Set sound device latency, this function must be called before sound device
+ * opened, or otherwise default latency setting will be used, @see
+ * PJMEDIA_SND_DEFAULT_REC_LATENCY & PJMEDIA_SND_DEFAULT_PLAY_LATENCY.
+ *
+ * Choosing latency value is not straightforward, it should accomodate both
+ * minimum latency and stability. Lower latency tends to cause sound device
+ * less reliable (producing audio dropouts) on CPU load disturbance. Moreover,
+ * the best latency setting may vary based on many aspects, e.g: sound card,
+ * CPU, OS, kernel, etc.
+ *
+ * @param input_latency The latency of input device, in ms, set to 0
+ * for default PJMEDIA_SND_DEFAULT_REC_LATENCY.
+ * @param output_latency The latency of output device, in ms, set to 0
+ * for default PJMEDIA_SND_DEFAULT_PLAY_LATENCY.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_set_latency(unsigned input_latency,
+ unsigned output_latency);
+
+
+/**
+ * Create sound stream for both capturing audio and audio playback, from the
+ * same device. This is the recommended way to create simultaneous recorder
+ * and player streams (instead of creating separate capture and playback
+ * streams), because it works on backends that does not allow
+ * a device to be opened more than once.
+ *
+ * @param rec_id Device index for recorder/capture stream, or
+ * -1 to use the first capable device.
+ * @param play_id Device index for playback stream, or -1 to use
+ * the first capable device.
+ * @param clock_rate Sound device's clock rate to set.
+ * @param channel_count Set number of channels, 1 for mono, or 2 for
+ * stereo. The channel count determines the format
+ * of the frame.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Set the number of bits per sample. The normal
+ * value for this parameter is 16 bits per sample.
+ * @param rec_cb Callback to handle captured audio samples.
+ * @param play_cb Callback to be called when the sound player needs
+ * more audio samples to play.
+ * @param user_data User data to be associated with the stream.
+ * @param p_snd_strm Pointer to receive the stream instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_open(int rec_id,
+ int play_id,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ pjmedia_snd_rec_cb rec_cb,
+ pjmedia_snd_play_cb play_cb,
+ void *user_data,
+ pjmedia_snd_stream **p_snd_strm);
+
+
+/**
+ * Create a unidirectional audio stream for capturing audio samples from
+ * the sound device.
+ *
+ * @param index Device index, or -1 to let the library choose the
+ * first available device.
+ * @param clock_rate Sound device's clock rate to set.
+ * @param channel_count Set number of channels, 1 for mono, or 2 for
+ * stereo. The channel count determines the format
+ * of the frame.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Set the number of bits per sample. The normal
+ * value for this parameter is 16 bits per sample.
+ * @param rec_cb Callback to handle captured audio samples.
+ * @param user_data User data to be associated with the stream.
+ * @param p_snd_strm Pointer to receive the stream instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_open_rec( int index,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ pjmedia_snd_rec_cb rec_cb,
+ void *user_data,
+ pjmedia_snd_stream **p_snd_strm);
+
+/**
+ * Create a unidirectional audio stream for playing audio samples to the
+ * sound device.
+ *
+ * @param index Device index, or -1 to let the library choose the
+ * first available device.
+ * @param clock_rate Sound device's clock rate to set.
+ * @param channel_count Set number of channels, 1 for mono, or 2 for
+ * stereo. The channel count determines the format
+ * of the frame.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Set the number of bits per sample. The normal
+ * value for this parameter is 16 bits per sample.
+ * @param play_cb Callback to be called when the sound player needs
+ * more audio samples to play.
+ * @param user_data User data to be associated with the stream.
+ * @param p_snd_strm Pointer to receive the stream instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_open_player( int index,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ pjmedia_snd_play_cb play_cb,
+ void *user_data,
+ pjmedia_snd_stream **p_snd_strm );
+
+
+/**
+ * Get information about live stream.
+ *
+ * @param strm The stream to be queried.
+ * @param pi Pointer to stream information to be filled up with
+ * information about the stream.
+ *
+ * @return PJ_SUCCESS on success or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_stream_get_info(pjmedia_snd_stream *strm,
+ pjmedia_snd_stream_info *pi);
+
+
+/**
+ * Start the stream.
+ *
+ * @param stream The recorder or player stream.
+ *
+ * @return Zero on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_stream_start(pjmedia_snd_stream *stream);
+
+/**
+ * Stop the stream.
+ *
+ * @param stream The recorder or player stream.
+ *
+ * @return Zero on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_stream_stop(pjmedia_snd_stream *stream);
+
+/**
+ * Destroy the stream.
+ *
+ * @param stream The recorder of player stream.
+ *
+ * @return Zero on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_stream_close(pjmedia_snd_stream *stream);
+
+/**
+ * Deinitialize sound library.
+ *
+ * @return Zero on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_deinit(void);
+
+
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_SOUND_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/sound_port.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/sound_port.h new file mode 100644 index 0000000..56cec34 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/sound_port.h @@ -0,0 +1,296 @@ +/* $Id: sound_port.h 2506 2009-03-12 18:11:37Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_SOUND_PORT_H__
+#define __PJMEDIA_SOUND_PORT_H__
+
+/**
+ * @file sound_port.h
+ * @brief Media port connection abstraction to sound device.
+ */
+#include <pjmedia-audiodev/audiodev.h>
+#include <pjmedia/port.h>
+
+PJ_BEGIN_DECL
+
+/**
+ * @defgroup PJMED_SND_PORT Sound Device Port
+ * @ingroup PJMEDIA_PORT_CLOCK
+ * @brief Media Port Connection Abstraction to the Sound Device
+ @{
+
+ As explained in @ref PJMED_SND, the sound hardware abstraction provides
+ some callbacks for its user:
+ - it calls <b><tt>rec_cb</tt></b> callback when it has finished capturing
+ one media frame, and
+ - it calls <b><tt>play_cb</tt></b> when it needs media frame to be
+ played to the sound playback hardware.
+
+ The @ref PJMED_SND_PORT (the object being explained here) add a
+ thin wrapper to the hardware abstraction:
+ - it will call downstream port's <tt>put_frame()</tt>
+ when <b><tt>rec_cb()</tt></b> is called (i.e. when the sound hardware
+ has finished capturing frame), and
+ - it will call downstream port's <tt>get_frame()</tt> when
+ <b><tt>play_cb()</tt></b> is called (i.e. every time the
+ sound hardware needs more frames to be played to the playback hardware).
+
+ This simple abstraction enables media to flow automatically (and
+ in timely manner) from the downstream media port to the sound device.
+ In other words, the sound device port supplies media clock to
+ the ports. The media clock concept is explained in @ref PJMEDIA_PORT_CLOCK
+ section.
+
+ Application registers downstream port to the sound device port by
+ calling #pjmedia_snd_port_connect();
+
+ */
+
+/**
+ * This opaque type describes sound device port connection.
+ * Sound device port is not a media port, but it is used to connect media
+ * port to the sound device.
+ */
+typedef struct pjmedia_snd_port pjmedia_snd_port;
+
+
+/**
+ * Create bidirectional sound port for both capturing and playback of
+ * audio samples.
+ *
+ * @param pool Pool to allocate sound port structure.
+ * @param rec_id Device index for recorder/capture stream, or
+ * -1 to use the first capable device.
+ * @param play_id Device index for playback stream, or -1 to use
+ * the first capable device.
+ * @param clock_rate Sound device's clock rate to set.
+ * @param channel_count Set number of channels, 1 for mono, or 2 for
+ * stereo. The channel count determines the format
+ * of the frame.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Set the number of bits per sample. The normal
+ * value for this parameter is 16 bits per sample.
+ * @param options Options flag, currently must be zero.
+ * @param p_port Pointer to receive the sound device port instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_port_create( pj_pool_t *pool,
+ int rec_id,
+ int play_id,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ unsigned options,
+ pjmedia_snd_port **p_port);
+
+/**
+ * Create unidirectional sound device port for capturing audio streams from
+ * the sound device with the specified parameters.
+ *
+ * @param pool Pool to allocate sound port structure.
+ * @param index Device index, or -1 to let the library choose the
+ * first available device.
+ * @param clock_rate Sound device's clock rate to set.
+ * @param channel_count Set number of channels, 1 for mono, or 2 for
+ * stereo. The channel count determines the format
+ * of the frame.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Set the number of bits per sample. The normal
+ * value for this parameter is 16 bits per sample.
+ * @param options Options flag, currently must be zero.
+ * @param p_port Pointer to receive the sound device port instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_port_create_rec(pj_pool_t *pool,
+ int index,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ unsigned options,
+ pjmedia_snd_port **p_port);
+
+/**
+ * Create unidirectional sound device port for playing audio streams with the
+ * specified parameters.
+ *
+ * @param pool Pool to allocate sound port structure.
+ * @param index Device index, or -1 to let the library choose the
+ * first available device.
+ * @param clock_rate Sound device's clock rate to set.
+ * @param channel_count Set number of channels, 1 for mono, or 2 for
+ * stereo. The channel count determines the format
+ * of the frame.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Set the number of bits per sample. The normal
+ * value for this parameter is 16 bits per sample.
+ * @param options Options flag, currently must be zero.
+ * @param p_port Pointer to receive the sound device port instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_port_create_player(pj_pool_t *pool,
+ int index,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ unsigned options,
+ pjmedia_snd_port **p_port);
+
+
+/**
+ * Create sound device port according to the specified parameters.
+ *
+ * @param pool Pool to allocate sound port structure.
+ * @param prm Sound device settings.
+ * @param p_port Pointer to receive the sound device port instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_port_create2(pj_pool_t *pool,
+ const pjmedia_aud_param *prm,
+ pjmedia_snd_port **p_port);
+
+
+/**
+ * Destroy sound device port.
+ *
+ * @param snd_port The sound device port.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_port_destroy(pjmedia_snd_port *snd_port);
+
+
+/**
+ * Retrieve the sound stream associated by this sound device port.
+ *
+ * @param snd_port The sound device port.
+ *
+ * @return The sound stream instance.
+ */
+PJ_DECL(pjmedia_aud_stream*) pjmedia_snd_port_get_snd_stream(
+ pjmedia_snd_port *snd_port);
+
+
+/**
+ * Change the echo cancellation settings. The echo cancellation settings
+ * should have been specified when this sound port was created, by setting
+ * the appropriate fields in the pjmedia_aud_param, because not all sound
+ * device implementation supports changing the EC setting once the device
+ * has been opened.
+ *
+ * The behavior of this function depends on whether device or software AEC
+ * is being used. If the device supports AEC, this function will forward
+ * the change request to the device and it will be up to the device whether
+ * to support the request. If software AEC is being used (the software EC
+ * will be used if the device does not support AEC), this function will
+ * change the software EC settings.
+ *
+ * @param snd_port The sound device port.
+ * @param pool Pool to re-create the echo canceller if necessary.
+ * @param tail_ms Maximum echo tail length to be supported, in
+ * miliseconds. If zero is specified, the EC would
+ * be disabled.
+ * @param options The options to be passed to #pjmedia_echo_create().
+ * This is only used if software EC is being used.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_port_set_ec( pjmedia_snd_port *snd_port,
+ pj_pool_t *pool,
+ unsigned tail_ms,
+ unsigned options);
+
+
+/**
+ * Get current echo canceller tail length, in miliseconds. The tail length
+ * will be zero if EC is not enabled.
+ *
+ * @param snd_port The sound device port.
+ * @param p_length Pointer to receive the tail length.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_port_get_ec_tail(pjmedia_snd_port *snd_port,
+ unsigned *p_length);
+
+
+/**
+ * Connect a port to the sound device port. If the sound device port has a
+ * sound recorder device, then this will start periodic function call to
+ * the port's put_frame() function. If the sound device has a sound player
+ * device, then this will start periodic function call to the port's
+ * get_frame() function.
+ *
+ * For this version of PJMEDIA, the media port MUST have the same audio
+ * settings as the sound device port, or otherwise the connection will
+ * fail. This means the port MUST have the same clock_rate, channel count,
+ * samples per frame, and bits per sample as the sound device port.
+ *
+ * @param snd_port The sound device port.
+ * @param port The media port to be connected.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_port_connect(pjmedia_snd_port *snd_port,
+ pjmedia_port *port);
+
+
+/**
+ * Retrieve the port instance currently attached to the sound port, if any.
+ *
+ * @param snd_port The sound device port.
+ *
+ * @return The port instance currently attached to the
+ * sound device port, or NULL if there is no port
+ * currently attached to the sound device port.
+ */
+PJ_DECL(pjmedia_port*) pjmedia_snd_port_get_port(pjmedia_snd_port *snd_port);
+
+
+/**
+ * Disconnect currently attached port from the sound device port.
+ *
+ * @param snd_port The sound device port.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_port_disconnect(pjmedia_snd_port *snd_port);
+
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_SOUND_PORT_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/splitcomb.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/splitcomb.h new file mode 100644 index 0000000..750cabc --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/splitcomb.h @@ -0,0 +1,140 @@ +/* $Id: splitcomb.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_SPLITCOMB_H__
+#define __PJMEDIA_SPLITCOMB_H__
+
+
+/**
+ * @file splitcomb.h
+ * @brief Media channel splitter/combiner port.
+ */
+#include <pjmedia/port.h>
+
+
+/**
+ * @addtogroup PJMEDIA_SPLITCOMB Media channel splitter/combiner
+ * @ingroup PJMEDIA_PORT
+ * @brief Split and combine multiple mono-channel media ports into
+ * a single multiple-channels media port
+ * @{
+ *
+ * This section describes media port to split and combine media
+ * channels in the stream.
+ *
+ * A splitter/combiner splits a single stereo/multichannels audio frame into
+ * multiple audio frames to each channel when put_frame() is called,
+ * and combines mono frames from each channel into a stereo/multichannel
+ * frame when get_frame() is called. A common application for the splitter/
+ * combiner is to split frames from stereo to mono and vise versa.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Create a media splitter/combiner with the specified parameters.
+ * When the splitter/combiner is created, it creates an instance of
+ * pjmedia_port. This media port represents the stereo/multichannel side
+ * of the splitter/combiner. Application needs to supply the splitter/
+ * combiner with a media port for each audio channels.
+ *
+ * @param pool Pool to allocate memory to create the splitter/
+ * combiner.
+ * @param clock_rate Audio clock rate/sampling rate.
+ * @param channel_count Number of channels.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Bits per sample.
+ * @param options Optional flags.
+ * @param p_splitcomb Pointer to receive the splitter/combiner.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_splitcomb_create(pj_pool_t *pool,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ unsigned options,
+ pjmedia_port **p_splitcomb);
+
+/**
+ * Supply the splitter/combiner with media port for the specified channel
+ * number. The media port will be called at the
+ * same phase as the splitter/combiner; which means that when application
+ * calls get_frame() of the splitter/combiner, it will call get_frame()
+ * for all ports that have the same phase. And similarly for put_frame().
+ *
+ * @param splitcomb The splitter/combiner.
+ * @param ch_num Audio channel starting number (zero based).
+ * @param options Must be zero at the moment.
+ * @param port The media port.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t) pjmedia_splitcomb_set_channel(pjmedia_port *splitcomb,
+ unsigned ch_num,
+ unsigned options,
+ pjmedia_port *port);
+
+/**
+ * Create a reverse phase media port for the specified channel number.
+ * For channels with reversed phase, when application calls put_frame() to
+ * the splitter/combiner, the splitter/combiner will only put the frame to
+ * a buffer. Later on, when application calls get_frame() on the channel's
+ * media port, it will return the frame that are available in the buffer.
+ * The same process happens when application calls put_frame() to the
+ * channel's media port, it will only put the frame to another buffer, which
+ * will be returned when application calls get_frame() to the splitter's
+ * media port. So this effectively reverse the phase of the media port.
+ *
+ * @param pool The pool to allocate memory for the port and
+ * buffers.
+ * @param splitcomb The splitter/combiner.
+ * @param ch_num Audio channel starting number (zero based).
+ * @param options Normally is zero, but the lower 8-bit of the
+ * options can be used to specify the number of
+ * buffers in the circular buffer. If zero, then
+ * default number will be used (default: 8).
+ * @param p_chport The media port created with reverse phase for
+ * the specified audio channel.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_splitcomb_create_rev_channel( pj_pool_t *pool,
+ pjmedia_port *splitcomb,
+ unsigned ch_num,
+ unsigned options,
+ pjmedia_port **p_chport);
+
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_SPLITCOMB_H__ */
+
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/stereo.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/stereo.h new file mode 100644 index 0000000..3c7af19 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/stereo.h @@ -0,0 +1,206 @@ +/* $Id: stereo.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_STEREO_H__
+#define __PJMEDIA_STEREO_H__
+
+/**
+ * @file stereo.h
+ * @brief Monochannel and multichannel converter.
+ */
+
+#include <pjmedia/errno.h>
+#include <pjmedia/port.h>
+#include <pjmedia/types.h>
+#include <pj/assert.h>
+
+
+/**
+ * @defgroup PJMEDIA_STEREO Monochannel and multichannel audio frame converter
+ * @ingroup PJMEDIA_FRAME_OP
+ * @brief Mono - multi-channels audio conversion
+ * @{
+ *
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Multichannel to monochannel conversion mixes samples from all channels
+ * into the monochannel.
+ */
+#define PJMEDIA_STEREO_MIX PJ_TRUE
+
+
+
+/**
+ * Multichannel to monochannel conversion, it has two operation mode specified
+ * by param options, @see pjmedia_stereo_options. This function can work safely
+ * using the same buffer (in place conversion).
+ *
+ * @param mono Output buffer to store the mono frame extracted
+ * from the multichannels frame.
+ * @param multi Input frame containing multichannels audio.
+ * @param channel_count Number of channels in the input frame.
+ * @param samples_per_frame Number of samples in the input frame.
+ * @param mix If the value is PJ_TRUE then the input channels
+ * will be mixed to produce output frame, otherwise
+ * only frame from channel_src will be copied to the
+ * output frame.
+ * @param channel_src When mixing is disabled, the mono output frame
+ * will be copied from this channel number.
+ *
+ * @return PJ_SUCCESS on success;
+ */
+PJ_INLINE(pj_status_t) pjmedia_convert_channel_nto1(pj_int16_t mono[],
+ const pj_int16_t multi[],
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ pj_bool_t mix,
+ unsigned channel_src)
+{
+ unsigned i;
+
+ PJ_ASSERT_RETURN(mono && multi && channel_count && samples_per_frame &&
+ channel_src < channel_count, PJ_EINVAL);
+
+ if (mix==PJ_FALSE) {
+ for (i = channel_src; i < samples_per_frame; i += channel_count) {
+ *mono = multi[i];
+ ++mono;
+ }
+ } else {
+ unsigned j;
+ for (i = 0; i < samples_per_frame; i += channel_count) {
+ int tmp = 0;
+ for(j = 0; j < channel_count; ++j)
+ tmp += multi[i+j];
+
+ if (tmp > 32767) tmp = 32767;
+ else if (tmp < -32768) tmp = -32768;
+ *mono = (pj_int16_t) tmp;
+ ++mono;
+ }
+ }
+
+ return PJ_SUCCESS;
+}
+
+
+/**
+ * Monochannel to multichannel conversion, it will just duplicate the samples
+ * from monochannel frame to all channels in the multichannel frame.
+ * This function can work safely using the same buffer (in place conversion)
+ * as long as the buffer is big enough for the multichannel samples.
+ *
+ * @param multi Output buffer to store the multichannels frame
+ * mixed from the mono frame.
+ * @param mono The input monochannel audio frame.
+ * @param channel_count Desired number of channels in the output frame.
+ * @param samples_per_frame Number of samples in the input frame.
+ * @param options Options for conversion, currently must be zero.
+ *
+ * @return PJ_SUCCESS on success;
+ */
+PJ_INLINE(pj_status_t) pjmedia_convert_channel_1ton(pj_int16_t multi[],
+ const pj_int16_t mono[],
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned options)
+{
+ const pj_int16_t *src;
+
+ PJ_ASSERT_RETURN(mono && multi && channel_count && samples_per_frame,
+ PJ_EINVAL);
+ PJ_ASSERT_RETURN(options == 0, PJ_EINVAL);
+
+ PJ_UNUSED_ARG(options);
+
+ src = mono + samples_per_frame - 1;
+ samples_per_frame *= channel_count;
+ while (samples_per_frame) {
+ unsigned i;
+ for (i=1; i<=channel_count; ++i)
+ multi[samples_per_frame-i] = *src;
+ samples_per_frame -= channel_count;
+ --src;
+ }
+
+ return PJ_SUCCESS;
+}
+
+
+/**
+ * Options for channel converter port. The @pjmedia_stereo_options is also
+ * valid for this port options.
+ */
+enum pjmedia_stereo_port_options
+{
+ /**
+ * Specifies whether this port should not destroy downstream port when
+ * this port is destroyed.
+ */
+ PJMEDIA_STEREO_DONT_DESTROY_DN = 4
+};
+
+
+/**
+ * Create a mono-multi channel converter port. This creates a converter session,
+ * which will adjust the samples of audio frame to a different channel count
+ * when the port's get_frame() and put_frame() is called.
+ *
+ * When the port's get_frame() is called, this port will get a frame from
+ * the downstream port and convert the frame to the target channel count before
+ * returning it to the caller.
+ *
+ * When the port's put_frame() is called, this port will convert the frame
+ * to the downstream port's channel count before giving the frame to the
+ * downstream port.
+ *
+ * @param pool Pool to allocate the structure and buffers.
+ * @param dn_port The downstream port, which channel count is to
+ * be converted to the target channel count.
+ * @param channel_count This port channel count.
+ * @param options Bitmask flags from #pjmedia_stereo_port_options
+ * and also application may add PJMEDIA_STEREO_MIX
+ * to mix channels.
+ * When this flag is zero, the default behavior
+ * is to use simple N-to-1 channel converter and
+ * to destroy downstream port when this port is
+ * destroyed.
+ * @param p_port Pointer to receive the stereo port instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_stereo_port_create( pj_pool_t *pool,
+ pjmedia_port *dn_port,
+ unsigned channel_count,
+ unsigned options,
+ pjmedia_port **p_port );
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_STEREO_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/stream.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/stream.h new file mode 100644 index 0000000..f4c58db --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/stream.h @@ -0,0 +1,354 @@ +/* $Id: stream.h 2844 2009-07-29 12:14:21Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_STREAM_H__
+#define __PJMEDIA_STREAM_H__
+
+
+/**
+ * @file stream.h
+ * @brief Media Stream.
+ */
+
+#include <pjmedia/codec.h>
+#include <pjmedia/endpoint.h>
+#include <pjmedia/jbuf.h>
+#include <pjmedia/port.h>
+#include <pjmedia/rtcp.h>
+#include <pjmedia/transport.h>
+#include <pj/sock.h>
+
+PJ_BEGIN_DECL
+
+
+/**
+ * @defgroup PJMED_STRM Streams
+ * @ingroup PJMEDIA_PORT
+ * @brief Communicating with remote peer via the network
+ * @{
+ *
+ * A media stream is a bidirectional multimedia communication between two
+ * endpoints. It corresponds to a media description (m= line) in SDP
+ * session descriptor.
+ *
+ * A media stream consists of two unidirectional channels:
+ * - encoding channel, which transmits unidirectional media to remote, and
+ * - decoding channel, which receives unidirectional media from remote.
+ *
+ * A media stream exports media port interface (see @ref PJMEDIA_PORT)
+ * and application normally uses this interface to interconnect the stream
+ * to other PJMEDIA components.
+ *
+ * A media stream internally manages the following objects:
+ * - an instance of media codec (see @ref PJMEDIA_CODEC),
+ * - an @ref PJMED_JBUF,
+ * - two instances of RTP sessions (#pjmedia_rtp_session, one for each
+ * direction),
+ * - one instance of RTCP session (#pjmedia_rtcp_session),
+ * - and a reference to media transport to send and receive packets
+ * to/from the network (see @ref PJMEDIA_TRANSPORT).
+ *
+ * Streams are created by calling #pjmedia_stream_create(), specifying
+ * #pjmedia_stream_info structure in the parameter. Application can construct
+ * the #pjmedia_stream_info structure manually, or use
+ * #pjmedia_stream_info_from_sdp() or #pjmedia_session_info_from_sdp()
+ * functions to construct the #pjmedia_stream_info from local and remote
+ * SDP session descriptors.
+ *
+ * Application can also use @ref PJMEDIA_SESSION to indirectly create the
+ * streams.
+ */
+
+/**
+ * Opaque declaration for media channel.
+ * Media channel is unidirectional flow of media from sender to
+ * receiver.
+ */
+typedef struct pjmedia_channel pjmedia_channel;
+
+/**
+ * This structure describes media stream information. Each media stream
+ * corresponds to one "m=" line in SDP session descriptor, and it has
+ * its own RTP/RTCP socket pair.
+ */
+struct pjmedia_stream_info
+{
+ pjmedia_type type; /**< Media type (audio, video) */
+ pjmedia_tp_proto proto; /**< Transport protocol (RTP/AVP, etc.) */
+ pjmedia_dir dir; /**< Media direction. */
+ pj_sockaddr rem_addr; /**< Remote RTP address */
+ pj_sockaddr rem_rtcp; /**< Optional remote RTCP address. If
+ sin_family is zero, the RTP address
+ will be calculated from RTP. */
+#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)
+ pj_bool_t rtcp_xr_enabled;
+ /**< Specify whether RTCP XR is enabled.*/
+ pj_uint32_t rtcp_xr_interval; /**< RTCP XR interval. */
+ pj_sockaddr rtcp_xr_dest;/**<Additional remote RTCP XR address.
+ This is useful for third-party (e.g:
+ network monitor) to monitor the
+ stream. If sin_family is zero,
+ this will be ignored. */
+#endif
+ pjmedia_codec_info fmt; /**< Incoming codec format info. */
+ pjmedia_codec_param *param; /**< Optional codec param. */
+ unsigned tx_pt; /**< Outgoing codec paylaod type. */
+ unsigned tx_maxptime;/**< Outgoing codec max ptime. */
+ int tx_event_pt;/**< Outgoing pt for telephone-events. */
+ int rx_event_pt;/**< Incoming pt for telephone-events. */
+ pj_uint32_t ssrc; /**< RTP SSRC. */
+ pj_uint32_t rtp_ts; /**< Initial RTP timestamp. */
+ pj_uint16_t rtp_seq; /**< Initial RTP sequence number. */
+ pj_uint8_t rtp_seq_ts_set;
+ /**< Bitmask flags if initial RTP sequence
+ and/or timestamp for sender are set.
+ bit 0/LSB : sequence flag
+ bit 1 : timestamp flag */
+ int jb_init; /**< Jitter buffer init delay in msec.
+ (-1 for default). */
+ int jb_min_pre; /**< Jitter buffer minimum prefetch
+ delay in msec (-1 for default). */
+ int jb_max_pre; /**< Jitter buffer maximum prefetch
+ delay in msec (-1 for default). */
+ int jb_max; /**< Jitter buffer max delay in msec. */
+};
+
+
+/**
+ * @see pjmedia_stream_info.
+ */
+typedef struct pjmedia_stream_info pjmedia_stream_info;
+
+
+
+/**
+ * Create a media stream based on the specified parameter. After the stream
+ * has been created, application normally would want to get the media port
+ * interface of the streams, by calling pjmedia_stream_get_port(). The
+ * media port interface exports put_frame() and get_frame() function, used
+ * to transmit and receive media frames from the stream.
+ *
+ * Without application calling put_frame() and get_frame(), there will be
+ * no media frames transmitted or received by the stream.
+ *
+ * @param endpt Media endpoint.
+ * @param pool Pool to allocate memory for the stream. A large
+ * number of memory may be needed because jitter
+ * buffer needs to preallocate some storage.
+ * @param info Stream information.
+ * @param tp Stream transport instance used to transmit
+ * and receive RTP/RTCP packets to/from the underlying
+ * transport.
+ * @param user_data Arbitrary user data (for future callback feature).
+ * @param p_stream Pointer to receive the media stream.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_stream_create(pjmedia_endpt *endpt,
+ pj_pool_t *pool,
+ const pjmedia_stream_info *info,
+ pjmedia_transport *tp,
+ void *user_data,
+ pjmedia_stream **p_stream);
+
+/**
+ * Destroy the media stream.
+ *
+ * @param stream The media stream.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_stream_destroy(pjmedia_stream *stream);
+
+
+/**
+ * Get the media port interface of the stream. The media port interface
+ * declares put_frame() and get_frame() function, which is the only
+ * way for application to transmit and receive media frames from the
+ * stream.
+ *
+ * @param stream The media stream.
+ * @param p_port Pointer to receive the port interface.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_stream_get_port(pjmedia_stream *stream,
+ pjmedia_port **p_port );
+
+
+/**
+ * Get the media transport object associated with this stream.
+ *
+ * @param st The media stream.
+ *
+ * @return The transport object being used by the stream.
+ */
+PJ_DECL(pjmedia_transport*) pjmedia_stream_get_transport(pjmedia_stream *st);
+
+
+/**
+ * Start the media stream. This will start the appropriate channels
+ * in the media stream, depending on the media direction that was set
+ * when the stream was created.
+ *
+ * @param stream The media stream.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_stream_start(pjmedia_stream *stream);
+
+
+/**
+ * Get the stream statistics. See also
+ * #pjmedia_stream_get_stat_jbuf()
+ *
+ * @param stream The media stream.
+ * @param stat Media stream statistics.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_stream_get_stat( const pjmedia_stream *stream,
+ pjmedia_rtcp_stat *stat);
+
+#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)
+/**
+ * Get the stream extended report statistics (RTCP XR).
+ *
+ * @param stream The media stream.
+ * @param stat Media stream extended report statistics.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_stream_get_stat_xr( const pjmedia_stream *stream,
+ pjmedia_rtcp_xr_stat *stat);
+#endif
+
+/**
+ * Get current jitter buffer state. See also
+ * #pjmedia_stream_get_stat()
+ *
+ * @param stream The media stream.
+ * @param state Jitter buffer state.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_stream_get_stat_jbuf(const pjmedia_stream *stream,
+ pjmedia_jb_state *state);
+
+
+/**
+ * Pause the individual channel in the stream.
+ *
+ * @param stream The media channel.
+ * @param dir Which direction to pause.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_stream_pause( pjmedia_stream *stream,
+ pjmedia_dir dir);
+
+/**
+ * Resume the individual channel in the stream.
+ *
+ * @param stream The media channel.
+ * @param dir Which direction to resume.
+ *
+ * @return PJ_SUCCESS on success;
+ */
+PJ_DECL(pj_status_t) pjmedia_stream_resume(pjmedia_stream *stream,
+ pjmedia_dir dir);
+
+/**
+ * Transmit DTMF to this stream. The DTMF will be transmitted uisng
+ * RTP telephone-events as described in RFC 2833. This operation is
+ * only valid for audio stream.
+ *
+ * @param stream The media stream.
+ * @param ascii_digit String containing digits to be sent to remote.
+ * Currently the maximum number of digits are 32.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_stream_dial_dtmf(pjmedia_stream *stream,
+ const pj_str_t *ascii_digit);
+
+
+/**
+ * Check if the stream has incoming DTMF digits in the incoming DTMF
+ * queue. Incoming DTMF digits received via RFC 2833 mechanism are
+ * saved in the incoming digits queue.
+ *
+ * @param stream The media stream.
+ *
+ * @return Non-zero (PJ_TRUE) if the stream has received DTMF
+ * digits in the .
+ */
+PJ_DECL(pj_bool_t) pjmedia_stream_check_dtmf(pjmedia_stream *stream);
+
+
+/**
+ * Retrieve the incoming DTMF digits from the stream, and remove the digits
+ * from stream's DTMF buffer. Note that the digits buffer will not be NULL
+ * terminated.
+ *
+ * @param stream The media stream.
+ * @param ascii_digits Buffer to receive the digits. The length of this
+ * buffer is indicated in the "size" argument.
+ * @param size On input, contains the maximum digits to be copied
+ * to the buffer.
+ * On output, it contains the actual digits that has
+ * been copied to the buffer.
+ *
+ * @return Non-zero (PJ_TRUE) if the stream has received DTMF
+ * digits in the .
+ */
+PJ_DECL(pj_status_t) pjmedia_stream_get_dtmf( pjmedia_stream *stream,
+ char *ascii_digits,
+ unsigned *size);
+
+
+/**
+ * Set callback to be called upon receiving DTMF digits. If callback is
+ * registered, the stream will not buffer incoming DTMF but rather call
+ * the callback as soon as DTMF digit is received completely.
+ *
+ * @param stream The media stream.
+ * @param cb Callback to be called upon receiving DTMF digits.
+ * The DTMF digits will be given to the callback as
+ * ASCII digits.
+ * @param user_data User data to be returned back when the callback
+ * is called.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_stream_set_dtmf_callback(pjmedia_stream *stream,
+ void (*cb)(pjmedia_stream*,
+ void *user_data,
+ int digit),
+ void *user_data);
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_STREAM_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/symbian_sound_aps.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/symbian_sound_aps.h new file mode 100644 index 0000000..865ec56 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/symbian_sound_aps.h @@ -0,0 +1,48 @@ +/* $Id: symbian_sound_aps.h 2506 2009-03-12 18:11:37Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_SYMBIAN_SOUND_APS_H__
+#define __PJMEDIA_SYMBIAN_SOUND_APS_H__
+
+
+/**
+ * @file symbian_sound_aps.h
+ * @brief Sound device wrapper using Audio Proxy Server on
+ * Symbian S60 3rd edition.
+ */
+#include <pjmedia/types.h>
+
+PJ_BEGIN_DECL
+
+/**
+ * Set audio routing for APS sound device.
+ *
+ * @param stream The sound device stream, the stream should be started
+ * before calling this function.
+ * @param route Audio routing to be set.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_snd_aps_set_route( pjmedia_snd_stream *stream,
+ pjmedia_snd_route route);
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_SYMBIAN_SOUND_APS_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/tonegen.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/tonegen.h new file mode 100644 index 0000000..3211e66 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/tonegen.h @@ -0,0 +1,293 @@ +/* $Id: tonegen.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_TONEGEN_PORT_H__
+#define __PJMEDIA_TONEGEN_PORT_H__
+
+/**
+ * @file tonegen.h
+ * @brief Tone (sine, MF, DTMF) generator media port.
+ */
+#include <pjmedia/port.h>
+
+
+/**
+ * @defgroup PJMEDIA_MF_DTMF_TONE_GENERATOR Multi-frequency tone generator
+ * @ingroup PJMEDIA_PORT
+ * @brief Multi-frequency tone generator
+ * @{
+ *
+ * This page describes tone generator media port. A tone generator can be
+ * used to generate a single frequency sine wave or dual frequency tones
+ * such as DTMF.
+ *
+ * The tone generator media port provides two functions to generate tones.
+ * The function #pjmedia_tonegen_play() can be used to generate arbitrary
+ * single or dual frequency tone, and #pjmedia_tonegen_play_digits() is
+ * used to play digits such as DTMF. Each tone specified in the playback
+ * function has individual on and off signal duration that must be
+ * specified by application.
+ *
+ * In order to play digits such as DTMF, the tone generator is equipped
+ * with digit map, which contain information about the frequencies of
+ * the digits. The default digit map is DTMF (0-9,a-d,*,#), but application
+ * may specifiy different digit map to the tone generator by calling
+ * #pjmedia_tonegen_set_digit_map() function.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * This structure describes individual MF digits to be played
+ * with #pjmedia_tonegen_play().
+ */
+typedef struct pjmedia_tone_desc
+{
+ short freq1; /**< First frequency. */
+ short freq2; /**< Optional second frequency. */
+ short on_msec; /**< Playback ON duration, in miliseconds. */
+ short off_msec; /**< Playback OFF duration, ini miliseconds. */
+ short volume; /**< Volume (1-32767), or 0 for default, which
+ PJMEDIA_TONEGEN_VOLUME will be used. */
+ short flags; /**< Currently internal flags, must be 0 */
+} pjmedia_tone_desc;
+
+
+
+/**
+ * This structure describes individual MF digits to be played
+ * with #pjmedia_tonegen_play_digits().
+ */
+typedef struct pjmedia_tone_digit
+{
+ char digit; /**< The ASCI identification for the digit. */
+ short on_msec; /**< Playback ON duration, in miliseconds. */
+ short off_msec; /**< Playback OFF duration, ini miliseconds. */
+ short volume; /**< Volume (1-32767), or 0 for default, which
+ PJMEDIA_TONEGEN_VOLUME will be used. */
+} pjmedia_tone_digit;
+
+
+/**
+ * This structure describes the digit map which is used by the tone generator
+ * to produce tones from an ASCII digits.
+ * Digit map used by a particular tone generator can be retrieved/set with
+ * #pjmedia_tonegen_get_digit_map() and #pjmedia_tonegen_set_digit_map().
+ */
+typedef struct pjmedia_tone_digit_map
+{
+ unsigned count; /**< Number of digits in the map. */
+
+ struct {
+ char digit; /**< The ASCI identification for the digit. */
+ short freq1; /**< First frequency. */
+ short freq2; /**< Optional second frequency. */
+ } digits[16]; /**< Array of digits in the digit map. */
+} pjmedia_tone_digit_map;
+
+
+/**
+ * Tone generator options.
+ */
+enum
+{
+ /**
+ * Play the tones in loop, restarting playing the first tone after
+ * the last tone has been played.
+ */
+ PJMEDIA_TONEGEN_LOOP = 1,
+
+ /**
+ * Disable mutex protection to the tone generator.
+ */
+ PJMEDIA_TONEGEN_NO_LOCK = 2
+};
+
+
+/**
+ * Create an instance of tone generator with the specified parameters.
+ * When the tone generator is first created, it will be loaded with the
+ * default digit map.
+ *
+ * @param pool Pool to allocate memory for the port structure.
+ * @param clock_rate Sampling rate.
+ * @param channel_count Number of channels. Currently only mono and stereo
+ * are supported.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Number of bits per sample. This version of PJMEDIA
+ * only supports 16bit per sample.
+ * @param options Option flags. Application may specify
+ * PJMEDIA_TONEGEN_LOOP to play the tone in a loop.
+ * @param p_port Pointer to receive the port instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_tonegen_create(pj_pool_t *pool,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ unsigned options,
+ pjmedia_port **p_port);
+
+
+/**
+ * Create an instance of tone generator with the specified parameters.
+ * When the tone generator is first created, it will be loaded with the
+ * default digit map.
+ *
+ * @param pool Pool to allocate memory for the port structure.
+ * @param name Optional name for the tone generator.
+ * @param clock_rate Sampling rate.
+ * @param channel_count Number of channels. Currently only mono and stereo
+ * are supported.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Number of bits per sample. This version of PJMEDIA
+ * only supports 16bit per sample.
+ * @param options Option flags. Application may specify
+ * PJMEDIA_TONEGEN_LOOP to play the tone in a loop.
+ * @param p_port Pointer to receive the port instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate
+ * error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_tonegen_create2(pj_pool_t *pool,
+ const pj_str_t *name,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ unsigned options,
+ pjmedia_port **p_port);
+
+
+/**
+ * Check if the tone generator is still busy producing some tones.
+ *
+ * @param tonegen The tone generator instance.
+ *
+ * @return Non-zero if busy.
+ */
+PJ_DECL(pj_bool_t) pjmedia_tonegen_is_busy(pjmedia_port *tonegen);
+
+
+/**
+ * Instruct the tone generator to stop current processing.
+ *
+ * @param tonegen The tone generator instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_tonegen_stop(pjmedia_port *tonegen);
+
+
+/**
+ * Rewind the playback. This will start the playback to the first
+ * tone in the playback list.
+ *
+ * @param tonegen The tone generator instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_tonegen_rewind(pjmedia_port *tonegen);
+
+
+/**
+ * Instruct the tone generator to play single or dual frequency tones
+ * with the specified duration. The new tones will be appended to currently
+ * playing tones, unless #pjmedia_tonegen_stop() is called before calling
+ * this function. The playback will begin as soon as the first get_frame()
+ * is called to the generator.
+ *
+ * @param tonegen The tone generator instance.
+ * @param count The number of tones in the array.
+ * @param tones Array of tones to be played.
+ * @param options Option flags. Application may specify
+ * PJMEDIA_TONEGEN_LOOP to play the tone in a loop.
+ *
+ * @return PJ_SUCCESS on success, or PJ_ETOOMANY if
+ * there are too many digits in the queue.
+ */
+PJ_DECL(pj_status_t) pjmedia_tonegen_play(pjmedia_port *tonegen,
+ unsigned count,
+ const pjmedia_tone_desc tones[],
+ unsigned options);
+
+/**
+ * Instruct the tone generator to play multiple MF digits with each of
+ * the digits having individual ON/OFF duration. Each of the digit in the
+ * digit array must have the corresponding descriptor in the digit map.
+ * The new tones will be appended to currently playing tones, unless
+ * #pjmedia_tonegen_stop() is called before calling this function.
+ * The playback will begin as soon as the first get_frame() is called
+ * to the generator.
+ *
+ * @param tonegen The tone generator instance.
+ * @param count Number of digits in the array.
+ * @param digits Array of MF digits.
+ * @param options Option flags. Application may specify
+ * PJMEDIA_TONEGEN_LOOP to play the tone in a loop.
+ *
+ * @return PJ_SUCCESS on success, or PJ_ETOOMANY if
+ * there are too many digits in the queue, or
+ * PJMEDIA_RTP_EINDTMF if invalid digit is
+ * specified.
+ */
+PJ_DECL(pj_status_t) pjmedia_tonegen_play_digits(pjmedia_port *tonegen,
+ unsigned count,
+ const pjmedia_tone_digit digits[],
+ unsigned options);
+
+
+/**
+ * Get the digit-map currently used by this tone generator.
+ *
+ * @param tonegen The tone generator instance.
+ * @param m On output, it will be filled with the pointer to
+ * the digitmap currently used by the tone generator.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_tonegen_get_digit_map(pjmedia_port *tonegen,
+ const pjmedia_tone_digit_map **m);
+
+
+/**
+ * Set digit map to be used by the tone generator.
+ *
+ * @param tonegen The tone generator instance.
+ * @param m Digitmap to be used by the tone generator.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_tonegen_set_digit_map(pjmedia_port *tonegen,
+ pjmedia_tone_digit_map *m);
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_TONEGEN_PORT_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport.h new file mode 100644 index 0000000..bc8352b --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport.h @@ -0,0 +1,820 @@ +/* $Id: transport.h 2945 2009-10-14 13:13:18Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_TRANSPORT_H__
+#define __PJMEDIA_TRANSPORT_H__
+
+
+/**
+ * @file transport.h Media Transport Interface
+ * @brief Transport interface.
+ */
+
+#include <pjmedia/types.h>
+#include <pjmedia/errno.h>
+
+/**
+ * @defgroup PJMEDIA_TRANSPORT Media Transport
+ * @brief Transports.
+ * @{
+ * The media transport (#pjmedia_transport) is the object to send and
+ * receive media packets over the network. The media transport interface
+ * allows the library to be extended to support different types of
+ * transports to send and receive packets.
+ *
+ * The media transport is declared as #pjmedia_transport "class", which
+ * declares "interfaces" to use the class in #pjmedia_transport_op
+ * structure. For the user of the media transport (normally the user of
+ * media transport is media stream, see \ref PJMED_STRM), these transport
+ * "methods" are wrapped with API such as #pjmedia_transport_attach(),
+ * so it should not need to call the function pointer inside
+ * #pjmedia_transport_op directly.
+ *
+ * The connection between \ref PJMED_STRM and media transport is shown in
+ * the diagram below:
+
+ \image html media-transport.PNG
+
+
+ * \section PJMEDIA_TRANSPORT_H_USING Basic Media Transport Usage
+ *
+ * The media transport's life-cycle normally follows the following stages.
+ *
+ * \subsection PJMEDIA_TRANSPORT_H_CREATE Creating the Media Transport
+ *
+ * Application creates the media transport when it needs to establish
+ * media session to remote peer. The media transport is created using
+ * specific function to create that particular transport; for example,
+ * for UDP media transport, it is created with #pjmedia_transport_udp_create()
+ * or #pjmedia_transport_udp_create2() functions. Different media
+ * transports will provide different API to create those transports.
+ *
+ * Alternatively, application may create pool of media transports when
+ * it is first started up. Using this approach probably is better, since
+ * application has to specify the RTP port when sending the initial
+ * session establishment request (e.g. SIP INVITE request), thus if
+ * application only creates the media transport later when media is to be
+ * established (normally when 200/OK is received, or when 18x is received
+ * for early media), there is a possibility that the particular RTP
+ * port might have been occupied by other programs. Also it is more
+ * efficient since sockets don't need to be closed and re-opened between
+ * calls.
+ *
+ *
+ * \subsection PJMEDIA_TRANSPORT_H_ATTACH Attaching and Using the Media Transport.
+ *
+ * Application specifies the media transport instance when creating
+ * the media session (#pjmedia_session_create()). Alternatively, it
+ * may create the media stream directly with #pjmedia_stream_create()
+ * and specify the transport instance in the argument. (Note: media
+ * session is a high-level abstraction for media communications between
+ * two endpoints, and it may contain more than one media streams, for
+ * example, an audio stream and a video stream).
+ *
+ * When stream is created, it will "attach" itself to the media
+ * transport by calling #pjmedia_transport_attach(), which is a thin
+ * wrapper which calls "attach()" method of the media transport's
+ * "virtual function pointer" (#pjmedia_transport_op). Among other things,
+ * the stream specifies two callback functions to the transport: one
+ * callback function will be called by transport when it receives RTP
+ * packet, and another callback for incoming RTCP packet. The
+ * #pjmedia_transport_attach() function also establish the destination
+ * of the outgoing RTP and RTCP packets.
+ *
+ * When the stream needs to send outgoing RTP/RTCP packets, it will
+ * call #pjmedia_transport_send_rtp() and #pjmedia_transport_send_rtcp()
+ * of the media transport API, which is a thin wrapper to call send_rtp()
+ * and send_rtcp() methods in the media transport's "virtual function
+ * pointer" (#pjmedia_transport_op).
+ *
+ * When the stream is destroyed, it will "detach" itself from
+ * the media transport by calling #pjmedia_transport_detach(), which is
+ * a thin wrapper which calls "detach()" method of the media transport's
+ * "virtual function pointer" (#pjmedia_transport_op). After the transport
+ * is detached from its user (the stream), it will no longer report
+ * incoming RTP/RTCP packets to the stream, and it will refuse to send
+ * outgoing packets since the destination has been cleared.
+ *
+ *
+ * \subsection PJMEDIA_TRANSPORT_H_REUSE Reusing the Media Transport.
+ *
+ * After transport has been detached, application may re-attach the
+ * transport to another stream if it wants to. Detaching and re-attaching
+ * media transport may be preferable than closing and re-opening the
+ * transport, since it is more efficient (sockets don't need to be
+ * closed and re-opened). However it is up to the application to choose
+ * which method is most suitable for its uses.
+ *
+ *
+ * \subsection PJMEDIA_TRANSPORT_H_DESTROY Destroying the Media Transport.
+ *
+ * Finally if application no longer needs the media transport, it will
+ * call #pjmedia_transport_close() function, which is thin wrapper which
+ * calls "destroy()" method of the media transport's "virtual function
+ * pointer" (#pjmedia_transport_op). This function releases
+ * all resources used by the transport, such as sockets and memory.
+ *
+ *
+ * \section offer_answer Interaction with SDP Offer/Answer
+
+ For basic UDP transport, the \ref PJMEDIA_TRANSPORT_H_USING above is
+ sufficient to use the media transport. However, more complex media
+ transports such as \ref PJMEDIA_TRANSPORT_SRTP and \ref
+ PJMEDIA_TRANSPORT_ICE requires closer interactions with SDP offer and
+ answer negotiation.
+
+ The media transports can interact with the SDP offer/answer via
+ these APIs:
+ - #pjmedia_transport_media_create(), to initialize the media transport
+ for new media session,
+ - #pjmedia_transport_encode_sdp(), to encode SDP offer or answer,
+ - #pjmedia_transport_media_start(), to activate the settings that
+ have been negotiated by SDP offer answer, and
+ - #pjmedia_transport_media_stop(), to deinitialize the media transport
+ and reset the transport to its idle state.
+
+ The usage of these API in the context of SDP offer answer will be
+ described below.
+
+ \subsection media_create Initializing Transport for New Session
+
+ Application must call #pjmedia_transport_media_create() before using
+ the transport for a new session.
+
+ \subsection creat_oa Creating SDP Offer and Answer
+
+ The #pjmedia_transport_encode_sdp() is used to put additional information
+ from the transport to the local SDP, before the SDP is sent and negotiated
+ with remote SDP.
+
+ When creating an offer, call #pjmedia_transport_encode_sdp() with
+ local SDP (and NULL as \a rem_sdp). The media transport will add the
+ relevant attributes in the local SDP. Application then gives the local
+ SDP to the invite session to be sent to remote agent.
+
+ When creating an answer, also call #pjmedia_transport_encode_sdp(),
+ but this time specify both local and remote SDP to the function. The
+ media transport will once again modify the local SDP and add relevant
+ attributes to the local SDP, if the appropriate attributes related to
+ the transport functionality are present in remote offer. The remote
+ SDP does not contain the relevant attributes, then the specific transport
+ functionality will not be activated for the session.
+
+ The #pjmedia_transport_encode_sdp() should also be called when application
+ sends subsequent SDP offer or answer. The media transport will encode
+ the appropriate attributes based on the state of the session.
+
+ \subsection media_start Offer/Answer Completion
+
+ Once both local and remote SDP have been negotiated by the
+ \ref PJMEDIA_SDP_NEG (normally this is part of PJSIP invite session),
+ application should give both local and remote SDP to
+ #pjmedia_transport_media_start() so that the settings are activated
+ for the session. This function should be called for both initial and
+ subsequent SDP negotiation.
+
+ \subsection media_stop Stopping Transport
+
+ Once session is stop application must call #pjmedia_transport_media_stop()
+ to deactivate the transport feature. Application may reuse the transport
+ for subsequent media session by repeating the #pjmedia_transport_media_create(),
+ #pjmedia_transport_encode_sdp(), #pjmedia_transport_media_start(), and
+ #pjmedia_transport_media_stop() above.
+
+ * \section PJMEDIA_TRANSPORT_H_IMPL Implementing Media Transport
+ *
+ * To implement a new type of media transport, one needs to "subclass" the
+ * media transport "class" (#pjmedia_transport) by providing the "methods"
+ * in the media transport "interface" (#pjmedia_transport_op), and provides
+ * a function to create this new type of transport (similar to
+ * #pjmedia_transport_udp_create() function).
+ *
+ * The media transport is expected to run indepently, that is there should
+ * be no polling like function to poll the transport for incoming RTP/RTCP
+ * packets. This normally can be done by registering the media sockets to
+ * the media endpoint's IOQueue, which allows the transport to be notified
+ * when incoming packet has arrived.
+ *
+ * Alternatively, media transport may utilize thread(s) internally to wait
+ * for incoming packets. The thread then will call the appropriate RTP or
+ * RTCP callback provided by its user (stream) whenever packet is received.
+ * If the transport's user is a stream, then the callbacks provided by the
+ * stream will be thread-safe, so the transport may call these callbacks
+ * without having to serialize the access with some mutex protection. But
+ * the media transport may still have to protect its internal data with
+ * mutex protection, since it may be called by application's thread (for
+ * example, to send RTP/RTCP packets).
+ *
+ */
+
+
+#include <pjmedia/sdp.h>
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Forward declaration for media transport.
+ */
+typedef struct pjmedia_transport pjmedia_transport;
+
+/**
+ * Forward declaration for media transport info.
+ */
+typedef struct pjmedia_transport_info pjmedia_transport_info;
+
+/**
+ * This enumeration specifies the general behaviour of media processing
+ */
+typedef enum pjmedia_tranport_media_option
+{
+ /**
+ * When this flag is specified, the transport will not perform media
+ * transport validation, this is useful when transport is stacked with
+ * other transport, for example when transport UDP is stacked under
+ * transport SRTP, media transport validation only need to be done by
+ * transport SRTP.
+ */
+ PJMEDIA_TPMED_NO_TRANSPORT_CHECKING = 1
+
+} pjmedia_tranport_media_option;
+
+
+/**
+ * This structure describes the operations for the stream transport.
+ */
+struct pjmedia_transport_op
+{
+ /**
+ * Get media socket info from the specified transport.
+ *
+ * Application should call #pjmedia_transport_get_info() instead
+ */
+ pj_status_t (*get_info)(pjmedia_transport *tp,
+ pjmedia_transport_info *info);
+
+ /**
+ * This function is called by the stream when the transport is about
+ * to be used by the stream for the first time, and it tells the transport
+ * about remote RTP address to send the packet and some callbacks to be
+ * called for incoming packets.
+ *
+ * Application should call #pjmedia_transport_attach() instead of
+ * calling this function directly.
+ */
+ pj_status_t (*attach)(pjmedia_transport *tp,
+ void *user_data,
+ const pj_sockaddr_t *rem_addr,
+ const pj_sockaddr_t *rem_rtcp,
+ unsigned addr_len,
+ void (*rtp_cb)(void *user_data,
+ void *pkt,
+ pj_ssize_t size),
+ void (*rtcp_cb)(void *user_data,
+ void *pkt,
+ pj_ssize_t size));
+
+ /**
+ * This function is called by the stream when the stream no longer
+ * needs the transport (normally when the stream is about to be closed).
+ * After the transport is detached, it will ignore incoming
+ * RTP/RTCP packets, and will refuse to send outgoing RTP/RTCP packets.
+ * Application may re-attach the media transport to another transport
+ * user (e.g. stream) after the transport has been detached.
+ *
+ * Application should call #pjmedia_transport_detach() instead of
+ * calling this function directly.
+ */
+ void (*detach)(pjmedia_transport *tp,
+ void *user_data);
+
+ /**
+ * This function is called by the stream to send RTP packet using the
+ * transport.
+ *
+ * Application should call #pjmedia_transport_send_rtp() instead of
+ * calling this function directly.
+ */
+ pj_status_t (*send_rtp)(pjmedia_transport *tp,
+ const void *pkt,
+ pj_size_t size);
+
+ /**
+ * This function is called by the stream to send RTCP packet using the
+ * transport.
+ *
+ * Application should call #pjmedia_transport_send_rtcp() instead of
+ * calling this function directly.
+ */
+ pj_status_t (*send_rtcp)(pjmedia_transport *tp,
+ const void *pkt,
+ pj_size_t size);
+
+ /**
+ * This function is called by the stream to send RTCP packet using the
+ * transport with destination address other than default specified in
+ * #pjmedia_transport_attach().
+ *
+ * Application should call #pjmedia_transport_send_rtcp2() instead of
+ * calling this function directly.
+ */
+ pj_status_t (*send_rtcp2)(pjmedia_transport *tp,
+ const pj_sockaddr_t *addr,
+ unsigned addr_len,
+ const void *pkt,
+ pj_size_t size);
+
+ /**
+ * Prepare the transport for a new media session.
+ *
+ * Application should call #pjmedia_transport_media_create() instead of
+ * calling this function directly.
+ */
+ pj_status_t (*media_create)(pjmedia_transport *tp,
+ pj_pool_t *sdp_pool,
+ unsigned options,
+ const pjmedia_sdp_session *remote_sdp,
+ unsigned media_index);
+
+ /**
+ * This function is called by application to generate the SDP parts
+ * related to transport type, e.g: ICE, SRTP.
+ *
+ * Application should call #pjmedia_transport_encode_sdp() instead of
+ * calling this function directly.
+ */
+ pj_status_t (*encode_sdp)(pjmedia_transport *tp,
+ pj_pool_t *sdp_pool,
+ pjmedia_sdp_session *sdp_local,
+ const pjmedia_sdp_session *rem_sdp,
+ unsigned media_index);
+
+ /**
+ * This function is called by application to start the transport
+ * based on local and remote SDP.
+ *
+ * Application should call #pjmedia_transport_media_start() instead of
+ * calling this function directly.
+ */
+ pj_status_t (*media_start) (pjmedia_transport *tp,
+ pj_pool_t *tmp_pool,
+ const pjmedia_sdp_session *sdp_local,
+ const pjmedia_sdp_session *sdp_remote,
+ unsigned media_index);
+
+ /**
+ * This function is called by application to stop the transport.
+ *
+ * Application should call #pjmedia_transport_media_stop() instead of
+ * calling this function directly.
+ */
+ pj_status_t (*media_stop) (pjmedia_transport *tp);
+
+ /**
+ * This function can be called to simulate packet lost.
+ *
+ * Application should call #pjmedia_transport_simulate_lost() instead of
+ * calling this function directly.
+ */
+ pj_status_t (*simulate_lost)(pjmedia_transport *tp,
+ pjmedia_dir dir,
+ unsigned pct_lost);
+
+ /**
+ * This function can be called to destroy this transport.
+ *
+ * Application should call #pjmedia_transport_close() instead of
+ * calling this function directly.
+ */
+ pj_status_t (*destroy)(pjmedia_transport *tp);
+};
+
+
+/**
+ * @see pjmedia_transport_op.
+ */
+typedef struct pjmedia_transport_op pjmedia_transport_op;
+
+
+/**
+ * Media transport type.
+ */
+typedef enum pjmedia_transport_type
+{
+ /** Media transport using standard UDP */
+ PJMEDIA_TRANSPORT_TYPE_UDP,
+
+ /** Media transport using ICE */
+ PJMEDIA_TRANSPORT_TYPE_ICE,
+
+ /**
+ * Media transport SRTP, this transport is actually security adapter to be
+ * stacked with other transport to enable encryption on the underlying
+ * transport.
+ */
+ PJMEDIA_TRANSPORT_TYPE_SRTP,
+
+ /**
+ * Start of user defined transport.
+ */
+ PJMEDIA_TRANSPORT_TYPE_USER
+
+} pjmedia_transport_type;
+
+
+/**
+ * This structure declares media transport. A media transport is called
+ * by the stream to transmit a packet, and will notify stream when
+ * incoming packet is arrived.
+ */
+struct pjmedia_transport
+{
+ /** Transport name (for logging purpose). */
+ char name[PJ_MAX_OBJ_NAME];
+
+ /** Transport type. */
+ pjmedia_transport_type type;
+
+ /** Transport's "virtual" function table. */
+ pjmedia_transport_op *op;
+};
+
+/**
+ * This structure describes storage buffer of transport specific info.
+ * The actual transport specific info contents will be defined by transport
+ * implementation. Note that some transport implementations do not need to
+ * provide specific info, since the general socket info is enough.
+ */
+typedef struct pjmedia_transport_specific_info
+{
+ /**
+ * Specify media transport type.
+ */
+ pjmedia_transport_type type;
+
+ /**
+ * Specify storage buffer size of transport specific info.
+ */
+ int cbsize;
+
+ /**
+ * Storage buffer of transport specific info.
+ */
+ char buffer[PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE];
+
+} pjmedia_transport_specific_info;
+
+
+/**
+ * This structure describes transport informations, including general
+ * socket information and specific information of single transport or
+ * stacked transports (e.g: SRTP stacked on top of UDP)
+ */
+struct pjmedia_transport_info
+{
+ /**
+ * General socket info.
+ */
+ pjmedia_sock_info sock_info;
+
+ /**
+ * Remote address where RTP/RTCP originated from. In case this transport
+ * hasn't ever received packet, the
+ */
+ pj_sockaddr src_rtp_name;
+ pj_sockaddr src_rtcp_name;
+
+ /**
+ * Specifies number of transport specific info included.
+ */
+ unsigned specific_info_cnt;
+
+ /**
+ * Buffer storage of transport specific info.
+ */
+ pjmedia_transport_specific_info spc_info[PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXCNT];
+
+};
+
+
+/**
+ * Initialize transport info.
+ *
+ * @param info Transport info to be initialized.
+ */
+PJ_INLINE(void) pjmedia_transport_info_init(pjmedia_transport_info *info)
+{
+ pj_bzero(&info->sock_info, sizeof(pjmedia_sock_info));
+ info->sock_info.rtp_sock = info->sock_info.rtcp_sock = PJ_INVALID_SOCKET;
+ info->specific_info_cnt = 0;
+}
+
+
+/**
+ * Get media transport info from the specified transport and all underlying
+ * transports if any. The transport also contains information about socket info
+ * which describes the local address of the transport, and would be needed
+ * for example to fill in the "c=" and "m=" line of local SDP.
+ *
+ * @param tp The transport.
+ * @param info Media socket info to be initialized.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_transport_get_info(pjmedia_transport *tp,
+ pjmedia_transport_info *info)
+{
+ if (tp && tp->op && tp->op->get_info)
+ return (*tp->op->get_info)(tp, info);
+
+ return PJ_ENOTSUP;
+}
+
+
+/**
+ * Attach callbacks to be called on receipt of incoming RTP/RTCP packets.
+ * This is just a simple wrapper which calls <tt>attach()</tt> member of
+ * the transport.
+ *
+ * @param tp The media transport.
+ * @param user_data Arbitrary user data to be set when the callbacks are
+ * called.
+ * @param rem_addr Remote RTP address to send RTP packet to.
+ * @param rem_rtcp Optional remote RTCP address. If the argument is NULL
+ * or if the address is zero, the RTCP address will be
+ * calculated from the RTP address (which is RTP port
+ * plus one).
+ * @param addr_len Length of the remote address.
+ * @param rtp_cb Callback to be called when RTP packet is received on
+ * the transport.
+ * @param rtcp_cb Callback to be called when RTCP packet is received on
+ * the transport.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_INLINE(pj_status_t) pjmedia_transport_attach(pjmedia_transport *tp,
+ void *user_data,
+ const pj_sockaddr_t *rem_addr,
+ const pj_sockaddr_t *rem_rtcp,
+ unsigned addr_len,
+ void (*rtp_cb)(void *user_data,
+ void *pkt,
+ pj_ssize_t),
+ void (*rtcp_cb)(void *usr_data,
+ void*pkt,
+ pj_ssize_t))
+{
+ return tp->op->attach(tp, user_data, rem_addr, rem_rtcp, addr_len,
+ rtp_cb, rtcp_cb);
+}
+
+
+/**
+ * Detach callbacks from the transport.
+ * This is just a simple wrapper which calls <tt>detach()</tt> member of
+ * the transport. After the transport is detached, it will ignore incoming
+ * RTP/RTCP packets, and will refuse to send outgoing RTP/RTCP packets.
+ * Application may re-attach the media transport to another transport user
+ * (e.g. stream) after the transport has been detached.
+ *
+ * @param tp The media transport.
+ * @param user_data User data which must match the previously set value
+ * on attachment.
+ */
+PJ_INLINE(void) pjmedia_transport_detach(pjmedia_transport *tp,
+ void *user_data)
+{
+ tp->op->detach(tp, user_data);
+}
+
+
+/**
+ * Send RTP packet with the specified media transport. This is just a simple
+ * wrapper which calls <tt>send_rtp()</tt> member of the transport. The
+ * RTP packet will be delivered to the destination address specified in
+ * #pjmedia_transport_attach() function.
+ *
+ * @param tp The media transport.
+ * @param pkt The packet to send.
+ * @param size Size of the packet.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_INLINE(pj_status_t) pjmedia_transport_send_rtp(pjmedia_transport *tp,
+ const void *pkt,
+ pj_size_t size)
+{
+ return (*tp->op->send_rtp)(tp, pkt, size);
+}
+
+
+/**
+ * Send RTCP packet with the specified media transport. This is just a simple
+ * wrapper which calls <tt>send_rtcp()</tt> member of the transport. The
+ * RTCP packet will be delivered to the destination address specified in
+ * #pjmedia_transport_attach() function.
+ *
+ * @param tp The media transport.
+ * @param pkt The packet to send.
+ * @param size Size of the packet.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_INLINE(pj_status_t) pjmedia_transport_send_rtcp(pjmedia_transport *tp,
+ const void *pkt,
+ pj_size_t size)
+{
+ return (*tp->op->send_rtcp)(tp, pkt, size);
+}
+
+
+/**
+ * Send RTCP packet with the specified media transport. This is just a simple
+ * wrapper which calls <tt>send_rtcp2()</tt> member of the transport. The
+ * RTCP packet will be delivered to the destination address specified in
+ * param addr, if addr is NULL, RTCP packet will be delivered to destination
+ * address specified in #pjmedia_transport_attach() function.
+ *
+ * @param tp The media transport.
+ * @param addr The destination address.
+ * @param addr_len Length of destination address.
+ * @param pkt The packet to send.
+ * @param size Size of the packet.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_INLINE(pj_status_t) pjmedia_transport_send_rtcp2(pjmedia_transport *tp,
+ const pj_sockaddr_t *addr,
+ unsigned addr_len,
+ const void *pkt,
+ pj_size_t size)
+{
+ return (*tp->op->send_rtcp2)(tp, addr, addr_len, pkt, size);
+}
+
+
+/**
+ * Prepare the media transport for a new media session, Application must
+ * call this function before starting a new media session using this
+ * transport.
+ *
+ * This is just a simple wrapper which calls <tt>media_create()</tt> member
+ * of the transport.
+ *
+ * @param tp The media transport.
+ * @param sdp_pool Pool object to allocate memory related to SDP
+ * messaging components.
+ * @param options Option flags, from #pjmedia_tranport_media_option
+ * @param rem_sdp Remote SDP if local SDP is an answer, otherwise
+ * specify NULL if SDP is an offer.
+ * @param media_index Media index in SDP.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_INLINE(pj_status_t) pjmedia_transport_media_create(pjmedia_transport *tp,
+ pj_pool_t *sdp_pool,
+ unsigned options,
+ const pjmedia_sdp_session *rem_sdp,
+ unsigned media_index)
+{
+ return (*tp->op->media_create)(tp, sdp_pool, options, rem_sdp,
+ media_index);
+}
+
+
+/**
+ * Put transport specific information into the SDP. This function can be
+ * called to put transport specific information in the initial or
+ * subsequent SDP offer or answer.
+ *
+ * This is just a simple wrapper which calls <tt>encode_sdp()</tt> member
+ * of the transport.
+ *
+ * @param tp The media transport.
+ * @param sdp_pool Pool object to allocate memory related to SDP
+ * messaging components.
+ * @param sdp The local SDP to be filled in information from the
+ * media transport.
+ * @param rem_sdp Remote SDP if local SDP is an answer, otherwise
+ * specify NULL if SDP is an offer.
+ * @param media_index Media index in SDP.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_INLINE(pj_status_t) pjmedia_transport_encode_sdp(pjmedia_transport *tp,
+ pj_pool_t *sdp_pool,
+ pjmedia_sdp_session *sdp,
+ const pjmedia_sdp_session *rem_sdp,
+ unsigned media_index)
+{
+ return (*tp->op->encode_sdp)(tp, sdp_pool, sdp, rem_sdp, media_index);
+}
+
+
+/**
+ * Start the transport session with the settings in both local and remote
+ * SDP. The actual work that is done by this function depends on the
+ * underlying transport type. For SRTP, this will activate the encryption
+ * and decryption based on the keys found the SDPs. For ICE, this will
+ * start ICE negotiation according to the information found in the SDPs.
+ *
+ * This is just a simple wrapper which calls <tt>media_start()</tt> member
+ * of the transport.
+ *
+ * @param tp The media transport.
+ * @param tmp_pool The memory pool for allocating temporary objects.
+ * @param sdp_local Local SDP.
+ * @param sdp_remote Remote SDP.
+ * @param media_index Media index in the SDP.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_INLINE(pj_status_t) pjmedia_transport_media_start(pjmedia_transport *tp,
+ pj_pool_t *tmp_pool,
+ const pjmedia_sdp_session *sdp_local,
+ const pjmedia_sdp_session *sdp_remote,
+ unsigned media_index)
+{
+ return (*tp->op->media_start)(tp, tmp_pool, sdp_local, sdp_remote,
+ media_index);
+}
+
+
+/**
+ * This API should be called when the session is stopped, to allow the media
+ * transport to release its resources used for the session.
+ *
+ * This is just a simple wrapper which calls <tt>media_stop()</tt> member
+ * of the transport.
+ *
+ * @param tp The media transport.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_INLINE(pj_status_t) pjmedia_transport_media_stop(pjmedia_transport *tp)
+{
+ return (*tp->op->media_stop)(tp);
+}
+
+/**
+ * Close media transport. This is just a simple wrapper which calls
+ * <tt>destroy()</tt> member of the transport. This function will free
+ * all resources created by this transport (such as sockets, memory, etc.).
+ *
+ * @param tp The media transport.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_INLINE(pj_status_t) pjmedia_transport_close(pjmedia_transport *tp)
+{
+ if (tp->op->destroy)
+ return (*tp->op->destroy)(tp);
+ else
+ return PJ_SUCCESS;
+}
+
+/**
+ * Simulate packet lost in the specified direction (for testing purposes).
+ * When enabled, the transport will randomly drop packets to the specified
+ * direction.
+ *
+ * @param tp The media transport.
+ * @param dir Media direction to which packets will be randomly dropped.
+ * @param pct_lost Percent lost (0-100). Set to zero to disable packet
+ * lost simulation.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_transport_simulate_lost(pjmedia_transport *tp,
+ pjmedia_dir dir,
+ unsigned pct_lost)
+{
+ return (*tp->op->simulate_lost)(tp, dir, pct_lost);
+}
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_TRANSPORT_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_adapter_sample.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_adapter_sample.h new file mode 100644 index 0000000..9847021 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_adapter_sample.h @@ -0,0 +1,73 @@ +/* $Id: transport_adapter_sample.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_TRANSPORT_ADAPTER_SAMPLE_H__
+#define __PJMEDIA_TRANSPORT_ADAPTER_SAMPLE_H__
+
+
+/**
+ * @file transport_adapter_sample.h
+ * @brief Sample Media Transport Adapter
+ */
+
+#include <pjmedia/transport.h>
+
+
+/**
+ * @defgroup PJMEDIA_TRANSPORT_ADAPTER_SAMPLE Sample Transport Adapter
+ * @ingroup PJMEDIA_TRANSPORT
+ * @brief Example on how to create transport adapter.
+ * @{
+ *
+ * This describes a sample implementation of transport adapter, similar to
+ * the way the SRTP transport adapter works.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Create the transport adapter, specifying the underlying transport to be
+ * used to send and receive RTP/RTCP packets.
+ *
+ * @param endpt The media endpoint.
+ * @param name Optional name to identify this media transport
+ * for logging purposes.
+ * @param transport The underlying media transport to send and receive
+ * RTP/RTCP packets.
+ * @param p_tp Pointer to receive the media transport instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_tp_adapter_create( pjmedia_endpt *endpt,
+ const char *name,
+ pjmedia_transport *transport,
+ pjmedia_transport **p_tp);
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_TRANSPORT_ADAPTER_SAMPLE_H__ */
+
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_ice.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_ice.h new file mode 100644 index 0000000..8c5d5d2 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_ice.h @@ -0,0 +1,194 @@ +/* $Id: transport_ice.h 2945 2009-10-14 13:13:18Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_TRANSPORT_ICE_H__
+#define __PJMEDIA_TRANSPORT_ICE_H__
+
+
+/**
+ * @file transport_ice.h
+ * @brief ICE capable media transport.
+ */
+
+#include <pjmedia/stream.h>
+#include <pjnath/ice_strans.h>
+
+
+/**
+ * @defgroup PJMEDIA_TRANSPORT_ICE ICE Media Transport
+ * @ingroup PJMEDIA_TRANSPORT
+ * @brief Interactive Connectivity Establishment (ICE) transport
+ * @{
+ *
+ * This describes the implementation of media transport using
+ * Interactive Connectivity Establishment (ICE) protocol.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Structure containing callbacks to receive ICE notifications.
+ */
+typedef struct pjmedia_ice_cb
+{
+ /**
+ * This callback will be called when ICE negotiation completes.
+ *
+ * @param tp PJMEDIA ICE transport.
+ * @param op The operation
+ * @param status Operation status.
+ */
+ void (*on_ice_complete)(pjmedia_transport *tp,
+ pj_ice_strans_op op,
+ pj_status_t status);
+
+} pjmedia_ice_cb;
+
+
+/**
+ * This structure specifies ICE transport specific info. This structure
+ * will be filled in media transport specific info.
+ */
+typedef struct pjmedia_ice_transport_info
+{
+ /**
+ * ICE sesion state.
+ */
+ pj_ice_strans_state sess_state;
+
+ /**
+ * Session role.
+ */
+ pj_ice_sess_role role;
+
+ /**
+ * Number of components in the component array. Before ICE negotiation
+ * is complete, the number represents the number of components of the
+ * local agent. After ICE negotiation has been completed successfully,
+ * the number represents the number of common components between local
+ * and remote agents.
+ */
+ unsigned comp_cnt;
+
+ /**
+ * Array of ICE components. Typically the first element denotes RTP and
+ * second element denotes RTCP.
+ */
+ struct
+ {
+ /**
+ * Local candidate type.
+ */
+ pj_ice_cand_type lcand_type;
+
+ /**
+ * Remote candidate type.
+ */
+ pj_ice_cand_type rcand_type;
+
+ } comp[2];
+
+} pjmedia_ice_transport_info;
+
+
+/**
+ * Options that can be specified when creating ICE transport.
+ */
+enum pjmedia_transport_ice_options
+{
+ /**
+ * Normally when remote doesn't use ICE, the ICE transport will
+ * continuously check the source address of incoming packets to see
+ * if it is different than the configured remote address, and switch
+ * the remote address to the source address of the packet if they
+ * are different after several packets are received.
+ * Specifying this option will disable this feature.
+ */
+ PJMEDIA_ICE_NO_SRC_ADDR_CHECKING = 1
+};
+
+
+/**
+ * Create the Interactive Connectivity Establishment (ICE) media transport
+ * using the specified configuration. When STUN or TURN (or both) is used,
+ * the creation operation will complete asynchronously, when STUN resolution
+ * and TURN allocation completes. When the initialization completes, the
+ * \a on_ice_complete() complete will be called with \a op parameter equal
+ * to PJ_ICE_STRANS_OP_INIT.
+ *
+ * In addition, this transport will also notify the application about the
+ * result of ICE negotiation, also in \a on_ice_complete() callback. In this
+ * case the callback will be called with \a op parameter equal to
+ * PJ_ICE_STRANS_OP_NEGOTIATION.
+ *
+ * Other than this, application should use the \ref PJMEDIA_TRANSPORT API
+ * to manipulate this media transport.
+ *
+ * @param endpt The media endpoint.
+ * @param name Optional name to identify this ICE media transport
+ * for logging purposes.
+ * @param comp_cnt Number of components to be created.
+ * @param cfg Pointer to configuration settings.
+ * @param cb Optional structure containing ICE specific callbacks.
+ * @param p_tp Pointer to receive the media transport instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_ice_create(pjmedia_endpt *endpt,
+ const char *name,
+ unsigned comp_cnt,
+ const pj_ice_strans_cfg *cfg,
+ const pjmedia_ice_cb *cb,
+ pjmedia_transport **p_tp);
+
+
+/**
+ * The same as @pjmedia_ice_create with additional \a options param.
+ *
+ * @param endpt The media endpoint.
+ * @param name Optional name to identify this ICE media transport
+ * for logging purposes.
+ * @param comp_cnt Number of components to be created.
+ * @param cfg Pointer to configuration settings.
+ * @param cb Optional structure containing ICE specific callbacks.
+ * @param options Options, see #pjmedia_transport_ice_options.
+ * @param p_tp Pointer to receive the media transport instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_ice_create2(pjmedia_endpt *endpt,
+ const char *name,
+ unsigned comp_cnt,
+ const pj_ice_strans_cfg *cfg,
+ const pjmedia_ice_cb *cb,
+ unsigned options,
+ pjmedia_transport **p_tp);
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_TRANSPORT_ICE_H__ */
+
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_loop.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_loop.h new file mode 100644 index 0000000..3d3fde4 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_loop.h @@ -0,0 +1,82 @@ +/* $Id: transport_loop.h 2845 2009-07-29 12:19:25Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_TRANSPORT_LOOP_H__
+#define __PJMEDIA_TRANSPORT_LOOP_H__
+
+
+/**
+ * @file transport_loop.h
+ * @brief Loopback transport
+ */
+
+#include <pjmedia/stream.h>
+
+
+/**
+ * @defgroup PJMEDIA_TRANSPORT_LOOP Loopback Media Transport
+ * @ingroup PJMEDIA_TRANSPORT
+ * @brief Loopback transport for testing.
+ * @{
+ *
+ * This is the loopback media transport, where packets sent to this transport
+ * will be sent back to the streams attached to this transport. Unlike the
+ * other PJMEDIA transports, the loop transport may be attached to multiple
+ * streams (in other words, application should specify the same loop transport
+ * instance when calling #pjmedia_stream_create()). Any RTP or RTCP packets
+ * sent by one stream to this transport by default will be sent back to all
+ * streams that are attached to this transport, including to the stream that
+ * sends the packet. Application may individually select which stream to
+ * receive packets by calling #pjmedia_transport_loop_disable_rx().
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Create the loopback transport.
+ *
+ * @param endpt The media endpoint instance.
+ * @param p_tp Pointer to receive the transport instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_transport_loop_create(pjmedia_endpt *endpt,
+ pjmedia_transport **p_tp);
+
+
+/**
+ * Set this stream as the receiver of incoming packets.
+ */
+PJ_DECL(pj_status_t) pjmedia_transport_loop_disable_rx(pjmedia_transport *tp,
+ void *user,
+ pj_bool_t disabled);
+
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_TRANSPORT_LOOP_H__ */
+
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_srtp.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_srtp.h new file mode 100644 index 0000000..8744f19 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_srtp.h @@ -0,0 +1,313 @@ +/* $Id: transport_srtp.h 2597 2009-04-14 15:18:30Z nanang $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_TRANSPORT_SRTP_H__
+#define __PJMEDIA_TRANSPORT_SRTP_H__
+
+/**
+ * @file transport_srtp.h
+ * @brief Secure RTP (SRTP) transport.
+ */
+
+#include <pjmedia/transport.h>
+
+
+/**
+ * @defgroup PJMEDIA_TRANSPORT_SRTP Secure RTP (SRTP) Media Transport
+ * @ingroup PJMEDIA_TRANSPORT
+ * @brief Media transport adapter to add SRTP feature to existing transports
+ * @{
+ *
+ * This module implements SRTP as described by RFC 3711, using RFC 4568 as
+ * key exchange method. It implements \ref PJMEDIA_TRANSPORT to integrate
+ * with the rest of PJMEDIA framework.
+ *
+ * As we know, media transport is separated from the stream object (which
+ * does the encoding/decoding of PCM frames, (de)packetization of RTP/RTCP
+ * packets, and de-jitter buffering). The connection between stream and media
+ * transport is established when the stream is created (we need to specify
+ * media transport during stream creation), and the interconnection can be
+ * depicted from the diagram below:
+ *
+ \image html media-transport.PNG
+
+ * I think the diagram above is self-explanatory.
+ *
+ * SRTP functionality is implemented as some kind of "adapter", which is
+ * plugged between the stream and the actual media transport that does
+ * sending/receiving RTP/RTCP packets. When SRTP is used, the interconnection
+ * between stream and transport is like the diagram below:
+ *
+ \image html media-srtp-transport.PNG
+
+ * So to stream, the SRTP transport behaves as if it is a media transport
+ * (because it is a media transport), and to the media transport it behaves
+ * as if it is a stream. The SRTP object then forwards RTP packets back and
+ * forth between stream and the actual transport, encrypting/decrypting
+ * the RTP/RTCP packets as necessary.
+ *
+ * The neat thing about this design is the SRTP "adapter" then can be used
+ * to encrypt any kind of media transports. We currently have UDP and ICE
+ * media transports that can benefit SRTP, and we could add SRTP to any
+ * media transports that will be added in the future.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Crypto option.
+ */
+typedef enum pjmedia_srtp_crypto_option
+{
+ /** When this flag is specified, encryption will be disabled. */
+ PJMEDIA_SRTP_NO_ENCRYPTION = 1,
+
+ /** When this flag is specified, authentication will be disabled. */
+ PJMEDIA_SRTP_NO_AUTHENTICATION = 2
+
+} pjmedia_srtp_crypto_option;
+
+
+/**
+ * This structure describes an individual crypto setting.
+ */
+typedef struct pjmedia_srtp_crypto
+{
+ /** Optional key. If empty, a random key will be autogenerated. */
+ pj_str_t key;
+
+ /** Crypto name. */
+ pj_str_t name;
+
+ /** Flags, bitmask from #pjmedia_srtp_crypto_option */
+ unsigned flags;
+
+} pjmedia_srtp_crypto;
+
+
+/**
+ * This enumeration specifies the behavior of the SRTP transport regarding
+ * media security offer and answer.
+ */
+typedef enum pjmedia_srtp_use
+{
+ /**
+ * When this flag is specified, SRTP will be disabled, and the transport
+ * will reject RTP/SAVP offer.
+ */
+ PJMEDIA_SRTP_DISABLED,
+
+ /**
+ * When this flag is specified, SRTP will be advertised as optional and
+ * incoming SRTP offer will be accepted.
+ */
+ PJMEDIA_SRTP_OPTIONAL,
+
+ /**
+ * When this flag is specified, the transport will require that RTP/SAVP
+ * media shall be used.
+ */
+ PJMEDIA_SRTP_MANDATORY
+
+} pjmedia_srtp_use;
+
+
+/**
+ * Settings to be given when creating SRTP transport. Application should call
+ * #pjmedia_srtp_setting_default() to initialize this structure with its
+ * default values.
+ */
+typedef struct pjmedia_srtp_setting
+{
+ /**
+ * Specify the usage policy. Default is PJMEDIA_SRTP_OPTIONAL.
+ */
+ pjmedia_srtp_use use;
+
+ /**
+ * Specify whether the SRTP transport should close the member transport
+ * when it is destroyed. Default: PJ_TRUE.
+ */
+ pj_bool_t close_member_tp;
+
+ /**
+ * Specify the number of crypto suite settings.
+ */
+ unsigned crypto_count;
+
+ /**
+ * Specify individual crypto suite setting.
+ */
+ pjmedia_srtp_crypto crypto[8];
+
+} pjmedia_srtp_setting;
+
+
+/**
+ * This structure specifies SRTP transport specific info. This will fit
+ * into \a buffer field of pjmedia_transport_specific_info.
+ */
+typedef struct pjmedia_srtp_info
+{
+ /**
+ * Specify whether the SRTP transport is active for SRTP session.
+ */
+ pj_bool_t active;
+
+ /**
+ * Specify the policy used by the SRTP session for receive direction.
+ */
+ pjmedia_srtp_crypto rx_policy;
+
+ /**
+ * Specify the policy used by the SRTP session for transmit direction.
+ */
+ pjmedia_srtp_crypto tx_policy;
+
+ /**
+ * Specify the usage policy.
+ */
+ pjmedia_srtp_use use;
+
+ /**
+ * Specify the peer's usage policy.
+ */
+ pjmedia_srtp_use peer_use;
+
+} pjmedia_srtp_info;
+
+
+/**
+ * Initialize SRTP library. This function should be called before
+ * any SRTP functions, however calling #pjmedia_transport_srtp_create()
+ * will also invoke this function. This function will also register SRTP
+ * library deinitialization to #pj_atexit(), so the deinitialization
+ * of SRTP library will be performed automatically by PJLIB destructor.
+ */
+PJ_DECL(pj_status_t) pjmedia_srtp_init_lib(void);
+
+
+/**
+ * Initialize SRTP setting with its default values.
+ *
+ * @param opt SRTP setting to be initialized.
+ */
+PJ_DECL(void) pjmedia_srtp_setting_default(pjmedia_srtp_setting *opt);
+
+
+/**
+ * Create an SRTP media transport.
+ *
+ * @param endpt The media endpoint instance.
+ * @param tp The actual media transport to send and receive
+ * RTP/RTCP packets. This media transport will be
+ * kept as member transport of this SRTP instance.
+ * @param opt Optional settings. If NULL is given, default
+ * settings will be used.
+ * @param p_tp Pointer to receive the transport SRTP instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_transport_srtp_create(
+ pjmedia_endpt *endpt,
+ pjmedia_transport *tp,
+ const pjmedia_srtp_setting *opt,
+ pjmedia_transport **p_tp);
+
+
+/**
+ * Manually start SRTP session with the given parameters. Application only
+ * needs to call this function when the SRTP transport is used without SDP
+ * offer/answer. When SDP offer/answer framework is used, the SRTP transport
+ * will be started/stopped by #pjmedia_transport_media_start() and
+ * #pjmedia_transport_media_stop() respectively.
+ *
+ * Please note that even if an RTP stream is only one direction, application
+ * will still need to provide both crypto suites, because it is needed by
+ * RTCP.
+
+ * If application specifies the crypto keys, the keys for transmit and receive
+ * direction MUST be different.
+ *
+ * @param srtp The SRTP transport.
+ * @param tx Crypto suite setting for transmit direction.
+ * @param rx Crypto suite setting for receive direction.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_transport_srtp_start(
+ pjmedia_transport *srtp,
+ const pjmedia_srtp_crypto *tx,
+ const pjmedia_srtp_crypto *rx);
+
+/**
+ * Stop SRTP session.
+ *
+ * @param srtp The SRTP media transport.
+ *
+ * @return PJ_SUCCESS on success.
+ *
+ * @see #pjmedia_transport_srtp_start()
+ */
+PJ_DECL(pj_status_t) pjmedia_transport_srtp_stop(pjmedia_transport *srtp);
+
+
+/**
+ * This is a utility function to decrypt SRTP packet using SRTP transport.
+ * This function is not part of SRTP transport's API, but it can be used
+ * to decrypt SRTP packets from non-network (for example, from a saved file)
+ * without having to use the transport framework. See pcaputil.c in the
+ * samples collection on how to use this function.
+ *
+ * @param tp The SRTP transport.
+ * @param is_rtp Set to non-zero if the packet is SRTP, otherwise set
+ * to zero if the packet is SRTCP.
+ * @param pkt On input, it contains SRTP or SRTCP packet. On
+ * output, it contains the decrypted RTP/RTCP packet.
+ * @param pkt_len On input, specify the length of the buffer. On
+ * output, it will be filled with the actual length
+ * of decrypted packet.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_transport_srtp_decrypt_pkt(pjmedia_transport *tp,
+ pj_bool_t is_rtp,
+ void *pkt,
+ int *pkt_len);
+
+
+/**
+ * Query member transport of SRTP.
+ *
+ * @param srtp The SRTP media transport.
+ *
+ * @return member media transport.
+ */
+PJ_DECL(pjmedia_transport*) pjmedia_transport_srtp_get_member(
+ pjmedia_transport *srtp);
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_TRANSPORT_SRTP_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_udp.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_udp.h new file mode 100644 index 0000000..0c30c7d --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/transport_udp.h @@ -0,0 +1,162 @@ +/* $Id: transport_udp.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_TRANSPORT_UDP_H__
+#define __PJMEDIA_TRANSPORT_UDP_H__
+
+
+/**
+ * @file transport_udp.h
+ * @brief Stream transport with UDP.
+ */
+
+#include <pjmedia/stream.h>
+
+
+/**
+ * @defgroup PJMEDIA_TRANSPORT_UDP UDP Media Transport
+ * @ingroup PJMEDIA_TRANSPORT
+ * @brief Implementation of media transport with UDP sockets.
+ * @{
+ *
+ * The UDP media transport is the standard based media transport
+ * as described by RFC 3550/3551. It can be used to facilitate RTP/RTCP
+ * unicast or multicast communication.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Options that can be specified when creating UDP transport.
+ */
+enum pjmedia_transport_udp_options
+{
+ /**
+ * Normally the UDP transport will continuously check the source address
+ * of incoming packets to see if it is different than the configured
+ * remote address, and switch the remote address to the source address
+ * of the packet if they are different after several packets are
+ * received.
+ * Specifying this option will disable this feature.
+ */
+ PJMEDIA_UDP_NO_SRC_ADDR_CHECKING = 1
+};
+
+
+/**
+ * Create an RTP and RTCP sockets and bind the sockets to the specified
+ * port to create media transport.
+ *
+ * @param endpt The media endpoint instance.
+ * @param name Optional name to be assigned to the transport.
+ * @param port UDP port number for the RTP socket. The RTCP port number
+ * will be set to one above RTP port.
+ * @param options Options, bitmask of #pjmedia_transport_udp_options.
+ * @param p_tp Pointer to receive the transport instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_transport_udp_create(pjmedia_endpt *endpt,
+ const char *name,
+ int port,
+ unsigned options,
+ pjmedia_transport **p_tp);
+
+
+/**
+ * Create an RTP and RTCP sockets and bind the sockets to the specified
+ * address and port to create media transport.
+ *
+ * @param endpt The media endpoint instance.
+ * @param name Optional name to be assigned to the transport.
+ * @param addr Optional local address to bind the sockets to. If this
+ * argument is NULL or empty, the sockets will be bound
+ * to all interface.
+ * @param port UDP port number for the RTP socket. The RTCP port number
+ * will be set to one above RTP port.
+ * @param options Options, bitmask of #pjmedia_transport_udp_options.
+ * @param p_tp Pointer to receive the transport instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_transport_udp_create2(pjmedia_endpt *endpt,
+ const char *name,
+ const pj_str_t *addr,
+ int port,
+ unsigned options,
+ pjmedia_transport **p_tp);
+
+/**
+ * Another variant of #pjmedia_transport_udp_create() which allows
+ * the creation of IPv6 transport.
+ *
+ * @param endpt The media endpoint instance.
+ * @param af Address family, which can be pj_AF_INET() for IPv4 or
+ * pj_AF_INET6() for IPv6.
+ * @param name Optional name to be assigned to the transport.
+ * @param addr Optional local address to bind the sockets to. If this
+ * argument is NULL or empty, the sockets will be bound
+ * to all interface.
+ * @param port UDP port number for the RTP socket. The RTCP port number
+ * will be set to one above RTP port.
+ * @param options Options, bitmask of #pjmedia_transport_udp_options.
+ * @param p_tp Pointer to receive the transport instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_transport_udp_create3(pjmedia_endpt *endpt,
+ int af,
+ const char *name,
+ const pj_str_t *addr,
+ int port,
+ unsigned options,
+ pjmedia_transport **p_tp);
+
+
+/**
+ * Create UDP stream transport from existing sockets. Use this function when
+ * the sockets have previously been created.
+ *
+ * @param endpt The media endpoint instance.
+ * @param name Optional name to be assigned to the transport.
+ * @param si Media socket info containing the RTP and RTCP sockets.
+ * @param options Options, bitmask of #pjmedia_transport_udp_options.
+ * @param p_tp Pointer to receive the transport instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_transport_udp_attach(pjmedia_endpt *endpt,
+ const char *name,
+ const pjmedia_sock_info *si,
+ unsigned options,
+ pjmedia_transport **p_tp);
+
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_TRANSPORT_UDP_H__ */
+
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/types.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/types.h new file mode 100644 index 0000000..faaee2b --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/types.h @@ -0,0 +1,533 @@ +/* $Id: types.h 2506 2009-03-12 18:11:37Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_TYPES_H__
+#define __PJMEDIA_TYPES_H__
+
+/**
+ * @file pjmedia/types.h Basic Types
+ * @brief Basic PJMEDIA types.
+ */
+
+#include <pjmedia/config.h>
+#include <pj/sock.h> /* pjmedia_sock_info */
+#include <pj/string.h> /* pj_memcpy(), pj_memset() */
+
+/**
+ * @defgroup PJMEDIA_PORT Media Ports Framework
+ * @brief Extensible framework for media terminations
+ */
+
+
+/**
+ * @defgroup PJMEDIA_FRAME_OP Audio Manipulation Algorithms
+ * @brief Algorithms to manipulate audio frames
+ */
+
+/**
+ * @defgroup PJMEDIA_TYPES Basic Types
+ * @ingroup PJMEDIA_BASE
+ * @brief Basic PJMEDIA types and operations.
+ * @{
+ */
+
+/**
+ * Top most media type.
+ */
+typedef enum pjmedia_type
+{
+ /** No type. */
+ PJMEDIA_TYPE_NONE = 0,
+
+ /** The media is audio */
+ PJMEDIA_TYPE_AUDIO = 1,
+
+ /** The media is video. */
+ PJMEDIA_TYPE_VIDEO = 2,
+
+ /** Unknown media type, in this case the name will be specified in
+ * encoding_name.
+ */
+ PJMEDIA_TYPE_UNKNOWN = 3,
+
+ /** The media is application. */
+ PJMEDIA_TYPE_APPLICATION = 4
+
+} pjmedia_type;
+
+
+/**
+ * Media transport protocol.
+ */
+typedef enum pjmedia_tp_proto
+{
+ /** No transport type */
+ PJMEDIA_TP_PROTO_NONE = 0,
+
+ /** RTP using A/V profile */
+ PJMEDIA_TP_PROTO_RTP_AVP,
+
+ /** Secure RTP */
+ PJMEDIA_TP_PROTO_RTP_SAVP,
+
+ /** Unknown */
+ PJMEDIA_TP_PROTO_UNKNOWN
+
+} pjmedia_tp_proto;
+
+
+/**
+ * Media direction.
+ */
+typedef enum pjmedia_dir
+{
+ /** None */
+ PJMEDIA_DIR_NONE = 0,
+
+ /** Encoding (outgoing to network) stream */
+ PJMEDIA_DIR_ENCODING = 1,
+
+ /** Decoding (incoming from network) stream. */
+ PJMEDIA_DIR_DECODING = 2,
+
+ /** Incoming and outgoing stream. */
+ PJMEDIA_DIR_ENCODING_DECODING = 3
+
+} pjmedia_dir;
+
+
+
+/* Alternate names for media direction: */
+
+/**
+ * Direction is capturing audio frames.
+ */
+#define PJMEDIA_DIR_CAPTURE PJMEDIA_DIR_ENCODING
+
+/**
+ * Direction is playback of audio frames.
+ */
+#define PJMEDIA_DIR_PLAYBACK PJMEDIA_DIR_DECODING
+
+/**
+ * Direction is both capture and playback.
+ */
+#define PJMEDIA_DIR_CAPTURE_PLAYBACK PJMEDIA_DIR_ENCODING_DECODING
+
+
+/**
+ * Create 32bit port signature from ASCII characters.
+ */
+#define PJMEDIA_PORT_SIGNATURE(a,b,c,d) \
+ (a<<24 | b<<16 | c<<8 | d)
+
+
+/**
+ * Opaque declaration of media endpoint.
+ */
+typedef struct pjmedia_endpt pjmedia_endpt;
+
+
+/*
+ * Forward declaration for stream (needed by transport).
+ */
+typedef struct pjmedia_stream pjmedia_stream;
+
+
+/**
+ * Media socket info is used to describe the underlying sockets
+ * to be used as media transport.
+ */
+typedef struct pjmedia_sock_info
+{
+ /** The RTP socket handle */
+ pj_sock_t rtp_sock;
+
+ /** Address to be advertised as the local address for the RTP
+ * socket, which does not need to be equal as the bound
+ * address (for example, this address can be the address resolved
+ * with STUN).
+ */
+ pj_sockaddr rtp_addr_name;
+
+ /** The RTCP socket handle. */
+ pj_sock_t rtcp_sock;
+
+ /** Address to be advertised as the local address for the RTCP
+ * socket, which does not need to be equal as the bound
+ * address (for example, this address can be the address resolved
+ * with STUN).
+ */
+ pj_sockaddr rtcp_addr_name;
+
+} pjmedia_sock_info;
+
+
+/**
+ * Macro for packing format.
+ */
+#define PJMEDIA_FORMAT_PACK(C1, C2, C3, C4) ( C4<<24 | C3<<16 | C2<<8 | C1 )
+
+/**
+ * This enumeration describes format ID.
+ */
+typedef enum pjmedia_format_id
+{
+ /**
+ * 16bit linear
+ */
+ PJMEDIA_FORMAT_L16 = 0,
+
+ /**
+ * Alias for PJMEDIA_FORMAT_L16
+ */
+ PJMEDIA_FORMAT_PCM = PJMEDIA_FORMAT_L16,
+
+ /**
+ * G.711 ALAW
+ */
+ PJMEDIA_FORMAT_PCMA = PJMEDIA_FORMAT_PACK('A', 'L', 'A', 'W'),
+
+ /**
+ * Alias for PJMEDIA_FORMAT_PCMA
+ */
+ PJMEDIA_FORMAT_ALAW = PJMEDIA_FORMAT_PCMA,
+
+ /**
+ * G.711 ULAW
+ */
+ PJMEDIA_FORMAT_PCMU = PJMEDIA_FORMAT_PACK('u', 'L', 'A', 'W'),
+
+ /**
+ * Aliaw for PJMEDIA_FORMAT_PCMU
+ */
+ PJMEDIA_FORMAT_ULAW = PJMEDIA_FORMAT_PCMU,
+
+ /**
+ * AMR narrowband
+ */
+ PJMEDIA_FORMAT_AMR = PJMEDIA_FORMAT_PACK(' ', 'A', 'M', 'R'),
+
+ /**
+ * ITU G.729
+ */
+ PJMEDIA_FORMAT_G729 = PJMEDIA_FORMAT_PACK('G', '7', '2', '9'),
+
+ /**
+ * Internet Low Bit-Rate Codec (ILBC)
+ */
+ PJMEDIA_FORMAT_ILBC = PJMEDIA_FORMAT_PACK('I', 'L', 'B', 'C')
+
+} pjmedia_format_id;
+
+
+/**
+ * Media format information.
+ */
+typedef struct pjmedia_format
+{
+ /** Format ID */
+ pjmedia_format_id id;
+
+ /** Bitrate. */
+ pj_uint32_t bitrate;
+
+ /** Flag to indicate whether VAD is enabled */
+ pj_bool_t vad;
+
+} pjmedia_format;
+
+
+
+/**
+ * This is a general purpose function set PCM samples to zero.
+ * Since this function is needed by many parts of the library,
+ * by putting this functionality in one place, it enables some.
+ * clever people to optimize this function.
+ *
+ * @param samples The 16bit PCM samples.
+ * @param count Number of samples.
+ */
+PJ_INLINE(void) pjmedia_zero_samples(pj_int16_t *samples, unsigned count)
+{
+#if 1
+ pj_bzero(samples, (count<<1));
+#elif 0
+ unsigned i;
+ for (i=0; i<count; ++i) samples[i] = 0;
+#else
+ unsigned i;
+ count >>= 1;
+ for (i=0; i<count; ++i) ((pj_int32_t*)samples)[i] = (pj_int32_t)0;
+#endif
+}
+
+
+/**
+ * This is a general purpose function to copy samples from/to buffers with
+ * equal size. Since this function is needed by many parts of the library,
+ * by putting this functionality in one place, it enables some.
+ * clever people to optimize this function.
+ */
+PJ_INLINE(void) pjmedia_copy_samples(pj_int16_t *dst, const pj_int16_t *src,
+ unsigned count)
+{
+#if 1
+ pj_memcpy(dst, src, (count<<1));
+#elif 0
+ unsigned i;
+ for (i=0; i<count; ++i) dst[i] = src[i];
+#else
+ unsigned i;
+ count >>= 1;
+ for (i=0; i<count; ++i)
+ ((pj_int32_t*)dst)[i] = ((pj_int32_t*)src)[i];
+#endif
+}
+
+
+/**
+ * This is a general purpose function to copy samples from/to buffers with
+ * equal size. Since this function is needed by many parts of the library,
+ * by putting this functionality in one place, it enables some.
+ * clever people to optimize this function.
+ */
+PJ_INLINE(void) pjmedia_move_samples(pj_int16_t *dst, const pj_int16_t *src,
+ unsigned count)
+{
+#if 1
+ pj_memmove(dst, src, (count<<1));
+#elif 0
+ unsigned i;
+ for (i=0; i<count; ++i) dst[i] = src[i];
+#else
+ unsigned i;
+ count >>= 1;
+ for (i=0; i<count; ++i)
+ ((pj_int32_t*)dst)[i] = ((pj_int32_t*)src)[i];
+#endif
+}
+
+/**
+ * Types of media frame.
+ */
+typedef enum pjmedia_frame_type
+{
+ PJMEDIA_FRAME_TYPE_NONE, /**< No frame. */
+ PJMEDIA_FRAME_TYPE_AUDIO, /**< Normal audio frame. */
+ PJMEDIA_FRAME_TYPE_EXTENDED /**< Extended audio frame. */
+
+} pjmedia_frame_type;
+
+
+/**
+ * This structure describes a media frame.
+ */
+typedef struct pjmedia_frame
+{
+ pjmedia_frame_type type; /**< Frame type. */
+ void *buf; /**< Pointer to buffer. */
+ pj_size_t size; /**< Frame size in bytes. */
+ pj_timestamp timestamp; /**< Frame timestamp. */
+ pj_uint32_t bit_info; /**< Bit info of the frame, sample case:
+ a frame may not exactly start and end
+ at the octet boundary, so this field
+ may be used for specifying start &
+ end bit offset. */
+} pjmedia_frame;
+
+
+/**
+ * The pjmedia_frame_ext is used to carry a more complex audio frames than
+ * the typical PCM audio frames, and it is signaled by setting the "type"
+ * field of a pjmedia_frame to PJMEDIA_FRAME_TYPE_EXTENDED. With this set,
+ * application may typecast pjmedia_frame to pjmedia_frame_ext.
+ *
+ * This structure may contain more than one audio frames, which subsequently
+ * will be called subframes in this structure. The subframes section
+ * immediately follows the end of this structure, and each subframe is
+ * represented by pjmedia_frame_ext_subframe structure. Every next
+ * subframe immediately follows the previous subframe, and all subframes
+ * are byte-aligned although its payload may not be byte-aligned.
+ */
+
+#pragma pack(1)
+typedef struct pjmedia_frame_ext {
+ pjmedia_frame base; /**< Base frame info */
+ pj_uint16_t samples_cnt; /**< Number of samples in this frame */
+ pj_uint16_t subframe_cnt; /**< Number of (sub)frames in this frame */
+
+ /* Zero or more (sub)frames follows immediately after this,
+ * each will be represented by pjmedia_frame_ext_subframe
+ */
+} pjmedia_frame_ext;
+#pragma pack()
+
+/**
+ * This structure represents the individual subframes in the
+ * pjmedia_frame_ext structure.
+ */
+#pragma pack(1)
+typedef struct pjmedia_frame_ext_subframe {
+ pj_uint16_t bitlen; /**< Number of bits in the data */
+ pj_uint8_t data[1]; /**< Start of encoded data */
+} pjmedia_frame_ext_subframe;
+
+#pragma pack()
+
+
+/**
+ * Append one subframe to #pjmedia_frame_ext.
+ *
+ * @param frm The #pjmedia_frame_ext.
+ * @param src Subframe data.
+ * @param bitlen Lenght of subframe, in bits.
+ * @param samples_cnt Number of audio samples in subframe.
+ */
+PJ_INLINE(void) pjmedia_frame_ext_append_subframe(pjmedia_frame_ext *frm,
+ const void *src,
+ unsigned bitlen,
+ unsigned samples_cnt)
+{
+ pjmedia_frame_ext_subframe *fsub;
+ pj_uint8_t *p;
+ unsigned i;
+
+ p = (pj_uint8_t*)frm + sizeof(pjmedia_frame_ext);
+ for (i = 0; i < frm->subframe_cnt; ++i) {
+ fsub = (pjmedia_frame_ext_subframe*) p;
+ p += sizeof(fsub->bitlen) + ((fsub->bitlen+7) >> 3);
+ }
+
+ fsub = (pjmedia_frame_ext_subframe*) p;
+ fsub->bitlen = (pj_uint16_t)bitlen;
+ if (bitlen)
+ pj_memcpy(fsub->data, src, (bitlen+7) >> 3);
+
+ frm->subframe_cnt++;
+ frm->samples_cnt = (pj_uint16_t)(frm->samples_cnt + samples_cnt);
+}
+
+/**
+ * Get a subframe from #pjmedia_frame_ext.
+ *
+ * @param frm The #pjmedia_frame_ext.
+ * @param n Subframe index, zero based.
+ *
+ * @return The n-th subframe, or NULL if n is out-of-range.
+ */
+PJ_INLINE(pjmedia_frame_ext_subframe*)
+pjmedia_frame_ext_get_subframe(const pjmedia_frame_ext *frm, unsigned n)
+{
+ pjmedia_frame_ext_subframe *sf = NULL;
+
+ if (n < frm->subframe_cnt) {
+ pj_uint8_t *p;
+ unsigned i;
+
+ p = (pj_uint8_t*)frm + sizeof(pjmedia_frame_ext);
+ for (i = 0; i < n; ++i) {
+ sf = (pjmedia_frame_ext_subframe*) p;
+ p += sizeof(sf->bitlen) + ((sf->bitlen+7) >> 3);
+ }
+
+ sf = (pjmedia_frame_ext_subframe*) p;
+ }
+
+ return sf;
+}
+
+/**
+ * Extract all frame payload to the specified buffer.
+ *
+ * @param frm The frame.
+ * @param dst Destination buffer.
+ * @param maxsize Maximum size to copy (i.e. the size of the
+ * destination buffer).
+ *
+ * @return Total size of payload copied.
+ */
+PJ_INLINE(unsigned)
+pjmedia_frame_ext_copy_payload(const pjmedia_frame_ext *frm,
+ void *dst,
+ unsigned maxlen)
+{
+ unsigned i, copied=0;
+ for (i=0; i<frm->subframe_cnt; ++i) {
+ pjmedia_frame_ext_subframe *sf;
+ unsigned sz;
+
+ sf = pjmedia_frame_ext_get_subframe(frm, i);
+ if (!sf)
+ continue;
+
+ sz = ((sf->bitlen + 7) >> 3);
+ if (sz + copied > maxlen)
+ break;
+
+ pj_memcpy(((pj_uint8_t*)dst) + copied, sf->data, sz);
+ copied += sz;
+ }
+ return copied;
+}
+
+
+/**
+ * Pop out first n subframes from #pjmedia_frame_ext.
+ *
+ * @param frm The #pjmedia_frame_ext.
+ * @param n Number of first subframes to be popped out.
+ *
+ * @return PJ_SUCCESS when successful.
+ */
+PJ_INLINE(pj_status_t)
+pjmedia_frame_ext_pop_subframes(pjmedia_frame_ext *frm, unsigned n)
+{
+ pjmedia_frame_ext_subframe *sf;
+ pj_uint8_t *move_src;
+ unsigned move_len;
+
+ if (frm->subframe_cnt <= n) {
+ frm->subframe_cnt = 0;
+ frm->samples_cnt = 0;
+ return PJ_SUCCESS;
+ }
+
+ move_src = (pj_uint8_t*)pjmedia_frame_ext_get_subframe(frm, n);
+ sf = pjmedia_frame_ext_get_subframe(frm, frm->subframe_cnt-1);
+ move_len = (pj_uint8_t*)sf - move_src + sizeof(sf->bitlen) +
+ ((sf->bitlen+7) >> 3);
+ pj_memmove((pj_uint8_t*)frm+sizeof(pjmedia_frame_ext),
+ move_src, move_len);
+
+ frm->samples_cnt = (pj_uint16_t)
+ (frm->samples_cnt - n*frm->samples_cnt/frm->subframe_cnt);
+ frm->subframe_cnt = (pj_uint16_t) (frm->subframe_cnt - n);
+
+ return PJ_SUCCESS;
+}
+
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_TYPES_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/wav_playlist.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/wav_playlist.h new file mode 100644 index 0000000..63b5c62 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/wav_playlist.h @@ -0,0 +1,105 @@ +/* $Id: wav_playlist.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_WAV_PLAYLIST_H__
+#define __PJMEDIA_WAV_PLAYLIST_H__
+
+/**
+ * @file wav_playlist.h
+ * @brief WAV file playlist.
+ */
+#include <pjmedia/wav_port.h>
+
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * @defgroup PJMEDIA_WAV_PLAYLIST WAV File Play List
+ * @ingroup PJMEDIA_PORT
+ * @brief Audio playback of multiple WAV files
+ * @{
+ *
+ * The WAV play list port enables application to play back multiple
+ * WAV files in a playlist.
+ */
+
+/**
+ * Create a WAV playlist from the array of WAV file names. The WAV
+ * files must have the same clock rate, number of channels, and bits
+ * per sample, or otherwise this function will return error.
+ *
+ * @param pool Pool to create memory buffers for this port.
+ * @param port_label Optional label to set as the port name.
+ * @param file_list Array of WAV file names.
+ * @param file_count Number of files in the array.
+ * @param ptime The duration (in miliseconds) of each frame read
+ * from this port. If the value is zero, the default
+ * duration (20ms) will be used.
+ * @param options Optional options. Application may specify
+ * PJMEDIA_FILE_NO_LOOP to prevent play back loop.
+ * @param buff_size Buffer size to be allocated. If the value is zero or
+ * negative, the port will use default buffer size (which
+ * is about 4KB).
+ * @param p_port Pointer to receive the file port instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_wav_playlist_create(pj_pool_t *pool,
+ const pj_str_t *port_label,
+ const pj_str_t file_list[],
+ int file_count,
+ unsigned ptime,
+ unsigned options,
+ pj_ssize_t buff_size,
+ pjmedia_port **p_port);
+
+
+/**
+ * Register a callback to be called when the file reading has reached the
+ * end of file of the last file. If the file is set to play repeatedly,
+ * then the callback will be called multiple times. Note that only one
+ * callback can be registered for each file port.
+ *
+ * @param port The WAV play list port.
+ * @param user_data User data to be specified in the callback
+ * @param cb Callback to be called. If the callback returns non-
+ * PJ_SUCCESS, the playback will stop. Note that if
+ * application destroys the file port in the callback,
+ * it must return non-PJ_SUCCESS here.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_wav_playlist_set_eof_cb(pjmedia_port *port,
+ void *user_data,
+ pj_status_t (*cb)(pjmedia_port *port,
+ void *usr_data));
+
+
+/**
+ * @}
+ */
+
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_WAV_PLAYLIST_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/wav_port.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/wav_port.h new file mode 100644 index 0000000..e3cd922 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/wav_port.h @@ -0,0 +1,250 @@ +/* $Id: wav_port.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_WAV_PORT_H__
+#define __PJMEDIA_WAV_PORT_H__
+
+/**
+ * @file wav_port.h
+ * @brief WAV file player and writer.
+ */
+#include <pjmedia/port.h>
+
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * @defgroup PJMEDIA_FILE_PLAY WAV File Player
+ * @ingroup PJMEDIA_PORT
+ * @brief Audio playback from WAV file
+ * @{
+ */
+
+/**
+ * WAV file player options.
+ */
+enum pjmedia_file_player_option
+{
+ /**
+ * Tell the file player to return NULL frame when the whole
+ * file has been played.
+ */
+ PJMEDIA_FILE_NO_LOOP = 1
+};
+
+
+/**
+ * Create a media port to play streams from a WAV file. WAV player port
+ * supports for reading WAV file with uncompressed 16 bit PCM format or
+ * compressed G.711 A-law/U-law format.
+ *
+ * @param pool Pool to create memory buffers for this port.
+ * @param filename File name to open.
+ * @param ptime The duration (in miliseconds) of each frame read
+ * from this port. If the value is zero, the default
+ * duration (20ms) will be used.
+ * @param flags Port creation flags.
+ * @param buff_size Buffer size to be allocated. If the value is zero or
+ * negative, the port will use default buffer size (which
+ * is about 4KB).
+ * @param p_port Pointer to receive the file port instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_wav_player_port_create( pj_pool_t *pool,
+ const char *filename,
+ unsigned ptime,
+ unsigned flags,
+ pj_ssize_t buff_size,
+ pjmedia_port **p_port );
+
+
+/**
+ * Get the data length, in bytes.
+ *
+ * @param port The file player port.
+ *
+ * @return The length of the data, in bytes. Upon error it will
+ * return negative value.
+ */
+PJ_DECL(pj_ssize_t) pjmedia_wav_player_get_len(pjmedia_port *port);
+
+
+/**
+ * Set the file play position of WAV player.
+ *
+ * @param port The file player port.
+ * @param offset Playback position in bytes, relative to the start of
+ * the payload.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_wav_player_port_set_pos( pjmedia_port *port,
+ pj_uint32_t offset );
+
+
+/**
+ * Get the file play position of WAV player.
+ *
+ * @param port The file player port.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_ssize_t) pjmedia_wav_player_port_get_pos( pjmedia_port *port );
+
+
+/**
+ * Register a callback to be called when the file reading has reached the
+ * end of file. If the file is set to play repeatedly, then the callback
+ * will be called multiple times. Note that only one callback can be
+ * registered for each file port.
+ *
+ * @param port The file player port.
+ * @param user_data User data to be specified in the callback
+ * @param cb Callback to be called. If the callback returns non-
+ * PJ_SUCCESS, the playback will stop. Note that if
+ * application destroys the file port in the callback,
+ * it must return non-PJ_SUCCESS here.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_wav_player_set_eof_cb( pjmedia_port *port,
+ void *user_data,
+ pj_status_t (*cb)(pjmedia_port *port,
+ void *usr_data));
+
+/**
+ * @}
+ */
+
+
+/**
+ * @defgroup PJMEDIA_FILE_REC File Writer (Recorder)
+ * @ingroup PJMEDIA_PORT
+ * @brief Audio capture/recording to WAV file
+ * @{
+ */
+
+
+/**
+ * WAV file writer options.
+ */
+enum pjmedia_file_writer_option
+{
+ /**
+ * Tell the file writer to save the audio in PCM format.
+ */
+ PJMEDIA_FILE_WRITE_PCM = 0,
+
+ /**
+ * Tell the file writer to save the audio in G711 Alaw format.
+ */
+ PJMEDIA_FILE_WRITE_ALAW = 1,
+
+ /**
+ * Tell the file writer to save the audio in G711 Alaw format.
+ */
+ PJMEDIA_FILE_WRITE_ULAW = 2,
+};
+
+
+/**
+ * Create a media port to record streams to a WAV file. Note that the port
+ * must be closed properly (with #pjmedia_port_destroy()) so that the WAV
+ * header can be filled with correct values (such as the file length).
+ * WAV writer port supports for writing audio in uncompressed 16 bit PCM format
+ * or compressed G.711 U-law/A-law format, this needs to be specified in
+ * \a flags param.
+ *
+ * @param pool Pool to create memory buffers for this port.
+ * @param filename File name.
+ * @param clock_rate The sampling rate.
+ * @param channel_count Number of channels.
+ * @param samples_per_frame Number of samples per frame.
+ * @param bits_per_sample Number of bits per sample (eg 16).
+ * @param flags Port creation flags, see
+ * #pjmedia_file_writer_option.
+ * @param buff_size Buffer size to be allocated. If the value is
+ * zero or negative, the port will use default buffer
+ * size (which is about 4KB).
+ * @param p_port Pointer to receive the file port instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_wav_writer_port_create(pj_pool_t *pool,
+ const char *filename,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned bits_per_sample,
+ unsigned flags,
+ pj_ssize_t buff_size,
+ pjmedia_port **p_port );
+
+
+/**
+ * Get current writing position. Note that this does not necessarily match
+ * the size written to the file, since the WAV writer employs some internal
+ * buffering. Also the value reported here only indicates the payload size
+ * (it does not include the size of the WAV header),
+ *
+ * @param port The file writer port.
+ *
+ * @return Positive value to indicate the position (in bytes),
+ * or negative value containing the error code.
+ */
+PJ_DECL(pj_ssize_t) pjmedia_wav_writer_port_get_pos( pjmedia_port *port );
+
+
+/**
+ * Register the callback to be called when the file writing has reached
+ * certain size. Application can use this callback, for example, to limit
+ * the size of the output file.
+ *
+ * @param port The file writer port.
+ * @param pos The file position on which the callback will be called.
+ * @param user_data User data to be specified in the callback, and will be
+ * given on the callback.
+ * @param cb Callback to be called. If the callback returns non-
+ * PJ_SUCCESS, the writing will stop. Note that if
+ * application destroys the port in the callback, it must
+ * return non-PJ_SUCCESS here.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_wav_writer_port_set_cb( pjmedia_port *port,
+ pj_size_t pos,
+ void *user_data,
+ pj_status_t (*cb)(pjmedia_port *port,
+ void *usr_data));
+
+
+/**
+ * @}
+ */
+
+
+PJ_END_DECL
+
+
+#endif /* __PJMEDIA_WAV_PORT_H__ */
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/wave.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/wave.h new file mode 100644 index 0000000..66320f8 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/wave.h @@ -0,0 +1,184 @@ +/* $Id: wave.h 2394 2008-12-23 17:27:53Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_WAVE_H__
+#define __PJMEDIA_WAVE_H__
+
+
+/**
+ * @file wave.h
+ * @brief WAVE file manipulation.
+ */
+#include <pjmedia/types.h>
+
+/**
+ * @defgroup PJMEDIA_FILE_FORMAT File Formats
+ * @brief Supported file formats
+ */
+
+
+/**
+ * @defgroup PJMEDIA_WAVE WAVE Header
+ * @ingroup PJMEDIA_FILE_FORMAT
+ * @brief Representation of RIFF/WAVE file format
+ * @{
+ *
+ * This the the low level representation of RIFF/WAVE file format. For
+ * higher abstraction, please see \ref PJMEDIA_FILE_PLAY and
+ * \ref PJMEDIA_FILE_REC.
+ */
+
+
+PJ_BEGIN_DECL
+
+/**
+ * Standard RIFF tag to identify RIFF file format in the WAVE header.
+ */
+#define PJMEDIA_RIFF_TAG ('F'<<24|'F'<<16|'I'<<8|'R')
+
+/**
+ * Standard WAVE tag to identify WAVE header.
+ */
+#define PJMEDIA_WAVE_TAG ('E'<<24|'V'<<16|'A'<<8|'W')
+
+/**
+ * Standard FMT tag to identify format chunks.
+ */
+#define PJMEDIA_FMT_TAG (' '<<24|'t'<<16|'m'<<8|'f')
+
+/**
+ * Standard DATA tag to identify data chunks.
+ */
+#define PJMEDIA_DATA_TAG ('a'<<24|'t'<<16|'a'<<8|'d')
+
+/**
+ * Standard FACT tag to identify fact chunks.
+ */
+#define PJMEDIA_FACT_TAG ('t'<<24|'c'<<16|'a'<<8|'f')
+
+
+/**
+ * Enumeration of format compression tag.
+ */
+typedef enum {
+ PJMEDIA_WAVE_FMT_TAG_PCM = 1,
+ PJMEDIA_WAVE_FMT_TAG_ALAW = 6,
+ PJMEDIA_WAVE_FMT_TAG_ULAW = 7
+} pjmedia_wave_fmt_tag;
+
+
+/**
+ * This file describes the simpler/canonical version of a WAVE file.
+ * It does not support the full RIFF format specification.
+ */
+#pragma pack(2)
+struct pjmedia_wave_hdr
+{
+ /** This structure describes RIFF WAVE file header */
+ struct {
+ pj_uint32_t riff; /**< "RIFF" ASCII tag. */
+ pj_uint32_t file_len; /**< File length minus 8 bytes */
+ pj_uint32_t wave; /**< "WAVE" ASCII tag. */
+ } riff_hdr;
+
+ /** This structure describes format chunks/header */
+ struct {
+ pj_uint32_t fmt; /**< "fmt " ASCII tag. */
+ pj_uint32_t len; /**< 16 for PCM. */
+ pj_uint16_t fmt_tag; /**< 1 for PCM */
+ pj_uint16_t nchan; /**< Number of channels. */
+ pj_uint32_t sample_rate; /**< Sampling rate. */
+ pj_uint32_t bytes_per_sec; /**< Average bytes per second. */
+ pj_uint16_t block_align; /**< nchannels * bits / 8 */
+ pj_uint16_t bits_per_sample; /**< Bits per sample. */
+ } fmt_hdr;
+
+ /** The data header preceeds the actual data in the file. */
+ struct {
+ pj_uint32_t data; /**< "data" ASCII tag. */
+ pj_uint32_t len; /**< Data length. */
+ } data_hdr;
+};
+#pragma pack()
+
+/**
+ * @see pjmedia_wave_hdr
+ */
+typedef struct pjmedia_wave_hdr pjmedia_wave_hdr;
+
+/**
+ * This structure describes generic RIFF subchunk header.
+ */
+typedef struct pjmedia_wave_subchunk
+{
+ pj_uint32_t id; /**< Subchunk ASCII tag. */
+ pj_uint32_t len; /**< Length following this field */
+} pjmedia_wave_subchunk;
+
+
+/**
+ * Normalize subchunk header from little endian (the representation of
+ * RIFF file) into host's endian.
+ */
+#if defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN!=0
+# define PJMEDIA_WAVE_NORMALIZE_SUBCHUNK(ch) \
+ do { \
+ (ch)->id = pj_swap32((ch)->id); \
+ (ch)->len = pj_swap32((ch)->len); \
+ } while (0)
+#else
+# define PJMEDIA_WAVE_NORMALIZE_SUBCHUNK(ch)
+#endif
+
+
+/**
+ * On big-endian hosts, this function swaps the byte order of the values
+ * in the WAVE header fields. On little-endian hosts, this function does
+ * nothing.
+ *
+ * Application SHOULD call this function after reading the WAVE header
+ * chunks from a file.
+ *
+ * @param hdr The WAVE header.
+ */
+PJ_DECL(void) pjmedia_wave_hdr_file_to_host( pjmedia_wave_hdr *hdr );
+
+
+/**
+ * On big-endian hosts, this function swaps the byte order of the values
+ * in the WAVE header fields. On little-endian hosts, this function does
+ * nothing.
+ *
+ * Application SHOULD call this function before writing the WAVE header
+ * to a file.
+ *
+ * @param hdr The WAVE header.
+ */
+PJ_DECL(void) pjmedia_wave_hdr_host_to_file( pjmedia_wave_hdr *hdr );
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_WAVE_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/wsola.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/wsola.h new file mode 100644 index 0000000..92c3eb8 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia/wsola.h @@ -0,0 +1,219 @@ +/* $Id: wsola.h 2850 2009-08-01 09:20:59Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_WSOLA_H__
+#define __PJMEDIA_WSOLA_H__
+
+/**
+ * @file wsola.h
+ * @brief Waveform Similarity Based Overlap-Add (WSOLA)
+ */
+#include <pjmedia/types.h>
+
+/**
+ * @defgroup PJMED_WSOLA Waveform Similarity Based Overlap-Add (WSOLA)
+ * @ingroup PJMEDIA_FRAME_OP
+ * @brief Time-scale modification to audio without affecting the pitch
+ * @{
+ *
+ * This section describes Waveform Similarity Based Overlap-Add (WSOLA)
+ * implementation in PJMEDIA. The WSOLA API here can be used both to
+ * compress (speed-up) and stretch (expand, slow down) audio playback
+ * without altering the pitch, or as a mean for performing packet loss
+ * concealment (WSOLA).
+ *
+ * The WSOLA implementation is used by \ref PJMED_DELAYBUF and \ref PJMED_PLC.
+ */
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Opaque declaration for WSOLA structure.
+ */
+typedef struct pjmedia_wsola pjmedia_wsola;
+
+
+/**
+ * WSOLA options, can be combined with bitmask operation.
+ */
+enum pjmedia_wsola_option
+{
+ /**
+ * Disable Hanning window to conserve memory.
+ */
+ PJMEDIA_WSOLA_NO_HANNING = 1,
+
+ /**
+ * Specify that the WSOLA will not be used for PLC.
+ */
+ PJMEDIA_WSOLA_NO_PLC = 2,
+
+ /**
+ * Specify that the WSOLA will not be used to discard frames in
+ * non-contiguous buffer.
+ */
+ PJMEDIA_WSOLA_NO_DISCARD = 4,
+
+ /**
+ * Disable fade-in and fade-out feature in the transition between
+ * actual and synthetic frames in WSOLA. With fade feature enabled,
+ * WSOLA will only generate a limited number of synthetic frames
+ * (configurable with #pjmedia_wsola_set_max_expand()), fading out
+ * the volume on every more samples it generates, and when it reaches
+ * the limit it will only generate silence.
+ */
+ PJMEDIA_WSOLA_NO_FADING = 8
+};
+
+
+
+/**
+ * Create and initialize WSOLA.
+ *
+ * @param pool Pool to allocate memory for WSOLA.
+ * @param clock_rate Sampling rate of audio playback.
+ * @param samples_per_frame Number of samples per frame.
+ * @param channel_count Number of channels.
+ * @param options Option flags, bitmask combination of
+ * #pjmedia_wsola_option.
+ * @param p_wsola Pointer to receive WSOLA structure.
+ *
+ * @return PJ_SUCCESS or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_wsola_create(pj_pool_t *pool,
+ unsigned clock_rate,
+ unsigned samples_per_frame,
+ unsigned channel_count,
+ unsigned options,
+ pjmedia_wsola **p_wsola);
+
+
+/**
+ * Specify maximum number of continuous synthetic frames that can be
+ * generated by WSOLA, in milliseconds. This option will only take
+ * effect if fading is not disabled via the option when the WSOLA
+ * session was created. Default value is PJMEDIA_WSOLA_MAX_EXPAND_MSEC
+ * (see also the documentation of PJMEDIA_WSOLA_MAX_EXPAND_MSEC for
+ * more information).
+ *
+ * @param wsola The WSOLA session
+ * @param msec The duration.
+ *
+ * @return PJ_SUCCESS normally.
+ */
+PJ_DECL(pj_status_t) pjmedia_wsola_set_max_expand(pjmedia_wsola *wsola,
+ unsigned msec);
+
+
+/**
+ * Destroy WSOLA.
+ *
+ * @param wsola WSOLA session.
+ *
+ * @return PJ_SUCCESS normally.
+ */
+PJ_DECL(pj_status_t) pjmedia_wsola_destroy(pjmedia_wsola *wsola);
+
+
+/**
+ * Reset the buffer contents of WSOLA.
+ *
+ * @param wsola WSOLA session.
+ * @param options Reset options, must be zero for now.
+ *
+ * @return PJ_SUCCESS normally.
+ */
+PJ_DECL(pj_status_t) pjmedia_wsola_reset(pjmedia_wsola *wsola,
+ unsigned options);
+
+
+/**
+ * Give one good frame to WSOLA to be kept as reference. Application
+ * must continuously give WSOLA good frames to keep its session up to
+ * date with current playback. Depending on the WSOLA implementation,
+ * this function may modify the content of the frame.
+ *
+ * @param wsola WSOLA session.
+ * @param frm The frame, which length must match the samples per
+ * frame setting of the WSOLA session.
+ * @param prev_lost If application previously generated a synthetic
+ * frame with #pjmedia_wsola_generate() before calling
+ * this function, specify whether that was because of
+ * packet lost. If so, set this parameter to PJ_TRUE
+ * to make WSOLA interpolate this frame with its buffer.
+ * Otherwise if this value is PJ_FALSE, WSOLA will
+ * just append this frame to the end of its buffer.
+ *
+ * @return PJ_SUCCESS normally.
+ */
+PJ_DECL(pj_status_t) pjmedia_wsola_save(pjmedia_wsola *wsola,
+ pj_int16_t frm[],
+ pj_bool_t prev_lost);
+
+/**
+ * Generate one synthetic frame from WSOLA.
+ *
+ * @param wsola WSOLA session.
+ * @param frm Buffer to receive the frame.
+ *
+ * @return PJ_SUCCESS normally.
+ */
+PJ_DECL(pj_status_t) pjmedia_wsola_generate(pjmedia_wsola *wsola,
+ pj_int16_t frm[]);
+
+
+/**
+ * Compress or compact the specified buffer by removing some audio samples
+ * from the buffer, without altering the pitch. For this function to work,
+ * total length of the buffer must be more than twice \a erase_cnt.
+ *
+ * @param wsola WSOLA session.
+ * @param buf1 Pointer to buffer.
+ * @param buf1_cnt Number of samples in the buffer.
+ * @param buf2 Pointer to second buffer, if the buffer is not
+ * contiguous. Otherwise this parameter must be NULL.
+ * @param buf2_cnt Number of samples in the second buffer, if the buffer
+ * is not contiguous. Otherwise this parameter should be
+ * zero.
+ * @param erase_cnt On input, specify the number of samples to be erased.
+ * This function may erase more or less than the requested
+ * number, and the actual number of samples erased will be
+ * given on this argument upon returning from the function.
+ *
+ * @return PJ_SUCCESS if some samples have been erased, PJ_ETOOSMALL
+ * if buffer is too small to be reduced, PJ_EINVAL if any
+ * of the parameters are not valid.
+ */
+PJ_DECL(pj_status_t) pjmedia_wsola_discard(pjmedia_wsola *wsola,
+ pj_int16_t buf1[],
+ unsigned buf1_cnt,
+ pj_int16_t buf2[],
+ unsigned buf2_cnt,
+ unsigned *erase_cnt);
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+#endif /* __PJMEDIA_WSOLA_H__ */
+
diff --git a/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia_audiodev.h b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia_audiodev.h new file mode 100644 index 0000000..e2d2658 --- /dev/null +++ b/Protocols/SIP/lib/pjsip/pjmedia/include/pjmedia_audiodev.h @@ -0,0 +1,33 @@ +/* $Id: pjmedia_audiodev.h 2506 2009-03-12 18:11:37Z bennylp $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * 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_AUDIODEV_H__
+#define __PJMEDIA_AUDIODEV_H__
+
+/**
+ * @file pjmedia_audiodev.h
+ * @brief PJMEDIA main header file.
+ */
+
+#include <pjmedia-audiodev/audiodev.h>
+#include <pjmedia-audiodev/audiodev_imp.h>
+#include <pjmedia-audiodev/audiotest.h>
+
+#endif /* __PJMEDIA_AUDIODEV_H__ */
+
|