media/webrtc/signaling/src/sipcc/stub/vcm_stub.c

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 /** @mainpage 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 #include "cpr_types.h"
    21 #include "vcm.h"
    22 #include "rtp_defs.h"
    23 #include "ccsdp.h"
    26 /**
    27  *  The initialization of the VCM module
    28  *
    29  */
    30 void vcmInit()
    31 {
    32     return ;
    33 }
    35 /**
    36  *   Should we remove this from external API
    37  *
    38  *  @param[in] mcap_id - group identifier to which stream belongs.
    39  *  @param[in]     group_id         - group identifier
    40  *  @param[in]     cc_stream_id        - stream identifier
    41  *  @param[in]     call_handle      - call handle
    42  *  @param[in]     port_requested   - requested port.
    43  *  @param[in]     listen_ip        - local IP for listening
    44  *  @param[in]     is_multicast     - multicast stream?
    45  *  @param[in,out] port_allocated   - allocated(reserved) port
    46  *
    47  *  tbd need to see if we can deprecate this API
    48  *
    49  *  @return       0 success, ERROR failure.
    50  *
    51  */
    53 short vcmRxOpen(cc_mcapid_t mcap_id, cc_groupid_t group_id, cc_streamid_t stream_id,  cc_call_handle_t call_handle,
    54                   uint16_t port_requested, cpr_ip_addr_t *listen_ip,
    55                   boolean is_multicast, int *port_allocated)
    56 {
    57     return 0;
    58 }
    59 /*!
    60  *  should we remove from external API
    61  *
    62  *  @param[in]  mcap_id - Media Capability ID
    63  *  @param[in]  group_id - group to which stream belongs
    64  *  @param[in]  cc_stream_id - stream identifier
    65  *  @param[in]  call_handle - call handle
    66  *
    67  *  @return  zero(0) for success otherwise, ERROR for failure
    68  *
    69  */
    71 short vcmTxOpen(cc_mcapid_t mcap_id, cc_groupid_t group_id, cc_streamid_t stream_id, cc_call_handle_t call_handle)
    72 {
    73     return 0;
    74 }
    76 /*!
    77  *  Allocate(Reserve) a receive port.
    78  *
    79  *  @param[in]  mcap_id - Media Capability ID
    80  *  @param[in]  group_id - group identifier to which stream belongs.
    81  *  @param[in]  cc_stream_id - stream identifier
    82  *  @param[in]  call_handle  - call handle
    83  *  @param[in]  port_requested - port requested (if zero -> give any)
    84  *  @param[out]  port_allocated - port that was actually allocated.
    85  *
    86  *  @return    void
    87  *
    88  */
    90 void vcmRxAllocPort(cc_mcapid_t mcap_id, cc_groupid_t group_id, cc_streamid_t stream_id,  cc_call_handle_t call_handle,
    91                        uint16_t port_requested, int *port_allocated)
    92 {
    93     return;
    94 }
    96 /*!
    97  *  Release the allocated port
    98  * @param[in] mcap_id   - media capability id (0 is audio)
    99  * @param[in] group_id  - group identifier
   100  * @param[in] cc_stream_id - stream identifier
   101  * @param[in] call_handle   - call handle
   102  * @param[in] port     - port to be released
   103  *
   104  * @return void
   105  */
   107 void vcmRxReleasePort(cc_mcapid_t mcap_id, cc_groupid_t group_id,cc_streamid_t stream_id,  cc_call_handle_t call_handle, int port)
   108 {
   109     return;
   110 }
   112 /*!
   113  *  Start receive stream
   114  *  Note: For video calls, for a given call_id there will be
   115  *        two media lines and the corresponding group_id/cc_stream_id pair.
   116  *        One RTP session is requested from media server for each
   117  *        media line(group/stream) i.e. a video call would result in
   118  *        two rtp_sessions in our session info list created by two
   119  *        calls to vcm_rx/tx with mcap_id of AUDIO and VIDEO respectively.
   120  *
   121  *  @param[in]    mcap_id     - media type id
   122  *  @param[in]    group_id    - group identifier associated with the stream
   123  *  @param[in]    cc_stream_id   - id of the stream one per each media line
   124  *  @param[in]    call_handle     - call handle
   125  *  @param[in]    payload     - payload type
   126  *  @param[in]    local_addr  - local ip address to use.
   127  *  @param[in]    port        - local port (receive)
   128  *  @param[in]    algorithmID - crypto alogrithm ID
   129  *  @param[in]    rx_key      - rx key used when algorithm ID is encrypting
   130  *  @param[in]    attrs       - media attributes
   131  *
   132  *  @return   zero(0) for success otherwise, -1 for failure
   133  *
   134  */
   136 int vcmRxStart(cc_mcapid_t mcap_id, cc_groupid_t group_id, cc_streamid_t
   137                stream_id, cc_call_handle_t call_handle,
   138                const vcm_payload_info_t *payload, cpr_ip_addr_t *local_addr,
   139                uint16_t port, vcm_crypto_algorithmID algorithmID,
   140                vcm_crypto_key_t *rx_key, vcm_mediaAttrs_t *attrs)
   141 {
   142     return 0;
   143 }
   145 /**
   146  *  start tx stream
   147  *  Note: For video calls, for a given call_id there will be
   148  *        two media lines and the corresponding group_id/cc_stream_id pair.
   149  *        One RTP session is requested from media server for each
   150  *        media line(group/stream) i.e. a video call would result in
   151  *        two rtp_sessions in our session info list created by two
   152  *        calls to vcm_rx/tx with mcap_id of AUDIO and VIDEO respectively.
   153  *
   154  *  @param[in]   mcap_id      - media cap id
   155  *  @param[in]   group_id     - group identifier to which the stream belongs
   156  *  @param[in]   cc_stream_id    - stream id of the given media type.
   157  *  @param[in]   call_handle  - call handle
   158  *  @param[in]   payload      - payload type
   159  *  @param[in]   tos          - bit marking
   160  *  @param[in]   local_addr   - local address
   161  *  @param[in]   local_port   - local port
   162  *  @param[in]   remote_ip_addr - remote ip address
   163  *  @param[in]   remote_port  - remote port
   164  *  @param[in]   algorithmID  - crypto alogrithm ID
   165  *  @param[in]   tx_key       - tx key used when algorithm ID is encrypting.
   166  *  @param[in]   attrs        - media attributes
   167  *
   168  *  Returns: zero(0) for success otherwise, ERROR for failure
   169  *
   170  */
   172 int vcmTxStart(cc_mcapid_t mcap_id, cc_groupid_t group_id,
   173                cc_streamid_t stream_id,  cc_call_handle_t call_handle,
   174                const vcm_payload_info_t *payload, short tos,
   175                cpr_ip_addr_t *local_addr, uint16_t local_port,
   176                cpr_ip_addr_t *remote_ip_addr, uint16_t remote_port,
   177                vcm_crypto_algorithmID algorithmID, vcm_crypto_key_t *tx_key,
   178                vcm_mediaAttrs_t *attrs)
   179 {
   180     return 0;
   181 }
   183 /*!
   184  *  Close the receive stream.
   185  *
   186  *  @param[in]    mcap_id - Media Capability ID
   187  *  @param[in]    group_id - group identifier that belongs to the stream.
   188  *  @param[in]    cc_stream_id - stream id of the given media type.
   189  *  @param[in]    call_handle  - call handle
   190  *
   191  *  @return   None
   192  *
   193  */
   195 void vcmRxClose(cc_mcapid_t mcap_id, cc_groupid_t group_id,cc_streamid_t stream_id,  cc_call_handle_t call_handle)
   196 {
   197     return;
   198 }
   200 /**
   201  *  Close the transmit stream
   202  *
   203  *  @param[in] mcap_id - Media Capability ID
   204  *  @param[in] group_id - identifier of the group to which stream belongs
   205  *  @param[in] cc_stream_id - stream id of the given media type.
   206  *  @param[in] call_handle  - call handle
   207  *
   208  *  @return     void
   209  */
   211 void vcmTxClose(cc_mcapid_t mcap_id, cc_groupid_t group_id, cc_streamid_t stream_id, cc_call_handle_t call_handleS)
   212 {
   213     return;
   214 }
   216 /**
   217  *  To be Deprecated
   218  *  This may be needed to be implemented if the DSP doesn't automatically enable the side tone
   219  *  The stack will make a call to this method based on the call state. Provide a stub if this is not needed.
   220  *
   221  *  @param[in] side_tone - boolean to enable/disable side tone
   222  *
   223  *  @return void
   224  *
   225  */
   226 void vcmEnableSidetone(uint16_t side_tone)
   227 {
   228     return;
   229 }
   231 /**
   232  *  Start a tone (continuous)
   233  *
   234  *  Parameters:
   235  *  @param[in] tone       - tone type
   236  *  @param[in] alert_info - alertinfo header
   237  *  @param[in] call_handle    - call handle
   238  *  @param[in] group_id - identifier of the group to which stream belongs
   239  *  @param[in] cc_stream_id   - stream identifier.
   240  *  @param[in] direction  - network, speaker, both
   241  *
   242  *  @return void
   243  *
   244  */
   246 void vcmToneStart(vcm_tones_t tone, short alert_info, cc_call_handle_t call_handle, cc_groupid_t group_id,
   247                     cc_streamid_t stream_id, uint16_t direction)
   248 {
   249     return;
   250 }
   252 /**
   253  * Plays a short tone. uses the open audio path.
   254  * If no audio path is open, plays on speaker.
   255  *
   256  * @param[in] tone       - tone type
   257  * @param[in] alert_info - alertinfo header
   258  * @param[in] call_handle - call handle
   259  * @param[in] group_id - identifier of the group to which stream belongs
   260  * @param[in] cc_stream_id   - stream identifier.
   261  * @param[in] direction  - network, speaker, both
   262  *
   263  * @return void
   264  */
   266 void vcmToneStartWithSpeakerAsBackup(vcm_tones_t tone, short alert_info, cc_call_handle_t call_handle, cc_groupid_t group_id,
   267                     cc_streamid_t stream_id, uint16_t direction)
   268 {
   269     return;
   270 }
   272 /**
   273  *  Stop the tone being played.
   274  *
   275  *  Description: Stop the tone being played currently
   276  *
   277  *
   278  * @param[in] tone - tone to be stopeed
   279  * @param[in] group_id - associated stream's group
   280  * @param[in] cc_stream_id - associated stream id
   281  * @param[in] call_handle - the context (call) for this tone.
   282  *
   283  * @return void
   284  *
   285  */
   287 void vcmToneStop(vcm_tones_t tone, cc_groupid_t group_id, cc_streamid_t cc_stream_id, cc_call_handle_t call_handle)
   288 {
   289     return;
   290 }
   292 /**
   293  *  start/stop ringing
   294  *
   295  *  @param[in] ringMode   - VCM ring mode (ON/OFF)
   296  *  @param[in] once       - type of ring - continuous or one shot.
   297  *  @param[in] alert_info - header specified ring mode.
   298  *  @param[in] line       - the line on which to start/stop ringing
   299  *
   300  *  @return    void
   301  */
   303 void vcmControlRinger(vcm_ring_mode_t ringMode, short once,
   304                         boolean alert_info, int line, cc_callid_t call_id)
   305 {
   306     return;
   307 }
   310 /**
   311  * Enable / disable speaker
   312  *
   313  * @param[in] state - true -> enable speaker, false -> disable speaker
   314  *
   315  * @return void
   316  */
   318 void vcmSetSpeakerMode(boolean state)
   319 {
   320     return;
   321 }
   323 /**
   324  * Get current list of audio codec that could be used
   325  * @param request_type - sendonly/recvonly/sendrecv
   326  */
   328 int vcmGetAudioCodecList(int request_type)
   329 {
   330     return 0;
   331 }
   332 /**
   333  * Get current list of video codec that could be used
   334  * @param request_type - sendonly/recvonly/sendrecv
   335  */
   337 int vcmGetVideoCodecList(int request_type)
   338 {
   339     return 0;
   340 }
   342 /**
   343  * Get max supported video packetization mode for H.264 video
   344  */
   345 /*
   346 int vcmGetVideoMaxSupportedPacketizationMode()
   347 {
   348     return 0;
   349 }
   350 */
   351 /**
   352  * Get the rx/tx stream statistics associated with the call.
   353  *
   354  * @param[in]  mcap_id  - media type (audio/video)
   355  * @param[in]  group_id - group id of the stream
   356  * @param[in]  cc_stream_id - stram id of the stream
   357  * @param[in]  call_handle - call handle
   358  * @param[out] rx_stats - ptr to the rx field in the stats struct
   359  * @param[out] tx_stats - ptr to the tx field in the stats struct
   360  *
   361  */
   363 /*
   364 int vcmGetRtpStats(cc_mcapid_t mcap_id, cc_groupid_t group_id,
   365                       cc_streamid_t stream_id, cc_call_handle_t call_handle,
   366                       char *rx_stats, char *tx_stats)
   367 {
   368     return 0;
   369 }
   370 */
   372 /**
   373  *
   374  * The wlan interface puts into unique situation where call control
   375  * has to allocate the worst case bandwith before creating a
   376  * inbound or outbound call. The function call will interface through
   377  * media API into wlan to get the call bandwidth. The function
   378  * return is asynchronous and will block till the return media
   379  * callback signals to continue the execution.
   380  *
   381  * @note If not using WLAN interface simply return true
   382  *
   383  * @return true if the bandwidth can be allocated else false.
   384  */
   386 /*
   387 boolean vcmAllocateBandwidth(cc_call_handle_t call_handle, int sessions)
   388 {
   389     return TRUE;
   390 }
   391 */
   393 /**
   394  *
   395  * Free the bandwidth allocated for this call
   396  * using the vcmAllocateBandwidth API
   397  *
   398  * @note  If not using WLAN provide a stub
   399  */
   401 /*
   402 void vcmRemoveBandwidth(cc_call_handle_t call_handle)
   403 {
   404     return;
   405 }
   406 */
   408 /**
   409  * @brief vcmActivateWlan
   410  *
   411  * Free the bandwidth allocated for this call
   412  * using the vcmAllocateBandwidth API
   413  *
   414  * @note If not using WLAN provide a stub
   415  */
   417 /*
   418 void vcmActivateWlan(boolean is_active)
   419 {
   420     return;
   421 }
   422 */
   424 /**
   425  *  free the media pointer allocated in vcm_negotiate_attrs method
   426  *
   427  *  @param ptr - pointer to be freed
   428  *
   429  *  @return  void
   430  */
   431 void vcmFreeMediaPtr(void *ptr)
   432 {
   433     return;
   434 }
   436 /**
   437  *  MEDIA control received from far end on signaling path
   438  *
   439  *  @param call_handle - call handle of the call
   440  *  @param to_encoder - the control request received
   441  *        Only FAST_PICTURE_UPDATE is supported
   442  *
   443  *  @return  void
   444  *
   445  */
   447 /*
   448 void vcmMediaControl(cc_call_handle_t call_handle, vcm_media_control_to_encoder_t to_encoder)
   449 {
   450     return;
   451 }
   452 */
   454 /**
   455  *  specifies DSCP marking for RTCP streams
   456  *
   457  *  @param group_id - call_id of the call
   458  *  @param dscp - the DSCP value to be used
   459  *
   460  *  @return  void
   461  */
   463 /*
   464 void vcmSetRtcpDscp(cc_groupid_t group_id, int dscp)
   465 {
   466     return;
   467 }
   468 */
   470 /**
   471  * Verify if the SDP attributes for the requested video codec are acceptable
   472  *
   473  * This method is called for video codecs only. This method should parse the
   474  * Video SDP attributes using the SDP helper API and verify if received
   475  * attributes are acceptable. If the attributes are acceptable any attribute
   476  * values if needed by vcmTxStart method should be bundled in the desired
   477  * structure and its pointer should be returned in rccappptr. This opaque
   478  * pointer shall be provided again when vcmTxStart is invoked.
   479  *
   480  * @param [in] media_type - codec for which we are negotiating
   481  * @param [in] sdp_p - opaque SDP pointer to be used via SDP helper APIs
   482  * @param [in] level - Parameter to be used with SDP helper APIs
   483  * @param [out] rcapptr - variable to return the allocated attrib structure
   484  *
   485  * @return boolean - true if attributes are accepted false otherwise
   486  */
   488 boolean vcmCheckAttribs(uint32_t media_type, void *sdp_p, int level, void **rcapptr)
   489 {
   490     return TRUE;
   491 }
   493 /**
   494  * Add Video attributes in the offer/answer SDP
   495  *
   496  * This method is called for video codecs only. This method should populate the
   497  * Video SDP attributes using the SDP helper API
   498  *
   499  * @param [in] sdp_p - opaque SDP pointer to be used via SDP helper APIs
   500  * @param [in] level - Parameter to be used with SDP helper APIs
   501  * @param [in] media_type - codec for which the SDP attributes are to be populated
   502  * @param [in] payload_number - RTP payload type used for the SDP
   503  * @param [in] isOffer - boolean indicating we are encoding an offer or an aswer
   504  *
   505  * @return void
   506  */
   509 void vcmPopulateAttribs(void *sdp_p, int level, uint32_t media_type,
   510                           uint16_t payload_number, boolean isOffer)
   511 {
   512     return;
   513 }
   515 /**
   516  * Send a DTMF digit
   517  *
   518  * This method is called for sending a DTMF tone for the specified duration
   519  *
   520  * @param [in] digit - the DTMF digit that needs to be played out.
   521  * @param [in] duration - duration of the tone
   522  * @param [in] direction - direction in which the tone needs to be played.
   523  *
   524  * @return void
   525  */
   527 /*
   528 int vcmDtmfBurst(int digit, int duration, int direction)
   529 {
   530     return 0;
   531 }
   532 */
   534 /*
   535 int vcmGetILBCMode()
   536 {
   537     return SIPSDP_ILBC_MODE20;
   538 }
   539 */

mercurial