Changeset 23

Show
Ignore:
Timestamp:
10/14/07 19:11:47 (1 year ago)
Author:
sip
Message:

Profiles, DID and fixed bye

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mcuWeb/src/java/org/murillo/mcuWeb/Conference.java

    r21 r23  
    3131    private Integer id; 
    3232    private String name; 
     33    private String did; 
    3334    private MediaMixer mixer; 
    3435    private HashMap<Integer,Participant> participants; 
    3536    private Integer compType; 
    3637    private Integer size; 
     38    private Profile profile; 
    3739 
    3840    /** Creates a new instance of Conference */ 
    39     protected Conference(Integer id,String name,MediaMixer mixer) { 
     41    protected Conference(Integer id,String name,String did,MediaMixer mixer,Profile profile) { 
    4042        //Save values 
    4143        this.id = id; 
    4244        this.mixer = mixer; 
    4345        this.name = name; 
     46        this.did = did; 
     47        this.profile = profile; 
    4448        //Default composition and size 
    4549        this.compType = XmlRpcMcuClient.MOSAIC2x2; 
     
    7276        return participants; 
    7377    } 
     78     
     79    public int getNumParcitipants() { 
     80        return participants.size(); 
     81    } 
     82     
    7483    public Integer getId() { 
    7584        return id; 
     
    8493    } 
    8594 
     95    public String getDID() { 
     96        return did; 
     97    }     
     98     
    8699    public MediaMixer getMixer() { 
    87100        return mixer; 
    88101    } 
    89  
    90     void removeParticitpant(Integer id) { 
    91         throw new UnsupportedOperationException("Not yet implemented")
     102     
     103    public Profile getProfile() { 
     104        return profile
    92105    } 
    93106     
     107    public void setProfile(Profile profile) { 
     108        this.profile = profile; 
     109    } 
     110 
     111    public void removeParticitpant(Integer id) { 
     112        participants.remove(id); 
     113    } 
     114     
     115     
     116             
     117     
    94118} 
  • mcuWeb/src/java/org/murillo/mcuWeb/ConferenceMngr.java

    r18 r23  
    2424import java.net.MalformedURLException; 
    2525import java.util.HashMap; 
    26 import java.util.Vector; 
     26import java.util.Iterator; 
    2727import java.util.logging.Level; 
    2828import java.util.logging.Logger; 
     
    3636public class ConferenceMngr extends Object implements Serializable { 
    3737 
    38     private Vector<MediaMixer> mixers; 
    39     private HashMap<String, Conference> conferences; 
     38    private HashMap<String,MediaMixer> mixers; 
     39    private HashMap<String,Conference> conferences; 
     40    private HashMap<String,Profile> profiles; 
    4041 
    4142    public ConferenceMngr() { 
    4243        //Create arrays 
    43         mixers = new Vector<MediaMixer>(); 
    44         conferences = new HashMap<String, Conference>(); 
    45     } 
    46  
    47     public Conference createConference(String name,Integer mixerId) { 
     44        mixers = new HashMap<String,MediaMixer>(); 
     45        conferences = new HashMap<String,Conference>(); 
     46        profiles = new HashMap<String,Profile>(); 
     47    } 
     48 
     49    public Conference createConference(String name,String did, String mixerId,String profileId) { 
    4850        Integer confId; 
    4951        Conference conf = null; 
     
    5153        MediaMixer mixer = mixers.get(mixerId); 
    5254        try { 
     55            //Get profile 
     56            Profile profile = profiles.get(profileId); 
    5357            //Create conference 
    5458            confId = mixer.CreateConference(name); 
    5559            //Create conference object 
    56             conf = new Conference(confId, name, mixer); 
     60            conf = new Conference(confId, name, did, mixer, profile); 
    5761            //Lock conferences 
    5862            synchronized (conferences) { 
     
    8185    } 
    8286     
    83     public Vector<MediaMixer> getMcus() { 
     87    public HashMap<String,MediaMixer> getMcus() { 
    8488        return mixers; 
    8589    } 
     
    8791    public HashMap<String, Conference> getConferences() { 
    8892        return conferences; 
     93    } 
     94     
     95    public HashMap<String, Profile> getProfiles() { 
     96        return profiles; 
    8997    } 
    9098 
     
    123131            //Get conference for participant 
    124132            Conference conf = part.getConference(); 
     133            //Get default profile 
     134            Profile profile = conf.getProfile(); 
    125135            //Get mixer for conference 
    126136            MediaMixer mixer = conf.getMixer(); 
     
    129139            Integer partId = part.getId(); 
    130140            //Setup audio & video 
    131             mixer.SetAudioCodec(confId, partId, MediaMixer.PCMU); 
    132             mixer.SetVideoCodec(confId, partId, MediaMixer.H263_1998, MediaMixer.QCIF, 15, 512, 1, 31); 
     141            mixer.SetAudioCodec(confId, partId, part.getAudioCodec()); 
     142            mixer.SetVideoCodec(confId, partId, part.getVideoCodec(), profile.getVideoSize() , profile.getVideoFPS(), profile.getVideoBitrate(), profile.getVideoQmin(), profile.getVideoQmax()); 
    133143            //Send video & audio 
    134144            mixer.StartSendingAudio(confId, partId, part.getSendIp(), part.getSendAudioPort()); 
     
    152162 
    153163    public String getMappedConference(String uri) { 
    154         //Return first conference 
    155         return conferences.keySet().iterator().next(); 
     164        //Get iterator 
     165        Iterator<Conference> itConf = conferences.values().iterator(); 
     166        //Loop  
     167        while(itConf.hasNext()) { 
     168            //Get conference 
     169            Conference conf = itConf.next(); 
     170            //Check did 
     171            if(uri.equals(conf.getDID())) 
     172                //Return conference 
     173                return conf.getUID(); 
     174        } 
     175        //No conference 
     176        return null; 
    156177    } 
    157178     
     
    276297        MediaMixer mixer = new MediaMixer(name,url,ip); 
    277298        //Append 
    278         mixers.add(mixer); 
     299        mixers.put(mixer.getUID(),mixer); 
    279300        //Exit 
    280301        return mixer; 
    281302    } 
    282  
     303    public Profile addProfile(String name, Integer videoSize, Integer videoBitrate, Boolean videoBitrateStrict, Integer videoFPS, Integer videoQmin, Integer videoQmax) 
     304    { 
     305        //Create Profile 
     306        Profile profile = new Profile(name, videoSize, videoBitrate, videoBitrateStrict, videoFPS, videoQmin, videoQmax); 
     307        //Append 
     308        profiles.put(profile.getUID(),profile); 
     309        //Exit 
     310        return profile; 
     311    } 
     312     
    283313    public void removeParticipant(Participant part) { 
    284314        //Get conference 
     
    298328    } 
    299329 
     330    void setCompositionType(String confId, Integer compType, Integer size, String profileId) { 
     331        //Get conference 
     332        Conference conf = conferences.get(confId); 
     333        //Get Mixer 
     334        MediaMixer mixer = conf.getMixer(); 
     335        //Get profile 
     336        Profile profile = profiles.get(profileId); 
     337        //Set composition type 
     338        try { 
     339            mixer.SetCompositionType(conf.getId(), compType, size); 
     340        } catch (XmlRpcException ex) { 
     341            ex.printStackTrace(); 
     342        } 
     343        //Set values in conference 
     344        conf.setCompType(compType); 
     345        conf.setSize(size); 
     346        conf.setProfile(profile); 
     347    } 
     348    
    300349} 
  • mcuWeb/src/java/org/murillo/mcuWeb/MCUHttpServlet.java

    r18 r23  
    7070            Logger.getLogger("global").log(Level.SEVERE, null, ex); 
    7171        } 
     72        //Create default profiles 
     73        confMngr.addProfile("High Quality",MediaMixer.CIF,2048,false,30,2,6); 
     74        confMngr.addProfile("Medium Quality", MediaMixer.CIF,512,true,15,2,8); 
     75        confMngr.addProfile("Low Quality", MediaMixer.QCIF,128,true,10,4,12); 
     76         
    7277    } 
    7378     
     
    106111        if (method.equals("createConference")) { 
    107112            //Get parameters 
    108             String  name     = request.getParameter("name"); 
    109             Integer mixerId = Integer.parseInt(request.getParameter("mixerId")); 
     113            String name      = request.getParameter("name"); 
     114            String did       = request.getParameter("did"); 
     115            String mixerId   = request.getParameter("mixerId"); 
     116            String profileId = request.getParameter("profileId"); 
    110117            Integer compType = Integer.parseInt(request.getParameter("compType")); 
    111118            //Call 
    112             Conference conf = createConference(name,mixerId,compType); 
     119            Conference conf = createConference(name,did,mixerId,compType,profileId); 
    113120            //Redirect 
    114121            response.sendRedirect("/mcuWeb/conference.jsp?uid=" + conf.getUID()); 
     
    140147            //Redirect 
    141148            response.sendRedirect("/mcuWeb"); 
    142              
     149         } else if (method.equals("setCompositionType")) { 
     150            //Get parameters 
     151            String  confId = request.getParameter("confId"); 
     152            Integer compType  = Integer.parseInt(request.getParameter("compType")); 
     153            Integer size = Integer.parseInt(request.getParameter("size")); 
     154            String  profileId = request.getParameter("profileId"); 
     155            //Call 
     156            setCompositionType(confId,compType,size,profileId); 
     157            //Redirect 
     158            response.sendRedirect("/mcuWeb/conference.jsp?uid=" + confId); 
    143159        } else { 
    144160            response.setContentType("text/html;charset=UTF-8"); 
     
    171187    } 
    172188 
    173     private Conference createConference(String name, Integer mixerId, Integer compType) { 
     189    private Conference createConference(String name, String did, String mixerId, Integer compType,String profileId) { 
    174190        //Create conference 
    175         return confMngr.createConference(name,mixerId); 
     191        return confMngr.createConference(name,did,mixerId,profileId); 
    176192    } 
    177193 
     
    220236    } 
    221237 
     238    private void setCompositionType(String confId, Integer compType, Integer size, String profileId) { 
     239       //Set composition type 
     240       confMngr.setCompositionType(confId,compType,size,profileId); 
     241    } 
     242 
    222243} 
  • mcuWeb/src/java/org/murillo/mcuWeb/MCUSipServlet.java

    r18 r23  
    3333import javax.servlet.sip.SipSessionEvent; 
    3434import javax.servlet.sip.SipSessionListener; 
     35import javax.servlet.sip.SipURI; 
    3536 
    3637/** 
     
    7172                return; 
    7273            } 
    73                      
     74            //Get caller 
     75            SipURI uri = (SipURI) request.getRequestURI(); 
    7476            //Get default conference 
    75             String confId = confMngr.getMappedConference("caller"); 
     77            String confId = confMngr.getMappedConference(uri.getUser()); 
    7678            //Get sip session 
    7779            SipSession session = request.getSession(); 
     
    152154    } 
    153155 
    154     public void sessionCreated(SipSessionEvent session) { 
    155  
    156         Logger.getLogger("global").log(Level.WARNING, "sessionCreated!"); 
     156    public void sessionCreated(SipSessionEvent event) { 
     157        Logger.getLogger("global").log(java.util.logging.Level.WARNING, "sessionCreated!"); 
     158        try { 
     159            //Set session handler 
     160            event.getSession().setHandler("MCUSipServlet"); 
     161        } catch (ServletException ex) { 
     162            Logger.getLogger("global").log(Level.SEVERE, "Could not set session handler", ex); 
     163        } 
    157164    } 
    158165 
  • mcuWeb/src/java/org/murillo/mcuWeb/MediaMixer.java

    r16 r23  
    5252        return ip; 
    5353    } 
     54     
     55    public String getUID() { 
     56        return name+"@"+url; 
     57    } 
    5458} 
  • mcuWeb/web/conference.jsp

    r21 r23  
    5656<fieldset style="width:48%;"> 
    5757    <legend><img src="icons/image.png"> Conference</legend> 
    58         <table class="form" method="POST" action="controller/setCompositionType"> 
    59             <form> 
     58        <table class="form"> 
     59            <form method="POST" action="controller/setCompositionType"> 
     60            <input type="hidden" name="confId" value="<%=conf.getUID()%>"> 
    6061            <tr> 
    6162                <td>Name:</td> 
    6263                <td><%=conf.getName()%></td> 
     64            </tr> 
     65            <tr> 
     66                <td>DID:</td> 
     67                <td><%=conf.getDID()%></td> 
    6368            </tr> 
    6469            <tr> 
     
    6974                <td>Composition:</td> 
    7075                <td><select name="compType" value="<%=conf.getCompType()%>"> 
    71                     <option value="0">Mosaic 1x1 
    72                     <option value="1">Mosaic 2x2 
    73                     <option value="2">Mosaic 3x3 
     76                    <option value="0" <%=conf.getCompType()==0?"selected":""%>>Mosaic 1x1 
     77                    <option value="1" <%=conf.getCompType()==1?"selected":""%>>Mosaic 2x2 
     78                    <option value="2" <%=conf.getCompType()==2?"selected":""%>>Mosaic 3x3 
    7479                    </select> 
    7580                </td> 
     
    7883                <td>Size</td> 
    7984                <td><select name="size" value="<%=conf.getSize()%>"> 
    80                     <option value="0">QCIF 
    81                     <option value="1">CIF 
     85                    <option value="0" <%=conf.getSize()==0?"selected":""%>>QCIF 
     86                    <option value="1" <%=conf.getSize()==1?"selected":""%>>CIF 
    8287                    </select> 
     88                </td> 
     89            </tr> 
     90            <tr> 
     91                <td>Default profile:</td> 
     92                <td><select name="profileId"> 
     93                     <% 
     94                        //Get profiles 
     95                        Iterator<org.murillo.mcuWeb.Profile> itProf = confMngr.getProfiles().values().iterator(); 
     96                        //Loop  
     97                        while(itProf.hasNext()) { 
     98                            // Get mixer 
     99                            org.murillo.mcuWeb.Profile profile = itProf.next(); 
     100                            //If it's the selected profile 
     101                            if (profile.getUID().equals(conf.getProfile().getUID())) { 
     102                                %><option value="<%=profile.getUID()%>" selected><%=profile.getName()%><% 
     103                            } else { 
     104                                %><option value="<%=profile.getUID()%>"><%=profile.getName()%><% 
     105                            } 
     106                        } 
     107                    %> 
    83108                </td> 
    84109            </tr> 
  • mcuWeb/web/createConference.jsp

    r21 r23  
    11<%@page contentType="text/html"%> 
    22<%@page pageEncoding="UTF-8"%> 
    3 <%@page import="java.util.Vector"%>  
     3<%@page import="java.util.Iterator"%>  
    44<jsp:useBean id="confMngr" class="org.murillo.mcuWeb.ConferenceMngr" scope="application" /> 
    55<fieldset> 
     
    1212            </tr> 
    1313            <tr> 
     14                <td>DID:</td> 
     15                <td><input type="text" name="did"></td> 
     16            </tr> 
     17            <tr> 
    1418                <td>MediaMixer:</td> 
    1519                <td><select name="mixerId"> 
    1620                    <% 
    1721                        //Get mixers 
    18                         Vector<org.murillo.mcuWeb.MediaMixer> mixers = confMngr.getMcus(); 
    19                         //Loop 
    20                         for (int i = new Integer(0);i<mixers.size();i++)  { 
    21                                %><option value="<%=i%>"><%=mixers.get(i).getName()%><% 
     22                        Iterator<org.murillo.mcuWeb.MediaMixer> it = confMngr.getMcus().values().iterator(); 
     23                        //Loop  
     24                        while(it.hasNext()) { 
     25                            // Get mixer 
     26                            org.murillo.mcuWeb.MediaMixer mixer = it.next(); 
     27                            %><option value="<%=mixer.getUID()%>"><%=mixer.getName()%><% 
    2228                        } 
    2329                    %> 
     
    3339            </tr> 
    3440            <tr> 
    35                 <td>Size:</td> 
    36                 <td><select name="sizw"> 
     41                <td>Mosaic size:</td> 
     42                <td><select name="size"> 
    3743                        <option value="0">QCIF 
    3844                        <option value="1">CIF 
    3945                    </select> 
     46                </td> 
     47            </tr> 
     48             <tr> 
     49                <td>Default profile:</td> 
     50                <td><select name="profileId"> 
     51                     <% 
     52                        //Get profiles 
     53                        Iterator<org.murillo.mcuWeb.Profile> itProf = confMngr.getProfiles().values().iterator(); 
     54                        //Loop  
     55                        while(itProf.hasNext()) { 
     56                            // Get mixer 
     57                            org.murillo.mcuWeb.Profile profile = itProf.next(); 
     58                            %><option value="<%=profile.getUID()%>"><%=profile.getName()%><% 
     59                        } 
     60                    %> 
    4061                </td> 
    4162            </tr> 
  • mcuWeb/web/index.jsp

    r18 r23  
    88    var param = {uid:uid}; 
    99    return callController("removeConference",param); 
     10} 
     11function removeMixer(uid) 
     12{ 
     13    var param = {uid:uid}; 
     14    return callController("removeMixer",param); 
    1015} 
    1116</script>     
     
    2126        <% 
    2227        //Get mixer iterator 
    23         Iterator<org.murillo.mcuWeb.MediaMixer> it = confMngr.getMcus().iterator(); 
     28        Iterator<org.murillo.mcuWeb.MediaMixer> it = confMngr.getMcus().values().iterator(); 
    2429        //Loop  
    2530        while(it.hasNext()) { 
    2631            // Get mixer 
    27            org.murillo.mcuWeb. MediaMixer mm = it.next(); 
     32           org.murillo.mcuWeb.MediaMixer mm = it.next(); 
    2833            //Print values 
    2934            %> 
     
    3237            <td><%=mm.getUrl()%></td> 
    3338            <td> Up and running...</td> 
    34             <td></td> 
     39            <td><a href="#" onClick="removeMixer('<%=mm.getUID()%>');return false;"><img src="icons/bin_closed.png"><span>Remove conference</span></a></td> 
    3540        </tr><% 
    3641        } 
     
    3944    <form><input type="submit" class="add" onClick="document.location.href='addMixer.jsp';return false;" value="Add"></form>     
    4045</fieldset> 
     46<fieldset> 
     47    <legend><img src="icons/table_multiple.png"> Profile List</legend> 
     48        <table class="list"> 
     49        <tr> 
     50            <th>Name</th> 
     51            <th>Parameters</th> 
     52            <th>Actions</th> 
     53        </tr> 
     54        <% 
     55        //Get mixer iterator 
     56        Iterator<org.murillo.mcuWeb.Profile> itProf = confMngr.getProfiles().values().iterator(); 
     57        //Loop  
     58        while(itProf.hasNext()) { 
     59            // Get mixer 
     60           org.murillo.mcuWeb.Profile profile = itProf.next(); 
     61            //Print values 
     62            %> 
     63        <tr> 
     64            <td><%=profile.getName()%></td> 
     65            <td><%  
     66                switch(profile.getVideoSize()) 
     67                { 
     68                    case 0: 
     69                        %>CIF<% 
     70                        break; 
     71                    case 1: 
     72                        %>QCIF<% 
     73                        break; 
     74                } 
     75                %><%=profile.getVideoBitrate()%>Kbs <%=profile.getVideoFPS()%>fps</td> 
     76            <td> 
     77<a href="#" onClick="removeProfile('<%=profile.getUID()%>');return false;"><img src="icons/bin_closed.png"><span>Remove conference</span></a> 
     78            </td> 
     79        </tr><% 
     80        } 
     81        %> 
     82    </table> 
     83    <form><input class="add" type="button" onClick="document.location.href='createProfile.jsp';return false;" value="Create"></form> 
     84</fieldset> 
    4185<% 
    42     //Only if there are available mixers 
    43     if (confMngr.getMcus().size()>0) { 
     86    //Only if there are available mixers and profiles 
     87    if (confMngr.getMcus().size()>0 && confMngr.getProfiles().size()>0) { 
    4488%> 
    4589<fieldset> 
     
    4892        <tr> 
    4993            <th>ID</th> 
     94            <th>DID</th> 
     95            <th>#</th> 
    5096            <th>Name</th> 
    5197            <th>Mixer</th> 
     
    63109        <tr> 
    64110            <td><%=conf.getId()%></td> 
     111            <td><%=conf.getDID()%></td> 
     112            <td><%=conf.getNumParcitipants()%></td> 
    65113            <td><%=conf.getName()%></td> 
    66114            <td><%=conf.getMixer().getName()%></td> 
Copyright 2006 - Sergio García Murillo
Powered by Trac - Edgewall Software