media/webrtc/signaling/src/sipcc/include/vcm.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rwxr-xr-x

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 /** @section vcm  VCM APIs
     6  *
     7  *  @section Introduction
     8  *  This module contains command APIs to the media layer
     9  */
    11 /**
    12  * @file   vcm.h
    13  * @brief  APIs to interface with the Media layer.
    14  *
    15  * This file contains API that interface to the media layer on the platform.
    16  * The following APIs need to be implemented to have the sip stack interact
    17  * and issue commands to the media layer.
    18  */
    20 #ifndef _VCM_H_
    21 #define _VCM_H_
    23 #include "cpr_types.h"
    24 #include "cc_constants.h"
    25 #include "ccsdp.h"
    28 /** Evaluates to TRUE for audio media streams where id is the mcap_id of the given stream */
    29 #define CC_IS_AUDIO(id) ((id == CC_AUDIO_1) ? TRUE:FALSE)
    30 /** Evaluates to TRUE for video media streams where id is the mcap_id of the given stream */
    31 #define CC_IS_VIDEO(id) ((id == CC_VIDEO_1) ? TRUE:FALSE)
    32 /** Evaluates to TRUE for datachannel streams where id is the mcap_id of the given stream */
    33 #define CC_IS_DATACHANNEL(id) ((id == CC_DATACHANNEL_1) ? TRUE:FALSE)
    36 /** Definitions for direction requesting Play tone to user */
    37 #define VCM_PLAY_TONE_TO_EAR      1
    38 /** Definitions value for direction requesting Play tone to network stream or far end */
    39 #define VCM_PLAY_TONE_TO_NET      2
    40 /** Definitions value for direction requesting Play tone to both user and network */
    41 #define VCM_PLAY_TONE_TO_ALL      3
    43 /** Definitions for alert_info in vcmToneStartWithSpeakerAsBackup API */
    44 #define VCM_ALERT_INFO_OFF        0
    45 /** Definitions for alert_info in vcmToneStartWithSpeakerAsBackup API */
    46 #define VCM_ALERT_INFO_ON         1
    48 /** Definitions for DSP Codec Resources. */
    49 #define VCM_CODEC_RESOURCE_G711     0x00000001
    50 #define VCM_CODEC_RESOURCE_G729A    0x00000002
    51 #define VCM_CODEC_RESOURCE_G729B    0x00000004
    52 #define VCM_CODEC_RESOURCE_LINEAR   0x00000008
    53 #define VCM_CODEC_RESOURCE_G722     0x00000010
    54 #define VCM_CODEC_RESOURCE_iLBC     0x00000020
    55 #define VCM_CODEC_RESOURCE_iSAC     0x00000040
    56 #define VCM_CODEC_RESOURCE_H264     0x00000080
    57 #define VCM_CODEC_RESOURCE_H263     0x00000002
    58 #define VCM_CODEC_RESOURCE_VP8      0x00000100
    59 #define VCM_CODEC_RESOURCE_I420     0x00000200
    60 #define VCM_CODEC_RESOURCE_OPUS     0x00000400
    62 #define VCM_DSP_DECODEONLY  0
    63 #define VCM_DSP_ENCODEONLY  1
    64 #define VCM_DSP_FULLDUPLEX  2
    65 #define VCM_DSP_IGNORE      3
    67 #define CC_KFACTOR_STAT_LEN   (256)
    69 /* Should be enough for any reasonable use-case */
    70 #define MAX_SSRCS_PER_MEDIA_LINE 16
    71 #define MAX_PTS_PER_MEDIA_LINE 16
    73 /**
    74  *  vcm_tones_t
    75  *  Enum identifying various tones that the media layer should implement
    76  */
    78 typedef enum
    79 {
    80     VCM_INSIDE_DIAL_TONE,
    81     VCM_OUTSIDE_DIAL_TONE,
    82     VCM_DEFAULT_TONE = 1,
    83     VCM_LINE_BUSY_TONE,
    84     VCM_ALERTING_TONE,
    85     VCM_BUSY_VERIFY_TONE,
    86     VCM_STUTTER_TONE,
    87     VCM_MSG_WAITING_TONE,
    88     VCM_REORDER_TONE,
    89     VCM_CALL_WAITING_TONE,
    90     VCM_CALL_WAITING_2_TONE,
    91     VCM_CALL_WAITING_3_TONE,
    92     VCM_CALL_WAITING_4_TONE,
    93     VCM_HOLD_TONE,
    94     VCM_CONFIRMATION_TONE,
    95     VCM_PERMANENT_SIGNAL_TONE,
    96     VCM_REMINDER_RING_TONE,
    97     VCM_NO_TONE,
    98     VCM_ZIP_ZIP,
    99     VCM_ZIP,
   100     VCM_BEEP_BONK,
   101 /*#$#$#$#$#@$#$#$#$#$#$#$#$#$#$#$#$$#$#$#$#$#$#$#$#$
   102  * There is a corresponding table defined in
   103  * dialplan.c tone_names[]. Make sure to add tone
   104  * name in that table if you add any new entry above
   105  */
   106     VCM_RECORDERWARNING_TONE,
   107     VCM_RECORDERDETECTED_TONE,
   108     VCM_MONITORWARNING_TONE,
   109     VCM_SECUREWARNING_TONE,
   110     VCM_NONSECUREWARNING_TONE,
   111     VCM_MAX_TONE,
   112     VCM_MAX_DIALTONE = VCM_BEEP_BONK
   113 } vcm_tones_t;
   116 /**
   117  *  vcm_tones_t
   118  *  Enum identifying various tones that the media layer should implement
   119  */
   122 /**
   123  * vcm_ring_mode_t
   124  * VCM_RING_OFFSET is used to map the list
   125  * of ring names to the correct enum type
   126  * when parsing the alert-info header.
   127  */
   128 typedef enum
   129 {
   130     VCM_RING_OFF     = 0x1,
   131     VCM_INSIDE_RING  = 0x2,
   132     VCM_OUTSIDE_RING = 0x3,
   133     VCM_FEATURE_RING = 0x4,
   134     VCM_BELLCORE_DR1 = 0x5,
   135     VCM_RING_OFFSET  = 0x5,
   136     VCM_BELLCORE_DR2 = 0x6,
   137     VCM_BELLCORE_DR3 = 0x7,
   138     VCM_BELLCORE_DR4 = 0x8,
   139     VCM_BELLCORE_DR5 = 0x9,
   140     VCM_BELLCORE_MAX = VCM_BELLCORE_DR5,
   141     VCM_FLASHONLY_RING = 0xA,
   142     VCM_STATION_PRECEDENCE_RING = 0xB,
   143     VCM_MAX_RING = 0xC
   144 } vcm_ring_mode_t;
   146 /**
   147  * vcm_ring_duration_t
   148  * Enums for specifying normal vs single ring
   149  */
   150 typedef enum {
   151     vcm_station_normal_ring = 0x1,
   152     vcm_station_single_ring = 0x2
   153 } vcm_ring_duration_t;
   155 /**
   156  * Structure to carry key codec information
   157  */
   158 typedef struct
   159 {
   160   rtp_ptype codec_type;
   162   /*
   163    * NOTE: We keep track of the RTP "PT" field for sending separate from the
   164    * one for receiving. This is to support asymmetric payload type values
   165    * for a given codec. When we get an offer, we answer with the same payload
   166    * type value that the remote offers. If we send an offer and the remote
   167    * choses to answer with different value than we offer, we support asymmetric.
   168    */
   170   /* RTP "PT" field we use to send this codec ("remote") */
   171   int remote_rtp_pt;
   173   /* RTP "PT" field we use to receive this codec ("local") */
   174   int local_rtp_pt;
   176   /* Parameters for specific media types */
   177   union
   178   {
   179     struct
   180     {
   181       int frequency;
   182       int packet_size; /* Number of samples in a packet */
   183       int channels;
   184       int bitrate;     /* Wire bitrate of RTP packet payloads */
   185     } audio;
   187     struct
   188     {
   189       int width;
   190       int height;
   191       uint32_t rtcp_fb_types;
   192       uint32_t max_fs; /* Max frame size */
   193       uint32_t max_fr; /* Max frame rate */
   194     } video;
   195   };
   197   /* Codec-specific parameters */
   198   union
   199   {
   200     struct {
   201         uint16_t mode;
   202     } ilbc;
   204     /* These are outdated, and need to be updated to match the current
   205        specification. */
   206     struct {
   207         uint32_t max_average_bitrate;
   208         const char *maxcodedaudiobandwidth;
   209         boolean usedtx;
   210         boolean stereo;
   211         boolean useinbandfec;
   212         boolean cbr;
   213     } opus;
   214   };
   215 } vcm_payload_info_t;
   217 /**
   218  * vcm_vad_t
   219  * Enums for Voice Activity Detection
   220  */
   221 typedef enum vcm_vad_t_ {
   222     VCM_VAD_OFF = 0,
   223     VCM_VAD_ON = 1
   224 } vcm_vad_t;
   226 /**
   227  * vcm_audio_bits_t
   228  * Enums for indicating audio path
   229  */
   230 typedef enum vcm_audio_bits_ {
   231     VCM_AUDIO_NONE,
   232     VCM_AUDIO_HANDSET,
   233     VCM_AUDIO_HEADSET,
   234     VCM_AUDIO_SPEAKER
   235 } vcm_audio_bits_t;
   237 /**
   238  * vcm_crypto_algorithmID
   239  * Crypto parameters for SRTP media
   240  */
   241 typedef enum {
   242     VCM_INVLID_ALGORITM_ID = -1,    /* invalid algorithm ID.             */
   243     VCM_NO_ENCRYPTION = 0,          /* no encryption                     */
   244     VCM_AES_128_COUNTER             /* AES 128 counter mode (32 bits HMAC)*/
   245 } vcm_crypto_algorithmID;
   247 /**
   248  * vcm_mixing_mode_t
   249  * Mixing mode for media
   250  */
   251 typedef enum {
   252     VCM_NO_MIX,
   253     VCM_MIX
   254 } vcm_mixing_mode_t;
   256 /**
   257  * vcm_session_t
   258  * Media Session Specification enum
   259  */
   260 typedef enum {
   261     PRIMARY_SESSION,
   262     MIX_SESSION,
   263     NO_SESSION
   264 } vcm_session_t;
   267 /**
   268  * vcm_mixing_party_t
   269  * Media mix party enum
   270  * Indicates the party to be mixed none/local/remote/both/TxBOTH_RxNONE
   271  * TxBOTH_RxNONE means that for Tx stream it's both, for Rx stream it's none
   272  */
   273 typedef enum {
   274     VCM_PARTY_NONE,
   275     VCM_PARTY_LOCAL,
   276     VCM_PARTY_REMOTE,
   277     VCM_PARTY_BOTH,
   278     VCM_PARTY_TxBOTH_RxNONE
   279 } vcm_mixing_party_t;
   281 /**
   282  * media_control_to_encoder_t
   283  * Enums for far end control for media
   284  * Only Fast Picture Update for video is supported
   285  */
   286 typedef enum {
   287     VCM_MEDIA_CONTROL_PICTURE_FAST_UPDATE
   288 } vcm_media_control_to_encoder_t;
   290 /**
   291  * Maximum key and salt must be adjust to the largest possible
   292  * supported key.
   293  */
   294 #define VCM_SRTP_MAX_KEY_SIZE  16   /* maximum key in bytes (128 bits) */
   295 /**
   296  * Maximum key and salt must be adjust to the largest possible
   297  * supported salt.
   298  */
   299 #define VCM_SRTP_MAX_SALT_SIZE 14   /* maximum salt in bytes (112 bits)*/
   301 /** Key size in bytes for AES128 algorithm */
   302 #define VCM_AES_128_COUNTER_KEY_SIZE  16
   303 /** Salt size in bytes for AES128 algorithm */
   304 #define VCM_AES_128_COUNTER_SALT_SIZE 14
   306 /** Structure to carry crypto key and salt for SRTP streams */
   307 typedef struct vcm_crypto_key_t_ {
   308     cc_uint8_t key_len; /**< key length*/
   309     cc_uint8_t key[VCM_SRTP_MAX_KEY_SIZE]; /**< key*/
   310     cc_uint8_t salt_len; /**< salt length*/
   311     cc_uint8_t salt[VCM_SRTP_MAX_SALT_SIZE]; /**< salt*/
   312 } vcm_crypto_key_t;
   314 /**
   315  *  vcm_videoAttrs_t
   316  *  An opaque handle to store and pass video attributes
   317  */
   318 typedef struct vcm_videoAttrs_t_ {
   319   void * opaque; /**< pointer to opaque data from application as received from vcm_negotiate_attrs()*/
   320 } vcm_videoAttrs_t;
   322 /**  A structure carrying audio media specific attributes */
   323 typedef struct vcm_audioAttrs_t_ {
   324   cc_uint16_t packetization_period; /**< ptime value received in SDP */
   325   cc_uint16_t max_packetization_period; /**< ptime value received in SDP */
   326   cc_int32_t avt_payload_type; /**< RTP payload type for AVT */
   327   vcm_vad_t vad; /**< Voice Activity Detection on or off */
   328   vcm_mixing_party_t mixing_party; /**< mixing_party */
   329   vcm_mixing_mode_t  mixing_mode;  /**< mixing_mode*/
   330 } vcm_audioAttrs_t;
   333 /**
   334  *  vcm_mediaAttrs_t
   335  *  A structure to contain audio or video media attributes
   336  */
   337 typedef struct vcm_attrs_t_ {
   338   cc_boolean         mute;
   339   cc_boolean         is_video;
   340   cc_boolean         rtcp_mux;
   341   cc_boolean         audio_level;
   342   uint8_t            audio_level_id;
   343   vcm_audioAttrs_t audio; /**< audio line attribs */
   344   vcm_videoAttrs_t video; /**< Video Atrribs */
   345   uint32_t bundle_level; /**< Where bundle transport info lives, if any */
   346   /* Some stuff for assisting in stream correlation for bundle */
   347   /** RTP correlator specified here:
   348    * http://tools.ietf.org/html/draft-roach-mmusic-unified-plan */
   349   cc_uint32_t        bundle_stream_correlator;
   350   cc_uint32_t        ssrcs[MAX_SSRCS_PER_MEDIA_LINE];
   351   cc_uint8_t         num_ssrcs;
   352   /** Payload type ids that appear on this m-line, but no other. Used as a
   353    * last-ditch correlator for bundle */
   354   cc_uint8_t         unique_payload_types[MAX_PTS_PER_MEDIA_LINE];
   355   cc_uint8_t         num_unique_payload_types;
   356 } vcm_mediaAttrs_t;
   358 //Using C++ for gips. This is required for gips.
   359 #ifdef __cplusplus
   360 extern "C" {
   361 #endif
   363 /**
   364  *  The initialization of the VCM module
   365  *
   366  */
   368 void vcmInit();
   370 /**
   371  * The unloading of the VCM module
   372  */
   373 void vcmUnload();
   376 /**
   377  *   Should we remove this from external API
   378  *
   379  *  @param[in] mcap_id - group identifier to which stream belongs.
   380  *  @param[in]     group_id         - group identifier
   381  *  @param[in]     stream_id        - stream identifier
   382  *  @param[in]     call_handle      - call handle
   383  *  @param[in]     port_requested   - requested port.
   384  *  @param[in]     listen_ip        - local IP for listening
   385  *  @param[in]     is_multicast     - multicast stream?
   386  *  @param[in,out] port_allocated   - allocated(reserved) port
   387  *
   388  *  tbd need to see if we can deprecate this API
   389  *
   390  *  @return       0 success, ERROR failure.
   391  *
   392  */
   394 short vcmRxOpen(cc_mcapid_t mcap_id,
   395         cc_groupid_t group_id,
   396         cc_streamid_t stream_id,
   397         cc_call_handle_t call_handle,
   398         cc_uint16_t port_requested,
   399         cpr_ip_addr_t *listen_ip,
   400         cc_boolean is_multicast,
   401         int *port_allocated);
   402 /*!
   403  *  should we remove from external API
   404  *
   405  *  @param[in]  mcap_id - Media Capability ID
   406  *  @param[in]  group_id - group to which stream belongs
   407  *  @param[in]  stream_id - stream identifier
   408  *  @param[in]  call_handle - call handle
   409  *
   410  *  @return  zero(0) for success; otherwise, ERROR for failure
   411  *
   412  */
   414 short vcmTxOpen(cc_mcapid_t mcap_id,
   415         cc_groupid_t group_id,
   416         cc_streamid_t stream_id,
   417         cc_call_handle_t call_handle);
   419 /*!
   420  *  Allocate(Reserve) a receive port.
   421  *
   422  *  @param[in]  mcap_id - Media Capability ID
   423  *  @param[in]  group_id - group identifier to which stream belongs.
   424  *  @param[in]  stream_id - stream identifier
   425  *  @param[in]  call_handle  - call handle
   426  *  @param[in]  port_requested - port requested (if zero -> give any)
   427  *  @param[out]  port_allocated - port that was actually allocated.
   428  *
   429  *  @return 0 for success; VCM_ERROR for failure
   430  *
   431  */
   433 void vcmRxAllocPort(cc_mcapid_t mcap_id,
   434         cc_groupid_t group_id,
   435         cc_streamid_t stream_id,
   436         cc_call_handle_t  call_handle,
   437         cc_uint16_t port_requested,
   438         int *port_allocated);
   441 short vcmRxAllocICE(cc_mcapid_t mcap_id,
   442         cc_groupid_t group_id,
   443         cc_streamid_t stream_id,
   444         cc_call_handle_t  call_handle,
   445         const char *peerconnection,
   446         uint16_t level,
   447         char **default_addr, /* Out */
   448         int *default_port, /* Out */
   449         char ***candidates, /* Out */
   450         int *candidate_ct /* Out */
   451 );
   454 /* Get ICE global parameters (ufrag and pwd)
   455  *
   456  *  @param[in]  peerconnection - the peerconnection in use
   457  *  @param[out] ufragp - where to put the ufrag
   458  *  @param[out] pwdp - where to put the pwd
   459  *
   460  *  @return 0 for success; VCM_ERROR for failure
   461  */
   462 short vcmGetIceParams(const char *peerconnection, char **ufragp, char **pwdp);
   464 /* Set remote ICE global parameters.
   465  *
   466  *  @param[in]  peerconnection - the peerconnection in use
   467  *  @param[in]  ufrag - the ufrag
   468  *  @param[in]  pwd - the pwd
   469  *
   470  *  @return 0 success, error failure
   471  */
   472 short vcmSetIceSessionParams(const char *peerconnection, char *ufrag, char *pwd);
   474 /* Set ice candidate for trickle ICE.
   475  *
   476  *  @param[in]  peerconnection - the peerconnection in use
   477  *  @param[in]  icecandidate - the icecandidate
   478  *  @param[in]  level - the m line level
   479  *
   480  *  @return 0 success, error failure
   481  */
   482 short vcmSetIceCandidate(const char *peerconnection, const char *icecandidate, uint16_t level);
   484 /* Set remote ICE media-level parameters.
   485  *
   486  *  @param[in]  peerconnection - the peerconnection in use
   487  *  @param[in]  level - the m-line
   488  *  @param[in]  ufrag - the ufrag
   489  *  @param[in]  pwd - the pwd
   490  *  @param[in]  candidates - the candidates
   491  *  @param[in]  candidate_ct - the number of candidates
   492  *  @return 0 success, error failure
   493  */
   494 short vcmSetIceMediaParams(const char *peerconnection, int level, char *ufrag, char *pwd,
   495                       char **candidates, int candidate_ct);
   497 /* Start ICE checks
   498  *  @param[in]  peerconnection - the peerconnection in use
   499  *  @param[in]  isControlling - true if controlling, false if controlled
   500  *  @return 0 success, error failure
   501  */
   502 short vcmStartIceChecks(const char *peerconnection, cc_boolean isControlling);
   506 /*
   507  * Create a remote stream
   508  *
   509  *  @param[in] mcap_id - group identifier to which stream belongs.
   510  *  @param[in]  peerconnection - the peerconnection in use
   511  *  @param[out] pc_stream_id - the id of the allocated stream
   512  *
   513  *  TODO(ekr@rtfm.com): Revise along with everything else for the
   514  *  new stream model.
   515  *
   516  *  Returns: zero(0) for success; otherwise, ERROR for failure
   517  */
   518 short vcmCreateRemoteStream(
   519              cc_mcapid_t mcap_id,
   520              const char *peerconnection,
   521              int *pc_stream_id);
   523 /*
   524  * Add remote stream hint
   525  *
   526  * We are sending track information up to PeerConnection before
   527  * the tracks exist so it knows when the stream is fully constructed.
   528  *
   529  * @param[in] peerconnection
   530  * @param[in] pc_stream_id
   531  * @param[in] is_video
   532  *
   533  * Returns: zero(0) for success; otherwise, ERROR for failure
   534  */
   535 short vcmAddRemoteStreamHint(
   536             const char *peerconnection,
   537             int pc_stream_id,
   538             cc_boolean is_video);
   540 /*!
   541  *  Release the allocated port
   542  * @param[in] mcap_id   - media capability id (0 is audio)
   543  * @param[in] group_id  - group identifier
   544  * @param[in] stream_id - stream identifier
   545  * @param[in] call_handle   - call handle
   546  * @param[in] port     - port to be released
   547  *
   548  * @return void
   549  */
   550 void vcmRxReleasePort(cc_mcapid_t mcap_id,
   551         cc_groupid_t group_id,
   552         cc_streamid_t stream_id,
   553         cc_call_handle_t  call_handle,
   554         int port);
   556 /*!
   557  *  Start receive stream
   558  *  Note: For video calls, for a given call handle there will be
   559  *        two media lines and the corresponding group_id/stream_id pair.
   560  *        One RTP session is requested from media server for each
   561  *        media line(group/stream) i.e. a video call would result in
   562  *        two rtp_sessions in our session info list created by two
   563  *        calls to vcm_rx/tx with mcap_id of AUDIO and VIDEO respectively.
   564  *
   565  *  @param[in]    mcap_id     - media type id
   566  *  @param[in]    group_id    - group identifier associated with the stream
   567  *  @param[in]    stream_id   - id of the stream one per each media line
   568  *  @param[in]    call_handle - call handle
   569  *  @param[in]    payload     - payload information
   570  *  @param[in]    local_addr  - local ip address to use.
   571  *  @param[in]    port        - local port (receive)
   572  *  @param[in]    algorithmID - crypto alogrithm ID
   573  *  @param[in]    rx_key      - rx key used when algorithm ID is encrypting
   574  *  @param[in]    attrs       - media attributes
   575  *
   576  *  @return   zero(0) for success; otherwise, -1 for failure
   577  *
   578  */
   580 int vcmRxStart(cc_mcapid_t mcap_id,
   581         cc_groupid_t group_id,
   582         cc_streamid_t stream_id,
   583         cc_call_handle_t  call_handle,
   584         const vcm_payload_info_t *payload,
   585         cpr_ip_addr_t *local_addr,
   586         cc_uint16_t port,
   587         vcm_crypto_algorithmID algorithmID,
   588         vcm_crypto_key_t *rx_key,
   589         vcm_mediaAttrs_t *attrs);
   592 /**
   593  *  start rx stream
   594  *  Same concept as vcmRxStart but for ICE/PeerConnection-based flows
   595  *
   596  *  @param[in]   mcap_id      - media cap id
   597  *  @param[in]   group_id     - group identifier to which the stream belongs
   598  *  @param[in]   stream_id    - stream id of the given media type.
   599  *  @param[in]   level        - the m-line index
   600  *  @param[in]   pc_stream_id - the media stream index (from PC.addStream())
   601  *  @param[in]   pc_track_id  - the track within the media stream
   602  *  @param[in]   call_handle  - call handle
   603  *  @param[in]   peerconnection - the peerconnection in use
   604  *  @param[in]   num_payloads  - number of codecs negotiated
   605  *  @param[in]   payloads      - list of negotiated codec details
   606  *  @param[in]   setup_t       - whether playing client or server role
   607  *  @param[in]   fingerprint_alg - the DTLS fingerprint algorithm
   608  *  @param[in]   fingerprint  - the DTLS fingerprint
   609  *  @param[in]   attrs        - media attributes
   610  *
   611  *  Returns: zero(0) for success; otherwise, ERROR for failure
   612  *
   613  */
   615 int vcmRxStartICE(cc_mcapid_t mcap_id,
   616         cc_groupid_t group_id,
   617         cc_streamid_t stream_id,
   618         int level,
   619         int pc_stream_id,
   620         int pc_track_id,
   621         cc_call_handle_t  call_handle,
   622         const char *peerconnection,
   623         int num_payloads,
   624         const vcm_payload_info_t* payloads,
   625         sdp_setup_type_e setup_type,
   626         const char *fingerprint_alg,
   627         const char *fingerprint,
   628         vcm_mediaAttrs_t *attrs);
   630 /**
   631  *  start tx stream
   632  *  Note: For video calls, for a given call handle there will be
   633  *        two media lines and the corresponding group_id/stream_id pair.
   634  *        One RTP session is requested from media server for each
   635  *        media line(group/stream) i.e. a video call would result in
   636  *        two rtp_sessions in our session info list created by two
   637  *        calls to vcm_rx/tx with mcap_id of AUDIO and VIDEO respectively.
   638  *
   639  *  @param[in]   mcap_id      - media cap id
   640  *  @param[in]   group_id     - group identifier to which the stream belongs
   641  *  @param[in]   stream_id    - stream id of the given media type.
   642  *  @param[in]   call_handle  - call handle
   643  *  @param[in]   payload      - payload information
   644  *  @param[in]   tos          - bit marking
   645  *  @param[in]   local_addr   - local address
   646  *  @param[in]   local_port   - local port
   647  *  @param[in]   remote_ip_addr - remote ip address
   648  *  @param[in]   remote_port  - remote port
   649  *  @param[in]   algorithmID  - crypto alogrithm ID
   650  *  @param[in]   tx_key       - tx key used when algorithm ID is encrypting.
   651  *  @param[in]   attrs        - media attributes
   652  *
   653  *  Returns: zero(0) for success; otherwise, ERROR for failure
   654  *
   655  */
   657 int vcmTxStart(cc_mcapid_t mcap_id,
   658         cc_groupid_t group_id,
   659         cc_streamid_t stream_id,
   660         cc_call_handle_t  call_handle,
   661         const vcm_payload_info_t *payload,
   662         short tos,
   663         cpr_ip_addr_t *local_addr,
   664         cc_uint16_t local_port,
   665         cpr_ip_addr_t *remote_ip_addr,
   666         cc_uint16_t remote_port,
   667         vcm_crypto_algorithmID algorithmID,
   668         vcm_crypto_key_t *tx_key,
   669         vcm_mediaAttrs_t *attrs);
   672 /**
   673  *  start tx stream
   674  *  Same concept as vcmTxStart but for ICE/PeerConnection-based flowso
   675  *
   676  *  @param[in]   mcap_id      - media cap id
   677  *  @param[in]   group_id     - group identifier to which the stream belongs
   678  *  @param[in]   stream_id    - stream id of the given media type.
   679  *  @param[in]   level        - the m-line index
   680  *  @param[in]   pc_stream_id - the media stream index (from PC.addStream())
   681  *  @param[in]   pc_track_id  - the track within the media stream
   682  *  @param[in]   call_handle  - call handle
   683  *  @param[in]   peerconnection - the peerconnection in use
   684  *  @param[in]   payload      - payload information
   685  *  @param[in]   tos          - bit marking
   686  *  @param[in]   setup_type   - whether playing client or server role
   687  *  @param[in]   fingerprint_alg - the DTLS fingerprint algorithm
   688  *  @param[in]   fingerprint  - the DTLS fingerprint
   689  *  @param[in]   attrs        - media attributes
   690  *
   691  *  Returns: zero(0) for success; otherwise, ERROR for failure
   692  *
   693  */
   695   int vcmTxStartICE(cc_mcapid_t mcap_id,
   696         cc_groupid_t group_id,
   697         cc_streamid_t stream_id,
   698         int level,
   699         int pc_stream_id,
   700         int pc_track_id,
   701         cc_call_handle_t  call_handle,
   702         const char *peerconnection,
   703         const vcm_payload_info_t *payload,
   704         short tos,
   705         sdp_setup_type_e setup_type,
   706         const char *fingerprint_alg,
   707         const char *fingerprint,
   708         vcm_mediaAttrs_t *attrs);
   711   short vcmGetDtlsIdentity(const char *peerconnection,
   712         char *digest_alg,
   713         size_t max_digest_alg_len,
   714         char *digest,
   715         size_t max_digest_len);
   718   short vcmInitializeDataChannel(const char *peerconnection,
   719         int track_id,
   720         cc_uint16_t streams,
   721         int local_datachannel_port,
   722         int remote_datachannel_port,
   723         const char* protocol);
   725 /*!
   726  *  Close the receive stream.
   727  *
   728  *  @param[in]    mcap_id - Media Capability ID
   729  *  @param[in]    group_id - group identifier that belongs to the stream.
   730  *  @param[in]    stream_id - stream id of the given media type.
   731  *  @param[in]    call_handle - call handle
   732  *
   733  *  @return 0 for success; VCM_ERROR for failure
   734  *
   735  */
   737 short vcmRxClose(cc_mcapid_t mcap_id,
   738         cc_groupid_t group_id,
   739         cc_streamid_t stream_id,
   740         cc_call_handle_t  call_handle);
   742 /**
   743  *  Close the transmit stream
   744  *
   745  *  @param[in] mcap_id - Media Capability ID
   746  *  @param[in] group_id - identifier of the group to which stream belongs
   747  *  @param[in] stream_id - stream id of the given media type.
   748  *  @param[in] call_handle - call handle
   749  *
   750  *  @return 0 for success; VCM_ERROR for failure
   751  */
   753 short vcmTxClose(cc_mcapid_t mcap_id,
   754         cc_groupid_t group_id,
   755         cc_streamid_t stream_id,
   756         cc_call_handle_t  call_handle);
   758 /**
   759  *  To be Deprecated
   760  *  This may be needed to be implemented if the DSP doesn't automatically enable the side tone
   761  *  The stack will make a call to this method based on the call state. Provide a stub if this is not needed.
   762  *
   763  *  @param[in] side_tone - cc_boolean to enable/disable side tone
   764  *
   765  *  @return void
   766  *
   767  */
   768 void vcmEnableSidetone(cc_uint16_t side_tone);
   770 /**
   771  *  Start a tone (continuous)
   772  *
   773  *  Parameters:
   774  *  @param[in] tone       - tone type
   775  *  @param[in] alert_info - alertinfo header
   776  *  @param[in] call_handle- call handle
   777  *  @param[in] group_id - identifier of the group to which stream belongs
   778  *  @param[in] stream_id   - stream identifier.
   779  *  @param[in] direction  - network, speaker, both
   780  *
   781  *  @return void
   782  *
   783  */
   785 void vcmToneStart(vcm_tones_t tone,
   786         short alert_info,
   787         cc_call_handle_t  call_handle,
   788         cc_groupid_t group_id,
   789         cc_streamid_t stream_id,
   790         cc_uint16_t direction);
   792 /**
   793  * Plays a short tone. uses the open audio path.
   794  * If no audio path is open, plays on speaker.
   795  *
   796  * @param[in] tone       - tone type
   797  * @param[in] alert_info - alertinfo header
   798  * @param[in] call_handle- call handle
   799  * @param[in] group_id - identifier of the group to which stream belongs
   800  * @param[in] stream_id   - stream identifier.
   801  * @param[in] direction  - network, speaker, both
   802  *
   803  * @return void
   804  */
   806 void vcmToneStartWithSpeakerAsBackup(vcm_tones_t tone,
   807         short alert_info,
   808         cc_call_handle_t call_handle,
   809         cc_groupid_t group_id,
   810         cc_streamid_t stream_id,
   811         cc_uint16_t direction);
   813 /**
   814  *  Stop the tone being played.
   815  *
   816  *  Description: Stop the tone being played currently
   817  *
   818  *
   819  * @param[in] tone - tone to be stopeed
   820  * @param[in] group_id - associated stream's group
   821  * @param[in] stream_id - associated stream id
   822  * @param[in] call_handle - the context (call) for this tone.
   823  *
   824  * @return void
   825  *
   826  */
   828 void vcmToneStop(vcm_tones_t tone,
   829         cc_groupid_t group_id,
   830         cc_streamid_t stream_id,
   831         cc_call_handle_t call_handle);
   833 /**
   834  *  start/stop ringing
   835  *
   836  *  @param[in] ringMode   - VCM ring mode (ON/OFF)
   837  *  @param[in] once       - type of ring - continuous or one shot.
   838  *  @param[in] alert_info - header specified ring mode.
   839  *  @param[in] line       - the line on which to start/stop ringing
   840  *
   841  *  @return    void
   842  */
   844 void vcmControlRinger(vcm_ring_mode_t ringMode,
   845         short once,
   846         cc_boolean alert_info,
   847         int line,
   848         cc_callid_t call_id);
   851 /**
   852  * Get current list of audio codec that could be used
   853  * @param request_type -
   854  * The request_type should be VCM_DECODEONLY/ENCODEONLY/FULLDUPLEX/IGNORE
   855  *
   856  * @return A bit mask should be returned that specifies the list of the audio
   857  * codecs. The bit mask should conform to the defines in this file.
   858  * #define VCM_RESOURCE_G711     0x00000001
   859  * #define VCM_RESOURCE_G729A    0x00000002
   860  * ....
   861  */
   863 int vcmGetAudioCodecList(int request_type);
   865 /**
   866  * Get current list of video codec that could be used
   867  * @param request_type -
   868  * The request_type should be VCM_DECODEONLY/ENCODEONLY/FULLDUPLEX/IGNORE
   869  *
   870  * @return A bit mask should be returned that specifies the list of the audio
   871  * codecs. The bit mask should conform to the defines in this file.
   872  * #define VCM_RESOURCE_G711     0x00000001
   873  * #define VCM_RESOURCE_G729A    0x00000002
   874  * ....
   875  */
   877 int vcmGetVideoCodecList(int request_type);
   879 /**
   880  * Get max supported H.264 video packetization mode.
   881  * @return maximum supported video packetization mode for H.264. Value returned
   882  * must be 0 or 1. Value 2 is not supported yet.
   883  */
   884 int vcmGetVideoMaxSupportedPacketizationMode();
   886 /**
   887  * Get the rx/tx stream statistics associated with the call.
   888  * The rx/tx stats are defined as comma seperated string as follows.
   889  * Rx_stats:
   890  *   snprintf(rx_stats, CC_KFACTOR_STAT_LEN,
   891  *               "Dur=%d,Pkt=%d,Oct=%d,LatePkt=%d,LostPkt=%d,AvgJit=%d,VQMetrics=\"%s\"",
   892  *               duration, numberOfPackageReceived, numberOfByteReceived, numberOfLatePackage, numberOfPackageLost, averageJitter, qualityMatrics);
   893  * Tx_stats:
   894  *   snprintf(tx_stats, CC_KFACTOR_STAT_LEN, "Dur=%d,Pkt=%d,Oct=%d",
   895  *               duration, numberOfPackageSent, numberOfByteSend);
   896  *
   897  *Example:
   898  *
   899  *   vcm_rtp_get_stats : rx_stats:Dur=1,Pkt=90,Oct=15480,LatePkt=0,LostPkt=0,AvgJit=0,VQMetrics="MLQK=0.0;MLQKav=0.0;MLQKmn=0.0;MLQKmx=0.0;MLQKvr=0.95;CCR=0.0;ICR=0.0;ICRmx=0.0;CS=0;SCS=0"
   900  *   vcm_rtp_get_stats : tx_stats:Dur=1,Pkt=92,Oct=14720
   901  *   Where the duration can be calculated, the numberOfLatePackage set to 0.
   902  *
   903  * @param[in]  mcap_id  - media type (audio/video)
   904  * @param[in]  group_id - group id of the stream
   905  * @param[in]  stream_id - stram id of the stream
   906  * @param[in]  call_handle - call handle
   907  * @param[out] rx_stats - ptr to the rx field in the stats struct, see above.
   908  * @param[out] tx_stats - ptr to the tx field in the stats struct, see above.
   909  *
   910  */
   912 int vcmGetRtpStats(cc_mcapid_t mcap_id,
   913         cc_groupid_t group_id,
   914         cc_streamid_t stream_id,
   915         cc_call_handle_t call_handle,
   916         char *rx_stats,
   917         char *tx_stats);
   919 /**
   920  *
   921  * The wlan interface puts into unique situation where call control
   922  * has to allocate the worst case bandwith before creating a
   923  * inbound or outbound call. The function call will interface through
   924  * media API into wlan to get the call bandwidth. The function
   925  * return is asynchronous and will block till the return media
   926  * callback signals to continue the execution.
   927  *
   928  * @note If not using WLAN interface simply return true
   929  *
   930  * @return true if the bandwidth can be allocated else false.
   931  */
   933 cc_boolean vcmAllocateBandwidth(cc_call_handle_t call_handle, int sessions);
   935 /**
   936  *
   937  * Free the bandwidth allocated for this call
   938  * using the vcmAllocateBandwidth API
   939  *
   940  * @note  If not using WLAN provide a stub
   941  */
   943 void vcmRemoveBandwidth(cc_call_handle_t call_handle);
   945 /**
   946  * @brief vcmActivateWlan
   947  *
   948  * Free the bandwidth allocated for this call
   949  * using the vcmAllocateBandwidth API
   950  *
   951  * @note If not using WLAN provide a stub
   952  */
   954 void vcmActivateWlan(cc_boolean is_active);
   956 /**
   957  *  free the media pointer allocated in vcm_negotiate_attrs method
   958  *
   959  *  @param ptr - pointer to be freed
   960  *
   961  *  @return  void
   962  */
   963 void vcmFreeMediaPtr(void *ptr);
   965 /**
   966  *  MEDIA control received from far end on signaling path
   967  *
   968  *  @param call_handle - call handle of the call
   969  *  @param to_encoder - the control request received
   970  *        Only FAST_PICTURE_UPDATE is supported
   971  *
   972  *  @return  void
   973  *
   974  */
   976 void vcmMediaControl(cc_call_handle_t call_handle, vcm_media_control_to_encoder_t to_encoder);
   978 /**
   979  *  specifies DSCP marking for RTCP streams
   980  *
   981  *  @param group_id - group id of the stream
   982  *  @param dscp - the DSCP value to be used
   983  *
   984  *  @return  void
   985  */
   987 void vcmSetRtcpDscp(cc_groupid_t group_id, int dscp);
   989 /**
   990  * Verify if the SDP attributes for the requested video codec are acceptable
   991  *
   992  * This method is called for video codecs only. This method should parse the
   993  * Video SDP attributes using the SDP helper API and verify if received
   994  * attributes are acceptable. If the attributes are acceptable any attribute
   995  * values if needed by vcmTxStart method should be bundled in the desired
   996  * structure and its pointer should be returned in rccappptr. This opaque
   997  * pointer shall be provided again when vcmTxStart is invoked.
   998  *
   999  * @param [in] media_type - codec for which we are negotiating
  1000  * @param [in] sdp_p - opaque SDP pointer to be used via SDP helper APIs
  1001  * @param [in] level - Parameter to be used with SDP helper APIs
  1002  * @param [out] rcapptr - variable to return the allocated attrib structure
  1004  * @return cc_boolean - true if attributes are accepted false otherwise
  1005  */
  1007 cc_boolean vcmCheckAttribs(cc_uint32_t media_type, void *sdp_p, int level, void **rcapptr);
  1009 /**
  1010  * Add Video attributes in the offer/answer SDP
  1012  * This method is called for video codecs only. This method should populate the
  1013  * Video SDP attributes using the SDP helper API
  1015  * @param [in] sdp_p - opaque SDP pointer to be used via SDP helper APIs
  1016  * @param [in] level - Parameter to be used with SDP helper APIs
  1017  * @param [in] media_type - codec for which the SDP attributes are to be populated
  1018  * @param [in] payload_number - RTP payload type used for the SDP
  1019  * @param [in] isOffer - cc_boolean indicating we are encoding an offer or an aswer
  1021  * @return void
  1022  */
  1025 void vcmPopulateAttribs(void *sdp_p, int level, cc_uint32_t media_type,
  1026                           cc_uint16_t payload_number, cc_boolean isOffer);
  1029 /**
  1030  * Send a DTMF digit
  1032  * This method is called for sending a DTMF tone for the specified duration
  1034  * @param [in] digit - the DTMF digit that needs to be played out.
  1035  * @param [in] duration - duration of the tone
  1036  * @param [in] direction - direction in which the tone needs to be played.
  1038  * @return void
  1039  */
  1040 int vcmDtmfBurst(int digit, int duration, int direction);
  1042 /**
  1043  * vcmGetILBCMode
  1045  * This method should return the mode that needs to be used in
  1046  * SDP
  1047  * @return int
  1048  */
  1049 int vcmGetILBCMode();
  1051 /**
  1052  * vcmOnSdpParseError
  1054  * This method is called for each parsing error of SDP.  It does not necessarily
  1055  * mean the SDP read was fatal and can be called many times for the same SDP.
  1057  */
  1058 int vcmOnSdpParseError(const char *peercconnection, const char *message);
  1060 /**
  1061  * vcmDisableRtcpComponent
  1063  * If we are doing rtcp-mux we need to disable component number 2 in the ICE
  1064  * layer.  Otherwise we will wait for it to connect when it is unused
  1065  */
  1066 int vcmDisableRtcpComponent(const char *peerconnection, int level);
  1068 short vcmGetVideoMaxFs(uint16_t codec, int32_t *max_fs);
  1070 short vcmGetVideoMaxFr(uint16_t codec, int32_t *max_fs);
  1072 //Using C++ for gips. This is the end of extern "C" above.
  1073 #ifdef __cplusplus
  1075 #endif
  1080 #endif /* _VCM_H_ */

mercurial