IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

API standards et tierces Android Discussion :

Web service pour la multivisualisation de flux sous Android


Sujet :

API standards et tierces Android

  1. #1
    Membre du Club
    Femme Profil pro
    Inscrit en
    Mars 2011
    Messages
    95
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Mars 2011
    Messages : 95
    Points : 67
    Points
    67
    Par défaut Web service pour la multivisualisation de flux sous Android
    Bonjour,
    je suis entrain de faire mon projet de fin d'étude (vidéo surveillance mobile sous android)
    j'ai réussi à faire la visualisation d'une caméra ip selon le choisi à travers une listeview de caméra ip ( récupéré de la base de données)
    mais si le choisie (de 2 camera jusqu'a 6) il affiche uniquement le flux la dernier cirulent en boucle entre les différentes position (nombre de position est égale à celui de caméra choisie), mon probléme se manifeste dans le web service qui recupére l'adresse ip de tout les caméras choisie dans la classe
    public static Mjpegsample read(String url)
    mais n'affiche pas le flux à cause de la classe
    public Bitmap readMjpegFrame() throws IOException
    je n'arrive pas la adapté correctemnet, y a -t- qlq qui peut m'aider. merci d'avance
    voila mon code:
    classe visualiser flux:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    package com.andro.surv;
     
    import java.util.ArrayList;
     
     
    import java.util.HashMap;
    import android.app.Activity;
     
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.AdapterView;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.GridView;
    import android.widget.ListView;
    import android.widget.SimpleAdapter;
    import android.widget.Toast;
    import android.widget.AdapterView.OnItemClickListener;
     
    public class visualiserflux_j  extends Activity implements OnClickListener{
     
    	//public MjpegView mv;
    	//public Mjpegsample  mpegs ;
    	public MjpegMultiView mmv ;
    	boolean affiche = false;
    	private Button r1;
        ListView listV;
    	private int checkedItem=0;
        String Hostrecuper;
    	String Portrecuper;
    	cameraBDD cameraBdd = new cameraBDD(this);
    	public ArrayList<String> ListHostCam =  new ArrayList<String>();
    	public ArrayList<String> ListPortCam =  new ArrayList<String>();
    	public ArrayList<String> ListUsernameCam =  new ArrayList<String>();
    	public ArrayList<String> ListPswCam =  new ArrayList<String>();
    	int k=0;
     
     
    	 @Override
    	 public void onCreate(Bundle savedInstanceState) {
    	        super.onCreate(savedInstanceState);
    	        setContentView(R.layout.visualiserflux);
    	        r1 = (Button) findViewById(R.id.bVTR);       
    	        r1.setOnClickListener(this);
    	        /********** Actualisation de la liste des caméras *********/
    	        try{
              	  cameraBdd.open();
                  ArrayList<HashMap<String, String>> listItem = cameraBdd.mapCameras();
                  SimpleAdapter mSchedule = new SimpleAdapter(getBaseContext(), listItem, R.layout.affichageitem1,
                  new String[] {"img", "id", "name", "host"}, new int[] {R.id.img, R.id.id, R.id.type, R.id.host});
                  listV.setAdapter(mSchedule);
                  cameraBdd.close();
     
              }catch(Exception e){
                  Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_LONG).show();
              }
     
    	        listV =(ListView) findViewById(R.id.listV);
    	        cameraBdd.open();
    	        ArrayList<HashMap<String, String>> listItem = cameraBdd.mapCameras();
    	        SimpleAdapter mSchedule = new SimpleAdapter(this.getBaseContext(), listItem, R.layout.affichageitem1,
    	               new String[] {"img", "id", "name", "host"}, new int[] {R.id.img, R.id.id, R.id.type, R.id.host});
    	        listV.setAdapter(mSchedule);
    	        cameraBdd.close();
     
    	        //Associer l'venemetn lorsque on clique sur un contact
    	        listV.setOnItemClickListener(new OnItemClickListener() {
    	        public void onItemClick(AdapterView<?> parent, View view,
    	        int position, long id) {
    	                    try{
    	                     HashMap<String, String> map = (HashMap<String, String>) listV.getItemAtPosition(position);
     
    	                        checkedItem=position;
    	                        listV.setItemChecked(position, true);
    	                        ListHostCam.add(map.get("host"));
    	                        ListPortCam.add(map.get("port"));
    	                        ListUsernameCam.add(map.get("username"));
    	                        ListPswCam.add(map.get("password"));                       
    	                   }catch(Exception e){
    	                    Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    	                    }                
    	            }
    	       });
     
    	 }
     
    	 public void ConnectCam(String username,String psw,String IP,String PORT, int nbcam) {
     
    		 String URL;
    		 if ((username=="")&&(psw=="")) // camera public n'ayant pas un username et un psw
    		 {
    			URL = "http://"+IP+":"+PORT+"/axis-cgi/" +"mjpg/video.cgi?resolution=640x480";
    	}
    		 else URL = "http://"+username+":"+psw+"@"+IP+":"+PORT+"/axis-cgi/" +"mjpg/video.cgi?resolution=640x480";
     
    		 mmv= new  MjpegMultiView(getBaseContext());
     
     
    			//Permét d'afficher l'objet multivisualisation//			
    			    setContentView(mmv);
    		        mmv.setDisplayNbCam(nbcam);
    				mmv.setSource( Mjpegsample.read(URL.trim())); //LA SOURCE DE MJPEG
    				mmv.setDisplayMode(MjpegMultiView.SIZE_BEST_FIT);
     
    				mmv.showFps(false);
    				affiche = true;	
     
    		}
     
    		@Override
    		public void onClick(View arg0) {
     
    			for(int j=0; j<ListHostCam.size();j++)
    				 ConnectCam(ListUsernameCam.get(j),ListPswCam.get(j),ListHostCam.get(j),ListPortCam.get(j),ListHostCam.size() );
     
    		}
    	}
    classe MjpegMultiView
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    package com.andro.surv;
     
    import java.io.IOException;
    import java.util.ArrayList;
    import android.app.AlertDialog;
    import android.content.Context;
    import android.content.DialogInterface;
    import android.graphics.Bitmap;
    import android.graphics.Canvas;
    import android.graphics.Color;
    import android.graphics.Paint;
    import android.graphics.PorterDuff;
    import android.graphics.PorterDuffXfermode;
    import android.graphics.Rect;
    import android.graphics.Typeface;
    import android.util.AttributeSet;
    import android.view.SurfaceHolder;
    import android.view.SurfaceView;
    import android.widget.Toast;
     
     
    public class MjpegMultiView extends SurfaceView implements SurfaceHolder.Callback {
     
    	public MjpegMultiView(Context context) {
    		super(context);
    		init(context); 		
    	}
     
    	public MjpegMultiView(Context context, AttributeSet attrs) {
    		super(context, attrs);
    		init(context); 
    	}
     
    	public final static int POSITION_UPPER_LEFT  = 9;
        public final static int POSITION_UPPER_RIGHT = 3;
        public final static int POSITION_LOWER_LEFT  = 12;
        public final static int POSITION_LOWER_RIGHT = 6;
     
        public final static int SIZE_STANDARD   = 1; 
        public final static int SIZE_BEST_FIT   = 4;
        public final static int SIZE_FULLSCREEN = 8;
     
        private static final String TAG = "MOT_MyActivity"; /* define log tag*/
     
     
        private MjpegMultiViewThread thread;
        private Mjpegsample mIn = null;    
        private boolean showFps = false;
        private boolean mRun = false;
        private boolean surfaceDone = false;    
        private Paint overlayPaint;
        private int overlayTextColor;
        private int overlayBackgroundColor;
        private int ovlPos;
        private int dispWidth;
        private int dispHeight;
        private int displayMode;
        public int nbCamVisualiser;
        public ArrayList<Rect> ListCoordView =  new ArrayList<Rect>();
        int k=0; 
        public class MjpegMultiViewThread extends Thread {
            private SurfaceHolder mSurfaceHolder;
            private int frameCounter = 0;
            private long start;
            private Bitmap ovl;
     
            public MjpegMultiViewThread(SurfaceHolder surfaceHolder, Context context) {
            	mSurfaceHolder = surfaceHolder; 
     
        		}
     
     
            public void setSurfaceSize(int width, int height) {
                synchronized(mSurfaceHolder) {
                    dispWidth = width;
                    dispHeight = height;
                }
            }
     
            private Bitmap makeFpsOverlay(Paint p, String text) {
                Rect b = new Rect();
                p.getTextBounds(text, 0, text.length(), b);
                int bwidth  = b.width()+2;
                int bheight = b.height()+2;
                Bitmap bm = Bitmap.createBitmap(bwidth, bheight, Bitmap.Config.ARGB_8888);
                Canvas c = new Canvas(bm);
                p.setColor(overlayBackgroundColor);
                c.drawRect(0, 0, bwidth, bheight, p);
                p.setColor(overlayTextColor);
                c.drawText(text, -b.left+1, (bheight/2)-((p.ascent()+p.descent())/2)+1, p);
                return bm;        
     
            }
     
     
    /////////////////////////////////////////////        
          public void run() {
                start = System.currentTimeMillis();
                PorterDuffXfermode mode = new PorterDuffXfermode(PorterDuff.Mode.DST_OVER);
                Bitmap bm;
                int width;
                int height;
                ArrayList<Rect> destRect;
                Canvas c = null;
                Paint p = new Paint();
                String fps = "";
                int nbcamVis;
                while (mRun) {
                    if(surfaceDone) {
                        try {
                            c = mSurfaceHolder.lockCanvas();
                            synchronized (mSurfaceHolder) {
                                try {
                                   bm = mIn.readMjpegFrame();
                                		   //.get(k);
                                   destRect = destRect(bm.getWidth(),bm.getHeight(),getDisplayNbCam() );
                                    c.drawColor(Color.BLACK);
                                  // c.drawBitmap(bm, null, p);
                                    //for(int k=0; k<ListCoordView.size();k++)
                                   // {
                                    	c.drawBitmap(bm, null, destRect.get(k), p);
                                    	//}
                                     k++;
     
                                }
                                catch (IOException e) {}
                            }
                        } 
                        finally { if (c != null) 
                        	mSurfaceHolder.unlockCanvasAndPost(c); }
                    }
                }
            }
        }
     
        public ArrayList<Rect>  destRect(int bmw, int bmh, int nbCam) {
            int tempx;
            int tempy;
     
            if (displayMode == MjpegMultiView.SIZE_BEST_FIT) {
                float bmasp = (float) bmw / (float) bmh;
                bmw = dispWidth;
                bmh = (int) (dispWidth / bmasp);
                if (bmh > dispHeight) {
                    bmh = dispHeight;
                    bmw = (int) (dispHeight * bmasp);
                }
                tempx = (dispWidth / 2) - (bmw / 2);
                tempy = (dispHeight / 2) - (bmh / 2);
     
                if (nbCam ==1) {
                  	 ListCoordView.add( new Rect(tempx, tempy, bmw + tempx, bmh + tempy));
                  	 return  ListCoordView;}
     
                if (nbCam ==2) {
               	ListCoordView.add(new Rect(tempx, tempy, (bmw/2) + tempx, bmh+ tempy)); 
                ListCoordView.add(new Rect((bmw/2) + tempx,tempy, bmw + tempx, bmh+ tempy));
                   return  ListCoordView;}
     
                if  (nbCam ==3 )
               {ListCoordView.add(new Rect(tempx, tempy, (bmw/2) + tempx,bmh/2+ tempy));
               ListCoordView.add(new Rect((bmw/2) + tempx,tempy, bmw + tempx, bmh/2+ tempy));
               ListCoordView.add(new Rect(tempx,bmh/2+ tempy, tempx+bmw/2, tempy+bmh));
               return  ListCoordView;}
     
                if (nbCam ==4)
                {  ListCoordView.add(new Rect(tempx, tempy, (bmw/2) + tempx,bmh/2+ tempy));
                   ListCoordView.add(new Rect((bmw/2) + tempx,tempy, bmw + tempx, bmh/2+ tempy));
                   ListCoordView.add(new Rect(tempx,bmh/2+ tempy, tempx+bmw/2, tempy+bmh));
                   ListCoordView.add(new Rect(tempx+bmw/2,tempy+bmh/2, tempx+bmw,tempy+bmh));
                    return  ListCoordView;}	
                if (nbCam==5)
                {ListCoordView.add(new Rect(tempx, tempy,tempx+(bmw/3),tempy+bmh/2));
           		ListCoordView.add(new Rect(tempx+(bmw/3),tempy,tempx+bmw*2/3,tempy+bmh/2));
           		ListCoordView.add(new Rect(tempx+bmw*2/3,tempy,tempx+bmw,tempy+bmh/2));
           		ListCoordView.add(new Rect(tempx,tempy+bmh/2,tempx+bmw/3,tempy+bmh));
           		ListCoordView.add(new Rect(tempx+bmw/3,tempy+bmh/2,tempx+bmw*2/3,tempy+bmh));
           		 return  ListCoordView;	
                }
                 if (nbCam==6)
                 {
               		ListCoordView.add(new Rect(tempx, tempy,tempx+(bmw/3),tempy+bmh/2));
               		ListCoordView.add(new Rect(tempx+(bmw/3),tempy,tempx+bmw*2/3,tempy+bmh/2));
               		ListCoordView.add(new Rect(tempx+bmw*2/3,tempy,tempx+bmw,tempy+bmh/2));
               		ListCoordView.add(new Rect(tempx,tempy+bmh/2,tempx+bmw/3,tempy+bmh));
               		ListCoordView.add(new Rect(tempx+bmw/3,tempy+bmh/2,tempx+bmw*2/3,tempy+bmh));
               		ListCoordView.add(new Rect(tempx+bmw*2/3,tempy+bmh/2,tempx+bmw,tempy+bmh));
               		 return  ListCoordView;}
     
            }
     
            return null;
        }
     
        private void init(Context context) {
            SurfaceHolder holder = getHolder();
            holder.addCallback(this);
            thread = new MjpegMultiViewThread(holder, context);
            setFocusable(true);
            overlayPaint = new Paint();
            overlayPaint.setTextAlign(Paint.Align.LEFT);
            overlayPaint.setTextSize(12);
            overlayPaint.setTypeface(Typeface.DEFAULT);
            overlayTextColor = Color.WHITE;
            overlayBackgroundColor = Color.BLACK;
            ovlPos = MjpegMultiView.POSITION_LOWER_RIGHT;
            displayMode = MjpegMultiView.SIZE_STANDARD;
            dispWidth = getWidth();
            dispHeight = getHeight();
        }
     
        public void startPlayback() { 
        // Mon code à éxécuter
       if(mIn != null) {
         mRun = true; 
         surfaceDone= true; // a été ajouté
         thread.start();}   
        }
     
        public void stopPlayback() { 
            mRun = false;
            boolean retry = true;
            while(retry) {
                try {
                    thread.join();
                    retry = false;
                } 
                catch (InterruptedException e) {}
            }
        }
     
     
        public void surfaceChanged(SurfaceHolder holder, int f, int w, int h) {
        	thread.setSurfaceSize(w, h); 
        }
     
        public void surfaceDestroyed(SurfaceHolder holder) { 
            surfaceDone = false; 
            stopPlayback(); 
        }
     
     
     
     
        public void surfaceCreated(SurfaceHolder holder) {
        	surfaceDone = true; }
     
        public void showFps(boolean b) { showFps = b;}
     
        public void setSource(Mjpegsample source) {  
        	mIn =source;
        	startPlayback();   
       }
     
        public void setOverlayPaint(Paint p) { overlayPaint = p; }
     
        public void setOverlayTextColor(int c) { overlayTextColor = c; }
     
        public void setOverlayBackgroundColor(int c) { overlayBackgroundColor = c; }
     
        public void setOverlayPosition(int p) { ovlPos = p; }
     
        public void setDisplayMode(int s) { 
        	displayMode = s; }
        public void setDisplayNbCam(int nbCam){ 
        	nbCamVisualiser= nbCam;}
        public int getDisplayNbCam(){
        	return nbCamVisualiser;}
     
     
    }
    classe Mjpegsample:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    package com.andro.surv;
     
     
    import java.io.BufferedInputStream;
     
    import java.io.ByteArrayInputStream;
    import java.io.DataInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.net.URI;
    import java.util.ArrayList;
    import java.util.Properties;
     
    import org.apache.http.HttpResponse;
    import org.apache.http.client.ClientProtocolException;
    import org.apache.http.client.methods.HttpGet;
    import org.apache.http.impl.client.DefaultHttpClient;
     
    import android.app.AlertDialog;
    import android.content.DialogInterface;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    public class Mjpegsample extends DataInputStream {
    	private final byte[] SOI_MARKER = { (byte) 0xFF, (byte) 0xD8 };
        private final byte[] EOF_MARKER = { (byte) 0xFF, (byte) 0xD9 };
        private final String CONTENT_LENGTH = "Content-Length";
        private final static int HEADER_MAX_LENGTH = 100;
        private final static int FRAME_MAX_LENGTH = 40000 + HEADER_MAX_LENGTH;
        private int mContentLength = -1;
        public String urlcam;
       public  ArrayList<Bitmap> ListBitmap = new ArrayList<Bitmap>();
     
        public static Mjpegsample read(String url) {
            HttpResponse res;
            DefaultHttpClient httpclient = new DefaultHttpClient();		
            try {
                res = httpclient.execute(new HttpGet(URI.create(url)));
               return new Mjpegsample(res.getEntity().getContent());
     
            } catch (ClientProtocolException e) {
            } 
            	catch (IOException e) {}
         return null;
        }
        public Mjpegsample(InputStream in) {
        	super(new BufferedInputStream(in, FRAME_MAX_LENGTH)); 
        	}
        private int getEndOfSeqeunce(DataInputStream in, byte[] sequence) throws IOException {
            int seqIndex = 0;
            byte c;
            for(int i=0; i < FRAME_MAX_LENGTH; i++) {
                c = (byte) in.readUnsignedByte();
                if(c == sequence[seqIndex]) {
                    seqIndex++;
                    if(seqIndex == sequence.length) 
                    	return i + 1;
                } else seqIndex = 0;
            }
     
            return -1;
        }
        private int getStartOfSequence(DataInputStream in, byte[] sequence) throws IOException {
            int end = getEndOfSeqeunce(in, sequence);
            return (end < 0) ? (-1) : (end - sequence.length);
        }
        private int parseContentLength(byte[] headerBytes) throws IOException, NumberFormatException {
            ByteArrayInputStream headerIn = new ByteArrayInputStream(headerBytes);
            Properties props = new Properties();
            props.load(headerIn);
            return Integer.parseInt(props.getProperty(CONTENT_LENGTH));
        }	
       // public ArrayList<Bitmap>
        public Bitmap readMjpegFrame() throws IOException {
            mark(FRAME_MAX_LENGTH);
            int headerLen = getStartOfSequence(this, SOI_MARKER);
            reset();
            byte[] header = new byte[headerLen];
            readFully(header);
            try {
                mContentLength = parseContentLength(header);
            } catch (NumberFormatException nfe) { 
                mContentLength = getEndOfSeqeunce(this, EOF_MARKER); 
            }
            reset();
            byte[] frameData = new byte[mContentLength];
            skipBytes(headerLen);
            readFully(frameData);
            return BitmapFactory.decodeStream(new ByteArrayInputStream(frameData));}

  2. #2
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Août 2011
    Messages : 37
    Points : 29
    Points
    29
    Par défaut
    Bonjour ensienene,

    je dois pour mon projet de fin d'études également faire une application de vidéo surveillance sous android. Je suis bloquée à la première étape(afficher la caméra à partir des paramètres: ip, user,psw,port). J'ai l'habitude de développer en Java mais il s'agit de ma première application android. J'ai essayé ton code mais il me manque la classe cameraBDD. Pourrais-tu me l'envoyer ainsi que ton fichier layout.

    Merci d'avance,
    Pauline

  3. #3
    Membre du Club
    Femme Profil pro
    Inscrit en
    Mars 2011
    Messages
    95
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Mars 2011
    Messages : 95
    Points : 67
    Points
    67
    Par défaut
    boujour,
    Moi aussi, c'est mon premier projet android, il s'agit de mon projet de fin d’étude voila le code de la visualisation de flux de caméra ip sous android http://www.2shared.com/file/J306GxY3/surveillance.html

  4. #4
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Août 2011
    Messages : 37
    Points : 29
    Points
    29
    Par défaut
    Merci beaucoup,
    Il marche nickel ton code pour les caméras qui n'ont pas besoin d'identifiants(user + password) Pour les autres, je pense qu'il faut juste que j'encode les paramètres pour que ça marche.

  5. #5
    Membre du Club
    Femme Profil pro
    Inscrit en
    Mars 2011
    Messages
    95
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Mars 2011
    Messages : 95
    Points : 67
    Points
    67
    Par défaut
    Je ne suis pas nickel
    oui ça marche aussi
    si la caméra possède un user et un password il suffit de changer l'url à
    http://user:password@adresseIP:port/ ... le reste c'est le meme.
    Bon courage et bon chance

  6. #6
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Août 2011
    Messages : 37
    Points : 29
    Points
    29
    Par défaut
    ça j'avais essayé ca ne marchait pas j'ai du surcharger la méthode read de la sorte
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
     
     
        public static Mjpegsample read(String url,String user, String pass) {
            HttpResponse res;
            DefaultHttpClient httpclient = new DefaultHttpClient();		
            try {        	
                HttpUriRequest httpGet = new HttpGet(URI.create(url));
                String auth = android.util.Base64.encodeToString(
                		(user + ":" + pass).getBytes("UTF-8"), 
                		android.util.Base64.NO_WRAP
                	);
                httpGet.addHeader("Authorization", "Basic "+auth);
    	res = httpclient.execute(httpGet);
                return new Mjpegsample(res.getEntity().getContent());
     
            } catch (ClientProtocolException e) {
            } catch (IOException e) {}
            return null;
        }
    Et pour ton problème d'affichage, je pense que c'est dû à ta fonction run() de MjpegMultiViewThread. A l'intérieur t'appelle pour chaque itération
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    destRect(bm.getWidth(),bm.getHeight(),getDisplayNbCam() );
    Je pense que tu devrais appeler cette méthode quelque part avant de lancer ton thread, puisque les paramètres bm.getWidth ,bm.getHeight et getDisplayNbCam() ne changent pas au cours de l'execution.

  7. #7
    Membre du Club
    Femme Profil pro
    Inscrit en
    Mars 2011
    Messages
    95
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Mars 2011
    Messages : 95
    Points : 67
    Points
    67
    Par défaut
    J'ai resolue mon problème avec une autre mèthode
    Mais qu'est ce qui ne marche pas avec toi?

  8. #8
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Août 2011
    Messages : 37
    Points : 29
    Points
    29
    Par défaut
    C'est cool , c'était le problème des id + mdp mais je l'ai résolu avec le solution que j'ai posté précédemment. Comment tu as résolu ton problème d'affichage? Peux-tu poster la solution s'il te plait?

  9. #9
    Membre du Club
    Femme Profil pro
    Inscrit en
    Mars 2011
    Messages
    95
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Mars 2011
    Messages : 95
    Points : 67
    Points
    67
    Par défaut
    J'ai construit des .xml qui contienne des layouts (selon le nombre de caméras que je veux afficher) chaque layout fait appel à la classe MjpegView, puis à chaque fois j'appel le .xml selon le nombre de caméra que j'ai choisi pour être afficher.

  10. #10
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Août 2011
    Messages : 37
    Points : 29
    Points
    29
    Par défaut
    tu mets quel composant dans ton layout pour afficher la video? surfaceView?

  11. #11
    Membre du Club
    Femme Profil pro
    Inscrit en
    Mars 2011
    Messages
    95
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Mars 2011
    Messages : 95
    Points : 67
    Points
    67
    Par défaut
    voila le contenue du layout
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
      <info.lamatricexiste.network.MjpegView
            android:id="@+id/CameraView1"
            android:layout_width="319dp"
            android:layout_height="287dp"
            android:layout_gravity="center" />

    info.lamatricexiste.network représente le nom de mon package
    et MjpegView représente la classe qui implémente la surface de la vidéo

  12. #12
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Août 2011
    Messages : 37
    Points : 29
    Points
    29
    Par défaut
    Merci, mais j'ai trouvé une autre solution

  13. #13
    Membre du Club
    Femme Profil pro
    Inscrit en
    Mars 2011
    Messages
    95
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Mars 2011
    Messages : 95
    Points : 67
    Points
    67
    Par défaut
    de rien de t'en prie.

  14. #14
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Août 2011
    Messages : 37
    Points : 29
    Points
    29
    Par défaut
    Salut,
    J'ai pas mal avancé sur mon projet mais je fais face maintenant à un autre problème auquel t'aurais peut être une solution. Lorsque la surfaceview est affichée avec des cameras,comment peut-on faire pour mettre un bouton en dessous des videos(sans forcément passer par la touche menu)? Peut-on afficher une layout en dessous de l'affichage des caméras?

  15. #15
    Membre du Club
    Femme Profil pro
    Inscrit en
    Mars 2011
    Messages
    95
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Mars 2011
    Messages : 95
    Points : 67
    Points
    67
    Par défaut
    Il suffit que tu ajoute tous ce que tu veut ( layout, button,... ) dans le .xlm

  16. #16
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Août 2011
    Messages : 37
    Points : 29
    Points
    29
    Par défaut
    Merci encore une fois, je ne savais pas qu'on pouvait charger la classe MjpegView à partir du fichier xml, c'est ce que j'ai fait pour résoudre mon problème. Comme ça je peux ajouter d'autres widgets dans mon fichier xml.

  17. #17
    Expert éminent

    Avatar de Feanorin
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    4 589
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 4 589
    Points : 9 149
    Points
    9 149
    Par défaut
    Bonjour,

    Si votre problème est résolu merci de bien penser à cliquer sur le bouton en bas de la page .

  18. #18
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Août 2011
    Messages : 37
    Points : 29
    Points
    29
    Par défaut
    Salut ensinienne,

    Je viens te poser une question qui n'a rien à voir avec le sujet. J'utilise un toggleButton et je veux controler le changement du status du bouton suivant un certain nombre de critères. Quand ces critères sont remplis , je fais un setchecked(true) sur le bouton, et je peux afficher dans le log la valeur button.ischecked(), la valeur est bien mis à jour. Le problème est que l'état visuel du bouton ne change pas.

  19. #19
    Membre du Club
    Femme Profil pro
    Inscrit en
    Mars 2011
    Messages
    95
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Mars 2011
    Messages : 95
    Points : 67
    Points
    67
    Par défaut
    Je n'est jamais utilisé un toggleButton, amis je vous conseille d'utiliser le mode débug et les break point pour réssoudre votre problème. bon courage

  20. #20
    Membre à l'essai
    Femme Profil pro
    Ingénieur avant-vente
    Inscrit en
    Janvier 2013
    Messages
    25
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations professionnelles :
    Activité : Ingénieur avant-vente
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2013
    Messages : 25
    Points : 19
    Points
    19
    Par défaut ajouter un bouton en dessous de flux du camera
    Bonsoir
    est ce que vous pouvez m'expliquer comment ajouter un bouton en dessous de flux du camera ?
    Merci.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Web Service pour vérification de la TVA
    Par rob81 dans le forum VBA Access
    Réponses: 9
    Dernier message: 23/01/2023, 17h50
  2. Web Service pour vérifier un numéro INE
    Par Mose dans le forum XML/XSL et SOAP
    Réponses: 3
    Dernier message: 21/12/2019, 17h21
  3. Appel de procédure distante sous Android : les Web Services pour les nuls
    Par Hephaistos007 dans le forum API standards et tierces
    Réponses: 1
    Dernier message: 13/07/2015, 14h52
  4. Java et Vista / Web services pour les nuls
    Par Colargole dans le forum Général Java
    Réponses: 28
    Dernier message: 02/03/2008, 18h58
  5. Les Web Services pour access
    Par naphta dans le forum Contribuez
    Réponses: 0
    Dernier message: 08/01/2008, 22h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo