Changeset 4662 for pjproject


Ignore:
Timestamp:
Nov 29, 2013 3:05:48 AM (10 years ago)
Author:
riza
Message:

Re #1519: Added Media API in pjsua2.

Location:
pjproject/branches/projects/pjsua2
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/pjsua2.i

    r4658 r4662  
    4040%feature("director") FindBuddyMatch; 
    4141 
    42  
    4342// 
    4443// STL stuff. 
     
    4645%include "std_string.i" 
    4746%include "std_vector.i" 
    48  
    4947 
    5048%template(StringVector)                 std::vector<std::string>; 
     
    7472%template(SipMultipartPartVector)       std::vector<pj::SipMultipartPart>; 
    7573%template(BuddyVector)                  std::vector<pj::Buddy*>; 
     74%template(AudioMediaVector)             std::vector<pj::AudioMedia*>; 
     75%template(MediaFormatVector)            std::vector<pj::MediaFormat*>; 
    7676 
     77%include "pjsua2/media.hpp" 
    7778%include "pjsua2/endpoint.hpp" 
    7879%include "pjsua2/presence.hpp" 
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/symbols.i

    r4657 r4662  
    4141enum pjmedia_vid_dev_std_index {PJMEDIA_VID_DEFAULT_CAPTURE_DEV = -1, PJMEDIA_VID_DEFAULT_RENDER_DEV = -2, PJMEDIA_VID_INVALID_DEV = -3}; 
    4242 
     43enum pjmedia_file_writer_option {PJMEDIA_FILE_WRITE_PCM = 0, PJMEDIA_FILE_WRITE_ALAW = 1, PJMEDIA_FILE_WRITE_ULAW = 2}; 
     44 
     45enum pjmedia_file_player_option {PJMEDIA_FILE_NO_LOOP = 1}; 
     46 
     47typedef enum pjmedia_type {PJMEDIA_TYPE_NONE, PJMEDIA_TYPE_AUDIO, PJMEDIA_TYPE_VIDEO, PJMEDIA_TYPE_APPLICATION, PJMEDIA_TYPE_UNKNOWN} pjmedia_type; 
     48 
     49typedef enum pjmedia_format_id {PJMEDIA_FORMAT_L16 = 0, PJMEDIA_FORMAT_PCM = PJMEDIA_FORMAT_L16, PJMEDIA_FORMAT_PCMA = ((('W' << 24) | ('A' << 16)) | ('L' << 8)) | 'A', PJMEDIA_FORMAT_ALAW = PJMEDIA_FORMAT_PCMA, PJMEDIA_FORMAT_PCMU = ((('W' << 24) | ('A' << 16)) | ('L' << 8)) | 'u', PJMEDIA_FORMAT_ULAW = PJMEDIA_FORMAT_PCMU, PJMEDIA_FORMAT_AMR = ((('R' << 24) | ('M' << 16)) | ('A' << 8)) | ' ', PJMEDIA_FORMAT_G729 = ((('9' << 24) | ('2' << 16)) | ('7' << 8)) | 'G', PJMEDIA_FORMAT_ILBC = ((('C' << 24) | ('B' << 16)) | ('L' << 8)) | 'I', PJMEDIA_FORMAT_RGB24 = ((('3' << 24) | ('B' << 16)) | ('G' << 8)) | 'R', PJMEDIA_FORMAT_RGBA = ((('A' << 24) | ('B' << 16)) | ('G' << 8)) | 'R', PJMEDIA_FORMAT_BGRA = ((('A' << 24) | ('R' << 16)) | ('G' << 8)) | 'B', PJMEDIA_FORMAT_RGB32 = PJMEDIA_FORMAT_RGBA, PJMEDIA_FORMAT_DIB = (((' ' << 24) | ('B' << 16)) | ('I' << 8)) | 'D', PJMEDIA_FORMAT_GBRP = ((('P' << 24) | ('R' << 16)) | ('B' << 8)) | 'G', PJMEDIA_FORMAT_AYUV = ((('V' << 24) | ('U' << 16)) | ('Y' << 8)) | 'A', PJMEDIA_FORMAT_YUY2 = ((('2' << 24) | ('Y' << 16)) | ('U' << 8)) | 'Y', PJMEDIA_FORMAT_UYVY = ((('Y' << 24) | ('V' << 16)) | ('Y' << 8)) | 'U', PJMEDIA_FORMAT_YVYU = ((('U' << 24) | ('Y' << 16)) | ('V' << 8)) | 'Y', PJMEDIA_FORMAT_I420 = ((('0' << 24) | ('2' << 16)) | ('4' << 8)) | 'I', PJMEDIA_FORMAT_IYUV = PJMEDIA_FORMAT_I420, PJMEDIA_FORMAT_YV12 = ((('2' << 24) | ('1' << 16)) | ('V' << 8)) | 'Y', PJMEDIA_FORMAT_I422 = ((('2' << 24) | ('2' << 16)) | ('4' << 8)) | 'I', PJMEDIA_FORMAT_I420JPEG = ((('0' << 24) | ('2' << 16)) | ('4' << 8)) | 'J', PJMEDIA_FORMAT_I422JPEG = ((('2' << 24) | ('2' << 16)) | ('4' << 8)) | 'J', PJMEDIA_FORMAT_H261 = ((('1' << 24) | ('6' << 16)) | ('2' << 8)) | 'H', PJMEDIA_FORMAT_H263 = ((('3' << 24) | ('6' << 16)) | ('2' << 8)) | 'H', PJMEDIA_FORMAT_H263P = ((('3' << 24) | ('6' << 16)) | ('2' << 8)) | 'P', PJMEDIA_FORMAT_H264 = ((('4' << 24) | ('6' << 16)) | ('2' << 8)) | 'H', PJMEDIA_FORMAT_MJPEG = ((('G' << 24) | ('P' << 16)) | ('J' << 8)) | 'M', PJMEDIA_FORMAT_MPEG1VIDEO = ((('V' << 24) | ('1' << 16)) | ('P' << 8)) | 'M', PJMEDIA_FORMAT_MPEG2VIDEO = ((('V' << 24) | ('2' << 16)) | ('P' << 8)) | 'M', PJMEDIA_FORMAT_MPEG4 = ((('4' << 24) | ('G' << 16)) | ('P' << 8)) | 'M'} pjmedia_format_id; 
     50 
    4351typedef enum pjsip_cred_data_type {PJSIP_CRED_DATA_PLAIN_PASSWD = 0, PJSIP_CRED_DATA_DIGEST = 1, PJSIP_CRED_DATA_EXT_AKA = 16} pjsip_cred_data_type; 
    4452 
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/symbols.lst

    r4657 r4662  
    1 pj/types.h                      pj_status_t pj_constants_ pj_uint8_t pj_int32_t          
     1pj/types.h                      pj_status_t pj_constants_ pj_uint8_t pj_int32_t          
    22pj/file_io.h                    pj_file_access 
    33pj/log.h                        pj_log_decoration 
     
    55pj/ssl_sock.h                   pj_ssl_cipher 
    66 
    7 pjnath/nat_detect.h             pj_stun_nat_type 
    8 pjnath/turn_session.h           pj_turn_tp_type 
     7pjnath/nat_detect.h             pj_stun_nat_type 
     8pjnath/turn_session.h          pj_turn_tp_type 
    99 
    10 pjmedia/transport_srtp.h        pjmedia_srtp_use 
    11 pjmedia/vid_stream.h            pjmedia_vid_stream_rc_method 
    12 pjmedia-videodev/videodev.h     pjmedia_vid_dev_index pjmedia_vid_dev_std_index 
     10pjmedia/transport_srtp.h        pjmedia_srtp_use 
     11pjmedia/vid_stream.h            pjmedia_vid_stream_rc_method 
     12pjmedia-videodev/videodev.h     pjmedia_vid_dev_index pjmedia_vid_dev_std_index 
     13pjmedia/wav_port.h              pjmedia_file_writer_option pjmedia_file_player_option 
     14pjmedia/types.h                 pjmedia_type 
     15pjmedia/format.h                pjmedia_format_id 
    1316 
    14 pjsip/sip_auth.h                pjsip_cred_data_type 
    15 pjsip/sip_msg.h                 pjsip_status_code 
    16 pjsip/sip_transport.h           pjsip_transport_type_e pjsip_transport_flags_e pjsip_transport_state 
    17 pjsip/sip_transport_tls.h       pjsip_ssl_method 
     17pjsip/sip_auth.h                pjsip_cred_data_type 
     18pjsip/sip_msg.h                 pjsip_status_code 
     19pjsip/sip_transport.h          pjsip_transport_type_e pjsip_transport_flags_e pjsip_transport_state 
     20pjsip/sip_transport_tls.h       pjsip_ssl_method 
    1821 
    19 pjsip-simple/rpid.h             pjrpid_activity 
     22pjsip-simple/rpid.h             pjrpid_activity 
    2023pjsip-simple/evsub.h            pjsip_evsub_state 
    2124 
  • pjproject/branches/projects/pjsua2/pjsip/build/Makefile

    r4657 r4662  
    9191export PJSUA2_LIB_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ 
    9292                           account.o endpoint.o json.o persistent.o types.o \ 
    93                            siptypes.o presence.o 
     93                           siptypes.o presence.o media.o 
    9494export PJSUA2_LIB_CFLAGS += $(_CFLAGS) $(PJ_VIDEO_CFLAGS) 
    9595export PJSUA2_LIB_CXXFLAGS = $(PJSUA2_LIB_CFLAGS)  
  • pjproject/branches/projects/pjsua2/pjsip/include/pjsua2.hpp

    r4657 r4662  
    2323#include <pjsua2/account.hpp> 
    2424#include <pjsua2/presence.hpp> 
     25#include <pjsua2/media.hpp> 
    2526#include <pjsua2/json.hpp> 
    2627 
  • pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/endpoint.hpp

    r4657 r4662  
    2525 */ 
    2626#include <pjsua2/persistent.hpp> 
     27#include <pjsua2/media.hpp> 
    2728#include <pjsua2/siptypes.hpp> 
    2829 
     
    946947    void transportClose(TransportId id) throw(Error); 
    947948 
     949    /************************************************************************* 
     950     * Media operations 
     951     */ 
     952 
     953    /** 
     954     * Add media to the media list. 
     955     * 
     956     * @param media     media to be added. 
     957     */ 
     958    void addMedia(AudioMedia &media); 
     959 
     960    /** 
     961     * Remove media from the media list. 
     962     * 
     963     * @param media     media to be removed. 
     964     */ 
     965    void removeMedia(AudioMedia &media); 
     966 
     967    /** 
     968     * Check if media has been added to the media list. 
     969     * 
     970     * @param media     media to be check. 
     971     * 
     972     * @return          True if media has been added, false otherwise. 
     973     */ 
     974    bool mediaExists(const AudioMedia &media) const; 
     975 
     976    /** 
     977     * Get maximum number of media port. 
     978     * 
     979     * @return          Maximum number of media port in the conference bridge. 
     980     */ 
     981    unsigned mediaMaxPorts() const; 
     982 
     983    /** 
     984     * Get current number of active media port in the bridge. 
     985     * 
     986     * @return          The number of active media port. 
     987     */ 
     988    unsigned mediaActivePorts() const; 
     989 
     990    /** 
     991     * Enumerate all media port. 
     992     * 
     993     * @return          The list of media port. 
     994     */ 
     995    const AudioMediaVector &mediaEnumPorts() const throw(Error); 
     996 
    948997public: 
    949998    /* 
     
    10101059 
    10111060private: 
    1012     static Endpoint     *instance_;     // static instance 
    1013     LogWriter           *writer;        // Custom writer, if any 
     1061    static Endpoint             *instance_;     // static instance 
     1062    LogWriter                   *writer;        // Custom writer, if any 
     1063    AudioMediaVector             mediaList; 
    10141064 
    10151065    /* Endpoint static callbacks */ 
     
    10711121    static void on_mwi_info(pjsua_acc_id acc_id, 
    10721122                            pjsua_mwi_info *mwi_info); 
     1123 
    10731124    static void on_buddy_state(pjsua_buddy_id buddy_id); 
    1074  
    10751125}; 
    10761126 
  • pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/endpoint.cpp

    r4659 r4662  
    2020#include <pjsua2/account.hpp> 
    2121#include <pjsua2/presence.hpp> 
     22#include <algorithm> 
    2223#include "util.hpp" 
    2324 
     
    366367    } 
    367368    delete writer; 
     369     
     370    while(mediaList.size() > 0) { 
     371        AudioMedia *cur_media = mediaList[0]; 
     372        delete cur_media; 
     373    } 
     374 
    368375    instance_ = NULL; 
    369376} 
     
    971978/////////////////////////////////////////////////////////////////////////////// 
    972979 
     980/* 
     981 * Media API 
     982 */ 
     983unsigned Endpoint::mediaMaxPorts() const 
     984{ 
     985    return pjsua_conf_get_max_ports(); 
     986} 
     987 
     988unsigned Endpoint::mediaActivePorts() const 
     989{ 
     990    return pjsua_conf_get_active_ports(); 
     991} 
     992 
     993const AudioMediaVector &Endpoint::mediaEnumPorts() const throw(Error) 
     994{ 
     995    return mediaList; 
     996} 
     997 
     998void Endpoint::addMedia(AudioMedia &media) 
     999{ 
     1000    if (mediaExists(media)) 
     1001        return; 
     1002 
     1003    mediaList.push_back(&media); 
     1004} 
     1005 
     1006void Endpoint::removeMedia(AudioMedia &media) 
     1007{ 
     1008    AudioMediaVector::iterator it = std::find(mediaList.begin(), 
     1009                                              mediaList.end(), 
     1010                                              &media); 
     1011 
     1012    if (it != mediaList.end()) 
     1013        mediaList.erase(it); 
     1014 
     1015} 
     1016 
     1017bool Endpoint::mediaExists(const AudioMedia &media) const 
     1018{ 
     1019    AudioMediaVector::const_iterator it = std::find(mediaList.begin(), 
     1020                                                    mediaList.end(), 
     1021                                                    &media); 
     1022 
     1023    return (it != mediaList.end()); 
     1024} 
Note: See TracChangeset for help on using the changeset viewer.